#3999 closed defect (fixed)
Variable name creation problem in C sources when model using complex object hierarchy and algebraic loops are built
Reported by: | Owned by: | Willi Braun | |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.0 |
Component: | Backend | Version: | v1.11.0 |
Keywords: | Cc: |
Description
To reproduce the problem I created a simple test library and a test .mo file which are attached to the ticket.
To reproduce the problem, follow the steps below:
- Download and extract the attached TestLibrary 0.0.1.zip to a convenient location.
- Download the attached TestPlant.mo file.
- Start the OMShell by typing 'OMShell-terminal'
- Issue a 'setModelicaPath(<parent path where you extracted the test library>)' command. The system's reply shall be 'true'.
- Issue a 'loadModel(TestLibrary)' command. The system's reply should be 'true' again.
- Issue a 'loadFile(<the path where you've downloaded the TestPlant.mo>)' command. Again, the expected reply is 'true'.
- Issue a 'simulate(Model2Test, outputFormat="csv")' command.
Here the OMShell reports an error message: 'Failed to build model: Model2Test'.
By this time the C sources are sitting in the folder where the OMShell had been started in and the Model2Test.log file is crowded with messages like this:
Model2Test_12jac.c:150:3: error: expected expression
$Pi$Psm4$Pspecies_TestLibrary.Models.ModelContainer2.Model2.Species.SP4_$P$pDERNLSJac1$PdummyVarNLSJac1 = (7.142857142857143e-05) * ((data->simulationInfo->realParameter[5] /* i._sm1._S4 PARAM */) * (($Pi_sm4_species_TestLibrary.Models.ModelContainer2.Model2.Species.SP1_SeedNLSJac1) * (DIVISION_SIM(data->localData[0]->realVars[11] /* i._sm4._var51 variable */,(tmp6 * tmp6),"(i.sm4.species[TestLibrary.Models.ModelContainer2.Model2.Species.SP1] + i.sm4.var51) 2.0",equationIndexes))));
(If needed, I can attach the full log as well).
So it seems that the generated C code is invalid. The expected behavior is that if the Modelica code is invalid, we should get a meaningful error message before the C code is generated; if however, the Modelica code is correct, then the C compilation should not fail.
I was able to reproduce the problem on a Mac and on Ubuntu xenial as well.
The omc --version command returned 'OpenModelica 1.11.0~dev-44-g9e3a252'
Thanks for your efforts!
Please let me know if further details are needed to investigate the problem.
The omc--version command
Attachments (3)
Change History (7)
by , 8 years ago
Attachment: | TestLibrary 0.0.1.zip added |
---|
comment:1 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
The generated cref contains dots instead of underscores (also for the #define). Willi: can you have a look?
comment:2 by , 8 years ago
Status: | assigned → accepted |
---|
comment:3 by , 8 years ago
Component: | *unknown* → Backend |
---|---|
Resolution: | → fixed |
Status: | accepted → closed |
Ihe issue was related to the usage of enumerations as array subscript.
Fixed in 895a1e1/OMCompiler.
comment:4 by , 8 years ago
Milestone: | Future → 1.11.0 |
---|
Test library for reproducing the problem.