19   USE iso_c_binding,                   
ONLY: c_intptr_t
 
   38#include "./base/base_uses.f90" 
   44   CHARACTER(len=*), 
PARAMETER, 
PRIVATE :: moduleN = 
'pexsi_types' 
   46   LOGICAL, 
PARAMETER, 
PRIVATE          :: careful_mod = .false.
 
   90      TYPE(dbcsr_csr_type)                     :: csr_mat_p = dbcsr_csr_type(), csr_mat_ks = dbcsr_csr_type(), &
 
   91                                                  csr_mat_s = dbcsr_csr_type(), csr_mat_e = dbcsr_csr_type(), &
 
   92                                                  csr_mat_f = dbcsr_csr_type()
 
   98      REAL(kind=
dp), 
DIMENSION(:), 
POINTER     :: kts => null()
 
  100         POINTER                               :: matrix_w => null()
 
 
  101      INTEGER(KIND=C_INTPTR_T)                 :: plan = 0_c_intptr_t
 
  102      INTEGER                                  :: nspin = -1, num_ranks_per_pole = -1
 
  105         POINTER                               :: max_ev_vector => null()
 
 
  107      INTEGER, 
DIMENSION(2)                    :: mp_dims = -1
 
  109      LOGICAL                                  :: csr_screening = .false., do_adaptive_tol_nel = .false.
 
  110      REAL(kind=
dp)                            :: adaptive_nel_alpha = -1.0_dp, adaptive_nel_beta = -1.0_dp, &
 
  111                                                  tol_nel_initial = -1.0_dp, tol_nel_target = -1.0_dp
 
 
 
  129      INTEGER, 
INTENT(IN)                                :: nspin
 
  131      CHARACTER(len=*), 
PARAMETER                        :: routinen = 
'lib_pexsi_init' 
  133      INTEGER                                            :: handle, ispin, npsymbfact, &
 
  138      IF (logger%para_env%is_source()) 
THEN 
  144      CALL timeset(routinen, handle)
 
  149      pexsi_env%mp_group = mp_group
 
  150      associate(numnodes => pexsi_env%mp_group%num_pe, mynode => pexsi_env%mp_group%mepos)
 
  154         IF ((pexsi_env%num_ranks_per_pole .GT. numnodes) &
 
  155             .OR. (pexsi_env%num_ranks_per_pole .EQ. 0)) 
THEN 
  156            pexsi_env%num_ranks_per_pole = numnodes
 
  162         DO WHILE (mod(numnodes, pexsi_env%num_ranks_per_pole) .NE. 0)
 
  163            pexsi_env%num_ranks_per_pole = pexsi_env%num_ranks_per_pole + 1
 
  167         IF ((npsymbfact .GT. pexsi_env%num_ranks_per_pole) .OR. (npsymbfact .EQ. 0)) 
THEN 
  173         pexsi_env%mp_dims = 0
 
  174         CALL mp_dims_create(pexsi_env%num_ranks_per_pole, pexsi_env%mp_dims)
 
  177         pexsi_env%nspin = nspin
 
  178         ALLOCATE (pexsi_env%kTS(nspin))
 
  179         pexsi_env%kTS(:) = 0.0_dp
 
  180         ALLOCATE (pexsi_env%max_ev_vector(nspin))
 
  181         ALLOCATE (pexsi_env%matrix_w(nspin))
 
  182         DO ispin = 1, pexsi_env%nspin
 
  183            ALLOCATE (pexsi_env%matrix_w(ispin)%matrix)
 
  188                                                   pexsi_env%mp_dims(2), mynode)
 
  191      pexsi_env%do_adaptive_tol_nel = .false.
 
  194      IF (unit_nr > 0) 
CALL print_pexsi_info(pexsi_env, unit_nr)
 
  196      CALL timestop(handle)
 
 
  209      CHARACTER(len=*), 
PARAMETER :: routinen = 
'lib_pexsi_finalize' 
  211      INTEGER                                            :: handle, ispin
 
  213      CALL timeset(routinen, handle)
 
  214      CALL cp_pexsi_plan_finalize(pexsi_env%plan)
 
  215      DEALLOCATE (pexsi_env%kTS)
 
  216      DEALLOCATE (pexsi_env%max_ev_vector)
 
  217      DO ispin = 1, pexsi_env%nspin
 
  218         DEALLOCATE (pexsi_env%matrix_w(ispin)%matrix)
 
  220      DEALLOCATE (pexsi_env%matrix_w)
 
  221      CALL timestop(handle)
 
 
  238      INTEGER, 
INTENT(IN)                                :: direction
 
  239      REAL(kind=dp), 
INTENT(INOUT), 
OPTIONAL             :: numelectron
 
  240      TYPE(dbcsr_type), 
INTENT(INOUT), 
OPTIONAL          :: matrix_p
 
  241      TYPE(dbcsr_p_type), 
INTENT(INOUT), 
OPTIONAL        :: matrix_w
 
  242      REAL(kind=dp), 
INTENT(INOUT), 
OPTIONAL             :: kts
 
  244      CHARACTER(len=*), 
PARAMETER :: routinen = 
'convert_nspin_cp2k_pexsi' 
  247      REAL(kind=dp)                                      :: scaling
 
  249      CALL timeset(routinen, handle)
 
  251      SELECT CASE (direction)
 
  258      IF (
PRESENT(numelectron)) numelectron = scaling*numelectron
 
  259      IF (
PRESENT(matrix_p)) 
CALL dbcsr_scale(matrix_p, scaling)
 
  260      IF (
PRESENT(matrix_w)) 
CALL dbcsr_scale(matrix_w%matrix, scaling)
 
  261      IF (
PRESENT(kts)) kts = scaling*kts
 
  263      CALL timestop(handle)
 
 
  271   SUBROUTINE print_pexsi_info(pexsi_env, unit_nr)
 
  273      INTEGER, 
INTENT(IN)                                :: unit_nr
 
  275      INTEGER                                            :: npsymbfact, numnodes, numpole, ordering, &
 
  277      REAL(kind=dp)                                      :: gap, muinertiaexpansion, &
 
  278                                                            muinertiatolerance, mumax0, mumin0, &
 
  279                                                            mupexsisafeguard, temperature
 
  281      numnodes = pexsi_env%mp_group%num_pe
 
  283      CALL cp_pexsi_get_options(pexsi_env%options, temperature=temperature, gap=gap, &
 
  284                                numpole=numpole, mumin0=mumin0, mumax0=mumax0, muinertiatolerance= &
 
  285                                muinertiatolerance, muinertiaexpansion=muinertiaexpansion, &
 
  286                                mupexsisafeguard=mupexsisafeguard, ordering=ordering, rowordering=rowordering, &
 
  287                                npsymbfact=npsymbfact)
 
  289      WRITE (unit_nr, 
'(/A)') 
" PEXSI| Initialized with parameters" 
  290      WRITE (unit_nr, 
'(A,T61,E20.3)') 
" PEXSI|   Electronic temperature", temperature
 
  291      WRITE (unit_nr, 
'(A,T61,E20.3)') 
" PEXSI|   Spectral gap", gap
 
  292      WRITE (unit_nr, 
'(A,T61,I20)') 
" PEXSI|   Number of poles", numpole
 
  293      WRITE (unit_nr, 
'(A,T61,E20.3)') 
" PEXSI|   Target tolerance in number of electrons", &
 
  294         pexsi_env%tol_nel_target
 
  295      WRITE (unit_nr, 
'(A,T61,E20.3)') 
" PEXSI|   Convergence tolerance for inertia counting in mu", &
 
  297      WRITE (unit_nr, 
'(A,T61,E20.3)') 
" PEXSI|   Restart tolerance for inertia counting in mu", &
 
  299      WRITE (unit_nr, 
'(A,T61,E20.3)') 
" PEXSI|   Expansion of mu interval for inertia counting", &
 
  302      WRITE (unit_nr, 
'(/A)') 
" PEXSI| Parallelization scheme" 
  303      WRITE (unit_nr, 
'(A,T61,I20)') 
" PEXSI|   Number of poles processed in parallel", &
 
  304         numnodes/pexsi_env%num_ranks_per_pole
 
  305      WRITE (unit_nr, 
'(A,T61,I20)') 
" PEXSI|   Number of processors per pole", &
 
  306         pexsi_env%num_ranks_per_pole
 
  307      WRITE (unit_nr, 
'(A,T71,I5,T76,I5)') 
" PEXSI|   Process grid dimensions", &
 
  308         pexsi_env%mp_dims(1), pexsi_env%mp_dims(2)
 
  309      SELECT CASE (ordering)
 
  311         WRITE (unit_nr, 
'(A,T61,A20)') 
" PEXSI|   Ordering strategy", 
"parallel" 
  313         WRITE (unit_nr, 
'(A,T61,A20)') 
" PEXSI|   Ordering strategy", 
"sequential" 
  315         WRITE (unit_nr, 
'(A,T61,A20)') 
" PEXSI|   Ordering strategy", 
"multiple minimum degree" 
  317      SELECT CASE (rowordering)
 
  319         WRITE (unit_nr, 
'(A,T61,A20)') 
" PEXSI|   Row permutation strategy", 
"no row permutation" 
  321         WRITE (unit_nr, 
'(A,T61,A20)') 
" PEXSI|   Row permutation strategy", 
"make diagonal entry larger than off diagonal" 
  323      IF (ordering .EQ. 0) 
WRITE (unit_nr, 
'(A,T61,I20/)') &
 
  324         " PEXSI|   Number of processors for symbolic factorization", npsymbfact
 
  326   END SUBROUTINE print_pexsi_info
 
collects all references to literature in CP2K as new algorithms / method are included from literature...
 
integer, save, public lin2009
 
integer, save, public lin2013
 
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
 
various routines to log and control the output. The idea is that decisions about where to log should ...
 
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
 
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
 
Defines the basic variable types.
 
integer, parameter, public dp
 
Interface to the message passing library MPI.
 
subroutine, public mp_dims_create(nodes, dims)
wrapper to MPI_Dims_create
 
Interface to the PEXSI library, providing wrappers for all PEXSI routines that are called inside CP2K...
 
subroutine, public cp_pexsi_set_options(pexsi_options, temperature, gap, deltae, numpole, isinertiacount, maxpexsiiter, mumin0, mumax0, mu0, muinertiatolerance, muinertiaexpansion, mupexsisafeguard, numelectronpexsitolerance, matrixtype, issymbolicfactorize, ordering, rowordering, npsymbfact, verbosity)
Set PEXSI internal options.
 
subroutine, public cp_pexsi_get_options(pexsi_options, temperature, gap, deltae, numpole, isinertiacount, maxpexsiiter, mumin0, mumax0, mu0, muinertiatolerance, muinertiaexpansion, mupexsisafeguard, numelectronpexsitolerance, matrixtype, issymbolicfactorize, ordering, rowordering, npsymbfact, verbosity)
Access PEXSI internal options.
 
subroutine, public cp_pexsi_plan_finalize(plan)
...
 
integer(kind=c_intptr_t) function, public cp_pexsi_plan_initialize(comm, numprocrow, numproccol, outputfileindex)
...
 
Environment storing all data that is needed in order to call the DFT driver of the PEXSI library with...
 
subroutine, public convert_nspin_cp2k_pexsi(direction, numelectron, matrix_p, matrix_w, kts)
Scale various quantities with factors of 2. This converts spin restricted DFT calculations (PEXSI) to...
 
integer, parameter, public cp2k_to_pexsi
 
subroutine, public lib_pexsi_init(pexsi_env, mp_group, nspin)
Initialize PEXSI.
 
integer, parameter, public pexsi_to_cp2k
 
subroutine, public lib_pexsi_finalize(pexsi_env)
Release all PEXSI data.
 
type of a logger, at the moment it contains just a print level starting at which level it should be l...