#6046 closed defect (invalid)
Support of N-dimensional arrays in readRealMatrix
Reported by: | Anton.Soppelsa@eurac.edu | Owned by: | somebody |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | *unknown* | Version: | |
Keywords: | Cc: |
Description
It seems that the function readRealMatrix does not support multi-dimensional arrays.
I suspect that this could be due to the fact that it seems not currently possible to declare an array of unknown dimensions in Modelica. Is this true?
My practical, immediate needs require two functions like readArraySize(fileName:String, arrayName:String):1DArray and read3DArrayFromFile(fileName:String, arrayName:String, dims:1DArray):3DArray to be called one after the other. What's the best approach to build them? Should I write C functions doing it and then two Modelica wrappers? Can you please point me in the right direction to do this sort of work?
Finally, what about implementing stream function to load/save arrays in HDF5 format? Is there a plan to do that?
Sincerely,
Anton
Change History (5)
comment:1 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
follow-up: 3 comment:2 by , 4 years ago
Replying to anton.soppelsa:
I suspect that this could be due to the fact that it seems not currently possible to declare an array of unknown dimensions in Modelica. Is this true?
Not really, you can do something like this
model foo parameter Real x[:,:] = getX(); end foo;
of course this requires the front-end to actually call the function getX() and figure out the dimensions at compile time. Current Modelica tools cannot handle models with dimensions changed at runtime, because they normally flatten the Modelica to scalar variables and equations to generate the simulation code, so the dimensions need to be known early on.
This may change in the future.
Finally, what about implementing stream function to load/save arrays in HDF5 format? Is there a plan to do that?
There's been plans to do that in the Modelica Standard Library for many years. What I understand is that we wanted to have a completely general solution, with the result that we got none...
I suggest you to scan the Modelica Standard Library github issue repository for this topic. If you don't find anything, feel free to open one yourself.
follow-up: 4 comment:3 by , 4 years ago
Replying to casella:
Replying to anton.soppelsa:
I suspect that this could be due to the fact that it seems not currently possible to declare an array of unknown dimensions in Modelica. Is this true?
Not really, you can do something like this
model foo parameter Real x[:,:] = getX(); end foo;
I think the issue here is rather that it's not possible for a Modelica function to return an array with an unknown number of dimensions.
follow-up: 5 comment:4 by , 4 years ago
Thank you all for the clarifications.
@perost: yes, I was speaking about the number of dimensions.
@casella: a pity that a compromise solution has not been found. Probably, full mapping of an HDF4 data object is too difficult to attain given the structure (and the purposes) of Modelica, however supporting the subset of HDF5 which makes sense for Modelica and allow support for n-dimensional arrays seems to me something very useful, almost essential.
I think I will post something on the MSL repo.
Cheers,
Anton
Replying to perost:
Replying to casella:
Replying to anton.soppelsa:
I suspect that this could be due to the fact that it seems not currently possible to declare an array of unknown dimensions in Modelica. Is this true?
Not really, you can do something like this
model foo parameter Real x[:,:] = getX(); end foo;I think the issue here is rather that it's not possible for a Modelica function to return an array with an unknown number of dimensions.
comment:5 by , 4 years ago
Replying to anton.soppelsa:
@casella: a pity that a compromise solution has not been found. Probably, full mapping of an HDF4 data object is too difficult to attain given the structure (and the purposes) of Modelica, however supporting the subset of HDF5 which makes sense for Modelica and allow support for n-dimensional arrays seems to me something very useful, almost essential.
I fully agree, please go ahead with the post. As a member of the Modelica Association Board, I'm well aware that sometimes we really do need input and pressure from outsiders to get things going :)
And, BTW, it would be really great if you could actively contribute to that.
This is not an OpenModelica issue.
readRealMatrix
is part of the Modelica Standard Library, which is not developed by us but by the Modelica Association. You can report issues on their github page.