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

Commit bacaf03

Browse files
lochelOpenModelica-Hudson
authored andcommitted
Don't replace dots in fileNamePrefix for FMUs
1 parent b7bed21 commit bacaf03

6 files changed

Lines changed: 22 additions & 14 deletions

File tree

Compiler/Script/CevalScriptBackend.mo

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,8 +3257,8 @@ protected function buildModelFMU " author: Frenkel TUD
32573257
output GlobalScript.SymbolTable st;
32583258
protected
32593259
Boolean staticSourceCodeFMU;
3260-
String filenameprefix, fmutmp, thisplatform, cmd, logfile,
3261-
makefileStr, LIBS, dir;
3260+
String filenameprefix, fmutmp, logfile, dir;
3261+
String fmuTargetName;
32623262
GlobalScript.SimulationOptions defaulSimOpt;
32633263
SimCode.SimulationSettings simSettings;
32643264
list<String> libs;
@@ -3285,11 +3285,12 @@ algorithm
32853285
Error.addMessage(Error.FMU_EXPORT_NOT_SUPPORTED_CPP, {FMUType});
32863286
FMUType := "me";
32873287
end if;
3288-
filenameprefix := Util.stringReplaceChar(if inFileNamePrefix == "<default>" then Absyn.pathString(className) else inFileNamePrefix,".","_");
3288+
filenameprefix := Util.stringReplaceChar(if inFileNamePrefix == "<default>" then Absyn.pathString(className) else inFileNamePrefix, ".", "_");
3289+
fmuTargetName := if FMUVersion == "1.0" then filenameprefix else (if inFileNamePrefix == "<default>" then Absyn.pathString(className) else inFileNamePrefix);
32893290
defaulSimOpt := buildSimulationOptionsFromModelExperimentAnnotation(st, className, filenameprefix, SOME(defaultSimulationOptions));
32903291
simSettings := convertSimulationOptionsToSimCode(defaulSimOpt);
32913292
try
3292-
(cache, outValue, st,_, libs,_, _) := SimCodeMain.translateModelFMU(cache, inEnv, className, st, FMUVersion, FMUType, filenameprefix, addDummy, simSettings);
3293+
(cache, outValue, st,_, libs,_, _) := SimCodeMain.translateModelFMU(cache, inEnv, className, st, FMUVersion, FMUType, filenameprefix, fmuTargetName, addDummy, simSettings);
32933294
else
32943295
outValue := Values.STRING("");
32953296
return;

Compiler/SimCode/SimCode.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ uniontype SimCode
134134
list<JacobianMatrix> jacobianMatrixes;
135135
Option<SimulationSettings> simulationSettingsOpt;
136136
String fileNamePrefix, fullPathPrefix "Used in FMI where files are generated in a special directory";
137+
String fmuTargetName;
137138
HpcOmSimCode.HpcOmData hpcomData;
138139
//maps each variable to an array of storage indices (with this information, arrays must not be unrolled) and a list for the array-dimensions
139140
//if the variable is not part of an array (if it is a scalar value), then the array has size 1

Compiler/SimCode/SimCodeMain.mo

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ protected function generateModelCodeFMU "
129129
input String FMUVersion;
130130
input String FMUType;
131131
input String filenamePrefix;
132+
input String fmuTargetName;
132133
input SimCode.SimulationSettings simSettings;
133134
output list<String> libs;
134135
output String fileDir;
@@ -151,7 +152,7 @@ algorithm
151152
(libs,libPaths,includes, includeDirs, recordDecls, functions, literals) :=
152153
SimCodeUtil.createFunctions(p, inBackendDAE);
153154
simCode := createSimCode(inBackendDAE, inInitDAE, inInitDAE_lambda0, NONE(), inRemovedInitialEquationLst,
154-
className, filenamePrefix, fileDir, functions, includes, includeDirs, libs, libPaths, p, SOME(simSettings), recordDecls, literals, Absyn.FUNCTIONARGS({},{}), isFMU=true, FMUVersion=FMUVersion);
155+
className, filenamePrefix, fileDir, functions, includes, includeDirs, libs, libPaths, p, SOME(simSettings), recordDecls, literals, Absyn.FUNCTIONARGS({},{}), isFMU=true, FMUVersion=FMUVersion, fmuTargetName=fmuTargetName);
155156
timeSimCode := System.realtimeTock(ClockIndexes.RT_CLOCK_SIMCODE);
156157
ExecStat.execStat("SimCode");
157158

@@ -215,6 +216,7 @@ public function translateModelFMU
215216
input String inFMUVersion;
216217
input String inFMUType;
217218
input String inFileNamePrefix;
219+
input String fmuTargetName;
218220
input Boolean addDummy "if true, add a dummy state";
219221
input SimCode.SimulationSettings inSimSettings;
220222
output FCore.Cache outCache;
@@ -274,7 +276,7 @@ algorithm
274276
timeBackend = System.realtimeTock(ClockIndexes.RT_CLOCK_BACKEND);
275277

276278
(libs,file_dir,timeSimCode,timeTemplates) =
277-
generateModelCodeFMU(dlow_1, initDAE, initDAE_lambda0, removedInitialEquationLst, p, className, FMUVersion, FMUType, filenameprefix, inSimSettings);
279+
generateModelCodeFMU(dlow_1, initDAE, initDAE_lambda0, removedInitialEquationLst, p, className, FMUVersion, FMUType, filenameprefix, fmuTargetName, inSimSettings);
278280

279281
//reset config flag
280282
Flags.setConfigBool(Flags.GENERATE_SYMBOLIC_LINEARIZATION, symbolicJacActivated);
@@ -289,7 +291,7 @@ algorithm
289291
("timeFrontend", Values.REAL(timeFrontend))
290292
};
291293

292-
resstr = filenameprefix + ".fmu";
294+
resstr = fmuTargetName + ".fmu";
293295
if not Config.getRunningTestsuite() then
294296
resstr = System.pwd() + System.pathDelimiter() + resstr;
295297
end if;
@@ -467,6 +469,7 @@ protected function createSimCode "
467469
input Absyn.FunctionArgs args;
468470
input Boolean isFMU=false;
469471
input String FMUVersion="";
472+
input String fmuTargetName="";
470473
output SimCode.SimCode simCode;
471474
algorithm
472475
simCode := matchcontinue(inBackendDAE, inClassName, filenamePrefix, inString11, functions, externalFunctionIncludes, includeDirs, libs, libPaths, program,simSettingsOpt, recordDecls, literals, args)
@@ -505,7 +508,7 @@ algorithm
505508
then HpcOmSimCodeMain.createSimCode(inBackendDAE, inInitDAE, inInitDAE_lambda0, inRemovedInitialEquationLst, inClassName, filenamePrefix, inString11, functions, externalFunctionIncludes, includeDirs, libs, libPaths,program,simSettingsOpt, recordDecls, literals, args);
506509

507510
else equation
508-
(tmpSimCode, _) = SimCodeUtil.createSimCode(inBackendDAE, inInitDAE, inInitDAE_lambda0, inInlineData, inRemovedInitialEquationLst, inClassName, filenamePrefix, inString11, functions, externalFunctionIncludes, includeDirs, libs,libPaths,program, simSettingsOpt, recordDecls, literals, args, isFMU=isFMU, FMUVersion=FMUVersion);
511+
(tmpSimCode, _) = SimCodeUtil.createSimCode(inBackendDAE, inInitDAE, inInitDAE_lambda0, inInlineData, inRemovedInitialEquationLst, inClassName, filenamePrefix, inString11, functions, externalFunctionIncludes, includeDirs, libs,libPaths,program, simSettingsOpt, recordDecls, literals, args, isFMU=isFMU, FMUVersion=FMUVersion, fmuTargetName=fmuTargetName);
509512
then tmpSimCode;
510513
end matchcontinue;
511514
end createSimCode;

Compiler/SimCode/SimCodeUtil.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public function createSimCode "entry point to create SimCode from BackendDAE."
166166
input Absyn.FunctionArgs args;
167167
input Boolean isFMU=false;
168168
input String FMUVersion="";
169+
input String fmuTargetName="";
169170
output SimCode.SimCode simCode;
170171
output tuple<Integer, list<tuple<Integer, Integer>>> outMapping "the highest simEqIndex in the mapping and the mapping simEq-Index -> scc-Index itself";
171172
protected
@@ -566,6 +567,7 @@ algorithm
566567
simSettingsOpt,
567568
filenamePrefix,
568569
if isFMU then (filenamePrefix+".fmutmp/sources/") else "",
570+
fmuTargetName,
569571
HpcOmSimCode.emptyHpcomData,
570572
varToArrayIndexMapping,
571573
varToIndexMapping,

Compiler/Template/CodegenFMU.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ match simVar
10381038
end SwitchAliasVarsSet;
10391039

10401040

1041-
template getPlatformString2(String modelNamePrefix, String platform, String fileNamePrefix, String dirExtra, String libsPos1, String libsPos2, String omhome, String FMUVersion)
1041+
template getPlatformString2(String modelNamePrefix, String platform, String fileNamePrefix, String fmuTargetName, String dirExtra, String libsPos1, String libsPos2, String omhome, String FMUVersion)
10421042
"returns compilation commands for the platform. "
10431043
::=
10441044
let fmudirname = '<%fileNamePrefix%>.fmutmp'
@@ -1067,7 +1067,7 @@ match platform
10671067
<%\t%>cp <%omhome%>/bin/libgcc_s_*.dll ../binaries/<%platform%>/
10681068
<%\t%>cp <%omhome%>/bin/libstdc*.dll ../binaries/<%platform%>/
10691069
<%\t%>rm -f <%fileNamePrefix%>.def <%fileNamePrefix%>.o <%fileNamePrefix%>$(DLLEXT) $(OFILES) $(RUNTIMEFILES)
1070-
<%\t%>cd .. && rm -f ../<%fileNamePrefix%>.fmu && zip -r ../<%fileNamePrefix%>.fmu *
1070+
<%\t%>cd .. && rm -f ../<%fileNamePrefix%>.fmu && zip -r ../<%fmuTargetName%>.fmu *
10711071

10721072
>>
10731073
else
@@ -1086,7 +1086,7 @@ match platform
10861086
<%\t%>cp <%fileNamePrefix%>.a <%fileNamePrefix%>_FMU.libs config.log make.log ../binaries/$(FMIPLATFORM)/
10871087
endif
10881088
<%\t%>$(MAKE) distclean
1089-
<%\t%>cd .. && rm -f ../<%fileNamePrefix%>.fmu && zip -r ../<%fileNamePrefix%>.fmu *
1089+
<%\t%>cd .. && rm -f ../<%fileNamePrefix%>.fmu && zip -r ../<%fmuTargetName%>.fmu *
10901090
distclean: clean
10911091
<%\t%>rm -f Makefile config.status config.log make.log
10921092
clean:
@@ -1132,7 +1132,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
11321132
'<%match s.method
11331133
case "inline-euler" then "-D_OMC_INLINE_EULER"
11341134
case "inline-rungekutta" then "-D_OMC_INLINE_RK"%>'
1135-
let compilecmds = getPlatformString2(modelNamePrefix(simCode), makefileParams.platform, fileNamePrefix, dirExtra, libsPos1, libsPos2, makefileParams.omhome, FMUVersion)
1135+
let compilecmds = getPlatformString2(modelNamePrefix(simCode), makefileParams.platform, fileNamePrefix, fmuTargetName, dirExtra, libsPos1, libsPos2, makefileParams.omhome, FMUVersion)
11361136
let mkdir = match makefileParams.platform case "win32" case "win64" then '"mkdir.exe"' else 'mkdir'
11371137
<<
11381138
# Makefile generated by OpenModelica
@@ -1190,7 +1190,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
11901190
copy <%stringReplace(makefileParams.omhome,"/","\\")%>\bin\LAPACK_WIN32_MT.DLL <%fmudirname%>\binaries\$(PLATWIN32)
11911191
copy <%stringReplace(makefileParams.omhome,"/","\\")%>\bin\pthreadVC2.dll <%fmudirname%>\binaries\$(PLATWIN32)
11921192
cd <%fmudirname%>
1193-
"zip.exe" -r ../<%fileNamePrefix%>.fmu *
1193+
"zip.exe" -r ../<%fmuTargetName%>.fmu *
11941194
cd ..
11951195
rm -rf <%fmudirname%>
11961196

@@ -1209,7 +1209,7 @@ case SIMCODE(modelInfo=MODELINFO(varInfo=varInfo as VARINFO(__)), delayedExps=DE
12091209
'<%match s.method
12101210
case "inline-euler" then "-D_OMC_INLINE_EULER"
12111211
case "inline-rungekutta" then "-D_OMC_INLINE_RK"%>'
1212-
let compilecmds = getPlatformString2(modelNamePrefix(simCode), makefileParams.platform, fileNamePrefix, dirExtra, libsPos1, libsPos2, makefileParams.omhome, FMUVersion)
1212+
let compilecmds = getPlatformString2(modelNamePrefix(simCode), makefileParams.platform, fileNamePrefix, fmuTargetName, dirExtra, libsPos1, libsPos2, makefileParams.omhome, FMUVersion)
12131213
let platformstr = makefileParams.platform
12141214
<<
12151215
# Makefile generated by OpenModelica

Compiler/Template/SimCodeTV.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ package SimCode
345345
Option<SimulationSettings> simulationSettingsOpt;
346346
String fileNamePrefix;
347347
String fullPathPrefix; // Used for FMI where code is not generated in the same directory
348+
String fmuTargetName;
348349
HpcOmSimCode.HpcOmData hpcomData;
349350
HashTableCrIListArray.HashTable varToArrayIndexMapping;
350351
Option<FmiModelStructure> modelStructure;

0 commit comments

Comments
 (0)