Next: String Arguments from Fortran
Up: Calls to different language
Previous: Calls to different language
Contents
Calling C Routines from Fortran
To make the following C routine,
int <routine name>(<argument list>)
...
also callable from Fortran, a new routine must be added, which is
declared using the CCTK_FCALL and CCTK_FNAME macros:
void CCTK_FCALL CCTK_FNAME(<routine name>)(int *ierr, <argument list>)
<rewrite routine code, or call C routine itself>
The convention used in Cactus, is that <routine name> be the same as any
C routine name, and that this is mixed-case. The macros change
the case and number of underscores of the routine name to match that expected
by Fortran.
All arguments passed by Fortran to the routine (except strings) are
pointers in C, e.g. a call from Fortran
CCTK_INT arg1
CCTK_REAL arg2
CCTK_REAL arg3(30,30,30)
...
call MyCRoutine(arg1,arg2,arg3)
should appear in C as
void CCTK_FCALL CCTK_FNAME(MyCRoutine)(CCTK_INT *arg1,
CCTK_REAL *arg2,
CCTK_REAL *arg3)
{
...
}
|