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

Simple array assignment problem

Simple array assignment problem

Compilation of the following simple test.mo file ("omc +a +s +showErrorMessages test.mo")

class Test
    parameter Integer p[2] = {1,2};
end Test;

causes the error message:

class Test
  parameter Integer p[1:2] = {1,2};
end Test;
{"Error: Internal error BackendDAEUtil.traverseBackendDAEExps failed", "TRANSLATION", "Error", "63"}
Error processing file: test.mo
Error: Internal error BackendDAEUtil.traverseBackendDAEExps failed

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!

I've studied the Language Specification intensively, yet cannot see what I do wrong... Help appreciated! Thanks.

-- Henk

Re: Simple array assignment problem

+a is an experimental flag that is not supported by the OpenModelica backend

Re: Simple array assignment problem

sjoelund.se wrote:

+a is an experimental flag that is not supported by the OpenModelica backend

"Experimental" here apparently means 'supported by the OpenModelica frontend only'. Does it also mean that it will be supported by the backend sometime, and if so, is there any idea when? (I can see the difficulty of how to handle arrays in a symbolic context...).

-- Henk

Re: Simple array assignment problem

henk wrote:

sjoelund.se wrote:

+a is an experimental flag that is not supported by the OpenModelica backend

"Experimental" here apparently means 'supported by the OpenModelica frontend only'. Does it also mean that it will be supported by the backend sometime, and if so, is there any idea when?.

Found that problem is linked to: Bug [# 1575] Really bad code generation for parameter arrays set via a function call...

Is work on its solution in sight? If not, is there a 'cleaner' alternative (than indexing multiple calls) to return arrays from external functions?

-- Henk

Re: Simple array assignment problem

This work was the start of that, but I believe it is on hold. Instead we are working on a new flattening of Modelica models that will keep as much structure as possible intact.

Anyway, the expansion is only a problem for binding equation. By using real equations, the code is efficient.

Code:

model Bad

constant Integer sz=10;
function fcall
   input Real r;
   output Real[sz] o = fill(r,sz);
end fcall;
parameter Real p = 1.5;
Real x[sz];
equation
x = fcall(p);
end Bad;

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