﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3999	Variable name creation problem in C sources when model using complex object hierarchy and algebraic loops are built	robert@…	Willi Braun	"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:

1. Download and extract the attached TestLibrary 0.0.1.zip to a convenient location.
2. Download the attached TestPlant.mo file.
3. Start the OMShell by typing 'OMShell-terminal'
4. Issue a 'setModelicaPath(<parent path where you extracted the test library>)' command. The system's reply shall be 'true'.
5. Issue a 'loadModel(TestLibrary)' command. The system's reply should be 'true' again.
6. Issue a 'loadFile(<the path where you've downloaded the TestPlant.mo>)' command. Again, the expected reply is 'true'.
7. 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 "	defect	closed	normal	1.11.0	Backend	v1.11.0	fixed		
