Here's a quick tutorial, courtesy of Chris Ullrich,
on calling fortran from C/C++ on HP9000.
For details, refer to the fortran reference manual for
HP9000 series computers.
1) The most important thing to remember is that fortran passes all variables
- except function return values.
- except for arrays, which have the same type of access as in C
2) the C name of a fortran subroutine is the same, with the same
argument list (but all fortran types -> C pointers ).
3) Fortran is case insensitive.
4) Strings are an absolute nightmare, which I won't discuss.
5) multidimensional arrays are stored in reverse order in fortran (row
major) than C (column major) -> do all numerical work in one language OR
the other (otherwise one of them will be really slow).
consider a fortran routine:
subroutine doStuff( k, j, y )
integer k, j
double precision y(10)
C do stuff
Could be called from C, by doing something like
// C - code
dostuff( &k, &j, y );
So to make a program:
1) compile your fortran code into object code (.o file).
f77 -c .f
2) compile your C code, and include the fortran object in the link line.
also include these libs in this order: -lcl -lisamstub -lc
gcc .c -o .o -lcl -lisamstub -lc
3) run your prog.