Fortran SFF API to data I/O streams in C++
|
In the case of this library Fortran programs will call C++ functions. A simple example is given here.
The C++ header file cxxfunc.h
contains:
The corresponding definition of the function is provided in cxxfunc.cc:
The Fortran interface function is declared in cxxiface.h:
The body of the function is defined in cxxiface.cc:
In the Fortran main program fprog.f
this function is called:
Compiling the library:
P> g++ -c -o cxxfunc.o cxxfunc.cc P> g++ -c -o cxxiface.o cxxiface.cc P> ar rc libiface.a cxxfunc.o cxxiface.o P> gfortran -ff2c -Wall -c -o fprog.o fprog.f P> gfortran -o fprog fprog.o -liface lstdc++
Calling fprog
will produce the output:
P> fprog 17.000000