Opened 12 years ago

Closed 12 years ago

#2026 closed defect (fixed)

generated mat-file is invalid

Reported by: Lennart Ochel Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Run-time Version: trunk
Keywords: Cc: Jens Frenkel

Description

If you test trunk/testsuite/simulation/modelica/events/EventIteration.mos with default outputFormat (mat) you get the following error:

omc: util/read_matlab4.c:436: omc_matlab4_read_single_val: Assertion `absVarIndex > 0 && absVarIndex <= reader->nvar' failed.
Aborted (core dumped)

Change History (14)

comment:1 by Lennart Ochel, 12 years ago

I guess this is linked to the filterOutput feature. Because the bug occurs since I filter the internal-variables which are introduced for the when-conditions.

comment:2 by Martin Sjölund, 12 years ago

Owner: changed from somebody to Martin Sjölund
Status: newaccepted

absVarIndex: 0 reader->nvar: 9

#4  0x0000000001f23a6e in omc_matlab4_read_single_val (res=0x7fffffffdce8, 
    reader=0x304c930 <simresglob+16>, varIndex=0, timeIndex=0)
    at util/read_matlab4.c:438
#5  0x0000000001f23fc2 in omc_matlab4_val (res=0x7fffffffdce8, 
    reader=0x304c930 <simresglob+16>, var=0x5826ce8, time=<optimised out>)
    at util/read_matlab4.c:524
#6  0x0000000001ed986c in SimulationResultsImpl__val (
    filename=0x7fffeeb7d740 "/home/marsj/dev/trunk-nomod/testsuite/simulation/modelica/events/EventIteration_res.mat", varname=0x7ffff7fb74b0 "h1", 
    timeStamp=<optimised out>, simresglob=<optimised out>)
    at SimulationResults.c:117

comment:3 by Martin Sjölund, 12 years ago

octave:3> dataInfo
dataInfo =

   2   2   2   2   2   2   2   2   2   0
   1   2   3   4   5   6   7   8   9   0
   0   0   0   0   0   0   0   0   0   0
  -1  -1  -1  -1  -1  -1  -1  -1  -1   0

octave:4> name'
ans =

time
x
der(x)
z
y
c3
c2
c1
$PRE.h1
h1

So h1 (the variable that fails) does not get an entry in the dataInfo matrix!!! This is clearly wrong. If it was filtered, it should not have gotten an entry at all.

comment:4 by Martin Sjölund, 12 years ago

To me it looks like $PRE.h1 is associated with the correct h1 matrix (but it shouldn't be part of the result-file, right?). And h1 gets a bad entry...

comment:5 by Lennart Ochel, 12 years ago

Yes, h1 should and pre(h1) should not occure.
I have just filtered $whenCondition1 ... $whenConditionN. But the implementation is quite a bad workaround. So probably the bug is linked to that implementation.

comment:6 by Martin Sjölund, 12 years ago

Yes. It seems the init.xml file lists h1 is an alias of $whenCondition2. So there are two solutions:
1) Don't filter $when
2) Make the backend never select $when as the real variable (always make $when the alias)

comment:7 by Lennart Ochel, 12 years ago

I would suggest to not select internal variable, that is solution 2

comment:8 by Lennart Ochel, 12 years ago

Cc: Jens Frenkel added

comment:9 by Lennart Ochel, 12 years ago

Who wants to fix that? I can do it.

comment:10 by Jens Frenkel, 12 years ago

one think to the encapsulateWhenConditions module.

I guess it is really awkward to replace

when y then

with

when $whenCondition1 then

The other think: make internal variables prefered as alias is easy to fix. I will do this.

Last edited 12 years ago by Jens Frenkel (previous) (diff)

comment:11 by Jens Frenkel, 12 years ago

add the case

    // we do not replace symbols
    case (condition as DAE.CREF(componentRef=_), _, index, ht)
    then (condition, {}, {}, {}, index, ht);

comment:12 by Jens Frenkel, 12 years ago

Actually Remove simple Equations takes care on variables with pre. Since all $whens have a pre it is not allowed to the remove simple equations module to replace this variables. If we want to replace them we have to change the handling of the initial system.

in reply to:  11 comment:13 by Lennart Ochel, 12 years ago

Replying to jfrenkel:

add the case

    // we do not replace symbols
    case (condition as DAE.CREF(componentRef=_), _, index, ht)
    then (condition, {}, {}, {}, index, ht);

That case is not possible, because it will break the when-handling.

comment:14 by Lennart Ochel, 12 years ago

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