Opened 8 years ago

Closed 8 years ago

#4387 closed defect (fixed)

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

Reported by: Bernhard Thiele Owned by: Lennart Ochel
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 by Jan Kokert, 8 years ago

Quick fix: Replace equation with algorithm :)

comment:2 by Lennart Ochel, 8 years ago

Status: newaccepted

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

Last edited 8 years ago by Lennart Ochel (previous) (diff)

comment:3 by Lennart Ochel, 8 years ago

Milestone: Future1.12.0

I just opened OMCompiler#1604 to fix this.

in reply to:  1 comment:4 by Lennart Ochel, 8 years ago

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 by Jan Kokert, 8 years ago

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 by Lennart Ochel, 8 years ago

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

comment:7 by Lennart Ochel, 8 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.