Opened 7 years ago

Closed 7 years ago

#4387 closed defect (fixed)

Functions with no return value are not called in when ( initial() ) clauses

Reported by: bthiele Owned by: lochel
Priority: high Milestone: 1.12.0
Component: Backend Version: v1.12.0
Keywords: Cc: tobias.bellmann@…

Description

The following model doesn't make the expected call to print during initialization.

model TestWhen
equation
  when initial() then
    Modelica.Utilities.Streams.print("In initial\n");
  end when;
end TestWhen;

Change History (7)

comment:1 follow-up: Changed 7 years ago by janK

Quick fix: Replace equation with algorithm :)

comment:2 Changed 7 years ago by lochel

  • Status changed from new to accepted

Or use an initial equation instead of an when initial() clause ;)

Last edited 7 years ago by lochel (previous) (diff)

comment:3 Changed 7 years ago by lochel

  • Milestone changed from Future to 1.12.0

I just opened OMCompiler#1604 to fix this.

comment:4 in reply to: ↑ 1 Changed 7 years ago by lochel

Replying to janK:

Quick fix: Replace equation with algorithm :)

I just realized that a when initial() clause will be evaluated twice if it is part of an algorithm section.

comment:5 Changed 7 years ago by janK

I saw it too, but didn't pay a lot of attention to it. Only with print this flaw was revealed - what a coincidence. Probably it is still worth fixing that. Issues could result if in initial() files (for writing e.g. results) are opened twice.

comment:6 Changed 7 years ago by lochel

Right, seems not be a big issue yet. Anyway, I will fix it with OMCompiler#1607.

comment:7 Changed 7 years ago by lochel

  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.