Skip to content

Commit 7c5c955

Browse files
authored
Don't combine subscripts for exposeLocalIOs (#12854) (#12861)
Otherwise the creation of top level IOs fails for arrays of model components.
1 parent ffbf36d commit 7c5c955

File tree

3 files changed

+138
-1
lines changed

3 files changed

+138
-1
lines changed

OMCompiler/Compiler/NFFrontEnd/NFFlatten.mo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,6 @@ algorithm
23882388
attributes := tlio_var.attributes;
23892389
if attributes.direction == Direction.NONE then
23902390
tlio_var := variable; // same attributes like start, unit
2391-
tlio_var.name := ComponentRef.combineSubscripts(tlio_var.name);
23922391
tlio_var.binding := UNBOUND(); // value is defined with tlio_eql
23932392
// find new name in global scope, starting with quoted identifier
23942393
cref := tlio_var.name;

testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TEST = ../../../../../rtest -v
44
TESTFILES = \
55
DIC_FMU2_CPP.mos \
66
exposeLocalIOs.mos \
7+
exposeLocalIOsArray.mos \
78
solveOneNonlinearEquationTest.mos \
89
testArrayEquations.mos \
910
testFMU2MatrixIO.mos \
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// name: exposeLocalIOsArray
2+
// keywords: FMI input output
3+
// status: correct
4+
// teardown_command: rm -f *LocalIOsArray.System* modelDescription.tmp.xml
5+
6+
setCommandLineOptions("--simCodeTarget=Cpp");
7+
setCommandLineOptions("--exposeLocalIOs=1"); getErrorString();
8+
9+
loadString("
10+
package LocalIOsArray
11+
12+
connector RealOutput = output Real;
13+
14+
model Component
15+
RealOutput y;
16+
equation
17+
y = time;
18+
end Component;
19+
20+
model System
21+
Component component;
22+
Component[2] componentArray;
23+
end System;
24+
25+
end LocalIOsArray;
26+
");
27+
getErrorString();
28+
29+
buildModelFMU(LocalIOsArray.System, version="2.0", fileNamePrefix="LocalIOsArray.System"); getErrorString();
30+
31+
// unzip to console, quiet, extra quiet
32+
system("unzip -cqq LocalIOsArray.System.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml");
33+
readFile("modelDescription.tmp.xml");
34+
35+
// Result:
36+
// true
37+
// true
38+
// ""
39+
// true
40+
// ""
41+
// "LocalIOsArray.System.fmu"
42+
// ""
43+
// 0
44+
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
45+
// <fmiModelDescription
46+
// fmiVersion=\"2.0\"
47+
// modelName=\"LocalIOsArray.System\"
48+
// description=\"\"
49+
// version=\"\"
50+
// variableNamingConvention=\"structured\"
51+
// numberOfEventIndicators=\"0\">
52+
// <ModelExchange
53+
// modelIdentifier=\"LocalIOsArray_System\"
54+
// needsExecutionTool=\"false\"
55+
// completedIntegratorStepNotNeeded=\"false\"
56+
// canBeInstantiatedOnlyOncePerProcess=\"false\"
57+
// canNotUseMemoryManagementFunctions=\"false\"
58+
// canGetAndSetFMUstate=\"false\"
59+
// canSerializeFMUstate=\"false\"
60+
// providesDirectionalDerivative=\"false\">
61+
// </ModelExchange>
62+
// <LogCategories>
63+
// <Category name=\"logEvents\" />
64+
// <Category name=\"logSingularLinearSystems\" />
65+
// <Category name=\"logNonlinearSystems\" />
66+
// <Category name=\"logDynamicStateSelection\" />
67+
// <Category name=\"logStatusWarning\" />
68+
// <Category name=\"logStatusDiscard\" />
69+
// <Category name=\"logStatusError\" />
70+
// <Category name=\"logStatusFatal\" />
71+
// <Category name=\"logStatusPending\" />
72+
// <Category name=\"logAll\" />
73+
// <Category name=\"logFmi2Call\" />
74+
// </LogCategories>
75+
// <DefaultExperiment startTime=\"0.0\" stopTime=\"1.0\" tolerance=\"1e-6\" stepSize=\"0.002\"/>
76+
// <ModelVariables>
77+
// <!-- Index of variable = \"1\" -->
78+
// <ScalarVariable
79+
// name=\"'component.y'\"
80+
// valueReference=\"0\"
81+
// causality=\"output\"
82+
// >
83+
// <Real/>
84+
// </ScalarVariable>
85+
// <!-- Index of variable = \"2\" -->
86+
// <ScalarVariable
87+
// name=\"'componentArray[1].y'\"
88+
// valueReference=\"1\"
89+
// causality=\"output\"
90+
// >
91+
// <Real/>
92+
// </ScalarVariable>
93+
// <!-- Index of variable = \"3\" -->
94+
// <ScalarVariable
95+
// name=\"'componentArray[2].y'\"
96+
// valueReference=\"2\"
97+
// causality=\"output\"
98+
// >
99+
// <Real/>
100+
// </ScalarVariable>
101+
// <!-- Index of variable = \"4\" -->
102+
// <ScalarVariable
103+
// name=\"component.y\"
104+
// valueReference=\"0\"
105+
// >
106+
// <Real/>
107+
// </ScalarVariable>
108+
// <!-- Index of variable = \"5\" -->
109+
// <ScalarVariable
110+
// name=\"componentArray[1].y\"
111+
// valueReference=\"1\"
112+
// >
113+
// <Real/>
114+
// </ScalarVariable>
115+
// <!-- Index of variable = \"6\" -->
116+
// <ScalarVariable
117+
// name=\"componentArray[2].y\"
118+
// valueReference=\"2\"
119+
// >
120+
// <Real/>
121+
// </ScalarVariable>
122+
// </ModelVariables>
123+
// <ModelStructure>
124+
// <Outputs>
125+
// <Unknown index=\"1\" dependencies=\"\" dependenciesKind=\"\" />
126+
// <Unknown index=\"2\" dependencies=\"\" dependenciesKind=\"\" />
127+
// <Unknown index=\"3\" dependencies=\"\" dependenciesKind=\"\" />
128+
// </Outputs>
129+
// <InitialUnknowns>
130+
// <Unknown index=\"1\" dependencies=\"\" dependenciesKind=\"\" />
131+
// <Unknown index=\"2\" dependencies=\"\" dependenciesKind=\"\" />
132+
// <Unknown index=\"3\" dependencies=\"\" dependenciesKind=\"\" />
133+
// </InitialUnknowns>
134+
// </ModelStructure>
135+
// </fmiModelDescription>
136+
// "
137+
// endResult

0 commit comments

Comments
 (0)