| 1 |
Files: |
| 2 |
- this README file |
| 3 |
- a LICENSE statement |
| 4 |
- use_libcerf_mod.f90 : the f95 interface to cerflib |
| 5 |
- cerflib_main_test.f90 : a main program exemplifying the calls to the cerflib functions |
| 6 |
from Fortran95 |
| 7 |
|
| 8 |
Prerequisites: |
| 9 |
- a modern f95 compiler including a f2003-standard ISO_C_BINDING module, |
| 10 |
like e.g. gfortran (4.6 or better) or ifort |
| 11 |
- libcerf installed and in the path where the linker searches for libraries |
| 12 |
(if this is not so, you have to give the path in the command line when compiling, |
| 13 |
preceded by -L, as usual) |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
Compiling: |
| 19 |
- Put the two .f90 files in the same folder, then on the console give the following commands |
| 20 |
(example with gfortran as compiler): |
| 21 |
|
| 22 |
gfortran -c use_libcerf_mod.f90 |
| 23 |
gfortran -o cerflib_main_test cerflib_main_test.f90 use_libcerf_mod.o -lcerf |
| 24 |
|
| 25 |
You may add compiler options (e.g. -O2, -fbounds-check, ...) as you see fit. |
| 26 |
|
| 27 |
Coding: |
| 28 |
The use_libcerf_mod.f90 file contains a module |
| 29 |
|
| 30 |
MODULE use_libcerf |
| 31 |
|
| 32 |
that interfaces Fortran95 code to the libcerf library. |
| 33 |
To call the cerflib functions, you need to use the module, that is, in your scoping unit |
| 34 |
there must be the code line |
| 35 |
|
| 36 |
use use_libcerf |
| 37 |
|
| 38 |
Fortran function names are like in the libcerf |
| 39 |
(see http://apps.jcns.fz-juelich.de/libcerf), |
| 40 |
with a _F at the end; |
| 41 |
e.g. erfcx of libcerf becomes erfcx_F in the Fortran95 version. |
| 42 |
Arguments are the same, see code for details. |
| 43 |
Arguments and results are the equivalent Fortran types to the C types of libcerf |
| 44 |
(double precision real / 8-byte real) for C double, |
| 45 |
double precision complex / 16-byte complex for C double complex). |
| 46 |
Fortran types are matched to those of your compiler/machine in use_libcerf_mod.f90; |
| 47 |
arguments are then converted to C types if needed, C-type results are back-converted |
| 48 |
into Fortran types. |
| 49 |
You may (must not, however) declare your variables using the autodetect types |
| 50 |
as defined in use_libcerf_mod.f90, that is, |
| 51 |
REAL(DP) for double precision real |
| 52 |
COMPLEX(DPC) for double precision complex |