- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Array in fuction
Array in fuction
Array in fuction
Hi,
I am a Windows OpenModelica user and I have the following problem: I have an instance of a class declared with an array (A a[1]). Within the instaciated class I call a function which returns one value of an array of a record. If the array size in the record is smaller or equal than 19, there is no problem. If the array size is greater 19 an unknown error occurs. The model code:
Code:
model FrameTest
// --- MAIN CLASS ---
Element element[1];
end FrameTest;
//############################################################################################################
model Element
Profile profile;
Real angle;
equation
angle = funct(alpha=profile.alpha);
end Element;
//############################################################################################################
function funct
input Real[:] alpha;
output Real cOut;
algorithm
cOut:= alpha[5];
end funct;
//############################################################################################################
record Profile
parameter Real alpha[20]={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0};
//parameter Real alpha[19]={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0};
end Profile;
Thanks for your help,
Sebastian
Re: Array in fuction
I will have a look at this bug. Note that this is related to the vectorization limit of OpenModelica.
As a workaround, you can run
Code:
omc +v=100
, or setVectorizationLimit(100) in OMShell or OMEdit. But this may have a negative impact on the performance of large models.
- sjoelund.se
- 1700 Posts
Re: Array in fuction
In r8597+ it should also work with any vectorization limit:
Code:
size 3: +v=1
real_array_create(&tmp1018, ((modelica_real*)&($Pelement$lB2$rB$Pprofile$Palpha)), 1, 3);
size 3: +v=100
array_alloc_scalar_real_array(&tmp1018, 3, (modelica_real)$Pelement$lB2$rB$Pprofile$Palpha$lB1$rB, (modelica_real)$Pelement$lB2$rB$Pprofile$Palpha$lB2$rB, (modelica_real)$Pelement$lB2$rB$Pprofile$Palpha$lB3$rB);
The generated code should be faster with a lower limit since we just use a reference to the array instead of creating a new one...
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Array in fuction