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

Inner Outer variable use for defining array size

Inner Outer variable use for defining array size

I want to pass value of 'm' to instantiated models and use it as array size, but while compiling it is saying array size of 's' is not defined, you need to define array size while compiling. Is there any other way to do this except specifically writing (m = m) while instantiating?

Code:


package Test

  model one
    outer parameter Integer m;
    Real s[m];
  equation
    s = fill(7, m);
  end one;
 
  model three
    inner parameter Integer m = 2;
    one to, th;
  end three;

end Test;

Edited by: pravin - Apr-04-19 13:05:53

Re: Inner Outer variable use for defining array size

I assume you mean something like this:

Code:


model A
  outer parameter Integer n;
  Real x[n];
end A;

model M
  inner parameter Integer n = 2;
  A a;
end M;

It seems our current frontend has issues with this, but the new frontend handles it just fine. You can try using the new frontend by either enabling the "Enable experimental new instantiation phase" option in OMEdit->Tools->Simulation, or by setting the compiler flag "-d=newInst" if you use some other tool. If you use OMEdit and you don't have this option you might want to update to a newer version which has it, since the new frontend is constantly improved.

Re: Inner Outer variable use for defining array size

Yes. Thank you. But I am using OpenModelica 1.11 due to some compatibility issues for the library I am working on. Is it possible to update OMEdit to newer version and use OpenModelica 1.11?

Re: Inner Outer variable use for defining array size

pravin wrote:


Yes. Thank you. But I am using OpenModelica 1.11 due to some compatibility issues for the library I am working on. Is it possible to update OMEdit to newer version and use OpenModelica 1.11?

No, it's not really OMEdit that needs to be updated but the compiler (omc). If you for some reason have to use OM 1.11 then you won't be able to use the new frontend, some OM 1.11 is far too old. I'd recommend trying to fix the issues with your library in that case though, rather than trying to work around old compiler bugs.

Re: Inner Outer variable use for defining array size

We are indeed working on fixing library issues with newer version. Thanks a lot for your help. 

Re: Inner Outer variable use for defining array size

I have tried this with 1.14.0 dev but it is still not working. It is showing error that the array dimension must be known at compile time.

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