Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

FORTRAN code interface

FORTRAN code interface

Hello,

I have a small FORTRAN Project which is composed of several source files .FOR. The FORTRAN Project consist of a Main program, which calls several subroutines.
As I tried to call the Main program in Modelica, the following questions appeared:

1. I guess, that all .FOR files should be placed in the working directory i.e. by default in C:\...\AppData\Local\Temp\OpenModelica\OMEdit, is this correct?
2. which file should I actually call in by the external clause in Modelica? .FOR, .exe, or yet another one?
  when I have a model in Modelica:

model ExternalFortranCall
  parameter Real Di = 24.5;
  parameter Real Ws = 6.5;
  Real Da; 
  function MAIN_program
    input Real di;
    input Real ws;
    output Real da;
    external "FORTRAN 77"
  end MAIN_program;
equation
  Da = MAIN_program(Di, Ws);
end ExternalFortranCall;

I put MAIN_program.FOR and MAIN_program.obj into the working directory and I still obtain notice "undefined reference to 'MAIN_program' during compilation of Modelica model.
Could anybody tell why is that? I would appreciate all suggestions.

Thank you.

Re: FORTRAN code interface

You need to create a library to call it, use the Library annotation to choose a name and compile the library as a .lib or .dll file. Make sure the file is mingw-compatible and uses the same integer/etc lengths as OpenModelica expects (as well as calling convention).

There are 0 guests and 0 other users also viewing this topic