Many numerical software packages are written in Fortran. Very often, we would like to call Fortran subroutines in C programs.
% f77 -c decomp.f
generates an object code named decomp.o containing decomp_, which can be called by a C program. For example, suppose a C program eg.c calls decomp_ and it has been compiled and eg.o has been generated. Then
% gcc -o eg eg.o decomp.o
generates an executable eg.
C Fortran
-------------------------
float real
double real*8
A[0][0] , A[0][1], A[1][0], A[1][1].But Fortran would create:
A[1][1] , A[2][1], A[1][2], A[2][2].Therefore, when we pass the pointer of an array in C to a Fortran routine, we need to transpose the array before and/or after the Fortran routine in order to match the different styles between C and Fortran.
Find out more
1. User
Notes on FORTRAN Programming (UNFP)
2. Binding
C and FORTRAN Source Code
3. The C/FORTRAN
Interface Kit
4. Fortran FAQ