Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5146 closed defect (fixed)

FMU export in ME 1.0 mode broken for OMEdit (but works with omc)

Reported by: anatoly.trosinenko@… Owned by: Adeel Asghar
Priority: high Milestone: 1.13.0
Component: OMEdit Version: v1.13.0-dev-nightly
Keywords: Cc:

Description

When exported through OMEdit menu, FMU is exported successfully in ME 1.0 mode, but when loaded with FMUChecker, complains about inability to load some JSON resource, and then crashes with Segmentation Fault. Interestingly, when manually specifying FMI version "1.0" instead of "1" (which is issued by OMEdit), FMU works correctly.

How to reproduce

Open OMEdit and select Model Exchange 1.0 FMU format in settings, then compile the following model:
TestFMU.mo

model TestFMU
  output Real x;
equation
  der(x) = x;
end TestFMU;

It is compiled successfully, but when run with FMUChecker 2.0.4, I got the following error:

$ ~/tmp/FMUChecker-2.0.4/build/fmuCheck.linux64 TestFMU.fmu
[INFO][FMUCHK] FMI compliance checker Test [FMILibrary: Test] build date: Sep 14 2018
[INFO][FMUCHK] Called with following options:
[INFO][FMUCHK] /home/work/tmp/FMUChecker-2.0.4/build/fmuCheck.linux64 TestFMU.fmu
[INFO][FMUCHK] Will process FMU TestFMU.fmu
[INFO][FMILIB] XML specifies FMI standard version 1.0
[INFO][FMUCHK] Model name: TestFMU
[INFO][FMUCHK] Model identifier: TestFMU
[INFO][FMUCHK] Model GUID: {2bbc49eb-1f4d-472a-a0b7-863d017f7c5e}
[INFO][FMUCHK] Model version: 
[INFO][FMUCHK] FMU kind: ModelExchange
[INFO][FMUCHK] The FMU contains:
0 constants
0 parameters
0 discrete variables
2 continuous variables
0 inputs
1 outputs
1 internal variables
0 variables with causality 'none'
2 real variables
0 integer variables
0 enumeration variables
0 boolean variables
0 string variables

[INFO][FMUCHK] Printing output file header
"time","x"
[INFO][FMILIB] Loading 'linux64' binary with 'standard32' platform types
[INFO][FMUCHK] Version returned from FMU:   1.0
assert            | debug   | Failed to open file (null)/TestFMU_info.json for reading: No such file or directory
Segmentation fault

When instead of

buildModelFMU(TestFMU,"1","me","<default>",{"static"},true)

issued by OMEdit, according to its OMC console, I use

buildModelFMU(TestFMU,"1.0","me","<default>",{"static"},true)

(which looks more in accordance with the buildModelFMU documentation), it initializes well:

$ ~/tmp/FMUChecker-2.0.4/build/fmuCheck.linux64 TestFMU.fmu
[INFO][FMUCHK] FMI compliance checker Test [FMILibrary: Test] build date: Sep 14 2018
[INFO][FMUCHK] Called with following options:
[INFO][FMUCHK] /home/work/tmp/FMUChecker-2.0.4/build/fmuCheck.linux64 TestFMU.fmu
[INFO][FMUCHK] Will process FMU TestFMU.fmu
[INFO][FMILIB] XML specifies FMI standard version 1.0
[INFO][FMUCHK] Model name: TestFMU
[INFO][FMUCHK] Model identifier: TestFMU
[INFO][FMUCHK] Model GUID: {d9f4657f-5c5b-4351-8f2f-b7083da52709}
[INFO][FMUCHK] Model version: 
[INFO][FMUCHK] FMU kind: ModelExchange
[INFO][FMUCHK] The FMU contains:
0 constants
0 parameters
0 discrete variables
2 continuous variables
0 inputs
1 outputs
1 internal variables
0 variables with causality 'none'
2 real variables
0 integer variables
0 enumeration variables
0 boolean variables
0 string variables

[INFO][FMUCHK] Printing output file header
"time","x"
[INFO][FMILIB] Loading 'linux64' binary with 'standard32' platform types
[INFO][FMUCHK] Version returned from FMU:   1.0
[INFO][FMUCHK] Checking that FMI set functions can be called with zero length arrays
[INFO][FMUCHK] Initialized FMU for simulation starting at time 0
[INFO][FMUCHK] Checking that FMI get functions can be called with zero length arrays
0.0000000000000000E+00,0.0000000000000000E+00
...
1.0000000000000000E+00,0.0000000000000000E+00
[INFO][FMUCHK] Simulation finished successfully at time 1
FMU check summary:
FMU reported:
        0 warning(s) and error(s)
Checker reported:
        0 Warning(s)
        0 Error(s)

How to fix

This probably uncovers some strange backend behavior, but as a quick fix, this should be as simple as using "1.0" instead of "1" for the FMU version argument in OMEdit.

This was tested on a fresh nightly build on Ubuntu 18.04 64 bit.

Change History (5)

comment:1 by Adeel Asghar, 6 years ago

Milestone: Future1.13.0
Resolution: fixed
Status: newclosed

Fixed in 1f1ae5/OMEdit.

comment:2 by anatoly.trosinenko@…, 6 years ago

Maybe it's worth to investigate why the backend accepts "1" as FMI version, but generates non-working FMUs, too. But it is another story. :)

comment:3 by Adeel Asghar, 6 years ago

Because it is just allowed :). Maybe it is a good idea to fix that as well.
https://github.com/OpenModelica/OMCompiler/blob/master/Compiler/Util/FMI.mo#L228

comment:4 by Adeel Asghar, 6 years ago

Fixed it even in the Compiler 7fd4fbc/OMCompiler.

comment:5 by adrpo@…, 6 years ago

Thank you!

Note: See TracTickets for help on using tickets.