diff --git a/Compiler/NFFrontEnd/NFInst.mo b/Compiler/NFFrontEnd/NFInst.mo index cfd5f3a84d..c1fae7ce3b 100644 --- a/Compiler/NFFrontEnd/NFInst.mo +++ b/Compiler/NFFrontEnd/NFInst.mo @@ -152,7 +152,10 @@ algorithm flat_model := Package.collectConstants(flat_model, funcs); // Scalarize array components in the flat model. - flat_model := Scalarize.scalarize(flat_model, name); + if Flags.isSet(Flags.NF_SCALARIZE) then + flat_model := Scalarize.scalarize(flat_model, name); + end if; + // Convert the flat model to a DAE. (dae, daeFuncs) := ConvertDAE.convert(flat_model, funcs, name, InstNode.info(inst_cls)); diff --git a/Compiler/NFFrontEnd/NFOCConnectionGraph.mo b/Compiler/NFFrontEnd/NFOCConnectionGraph.mo index 47d52bc22b..0766a4dcb1 100644 --- a/Compiler/NFFrontEnd/NFOCConnectionGraph.mo +++ b/Compiler/NFFrontEnd/NFOCConnectionGraph.mo @@ -192,6 +192,10 @@ algorithm if isOverconstrainedCref(lhs) and isOverconstrainedCref(rhs) then lhs := getOverconstrainedCref(lhs); rhs := getOverconstrainedCref(rhs); + + lhs := ComponentRef.stripSubscripts(lhs); + rhs := ComponentRef.stripSubscripts(rhs); + graph := addConnection(graph, lhs, rhs, eqlBroken); added := true; break; @@ -270,11 +274,11 @@ function generateEqualityConstraintEquation input DAE.ElementSource source; output list eqsEqualityConstraint = {}; protected - ComponentRef lhs, rhs, cref, fcref_rhs, fcref_lhs; + ComponentRef lhs, rhs, cref, fcref_rhs, fcref_lhs, lhsArr, rhsArr; list eql = {}; list lst; Type ty, ty1, ty2; - ComponentRef lhs, rhs; + ComponentRef clhs, crhs; Integer priority; Expression root, msg; Connector c1, c2, cc1, cc2; @@ -288,12 +292,12 @@ algorithm return; end if; - Expression.CREF(ty = ty1, cref = lhs) := elhs; - Expression.CREF(ty = ty2, cref = rhs) := erhs; - if not (ComponentRef.isDeleted(lhs) or ComponentRef.isDeleted(rhs)) + Expression.CREF(ty = ty1, cref = clhs) := elhs; + Expression.CREF(ty = ty2, cref = crhs) := erhs; + if not (ComponentRef.isDeleted(clhs) or ComponentRef.isDeleted(crhs)) then - cl1 := NFConnections.makeConnectors(lhs, ty1, source); - cl2 := NFConnections.makeConnectors(rhs, ty2, source); + cl1 := NFConnections.makeConnectors(clhs, ty1, source); + cl2 := NFConnections.makeConnectors(crhs, ty2, source); for c1 in cl1 loop c2 :: cl2 := cl2; @@ -310,16 +314,19 @@ algorithm lhs := getOverconstrainedCref(lhs); rhs := getOverconstrainedCref(rhs); - ty1 := ComponentRef.getComponentType(lhs); - ty2 := ComponentRef.getComponentType(rhs); + lhsArr := ComponentRef.stripSubscripts(lhs); + rhsArr := ComponentRef.stripSubscripts(rhs); + + ty1 := ComponentRef.getComponentType(lhsArr); + ty2 := ComponentRef.getComponentType(rhsArr); - fcref_rhs := Function.lookupFunctionSimple("equalityConstraint", ComponentRef.node(lhs)); + fcref_rhs := Function.lookupFunctionSimple("equalityConstraint", InstNode.classScope(ComponentRef.node(lhs))); (fcref_rhs, fn_node_rhs, _) := Function.instFunctionRef(fcref_rhs, ElementSource.getInfo(source)); - expRHS := Expression.CALL(Call.UNTYPED_CALL(fcref_rhs, {Expression.CREF(ty1, lhs), Expression.CREF(ty2, rhs)}, {}, fn_node_rhs)); + expRHS := Expression.CALL(Call.UNTYPED_CALL(fcref_rhs, {Expression.CREF(ty1, lhsArr), Expression.CREF(ty2, rhsArr)}, {}, fn_node_rhs)); (expRHS, ty, var) := Typing.typeExp(expRHS, origin, ElementSource.getInfo(source), true); - fcref_lhs := Function.lookupFunctionSimple("fill", ComponentRef.node(lhs)); + fcref_lhs := Function.lookupFunctionSimple("fill", InstNode.topScope(ComponentRef.node(clhs))); (fcref_lhs, fn_node_lhs, _) := Function.instFunctionRef(fcref_lhs, ElementSource.getInfo(source)); expLHS := Expression.CALL(Call.UNTYPED_CALL(fcref_lhs, Expression.REAL(0.0)::List.map(Type.arrayDims(ty), Dimension.sizeExp), {}, fn_node_lhs)); diff --git a/Compiler/Util/Flags.mo b/Compiler/Util/Flags.mo index 2adfa9abe2..e4c0fee376 100644 --- a/Compiler/Util/Flags.mo +++ b/Compiler/Util/Flags.mo @@ -530,6 +530,8 @@ constant DebugFlag EXEC_STAT_EXTRA_GC = DEBUG_FLAG(177, "execstatGCcollect", fal Util.gettext("When running execstat, also perform an extra full garbage collection.")); constant DebugFlag DEBUG_DAEMODE = DEBUG_FLAG(178, "debugDAEmode", false, Util.gettext("Dump debug output for the DAEmode.")); +constant DebugFlag NF_SCALARIZE = DEBUG_FLAG(179, "nfScalarize", true, + Util.gettext("Run scalarization in NF, default true.")); // This is a list of all debug flags, to keep track of which flags are used. A // flag can not be used unless it's in this list, and the list is checked at @@ -714,7 +716,8 @@ constant list allDebugFlags = { SUSAN_MATCHCONTINUE_DEBUG, OLD_FE_UNITCHECK, EXEC_STAT_EXTRA_GC, - DEBUG_DAEMODE + DEBUG_DAEMODE, + NF_SCALARIZE }; public