PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
FORTRAN interface

The FORTRAN interface is based on the ISO_C_BINDING feature, which is available for FORTRAN 2003 or later. The usage of FORTRAN interface is very similar to the C interface as given in the Tutorial section.

In FORTRAN, the PPEXSIPlan data type is c_intptr_t (or equivalently INTEGER*8). The naming of the subroutines is similar to the C interface as in c_pexsi_interface.h. All FORTRAN interface routines are in f_interface.f90. For instance, the subroutine PPEXSIPlanInitialize (C/C++) corresponds to the subroutine f_ppexsi_plan_initialize (FORTRAN).

Example: Parallel selected inversion for a real symmetric matrix

integer(c_intptr_t) :: plan
type(f_ppexsi_options) :: options
! Initialize PEXSI.
! PPEXSIPlan is a handle communicating with the C++ internal data structure
! Set the outputFileIndex to be the pole index.
! The first processor for each pole outputs information
if( mod( mpirank, nprow * npcol ) .eq. 0 ) then
outputfileindex = mpirank / (nprow * npcol);
else
outputfileindex = -1;
endif
mpi_comm_world,&
nprow,&
npcol,&
outputfileindex,&
info )
! Tuning parameters of PEXSI. The default options is reasonable to
! start, and the parameters in options can be changed.
call f_ppexsi_set_default_options(&
options )
! Load the matrix into the internal data structure
call f_ppexsi_load_real_symmetric_hs_matrix(&
plan,&
options,&
nrows,&
nnz,&
nnzlocal,&
numcollocal,&
colptrlocal,&
rowindlocal,&
hnzvallocal,&
1,&
snzvallocal,&
info )
! Factorize the matrix symbolically
call f_ppexsi_symbolic_factorize_real_symmetric_matrix(&
plan,&
options,&
info)
! Main routine for computing selected elements and save into AinvnzvalLocal
call f_ppexsi_selinv_real_symmetric_matrix(& plan,&
options,&
anzvallocal,&
ainvnzvallocal,&
info)
! Post processing step...
! Release the data saved in the plan
call f_ppexsi_plan_finalize( plan, info )

The examples of the FORTRAN interface can be found under fortran/ directory, including f_driver_pselinv_real.f90, f_driver_pselinv_complex.f90, f_driver_pselinv_real_unsym.f90, f_driver_pselinv_complex_unsym.f90, f_driver_ksdft.f90.