(cross-posted on StackOverflow)
Unspecified array dimensions using [:] are very important to write flexible components for frequent reuse. While I am aware, that the actual size of an array has to be determined at the time a model is compiled, I was having the opinion that this can be done by binding a variable with a definite dimension to one with an unspecified one.
The following simple example for a block VectorSum that is to sum a vector input will not work:
VectorSum converter "Component taking the sum of a vector input";
InformationSource source "Vector input";
connect( source.y, converter.u );
block VectorSum "Take the sum of an input with unspecified dimension"
y = sum(u);
block InformationSource "Provide some vector output"
y = ones( 3 );
Why does this not work out (after all the dimension for u should be clear from the connect statement as the dimension of the input array is a constant)? What other way to do something like this is there?
I changed inputs and outputs into connectors so that the use of connect is cleaner. The Modelica Specs imo are not so clear about this as Section 10.2 Flexible Array Sizes simply points to Section 12.4.5 where this is discussed for functions. Functions according to the specs explicitly allow the above use of unspecified array dimensions for inputs. Since blocks share quite a bit with functions I am not seeing a good reason for this not to work out.
I agree with your interpretation, I think we should support it. I have filed a bug to keep track of this issue internally, unfortunately I do not see any work around. We will come back to you when we have fixed this problem.