LCOV - code coverage report
Current view: top level - src - kpoint_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:d1f8d1b) Lines: 244 271 90.0 %
Date: 2024-11-29 06:42:44 Functions: 11 17 64.7 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief Types and basic routines needed for a kpoint calculation
      10             : !> \par History
      11             : !>       2014.07 created [JGH]
      12             : !>       2014.11 unified k-point and gamma-point code [Ole Schuett]
      13             : !> \author JGH
      14             : ! **************************************************************************************************
      15             : MODULE kpoint_types
      16             :    USE cp_blacs_env,                    ONLY: cp_blacs_env_release,&
      17             :                                               cp_blacs_env_type
      18             :    USE cp_fm_types,                     ONLY: cp_fm_release,&
      19             :                                               cp_fm_type
      20             :    USE cp_log_handling,                 ONLY: cp_get_default_logger,&
      21             :                                               cp_logger_type
      22             :    USE cp_output_handling,              ONLY: cp_print_key_finished_output,&
      23             :                                               cp_print_key_unit_nr
      24             :    USE input_cp2k_kpoints,              ONLY: use_complex_wfn,&
      25             :                                               use_real_wfn
      26             :    USE input_section_types,             ONLY: section_vals_get,&
      27             :                                               section_vals_type,&
      28             :                                               section_vals_val_get
      29             :    USE kinds,                           ONLY: default_string_length,&
      30             :                                               dp
      31             :    USE mathconstants,                   ONLY: twopi
      32             :    USE message_passing,                 ONLY: mp_para_env_release,&
      33             :                                               mp_para_env_type
      34             :    USE physcon,                         ONLY: angstrom
      35             :    USE qs_diis_types,                   ONLY: qs_diis_b_release_kp,&
      36             :                                               qs_diis_buffer_type_kp
      37             :    USE qs_matrix_pools,                 ONLY: mpools_release,&
      38             :                                               qs_matrix_pools_type
      39             :    USE qs_mo_types,                     ONLY: deallocate_mo_set,&
      40             :                                               mo_set_type
      41             :    USE qs_neighbor_list_types,          ONLY: neighbor_list_set_p_type
      42             :    USE string_utilities,                ONLY: uppercase
      43             : #include "./base/base_uses.f90"
      44             : 
      45             :    IMPLICIT NONE
      46             : 
      47             :    PRIVATE
      48             : 
      49             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'kpoint_types'
      50             : 
      51             :    PUBLIC :: kpoint_type
      52             :    PUBLIC :: kpoint_create, kpoint_release, get_kpoint_info, set_kpoint_info
      53             :    PUBLIC :: read_kpoint_section, write_kpoint_info
      54             :    PUBLIC :: kpoint_env_type, kpoint_env_p_type
      55             :    PUBLIC :: kpoint_env_create, get_kpoint_env
      56             :    PUBLIC :: kind_rotmat_type
      57             :    PUBLIC :: kpoint_sym_type
      58             :    PUBLIC :: kpoint_sym_create
      59             : 
      60             : ! **************************************************************************************************
      61             : !> \brief Keeps information about a specific k-point
      62             : !> \param nkpoint   the kpoint index
      63             : !> \param wkp       weight of this kpoint
      64             : !> \param xkp       kpoint coordinates in units of b-vector
      65             : !> \param is_local  if this kpoint is calculated on a single thread
      66             : !> \param mos       associated MOs (r/i,spin)
      67             : !> \param pmat      associated density matrix (r/i,spin)
      68             : !> \param wmat      associated energy weighted density matrix (r/i,spin)
      69             : !> \param smat      associated overlap matrix (for ADMM) (r/i,spin)
      70             : !> \param amat      associated ADMM basis projection matrix (r/i,spin)
      71             : !> \author JGH
      72             : ! **************************************************************************************************
      73             :    TYPE kpoint_env_type
      74             :       INTEGER                                           :: nkpoint = -1
      75             :       REAL(KIND=dp)                                     :: wkp = 0.0_dp
      76             :       REAL(KIND=dp), DIMENSION(3)                       :: xkp = 0.0_dp
      77             :       LOGICAL                                           :: is_local = .FALSE.
      78             :       TYPE(mo_set_type), DIMENSION(:, :), POINTER     :: mos => NULL()
      79             :       TYPE(cp_fm_type), DIMENSION(:, :), POINTER      :: pmat => NULL()
      80             :       TYPE(cp_fm_type), DIMENSION(:, :), POINTER      :: wmat => NULL()
      81             :       TYPE(cp_fm_type), DIMENSION(:, :), POINTER      :: smat => NULL()
      82             :       TYPE(cp_fm_type), DIMENSION(:, :), POINTER      :: amat => NULL()
      83             :    END TYPE kpoint_env_type
      84             : 
      85             :    TYPE kpoint_env_p_type
      86             :       TYPE(kpoint_env_type), POINTER                    :: kpoint_env => NULL()
      87             :    END TYPE kpoint_env_p_type
      88             : 
      89             : ! **************************************************************************************************
      90             : !> \brief Rotation matrices for basis sets
      91             : !> \param rmat      atom basis function rotation matrix
      92             : !> \author JGH
      93             : ! **************************************************************************************************
      94             :    TYPE kind_rotmat_type
      95             :       REAL(KIND=dp), DIMENSION(:, :), POINTER           :: rmat => NULL()
      96             :    END TYPE kind_rotmat_type
      97             : 
      98             : ! **************************************************************************************************
      99             : !> \brief Keeps symmetry information about a specific k-point
     100             : !> \param apply_symmetry ...
     101             : !> \param nwght     kpoint multiplicity
     102             : !> \param xkp       kpoint coordinates
     103             : !> \param rot       rotation matrices
     104             : !> \param f0        atom permutation
     105             : !> \author JGH
     106             : ! **************************************************************************************************
     107             :    TYPE kpoint_sym_type
     108             :       LOGICAL                                           :: apply_symmetry = .FALSE.
     109             :       INTEGER                                           :: nwght = -1
     110             :       INTEGER                                           :: nwred = -1
     111             :       REAL(KIND=dp), DIMENSION(:, :), POINTER           :: xkp => NULL()
     112             :       REAL(KIND=dp), DIMENSION(:, :, :), POINTER        :: rot => NULL()
     113             :       INTEGER, DIMENSION(:), POINTER                    :: rotp => NULL()
     114             :       INTEGER, DIMENSION(:, :), POINTER                 :: f0 => NULL()
     115             :    END TYPE kpoint_sym_type
     116             : 
     117             :    TYPE kpoint_sym_p_type
     118             :       TYPE(kpoint_sym_type), POINTER                    :: kpoint_sym => NULL()
     119             :    END TYPE kpoint_sym_p_type
     120             : 
     121             : ! **************************************************************************************************
     122             : !> \brief Contains information about kpoints
     123             : !> \par History
     124             : !>       2014.07 created [JGH]
     125             : !> \param kp_scheme           [input] Type of kpoint grid
     126             : !> \param nkp_grid            [input] Grid points
     127             : !> \param kp_shift            [input] Shift of the grid
     128             : !> \param use_real_wfn        [input] real/complex wfn
     129             : !> \param symmetry            [input] use symmetry (atoms) to reduce kpoints
     130             : !> \param full_grid           [input] don't reduce kpoints at all
     131             : !> \param verbose             [input] more output information
     132             : !> \param eps_geo             [input] accuracy of atom symmetry detection
     133             : !> \param parallel_group_size [input] kpoint group size
     134             : !> \param nkp     number of kpoints
     135             : !> \param xkp     kpoint coordinates
     136             : !> \param wkp     kpoint weights
     137             : !> \param para_env 'global' parallel environment
     138             : !> \param para_env_kp parallel environment of the kpoint calculation
     139             : !> \param para_env_inter_kp parallel environment between kpoints
     140             : !> \param iogrp  this kpoint group has the IO processor
     141             : !> \param nkp_groups   number of kpoint groups
     142             : !> \param kp_dist      kpoints distribution on groups
     143             : !> \param kp_range     kpoints distribution for local processor
     144             : !> \param blacs_env    BLACS env for the kpoint group
     145             : !> \param opmats       Operator matrices
     146             : !> \param kp_env       Information for each kpoint
     147             : !> \param mpools       FM matrix pools for kpoint groups
     148             : !> \author JGH
     149             : ! **************************************************************************************************
     150             :    TYPE kpoint_type
     151             :       CHARACTER(LEN=default_string_length)    :: kp_scheme = ""
     152             :       INTEGER, DIMENSION(3)                   :: nkp_grid = -1
     153             :       REAL(KIND=dp), DIMENSION(3)             :: kp_shift = 0.0_dp
     154             :       LOGICAL                                 :: use_real_wfn = .FALSE.
     155             :       LOGICAL                                 :: symmetry = .FALSE.
     156             :       LOGICAL                                 :: full_grid = .FALSE.
     157             :       LOGICAL                                 :: verbose = .FALSE.
     158             :       REAL(KIND=dp)                           :: eps_geo = 0.0_dp
     159             :       INTEGER                                 :: parallel_group_size = -1
     160             :       INTEGER                                 :: nkp = -1
     161             :       REAL(KIND=dp), DIMENSION(:, :), POINTER :: xkp => Null()
     162             :       REAL(KIND=dp), DIMENSION(:), POINTER    :: wkp => Null()
     163             :       ! parallel environment
     164             :       TYPE(mp_para_env_type), POINTER         :: para_env => Null()
     165             :       TYPE(cp_blacs_env_type), POINTER        :: blacs_env_all => Null()
     166             :       TYPE(mp_para_env_type), POINTER         :: para_env_kp => Null(), &
     167             :                                                  para_env_inter_kp => Null()
     168             :       LOGICAL                                 :: iogrp = .FALSE.
     169             :       INTEGER                                 :: nkp_groups = -1
     170             :       INTEGER, DIMENSION(:, :), POINTER       :: kp_dist => Null()
     171             :       INTEGER, DIMENSION(2)                   :: kp_range = -1
     172             :       TYPE(cp_blacs_env_type), POINTER        :: blacs_env => Null()
     173             :       INTEGER, DIMENSION(:, :, :), POINTER    :: cell_to_index => Null()
     174             :       INTEGER, DIMENSION(:, :), POINTER       :: index_to_cell => Null()
     175             :       TYPE(neighbor_list_set_p_type), &
     176             :          DIMENSION(:), POINTER                :: sab_nl => Null(), &
     177             :                                                  sab_nl_nosym => Null()
     178             :       ! environment
     179             :       TYPE(kpoint_env_p_type), DIMENSION(:), &
     180             :          POINTER                              :: kp_env => Null()
     181             :       TYPE(kpoint_env_p_type), DIMENSION(:), &
     182             :          POINTER                              :: kp_aux_env => Null()
     183             :       ! symmetry
     184             :       TYPE(kpoint_sym_p_type), DIMENSION(:), &
     185             :          POINTER                              :: kp_sym => Null()
     186             :       INTEGER, DIMENSION(:), POINTER          :: atype => Null()
     187             :       INTEGER, DIMENSION(:), POINTER          :: ibrot => Null()
     188             :       TYPE(kind_rotmat_type), DIMENSION(:, :), &
     189             :          POINTER                              :: kind_rotmat => Null()
     190             :       ! pools
     191             :       TYPE(qs_matrix_pools_type), POINTER     :: mpools => Null()
     192             :       TYPE(qs_diis_buffer_type_kp), POINTER   :: scf_diis_buffer => Null()
     193             :       TYPE(qs_matrix_pools_type), POINTER     :: mpools_aux_fit => Null()
     194             :    END TYPE kpoint_type
     195             : 
     196             : ! **************************************************************************************************
     197             : 
     198             : CONTAINS
     199             : 
     200             : ! **************************************************************************************************
     201             : !> \brief Create a kpoint environment
     202             : !> \param kpoint  All the kpoint information
     203             : !> \author JGH
     204             : ! **************************************************************************************************
     205        6834 :    SUBROUTINE kpoint_create(kpoint)
     206             :       TYPE(kpoint_type), POINTER                         :: kpoint
     207             : 
     208        6834 :       CPASSERT(.NOT. ASSOCIATED(kpoint))
     209             : 
     210       75174 :       ALLOCATE (kpoint)
     211             : 
     212        6834 :       kpoint%kp_scheme = ""
     213       27336 :       kpoint%nkp_grid = 0
     214       27336 :       kpoint%kp_shift = 0.0_dp
     215        6834 :       kpoint%symmetry = .FALSE.
     216        6834 :       kpoint%verbose = .FALSE.
     217        6834 :       kpoint%full_grid = .FALSE.
     218        6834 :       kpoint%use_real_wfn = .FALSE.
     219        6834 :       kpoint%eps_geo = 1.0e-6_dp
     220        6834 :       kpoint%parallel_group_size = -1
     221             : 
     222        6834 :       kpoint%nkp = 0
     223             : 
     224        6834 :       NULLIFY (kpoint%xkp, kpoint%wkp)
     225        6834 :       NULLIFY (kpoint%kp_dist)
     226             : 
     227        6834 :       NULLIFY (kpoint%para_env)
     228        6834 :       NULLIFY (kpoint%blacs_env_all)
     229        6834 :       NULLIFY (kpoint%para_env_kp, kpoint%para_env_inter_kp)
     230        6834 :       NULLIFY (kpoint%blacs_env)
     231        6834 :       kpoint%nkp_groups = 0
     232        6834 :       kpoint%iogrp = .FALSE.
     233       20502 :       kpoint%kp_range = 0
     234             : 
     235        6834 :       NULLIFY (kpoint%kp_env)
     236        6834 :       NULLIFY (kpoint%mpools)
     237             : 
     238        6834 :       ALLOCATE (kpoint%cell_to_index(0:0, 0:0, 0:0))
     239       27336 :       kpoint%cell_to_index(:, :, :) = 1
     240             : 
     241        6834 :       ALLOCATE (kpoint%index_to_cell(0:0, 0:0))
     242       20502 :       kpoint%index_to_cell(:, :) = 0
     243             : 
     244        6834 :    END SUBROUTINE kpoint_create
     245             : 
     246             : ! **************************************************************************************************
     247             : !> \brief  Release a kpoint environment, deallocate all data
     248             : !> \param kpoint  The kpoint environment
     249             : !> \author JGH
     250             : ! **************************************************************************************************
     251        6843 :    SUBROUTINE kpoint_release(kpoint)
     252             :       TYPE(kpoint_type), POINTER                         :: kpoint
     253             : 
     254             :       INTEGER                                            :: i, ik, j
     255             : 
     256        6843 :       IF (ASSOCIATED(kpoint)) THEN
     257             : 
     258        6834 :          IF (ASSOCIATED(kpoint%xkp)) THEN
     259         326 :             DEALLOCATE (kpoint%xkp)
     260             :          END IF
     261        6834 :          IF (ASSOCIATED(kpoint%wkp)) THEN
     262         326 :             DEALLOCATE (kpoint%wkp)
     263             :          END IF
     264        6834 :          IF (ASSOCIATED(kpoint%kp_dist)) THEN
     265         224 :             DEALLOCATE (kpoint%kp_dist)
     266             :          END IF
     267             : 
     268        6834 :          CALL mpools_release(kpoint%mpools)
     269        6834 :          CALL mpools_release(kpoint%mpools_aux_fit)
     270             : 
     271        6834 :          CALL cp_blacs_env_release(kpoint%blacs_env)
     272        6834 :          CALL cp_blacs_env_release(kpoint%blacs_env_all)
     273             : 
     274        6834 :          CALL mp_para_env_release(kpoint%para_env)
     275        6834 :          CALL mp_para_env_release(kpoint%para_env_kp)
     276        6834 :          CALL mp_para_env_release(kpoint%para_env_inter_kp)
     277             : 
     278        6834 :          IF (ASSOCIATED(kpoint%cell_to_index)) DEALLOCATE (kpoint%cell_to_index)
     279        6834 :          IF (ASSOCIATED(kpoint%index_to_cell)) DEALLOCATE (kpoint%index_to_cell)
     280             : 
     281        6834 :          IF (ASSOCIATED(kpoint%kp_env)) THEN
     282        1744 :             DO ik = 1, SIZE(kpoint%kp_env)
     283        1744 :                CALL kpoint_env_release(kpoint%kp_env(ik)%kpoint_env)
     284             :             END DO
     285         224 :             DEALLOCATE (kpoint%kp_env)
     286             :          END IF
     287             : 
     288        6834 :          IF (ASSOCIATED(kpoint%kp_aux_env)) THEN
     289         188 :             DO ik = 1, SIZE(kpoint%kp_aux_env)
     290         188 :                CALL kpoint_env_release(kpoint%kp_aux_env(ik)%kpoint_env)
     291             :             END DO
     292          28 :             DEALLOCATE (kpoint%kp_aux_env)
     293             :          END IF
     294             : 
     295        6834 :          IF (ASSOCIATED(kpoint%kp_sym)) THEN
     296        8790 :             DO ik = 1, SIZE(kpoint%kp_sym)
     297        8790 :                CALL kpoint_sym_release(kpoint%kp_sym(ik)%kpoint_sym)
     298             :             END DO
     299         228 :             DEALLOCATE (kpoint%kp_sym)
     300             :          END IF
     301             : 
     302        6834 :          IF (ASSOCIATED(kpoint%atype)) DEALLOCATE (kpoint%atype)
     303        6834 :          IF (ASSOCIATED(kpoint%ibrot)) DEALLOCATE (kpoint%ibrot)
     304             : 
     305        6834 :          IF (ASSOCIATED(kpoint%kind_rotmat)) THEN
     306          48 :             DO i = 1, SIZE(kpoint%kind_rotmat, 1)
     307          48 :                DO j = 1, SIZE(kpoint%kind_rotmat, 2)
     308           0 :                   IF (ASSOCIATED(kpoint%kind_rotmat(i, j)%rmat)) THEN
     309           0 :                      DEALLOCATE (kpoint%kind_rotmat(i, j)%rmat)
     310             :                   END IF
     311             :                END DO
     312             :             END DO
     313          48 :             DEALLOCATE (kpoint%kind_rotmat)
     314             :          END IF
     315             : 
     316        6834 :          IF (ASSOCIATED(kpoint%scf_diis_buffer)) THEN
     317         130 :             CALL qs_diis_b_release_kp(kpoint%scf_diis_buffer)
     318         130 :             DEALLOCATE (kpoint%scf_diis_buffer)
     319             :          END IF
     320             : 
     321        6834 :          DEALLOCATE (kpoint)
     322             : 
     323             :       END IF
     324             : 
     325        6843 :    END SUBROUTINE kpoint_release
     326             : 
     327             : ! **************************************************************************************************
     328             : !> \brief Retrieve information from a kpoint environment
     329             : !> \param kpoint        The kpoint environment
     330             : !> \param kp_scheme     Type of kpoint grid
     331             : !> \param nkp_grid      Grid points
     332             : !> \param kp_shift      Shift of the grid
     333             : !> \param symmetry      use symmetry (atoms) to reduce kpoints
     334             : !> \param verbose       more output information
     335             : !> \param full_grid     don't reduce kpoints at all
     336             : !> \param use_real_wfn  real/complex wfn
     337             : !> \param eps_geo       accuracy of atom symmetry detection
     338             : !> \param parallel_group_size kpoint group size
     339             : !> \param kp_range      kpoints distribution for local processor
     340             : !> \param nkp           number of kpoints
     341             : !> \param xkp           kpoint coordinates in units of b-vector
     342             : !> \param wkp           kpoint weights
     343             : !> \param para_env      'global' parallel environment
     344             : !> \param blacs_env_all BLACS env for the total environment
     345             : !> \param para_env_kp   parallel environment of the kpoint calculation
     346             : !> \param para_env_inter_kp   parallel environment between kpoints
     347             : !> \param blacs_env     BLACS env for the kpoint group
     348             : !> \param kp_env        Information for each kpoint
     349             : !> \param kp_aux_env ...
     350             : !> \param mpools        FM matrix pools for kpoint groups
     351             : !> \param iogrp         this kpoint group has the IO processor
     352             : !> \param nkp_groups    number of kpoint groups
     353             : !> \param kp_dist       kpoints distribution on groups
     354             : !> \param cell_to_index given a cell triple, returns the real space index
     355             : !> \param index_to_cell ...
     356             : !> \param sab_nl        neighbourlist that defines real space matrices
     357             : !> \param sab_nl_nosym neighbourlist that defines real space matrices, non-symmetric
     358             : !> \author JGH
     359             : ! **************************************************************************************************
     360      844859 :    SUBROUTINE get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, &
     361             :                               full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, &
     362             :                               para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, &
     363             :                               kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, &
     364             :                               sab_nl, sab_nl_nosym)
     365             :       TYPE(kpoint_type), INTENT(IN)                      :: kpoint
     366             :       CHARACTER(LEN=*), OPTIONAL                         :: kp_scheme
     367             :       INTEGER, DIMENSION(3), OPTIONAL                    :: nkp_grid
     368             :       REAL(KIND=dp), DIMENSION(3), OPTIONAL              :: kp_shift
     369             :       LOGICAL, OPTIONAL                                  :: symmetry, verbose, full_grid, &
     370             :                                                             use_real_wfn
     371             :       REAL(KIND=dp), OPTIONAL                            :: eps_geo
     372             :       INTEGER, OPTIONAL                                  :: parallel_group_size
     373             :       INTEGER, DIMENSION(2), OPTIONAL                    :: kp_range
     374             :       INTEGER, OPTIONAL                                  :: nkp
     375             :       REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER  :: xkp
     376             :       REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER     :: wkp
     377             :       TYPE(mp_para_env_type), OPTIONAL, POINTER          :: para_env
     378             :       TYPE(cp_blacs_env_type), OPTIONAL, POINTER         :: blacs_env_all
     379             :       TYPE(mp_para_env_type), OPTIONAL, POINTER          :: para_env_kp, para_env_inter_kp
     380             :       TYPE(cp_blacs_env_type), OPTIONAL, POINTER         :: blacs_env
     381             :       TYPE(kpoint_env_p_type), DIMENSION(:), OPTIONAL, &
     382             :          POINTER                                         :: kp_env, kp_aux_env
     383             :       TYPE(qs_matrix_pools_type), OPTIONAL, POINTER      :: mpools
     384             :       LOGICAL, OPTIONAL                                  :: iogrp
     385             :       INTEGER, OPTIONAL                                  :: nkp_groups
     386             :       INTEGER, DIMENSION(:, :), OPTIONAL, POINTER        :: kp_dist
     387             :       INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER     :: cell_to_index
     388             :       INTEGER, DIMENSION(:, :), OPTIONAL, POINTER        :: index_to_cell
     389             :       TYPE(neighbor_list_set_p_type), DIMENSION(:), &
     390             :          OPTIONAL, POINTER                               :: sab_nl, sab_nl_nosym
     391             : 
     392           0 :       IF (PRESENT(kp_scheme)) kp_scheme = kpoint%kp_scheme
     393      845571 :       IF (PRESENT(nkp_grid)) nkp_grid = kpoint%nkp_grid
     394      844859 :       IF (PRESENT(kp_shift)) kp_shift = kpoint%kp_shift
     395      844859 :       IF (PRESENT(symmetry)) symmetry = kpoint%symmetry
     396      844859 :       IF (PRESENT(verbose)) verbose = kpoint%verbose
     397      844859 :       IF (PRESENT(full_grid)) full_grid = kpoint%full_grid
     398      844859 :       IF (PRESENT(use_real_wfn)) use_real_wfn = kpoint%use_real_wfn
     399      844859 :       IF (PRESENT(eps_geo)) eps_geo = kpoint%eps_geo
     400      844859 :       IF (PRESENT(parallel_group_size)) parallel_group_size = kpoint%parallel_group_size
     401             : 
     402      844859 :       IF (PRESENT(nkp)) nkp = kpoint%nkp
     403      844859 :       IF (PRESENT(wkp)) wkp => kpoint%wkp
     404      844859 :       IF (PRESENT(xkp)) xkp => kpoint%xkp
     405             : 
     406      844859 :       IF (PRESENT(para_env)) para_env => kpoint%para_env
     407      844859 :       IF (PRESENT(para_env_kp)) para_env_kp => kpoint%para_env_kp
     408      844859 :       IF (PRESENT(para_env_inter_kp)) para_env_inter_kp => kpoint%para_env_inter_kp
     409      844859 :       IF (PRESENT(blacs_env_all)) blacs_env_all => kpoint%blacs_env_all
     410      844859 :       IF (PRESENT(blacs_env)) blacs_env => kpoint%blacs_env
     411             : 
     412      844859 :       IF (PRESENT(iogrp)) iogrp = kpoint%iogrp
     413      897023 :       IF (PRESENT(kp_range)) kp_range = kpoint%kp_range
     414      844859 :       IF (PRESENT(nkp_groups)) nkp_groups = kpoint%nkp_groups
     415      844859 :       IF (PRESENT(kp_dist)) kp_dist => kpoint%kp_dist
     416             : 
     417      844859 :       IF (PRESENT(kp_env)) kp_env => kpoint%kp_env
     418      844859 :       IF (PRESENT(kp_aux_env)) kp_aux_env => kpoint%kp_aux_env
     419      844859 :       IF (PRESENT(mpools)) mpools => kpoint%mpools
     420             : 
     421      844859 :       IF (PRESENT(cell_to_index)) cell_to_index => kpoint%cell_to_index
     422      844859 :       IF (PRESENT(index_to_cell)) index_to_cell => kpoint%index_to_cell
     423      844859 :       IF (PRESENT(sab_nl)) sab_nl => kpoint%sab_nl
     424      844859 :       IF (PRESENT(sab_nl_nosym)) sab_nl_nosym => kpoint%sab_nl_nosym
     425             : 
     426      844859 :    END SUBROUTINE get_kpoint_info
     427             : 
     428             : ! **************************************************************************************************
     429             : !> \brief Set information in a kpoint environment
     430             : !> \param kpoint        The kpoint environment
     431             : !> \param kp_scheme     Type of kpoint grid
     432             : !> \param nkp_grid      Grid points
     433             : !> \param kp_shift      Shift of the grid
     434             : !> \param symmetry      use symmetry (atoms) to reduce kpoints
     435             : !> \param verbose       more output information
     436             : !> \param full_grid     don't reduce kpoints at all
     437             : !> \param use_real_wfn  real/complex wfn
     438             : !> \param eps_geo       accuracy of atom symmetry detection
     439             : !> \param parallel_group_size kpoint group size
     440             : !> \param kp_range      kpoints distribution for local processor
     441             : !> \param nkp           number of kpoints
     442             : !> \param xkp           kpoint coordinates
     443             : !> \param wkp           kpoint weights
     444             : !> \param para_env      'global' parallel environment
     445             : !> \param blacs_env_all BLACS env for the total environment
     446             : !> \param para_env_kp   parallel environment of the kpoint calculation
     447             : !> \param para_env_inter_kp   parallel environment between kpoints
     448             : !> \param blacs_env     BLACS env for the kpoint group
     449             : !> \param kp_env        Information for each kpoint
     450             : !> \param kp_aux_env ...
     451             : !> \param mpools        FM matrix pools for kpoint groups
     452             : !> \param iogrp         this kpoint group has the IO processor
     453             : !> \param nkp_groups    number of kpoint groups
     454             : !> \param kp_dist       kpoints distribution on groups
     455             : !> \param cell_to_index given a cell triple, returns the real space index
     456             : !> \param index_to_cell ...
     457             : !> \param sab_nl        neighbourlist that defines real space matrices
     458             : !> \param sab_nl_nosym  neighbourlist that defines real space matrices
     459             : !> \author JGH
     460             : ! **************************************************************************************************
     461         910 :    SUBROUTINE set_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, &
     462             :                               full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, &
     463             :                               para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, &
     464             :                               kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, &
     465             :                               sab_nl, sab_nl_nosym)
     466             :       TYPE(kpoint_type), INTENT(INOUT)                   :: kpoint
     467             :       CHARACTER(LEN=*), OPTIONAL                         :: kp_scheme
     468             :       INTEGER, DIMENSION(3), OPTIONAL                    :: nkp_grid
     469             :       REAL(KIND=dp), DIMENSION(3), OPTIONAL              :: kp_shift
     470             :       LOGICAL, OPTIONAL                                  :: symmetry, verbose, full_grid, &
     471             :                                                             use_real_wfn
     472             :       REAL(KIND=dp), OPTIONAL                            :: eps_geo
     473             :       INTEGER, OPTIONAL                                  :: parallel_group_size
     474             :       INTEGER, DIMENSION(2), OPTIONAL                    :: kp_range
     475             :       INTEGER, OPTIONAL                                  :: nkp
     476             :       REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER  :: xkp
     477             :       REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER     :: wkp
     478             :       TYPE(mp_para_env_type), OPTIONAL, POINTER          :: para_env
     479             :       TYPE(cp_blacs_env_type), OPTIONAL, POINTER         :: blacs_env_all
     480             :       TYPE(mp_para_env_type), OPTIONAL, POINTER          :: para_env_kp, para_env_inter_kp
     481             :       TYPE(cp_blacs_env_type), OPTIONAL, POINTER         :: blacs_env
     482             :       TYPE(kpoint_env_p_type), DIMENSION(:), OPTIONAL, &
     483             :          POINTER                                         :: kp_env, kp_aux_env
     484             :       TYPE(qs_matrix_pools_type), OPTIONAL, POINTER      :: mpools
     485             :       LOGICAL, OPTIONAL                                  :: iogrp
     486             :       INTEGER, OPTIONAL                                  :: nkp_groups
     487             :       INTEGER, DIMENSION(:, :), OPTIONAL, POINTER        :: kp_dist
     488             :       INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER     :: cell_to_index
     489             :       INTEGER, DIMENSION(:, :), OPTIONAL, POINTER        :: index_to_cell
     490             :       TYPE(neighbor_list_set_p_type), DIMENSION(:), &
     491             :          OPTIONAL, POINTER                               :: sab_nl, sab_nl_nosym
     492             : 
     493           0 :       IF (PRESENT(kp_scheme)) kpoint%kp_scheme = kp_scheme
     494         910 :       IF (PRESENT(nkp_grid)) kpoint%nkp_grid = nkp_grid
     495         910 :       IF (PRESENT(kp_shift)) kpoint%kp_shift = kp_shift
     496         910 :       IF (PRESENT(symmetry)) kpoint%symmetry = symmetry
     497         910 :       IF (PRESENT(verbose)) kpoint%verbose = verbose
     498         910 :       IF (PRESENT(full_grid)) kpoint%full_grid = full_grid
     499         910 :       IF (PRESENT(use_real_wfn)) kpoint%use_real_wfn = use_real_wfn
     500         910 :       IF (PRESENT(eps_geo)) kpoint%eps_geo = eps_geo
     501         910 :       IF (PRESENT(parallel_group_size)) kpoint%parallel_group_size = parallel_group_size
     502             : 
     503         910 :       IF (PRESENT(nkp)) kpoint%nkp = nkp
     504         910 :       IF (PRESENT(wkp)) kpoint%wkp => wkp
     505         910 :       IF (PRESENT(xkp)) kpoint%xkp => xkp
     506             : 
     507         910 :       IF (PRESENT(para_env)) kpoint%para_env => para_env
     508         910 :       IF (PRESENT(para_env_kp)) kpoint%para_env_kp => para_env_kp
     509         910 :       IF (PRESENT(para_env_inter_kp)) kpoint%para_env_inter_kp => para_env_inter_kp
     510         910 :       IF (PRESENT(blacs_env_all)) kpoint%blacs_env_all => blacs_env_all
     511         910 :       IF (PRESENT(blacs_env)) kpoint%blacs_env => blacs_env
     512             : 
     513         910 :       IF (PRESENT(iogrp)) kpoint%iogrp = iogrp
     514         910 :       IF (PRESENT(kp_range)) kpoint%kp_range = kp_range
     515         910 :       IF (PRESENT(nkp_groups)) kpoint%nkp_groups = nkp_groups
     516         910 :       IF (PRESENT(kp_dist)) kpoint%kp_dist => kp_dist
     517             : 
     518         910 :       IF (PRESENT(kp_env)) kpoint%kp_env => kp_env
     519           0 :       IF (PRESENT(kp_env)) kpoint%kp_aux_env => kp_aux_env
     520         910 :       IF (PRESENT(mpools)) kpoint%mpools => mpools
     521         910 :       IF (PRESENT(sab_nl)) kpoint%sab_nl => sab_nl
     522         910 :       IF (PRESENT(sab_nl_nosym)) kpoint%sab_nl_nosym => sab_nl_nosym
     523             : 
     524         910 :       IF (PRESENT(cell_to_index)) THEN
     525           0 :          IF (ASSOCIATED(kpoint%cell_to_index)) DEALLOCATE (kpoint%cell_to_index)
     526           0 :          kpoint%cell_to_index => cell_to_index
     527             :       END IF
     528             : 
     529         910 :       IF (PRESENT(index_to_cell)) THEN
     530           0 :          IF (ASSOCIATED(kpoint%index_to_cell)) DEALLOCATE (kpoint%index_to_cell)
     531           0 :          kpoint%index_to_cell => index_to_cell
     532             :       END IF
     533             : 
     534         910 :    END SUBROUTINE set_kpoint_info
     535             : 
     536             : ! **************************************************************************************************
     537             : !> \brief Read the kpoint input section
     538             : !> \param kpoint  The kpoint environment
     539             : !> \param kpoint_section The input section
     540             : !> \param a_vec ...
     541             : !> \author JGH
     542             : ! **************************************************************************************************
     543        6684 :    SUBROUTINE read_kpoint_section(kpoint, kpoint_section, a_vec)
     544             :       TYPE(kpoint_type), INTENT(INOUT)                   :: kpoint
     545             :       TYPE(section_vals_type), POINTER                   :: kpoint_section
     546             :       REAL(KIND=dp), DIMENSION(3, 3), INTENT(IN)         :: a_vec
     547             : 
     548             :       CHARACTER(LEN=default_string_length)               :: ustr
     549             :       CHARACTER(LEN=default_string_length), &
     550        6684 :          DIMENSION(:), POINTER                           :: tmpstringlist
     551             :       INTEGER                                            :: i, n_rep, nval, wfntype
     552             :       LOGICAL                                            :: available
     553             :       REAL(KIND=dp)                                      :: ff
     554        6684 :       REAL(KIND=dp), DIMENSION(:), POINTER               :: reallist
     555             : 
     556        6684 :       CALL section_vals_get(kpoint_section, explicit=available)
     557             : 
     558        6684 :       IF (available) THEN
     559         168 :          CALL section_vals_val_get(kpoint_section, "SCHEME", c_vals=tmpstringlist)
     560         168 :          nval = SIZE(tmpstringlist)
     561         168 :          CPASSERT(nval >= 1)
     562         168 :          kpoint%kp_scheme = tmpstringlist(1)
     563         168 :          CALL uppercase(kpoint%kp_scheme)
     564             : 
     565             :          ! SCHEME [None, Gamma, Monkhorst-Pack, MacDonald, General]
     566         142 :          SELECT CASE (kpoint%kp_scheme)
     567             :          CASE ("NONE")
     568             :             ! do nothing
     569             :          CASE ("GAMMA")
     570             :             ! do nothing
     571             :          CASE ("MONKHORST-PACK")
     572         142 :             CPASSERT(nval >= 4)
     573         568 :             DO i = 2, 4
     574         568 :                READ (tmpstringlist(i), *) kpoint%nkp_grid(i - 1)
     575             :             END DO
     576             :          CASE ("MACDONALD")
     577           0 :             CPASSERT(nval >= 7)
     578           0 :             DO i = 2, 4
     579           0 :                READ (tmpstringlist(i), *) kpoint%nkp_grid(i - 1)
     580             :             END DO
     581           0 :             DO i = 5, 7
     582           0 :                READ (tmpstringlist(i), *) kpoint%kp_shift(i - 4)
     583             :             END DO
     584             :          CASE ("GENERAL")
     585           2 :             CALL section_vals_val_get(kpoint_section, "UNITS", c_val=ustr)
     586           2 :             CALL uppercase(ustr)
     587           2 :             CALL section_vals_val_get(kpoint_section, "KPOINT", n_rep_val=n_rep)
     588           2 :             kpoint%nkp = n_rep
     589          10 :             ALLOCATE (kpoint%xkp(3, n_rep), kpoint%wkp(n_rep))
     590           8 :             DO i = 1, n_rep
     591             :                CALL section_vals_val_get(kpoint_section, "KPOINT", i_rep_val=i, &
     592           6 :                                          r_vals=reallist)
     593           6 :                nval = SIZE(reallist)
     594           6 :                CPASSERT(nval >= 4)
     595           6 :                SELECT CASE (ustr)
     596             :                CASE ("B_VECTOR")
     597          24 :                   kpoint%xkp(1:3, i) = reallist(1:3)
     598             :                CASE ("CART_ANGSTROM")
     599             :                   kpoint%xkp(1:3, i) = (reallist(1)*a_vec(1, 1:3) + &
     600             :                                         reallist(2)*a_vec(2, 1:3) + &
     601           0 :                                         reallist(3)*a_vec(3, 1:3))/twopi*angstrom
     602             :                CASE ("CART_BOHR")
     603             :                   kpoint%xkp(1:3, i) = (reallist(1)*a_vec(1, 1:3) + &
     604             :                                         reallist(2)*a_vec(2, 1:3) + &
     605           0 :                                         reallist(3)*a_vec(3, 1:3))/twopi
     606             :                CASE DEFAULT
     607           6 :                   CPABORT("Unknown Unit for kpoint definition")
     608             :                END SELECT
     609           8 :                kpoint%wkp(i) = reallist(4)
     610             :             END DO
     611           8 :             ff = 1.0_dp/SUM(kpoint%wkp(:))
     612          10 :             kpoint%wkp(:) = ff*kpoint%wkp(:)
     613             :          CASE DEFAULT
     614         168 :             CPABORT("")
     615             :          END SELECT
     616             : 
     617         168 :          CALL section_vals_val_get(kpoint_section, "SYMMETRY", l_val=kpoint%symmetry)
     618         168 :          CALL section_vals_val_get(kpoint_section, "WAVEFUNCTIONS", i_val=wfntype)
     619         168 :          CALL section_vals_val_get(kpoint_section, "VERBOSE", l_val=kpoint%verbose)
     620         168 :          CALL section_vals_val_get(kpoint_section, "FULL_GRID", l_val=kpoint%full_grid)
     621         168 :          CALL section_vals_val_get(kpoint_section, "EPS_GEO", r_val=kpoint%eps_geo)
     622             :          CALL section_vals_val_get(kpoint_section, "PARALLEL_GROUP_SIZE", &
     623         168 :                                    i_val=kpoint%parallel_group_size)
     624          10 :          SELECT CASE (wfntype)
     625             :          CASE (use_real_wfn)
     626          10 :             kpoint%use_real_wfn = .TRUE.
     627             :          CASE (use_complex_wfn)
     628         158 :             kpoint%use_real_wfn = .FALSE.
     629             :          CASE DEFAULT
     630         168 :             CPABORT("")
     631             :          END SELECT
     632             : 
     633             :       ELSE
     634        6516 :          kpoint%kp_scheme = "NONE"
     635             :       END IF
     636             : 
     637        6684 :    END SUBROUTINE read_kpoint_section
     638             : 
     639             : ! **************************************************************************************************
     640             : !> \brief Write information on the kpoints to output
     641             : !> \param kpoint  The kpoint environment
     642             : !> \param dft_section  DFT section information
     643             : !> \author JGH
     644             : ! **************************************************************************************************
     645        6684 :    SUBROUTINE write_kpoint_info(kpoint, dft_section)
     646             :       TYPE(kpoint_type), INTENT(IN)                      :: kpoint
     647             :       TYPE(section_vals_type), INTENT(IN)                :: dft_section
     648             : 
     649             :       INTEGER                                            :: i, punit
     650             :       TYPE(cp_logger_type), POINTER                      :: logger
     651             : 
     652        6684 :       NULLIFY (logger)
     653        6684 :       logger => cp_get_default_logger()
     654             : 
     655        6684 :       punit = cp_print_key_unit_nr(logger, dft_section, "PRINT%KPOINTS", extension=".Log")
     656        6684 :       IF (punit > 0) THEN
     657             : 
     658        1817 :          IF (kpoint%kp_scheme /= "NONE") THEN
     659          31 :             WRITE (punit, '(/," ",79("*"),/,T37,A,/," ",79("*"))') "Kpoints"
     660             :          END IF
     661           1 :          SELECT CASE (kpoint%kp_scheme)
     662             :          CASE ("NONE")
     663             :             ! be silent
     664             :          CASE ("GAMMA")
     665           1 :             WRITE (punit, '(A,T57,A)') ' BRILLOUIN|', ' Gamma-point calculation'
     666             :          CASE ("MONKHORST-PACK")
     667          30 :             WRITE (punit, '(A,T61,A20)') ' BRILLOUIN| K-point scheme ', '      Monkhorst-Pack'
     668          30 :             WRITE (punit, '(A,T66,3I5)') ' BRILLOUIN| K-Point grid', kpoint%nkp_grid
     669          30 :             WRITE (punit, '(A,T66,G15.6)') ' BRILLOUIN| Accuracy in Symmetry determination', kpoint%eps_geo
     670             :          CASE ("MACDONALD")
     671           0 :             WRITE (punit, '(A,T71,A10)') ' BRILLOUIN| K-point scheme ', ' MacDonald'
     672           0 :             WRITE (punit, '(A,T66,3I5)') ' BRILLOUIN| K-Point grid', kpoint%nkp_grid
     673           0 :             WRITE (punit, '(A,T51,3F10.4)') ' BRILLOUIN| K-Point shift', kpoint%kp_shift
     674           0 :             WRITE (punit, '(A,T66,G15.6)') ' BRILLOUIN| Accuracy in Symmetry determination', kpoint%eps_geo
     675             :          CASE ("GENERAL")
     676           0 :             WRITE (punit, '(A,T71,A10)') ' BRILLOUIN| K-point scheme ', '   General'
     677             :          CASE DEFAULT
     678        1817 :             CPABORT("")
     679             :          END SELECT
     680        1817 :          IF (kpoint%kp_scheme /= "NONE") THEN
     681          31 :             IF (kpoint%symmetry) THEN
     682           5 :                WRITE (punit, '(A,T76,A)') ' BRILLOUIN| K-Point point group symmetrization', '   ON'
     683             :             ELSE
     684          26 :                WRITE (punit, '(A,T76,A)') ' BRILLOUIN| K-Point point group symmetrization', '  OFF'
     685             :             END IF
     686          31 :             IF (kpoint%use_real_wfn) THEN
     687           0 :                WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Wavefunction type', ' REAL'
     688             :             ELSE
     689          31 :                WRITE (punit, '(A,T73,A)') ' BRILLOUIN| Wavefunction type', ' COMPLEX'
     690             :             END IF
     691          31 :             IF (kpoint%full_grid) THEN
     692           5 :                WRITE (punit, '(A,T76,A)') ' BRILLOUIN| Use full k-point grid     '
     693             :             END IF
     694          31 :             IF (kpoint%kp_scheme /= "GAMMA") THEN
     695          30 :                WRITE (punit, '(A,T71,I10)') ' BRILLOUIN| List of Kpoints [2 Pi/Bohr]', kpoint%nkp
     696             :                WRITE (punit, '(A,T30,A,T48,A,T63,A,T78,A)') &
     697          30 :                   ' BRILLOUIN| Number ', 'Weight', 'X', 'Y', 'Z'
     698         472 :                DO i = 1, kpoint%nkp
     699         442 :                   WRITE (punit, '(A,I5,3X,4F15.5)') ' BRILLOUIN| ', i, kpoint%wkp(i), &
     700         914 :                      kpoint%xkp(1, i), kpoint%xkp(2, i), kpoint%xkp(3, i)
     701             :                END DO
     702             :             END IF
     703          31 :             WRITE (punit, '(" ",79("*"))')
     704             :          END IF
     705             : 
     706             :       END IF
     707        6684 :       CALL cp_print_key_finished_output(punit, logger, dft_section, "PRINT%KPOINTS")
     708             : 
     709        6684 :    END SUBROUTINE write_kpoint_info
     710             : 
     711             : ! **************************************************************************************************
     712             : !> \brief Create a single kpoint environment
     713             : !> \param kp_env  Single kpoint environment
     714             : !> \author JGH
     715             : ! **************************************************************************************************
     716        1680 :    SUBROUTINE kpoint_env_create(kp_env)
     717             :       TYPE(kpoint_env_type), POINTER                     :: kp_env
     718             : 
     719        1680 :       CPASSERT(.NOT. ASSOCIATED(kp_env))
     720             : 
     721        8400 :       ALLOCATE (kp_env)
     722             : 
     723        1680 :       kp_env%nkpoint = 0
     724             :       kp_env%wkp = 0.0_dp
     725        6720 :       kp_env%xkp = 0.0_dp
     726        1680 :       kp_env%is_local = .FALSE.
     727             : 
     728        1680 :       NULLIFY (kp_env%mos)
     729        1680 :       NULLIFY (kp_env%pmat)
     730        1680 :       NULLIFY (kp_env%wmat)
     731        1680 :       NULLIFY (kp_env%smat)
     732        1680 :       NULLIFY (kp_env%amat)
     733             : 
     734        1680 :    END SUBROUTINE kpoint_env_create
     735             : 
     736             : ! **************************************************************************************************
     737             : !> \brief Release a single kpoint environment
     738             : !> \param kp_env  Single kpoint environment
     739             : !> \author JGH
     740             : ! **************************************************************************************************
     741        1680 :    SUBROUTINE kpoint_env_release(kp_env)
     742             :       TYPE(kpoint_env_type), POINTER                     :: kp_env
     743             : 
     744             :       INTEGER                                            :: ic, is
     745             : 
     746        1680 :       IF (ASSOCIATED(kp_env)) THEN
     747             : 
     748        1680 :          IF (ASSOCIATED(kp_env%mos)) THEN
     749        3632 :             DO is = 1, SIZE(kp_env%mos, 2)
     750        7522 :                DO ic = 1, SIZE(kp_env%mos, 1)
     751        5842 :                   CALL deallocate_mo_set(kp_env%mos(ic, is))
     752             :                END DO
     753             :             END DO
     754        1680 :             DEALLOCATE (kp_env%mos)
     755             :          END IF
     756             : 
     757        1680 :          CALL cp_fm_release(kp_env%pmat)
     758        1680 :          CALL cp_fm_release(kp_env%wmat)
     759        1680 :          CALL cp_fm_release(kp_env%smat)
     760        1680 :          CALL cp_fm_release(kp_env%amat)
     761             : 
     762        1680 :          DEALLOCATE (kp_env)
     763             : 
     764             :       END IF
     765             : 
     766        1680 :    END SUBROUTINE kpoint_env_release
     767             : 
     768             : ! **************************************************************************************************
     769             : !> \brief Get information from a single kpoint environment
     770             : !> \param kpoint_env Single kpoint environment
     771             : !> \param nkpoint    Index of kpoint
     772             : !> \param wkp        Weight of kpoint
     773             : !> \param xkp        Coordinates of kpoint
     774             : !> \param is_local   Is this kpoint local (single cpu group)
     775             : !> \param mos        MOs of this kpoint
     776             : !> \author JGH
     777             : ! **************************************************************************************************
     778        2652 :    SUBROUTINE get_kpoint_env(kpoint_env, nkpoint, wkp, xkp, is_local, mos)
     779             :       TYPE(kpoint_env_type), INTENT(IN)                  :: kpoint_env
     780             :       INTEGER, OPTIONAL                                  :: nkpoint
     781             :       REAL(KIND=dp), OPTIONAL                            :: wkp
     782             :       REAL(KIND=dp), DIMENSION(3), OPTIONAL              :: xkp
     783             :       LOGICAL, OPTIONAL                                  :: is_local
     784             :       TYPE(mo_set_type), DIMENSION(:, :), OPTIONAL, &
     785             :          POINTER                                         :: mos
     786             : 
     787        2652 :       IF (PRESENT(nkpoint)) nkpoint = kpoint_env%nkpoint
     788        2652 :       IF (PRESENT(wkp)) wkp = kpoint_env%wkp
     789        2652 :       IF (PRESENT(xkp)) xkp = kpoint_env%xkp
     790        2652 :       IF (PRESENT(is_local)) is_local = kpoint_env%is_local
     791        2652 :       IF (PRESENT(mos)) mos => kpoint_env%mos
     792             : 
     793        2652 :    END SUBROUTINE get_kpoint_env
     794             : 
     795             : ! **************************************************************************************************
     796             : !> \brief Create a single kpoint symmetry environment
     797             : !> \param kp_sym  ...
     798             : !> \author JGH
     799             : ! **************************************************************************************************
     800        8562 :    SUBROUTINE kpoint_sym_create(kp_sym)
     801             :       TYPE(kpoint_sym_type), POINTER                     :: kp_sym
     802             : 
     803        8562 :       CPASSERT(.NOT. ASSOCIATED(kp_sym))
     804             : 
     805        8562 :       ALLOCATE (kp_sym)
     806             : 
     807        8562 :       kp_sym%nwght = 0
     808        8562 :       kp_sym%nwred = 0
     809             :       kp_sym%apply_symmetry = .FALSE.
     810             : 
     811             :       NULLIFY (kp_sym%rot)
     812             :       NULLIFY (kp_sym%xkp)
     813             :       NULLIFY (kp_sym%rotp)
     814             :       NULLIFY (kp_sym%f0)
     815             : 
     816        8562 :    END SUBROUTINE kpoint_sym_create
     817             : 
     818             : ! **************************************************************************************************
     819             : !> \brief Release a single kpoint symmetry environment
     820             : !> \param kp_sym  ...
     821             : !> \author JGH
     822             : ! **************************************************************************************************
     823        8562 :    SUBROUTINE kpoint_sym_release(kp_sym)
     824             :       TYPE(kpoint_sym_type), POINTER                     :: kp_sym
     825             : 
     826        8562 :       IF (ASSOCIATED(kp_sym)) THEN
     827             : 
     828        8562 :          IF (ASSOCIATED(kp_sym%rot)) THEN
     829           0 :             DEALLOCATE (kp_sym%rot)
     830             :          END IF
     831        8562 :          IF (ASSOCIATED(kp_sym%xkp)) THEN
     832           0 :             DEALLOCATE (kp_sym%xkp)
     833             :          END IF
     834        8562 :          IF (ASSOCIATED(kp_sym%f0)) THEN
     835           0 :             DEALLOCATE (kp_sym%f0)
     836             :          END IF
     837        8562 :          IF (ASSOCIATED(kp_sym%rotp)) THEN
     838           0 :             DEALLOCATE (kp_sym%rotp)
     839             :          END IF
     840             : 
     841        8562 :          DEALLOCATE (kp_sym)
     842             : 
     843             :       END IF
     844             : 
     845        8562 :    END SUBROUTINE kpoint_sym_release
     846             : 
     847             : ! **************************************************************************************************
     848             : 
     849           0 : END MODULE kpoint_types

Generated by: LCOV version 1.15