I am willing to interface an FMU (Functional Mockup Unit) to my Fortran code (IVF 12). The valid path i see would be to create wrappers for each of the C functions (using the C binding) and call from the main Fortran Subroutine.
The FMU in this case represent a time domain simulation model containing continuous and discrete states and projected for Model Exchange (FMI 2.0). This means that the FMU doesn't have the solver inherently and the solver would be written in the Fortran interface.
This is why the Fortran wrappers are needed to load, instantiate/initialize get and set sates/derivatives and advance time
Does anyone have experience with integrating/ FMUs within Fortran programs ?
FMI --> Functional Mockup Interface
Hey Khaled, i just started with a project which seems to have a problem similar to your integration task - just the other way round. The simulation tool i intent to integrate into a simulation environment is written in fortran.
Have you been able to work out the things you described? Did you come across information about Fortran FMI Wrappers during your research? I would be greatful if you share your experience with me in this case.
Thanks for your post.
The FMI generated code need to be wrapped, i.e. initialize model, get/set states and variables, advance time step, etc...
This could be done:
- In C/C++, then the main C/C++ function including all this sequence can be called from Fortran
- In Fortran, where each of the above functions (i.e. set/get states, etc..) needs to be interfaced to a Fortran subroutine, then those Fortran subroutines are glued to make the sequence required.
There are already python (PyFMI) and Java wrapper
I was seeking experience around which of the two options is most valid/feasible.
So far as i am researching, I didn't come across any similar work done in Fortran.
Since this is not the core of my work (which is more the power system simulation) cooperation maybe an interesting option
Any feedback is very welcome.