Opened 12 years ago

Closed 11 years ago

#2106 closed defect (fixed)

Code generation for arrays of records

Reported by: Martin Sjölund Owned by: Mahder Alemseged Gebremedhin
Priority: high Milestone: 1.9.0
Component: Code Generation Version: trunk
Keywords: Cc:

Description (last modified by Martin Sjölund)

We need to add support for arrays of records in function context
Currently our code looks something like:

struct Complex_array _t;
alloc_struct Complex_array(&_t, 1, (modelica_integer) 2);

This needs to be something like...

struct_array _t;
alloc_struct_array(&t, sizeof(struct Complex), 1, 2);

Code like this is used in MoMoLib, which will probably be a part of MSL 3.2.1

Attachments (2)

ComplexArray.mo (534 bytes ) - added by Adrian Pop 12 years ago.
ComplexArray.mos (180 bytes ) - added by Adrian Pop 12 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 by Martin Sjölund, 12 years ago

Description: modified (diff)
Owner: changed from mahge to Mahder Alemseged Gebremedhin
Status: newassigned

comment:2 by Mahder Alemseged Gebremedhin, 12 years ago

Status: assignedaccepted

by Adrian Pop, 12 years ago

Attachment: ComplexArray.mo added

by Adrian Pop, 12 years ago

Attachment: ComplexArray.mos added

comment:3 by Adrian Pop, 12 years ago

Any progress on this? If not, maybe I can have a look.

in reply to:  3 comment:4 by Mahder Alemseged Gebremedhin, 12 years ago

Replying to adrpo:

Any progress on this? If not, maybe I can have a look.

I have fixed it to some extent. By falling back to normal arrays. However it doesn't cover all cases. A more robust way to fix it is to write a new set of allocation, copy and element address functions which will take element size info as an additional argument. Sometimes indexing struct arrays also generates UNKNOWN_SUBSCRIPT right now. I had to switch to the openmp stuff before I completely fixed it. If urgent I can work on it now.

comment:5 by Adrian Pop, 12 years ago

We'll talk more about this in the dev meeting on Tuesday 14:00 and we'll decide.

comment:6 by Adrian Pop, 12 years ago

Partially fixed in r16093. A bit of a hack, more work is needed.
recordArray[i].recordComponent does not work yet, just recordArray[i] directly.
We now generate array operations on all records in Model_functions.h but we should generate it just for records that actually appear in any arrays.

comment:7 by Mahder Alemseged Gebremedhin, 11 years ago

Fixed in r16536.

Multi-dimensional arrays of records need more support for default values. Right now default values handled only for one dimensional arrays of records. I think if needed we can handle those manually for 2 or 3 dimensions. I don't think anyone uses >3 dimensional arrays of records anyway.

comment:8 by Mahder Alemseged Gebremedhin, 11 years ago

Resolution: fixed
Status: acceptedclosed

comment:9 by Martin Sjölund, 11 years ago

Resolution: fixed
Status: closedreopened

Fix breaks MetaModelica tests

comment:10 by Adrian Pop, 11 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in r16552 by Mahder.

Note: See TracTickets for help on using tickets.