Opened 11 years ago

Closed 10 years ago

#2562 closed defect (duplicate)

Problem with code generation - array in record

Reported by: Francesco Casella Owned by: Lennart Ochel
Priority: critical Milestone: 1.9.1
Component: Code Generation Version: trunk
Keywords: Cc: Lennart Ochel

Description

The compilation of model ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator in the testsuite fails due to incorrectly generated C code:

ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_06inz.c:3762: error: '$Pplant$PPressDrop2$Pgas$Pstate$PX$lB5$rB' undeclared (first use in this function)

plant.PressDrop2.gas.state is a record, that contains the array X[4] - apparently the code generator doesn't like this.

Note that this problem shows up in all models using gas mixtures from Modelica.Media

Change History (13)

comment:1 by Lennart Ochel, 11 years ago

Status: newaccepted

comment:2 by Lennart Ochel, 11 years ago

I created a new test for this ticket here: testsuite/simulation/libraries/3rdParty/ThermoPower.

comment:3 by Lennart Ochel, 11 years ago

It seems that you point to two different examples:

  1. ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator
  2. ThermoPower.Examples.BraytonCycle.OpenLoopSimulator

I cannot find the second one in the test suite.

The first one produces the following error output:

ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_functions.o: In function `omc_Modelica_Blocks_Types_ExternalCombiTable2D_destructor':
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_functions.c:(.text+0x670): undefined reference to `ModelicaStandardTables_CombiTable2D_close'
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_functions.o: In function `omc_Modelica_Blocks_Types_ExternalCombiTable2D_constructor':
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_functions.c:(.text+0x6ed): undefined reference to `ModelicaStandardTables_CombiTable2D_init'
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_functions.o: In function `omc_Modelica_Blocks_Tables_CombiTable2D_getTableValue':
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_functions.c:(.text+0x75d): undefined reference to `ModelicaStandardTables_CombiTable2D_getValue'
collect2: ld returned 1 exit status
make: *** [omc_main_target] Error 1

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

Those are old total models in the testsuite... Not the new ones that we are considering. Get it from svn or by using make GITLIBRARIES=Yes.

comment:5 by Lennart Ochel, 11 years ago

Ohh, yes. Shouldn't become the whole library part of the test suite?

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

No, we cannot put all libraries in there :)

It's under https://test.openmodelica.org/libraries/ThermoPower/BuildModelRecursive.html

comment:7 by Lennart Ochel, 11 years ago

I get the follwoing Errors using omc 1.9.1+dev (r18989) (RML version) and the branch version of ThermoPower 3.0:

ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator

Simulation failed for model: ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator
[ThermoPower/Gas.mo:100:5-102:11:writable] Error: Cannot resolve type of expression cardinality(in_X) == 0. The operands have types Integer[4], Integer in component plant.SourceP1.
Error: Error occurred while flattening model ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator

ThermoPower.Examples.BraytonCycle.OpenLoopSimulator

Simulation failed for model: ThermoPower.Examples.BraytonCycle.OpenLoopSimulator
[ThermoPower/Gas.mo:100:5-102:11:writable] Error: Cannot resolve type of expression cardinality(in_X) == 0. The operands have types Integer[4], Integer in component plant.SourceP1.
Error: Error occurred while flattening model ThermoPower.Examples.BraytonCycle.OpenLoopSimulator

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

We only use the trunk version of ThermoPower 3.1 :)

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

Tested Library: ThermoPower 3.1 revision 240

comment:10 by Lennart Ochel, 11 years ago

I see.

ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator

ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_08bnd.c: In function ‘ThermoPower_Examples_BraytonCycle_ClosedLoopSimulator_eqFunction_730’:
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_08bnd.c:496: error: ‘$Pplant$PPressDrop2$Pgas$Pstate$PX$lB5$rB’ undeclared (first use in this function)
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_08bnd.c:496: error: (Each undeclared identifier is reported only once
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_08bnd.c:496: error: for each function it appears in.)
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_06inz.c: In function ‘ThermoPower_Examples_BraytonCycle_ClosedLoopSimulator_eqFunction_422’:
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_06inz.c:3733: error: ‘$Pplant$PPressDrop2$Pgas$Pstate$PX$lB5$rB’ undeclared (first use in this function)
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_06inz.c:3733: error: (Each undeclared identifier is reported only once
ThermoPower.Examples.BraytonCycle.ClosedLoopSimulator_06inz.c:3733: error: for each function it appears in.)

ThermoPower.Examples.BraytonCycle.OpenLoopSimulator

ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_08bnd.c: In function ‘ThermoPower_Examples_BraytonCycle_OpenLoopSimulator_eqFunction_705’:
ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_08bnd.c:449: error: ‘$Pplant$PPressDrop2$Pgas$Pstate$PX$lB5$rB’ undeclared (first use in this function)
ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_08bnd.c:449: error: (Each undeclared identifier is reported only once
ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_08bnd.c:449: error: for each function it appears in.)
ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_06inz.c: In function ‘ThermoPower_Examples_BraytonCycle_OpenLoopSimulator_eqFunction_413’:
ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_06inz.c:3762: error: ‘$Pplant$PPressDrop2$Pgas$Pstate$PX$lB5$rB’ undeclared (first use in this function)
ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_06inz.c:3762: error: (Each undeclared identifier is reported only once
ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_06inz.c:3762: error: for each function it appears in.)

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

Good, now fix it :)

comment:12 by Francesco Casella, 11 years ago

Sorry, I should have been more precise in defining the test model, but I see Martin did a good job at that. My apologies.

Happy hacking!

comment:13 by Francesco Casella, 10 years ago

Resolution: duplicate
Status: acceptedclosed

Same bug reported in #2658

Note: See TracTickets for help on using tickets.