﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
1679	Equations in certain order cause errors	Teemu Lempinen	Teemu Lempinen	"As far as I know, the order of equations in equation block should not matter. However, the following code causes an error:

{{{
class Model
    Real BUGTEST[2];
    Real Var1[2, 5, 2, 3];
    Real Var2[2, 5, 2, 3]; 
    Real Var3[2, 5, 2, 3] = zeros(2, 5, 2, 3);
equation
    Var2 = Var1;
    BUGTEST = {sum(Var2[i,:,:,:]) for i in 1:2};
    Var1 = ones(2,5,2,3);
end Model;
}}}

{{{
Error: Error building simulator. Buildlog: gcc  -O3 -falign-functions -msse2 -mf
pmath=sse   -I\""C:/OpenModelica1.8.0//include/omc\"" -I.    -c -o Model.o Model.c

Model.c: In function 'eqFunction_0':
Model.c:1704: error: '$PVar2' undeclared (first use in this function)
Model.c:1704: error: (Each undeclared identifier is reported only once
Model.c:1704: error: for each function it appears in.)
Model.c: In function 'eqFunction_1':
Model.c:1714: error: '$PVar2' undeclared (first use in this function)
mingw32-make: *** [Model.o] Error 1
}}}

But the model simulates if you change the order of the equations to:
{{{
equation
    Var1 = ones(2,5,2,3);
    Var2 = Var1;
    BUGTEST = {sum(Var2[i,:,:,:]) for i in 1:2};
}}}

Reducing the dimensions to Var[[2,5,2] causes the following error:
{{{
Error: Error building simulator. Buildlog: gcc  -O3 -falign-functions -msse2 -mf
pmath=sse   -I\""C:/OpenModelica1.8.0//include/omc\"" -I.    -c -o Model.o Model.c

Model.c: In function 'eqFunction_0':
Model.c:804: error: '$PVar2' undeclared (first use in this function)
Model.c:804: error: (Each undeclared identifier is reported only once
Model.c:804: error: for each function it appears in.)
Model.c:823: error: invalid operands to binary + (have 'real_array' and 'real_ar
ray')
Model.c: In function 'eqFunction_1':
Model.c:852: error: '$PVar2' undeclared (first use in this function)
Model.c:871: error: invalid operands to binary + (have 'real_array' and 'real_ar
ray')
mingw32-make: *** [Model.o] Error 1
}}}

And finally the simulation is OK when dimensions are reduced to Var[[2,5].


Simulations have been run with the latest Windows nightly build (revision 10787)"	defect	accepted	high						Teemu Lempinen Jens Frenkel
