When you want to write C/C++ programs which call Fortran routines, you must then define the Fortran routines in the C/C++ code.
SUBROUTINE EVENT(KFL,ECM)
has to be declared as:
C++:
extern "C"
{
extern void event_(int*, float*);
}
C:
extern void event_(int*, float*);
and called as (in both C and C++):
int kflavour = 0; float energy = 90.0; event_(&kflavour, &energy);
CALL HBOOKN(ID,CHTITL,NVAR,CHRPZPA,NWBUFF,TAGS)
has to be declared as:
C++:
extern "C"
{
extern void hbookn_(const int*, const char*, int*, const char*,
int*, const char*, int, int, int);
}
C:
extern void hbookn_(const int*, const char*, int*, const char*,
int*, const char*, int, int, int);
where the last three int arguments are the lengths of the three character string arguments. Note that they have to be passed by value and not by address.
This will only take us through the compilation phase. When linking the C/C++ programs the Fortran run-time libraries has to be specified. The run-time libraries are compiler dependent, so you need some information from your local guru, or you will have to search around in your file system. An example is given here.
However, you can be lucky, your favourite linker might have an option which includes the proper runtime libraries. An example of this is the Silicon Graphics C++ compiler environment; using the CC command to link your objects, you can supply the option -lftn to the linker and it will use the appropriate Fortran run-time libraries.
This page was created June 24, 1996
Latest change was made on June 20, 2007.
mail to:
webmaster@chiralcomp.com
©1996-2007 Chiral Data HB All Rights Reserved