Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Model error with arrays of different size

Model error with arrays of different size

Hello,

I get an error using OpenModelica (r10977) when I want to simulate the following model.

Code:


model ArrayModel
  parameter Integer N=1;
  Real y[N];
end ArrayModel;

model TestModel
  parameter Integer N[:]={1, 2};
  ArrayModel a[2](N=N);
equation
  a[1].y[1] = 1;
 
  a[2].y[1] = 1;
  a[2].y[2] = 1;
end TestModel;

The error message is

Code:


Error: Illegal subscript [2] for dimensions 1 in component a[2]

which is related to acessing a[2].y[2]. Acessing only a[2].y[1] does not cause any errors and for this the flattened model has all the declared variables, i.e. a[2].y[2] is defined.

Is this incorrect usage of the Modelica language from me or a bug?

Best regards,

Michael

Re: Model error with arrays of different size

We're pretty sure this subscripting is illegal, simply because a.y has undefined type (Real[1] or Real[2] depending on which element on a you access).

However, there is no answer to the ticket here: https://trac.modelica.org/Modelica/ticket/655

There are 0 guests and 0 other users also viewing this topic
You are here: