Opened 11 years ago

Closed 11 years ago

#2026 closed defect (fixed)

generated mat-file is invalid

Reported by: lochel Owned by: sjoelund.se
Priority: high Milestone: 1.9.0
Component: Run-time Version: trunk
Keywords: Cc: jfrenkel

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 Changed 11 years ago by lochel

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 Changed 11 years ago by sjoelund.se

  • Owner changed from somebody to sjoelund.se
  • Status changed from new to accepted

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 Changed 11 years ago by sjoelund.se

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 Changed 11 years ago by sjoelund.se

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 Changed 11 years ago by lochel

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 Changed 11 years ago by sjoelund.se

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 Changed 11 years ago by lochel

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

comment:8 Changed 11 years ago by lochel

  • Cc jfrenkel added

comment:9 Changed 11 years ago by lochel

Who wants to fix that? I can do it.

comment:10 Changed 11 years ago by jfrenkel

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 11 years ago by jfrenkel (previous) (diff)

comment:11 follow-up: Changed 11 years ago by jfrenkel

add the case

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

comment:12 Changed 11 years ago by jfrenkel

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.

comment:13 in reply to: ↑ 11 Changed 11 years ago by lochel

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 Changed 11 years ago by lochel

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