Opened 12 years ago
Closed 12 years ago
#2028 closed defect (fixed)
Problem in initial residuals
Reported by: | Christian Schubert | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | 1.9.0 |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: |
Description ¶
There is a problem with code generation in the initial residuals.
Consider the model
model TestInitial discrete Real T[3,3]; initial equation pre(T) = identity(3); equation when sample(1e-8, 1) then T = time*identity(3); end when; end TestInitial;
when simulating it, it gives the error messages
TestInitial.c: In function 'initial_residual': TestInitial.c:283: error: lvalue required as unary '&' operand TestInitial.c:283: warning: passing argument 1 of 'add_alloc_real_array' from incompatible pointer type C:/Projekte/OpenModelica/build//include/omc/real_array.h:150: note: expected 'const struct real_array_t *' but argument is of type 'modelica_real *' TestInitial.c:284: error: incompatible types when assigning to type 'double' from type 'real_array' TestInitial.c:292: error: lvalue required as unary '&' operand TestInitial.c:292: warning: passing argument 1 of 'add_alloc_real_array' from incompatible pointer type C:/Projekte/OpenModelica/build//include/omc/real_array.h:150: note: expected 'const struct real_array_t *' but argument is of type 'modelica_real *' TestInitial.c:293: error: incompatible types when assigning to type 'double' from type 'real_array' TestInitial.c:301: error: lvalue required as unary '&' operand TestInitial.c:301: warning: passing argument 1 of 'add_alloc_real_array' from incompatible pointer type C:/Projekte/OpenModelica/build//include/omc/real_array.h:150: note: expected 'const struct real_array_t *' but argument is of type 'modelica_real *' TestInitial.c:302: error: incompatible types when assigning to type 'double' from type 'real_array' TestInitial.c: In function 'eqFunction_3': TestInitial.c:322: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_5': TestInitial.c:336: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_7': TestInitial.c:350: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_9': TestInitial.c:364: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_11': TestInitial.c:378: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_13': TestInitial.c:392: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_15': TestInitial.c:406: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_17': TestInitial.c:420: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' TestInitial.c: In function 'eqFunction_19': TestInitial.c:434: error: incompatible types when assigning to type 'modelica_real' from type 'real_array' mingw32-make: *** [TestInitial.o] Error 1
It seems that the Frontend misses transforming a SUB_ARRAY into a SUB while expanding the matrix expressions.
Change History (7)
by , 12 years ago
Attachment: | TestInitial.mos added |
---|
comment:1 by , 12 years ago
Component: | Frontend → Backend |
---|
comment:2 by , 12 years ago
Component: | Backend → Frontend |
---|
Yes but, If you have a look at the pre call attributes return type you find
record<DAE.Type.T_ARRAY>
And this forces the code generation to use sub_array instead of sub.
comment:3 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Ok, it looks like it is not simplify that is wrong. Maybe it is in elaboration of pre.
comment:4 by , 12 years ago
Ok, I found the error in the frontend, but that's not the error that's triggered in the backend.
For each when-equation:
T[1,1] = time
, there are two functions generated. One that does
T[1,1] = pre(T[1,1])
(which is generated somewhere in the backend), and one that does T[1,1] = time
.
Unless also the type of the cref is wrong from the frontend...
comment:5 by , 12 years ago
From frontend (after my local changes; will be committed soon):
class TestInitial discrete Real T[1,1]; ... discrete Real T[3,3]; initial equation /*Real*/ pre(/*Real*/ T[1,1]) = 1.0; ... /*Real*/ pre(/*Real*/ T[3,3]) = 1.0; equation when /*Boolean*/ sample(0.00000001, 1.0) then /*Real*/ T[1,1] = /*Real*/ time; ... /*Real*/ T[3,3] = /*Real*/ time; end when; end TestInitial;
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
There are no subtractions in the front-end here. The flattened code is scalar equations only.