20.1. Introduction
An interface module can be accessed with the use statement, e.g.
use fsundials_core_mod ! this is needed to access core SUNDIALS types, utilities, and data structures
use fcvode_mod ! this is needed to access CVODE functions and types
use fnvector_openmp_mod ! this is needed to access the OpenMP implementation of the N_Vector class
and by linking to the Fortran 2003 library in addition to the C library, e.g.
libsundials_fcore_mod.<so|a>, libsundials_core.<so|a>,
libsundials_fnvecpenmp_mod.<so|a>, libsundials_nvecopenmp.<so|a>,
libsundials_fcvode_mod.<so|a> and libsundials_cvode.<so|a>.
The use statements mirror the #include statements needed when using the
C API.
The Fortran 2003 interfaces leverage the iso_c_binding module and the
bind(C) attribute to closely follow the SUNDIALS C API (modulo language
differences). The SUNDIALS classes, e.g. N_Vector, are interfaced as
Fortran derived types, and function signatures are matched but with an F
prepending the name, e.g. FN_VConst instead of N_VConst() or
FCVodeCreate instead of CVodeCreate. Constants are named exactly as they
are in the C API. Accordingly, using SUNDIALS via the Fortran 2003 interfaces
looks just like using it in C. Some caveats stemming from the language
differences are discussed in §20.3. A
discussion on the topic of equivalent data types in C and Fortran 2003 is
presented in §20.2.
Further information on the Fortran 2003 interfaces specific to the
N_Vector, SUNMatrix, SUNLinearSolver, and
SUNNonlinearSolver classes is given alongside the C documentation. For
details on where the Fortran 2003 module (.mod) files and libraries are
installed see §1.1.
The Fortran 2003 interface modules were generated with SWIG Fortran [90], a fork of SWIG. Users who are interested in the SWIG code used in the generation process should contact the SUNDIALS development team.
Class/Module |
Fortran 2003 Module Name |
|---|---|
SUNDIALS core |
|
ARKODE |
|
ARKODE::ARKSTEP |
|
ARKODE::ERKSTEP |
|
ARKODE::MRISTEP |
|
ARKODE::SPRKSTEP |
|
ARKODE::LSRKSTEP |
|
ARKODE::SPLITTINGSTEP |
|
ARKODE::FORCINGSTEP |
|
CVODE |
|
CVODES |
|
IDA |
|
IDAS |
|
KINSOL |
|
NVECTOR_CUDA |
Not interfaced |
NVECTOR_MANVECTOR |
|
NVECTOR_MPIMANVECTOR |
|
NVECTOR_MPIPLUSX |
|
NVECTOR_OPENMP |
|
NVECTOR_PARALLEL |
|
NVECTOR_PARHYP |
Not interfaced |
NVECTOR_PETSC |
Not interfaced |
NVECTOR_PTHREADS |
|
NVECTOR_RAJA |
Not interfaced |
NVECTOR_SERIAL |
|
NVECTOR_SYCL |
Not interfaced |
SUNADAPTCONTROLLER_IMEXGUS |
|
SUNADAPTCONTROLLER_SODERLIND |
|
SUNADAPTCONTROLLER_MRIHTOL |
|
SUNADJOINTCHECKPOINTSCHEME_FIXED |
|
SUNDOMEIGEST_ARNOLDI |
|
SUNDOMEIGEST_POWER |
|
SUNLINSOL_BAND |
|
SUNLINSOL_DENSE |
|
SUNLINSOL_KLU |
|
SUNLINSOL_LAPACKBAND |
Not interfaced |
SUNLINSOL_LAPACKDENSE |
Not interfaced |
SUNLINSOL_MAGMADENSE |
Not interfaced |
SUNLINSOL_ONEMKLDENSE |
Not interfaced |
SUNLINSOL_PCG |
|
SUNLINSOL_SLUDIST |
Not interfaced |
SUNLINSOL_SLUMT |
Not interfaced |
SUNLINSOL_SPBCGS |
|
SUNLINSOL_SPFGMR |
|
SUNLINSOL_SPGMR |
|
SUNLINSOL_SPTFQMR |
|
SUNMATRIX_BAND |
|
SUNMATRIX_DENSE |
|
SUNMATRIX_MAGMADENSE |
Not interfaced |
SUNMATRIX_ONEMKLDENSE |
Not interfaced |
SUNMATRIX_SPARSE |
|
SUNNONLINSOL_FIXEDPOINT |
|
SUNNONLINSOL_NEWTON |
|
SUNNONLINSOL_PETSCSNES |
Not interfaced |
20.1.1. Installation
The installation procedure for the Fortran interfaces is the same as for the C/C++ core of SUNDIALS, refer
to §1.1. The CMake option to turn on the Fortran interfaces in a SUNDIALS build
is BUILD_FORTRAN_MODULE_INTERFACE. The Spack variant is +fortran.
20.1.2. Important notes on portability
The SUNDIALS Fortran 2003 interface should be compatible with any compiler supporting the Fortran 2003 ISO standard.
Upon compilation of SUNDIALS, Fortran module (.mod) files are generated for
each Fortran 2003 interface. These files are highly compiler specific, and thus
it is almost always necessary to compile a consuming application with the same
compiler that was used to generate the modules.