- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » More array/algorithm issues
More array/algorithm issues
More array/algorithm issues
Thanks to sjoelund.se, I've been able to replicate my problem on a reduced model. Here is my model:
model mod1
parameter Integer n=3;
Real Z[n, n];
Real V[n], I[n];
algorithm
for i in 1:n loop
Z[i,i] := i^3;
for k in (i+1):n loop
Z[i,k] := i * k;
Z[k,i] := Z[i,k];
end for;
end for;
equation
I = fill(1.0,n);
V = Z * I;
end mod1;
model mod3
mod1 mymod;
Real V2[mymod.n];
equation
V2 = 2.0 * mymod.V;
end mod3;
"mod1" flattens and simulates fine. "mod3" flattens okay but fails during simulations. The error messages start with the following:
mod3.cpp: In function `int functionDAE_output()':
mod3.cpp:678: error: expected primary-expression before "struct"
mod3.cpp:678: error: expected `)' before "struct"
mod3.cpp:683: error: expected primary-expression before "struct"
mod3.cpp:683: error: expected `)' before "struct"
Here is some of the code the errors point to:
677 tmp41 = get_memory_state();
678 (*struct _array_element_addr(&(*struct _array_element_addr(&$Pmymod$PZ, 2, (modelica_integer)$Pi, (modelica_integer)$Pi)), 2, (modelica_integer)$Pi, (modelica_integer)$Pi)) = ((modelica_real)pow((modelica_real)(modelica_integer)$Pi, (modelica_real)3));
679 tmp38 = (1 + (modelica_integer)$Pi); tmp39 = (1); tmp40 = (modelica_integer)$Pmymod$Pn;
680 {
681 for(modelica_integer $Pk = (1 + (modelica_integer)$Pi); in_range_integer($Pk, tmp38, tmp40); $Pk += tmp39) {
682 tmp37 = get_memory_state();
683 (*struct _array_element_addr(&(*struct _array_element_addr(&$Pmymod$PZ, 2, (modelica_integer)$Pi, (modelica_integer)$Pk)), 2, (modelica_integer)$Pi, (modelica_integer)$Pk)) = ((modelica_real)((modelica_integer)$Pi * (modelica_integer)$Pk));
If I change the algorithm part of mod1 to the following, it simulates correctly.
Z := {{1,2,3},{4,5,6},{7,8,9}};
I'm on windows XP. These results are on a fairly recently downloaded daily (OpenModelica-revision-6338.msi).
- Tom
Re: More array/algorithm issues
I installed OpenModelica from SVN on a Ubuntu machine and tried the model above. I got the same errors, so I think that rules out compiler issues. It seems there's something wrong with my model, or there's a bug somewhere.
- Tom
Re: More array/algorithm issues
The example seems to be working using branches/sjoelund-functiontree instead of trunk (well, at least the simulation runs without error; I did not verify if the results are correct). So it will be fixed when we merge it with the trunk in the near future. (It is a bug in the current trunk though)
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » More array/algorithm issues