Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » edes
  • » Profile

Posts

Posts

Aug-13-10 00:18:14
How to read OMC's failtrace outputs?

Right, I wouldn't hope for too much either - especially not, if you work on a timeline. The true problem is, that 1.5 final in fact is somthing which normally would be labeled as an early beta release. Maybe it will work better in half a year, maybe in a year, maybe never... who knows.

If you work with Modelica professionally, you could consider commercial environments - They are not cheap, but it pays off. Just my opinion...

Jul-30-10 13:59:29
Usage of unit attributes impedes build of simulation binary

Hello!

I just noticed a weird phenomenon: In a class of mine I use some connectors with variables which have unit attibutes set. When using units from Modelica.SIunits everything works normal. When using units out of my own units library flattening works fine, but an error occures while building the simulator.

Really strange is, that, when I declare the units from Modelica.SIunits within my own units library and use them, the flattened modelica code (fclass) looks exactly like when the units out of Modelica.SIunits are used - not a single byte differs. But (even if the fclasses look like copies) in one case the build fails, in the other it doesn't.

Any ideas?

Regards,
Hannes

EDIT: I must correct that: It does not matter where the units come from (own lib or Modelica libs). Fact is, that input variables within connectors "disappear" as unknown values from the system of equations when an unit attribute is set for them..

Example: A block with 3 causal connector variables (input); all 3 variables DON'T have unit attributes set: Trying to simulate that block leads to an error, because 3 values/equations are missing (model underdetermined by degree 3). Adding a unit attribute to 1 of the connector variables leads to a model which is underdetermined by degree 2.  Adding a unit attribute to 2 of the connector variables leads to a model which is underdetermined by degree 1. (Means: with every time a unit attribute is added, one unknown seems to disappear). Finally, when all 3 variables have unit attributes set, the model seems to be balanced (which it obviously is not) and when trying to compile the simulator binary an error occures.

I reported this phenomenon 2 months ago already, with no reaction (http://www.openmodelica.org/index.php/forum/topic?id=66). Am I doing something wrong here, or why doesn't anyone see that problem?

Jul-29-10 17:04:52
cannot convert `time_t ()(time_t*)' to `modelica_real' in assignment

Ah - Didn't know that (obviously). Thanks a lot!

Jul-29-10 16:30:28
cannot convert `time_t ()(time_t*)' to `modelica_real' in assignment

Hello!

I have a problem which is best illustrated by the following example:

Code:


function time_dependent_function
  output Real i;
algorithm
  i := time;
end time_dependent_function;

fclass test
  Real x;
equation
  x = time_dependent_function();
end test;

When building the simulator for that class, the following error occures:

Code:


Error: Error building simulator. Buildlog: g++ -I"C:\OpenModelica1.5.0\/include/omc" -msse2 -mfpmath=sse  -I. -o funktionstest.exe funktionstest.cpp -L"C:/Users/Hannes Edinger/workspace/OIB_RL6/OIB_RL6/../OIB_RL6/OENORM_B8110_6"  -lsim -L"C:\OpenModelica1.5.0\/lib/omc" -lc_runtime -lf2c -linteractive -lsendData -lQtNetwork-mingw -lQtCore-mingw -lQtGui-mingw -luuid -lole32 -lws2_32
In file included from funktionstest.cpp:14:
funktionstest_functions.cpp: In function `time__dependent__function_rettype _time__dependent__function()':
funktionstest_functions.cpp:34: error: cannot convert `time_t ()(time_t*)' to `modelica_real' in assignment
mingw32-make: *** [funktionstest] Error 1

I think the crux of the matter is the part "cannot convert `time_t ()(time_t*)' to `modelica_real' in assignment".

How to deal with that?

Regards,
Hannes

Jul-29-10 12:34:14
How to read OMC's failtrace outputs?

Hello!

A model of mine doesn't want to simulate - I get the message "Error occured while flattening model" without any further details. Using OMC's failtrace function gives a whole bunch of errors, but the output is kind of hard to read for someone who is not familiar with the internals of OMC.

My question is: How can I find the "root of all errors" in such a series of warnings/failures/errors?

Code:


/*- CevalScript.cevalGenerateFunctionDAEs failed( clear )*/
/*- CevalScript.cevalGenerateFunction failed(clear)*/
/*- CevalScript.cevalGenerateFunctionDAEs failed( loadFile )*/
/*- CevalScript.cevalGenerateFunction failed(loadFile)*/
/*- CevalScript.cevalGenerateFunctionDAEs failed( loadFile )*/
/*- CevalScript.cevalGenerateFunction failed(loadFile)*/
Error inserting class: OENORM_B8110_6 within: (within OIB_RL6;
) program:
Error inserting class: Tabellen within: (within OENORM_B8110_6;
) program:
Error inserting class: Gleichungen within: (within OENORM_B8110_6;
) program:
/*- CevalScript.cevalGenerateFunctionDAEs failed( loadFile )*/
/*- CevalScript.cevalGenerateFunction failed(loadFile)*/
Error inserting class: OENORM_H5056 within: (within OIB_RL6;
) program:
Error inserting class: Tabellen within: (within OENORM_H5056;
) program:
Error inserting class: Gleichungen within: (within OENORM_H5056;
) program:
/*- CevalScript.cevalGenerateFunctionDAEs failed( loadFile )*/
/*- CevalScript.cevalGenerateFunction failed(loadFile)*/
Error inserting class: DefaultProjekt within: (within OIB_RL6;
) program:
/*- CevalScript.cevalGenerateFunctionDAEs failed( loadModel )*/
/*- CevalScript.cevalGenerateFunction failed(loadModel)*/
/*- CevalScript.cevalGenerateFunctionDAEs failed( simulate )*/
/*- CevalScript.cevalGenerateFunction failed(simulate)*/
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.outputConnector
- Inst.instClass: outputConnector failed
- Inst.instVar2 failed: L_VhRLT.result(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: L_VhRLT.result redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = result
mods:  {result(redeclare(COMPONENT(result in/out:  mod:  tp: OIB_RL6.Schnittstellen.outputConnectorLeitwert var :VAR)))}
scope: OIB_RL6.OENORM_B8110_6.Gleichungen.'(34) L_VRLT'
- Inst.instClass: Real failed
- Inst.instVar2 failed: L_VhRLT.result.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: L_VhRLT.result.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: Modelica.SIunits.ThermalConductance var :VAR)))}
scope: OIB_RL6.Schnittstellen.outputConnectorLeitwert
- Inst.instClass: Real failed
- Inst.instVar2 failed: L_VhRLT.v_mech.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: L_VhRLT.v_mech.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: VolumeFlowRate_hourly var :VAR)))}
scope: OIB_RL6.Schnittstellen.inputConnectorVolumenstrom
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.outputConnector
- Inst.instClass: outputConnector failed
- Inst.instVar2 failed: L_VcRLT.result(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: L_VcRLT.result redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = result
mods:  {result(redeclare(COMPONENT(result in/out:  mod:  tp: OIB_RL6.Schnittstellen.outputConnectorLeitwert var :VAR)))}
scope: OIB_RL6.OENORM_B8110_6.Gleichungen.'(34) L_VRLT'
- Inst.instClass: Real failed
- Inst.instVar2 failed: L_VcRLT.result.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: L_VcRLT.result.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: Modelica.SIunits.ThermalConductance var :VAR)))}
scope: OIB_RL6.Schnittstellen.outputConnectorLeitwert
- Inst.instClass: Real failed
- Inst.instVar2 failed: L_VcRLT.v_mech.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: L_VcRLT.v_mech.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: VolumeFlowRate_hourly var :VAR)))}
scope: OIB_RL6.Schnittstellen.inputConnectorVolumenstrom
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.outputConnector
- Inst.instClass: outputConnector failed
- Inst.instVar2 failed: V_V.result(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: V_V.result redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = result
mods:  {result(redeclare(COMPONENT(result in/out:  mod:  tp: OIB_RL6.Schnittstellen.outputConnectorVolumen var :VAR)))}
scope: OIB_RL6.OENORM_B8110_6.Gleichungen.'(23) V_V'
- Inst.instClass: Real failed
- Inst.instVar2 failed: V_V.result.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: V_V.result.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: Modelica.SIunits.Volume var :VAR)))}
scope: OIB_RL6.Schnittstellen.outputConnectorVolumen
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.outputConnector
- Inst.instClass: outputConnector failed
- Inst.instVar2 failed: v_mech.result(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: v_mech.result redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = result
mods:  {result(redeclare(COMPONENT(result in/out:  mod:  tp: OIB_RL6.Schnittstellen.outputConnectorVolumenstrom var :VAR)))}
scope: OIB_RL6.OENORM_B8110_6.Gleichungen.'(35) v_mech'
- Inst.instClass: Real failed
- Inst.instVar2 failed: v_mech.result.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: v_mech.result.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: VolumeFlowRate_hourly var :VAR)))}
scope: OIB_RL6.Schnittstellen.outputConnectorVolumenstrom
- Inst.instClass: Real failed
- Inst.instVar2 failed: v_mech.V_V.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: v_mech.V_V.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: Modelica.SIunits.Volume var :VAR)))}
scope: OIB_RL6.Schnittstellen.inputConnectorVolumen
- Inst.instClass: Real failed
- Inst.instVar2 failed: v_mech.n_LRLT.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: v_mech.n_LRLT.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: perHour var :VAR)))}
scope: OIB_RL6.Schnittstellen.inputConnectorStundenrate
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.inputConnector
- Inst.instClass: inputConnector failed
- Inst.instVar2 failed: n_LRLT.in_x(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: n_LRLT.in_x redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = in_x
mods:  {in_x(redeclare(COMPONENT(in_x in/out:  mod:  tp: OIB_RL6.Schnittstellen.inputConnectorInteger var :VAR)))}
scope: OIB_RL6.OENORM_B8110_5.Tabellen.Tabelle_2
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.inputConnector
- Inst.instClass: inputConnector failed
- Inst.instVar2 failed: n_LRLT.in_y(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: n_LRLT.in_y redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = in_y
mods:  {in_y(redeclare(COMPONENT(in_y in/out:  mod:  tp: OIB_RL6.Schnittstellen.inputConnectorInteger var :VAR)))}
scope: OIB_RL6.OENORM_B8110_5.Tabellen.Tabelle_2
- Inst.instClass: Real failed
- Inst.instVar2 failed: n_LRLT.in_x.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: n_LRLT.in_x.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: Integer var :VAR)))}
scope: OIB_RL6.Schnittstellen.inputConnectorInteger
- Inst.instClass: Real failed
- Inst.instVar2 failed: n_LRLT.in_y.value(redeclare...)
  Scope: <global scope>
- Inst.instVar failed while instatiating variable: n_LRLT.in_y.value redeclare... in scope: <global scope>
- Inst.updateComponentInEnv failed, ident = value
mods:  {value(redeclare(COMPONENT(value in/out:  mod:  tp: Integer var :VAR)))}
scope: OIB_RL6.Schnittstellen.inputConnectorInteger
- Static.makeASUBArrayAdressing2 failed for INDEX(in_y.value)
- Static.makeASUBArrayAdressing2 failed for INDEX(in_y.value)
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.outputConnector
- Inst.instClass: outputConnector failed
- Inst.instVar2 failed: eta_Vgesh.result(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: eta_Vgesh.result redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = result
mods:  {result(redeclare(COMPONENT(result in/out:  mod:  tp: OIB_RL6.Schnittstellen.outputConnectorEinheitslos var :VAR)))}
scope: OIB_RL6.OENORM_B8110_6.Gleichungen.'(36) eta_Vges'
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.outputConnector
- Inst.instClass: outputConnector failed
- Inst.instVar2 failed: eta_Vgesc.result(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: eta_Vgesc.result redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = result
mods:  {result(redeclare(COMPONENT(result in/out:  mod:  tp: OIB_RL6.Schnittstellen.outputConnectorEinheitslos var :VAR)))}
scope: OIB_RL6.OENORM_B8110_6.Gleichungen.'(36) eta_Vges'
- Inst.updateComponentInEnv failed, ident = header_x
mods:  {header_x(redeclare( finalCOMPONENT(header_x in/out:  mod:  = 1:2 tp: Real var :CONST)))}
scope: OIB_RL6.OENORM_B8110_6.Tabellen.Tab_14
- Inst.updateComponentInEnv failed, ident = header_y
mods:  {header_y(redeclare( finalCOMPONENT(header_y in/out:  mod:  = 1:6 tp: Real var :CONST)))}
scope: OIB_RL6.OENORM_B8110_6.Tabellen.Tab_14
- Inst.updateComponentInEnv failed, ident = tableData
mods:  {tableData(redeclare( finalCOMPONENT(tableData in/out:  mod:  = {{0.5, -0},{0.65, -0},{0.4, -0},{0.7, -0},{0.7, -0},{0.7,0.7}} tp: Real var :CONST)))}
scope: OIB_RL6.OENORM_B8110_6.Tabellen.Tab_14
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.Connector
- Inst.instClassdef failed
  class :OIB_RL6.Prototypen.outputConnector
- Inst.instClass: outputConnector failed
- Inst.instVar2 failed: Phi_WRGh.out(redeclare...)
  Scope: OIB_RL6.Prototypen
- Inst.instVar failed while instatiating variable: Phi_WRGh.out redeclare... in scope: OIB_RL6.Prototypen
- Inst.updateComponentInEnv failed, ident = out
mods:  {out(redeclare(COMPONENT(out in/out:  mod:  tp: OIB_RL6.Prototypen.outputConnectorEinheitslos var :VAR)))}
scope: OIB_RL6.OENORM_B8110_6.Tabellen.Tab_14
- Inst.instElement failed: COMPONENT(out in/out:  mod:  tp: OIB_RL6.Prototypen.outputConnector var :VAR)
  Scope: OIB_RL6.OENORM_B8110_6.Tabellen.Tab_14
- Inst.instClassdef failed
  class :OIB_RL6.OENORM_B8110_6.Tabellen.Tab_14
- Inst.instClass: Tab_14 failed
- Inst.instVar2 failed: <Prefix.NOPRE()>.Phi_WRGh()
  Scope: OIB_RL6.OENORM_B8110_6.Tabellen
- Inst.instVar failed while instatiating variable: Phi_WRGh  in scope: OIB_RL6.OENORM_B8110_6.Tabellen
- Inst.instElement failed: COMPONENT(Phi_WRGh in/out:  mod:  tp: OIB_RL6.OENORM_B8110_6.Tabellen.Tab_14 var :VAR)
  Scope: OIB_RL6.OENORM_B8110_6.LV_NWG_RLT
- Inst.instClassdef failed
  class :OIB_RL6.OENORM_B8110_6.LV_NWG_RLT
- Inst.instClass: LV_NWG_RLT failed

Any hints are appreciated.

Regards
Hannes

PS: Sorry for copy-pasting endless OMC outputs into the text, but uploading files onto the server via the attachments-function doesn't work for me any longer.

No response for 5 days. Anything unclear / missing in my posting?

Cheers
Hannes

Dear people,

I have a model which contains 9 variables. 3 of them have unit attributes set. The model makes use of some self-written functions.

While trying to make it work, I ran into two problems: 1.) It looks like the usage of unit attributes reduces the number of variables in the flattened class. 2.) If the number of equations matches the number of variables, the simulator executeable cannot be built.

These are the variants I played and the errors which occured:

Code:


                       | 6 equations          | 9 equations
-----------------------+----------------------+---------------------
with 3 unit attributes | err: g++ not found   | unbalanced: 9eq/6var
w/o 3 unit attributes  | unbalanced: 6eq/9var | err: g++ not found

Using 1.5 RC3 in Win7/64 here. The flattened models for all 4 variants can be found here.

Any hints?

Regards,
Hannes

Clear now. Thank you!

Apr-25-10 23:53:32
Model does not compile any longer

Thank you for digging deeply into that.

You were right: The problem has to do with the declaration of constant Arrays. After I commented out the "constant" keyword in the array (re-)declaration, the simulation could be compiled again. BUT the simulation's result in the .plt file is totally wrong now: It consists of only one dataset for each variable (the inital values) even if the test-run was over 100 timesteps current/hmm

Apr-25-10 22:29:04
Model does not compile any longer

...and this is the main .cpp:

Code:


// Simulation code for OIB_RL6.BEISPIELE.beispielTabellen generated by the OpenModelica Compiler.
#include "modelica.h"
#include "assert.h"
#include "string.h"
#include "simulation_runtime.h"

#if defined(_MSC_VER) && !defined(_SIMULATION_RUNTIME_H)
  #define DLLExport   __declspec( dllexport )
#else
  #define DLLExport /* nothing */
#endif

#include "OIB_RL6.BEISPIELE.beispielTabellen_functions.cpp"

extern "C" {

}

#define NHELP 0
#define NG 0//number of zero crossing
#define NX 1
#define NY 17
#define NP 8 // number of parameters
#define NO 7 // number of outputvar on topmodel
#define NI 0 // number of inputvar on topmodel
#define NR 18 // number of residuals for initialialization function
#define NEXT 0 // number of external objects
#define MAXORD 5
#define NYSTR 0 // number of alg. string variables
#define NPSTR 0 // number of alg. string variables

static DATA* localData = 0;
#define time localData->timeValue
extern "C" { /* adrpo: this is needed for Visual C++ compilation to work! */
  char *model_name="OIB_RL6.BEISPIELE.beispielTabellen";
  char *model_dir="C:/Users/Hannes Edinger/workspace/OIB_RL6/OIB_RL6/../OIB_RL6/BEISPIELE";
}
char* state_names[1]={"$dummy"};
char* derivative_names[1]={"der($dummy)"};
char* algvars_names[17]={"GL3.inPort.value", "GL6.inPort.value", "Summe.result.value", "Summe.inPort1.value", "Summe.inPort2.value", "GL1.result.value", "GL2.result.value", "GL3.result.value", "TAB1.in_x.value", "TAB1.in_y.value", "TAB1.out.value", "GL4.result.value", "GL5.result.value", "GL6.result.value", "TAB2.in_x.value", "TAB2.in_y.value", "TAB2.out.value"};
char* input_names[1] = {""};
char* output_names[7]={"GL6.result.value", "GL5.result.value", "GL4.result.value", "GL3.result.value", "GL2.result.value", "GL1.result.value", "Summe.result.value"};
char* param_names[8]={"GL1.x", "GL2.x", "TAB1.method_x", "TAB1.method_y", "GL4.x", "GL5.x", "TAB2.method_x", "TAB2.method_y"};
char* string_alg_names[1] = {""};
char* string_param_names[1] = {""};

char* state_comments[1]={""};
char* derivative_comments[1]={""};
char* algvars_comments[17]={"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
char* input_comments[1] = {""};
char* output_comments[7]={"", "", "", "", "", "", ""};
char* param_comments[8]={ "Ausgabewert",  "Ausgabewert",  "Optionen: nearest, left, right, interpolate",  "Optionen: nearest, left, right, interpolate",  "Ausgabewert",  "Ausgabewert",  "Optionen: nearest, left, right, interpolate",  "Optionen: nearest, left, right, interpolate"};
char* string_param_comments[1] = {""};
char* string_alg_comments[1] = {""};

#define $TAB2$Pout$Pvalue localData->algebraics[16]
#define $TAB2$Pin_y$Pvalue localData->algebraics[15]
#define $TAB2$Pin_x$Pvalue localData->algebraics[14]
#define $GL6$Presult$Pvalue localData->algebraics[13]
#define $GL5$Presult$Pvalue localData->algebraics[12]
#define $GL4$Presult$Pvalue localData->algebraics[11]
#define $TAB1$Pout$Pvalue localData->algebraics[10]
#define $TAB1$Pin_y$Pvalue localData->algebraics[9]
#define $TAB1$Pin_x$Pvalue localData->algebraics[8]
#define $GL3$Presult$Pvalue localData->algebraics[7]
#define $GL2$Presult$Pvalue localData->algebraics[6]
#define $GL1$Presult$Pvalue localData->algebraics[5]
#define $TAB2$Pmethod_y localData->parameters[7]
#define $TAB2$Pmethod_x localData->parameters[6]
#define $GL5$Px localData->parameters[5]
#define $GL4$Px localData->parameters[4]
#define $TAB1$Pmethod_y localData->parameters[3]
#define $TAB1$Pmethod_x localData->parameters[2]
#define $GL2$Px localData->parameters[1]
#define $GL1$Px localData->parameters[0]
#define $Summe$PinPort2$Pvalue localData->algebraics[4]
#define $Summe$PinPort1$Pvalue localData->algebraics[3]
#define $Summe$Presult$Pvalue localData->algebraics[2]
#define $GL6$PinPort$Pvalue localData->algebraics[1]
#define $GL3$PinPort$Pvalue localData->algebraics[0]
#define $$dummy localData->states[0]
#define $DER$$dummy localData->statesDerivatives[0]

char* getName( double* ptr)
{
  if( &$TAB2$Pout$Pvalue == ptr ) return algvars_names[16];
  if( &$TAB2$Pin_y$Pvalue == ptr ) return algvars_names[15];
  if( &$TAB2$Pin_x$Pvalue == ptr ) return algvars_names[14];
  if( &$GL6$Presult$Pvalue == ptr ) return output_names[6];
  if( &$GL6$Presult$Pvalue == ptr ) return algvars_names[13];
  if( &$GL5$Presult$Pvalue == ptr ) return output_names[5];
  if( &$GL5$Presult$Pvalue == ptr ) return algvars_names[12];
  if( &$GL4$Presult$Pvalue == ptr ) return output_names[4];
  if( &$GL4$Presult$Pvalue == ptr ) return algvars_names[11];
  if( &$TAB1$Pout$Pvalue == ptr ) return algvars_names[10];
  if( &$TAB1$Pin_y$Pvalue == ptr ) return algvars_names[9];
  if( &$TAB1$Pin_x$Pvalue == ptr ) return algvars_names[8];
  if( &$GL3$Presult$Pvalue == ptr ) return output_names[3];
  if( &$GL3$Presult$Pvalue == ptr ) return algvars_names[7];
  if( &$GL2$Presult$Pvalue == ptr ) return output_names[2];
  if( &$GL2$Presult$Pvalue == ptr ) return algvars_names[6];
  if( &$GL1$Presult$Pvalue == ptr ) return output_names[1];
  if( &$GL1$Presult$Pvalue == ptr ) return algvars_names[5];
  if( &$TAB2$Pmethod_y == ptr ) return param_names[7];
  if( &$TAB2$Pmethod_x == ptr ) return param_names[6];
  if( &$GL5$Px == ptr ) return param_names[5];
  if( &$GL4$Px == ptr ) return param_names[4];
  if( &$TAB1$Pmethod_y == ptr ) return param_names[3];
  if( &$TAB1$Pmethod_x == ptr ) return param_names[2];
  if( &$GL2$Px == ptr ) return param_names[1];
  if( &$GL1$Px == ptr ) return param_names[0];
  if( &$Summe$PinPort2$Pvalue == ptr ) return algvars_names[4];
  if( &$Summe$PinPort1$Pvalue == ptr ) return algvars_names[3];
  if( &$Summe$Presult$Pvalue == ptr ) return output_names[0];
  if( &$Summe$Presult$Pvalue == ptr ) return algvars_names[2];
  if( &$GL6$PinPort$Pvalue == ptr ) return algvars_names[1];
  if( &$GL3$PinPort$Pvalue == ptr ) return algvars_names[0];
  if( &$DER$$dummy == ptr ) return derivative_names[0];
  if( &$$dummy == ptr ) return state_names[0];
  return "";
}

static char init_fixed[NX+NX+NY+NP]={
    1/*$dummy*/, 1/*default*/, 0/*GL3.inPort.value*/, 0/*GL6.inPort.value*/,
    0/*Summe.result.value*/, 0/*Summe.inPort1.value*/, 0/*Summe.inPort2.value*/,
    0/*GL1.result.value*/, 0/*GL2.result.value*/, 0/*GL3.result.value*/,
    0/*TAB1.in_x.value*/, 0/*TAB1.in_y.value*/, 0/*TAB1.out.value*/,
    0/*GL4.result.value*/, 0/*GL5.result.value*/, 0/*GL6.result.value*/,
    0/*TAB2.in_x.value*/, 0/*TAB2.in_y.value*/, 0/*TAB2.out.value*/,
    1/*GL1.x*/, 1/*GL2.x*/, 1/*TAB1.method_x*/,
    1/*TAB1.method_y*/, 1/*GL4.x*/, 1/*GL5.x*/,
    1/*TAB2.method_x*/, 1/*TAB2.method_y*/
};

char var_attr[NX+NY+NP]={/*$dummy:*/1+0, /*GL3.inPort.value:*/1+0, /*GL6.inPort.value:*/1+0, /*Summe.result.value:*/1+0,
/*Summe.inPort1.value:*/1+0, /*Summe.inPort2.value:*/1+0, /*GL1.result.value:*/1+0,
/*GL2.result.value:*/1+0, /*GL3.result.value:*/1+0, /*TAB1.in_x.value:*/1+0,
/*TAB1.in_y.value:*/1+0, /*TAB1.out.value:*/1+0, /*GL4.result.value:*/1+0,
/*GL5.result.value:*/1+0, /*GL6.result.value:*/1+0, /*TAB2.in_x.value:*/1+0,
/*TAB2.in_y.value:*/1+0, /*TAB2.out.value:*/1+0, /*GL1.x:*/1,
/*GL2.x:*/1, /*TAB1.method_x:*/4, /*TAB1.method_y:*/4,
/*GL4.x:*/1, /*GL5.x:*/1, /*TAB2.method_x:*/4,
/*TAB2.method_y:*/4};

#define DIVISION(a,b,c) ((b != 0) ? a / b : a / division_error(b,c))


int encounteredDivisionByZero = 0;
double division_error(double b,const char* division_str)
{
  if(!encounteredDivisionByZero){
    fprintf(stderr,"ERROR: Division by zero in partial equation: %s.\n",division_str);
    encounteredDivisionByZero = 1;
   }
   return b;
}

void setLocalData(DATA* data)
{
   localData = data;
}

DATA* initializeDataStruc(DATA_FLAGS flags)
{
  DATA* returnData = (DATA*)malloc(sizeof(DATA));

  if(!returnData) //error check
    return 0;

  memset(returnData,0,sizeof(DATA));
  returnData->nStates = NX;
  returnData->nAlgebraic = NY;
  returnData->nParameters = NP;
  returnData->nInputVars = NI;
  returnData->nOutputVars = NO;
  returnData->nZeroCrossing = NG;
  returnData->nInitialResiduals = NR;
  returnData->nHelpVars = NHELP;
  returnData->stringVariables.nParameters = NPSTR;
  returnData->stringVariables.nAlgebraic = NYSTR;

  if(flags & STATES && returnData->nStates) {
    returnData->states = (double*) malloc(sizeof(double)*returnData->nStates);
    returnData->oldStates = (double*) malloc(sizeof(double)*returnData->nStates);
    returnData->oldStates2 = (double*) malloc(sizeof(double)*returnData->nStates);
    assert(returnData->states&&returnData->oldStates&&returnData->oldStates2);
    memset(returnData->states,0,sizeof(double)*returnData->nStates);
    memset(returnData->oldStates,0,sizeof(double)*returnData->nStates);
    memset(returnData->oldStates2,0,sizeof(double)*returnData->nStates);
  } else {
    returnData->states = 0;
    returnData->oldStates = 0;
    returnData->oldStates2 = 0;
  }

  if(flags & STATESDERIVATIVES && returnData->nStates) {
    returnData->statesDerivatives = (double*) malloc(sizeof(double)*returnData->nStates);
    returnData->oldStatesDerivatives = (double*) malloc(sizeof(double)*returnData->nStates);
    returnData->oldStatesDerivatives2 = (double*) malloc(sizeof(double)*returnData->nStates);
    assert(returnData->statesDerivatives&&returnData->oldStatesDerivatives&&returnData->oldStatesDerivatives2);
    memset(returnData->statesDerivatives,0,sizeof(double)*returnData->nStates);
    memset(returnData->oldStatesDerivatives,0,sizeof(double)*returnData->nStates);
    memset(returnData->oldStatesDerivatives2,0,sizeof(double)*returnData->nStates);
  } else {
    returnData->statesDerivatives = 0;
    returnData->oldStatesDerivatives = 0;
    returnData->oldStatesDerivatives2 = 0;
  }

  if(flags & HELPVARS && returnData->nHelpVars) {
    returnData->helpVars = (double*) malloc(sizeof(double)*returnData->nHelpVars);
    assert(returnData->helpVars);
    memset(returnData->helpVars,0,sizeof(double)*returnData->nHelpVars);
  } else {
    returnData->helpVars = 0;
  }

  if(flags & ALGEBRAICS && returnData->nAlgebraic) {
    returnData->algebraics = (double*) malloc(sizeof(double)*returnData->nAlgebraic);
    returnData->oldAlgebraics = (double*) malloc(sizeof(double)*returnData->nAlgebraic);
    returnData->oldAlgebraics2 = (double*) malloc(sizeof(double)*returnData->nAlgebraic);
    assert(returnData->algebraics&&returnData->oldAlgebraics&&returnData->oldAlgebraics2);
    memset(returnData->algebraics,0,sizeof(double)*returnData->nAlgebraic);
    memset(returnData->oldAlgebraics,0,sizeof(double)*returnData->nAlgebraic);
    memset(returnData->oldAlgebraics2,0,sizeof(double)*returnData->nAlgebraic);
  } else {
    returnData->algebraics = 0;
    returnData->oldAlgebraics = 0;
    returnData->oldAlgebraics2 = 0;
    returnData->stringVariables.algebraics = 0;
  }

  if (flags & ALGEBRAICS && returnData->stringVariables.nAlgebraic) {
    returnData->stringVariables.algebraics = (char**)malloc(sizeof(char*)*returnData->stringVariables.nAlgebraic);
    assert(returnData->stringVariables.algebraics);
    memset(returnData->stringVariables.algebraics,0,sizeof(char*)*returnData->stringVariables.nAlgebraic);
  } else {
    returnData->stringVariables.algebraics=0;
  }

  if(flags & PARAMETERS && returnData->nParameters) {
    returnData->parameters = (double*) malloc(sizeof(double)*returnData->nParameters);
    assert(returnData->parameters);
    memset(returnData->parameters,0,sizeof(double)*returnData->nParameters);
  } else {
    returnData->parameters = 0;
  }

  if (flags & PARAMETERS && returnData->stringVariables.nParameters) {
        returnData->stringVariables.parameters = (char**)malloc(sizeof(char*)*returnData->stringVariables.nParameters);
      assert(returnData->stringVariables.parameters);
      memset(returnData->stringVariables.parameters,0,sizeof(char*)*returnData->stringVariables.nParameters);
  } else {
      returnData->stringVariables.parameters=0;
  }

  if(flags & OUTPUTVARS && returnData->nOutputVars) {
    returnData->outputVars = (double*) malloc(sizeof(double)*returnData->nOutputVars);
    assert(returnData->outputVars);
    memset(returnData->outputVars,0,sizeof(double)*returnData->nOutputVars);
  } else {
    returnData->outputVars = 0;
  }

  if(flags & INPUTVARS && returnData->nInputVars) {
    returnData->inputVars = (double*) malloc(sizeof(double)*returnData->nInputVars);
    assert(returnData->inputVars);
    memset(returnData->inputVars,0,sizeof(double)*returnData->nInputVars);
  } else {
    returnData->inputVars = 0;
  }

  if(flags & INITIALRESIDUALS && returnData->nInitialResiduals) {
    returnData->initialResiduals = (double*) malloc(sizeof(double)*returnData->nInitialResiduals);
    assert(returnData->initialResiduals);
    memset(returnData->initialResiduals,0,sizeof(double)*returnData->nInitialResiduals);
  } else {
    returnData->initialResiduals = 0;
  }

  if(flags & INITFIXED) {
    returnData->initFixed = init_fixed;
  } else {
    returnData->initFixed = 0;
  }

  /*   names   */
  if(flags & MODELNAME) {
    returnData->modelName = model_name;
  } else {
    returnData->modelName = 0;
  }

  if(flags & STATESNAMES) {
    returnData->statesNames = state_names;
  } else {
    returnData->statesNames = 0;
  }

  if(flags & STATESDERIVATIVESNAMES) {
    returnData->stateDerivativesNames = derivative_names;
  } else {
    returnData->stateDerivativesNames = 0;
  }

  if(flags & ALGEBRAICSNAMES) {
    returnData->algebraicsNames = algvars_names;
  } else {
    returnData->algebraicsNames = 0;
  }

  if(flags & PARAMETERSNAMES) {
    returnData->parametersNames = param_names;
  } else {
    returnData->parametersNames = 0;
  }

  if(flags & INPUTNAMES) {
    returnData->inputNames = input_names;
  } else {
    returnData->inputNames = 0;
  }

  if(flags & OUTPUTNAMES) {
    returnData->outputNames = output_names;
  } else {
    returnData->outputNames = 0;
  }

  /*   comments  */
  if(flags & STATESCOMMENTS) {
    returnData->statesComments = state_comments;
  } else {
    returnData->statesComments = 0;
  }

  if(flags & STATESDERIVATIVESCOMMENTS) {
    returnData->stateDerivativesComments = derivative_comments;
  } else {
    returnData->stateDerivativesComments = 0;
  }

  if(flags & ALGEBRAICSCOMMENTS) {
    returnData->algebraicsComments = algvars_comments;
  } else {
    returnData->algebraicsComments = 0;
  }

  if(flags & PARAMETERSCOMMENTS) {
    returnData->parametersComments = param_comments;
  } else {
    returnData->parametersComments = 0;
  }

  if(flags & INPUTCOMMENTS) {
    returnData->inputComments = input_comments;
  } else {
    returnData->inputComments = 0;
  }

  if(flags & OUTPUTCOMMENTS) {
    returnData->outputComments = output_comments;
  } else {
    returnData->outputComments = 0;
  }

  if (flags & EXTERNALVARS) {
    returnData->extObjs = (void**)malloc(sizeof(void*)*NEXT);
    if (!returnData->extObjs) {
      printf("error allocating external objects\n");
      exit(-2);
    }
    memset(returnData->extObjs,0,sizeof(void*)*NEXT);
    setLocalData(returnData); /* must be set since used by constructors*/
  }
  return returnData;
}

void deInitializeDataStruc(DATA* data, DATA_FLAGS flags)
{
  if(!data)
    return;

  if(flags & STATES && data->states) {
    free(data->states);
    data->states = 0;
  }

  if(flags & STATESDERIVATIVES && data->statesDerivatives) {
    free(data->statesDerivatives);
    data->statesDerivatives = 0;
  }

  if(flags & ALGEBRAICS && data->algebraics) {
    free(data->algebraics);
    data->algebraics = 0;
  }

  if(flags & PARAMETERS && data->parameters) {
    free(data->parameters);
    data->parameters = 0;
  }

  if(flags & OUTPUTVARS && data->inputVars) {
    free(data->inputVars);
    data->inputVars = 0;
  }

  if(flags & INPUTVARS && data->outputVars) {
    free(data->outputVars);
    data->outputVars = 0;
  }

  if(flags & INITIALRESIDUALS && data->initialResiduals){
    free(data->initialResiduals);
    data->initialResiduals = 0;
  }
  if (flags & EXTERNALVARS && data->extObjs) {
    free(data->extObjs);
    data->extObjs = 0;
  }
}

int functionDAE_output()
{
  state mem_state;
  real_array tmp0;
  real_array tmp1;
  real_array tmp2;
  real_array tmp3;
  real_array tmp4;
  real_array tmp5;
  real_array tmp6;
  real_array tmp7;
  real_array tmp8;
  real_array tmp9;
  real_array tmp10;
  real_array tmp11;
  real_array tmp12;
  real_array tmp13;
  real_array tmp14;
  real_array tmp15;
  real_array tmp16;
  real_array tmp17;
  real_array tmp18;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype tmp19;
  sin_rettype tmp20;
  real_array tmp21;
  real_array tmp22;
  real_array tmp23;
  real_array tmp24;
  real_array tmp25;
  real_array tmp26;
  real_array tmp27;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype tmp28;
  sin_rettype tmp29;
  mem_state = get_memory_state();
  array_alloc_scalar_real_array(&tmp0, 5, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0, (modelica_real)5.0);
  array_alloc_scalar_real_array(&tmp1, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  promote_scalar_real_array(1.0, 2, &tmp2);
  promote_scalar_real_array(5.0, 2, &tmp3);
  promote_scalar_real_array(9.0, 2, &tmp4);
  promote_scalar_real_array(2.0, 2, &tmp5);
  promote_scalar_real_array(6.0, 2, &tmp6);
  promote_scalar_real_array(10.0, 2, &tmp7);
  promote_scalar_real_array(3.0, 2, &tmp8);
  promote_scalar_real_array(7.0, 2, &tmp9);
  promote_scalar_real_array(11.0, 2, &tmp10);
  promote_scalar_real_array(4.0, 2, &tmp11);
  promote_scalar_real_array(8.0, 2, &tmp12);
  promote_scalar_real_array(12.0, 2, &tmp13);
  cat_alloc_real_array(2, &tmp14, 3, &tmp2, &tmp3, &tmp4);
  cat_alloc_real_array(2, &tmp15, 3, &tmp5, &tmp6, &tmp7);
  cat_alloc_real_array(2, &tmp16, 3, &tmp8, &tmp9, &tmp10);
  cat_alloc_real_array(2, &tmp17, 3, &tmp11, &tmp12, &tmp13);
  cat_alloc_real_array(1, &tmp18, 4, &tmp14, &tmp15, &tmp16, &tmp17);
  tmp19 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(tmp0, tmp1, $GL4$Px, $GL5$Px, tmp18, $TAB2$Pmethod_x, $TAB2$Pmethod_y);
  $GL6$PinPort$Pvalue = tmp19.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype_1;
  tmp20 = sin((0.0174527777777778 * (time * $GL6$PinPort$Pvalue)));
  $Summe$PinPort2$Pvalue = tmp20;
  array_alloc_scalar_real_array(&tmp21, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_scalar_real_array(&tmp22, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_real_array(&tmp23, 4, &1.0, &5.0, &9.0, &13.0);
  array_alloc_real_array(&tmp24, 4, &2.0, &6.0, &10.0, &14.0);
  array_alloc_real_array(&tmp25, 4, &3.0, &7.0, &11.0, &15.0);
  array_alloc_real_array(&tmp26, 4, &4.0, &8.0, &12.0, &16.0);
  array_alloc_real_array(&tmp27, 4, &tmp23, &tmp24, &tmp25, &tmp26);
  tmp28 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(tmp21, tmp22, $GL1$Px, $GL2$Px, tmp27, $TAB1$Pmethod_x, $TAB1$Pmethod_y);
  $GL3$PinPort$Pvalue = tmp28.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype_1;
  tmp29 = sin((0.0174527777777778 * (time * $GL3$PinPort$Pvalue)));
  $Summe$PinPort1$Pvalue = tmp29;
  $Summe$Presult$Pvalue = ($Summe$PinPort1$Pvalue + $Summe$PinPort2$Pvalue);
  $GL1$Presult$Pvalue = $GL1$Px;
  $GL2$Presult$Pvalue = $GL2$Px;
  $GL4$Presult$Pvalue = $GL4$Px;
  $GL5$Presult$Pvalue = $GL5$Px;
  $TAB1$Pin_x$Pvalue = $GL1$Px;
  $TAB1$Pin_y$Pvalue = $GL2$Px;
  $TAB1$Pout$Pvalue = $GL3$PinPort$Pvalue;
  $TAB2$Pin_x$Pvalue = $GL4$Px;
  $TAB2$Pin_y$Pvalue = $GL5$Px;
  $TAB2$Pout$Pvalue = $GL6$PinPort$Pvalue;
  $GL6$Presult$Pvalue = $Summe$PinPort2$Pvalue;
  $GL3$Presult$Pvalue = $Summe$PinPort1$Pvalue;
  restore_memory_state(mem_state);
  return 0;
}

int functionDAE_output2()
{
  state mem_state;
  mem_state = get_memory_state();
  $GL1$Presult$Pvalue = $GL1$Px;
  $GL2$Presult$Pvalue = $GL2$Px;
  $GL4$Presult$Pvalue = $GL4$Px;
  $GL5$Presult$Pvalue = $GL5$Px;
  $TAB1$Pin_x$Pvalue = $GL1$Px;
  $TAB1$Pin_y$Pvalue = $GL2$Px;
  $TAB1$Pout$Pvalue = $GL3$PinPort$Pvalue;
  $TAB2$Pin_x$Pvalue = $GL4$Px;
  $TAB2$Pin_y$Pvalue = $GL5$Px;
  $TAB2$Pout$Pvalue = $GL6$PinPort$Pvalue;
  $GL6$Presult$Pvalue = $Summe$PinPort2$Pvalue;
  $GL3$Presult$Pvalue = $Summe$PinPort1$Pvalue;
  restore_memory_state(mem_state);
  return 0;
}

/*
*/
int input_function()
{
  return 0;
}

/*
*/
int output_function()
{
  localData->outputVars[0] =$GL6$Presult$Pvalue;
  localData->outputVars[1] =$GL5$Presult$Pvalue;
  localData->outputVars[2] =$GL4$Presult$Pvalue;
  localData->outputVars[3] =$GL3$Presult$Pvalue;
  localData->outputVars[4] =$GL2$Presult$Pvalue;
  localData->outputVars[5] =$GL1$Presult$Pvalue;
  localData->outputVars[6] =$Summe$Presult$Pvalue;return 0;
}

int functionDAE_res(double *t, double *x, double *xd, double *delta, fortran_integer *ires, double *rpar, fortran_integer* ipar)
{
  int i;
  double temp_xd[NX];
  double* statesBackup;
  double* statesDerivativesBackup;
  double timeBackup;
  statesBackup = localData->states;
  statesDerivativesBackup = localData->statesDerivatives;
  timeBackup = localData->timeValue;
  localData->states = x;
  for (i=0; i<localData->nStates; i++) temp_xd[i]=localData->statesDerivatives[i];
 
  localData->statesDerivatives = temp_xd;
  localData->timeValue = *t;
 
  functionODE();
  /* get the difference between the temp_xd(=localData->statesDerivatives) and xd(=statesDerivativesBackup) */
  for (i=0; i < localData->nStates; i++) delta[i]=localData->statesDerivatives[i]-statesDerivativesBackup[i];
 
  localData->states = statesBackup;
  localData->statesDerivatives = statesDerivativesBackup;
  localData->timeValue = timeBackup;
  if (modelErrorCode) {
      if (ires) *ires = -1;
      modelErrorCode =0;
  }
  return 0;
}

int function_zeroCrossing(fortran_integer *neqm, double *t, double *x, fortran_integer *ng, double *gout, double *rpar, fortran_integer* ipar)
{
  double timeBackup;
  state mem_state;
  mem_state = get_memory_state();
  timeBackup = localData->timeValue;
  localData->timeValue = *t;
  functionODE();
  functionDAE_output();
  restore_memory_state(mem_state);
  localData->timeValue = timeBackup;
  return 0;
}

int handleZeroCrossing(long index)
{
  state mem_state;
  mem_state = get_memory_state();
  switch(index) {
    default: break;
  }
  restore_memory_state(mem_state);
  return 0;
}

int function_updateDependents()
{
  state mem_state;
  real_array tmp0;
  real_array tmp1;
  real_array tmp2;
  real_array tmp3;
  real_array tmp4;
  real_array tmp5;
  real_array tmp6;
  real_array tmp7;
  real_array tmp8;
  real_array tmp9;
  real_array tmp10;
  real_array tmp11;
  real_array tmp12;
  real_array tmp13;
  real_array tmp14;
  real_array tmp15;
  real_array tmp16;
  real_array tmp17;
  real_array tmp18;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype tmp19;
  sin_rettype tmp20;
  real_array tmp21;
  real_array tmp22;
  real_array tmp23;
  real_array tmp24;
  real_array tmp25;
  real_array tmp26;
  real_array tmp27;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype tmp28;
  sin_rettype tmp29;
  inUpdate=initial()?0:1;
  mem_state = get_memory_state();
  $DER$$dummy = 0.0;
  array_alloc_scalar_real_array(&tmp0, 5, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0, (modelica_real)5.0);
  array_alloc_scalar_real_array(&tmp1, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  promote_scalar_real_array(1.0, 2, &tmp2);
  promote_scalar_real_array(5.0, 2, &tmp3);
  promote_scalar_real_array(9.0, 2, &tmp4);
  promote_scalar_real_array(2.0, 2, &tmp5);
  promote_scalar_real_array(6.0, 2, &tmp6);
  promote_scalar_real_array(10.0, 2, &tmp7);
  promote_scalar_real_array(3.0, 2, &tmp8);
  promote_scalar_real_array(7.0, 2, &tmp9);
  promote_scalar_real_array(11.0, 2, &tmp10);
  promote_scalar_real_array(4.0, 2, &tmp11);
  promote_scalar_real_array(8.0, 2, &tmp12);
  promote_scalar_real_array(12.0, 2, &tmp13);
  cat_alloc_real_array(2, &tmp14, 3, &tmp2, &tmp3, &tmp4);
  cat_alloc_real_array(2, &tmp15, 3, &tmp5, &tmp6, &tmp7);
  cat_alloc_real_array(2, &tmp16, 3, &tmp8, &tmp9, &tmp10);
  cat_alloc_real_array(2, &tmp17, 3, &tmp11, &tmp12, &tmp13);
  cat_alloc_real_array(1, &tmp18, 4, &tmp14, &tmp15, &tmp16, &tmp17);
  tmp19 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(tmp0, tmp1, $GL4$Px, $GL5$Px, tmp18, $TAB2$Pmethod_x, $TAB2$Pmethod_y);
  $GL6$PinPort$Pvalue = tmp19.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype_1;
  tmp20 = sin((0.0174527777777778 * (time * $GL6$PinPort$Pvalue)));
  $Summe$PinPort2$Pvalue = tmp20;
  array_alloc_scalar_real_array(&tmp21, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_scalar_real_array(&tmp22, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_real_array(&tmp23, 4, &1.0, &5.0, &9.0, &13.0);
  array_alloc_real_array(&tmp24, 4, &2.0, &6.0, &10.0, &14.0);
  array_alloc_real_array(&tmp25, 4, &3.0, &7.0, &11.0, &15.0);
  array_alloc_real_array(&tmp26, 4, &4.0, &8.0, &12.0, &16.0);
  array_alloc_real_array(&tmp27, 4, &tmp23, &tmp24, &tmp25, &tmp26);
  tmp28 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(tmp21, tmp22, $GL1$Px, $GL2$Px, tmp27, $TAB1$Pmethod_x, $TAB1$Pmethod_y);
  $GL3$PinPort$Pvalue = tmp28.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype_1;
  tmp29 = sin((0.0174527777777778 * (time * $GL3$PinPort$Pvalue)));
  $Summe$PinPort1$Pvalue = tmp29;
  $Summe$Presult$Pvalue = ($Summe$PinPort1$Pvalue + $Summe$PinPort2$Pvalue);
  restore_memory_state(mem_state);
  inUpdate=0;
  return 0;
}

int function_updateDepend()
{
  state mem_state;
  real_array tmp0;
  real_array tmp1;
  real_array tmp2;
  real_array tmp3;
  real_array tmp4;
  real_array tmp5;
  real_array tmp6;
  real_array tmp7;
  real_array tmp8;
  real_array tmp9;
  real_array tmp10;
  real_array tmp11;
  real_array tmp12;
  real_array tmp13;
  real_array tmp14;
  real_array tmp15;
  real_array tmp16;
  real_array tmp17;
  real_array tmp18;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype tmp19;
  sin_rettype tmp20;
  real_array tmp21;
  real_array tmp22;
  real_array tmp23;
  real_array tmp24;
  real_array tmp25;
  real_array tmp26;
  real_array tmp27;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype tmp28;
  sin_rettype tmp29;
  inUpdate=initial()?0:1;
  mem_state = get_memory_state();
  $DER$$dummy = 0.0;
  array_alloc_scalar_real_array(&tmp0, 5, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0, (modelica_real)5.0);
  array_alloc_scalar_real_array(&tmp1, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  promote_scalar_real_array(1.0, 2, &tmp2);
  promote_scalar_real_array(5.0, 2, &tmp3);
  promote_scalar_real_array(9.0, 2, &tmp4);
  promote_scalar_real_array(2.0, 2, &tmp5);
  promote_scalar_real_array(6.0, 2, &tmp6);
  promote_scalar_real_array(10.0, 2, &tmp7);
  promote_scalar_real_array(3.0, 2, &tmp8);
  promote_scalar_real_array(7.0, 2, &tmp9);
  promote_scalar_real_array(11.0, 2, &tmp10);
  promote_scalar_real_array(4.0, 2, &tmp11);
  promote_scalar_real_array(8.0, 2, &tmp12);
  promote_scalar_real_array(12.0, 2, &tmp13);
  cat_alloc_real_array(2, &tmp14, 3, &tmp2, &tmp3, &tmp4);
  cat_alloc_real_array(2, &tmp15, 3, &tmp5, &tmp6, &tmp7);
  cat_alloc_real_array(2, &tmp16, 3, &tmp8, &tmp9, &tmp10);
  cat_alloc_real_array(2, &tmp17, 3, &tmp11, &tmp12, &tmp13);
  cat_alloc_real_array(1, &tmp18, 4, &tmp14, &tmp15, &tmp16, &tmp17);
  tmp19 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(tmp0, tmp1, $GL4$Px, $GL5$Px, tmp18, $TAB2$Pmethod_x, $TAB2$Pmethod_y);
  $GL6$PinPort$Pvalue = tmp19.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype_1;
  tmp20 = sin((0.0174527777777778 * (time * $GL6$PinPort$Pvalue)));
  $Summe$PinPort2$Pvalue = tmp20;
  array_alloc_scalar_real_array(&tmp21, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_scalar_real_array(&tmp22, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_real_array(&tmp23, 4, &1.0, &5.0, &9.0, &13.0);
  array_alloc_real_array(&tmp24, 4, &2.0, &6.0, &10.0, &14.0);
  array_alloc_real_array(&tmp25, 4, &3.0, &7.0, &11.0, &15.0);
  array_alloc_real_array(&tmp26, 4, &4.0, &8.0, &12.0, &16.0);
  array_alloc_real_array(&tmp27, 4, &tmp23, &tmp24, &tmp25, &tmp26);
  tmp28 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(tmp21, tmp22, $GL1$Px, $GL2$Px, tmp27, $TAB1$Pmethod_x, $TAB1$Pmethod_y);
  $GL3$PinPort$Pvalue = tmp28.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype_1;
  tmp29 = sin((0.0174527777777778 * (time * $GL3$PinPort$Pvalue)));
  $Summe$PinPort1$Pvalue = tmp29;
  $Summe$Presult$Pvalue = ($Summe$PinPort1$Pvalue + $Summe$PinPort2$Pvalue);
  restore_memory_state(mem_state);
  inUpdate=0;
  return 0;
}

int function_onlyZeroCrossings(double *gout,double *t)
{
  state mem_state;
  mem_state = get_memory_state();
  restore_memory_state(mem_state);
  return 0;
}

int checkForDiscreteChanges()
{
  int needToIterate=0;

  return needToIterate;
}
int function_storeDelayed()
{
  state mem_state;
  mem_state = get_memory_state();
  restore_memory_state(mem_state);
  return 0;
}

int function_when(int i)
{
  state mem_state;
  mem_state = get_memory_state();
  switch(i) {
    default: break;
  }
  restore_memory_state(mem_state);
  return 0;
}

int functionODE()
{
  state mem_state;
  mem_state = get_memory_state();
  $DER$$dummy = 0.0;
  restore_memory_state(mem_state);
  return 0;
}

int initial_function()
{
  return 0;
}

int initial_residual()
{
  sin_rettype tmp0;
  real_array tmp1;
  real_array tmp2;
  real_array tmp3;
  real_array tmp4;
  real_array tmp5;
  real_array tmp6;
  real_array tmp7;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype tmp8;
  sin_rettype tmp9;
  real_array tmp10;
  real_array tmp11;
  real_array tmp12;
  real_array tmp13;
  real_array tmp14;
  real_array tmp15;
  real_array tmp16;
  real_array tmp17;
  real_array tmp18;
  real_array tmp19;
  real_array tmp20;
  real_array tmp21;
  real_array tmp22;
  real_array tmp23;
  real_array tmp24;
  real_array tmp25;
  real_array tmp26;
  real_array tmp27;
  real_array tmp28;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype tmp29;
  int i=0;
  state mem_state;
  mem_state = get_memory_state();
  tmp0 = sin((0.0174527777777778 * (time * $GL3$PinPort$Pvalue)));
  localData->initialResiduals[i++] = ($Summe$PinPort1$Pvalue - tmp0);
  array_alloc_scalar_real_array(&tmp1, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_scalar_real_array(&tmp2, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  array_alloc_real_array(&tmp3, 4, &1.0, &5.0, &9.0, &13.0);
  array_alloc_real_array(&tmp4, 4, &2.0, &6.0, &10.0, &14.0);
  array_alloc_real_array(&tmp5, 4, &3.0, &7.0, &11.0, &15.0);
  array_alloc_real_array(&tmp6, 4, &4.0, &8.0, &12.0, &16.0);
  array_alloc_real_array(&tmp7, 4, &tmp3, &tmp4, &tmp5, &tmp6);
  tmp8 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(tmp1, tmp2, $GL1$Px, $GL2$Px, tmp7, $TAB1$Pmethod_x, $TAB1$Pmethod_y);
  localData->initialResiduals[i++] = ($GL3$PinPort$Pvalue - tmp8.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype_1);
  tmp9 = sin((0.0174527777777778 * (time * $GL6$PinPort$Pvalue)));
  localData->initialResiduals[i++] = ($Summe$PinPort2$Pvalue - tmp9);
  array_alloc_scalar_real_array(&tmp10, 5, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0, (modelica_real)5.0);
  array_alloc_scalar_real_array(&tmp11, 4, (modelica_real)1.0, (modelica_real)2.0, (modelica_real)3.0, (modelica_real)4.0);
  promote_scalar_real_array(1.0, 2, &tmp12);
  promote_scalar_real_array(5.0, 2, &tmp13);
  promote_scalar_real_array(9.0, 2, &tmp14);
  promote_scalar_real_array(2.0, 2, &tmp15);
  promote_scalar_real_array(6.0, 2, &tmp16);
  promote_scalar_real_array(10.0, 2, &tmp17);
  promote_scalar_real_array(3.0, 2, &tmp18);
  promote_scalar_real_array(7.0, 2, &tmp19);
  promote_scalar_real_array(11.0, 2, &tmp20);
  promote_scalar_real_array(4.0, 2, &tmp21);
  promote_scalar_real_array(8.0, 2, &tmp22);
  promote_scalar_real_array(12.0, 2, &tmp23);
  cat_alloc_real_array(2, &tmp24, 3, &tmp12, &tmp13, &tmp14);
  cat_alloc_real_array(2, &tmp25, 3, &tmp15, &tmp16, &tmp17);
  cat_alloc_real_array(2, &tmp26, 3, &tmp18, &tmp19, &tmp20);
  cat_alloc_real_array(2, &tmp27, 3, &tmp21, &tmp22, &tmp23);
  cat_alloc_real_array(1, &tmp28, 4, &tmp24, &tmp25, &tmp26, &tmp27);
  tmp29 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(tmp10, tmp11, $GL4$Px, $GL5$Px, tmp28, $TAB2$Pmethod_x, $TAB2$Pmethod_y);
  localData->initialResiduals[i++] = ($GL6$PinPort$Pvalue - tmp29.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype_1);
  localData->initialResiduals[i++] = ($Summe$Presult$Pvalue - ($Summe$PinPort1$Pvalue + $Summe$PinPort2$Pvalue));
  localData->initialResiduals[i++] = $DER$$dummy;
  localData->initialResiduals[i++] = ($GL1$Presult$Pvalue - $GL1$Px);
  localData->initialResiduals[i++] = ($GL2$Presult$Pvalue - $GL2$Px);
  localData->initialResiduals[i++] = ($GL4$Presult$Pvalue - $GL4$Px);
  localData->initialResiduals[i++] = ($GL5$Presult$Pvalue - $GL5$Px);
  localData->initialResiduals[i++] = ($TAB1$Pin_x$Pvalue - $GL1$Px);
  localData->initialResiduals[i++] = ($TAB1$Pin_y$Pvalue - $GL2$Px);
  localData->initialResiduals[i++] = ($TAB1$Pout$Pvalue - $GL3$PinPort$Pvalue);
  localData->initialResiduals[i++] = ($TAB2$Pin_x$Pvalue - $GL4$Px);
  localData->initialResiduals[i++] = ($TAB2$Pin_y$Pvalue - $GL5$Px);
  localData->initialResiduals[i++] = ($TAB2$Pout$Pvalue - $GL6$PinPort$Pvalue);
  localData->initialResiduals[i++] = ($GL6$Presult$Pvalue - $Summe$PinPort2$Pvalue);
  localData->initialResiduals[i++] = ($GL3$Presult$Pvalue - $Summe$PinPort1$Pvalue);
  restore_memory_state(mem_state);
  return 0;
}

int bound_parameters()
{
  state mem_state;
  mem_state = get_memory_state();
  restore_memory_state(mem_state);
  return 0;
}

int checkForDiscreteVarChanges()
{
  int needToIterate=0;
 
  for (long i = 0; i < localData->nHelpVars; i++) {
    if (change(localData->helpVars[i])) { needToIterate=1; }
  }
  return needToIterate;
}

Apr-25-10 22:27:19
Model does not compile any longer

...Viola!

This is the functions .cpp:

Code:


#ifdef __cplusplus
extern "C" {
#endif
/* header part */
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_s
{
    modelica_integer targ1; /* [] */
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(real_array array, modelica_real value);

DLLExport
int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(type_description * inArgs, type_description * outVar);
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_s
{
    modelica_real targ1; /* [] */
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(modelica_real lowerIndex, modelica_real interimIndex, modelica_real upperIndex, modelica_real lowerValue, modelica_real upperValue);

DLLExport
int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(type_description * inArgs, type_description * outVar);
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettypeboxed_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettypeboxed_s
{
  modelica_metatype targ1;
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettypeboxed;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettypeboxed boxptr_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(modelica_metatype lowerIndex, modelica_metatype interimIndex, modelica_metatype upperIndex, modelica_metatype lowerValue, modelica_metatype upperValue);
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_s
{
    modelica_integer targ1; /* [] */
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(real_array array, modelica_real value);

DLLExport
int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(type_description * inArgs, type_description * outVar);
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_s
{
    modelica_real targ1; /* [] */
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(modelica_real lowerIndex, modelica_real interimIndex, modelica_real upperIndex, modelica_real lowerValue, modelica_real upperValue);

DLLExport
int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(type_description * inArgs, type_description * outVar);
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettypeboxed_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettypeboxed_s
{
  modelica_metatype targ1;
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettypeboxed;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettypeboxed boxptr_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(modelica_metatype lowerIndex, modelica_metatype interimIndex, modelica_metatype upperIndex, modelica_metatype lowerValue, modelica_metatype upperValue);
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype_s
{
    modelica_real targ1; /* [] */
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(real_array header_x, real_array header_y, modelica_real value_x, modelica_real value_y, real_array tableData, modelica_integer method_x, modelica_integer method_y);

DLLExport
int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(type_description * inArgs, type_description * outVar);
#define OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype_1 targ1
typedef struct OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype_s
{
    modelica_real targ1; /* [] */
} OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype;

DLLExport
OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(real_array header_x, real_array header_y, modelica_real value_x, modelica_real value_y, real_array tableData, modelica_integer method_x, modelica_integer method_y);

DLLExport
int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(type_description * inArgs, type_description * outVar);
/* End of header part */

/* Body */
OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(real_array array, modelica_real value)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype tmp1;
  state tmp2;
  modelica_integer index;
  modelica_real minDistance;
  modelica_real tmp3;
  size_t tmp9;
  state tmp4;
  modelica_integer tmp6;
  modelica_integer tmp7;
  modelica_integer tmp8;
  modelica_real tmp10;
  modelica_real tmp11;
  tmp2 = get_memory_state();
  tmp3 = fabs((value - (*real_array_element_addr1(&array, 1, 1))));
  minDistance = tmp3;
  index = 1;
  tmp9 = size_of_dimension_real_array(array,1);
  tmp6 = 2; tmp7 = (1); tmp8 = tmp9;
  {
  modelica_integer x;

    for (x = tmp6; in_range_integer(x, tmp6, tmp8); x += tmp7) {
      tmp4 = get_memory_state();
      tmp10 = fabs((value - (*real_array_element_addr1(&array, 1, (modelica_integer)x))));
      if ((tmp10 < minDistance)) {
        tmp11 = fabs((value - (*real_array_element_addr1(&array, 1, (modelica_integer)x))));
        minDistance = tmp11;
        index = (modelica_integer)x;
      }
      restore_memory_state(tmp4);
    }
  } /* end for*/

 
  _return:
  tmp1.targ1 = index;
  restore_memory_state(tmp2);
  return tmp1;
}

int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(type_description * inArgs, type_description * outVar)
{
  real_array array; /* [:] */
  modelica_real value;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype out;
  if(read_real_array(&inArgs, &array)) return 1;
  if(read_modelica_real(&inArgs, &value)) return 1;
  out = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(array, value);
  write_modelica_integer(outVar, &out.targ1);
  return 0;
}

OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(modelica_real lowerIndex, modelica_real interimIndex, modelica_real upperIndex, modelica_real lowerValue, modelica_real upperValue)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp1;
  state tmp2;
  modelica_real interimValue;
  tmp2 = get_memory_state();
  interimValue = (lowerValue + ((upperValue - lowerValue) * ((interimIndex - lowerIndex) / (upperIndex - lowerIndex))));
 
  _return:
  tmp1.targ1 = interimValue;
  restore_memory_state(tmp2);
  return tmp1;
}

int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(type_description * inArgs, type_description * outVar)
{
  modelica_real lowerIndex;
  modelica_real interimIndex;
  modelica_real upperIndex;
  modelica_real lowerValue;
  modelica_real upperValue;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype out;
  if(read_modelica_real(&inArgs, &lowerIndex)) return 1;
  if(read_modelica_real(&inArgs, &interimIndex)) return 1;
  if(read_modelica_real(&inArgs, &upperIndex)) return 1;
  if(read_modelica_real(&inArgs, &lowerValue)) return 1;
  if(read_modelica_real(&inArgs, &upperValue)) return 1;
  out = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(lowerIndex, interimIndex, upperIndex, lowerValue, upperValue);
  write_modelica_real(outVar, &out.targ1);
  return 0;
}

OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettypeboxed boxptr_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(modelica_metatype lowerIndex, modelica_metatype interimIndex, modelica_metatype upperIndex, modelica_metatype lowerValue, modelica_metatype upperValue)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettypeboxed tmp1;
  state tmp9;
  mmc__unbox__real_rettype tmp2;
  mmc__unbox__real_rettype tmp3;
  mmc__unbox__real_rettype tmp4;
  mmc__unbox__real_rettype tmp5;
  mmc__unbox__real_rettype tmp6;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp7;
  mmc__mk__rcon_rettype tmp8;
  tmp9 = get_memory_state();
  tmp2 = mmc__unbox__real(lowerIndex);
  tmp3 = mmc__unbox__real(interimIndex);
  tmp4 = mmc__unbox__real(upperIndex);
  tmp5 = mmc__unbox__real(lowerValue);
  tmp6 = mmc__unbox__real(upperValue);
  tmp7 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate(tmp2, tmp3, tmp4, tmp5, tmp6);
  tmp8 = mmc__mk__rcon(tmp7.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1);
  tmp1.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettypeboxed_1 = tmp8;
  restore_memory_state(tmp9);
  return tmp1;
}

OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(real_array array, modelica_real value)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype tmp1;
  state tmp2;
  modelica_integer index;
  modelica_real minDistance;
  modelica_real tmp3;
  size_t tmp9;
  state tmp4;
  modelica_integer tmp6;
  modelica_integer tmp7;
  modelica_integer tmp8;
  modelica_real tmp10;
  modelica_real tmp11;
  tmp2 = get_memory_state();
  tmp3 = fabs((value - (*real_array_element_addr1(&array, 1, 1))));
  minDistance = tmp3;
  index = 1;
  tmp9 = size_of_dimension_real_array(array,1);
  tmp6 = 2; tmp7 = (1); tmp8 = tmp9;
  {
  modelica_integer x;

    for (x = tmp6; in_range_integer(x, tmp6, tmp8); x += tmp7) {
      tmp4 = get_memory_state();
      tmp10 = fabs((value - (*real_array_element_addr1(&array, 1, (modelica_integer)x))));
      if ((tmp10 < minDistance)) {
        tmp11 = fabs((value - (*real_array_element_addr1(&array, 1, (modelica_integer)x))));
        minDistance = tmp11;
        index = (modelica_integer)x;
      }
      restore_memory_state(tmp4);
    }
  } /* end for*/

 
  _return:
  tmp1.targ1 = index;
  restore_memory_state(tmp2);
  return tmp1;
}

int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(type_description * inArgs, type_description * outVar)
{
  real_array array; /* [:] */
  modelica_real value;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype out;
  if(read_real_array(&inArgs, &array)) return 1;
  if(read_modelica_real(&inArgs, &value)) return 1;
  out = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(array, value);
  write_modelica_integer(outVar, &out.targ1);
  return 0;
}

OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(modelica_real lowerIndex, modelica_real interimIndex, modelica_real upperIndex, modelica_real lowerValue, modelica_real upperValue)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp1;
  state tmp2;
  modelica_real interimValue;
  tmp2 = get_memory_state();
  interimValue = (lowerValue + ((upperValue - lowerValue) * ((interimIndex - lowerIndex) / (upperIndex - lowerIndex))));
 
  _return:
  tmp1.targ1 = interimValue;
  restore_memory_state(tmp2);
  return tmp1;
}

int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(type_description * inArgs, type_description * outVar)
{
  modelica_real lowerIndex;
  modelica_real interimIndex;
  modelica_real upperIndex;
  modelica_real lowerValue;
  modelica_real upperValue;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype out;
  if(read_modelica_real(&inArgs, &lowerIndex)) return 1;
  if(read_modelica_real(&inArgs, &interimIndex)) return 1;
  if(read_modelica_real(&inArgs, &upperIndex)) return 1;
  if(read_modelica_real(&inArgs, &lowerValue)) return 1;
  if(read_modelica_real(&inArgs, &upperValue)) return 1;
  out = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(lowerIndex, interimIndex, upperIndex, lowerValue, upperValue);
  write_modelica_real(outVar, &out.targ1);
  return 0;
}

OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettypeboxed boxptr_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(modelica_metatype lowerIndex, modelica_metatype interimIndex, modelica_metatype upperIndex, modelica_metatype lowerValue, modelica_metatype upperValue)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettypeboxed tmp1;
  state tmp9;
  mmc__unbox__real_rettype tmp2;
  mmc__unbox__real_rettype tmp3;
  mmc__unbox__real_rettype tmp4;
  mmc__unbox__real_rettype tmp5;
  mmc__unbox__real_rettype tmp6;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp7;
  mmc__mk__rcon_rettype tmp8;
  tmp9 = get_memory_state();
  tmp2 = mmc__unbox__real(lowerIndex);
  tmp3 = mmc__unbox__real(interimIndex);
  tmp4 = mmc__unbox__real(upperIndex);
  tmp5 = mmc__unbox__real(lowerValue);
  tmp6 = mmc__unbox__real(upperValue);
  tmp7 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate(tmp2, tmp3, tmp4, tmp5, tmp6);
  tmp8 = mmc__mk__rcon(tmp7.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1);
  tmp1.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettypeboxed_1 = tmp8;
  restore_memory_state(tmp9);
  return tmp1;
}

OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(real_array header_x, real_array header_y, modelica_real value_x, modelica_real value_y, real_array tableData, modelica_integer method_x, modelica_integer method_y)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype tmp1;
  state tmp2;
  modelica_real result;
  modelica_integer index_x;
  modelica_integer index_y;
  modelica_integer lower;
  modelica_integer upper;
  modelica_integer i;
  boolean_array extrapolate; /* [4] */
  modelica_string tmp3;
  size_t tmp4;
  size_t tmp5;
  modelica_string tmp6;
  size_t tmp7;
  size_t tmp8;
  modelica_string tmp9;
  size_t tmp10;
  size_t tmp11;
  modelica_string tmp12;
  size_t tmp13;
  size_t tmp14;
  modelica_string tmp15;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype tmp16;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype tmp17;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype tmp18;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp19;
  modelica_string tmp20;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp21;
  size_t tmp22;
  size_t tmp23;
  size_t tmp24;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp25;
  size_t tmp26;
  modelica_string tmp27;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp28;
  size_t tmp34;
  state tmp29;
  modelica_integer tmp31;
  modelica_integer tmp32;
  modelica_integer tmp33;
  size_t tmp40;
  state tmp35;
  modelica_integer tmp37;
  modelica_integer tmp38;
  modelica_integer tmp39;
  modelica_string tmp41;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype tmp42;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype tmp43;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype tmp44;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp45;
  modelica_string tmp46;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp47;
  size_t tmp48;
  size_t tmp49;
  size_t tmp50;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp51;
  size_t tmp52;
  modelica_string tmp53;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype tmp54;
  size_t tmp60;
  state tmp55;
  modelica_integer tmp57;
  modelica_integer tmp58;
  modelica_integer tmp59;
  size_t tmp66;
  state tmp61;
  modelica_integer tmp63;
  modelica_integer tmp64;
  modelica_integer tmp65;
  modelica_string tmp67;
  tmp2 = get_memory_state();
  alloc_boolean_array(&extrapolate, 1, 4);
  (*boolean_array_element_addr1(&extrapolate, 1, 1)) = (0);
  (*boolean_array_element_addr1(&extrapolate, 1, 2)) = (0);
  (*boolean_array_element_addr1(&extrapolate, 1, 3)) = (0);
  (*boolean_array_element_addr1(&extrapolate, 1, 4)) = (0);
  if ((method_x == 2)) {
    method_x = 3;
  }
  if ((method_x == 1)) {
    method_x = 3;
  }
  if ((method_y == 2)) {
    method_y = 3;
  }
  if ((method_y == 1)) {
    method_y = 3;
  }
  init_modelica_string(&tmp3,"Interpolation ist nur in einer Tabellendimension (Spalten oder Zeilen) moeglich.");
  MODELICA_ASSERT((!((method_x == 6) && (method_y == 6))), tmp3);
  if (((method_x == 3) || (method_x == 6))) {
    tmp4 = size_of_dimension_real_array(tableData,1);
    tmp5 = size_of_dimension_real_array(header_x,1);
    init_modelica_string(&tmp6,"Dimension der Kopfzeile ist inkompatibel zur Dimension der Tabellenbreite.");
    MODELICA_ASSERT((tmp4 == tmp5), tmp6);
  }
  else {
    if (((method_x == 4) || (method_x == 5))) {
      tmp7 = size_of_dimension_real_array(tableData,1);
      tmp8 = size_of_dimension_real_array(header_x,1);
      init_modelica_string(&tmp9,"Dimension der Kopfzeile ist inkompatibel zur Dimension der Tabellenbreite.");
      MODELICA_ASSERT((tmp7 == (tmp8 - 1)), tmp9);
    }
  }
  if (((method_y == 3) || (method_y == 6))) {
    tmp10 = size_of_dimension_real_array(tableData,2);
    tmp11 = size_of_dimension_real_array(header_y,1);
    init_modelica_string(&tmp12,"Dimension der Indexspalte ist inkompatibel zur Dimension der Tabellenhöhe.");
    MODELICA_ASSERT((tmp10 == tmp11), tmp12);
  }
  else {
    if (((method_y == 4) || (method_y == 5))) {
      tmp13 = size_of_dimension_real_array(tableData,2);
      tmp14 = size_of_dimension_real_array(header_y,1);
      init_modelica_string(&tmp15,"Dimension der Indexspalte ist inkompatibel zur Dimension der Tabellenhöhe.");
      MODELICA_ASSERT((tmp13 == (tmp14 - 1)), tmp15);
    }
  }
  if ((method_x == 3)) {
    tmp16 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(header_x, value_x);
    index_x = tmp16.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_1;
  }
  else {
    if ((method_x == 6)) {
      tmp17 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(header_x, value_x);
      index_x = tmp17.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_1;
      tmp18 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(header_y, value_y);
      index_y = tmp18.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_1;
      if ((value_x < (*real_array_element_addr1(&header_x, 1, (modelica_integer)index_x)))) {
        if ((((modelica_integer)index_x - 1) < 1)) {
          if ((*boolean_array_element_addr1(&extrapolate, 1, 1))) {
            lower = 1;
            upper = 2;
            tmp19 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
            result = tmp19.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
            goto _return;
          }
          else {
            init_modelica_string(&tmp20,"Spalten-Eingangswert erfodert Extrapolation am linken Tabellenrand.");
            MODELICA_ASSERT((!((((modelica_integer)index_x - 1) < 1) && (!(*boolean_array_element_addr1(&extrapolate, 1, 1))))), tmp20);
          }
        }
        else {
          lower = ((modelica_integer)index_x - 1);
          upper = (modelica_integer)index_x;
          tmp21 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
          result = tmp21.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
          goto _return;
        }
      }
      else {
        if ((value_x > (*real_array_element_addr1(&header_x, 1, (modelica_integer)index_x)))) {
          tmp22 = size_of_dimension_real_array(header_x,1);
          if (((1 + (modelica_integer)index_x) > tmp22)) {
            if ((*boolean_array_element_addr1(&extrapolate, 1, 2))) {
              tmp23 = size_of_dimension_real_array(header_x,1);
              lower = (tmp23 - 1);
              tmp24 = size_of_dimension_real_array(header_x,1);
              upper = tmp24;
              tmp25 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
              result = tmp25.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
              goto _return;
            }
            else {
              tmp26 = size_of_dimension_real_array(header_x,1);
              init_modelica_string(&tmp27,"Spalten-Eingangswert erfodert Extrapolation am rechten Tabellenrand.");
              MODELICA_ASSERT((!(((1 + (modelica_integer)index_x) > tmp26) && (!(*boolean_array_element_addr1(&extrapolate, 1, 2))))), tmp27);
            }
          }
          else {
            lower = (modelica_integer)index_x;
            upper = (1 + (modelica_integer)index_x);
            tmp28 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
            result = tmp28.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
            goto _return;
          }
        }
      }
    }
    else {
      if ((method_x == 4)) {
        tmp34 = size_of_dimension_real_array(header_x,1);
        tmp31 = 1; tmp32 = (1); tmp33 = (tmp34 - 1);
        {
  modelica_integer i;

          for (i = tmp31; in_range_integer(i, tmp31, tmp33); i += tmp32) {
            tmp29 = get_memory_state();
            if ((((*real_array_element_addr1(&header_x, 1, (modelica_integer)i)) <= value_x) && (value_x < (*real_array_element_addr1(&header_x, 1, (1 + (modelica_integer)i)))))) {
              index_x = (modelica_integer)i;
              break;
            }
            restore_memory_state(tmp29);
          }
        } /* end for*/

      }
      else {
        if ((method_x == 5)) {
          tmp40 = size_of_dimension_real_array(header_x,1);
          tmp37 = 1; tmp38 = (1); tmp39 = (tmp40 - 1);
          {
  modelica_integer i;

            for (i = tmp37; in_range_integer(i, tmp37, tmp39); i += tmp38) {
              tmp35 = get_memory_state();
              if ((((*real_array_element_addr1(&header_x, 1, (modelica_integer)i)) < value_x) && (value_x <= (*real_array_element_addr1(&header_x, 1, (1 + (modelica_integer)i)))))) {
                index_x = (modelica_integer)i;
                break;
              }
              restore_memory_state(tmp35);
            }
          } /* end for*/

        }
        else {
          init_modelica_string(&tmp41,"Unbekannte Lookup-Methode für Tabellenspalte.");
          MODELICA_ASSERT((0), tmp41);
        }
      }
    }
  }
  if ((method_y == 3)) {
    tmp42 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(header_y, value_y);
    index_y = tmp42.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_1;
  }
  else {
    if ((method_y == 6)) {
      tmp43 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(header_x, value_x);
      index_x = tmp43.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_1;
      tmp44 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex(header_y, value_y);
      index_y = tmp44.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_findClosestIndex_rettype_1;
      if ((value_y < (*real_array_element_addr1(&header_y, 1, (modelica_integer)index_y)))) {
        if ((((modelica_integer)index_y - 1) < 1)) {
          if ((*boolean_array_element_addr1(&extrapolate, 1, 3))) {
            lower = 1;
            upper = 2;
            tmp45 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
            result = tmp45.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
            goto _return;
          }
          else {
            init_modelica_string(&tmp46,"Zeilen-Eingangswert erfodert Extrapolation am unteren Tabellenrand.");
            MODELICA_ASSERT((!((((modelica_integer)index_y - 1) < 1) && (!(*boolean_array_element_addr1(&extrapolate, 1, 3))))), tmp46);
          }
        }
        else {
          lower = ((modelica_integer)index_y - 1);
          upper = (modelica_integer)index_y;
          tmp47 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
          result = tmp47.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
          goto _return;
        }
      }
      else {
        if ((value_y > (*real_array_element_addr1(&header_y, 1, (modelica_integer)index_y)))) {
          tmp48 = size_of_dimension_real_array(header_y,1);
          if (((1 + (modelica_integer)index_y) > tmp48)) {
            if ((*boolean_array_element_addr1(&extrapolate, 1, 4))) {
              tmp49 = size_of_dimension_real_array(header_y,1);
              lower = (tmp49 - 1);
              tmp50 = size_of_dimension_real_array(header_y,1);
              upper = tmp50;
              tmp51 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
              result = tmp51.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
              goto _return;
            }
            else {
              tmp52 = size_of_dimension_real_array(header_y,1);
              init_modelica_string(&tmp53,"Zeilen-Eingangswert erfodert Extrapolation am oberen Tabellenrand.");
              MODELICA_ASSERT((!(((1 + (modelica_integer)index_y) > tmp52) && (!(*boolean_array_element_addr1(&extrapolate, 1, 4))))), tmp53);
            }
          }
          else {
            lower = (modelica_integer)index_y;
            upper = (1 + (modelica_integer)index_y);
            tmp54 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
            result = tmp54.OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_interpolate_rettype_1;
            goto _return;
          }
        }
      }
    }
    else {
      if ((method_y == 4)) {
        tmp60 = size_of_dimension_real_array(header_y,1);
        tmp57 = 1; tmp58 = (1); tmp59 = (tmp60 - 1);
        {
  modelica_integer i;

          for (i = tmp57; in_range_integer(i, tmp57, tmp59); i += tmp58) {
            tmp55 = get_memory_state();
            if ((((*real_array_element_addr1(&header_y, 1, (modelica_integer)i)) <= value_y) && (value_y < (*real_array_element_addr1(&header_y, 1, (1 + (modelica_integer)i)))))) {
              index_y = (modelica_integer)i;
              break;
            }
            restore_memory_state(tmp55);
          }
        } /* end for*/

      }
      else {
        if ((method_y == 5)) {
          tmp66 = size_of_dimension_real_array(header_y,1);
          tmp63 = 1; tmp64 = (1); tmp65 = (tmp66 - 1);
          {
  modelica_integer i;

            for (i = tmp63; in_range_integer(i, tmp63, tmp65); i += tmp64) {
              tmp61 = get_memory_state();
              if ((((*real_array_element_addr1(&header_y, 1, (modelica_integer)i)) < value_y) && (value_y <= (*real_array_element_addr1(&header_y, 1, (1 + (modelica_integer)i)))))) {
                index_y = (modelica_integer)i;
                break;
              }
              restore_memory_state(tmp61);
            }
          } /* end for*/

        }
        else {
          init_modelica_string(&tmp67,"Unbekannte Lookup-Methode für Tabellenzeile.");
          MODELICA_ASSERT((0), tmp67);
        }
      }
    }
  }
  result = (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)index_y));
 
  _return:
  tmp1.targ1 = result;
  restore_memory_state(tmp2);
  return tmp1;
}

int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(type_description * inArgs, type_description * outVar)
{
  real_array header_x; /* [:] */
  real_array header_y; /* [:] */
  modelica_real value_x;
  modelica_real value_y;
  real_array tableData; /* [:, :] */
  modelica_integer method_x;
  modelica_integer method_y;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype out;
  if(read_real_array(&inArgs, &header_x)) return 1;
  if(read_real_array(&inArgs, &header_y)) return 1;
  if(read_modelica_real(&inArgs, &value_x)) return 1;
  if(read_modelica_real(&inArgs, &value_y)) return 1;
  if(read_real_array(&inArgs, &tableData)) return 1;
  if(read_modelica_integer(&inArgs, &method_x)) return 1;
  if(read_modelica_integer(&inArgs, &method_y)) return 1;
  out = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(header_x, header_y, value_x, value_y, tableData, method_x, method_y);
  write_modelica_real(outVar, &out.targ1);
  return 0;
}

OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(real_array header_x, real_array header_y, modelica_real value_x, modelica_real value_y, real_array tableData, modelica_integer method_x, modelica_integer method_y)
{
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype tmp1;
  state tmp2;
  modelica_real result;
  modelica_integer index_x;
  modelica_integer index_y;
  modelica_integer lower;
  modelica_integer upper;
  modelica_integer i;
  boolean_array extrapolate; /* [4] */
  modelica_string tmp3;
  size_t tmp4;
  size_t tmp5;
  modelica_string tmp6;
  size_t tmp7;
  size_t tmp8;
  modelica_string tmp9;
  size_t tmp10;
  size_t tmp11;
  modelica_string tmp12;
  size_t tmp13;
  size_t tmp14;
  modelica_string tmp15;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype tmp16;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype tmp17;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype tmp18;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp19;
  modelica_string tmp20;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp21;
  size_t tmp22;
  size_t tmp23;
  size_t tmp24;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp25;
  size_t tmp26;
  modelica_string tmp27;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp28;
  size_t tmp34;
  state tmp29;
  modelica_integer tmp31;
  modelica_integer tmp32;
  modelica_integer tmp33;
  size_t tmp40;
  state tmp35;
  modelica_integer tmp37;
  modelica_integer tmp38;
  modelica_integer tmp39;
  modelica_string tmp41;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype tmp42;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype tmp43;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype tmp44;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp45;
  modelica_string tmp46;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp47;
  size_t tmp48;
  size_t tmp49;
  size_t tmp50;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp51;
  size_t tmp52;
  modelica_string tmp53;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype tmp54;
  size_t tmp60;
  state tmp55;
  modelica_integer tmp57;
  modelica_integer tmp58;
  modelica_integer tmp59;
  size_t tmp66;
  state tmp61;
  modelica_integer tmp63;
  modelica_integer tmp64;
  modelica_integer tmp65;
  modelica_string tmp67;
  tmp2 = get_memory_state();
  alloc_boolean_array(&extrapolate, 1, 4);
  (*boolean_array_element_addr1(&extrapolate, 1, 1)) = (0);
  (*boolean_array_element_addr1(&extrapolate, 1, 2)) = (0);
  (*boolean_array_element_addr1(&extrapolate, 1, 3)) = (0);
  (*boolean_array_element_addr1(&extrapolate, 1, 4)) = (0);
  if ((method_x == 2)) {
    method_x = 3;
  }
  if ((method_x == 1)) {
    method_x = 3;
  }
  if ((method_y == 2)) {
    method_y = 3;
  }
  if ((method_y == 1)) {
    method_y = 3;
  }
  init_modelica_string(&tmp3,"Interpolation ist nur in einer Tabellendimension (Spalten oder Zeilen) moeglich.");
  MODELICA_ASSERT((!((method_x == 6) && (method_y == 6))), tmp3);
  if (((method_x == 3) || (method_x == 6))) {
    tmp4 = size_of_dimension_real_array(tableData,1);
    tmp5 = size_of_dimension_real_array(header_x,1);
    init_modelica_string(&tmp6,"Dimension der Kopfzeile ist inkompatibel zur Dimension der Tabellenbreite.");
    MODELICA_ASSERT((tmp4 == tmp5), tmp6);
  }
  else {
    if (((method_x == 4) || (method_x == 5))) {
      tmp7 = size_of_dimension_real_array(tableData,1);
      tmp8 = size_of_dimension_real_array(header_x,1);
      init_modelica_string(&tmp9,"Dimension der Kopfzeile ist inkompatibel zur Dimension der Tabellenbreite.");
      MODELICA_ASSERT((tmp7 == (tmp8 - 1)), tmp9);
    }
  }
  if (((method_y == 3) || (method_y == 6))) {
    tmp10 = size_of_dimension_real_array(tableData,2);
    tmp11 = size_of_dimension_real_array(header_y,1);
    init_modelica_string(&tmp12,"Dimension der Indexspalte ist inkompatibel zur Dimension der Tabellenhöhe.");
    MODELICA_ASSERT((tmp10 == tmp11), tmp12);
  }
  else {
    if (((method_y == 4) || (method_y == 5))) {
      tmp13 = size_of_dimension_real_array(tableData,2);
      tmp14 = size_of_dimension_real_array(header_y,1);
      init_modelica_string(&tmp15,"Dimension der Indexspalte ist inkompatibel zur Dimension der Tabellenhöhe.");
      MODELICA_ASSERT((tmp13 == (tmp14 - 1)), tmp15);
    }
  }
  if ((method_x == 3)) {
    tmp16 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(header_x, value_x);
    index_x = tmp16.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_1;
  }
  else {
    if ((method_x == 6)) {
      tmp17 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(header_x, value_x);
      index_x = tmp17.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_1;
      tmp18 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(header_y, value_y);
      index_y = tmp18.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_1;
      if ((value_x < (*real_array_element_addr1(&header_x, 1, (modelica_integer)index_x)))) {
        if ((((modelica_integer)index_x - 1) < 1)) {
          if ((*boolean_array_element_addr1(&extrapolate, 1, 1))) {
            lower = 1;
            upper = 2;
            tmp19 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
            result = tmp19.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
            goto _return;
          }
          else {
            init_modelica_string(&tmp20,"Spalten-Eingangswert erfodert Extrapolation am linken Tabellenrand.");
            MODELICA_ASSERT((!((((modelica_integer)index_x - 1) < 1) && (!(*boolean_array_element_addr1(&extrapolate, 1, 1))))), tmp20);
          }
        }
        else {
          lower = ((modelica_integer)index_x - 1);
          upper = (modelica_integer)index_x;
          tmp21 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
          result = tmp21.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
          goto _return;
        }
      }
      else {
        if ((value_x > (*real_array_element_addr1(&header_x, 1, (modelica_integer)index_x)))) {
          tmp22 = size_of_dimension_real_array(header_x,1);
          if (((1 + (modelica_integer)index_x) > tmp22)) {
            if ((*boolean_array_element_addr1(&extrapolate, 1, 2))) {
              tmp23 = size_of_dimension_real_array(header_x,1);
              lower = (tmp23 - 1);
              tmp24 = size_of_dimension_real_array(header_x,1);
              upper = tmp24;
              tmp25 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
              result = tmp25.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
              goto _return;
            }
            else {
              tmp26 = size_of_dimension_real_array(header_x,1);
              init_modelica_string(&tmp27,"Spalten-Eingangswert erfodert Extrapolation am rechten Tabellenrand.");
              MODELICA_ASSERT((!(((1 + (modelica_integer)index_x) > tmp26) && (!(*boolean_array_element_addr1(&extrapolate, 1, 2))))), tmp27);
            }
          }
          else {
            lower = (modelica_integer)index_x;
            upper = (1 + (modelica_integer)index_x);
            tmp28 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_x, 1, (modelica_integer)lower)), value_x, (*real_array_element_addr1(&header_x, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)lower, (modelica_integer)index_y)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)upper, (modelica_integer)index_y)));
            result = tmp28.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
            goto _return;
          }
        }
      }
    }
    else {
      if ((method_x == 4)) {
        tmp34 = size_of_dimension_real_array(header_x,1);
        tmp31 = 1; tmp32 = (1); tmp33 = (tmp34 - 1);
        {
  modelica_integer i;

          for (i = tmp31; in_range_integer(i, tmp31, tmp33); i += tmp32) {
            tmp29 = get_memory_state();
            if ((((*real_array_element_addr1(&header_x, 1, (modelica_integer)i)) <= value_x) && (value_x < (*real_array_element_addr1(&header_x, 1, (1 + (modelica_integer)i)))))) {
              index_x = (modelica_integer)i;
              break;
            }
            restore_memory_state(tmp29);
          }
        } /* end for*/

      }
      else {
        if ((method_x == 5)) {
          tmp40 = size_of_dimension_real_array(header_x,1);
          tmp37 = 1; tmp38 = (1); tmp39 = (tmp40 - 1);
          {
  modelica_integer i;

            for (i = tmp37; in_range_integer(i, tmp37, tmp39); i += tmp38) {
              tmp35 = get_memory_state();
              if ((((*real_array_element_addr1(&header_x, 1, (modelica_integer)i)) < value_x) && (value_x <= (*real_array_element_addr1(&header_x, 1, (1 + (modelica_integer)i)))))) {
                index_x = (modelica_integer)i;
                break;
              }
              restore_memory_state(tmp35);
            }
          } /* end for*/

        }
        else {
          init_modelica_string(&tmp41,"Unbekannte Lookup-Methode für Tabellenspalte.");
          MODELICA_ASSERT((0), tmp41);
        }
      }
    }
  }
  if ((method_y == 3)) {
    tmp42 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(header_y, value_y);
    index_y = tmp42.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_1;
  }
  else {
    if ((method_y == 6)) {
      tmp43 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(header_x, value_x);
      index_x = tmp43.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_1;
      tmp44 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex(header_y, value_y);
      index_y = tmp44.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_findClosestIndex_rettype_1;
      if ((value_y < (*real_array_element_addr1(&header_y, 1, (modelica_integer)index_y)))) {
        if ((((modelica_integer)index_y - 1) < 1)) {
          if ((*boolean_array_element_addr1(&extrapolate, 1, 3))) {
            lower = 1;
            upper = 2;
            tmp45 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
            result = tmp45.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
            goto _return;
          }
          else {
            init_modelica_string(&tmp46,"Zeilen-Eingangswert erfodert Extrapolation am unteren Tabellenrand.");
            MODELICA_ASSERT((!((((modelica_integer)index_y - 1) < 1) && (!(*boolean_array_element_addr1(&extrapolate, 1, 3))))), tmp46);
          }
        }
        else {
          lower = ((modelica_integer)index_y - 1);
          upper = (modelica_integer)index_y;
          tmp47 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
          result = tmp47.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
          goto _return;
        }
      }
      else {
        if ((value_y > (*real_array_element_addr1(&header_y, 1, (modelica_integer)index_y)))) {
          tmp48 = size_of_dimension_real_array(header_y,1);
          if (((1 + (modelica_integer)index_y) > tmp48)) {
            if ((*boolean_array_element_addr1(&extrapolate, 1, 4))) {
              tmp49 = size_of_dimension_real_array(header_y,1);
              lower = (tmp49 - 1);
              tmp50 = size_of_dimension_real_array(header_y,1);
              upper = tmp50;
              tmp51 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
              result = tmp51.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
              goto _return;
            }
            else {
              tmp52 = size_of_dimension_real_array(header_y,1);
              init_modelica_string(&tmp53,"Zeilen-Eingangswert erfodert Extrapolation am oberen Tabellenrand.");
              MODELICA_ASSERT((!(((1 + (modelica_integer)index_y) > tmp52) && (!(*boolean_array_element_addr1(&extrapolate, 1, 4))))), tmp53);
            }
          }
          else {
            lower = (modelica_integer)index_y;
            upper = (1 + (modelica_integer)index_y);
            tmp54 = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate((*real_array_element_addr1(&header_y, 1, (modelica_integer)lower)), value_y, (*real_array_element_addr1(&header_y, 1, (modelica_integer)upper)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)lower)), (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)upper)));
            result = tmp54.OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_interpolate_rettype_1;
            goto _return;
          }
        }
      }
    }
    else {
      if ((method_y == 4)) {
        tmp60 = size_of_dimension_real_array(header_y,1);
        tmp57 = 1; tmp58 = (1); tmp59 = (tmp60 - 1);
        {
  modelica_integer i;

          for (i = tmp57; in_range_integer(i, tmp57, tmp59); i += tmp58) {
            tmp55 = get_memory_state();
            if ((((*real_array_element_addr1(&header_y, 1, (modelica_integer)i)) <= value_y) && (value_y < (*real_array_element_addr1(&header_y, 1, (1 + (modelica_integer)i)))))) {
              index_y = (modelica_integer)i;
              break;
            }
            restore_memory_state(tmp55);
          }
        } /* end for*/

      }
      else {
        if ((method_y == 5)) {
          tmp66 = size_of_dimension_real_array(header_y,1);
          tmp63 = 1; tmp64 = (1); tmp65 = (tmp66 - 1);
          {
  modelica_integer i;

            for (i = tmp63; in_range_integer(i, tmp63, tmp65); i += tmp64) {
              tmp61 = get_memory_state();
              if ((((*real_array_element_addr1(&header_y, 1, (modelica_integer)i)) < value_y) && (value_y <= (*real_array_element_addr1(&header_y, 1, (1 + (modelica_integer)i)))))) {
                index_y = (modelica_integer)i;
                break;
              }
              restore_memory_state(tmp61);
            }
          } /* end for*/

        }
        else {
          init_modelica_string(&tmp67,"Unbekannte Lookup-Methode für Tabellenzeile.");
          MODELICA_ASSERT((0), tmp67);
        }
      }
    }
  }
  result = (*real_array_element_addr2(&tableData, 2, (modelica_integer)index_x, (modelica_integer)index_y));
 
  _return:
  tmp1.targ1 = result;
  restore_memory_state(tmp2);
  return tmp1;
}

int in_OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(type_description * inArgs, type_description * outVar)
{
  real_array header_x; /* [:] */
  real_array header_y; /* [:] */
  modelica_real value_x;
  modelica_real value_y;
  real_array tableData; /* [:, :] */
  modelica_integer method_x;
  modelica_integer method_y;
  OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup_rettype out;
  if(read_real_array(&inArgs, &header_x)) return 1;
  if(read_real_array(&inArgs, &header_y)) return 1;
  if(read_modelica_real(&inArgs, &value_x)) return 1;
  if(read_modelica_real(&inArgs, &value_y)) return 1;
  if(read_real_array(&inArgs, &tableData)) return 1;
  if(read_modelica_integer(&inArgs, &method_x)) return 1;
  if(read_modelica_integer(&inArgs, &method_y)) return 1;
  out = _OIB__RL6_BEISPIELE_Tabellen_TestTabelle1_lookup(header_x, header_y, value_x, value_y, tableData, method_x, method_y);
  write_modelica_real(outVar, &out.targ1);
  return 0;
}

/* End Body */

#ifdef __cplusplus
}
#endif

Hallo!

As of RC3 the enumeration implementation in OM is quite rudimentary yet. It's not possible to use enumerations in headers of for-loops, and I also noticed problems when indexing arrays with enumerations. Furthermore the function String(enum.element) is not yet implemented while Integer(enum.element) already works fine in the recently released RC3.

Which priority has the full implementation of the enumeration type in the OM project?

Thanks!
Hannes

Apr-25-10 22:06:45
...results in compile error.
Category: Programming

Hello!

From OMShell (1.5 RC3):

Code:

>> class defect 

  constant Real i[2,2] = transpose({{1.1,2.2},{3.3,4.4}});
  Real r;
  equation
    r = i[2,2];
end defect;


class working
  constant Real i[2,2] = {{1.1,2.2},{3.3,4.4}};
  Real r;
  equation
    r = i[2,2];
end working;
{defect,working}

>> simulate(working)
record SimulationResult
    resultFile = "working_res.plt"
end SimulationResult;

>> simulate(defect)
record SimulationResult
    resultFile = "Simulation failed.
Error: Error building simulator. Buildlog: g++ -I"C:\OpenModelica1.5.0\/include" -msse2 -mfpmath=sse  -I. -o defect.exe defect.cpp  -lsim -L"C:\OpenModelica1.5.0\/lib" -lc_runtime -lf2c -lsendData -lQtNetwork-mingw -lQtCore-mingw -lQtGui-mingw -luuid -lole32 -lws2_32
defect.cpp: In function `int functionDAE_output()':
defect.cpp:357: error: `$i$lB2$c2$rB' was not declared in this scope
defect.cpp: In function `int functionDAE_output2()':
defect.cpp:366: error: `$i$lB2$c2$rB' was not declared in this scope
defect.cpp: In function `int initial_residual()':
defect.cpp:515: error: `$i$lB2$c2$rB' was not declared in this scope
mingw32-make: *** [defect] Error 1

Error: Error building simulator. Buildlog: command g++ not found. Check $OPENMODELICAHOME
Error: Error building simulator. Buildlog: command "C:\OpenModelica1.5.0\/bin/Compile" not found. Check $OPENMODELICAHOME
"
end SimulationResult;

>>

Shouldn't it work?

Cheers
Hannes

Apr-25-10 22:03:02
Model does not compile any longer

Was the information I provided sufficient?

Oh - Thanks! ...Actually I did not mean to ask for a workaround solution - I just wasn't sure wether the problem was a fault in our programming or not.

Just one more thing: Is there a chance to pass the failtrace switch to omc, if a simulation is run from OMShell?

Huh...?

Well - We already noticed, that the enum implementation im OM is kind of rudimentary yet, but we need enums here, cause they are ideal for the definition of table headers (combination of a String and the corresponding Integer, which is the Array-Index).

But I didn't really get your answer: Do you suggest to implement a workaround?

Thanks for your response.

As for the failtrace to omc: We start our simulation using a .mos OMShell script,  because the simulation environment needs much more than one command to be set up correctly. Is there any way to pass omc-switches from OMShell?

As for the scoping problem: Our situation looks a little different - This is from an OMShell session, which describes the actual problem better:

Code:


>> model C 
  function find
    input  Integer index;
    output Real value;       
    algorithm
    for j in labels loop
      if index == Integer(j) then value := werte[i]; end if;
    end for;
  end find;
  type labels = enumeration (one "1st", two "2nd");
  constant Real[labels] values := {1.1, 2.2};
  Real valueTwo = find(Integer(labels.two));
end C; 

{C}

>> simulate(C)
record SimulationResult
    resultFile = "Simulation failed.
Error: Wrong type or wrong number of arguments to Integer(j)'.

Error: Variable labels not found in scope C.find
Error: No matching function found for find(2) of type function(index:Integer) => Real, candidates are function(index:Integer) => Real
Error: Error occured while flattening model C
"
end SimulationResult;

...Maybe the type exists in the function's scope, but the for-statement doesn't work as described in 11.2.2 of the Modelica 3.0 language specification?

Cheers,
Hannes

Hello!

Two questions:

First:
Error: No matching function found for find(in_x.value) of type function(index:Integer) => Real, candidates are function(index:Integer) => Real

How to interpret that? ...Looks like the candidate's pattern exactly matches the reqired one.

Second:
In the case of a class which contains a type declaration and a function - Shouldn't the type be available in the scope of the function then?

Kind Regards,
Hannes

Apr-23-10 18:00:37
Model does not compile any longer

This is it:

Code:


  function lookup
   
    input Real header_x[:],
               header_y[:];
    input Real value_x,
               value_y;
    input Real tableData[:,:];
    input table_lookup_method method_x = table_lookup_method.nearest,
                              method_y = table_lookup_method.nearest;

    output Real result;

    protected
      Integer index_x, index_y;
      Integer lower, upper;
      Integer i;   
     
      Boolean extrapolate[tableBorder]; //FYI: tableBoder is an enumeration type
   
    algorithm
   
    [...]
   
   end lookup;   

Apr-23-10 17:17:51
Model does not compile any longer

Hello!

After an Update from RC2 to RC3 I have problems running a simulation which worked fine in the earlier version. The model is flattened without errors, but the build of the simulation executeable fails due to some type mismatch problem.

This is the flattened model:

Code:


fclass OIB_RL6.BEISPIELE.beispielTabellen
output Real GL1.result.value;
parameter Real GL1.x = 5.0 "Ausgabewert";
output Real GL2.result.value;
parameter Real GL2.x = 1.9 "Ausgabewert";
output Real GL3.result.value;
Real GL3.inPort.value;
parameter enumeration(index, exact, nearest, left, right, interpolate) TAB1.method_x = OIB_RL6.Datentypen.table_lookup_method.interpolate "Optionen: nearest, left, right, interpolate";
parameter enumeration(index, exact, nearest, left, right, interpolate) TAB1.method_y = OIB_RL6.Datentypen.table_lookup_method.nearest "Optionen: nearest, left, right, interpolate";
constant Real TAB1.header_x[1] = 1.0;
constant Real TAB1.header_x[2] = 2.0;
constant Real TAB1.header_x[3] = 3.0;
constant Real TAB1.header_x[4] = 4.0;
constant Real TAB1.header_y[1] = 1.0;
constant Real TAB1.header_y[2] = 2.0;
constant Real TAB1.header_y[3] = 3.0;
constant Real TAB1.header_y[4] = 4.0;
constant Real TAB1.tableData[1,1] = 1.0;
constant Real TAB1.tableData[1,2] = 2.0;
constant Real TAB1.tableData[1,3] = 3.0;
constant Real TAB1.tableData[1,4] = 4.0;
constant Real TAB1.tableData[2,1] = 5.0;
constant Real TAB1.tableData[2,2] = 6.0;
constant Real TAB1.tableData[2,3] = 7.0;
constant Real TAB1.tableData[2,4] = 8.0;
constant Real TAB1.tableData[3,1] = 9.0;
constant Real TAB1.tableData[3,2] = 10.0;
constant Real TAB1.tableData[3,3] = 11.0;
constant Real TAB1.tableData[3,4] = 12.0;
constant Real TAB1.tableData[4,1] = 13.0;
constant Real TAB1.tableData[4,2] = 14.0;
constant Real TAB1.tableData[4,3] = 15.0;
constant Real TAB1.tableData[4,4] = 16.0;
Real TAB1.in_x.value;
Real TAB1.in_y.value;
Real TAB1.out.value;
output Real GL4.result.value;
parameter Real GL4.x = 1.9999999 "Ausgabewert";
output Real GL5.result.value;
parameter Real GL5.x = 2.0000001 "Ausgabewert";
output Real GL6.result.value;
Real GL6.inPort.value;
parameter enumeration(index, exact, nearest, left, right, interpolate) TAB2.method_x = OIB_RL6.Datentypen.table_lookup_method.left "Optionen: nearest, left, right, interpolate";
parameter enumeration(index, exact, nearest, left, right, interpolate) TAB2.method_y = OIB_RL6.Datentypen.table_lookup_method.right "Optionen: nearest, left, right, interpolate";
constant Real TAB2.header_x[1] = 1.0;
constant Real TAB2.header_x[2] = 2.0;
constant Real TAB2.header_x[3] = 3.0;
constant Real TAB2.header_x[4] = 4.0;
constant Real TAB2.header_x[5] = 5.0;
constant Real TAB2.header_y[1] = 1.0;
constant Real TAB2.header_y[2] = 2.0;
constant Real TAB2.header_y[3] = 3.0;
constant Real TAB2.header_y[4] = 4.0;
constant Real TAB2.tableData[1,1] = 1.0;
constant Real TAB2.tableData[1,2] = 2.0;
constant Real TAB2.tableData[1,3] = 3.0;
constant Real TAB2.tableData[1,4] = 4.0;
constant Real TAB2.tableData[2,1] = 5.0;
constant Real TAB2.tableData[2,2] = 6.0;
constant Real TAB2.tableData[2,3] = 7.0;
constant Real TAB2.tableData[2,4] = 8.0;
constant Real TAB2.tableData[3,1] = 9.0;
constant Real TAB2.tableData[3,2] = 10.0;
constant Real TAB2.tableData[3,3] = 11.0;
constant Real TAB2.tableData[3,4] = 12.0;
Real TAB2.in_x.value;
Real TAB2.in_y.value;
Real TAB2.out.value;
output Real Summe.result.value;
Real Summe.inPort1.value;
Real Summe.inPort2.value;
equation
  GL1.result.value = GL1.x;
  GL2.result.value = GL2.x;
  GL3.result.value = sin(0.0174527777777778 * (time * GL3.inPort.value));
  TAB1.out.value = OIB_RL6.BEISPIELE.Tabellen.TestTabelle1.lookup({1.0,2.0,3.0,4.0},{1.0,2.0,3.0,4.0},TAB1.in_x.value,TAB1.in_y.value,{{1.0,5.0,9.0,13.0},{2.0,6.0,10.0,14.0},{3.0,7.0,11.0,15.0},{4.0,8.0,12.0,16.0}},TAB1.method_x,TAB1.method_y);
  GL4.result.value = GL4.x;
  GL5.result.value = GL5.x;
  GL6.result.value = sin(0.0174527777777778 * (time * GL6.inPort.value));
  TAB2.out.value = OIB_RL6.BEISPIELE.Tabellen.TestTabelle2.lookup({1.0,2.0,3.0,4.0,5.0},{1.0,2.0,3.0,4.0},TAB2.in_x.value,TAB2.in_y.value,{{1.0,5.0,9.0},{2.0,6.0,10.0},{3.0,7.0,11.0},{4.0,8.0,12.0}},TAB2.method_x,TAB2.method_y);
  Summe.result.value = Summe.inPort1.value + Summe.inPort2.value;
GL1.result.value = TAB1.in_x.value;
GL2.result.value = TAB1.in_y.value;
TAB1.out.value = GL3.inPort.value;
GL4.result.value = TAB2.in_x.value;
GL5.result.value = TAB2.in_y.value;
TAB2.out.value = GL6.inPort.value;
GL6.result.value = Summe.inPort2.value;
GL3.result.value = Summe.inPort1.value;
end OIB_RL6.BEISPIELE.beispielTabellen;

The build log contains a couple of errors like this.

Code:


OIB_RL6.BEISPIELE.beispielTabellen.cpp:477: warning: passing `double' for converting 7 of `OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup_rettype _OIB__RL6_BEISPIELE_Tabellen_TestTabelle2_lookup(real_array, real_array, modelica_real, modelica_real, real_array, modelica_integer, modelica_integer)'
OIB_RL6.BEISPIELE.beispielTabellen.cpp:483: error: non-lvalue in unary `&'

Does anyone know, what's going wrong here?

Kind Regards,
Hannes

Hi,

I think you mean to run your simulation with the switch numberOfIntervals=1.

Regards

Clear now. Thank you!


EDIT: Well... I just built an omc.exe from the SVN-trunk, but moving the .exe and the .dlls to ${OPENMODELICAHOME}/bin/ results in an error when starting OMShell, because there seems to be en entry point missing in the newly generated mico2313.dll current/hmm

Clear now. Thanks a  lot!

Can anyone reproduce that, or is it just me, who messed something up?

Apr-12-10 09:16:32
How to find out where most of the CPU time goes

Thank you for your answer - I'll try that.

Looking for Linux binaries/souces i could only find 1.5.0 RC1. Where can I find the latest RC2 for Linux?

Apr-11-10 20:02:53
How to find out where most of the CPU time goes

Hello!

Except for varying the code and taking the simulation-time with a stop watch - Is there any mechanism which can be (ab-)used to find out which function calls need most CPU time in a simulation?

Cheers
Hannes

Apr-11-10 18:01:58
Graphical objects: Usage of constants for RGB-triples in annotations
Category: Programming

Hello!

DynamicSelect does not allow the usage of references to variables/constants in the first argument (editing state). So, is there any way to use an Integer[3]-constant as RGB-triple in graphical annotations to modify the editing state of a graphical symbol? That would be helpful, if a symbol is inherited from a baseclass, and a color of it's icon should be changed without having to rewrite the whole annotation again.

Regards,
Hannes

Man, you spend your saturday nights in front of the screen too? ...We definitively must change somthing in our lives! current/smile ...Anyway - Thanks for the answer!

Talking about constants: Shouldn't a variable which is declared with the parameter-prefix behave like one declared with the constant-prefix in this context? (It doesn't, and I accepted this already, but I still ask myself why it does not. In the language specification [Ch. 4.4.4, 1st of the 3 dots] it is described like both, parameter- and constant-declarations, would result in a constant.)

I just created that ticket.

Cheers
Hannes

Hello,

According to the Modelica language specification, functions are "specialized classes" [Ch. 12.1] with certain restrictions [Ch. 12.2].  Since the restrictions do not tell anything about inner/outer declarations, I assumed that it should be possible to access outer variables from within a function:

Code:


class myModel2
 
  function circlePerimeter
    input  Real radius;
    output Real perimeter;
   
    outer Real pi; // --> case1: with inner/outer: Wrong value for pi inside function: 0
   
    algorithm
      perimeter := 2* radius * pi;     
  end circlePerimeter;
 
  //Real pi = 3.1415; // --> case 2: without inner/outer: Error: Error building simulator.
  inner constant Real pi = 3.1415; // --> case 1: with inner/outer: Wrong value for pi inside function: 0
 
  Real x;
 
  equation
    x = circlePerimeter(time);
   
end myModel2;

Trying to do so I noticed, that an outer value is always set to 0, if adressed from within a function (case1). Just out of courisitiy I also tried to access the outer variable without declaring it as "inside" in the outer class and without declaring it anyhow in the inner class (which is the function actually). I was pretty surprised that the model can be flattened then, but the result is an g++-compilation error due to the undeclared variable (case 2).

Do I always have to pass "anything needed inside a function" as a parameter, or am I missing something here?

Regards,
Hannes

EDIT: Using 1.5.0 RC on Win7/64bit here.

That hint was a good one. I already noticed a problem with arrays of type Boolean in past, and this is another one.

Problem Nr. 1: I noticed, that an array {true,true,true,true} became {true,false,false,false} when it was passed as an argument to a function. When I passed {false,false,false,false} to the same function everything went normal. When I found out about that, I did a workaraound by passing the 4 elements of my Boolean-array as 4 seperate boolean values to the function. Out of these 4 seperate values I reassembled the array within the function, and this way it worked.

Problem Nr. 2: The actual case (which is the topic of my posting) is related to exactly the same array: The array is allocated in the declaration of a class which inherits form the class where Problem Nr. 1 occured. When I set the parameter to {false,false,false,false} in the class-declaration, a defective (crashing) simulation-executeable is generated. While I was trying to find the problem by manipulating my modelica-code there have also been cases, where the generated cpp-code could not even be compiled. In other cases the simulation-binary hung on execution. Anyway - When I set the array to {true,true,true,true} everything seems fine (even if I did not check the simulation results yet, but at least the generated cpp-code compiles and the executeable is neither crashing nor hanging).

I tried to reduce my code to a small demonstration of the problems:

Code:


model myModel

type edges = enumeration ( l "left", r  "right", t "top", b "bottom");

class mother
 
  function countTrueValues
   
    input Boolean boolArray[edges] = {false,false,false,false};
    output Integer numOfTrueValues;
   
    algorithm
      numOfTrueValues := 0;
      for i in edges loop
        if boolArray[i] then numOfTrueValues := numOfTrueValues + 1; end if;
      end for;
  end countTrueValues;
 
  parameter Boolean boolArray[edges] = {true, true, true, true};
 
  Integer numOfTrueValues;
 
  equation
/* Problem 1, Case 1: Passing an array explicitly --> works well
* results in numOfTrueValues = 0 for {false,false,false,false} --> OK
* results in numOfTrueValues = 2 for {true, true, false,false} --> OK
* results in numOfTrueValues = 4 for {true, true,  true, true} --> OK
*/ 
//   numOfTrueValues = countTrueValues({true,true,true,true});

/* Problem 1, Case 2: passing parameter boolArray --> only first element handled correctly
* results in numOfTrueValues = 0 for boolArray = {false,false,false,false} --> coincidently OK
* results in numOfTrueValues = 0 for boolArray = {false,false, true, true} --> NOT OK
* results in numOfTrueValues = 1 for boolArray = { true, true,false,false} --> NOT OK
* results in numOfTrueValues = 1 for boolArray = { true, true, true, true} --> NOT OK
*/
    numOfTrueValues = countTrueValues(boolArray);
   
end mother;


class child
/* Problem 2: inheriting from a class with an array of boolen type as parameter. */
//  extends mother( boolArray = {true,true,true,true} ); // --> flattening error
//  extends mother( boolArray = {false,false,false,false} ); // --> flattening error
//  extends mother(); // --> flattening error
end child;

mother motherInstance;
child  childInstance;

end myModel;

Unfortunately  Problem Nr. 2 cannot be exactly reproduced with this small demo, because the demo-model cannot even be flattened when the inherited class is instantiated (Dont ask me, why my real model can be flattend whild the example cannot - I dont know.)

You might think now, that the problem is related to the fact that the array is indexed with enumeration values (and enumeration handling is not yet fully implemented in 1.5.0 RC2), but it is not: At least the first of the described problems (wrong values in the array after passing it to the function) also occures, whe the array is indexed conventionally.

Regards,
Hannes

Hmmm... Not a single response within 24 hours - I start thinking that my question must be either very stupid or very tricky current/wink

Is there any more information I should provide to make this thread run?

Thanks.

Apr-06-10 17:47:17
...related to type conversion.

Thank you, Adrian. So basically it is correct: All four lines are valid? (I'm not perfectly sure about line 2 and 4)

Apr-06-10 16:26:50
...related to type conversion.

Hello!

I have a question related to type conversion of enumeration values like described in chapter 4.8.5.2 of the Modelica 3.1 language specification:

Assuming the following case:

Code:

model myModel


type enum = enumeration(one "ONE", two "TWO");
enum e = enum.one;

Integer i1 = Integer(enum.one); // line 1: Working (i1 = 1)
Integer i2 = Integer(e);        // line 2: Error ("No matching function found")
String  s1 = String(enum.one);  // line 3: Error ("Error building simulator")
String  s2 = String(e);         // line 4: Error ("Error building simulator")

end myModel;

Using OM 1.5.0 RC2 on Win7 64bit, only line 1 is working, but shouldn't all 4 lines be valid?

Kind regards,
Hannes

Hello!

My Environment is OM 1.5.0 RC2 on Win7 64bit, and I work on a model, based on valid modelica code. (At least I believe the code is valid, because the model can be flattened without errors using the instantiateModel command on OMShell, and no errorstring is returned)

Recently I have problems running the simulation, because

1.) either the generated cpp-code is invalid, or
2.) the compiled binary crashes/hangs.

In cases where a binary executable is built successfully, the generated .log-file contains some type-conversion related warnings which basically all look like this:

Code:

myModelName.cpp:866: warning: passing `double' for converting 11 of `OIB__RL6_OENORM__B8110__5_Tabellen_Tabelle__x_lookup_rettype _OIB__RL6_OENORM__B8110__5_Tabellen_Tabelle__x_lookup(real_array, real_array, modelica_real, modelica_real, real_array, modelica_integer, modelica_integer, modelica_boolean, modelica_boolean, modelica_boolean, modelica_boolean)'

How do I deal with that?

Greetings
Hannes

EDIT: This is an example for a flattened model, where the generated binary crashes on execution:

Code:

fclass OIB_RL6.OENORM_B8110_6.Transmissionsleitwert_detailliert

output Real L_T.result.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_e.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_u.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_g.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_psi.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_T.L_chi.value(quantity = "ThermalConductance", unit = "W/K");
output Real L_g.result.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g1.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g2.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g3.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g4.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g5.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_g.L_g6.value(quantity = "ThermalConductance", unit = "W/K");
output Real L_e.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_e.A[1] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[2] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[3] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[4] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[5] = 8.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[6] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[7] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[8] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[9] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.A[10] = 1.0 "Vektor der Bauteilflächen [m^2]";
parameter Real L_e.U[1] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[2] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[3] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[4] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[5] = 0.3 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[6] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[7] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[8] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[9] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
parameter Real L_e.U[10] = 1.0 "Vektor der Wärmedurchgangskoeffizienten nach EN ISO 6946, 10077, 13947 [W/(m^2*K)]";
output Real L_u.result.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_u.L_iu.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_u.L_ue.value(quantity = "ThermalConductance", unit = "W/K");
input Real L_u.L_Vue.value(quantity = "ThermalConductance", unit = "W/K");
output Real L_Vue.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_Vue.rho_L = 1.2 "Dichte von Luft [kg/m^3]";
parameter Real L_Vue.c_pL = 0.283333333333333 "spezifische Wärmekapazität von Luft [(W*h)/(kg*K)]";
parameter Real L_Vue.n_Lu = 0.5 "stündliche Luftwechselrate zw. unkondittioniertem Raum u. außen [h^(-1)]";
parameter Real L_Vue.V_fu = 0 "freies Luftvolumen des unkonditionierten Raumes [m^3]";
output Real L_iu.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_iu.A_iu[1] = 0 "Vektor der Bauteilflächen zwischen innen und unkonditionierten Räumen [m^2]";
parameter Real L_iu.U_iu[1] = 0 "Vektor der Wärmedurchgangskoeffizienten [W/(m^2*K)]";
parameter Real L_iu.l_psiiu[1] = 0 "Vektor der Längen von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [m]";
parameter Real L_iu.psi_iu[1] = 0 "Vektor der Leitwerte von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [W/(m*K)]";
parameter Real L_iu.chi_iu[1] = 0 "Vektor der Leitwerte von 3D-Wärmebrücken [W/(m^2*K)]";
output Real L_ue.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_ue.A_ue[1] = 0 "Vektor der Bauteilflächen zwischen außen und unkonditionierten Räumen [m^2]";
parameter Real L_ue.U_ue[1] = 0 "Vektor der Wärmedurchgangskoeffizienten [W/(m^2*K)]";
parameter Real L_ue.l_psiue[1] = 0 "Vektor der Längen von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [m]";
parameter Real L_ue.psi_ue[1] = 0 "Vektor der Leitwerte von 2D-Wärmebrücken zwischen innen und unkonditionierten Räumen [W/(m*K)]";
parameter Real L_ue.chi_ue[1] = 0 "Vektor der Leitwerte von 3D-Wärmebrücken [W/(m^2*K)]";
output Real L_gB1.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gB1.A[1] = 9 "Vektor der Bauteilflächen von Bodenplatten [m^2]";
parameter Real L_gB1.U_0[1] = 0.1 "Vektor der fiktiven Wärmedurchgangskoeffizienten von Bodenplatten [W/(m^2*K)]";
output Real L_gB2.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gB2.A[1] = 9 "Vektor der Bauteilflächen der Bodenplatten [m^2]";
parameter Real L_gB2.U_0[1] = 0.1 "Vektor der fiktiven Wärmedurchgangskoeffizienten von Bodenplatten [W/(m^2*K)]";
parameter Real L_gB2.P[1] = 12 "Vektor der Perimeterlängen [m]";
parameter Real L_gB2.deltaPsi[1] = 0 "Vektor der längenbezogenen Korrekturkoeffizienten [W/(m*K)]";
output Real L_gB3.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gB3.A[1] = 9 "Vektor der Bauteilflächen der Bodenplatten [m^2]";
parameter Real L_gB3.U_0[1] = 0.1 "Vektor der fiktiven Wärmedurchgangskoeffizienten von Bodenplatten [W/(m^2*K)]";
parameter Real L_gB3.P[1] = 12 "Vektor der Perimeterlängen [m]";
parameter Real L_gB3.deltaPsi[1] = 0 "Vektor der längenbezogenen Korrekturkoeffizienten [W/(m*K)]";
output Real L_gK1.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gK1.A[1] = 0 "Vektor der Bauteilflächen der Kellerdecke [m^2]";
parameter Real L_gK1.U[1] = 0 "Vektor der Wärmedurchgangskoeffizienten [W/(m^2*K)]";
output Real L_gH.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gH.A_bf[1] = 0 "Vektor der Bauteilflächen des Kellerbodens [m^2]";
parameter Real L_gH.U_bf[1] = 0 "Vektor der Wärmedurchgangskoeffizienten des Kellerbodens [W/(m^2*K)]";
parameter Real L_gH.H[1] = 0 "Vektor der Höhen der Keller-Räume (Höhe unter Erdniveau) [m]";
parameter Real L_gH.P[1] = 0 "Vektor der Keller-Perimeterlängen (='erdberührte Wandlänge') [m]";
parameter Real L_gH.U_bw[1] = 0 "Vektor der fiktiven Wärmedurchgangskoeffizienten der erdberührten Kellerwand [W/(m^2*K)]";
Real L_gH.sum_L_bw(quantity = "ThermalConductance", unit = "W/K");
output Real L_gK2.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_gK2.A[1] = 0 "Vektor der Bauteilflächen des Kellerbodens [m^2]";
parameter Real L_gK2.U[1] = 0 "Vektor der Wärmedurchgangskoeffizienten des Kellerbodens [W/(m^2*K)]";
output Real L_psi.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_psi.l[1] = 0 "Vektor der Längen der 2D-Wärmebrücken [m]";
parameter Real L_psi.psi[1] = 0 "Vektor der Korrekturkoeffizienten der 2D-Wärmebrücken [W/(m*K)]";
output Real L_chi.result.value(quantity = "ThermalConductance", unit = "W/K");
parameter Real L_chi.chi[1] = 0 "Vektor der Korrekturkoeffizienten der 3D-Wärmebrücken [W/(m*K)]";
equation
  L_T.result.value = L_T.L_e.value + (L_T.L_u.value + (L_T.L_g.value + (L_T.L_psi.value + L_T.L_chi.value)));
  L_g.result.value = L_g.L_g1.value + (L_g.L_g2.value + (L_g.L_g3.value + (L_g.L_g4.value + (L_g.L_g5.value + L_g.L_g6.value))));
  L_e.result.value = L_e.A[1] * L_e.U[1] + (L_e.A[2] * L_e.U[2] + (L_e.A[3] * L_e.U[3] + (L_e.A[4] * L_e.U[4] + (L_e.A[5] * L_e.U[5] + (L_e.A[6] * L_e.U[6] + (L_e.A[7] * L_e.U[7] + (L_e.A[8] * L_e.U[8] + (L_e.A[9] * L_e.U[9] + L_e.A[10] * L_e.U[10]))))))));
  L_u.result.value = L_u.L_iu.value * (L_u.L_ue.value + L_u.L_Vue.value) / (L_u.L_iu.value + (L_u.L_ue.value + L_u.L_Vue.value));
  L_Vue.result.value = L_Vue.rho_L * (L_Vue.c_pL * (L_Vue.n_Lu * L_Vue.V_fu));
  L_iu.result.value = L_iu.A_iu[1] * L_iu.U_iu[1] + (L_iu.l_psiiu[1] * L_iu.psi_iu[1] + L_iu.chi_iu[1]);
  L_ue.result.value = L_ue.A_ue[1] * L_ue.U_ue[1] + (L_ue.l_psiue[1] * L_ue.psi_ue[1] + L_ue.chi_ue[1]);
  L_gB1.result.value = L_gB1.A[1] * L_gB1.U_0[1];
  L_gB2.result.value = L_gB2.A[1] * L_gB2.U_0[1] + L_gB2.P[1] * L_gB2.deltaPsi[1];
  L_gB3.result.value = L_gB3.A[1] * L_gB3.U_0[1] + L_gB3.P[1] * L_gB3.deltaPsi[1];
  L_gK1.result.value = L_gK1.A[1] * L_gK1.U[1];
  L_gH.sum_L_bw = <reduction>sum(L_gH.H[j] * (L_gH.P[j] * L_gH.U_bw[j]) for j in {1});
  L_gH.result.value = L_gH.A_bf[1] * L_gH.U_bf[1] + L_gH.sum_L_bw;
  L_gK2.result.value = L_gK2.A[1] * L_gK2.U[1];
  L_psi.result.value = L_psi.l[1] * L_psi.psi[1];
  L_chi.result.value = L_chi.chi[1];
L_chi.result.value = L_T.L_chi.value;
L_psi.result.value = L_T.L_psi.value;
L_g.result.value = L_T.L_g.value;
L_u.result.value = L_T.L_u.value;
L_e.result.value = L_T.L_e.value;
L_gH.result.value = L_g.L_g6.value;
L_gK2.result.value = L_g.L_g5.value;
L_gK1.result.value = L_g.L_g4.value;
L_gB3.result.value = L_g.L_g3.value;
L_gB2.result.value = L_g.L_g2.value;
L_gB1.result.value = L_g.L_g1.value;
L_ue.result.value = L_u.L_ue.value;
L_iu.result.value = L_u.L_iu.value;
L_Vue.result.value = L_u.L_Vue.value;
end OIB_RL6.OENORM_B8110_6.Transmissionsleitwert_detailliert;

Mar-25-10 12:58:54
Error: Internal error Code generation of Modelica functions failed.

I think we had the affected parts of the code commented out for a while, before we finally deleted them. So there should be traces left in out SVN. I'll try to dig it out over the weekend and send it to you then.

Thanks for your support so far!

Edit: After uninstalling 1.5 RC1, reinstalling 1.5 RC2, reboot & restart the whole environment from the scratch the problem as described in my initial posting is now gone. I really can't tell, what the exact reason was, but it seems the problem was somehow related to "leftovers" in my development environment.

I'll keep my eyes on it, but at the moment I don't see any reason, not to trust in OpenModelica's enumeration handling.

Mar-24-10 20:34:47
Error: Internal error Code generation of Modelica functions failed.

Downgrade to 1.5 RC1 does not solve the problem for me and downgrade to 1.4.5 just leads to another error (doesn't recognize the elements of the enumeration list while flattening).

Before I start implementing on a workaround: You sayed that you were able to run the code from my initial posting without error - Which environment did you use for that?

Another thing: During the last weeks I also noticed other issues with enumerations: In one case the elements of the enumeration list were missing after a redeclaration of an enumeration-variable, while the enumeration type itself still was present in the scope. In another case OMC produced code which couldn't be compiled by the GCC than. I'm new to Modelica, so of course it's possible that I just messed something up myself, but after our little chat here and since most of my troubles are somehow "mysteriously" connected with enumerations, I'm not so sure about that any longer... current/smile

Mar-24-10 18:23:14
Error: Internal error Code generation of Modelica functions failed.

Thanks a lot for the quick response. The typo you mentioned happened only in my posting, not in my original code. I use 1.5.0 RC2 - Is there any newer RC or should I better downgrade to the latest stable?

Mar-24-10 18:03:31
Error: Internal error Code generation of Modelica functions failed.

Hello community!

I'm new to Modelica, so probably the answer to my question is simple. I have a construct which basically looks like this:

Code:


package myPackage
  type myType = enumeration(item1, item2);

  connector myConnector
    Real myConnectorValue;
  end myConnector;

  block myBlock
    function myFunction
      input myType myFunctionParameter; // <-- THIS LINE IS THE KILLER
      output Real myFunctionResult;

      algortithm
      /* yet empty */
    end myFunction;

    parameter myType myBlockParameter = myType.item1;
    myConnector out;

    equation
      out.myConnectorValue= myFunction(myFunctionParameter = myBlockParameter);
  end myBlock;
end myPackage;

Trying to simulate a model containing a myBlock fails with

Code:

resultFile = "Simulation failed. Error: Internal error Code generation of Modelica functions failed."

The error also occures, when the myFunction is not even called. When the type of myFunctionParameter is changed to Real, everything goes smoothly.

Environment: OpenModelica 1.5.0 on Win7/64bit.

What am I missing?
Regards,
Hannes

  • Index
  • » Users
  • » edes
  • » Profile
You are here: