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

Incorret code generation

Incorret code generation

I have a simple model for which OpenModelica fails to generate compileable code. Flatting and model check, however, succeed without errors.

Code:


package MyPackage
  record State
    Real a;
  end State;
 
  model Properties
    State state;
    Real b;
  equation
    b = func_b(state.a);
  end Properties;
 
  function func
    input State s;
    output Real b;
  algorithm
    b := func_b(s.a);
  end func;
 
  function func_b
    input Real a;
    output Real b;
  algorithm
    b := 2 * a;
  end func_b;
end MyPackage;


model MyModel
  replaceable package Medium = MyPackage;
  parameter Integer numberOfNodes = 1;
 
  input Medium.State[numberOfNodes] states;
  Real[numberOfNodes] b;

equation
  b = Medium.func(states);
end MyModel;


model TestModel
  package Medium = MyPackage;
  MyModel m(states = props.state);
  Medium.Properties[1] props;
equation
  props.state.a = {1};
end TestModel;

Best regards,

Michael

Edited by: mburisch - Jan-25-12 18:26:00

Re: Incorret code generation

There are 0 guests and 0 other users also viewing this topic