Opened 14 years ago
Last modified 14 years ago
#1249 closed defect (fixed)
incorrect function of SimCode.crefIsScalar() called from template SimCodeC.daeExpCrefRhs2()
Reported by: | Pavol Privitzer | Owned by: | Pavol Privitzer |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | 1.6.0 | |
Keywords: | Cc: | Pavol Privitzer, Per Östlund |
Description
The attached model does not compile with the current OMC trunk.
The model hierarchy is this (only relevant fractions):
{{{model Curve
parameter Real x[:];
parameter Real y[:];
parameter Real slope[:];
end Curve;
model SplineDelayByDay
parameter Real[:,3] data;
Curve curve(
x=data[:, 1],
y=data[:, 2],
slope=data[:, 3]);
end SplineDelayByDay;
model RedCells2
SplineDelayByDay EPOEffect(data={{0.0,0.0,0},{1.3,1.0,1.0},{4.0,4.0,0}});
end RedCells2;
model T
RedCells2 redCells2_1;
end T;
}}}
Where generated BoundParameters() for model T has:
{{{$redCells2_1$PEPOEffect$Pcurve$Pslope$lB3$rB = (*real_array_element_addr(&$redCells2_1$PEPOEffect$Pdata, 2, 3, 3));
$redCells2_1$PEPOEffect$Pcurve$Pslope$lB2$rB = (*real_array_element_addr(&$redCells2_1$PEPOEffect$Pdata, 2, 2, 3));
$redCells2_1$PEPOEffect$Pcurve$Pslope$lB1$rB = (*real_array_element_addr(&$redCells2_1$PEPOEffect$Pdata, 2, 1, 3));
... same for x and y arrays ...
}}}
Instead of
{{{$redCells2_1$PEPOEffect$Pcurve$Pslope$lB3$rB = $redCells2_1$PEPOEffect$Pdata$lB3$c3$rB;
$redCells2_1$PEPOEffect$Pcurve$Pslope$lB2$rB = $redCells2_1$PEPOEffect$Pdata$lB2$c3$rB;
$redCells2_1$PEPOEffect$Pcurve$Pslope$lB1$rB = $redCells2_1$PEPOEffect$Pdata$lB1$c3$rB;
}}}
The incorrect decision point is in the SimCodeC.daeExpCrefRhs2() template in the condition
if crefIsScalar(cr, context) then
which should be true but is not.
The problem is probably in the component references that does not have correct type,
resp. dimension information in the type (the last ident type has 1 less dimensions).
My local workaround is modification of Exp.crefHasScalarSubscripts(), where line
true = listLength(dims) == listLength(subs);
is replaced with
true = listLength(dims) <= listLength(subs);
but the problem is elsewhere, I guess somewhere in the instatiation.
Attachments (1)
Change History (2)
by , 14 years ago
Attachment: | TestRedCells2NoExpandable.mo added |
---|
Fixed in revision 5994, test case mosfiles/SliceAssignment.
The problem is that dimensions may be removed when instantiating a component with constant dimensions, so a component reference may have more subscripts than dimensions. Assuming that a component reference can have more subscripts than dimensions is perhaps not entirely correct, but I believe it is an acceptable solution for now.