I have the source file of a big module written in fortran90 with some type definitions, some interfaces, some functions and subroutines. I am able to compile it and to use it inside a normal fortran program.
But since I have always used C/C++ and I don't know so much of fortran I would like to use this module inside a C/C++ program. That is using its data types and calling its functions/subroutines on them.
Is it possible? How can I do this? What are the various steps I have to achieve? Are there some exhaustive tutorials on the web (I didn't find so much with a brief google search..)
The search call fortran from c gave me several links to various tutorials and examples.
Some highlights:
Fortran calls are by reference, so you get to use pointers/the address-of operator a lot.
Fortran routines are usually exported with some simple name mangling. You can either find out by reading the manual or you can use
nm f.o, where f.o is a compiled fortran file.Using the routine names obtained you need to create a C header file with declarations for the routines you want to call.
When linking you need to link with the fortran library,
-l<name of fortran lib>.