Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 8e8393f

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
[NF] Skip empty array variables and equations
Belonging to [master]: - #2738 - OpenModelica/OpenModelica-testsuite#1060
1 parent a08ef7b commit 8e8393f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Compiler/NFFrontEnd/NFConnector.mo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ protected
236236
conns := splitImpl(c, t, face, source, cty, conns);
237237
end for;
238238
else
239-
conns := CONNECTOR(name, ty, face, cty, source) :: conns;
239+
if not Type.isEmptyArray(ty) then
240+
conns := CONNECTOR(name, ty, face, cty, source) :: conns;
241+
end if;
240242
end if;
241243
then
242244
conns;

Compiler/NFFrontEnd/NFInst.mo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import FlatModel = NFFlatModel;
9797
import ElementSource;
9898
import SimplifyModel = NFSimplifyModel;
9999
import Record = NFRecord;
100+
import Variable = NFVariable;
100101
import OperatorOverloading = NFOperatorOverloading;
101102
import EvalConstants = NFEvalConstants;
102103

@@ -167,6 +168,9 @@ algorithm
167168
// Scalarize array components in the flat model.
168169
if Flags.isSet(Flags.NF_SCALARIZE) then
169170
flat_model := Scalarize.scalarize(flat_model, name);
171+
else
172+
// Remove empty arrays from variables
173+
flat_model.variables := List.filterOnFalse(flat_model.variables, Variable.isEmptyArray);
170174
end if;
171175

172176
// Convert the flat model to a DAE.

Compiler/NFFrontEnd/NFVariable.mo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,10 @@ public
8484
variable.attributes.variability <= Variability.STRUCTURAL_PARAMETER;
8585
end isStructural;
8686

87+
function isEmptyArray
88+
input Variable variable;
89+
output Boolean isEmpty = Type.isEmptyArray(variable.ty);
90+
end isEmptyArray;
91+
8792
annotation(__OpenModelica_Interface="frontend");
8893
end NFVariable;

0 commit comments

Comments
 (0)