Fortran binding in C
Part A - Using .f / .f90 directly
1. Compile the .f / .f90 files to .o object file using;
FC -c -O filename.f
This generates the filename.o object file and can be used to as a C function routine with little additional effort.2. Define the function before your main() call and pass by reference the pointers and data as suitable. For more explanation see;
http://www.math.utah.edu/software/c-with-fortran.html
http://www.physics.utah.edu/~detar/phys6720/handouts/fortran_binding.html
Part B - Convert your .f / .f90 to .c files using f2c converter
Perhaps a more easy way (if you know what you are doing !)
1. Convert the simple .f / .f90 routines to C using f2c [ http://netlib.org/f2c/ ]
2. Include the f2c library and include file while converting.
Always check for the consistency of the output after the compile & run parts of the code.
0 comments:
Post a Comment