Opened 9 years ago

Last modified 9 years ago

#3687 closed defect

Inline module fails with protected array variables — at Version 2

Reported by: Willi Braun Owned by: Willi Braun
Priority: blocker Milestone: 1.9.4
Component: Backend Version: v1.9.4-dev-nightly
Keywords: Cc: Vitalij Ruge

Description (last modified by Willi Braun)

Following model results into code generation issue, because of protected array variables:

model foo
  function f
    input Real z;
    output Real y;
  protected
    Real a[2];
  algorithm
    a := {2 * z, z};
    y := sum(a);
    annotation(Inline = true);
  end f;

  Real y(start = 0, fixed = true);
  Real z;
equation
  z = f(5 + time);
  der(y) = z;
end foo;

Even worse is the following example:

model foo
  function f
    input Real z;
    output Real y;
  protected
    Real a[2];
  algorithm
    a := {2 * z, z};
    y := sum(a)/3;
    annotation(Inline = true);
  end f;
  function f1
    input Real z;
    output Real y;
  protected
    Real a[2];
  algorithm
    a := {2 * z, z};
    y := sum(a)/3;
  end f1;

  Real y(start = 0, fixed = true);
  Real z, z2;
  Real a[2] = {sin(time),cos(time)};
equation
  z = f(5 + time);
  z2 = f1(5 + time);
  der(y) = z;
end foo;

that results into really wrong outcome for z compared to z2.

Change History (2)

comment:1 by Willi Braun, 9 years ago

Description: modified (diff)
Priority: highblocker

comment:2 by Willi Braun, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.