CODE
function testfun
parameter Integer n = size(a,1);
input Real[n] a;
output Real[n] b;
algorithm
b := 2*a;
end testfun;
model testmod
Real[2] a;
Real[2] b;
equation
b = {1,2};
a = testfun(b);
end testmod;
The function can be checked (in Dymola) without errors, but when I check the model, I get
QUOTE
Error: Unknown variable n in size expression: n
for function Test.testfun
Errors or failure to expand the equation:
equation
a = Test.testfun(b);
Found in class Test.testmod, declaration window at line 6.
for function Test.testfun
Errors or failure to expand the equation:
equation
a = Test.testfun(b);
Found in class Test.testmod, declaration window at line 6.
The usage of the parameter n is inspired from the example at page 303 (bottom) in Fritzon's book.
For this simple test example, I know that the code below would work. However, (I think) I really need to know the input sizes in defining outputs in the function where I have this problem. Compare for example if a in the model above is defines as Real[:] (which is still not the same error message I get, but similar).
CODE
function testfun
input Real[:] a;
output Real[:] b;
algorithm
b := 2*a;
end testfun;