Hi all,
I'm trying to build an FMU from a Modelica model. Some of the parameters are read in Modelica from a .json-file, others from a .csv file.
This happens on various systems. My host system is a M1 Mac running macOS Ventura 13.2
I installed OpenModelica using brew. omc --version
prints:
OMCompiler v1.18.0
Afterwards I ran this script to install the Modelica and ExternData libraries:
installPackage(Modelica);
installPackage(Complex);
installPackage(ModelicaServices);
installPackage(ExternData);
Now, I want to build my FMU with the following script (executed in the package folder):
loadModel(Modelica);getErrorString();
loadModel(ExternData);getErrorString();
loadFile("package.mo");getErrorString();
setCommandLineOptions("--fmiFlags=s:cvode --linkType=static --fmuRuntimeDepends=all");getErrorString();
cd("/home/Modelica/res");getErrorString(); // (note: the folder exists)
buildModelFMU(PVexample.Houseexample, version="2.0", fmuType="cs", fileNamePrefix="Houseexample");getErrorString();
When running the script on macOS, this is the resulting error:
[...]
mkdir -p ../binaries/aarch64-darwin
clang -shared -o Houseexample.dylib Houseexample.o Houseexample_functions.o Houseexample_records.o Houseexample_01exo.o Houseexample_02nls.o Houseexample_03lsy.o Houseexample_04set.o Houseexample_05evt.o Houseexample_06inz.o Houseexample_07dly.o Houseexample_08bnd.o Houseexample_09alg.o Houseexample_10asr.o Houseexample_11mix.o Houseexample_12jac.o Houseexample_13opt.o Houseexample_14lnz.o Houseexample_15syn.o Houseexample_16dae.o Houseexample_17inl.o Houseexample_18spd.o Houseexample_init_fmu.o Houseexample_FMU.o simulation/solver/cvode_solver.o simulation/solver/sundials_error.o -L\"/Users/alex/Diplomarbeit/Modelica/packages/PVexample\" \"-L/opt/homebrew/Cellar/openmodelica/1.18.0_6/lib/aarch64-darwin21.6.0/omc\" \"-L/opt/homebrew/Cellar/openmodelica/1.18.0_6/lib/\" \"-L/Users/alex/.openmodelica/binaries/PVexample\" \"-L/Users/alex/Diplomarbeit/Modelica/packages/PVexample/Resources/Library/aarch64-darwin\" \"-L/Users/alex/Diplomarbeit/Modelica/packages/PVexample/Resources/Library\" -lED_JSONFile -lparson \"-L/Users/alex/.openmodelica/binaries/Modelica\" \"-L/Users/alex/.openmodelica/libraries/Modelica 4.0.0+maint.om/Resources/Library/aarch64-darwin\" \"-L/Users/alex/.openmodelica/libraries/Modelica 4.0.0+maint.om/Resources/Library\" -lModelicaExternalC -lModelicaStandardTables -lModelicaIO -lModelicaMatIO -lzlib \"-L/Users/alex/.openmodelica/binaries/ExternData\" \"-L/Users/alex/.openmodelica/libraries/ExternData 3.0.3/Resources/Library/aarch64-darwin\" \"-L/Users/alex/.openmodelica/libraries/ExternData 3.0.3/Resources/Library\" -L'/opt/homebrew/Cellar/openmodelica/1.18.0_6/lib/aarch64-darwin21.6.0/omc' -Wl,-rpath,'/opt/homebrew/Cellar/openmodelica/1.18.0_6/lib/aarch64-darwin21.6.0/omc' -lSimulationRuntimeFMI -lopenblas -lm -lsundials_cvode -lsundials_nvecserial
ld: warning: directory not found for option '-L/Users/alex/.openmodelica/binaries/PVexample'
ld: warning: directory not found for option '-L/Users/alex/Diplomarbeit/Modelica/packages/PVexample/Resources/Library/aarch64-darwin'
ld: warning: directory not found for option '-L/Users/alex/Diplomarbeit/Modelica/packages/PVexample/Resources/Library'
ld: warning: directory not found for option '-L/Users/alex/.openmodelica/binaries/Modelica'
ld: warning: directory not found for option '-L/Users/alex/.openmodelica/libraries/Modelica 4.0.0+maint.om/Resources/Library/aarch64-darwin'
ld: warning: directory not found for option '-L/Users/alex/.openmodelica/libraries/Modelica 4.0.0+maint.om/Resources/Library'
ld: warning: directory not found for option '-L/Users/alex/.openmodelica/binaries/ExternData'
ld: warning: directory not found for option '-L/Users/alex/.openmodelica/libraries/ExternData 3.0.3/Resources/Library/aarch64-darwin'
ld: library not found for -lED_JSONFile
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nozip] Error 1
I checked if there were any missing files, but ExternData folder inside .openmodelica/libraries is identical to what I see here on GitHub.
So next I tried the amd64 docker container (openmodelica/openmodelica:v1.20.0-gui).
I installed the libraries with the same script as above, then ran the same script.
It finished and produced an FMU. I could not load this though because in the modelDescription.xml, every parameter that should have been read from the .json or .csv is missing the start value, therefore it cannot be initialized.
While compiling, I get this output several times:
[/root/.openmodelica/libraries/ExternData 3.0.3/package.mo:112:23-112:178:writable] Warning: Could not find library ED_JSONFile in either of:
/usr/bin/../lib/x86_64-linux-gnu/omc/libED_JSONFile.a
/usr/lib/x86_64-linux-gnu/libED_JSONFile.a
/lib/x86_64-linux-gnu/libED_JSONFile.a
/usr/lib//libED_JSONFile.a
/lib//libED_JSONFile.a
/usr/bin/../lib/x86_64-linux-gnu/omc/libED_JSONFile.a
/usr/bin/../lib//libED_JSONFile.a
/root/.openmodelica/binaries/PVexample/libED_JSONFile.a
/home/Modelica/PVexample/Resources/Library/x86_64-linux/libED_JSONFile.a
/home/Modelica/PVexample/Resources/Library/linux64/libED_JSONFile.a
/home/Modelica/PVexample/Resources/Library/libED_JSONFile.a
/usr/bin/../lib/x86_64-linux-gnu/omc/libED_JSONFile.so
/usr/lib/x86_64-linux-gnu/libED_JSONFile.so
/lib/x86_64-linux-gnu/libED_JSONFile.so
/usr/lib//libED_JSONFile.so
/lib//libED_JSONFile.so
/usr/bin/../lib/x86_64-linux-gnu/omc/libED_JSONFile.so
/usr/bin/../lib//libED_JSONFile.so
/root/.openmodelica/binaries/PVexample/libED_JSONFile.so
/home/Modelica/PVexample/Resources/Library/x86_64-linux/libED_JSONFile.so
/home/Modelica/PVexample/Resources/Library/linux64/libED_JSONFile.so
/home/Modelica/PVexample/Resources/Library/libED_JSONFile.so
[/root/.openmodelica/libraries/ExternData 3.0.3/package.mo:112:23-112:178:writable] Warning: Could not find library parson in either of:
/usr/bin/../lib/x86_64-linux-gnu/omc/libparson.a
/usr/lib/x86_64-linux-gnu/libparson.a
/lib/x86_64-linux-gnu/libparson.a
/usr/lib//libparson.a
/lib//libparson.a
/usr/bin/../lib/x86_64-linux-gnu/omc/libparson.a
/usr/bin/../lib//libparson.a
/root/.openmodelica/binaries/PVexample/libparson.a
/home/Modelica/PVexample/Resources/Library/x86_64-linux/libparson.a
/home/Modelica/PVexample/Resources/Library/linux64/libparson.a
/home/Modelica/PVexample/Resources/Library/libparson.a
/usr/bin/../lib/x86_64-linux-gnu/omc/libparson.so
/usr/lib/x86_64-linux-gnu/libparson.so
/lib/x86_64-linux-gnu/libparson.so
/usr/lib//libparson.so
/lib//libparson.so
/usr/bin/../lib/x86_64-linux-gnu/omc/libparson.so
/usr/bin/../lib//libparson.so
/root/.openmodelica/binaries/PVexample/libparson.so
/home/Modelica/PVexample/Resources/Library/x86_64-linux/libparson.so
/home/Modelica/PVexample/Resources/Library/linux64/libparson.so
/home/Modelica/PVexample/Resources/Library/libparson.so
Warning: Could not resolve URI (uri) at compile-time; copying all loaded packages into the FMU
"
When running the executable in the terminal, I get the following:
stdout | info | ... loading "/home/dev/Modelica/packages/PVexample/Data/CH4.json"
stdout | info | ... loading "/home/dev/Modelica/packages/PVexample/Data/ExhaustGas.json"
stdout | info | ... loading "/home/dev/Modelica/packages/PVexample/Data/Air.json"
stdout | info | ... loading "/home/dev/Modelica/packages/PVexample/Data/ExhaustGas.json"
stdout | info | ... loading "/home/dev/Modelica/packages/PVexample/Data/CH4.json"
stdout | info | ... loading "table" from "/home/dev/Modelica/packages/PVexample/Data/HouseholdProfiles.csv"
assert | debug | Error in line 1 when reading numeric data of matrix "table(8762,5)" from file "/home/dev/Modelica/packages/PVexample/Data/HouseholdProfiles.csv"
assert | info | simulation terminated by an assertion at initialization
The same output is generated when using OMPython to start a simulation. When I call convertMo2Fmu(), I can see that files are being generated, but no .fmu file. The return in the console is just ' '.
I tried the same on an Ubuntu 22.04 VM using OMEdit. The results were - unsurprisingly - the same.
When I ran the package in OMEdit on a Windows machine, it worked perfectly fine. All I did was copying the package to a unix system (and I even ran dos2unix on the .csv files).
Please do not tell me that using Windows is the only way to go...
Where is my mistake here? Any help is gladly appreciated!
Thanks in advance