LCOV - code coverage report
Current view: top level - src/43_wvl_wrappers - m_wvl_projectors.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 6 0
Test Date: 2026-09-21 22:40:37 Functions: 0.0 % 2 0

            Line data    Source code
       1              : !!****m* ABINIT/m_wvl_projectors
       2              : !! NAME
       3              : !!  m_wvl_projectors
       4              : !!
       5              : !! FUNCTION
       6              : !!
       7              : !!
       8              : !! COPYRIGHT
       9              : !!  Copyright (C) 2008-2026 ABINIT group (DC)
      10              : !!  This file is distributed under the terms of the
      11              : !!  GNU General Public License, see ~abinit/COPYING
      12              : !!  or http://www.gnu.org/copyleft/gpl.txt .
      13              : !!
      14              : !! SOURCE
      15              : 
      16              : #if defined HAVE_CONFIG_H
      17              : #include "config.h"
      18              : #endif
      19              : 
      20              : #include "abi_common.h"
      21              : 
      22              : module m_wvl_projectors
      23              : 
      24              :  use defs_basis
      25              :  use defs_wvltypes
      26              :  use m_errors
      27              :  use m_abicore
      28              :  use m_atomdata
      29              : 
      30              :  use defs_datatypes, only : pseudopotential_type
      31              :  use m_geometry,     only : xred2xcart
      32              : 
      33              :  implicit none
      34              : 
      35              :  private
      36              : !!***
      37              : 
      38              :  public :: wvl_projectors_set
      39              :  public :: wvl_projectors_free
      40              : !!***
      41              : 
      42              : contains
      43              : !!***
      44              : 
      45              : !!****f* ABINIT/wvl_projectors_set
      46              : !!
      47              : !! NAME
      48              : !! wvl_projectors_set
      49              : !!
      50              : !! FUNCTION
      51              : !! Allocate and compute the access keys for the projectors when the positions
      52              : !! of the atoms are given. The array to store projectors
      53              : !! is also allocated, use wvl_projectors_free() to free them after use.
      54              : !!
      55              : !! INPUTS
      56              : !!  dtset <type(dataset_type)>=internal variables used by wavelets, describing
      57              : !!   | wvl_internal=desciption of the wavelet box.
      58              : !!   | natom=number of atoms.
      59              : !!  mpi_enreg=information about MPI parallelization
      60              : !!  psps <type(pseudopotential_type)>=variables related to pseudopotentials
      61              : !!  rprimd(3,3)=dimensional primitive translations in real space (bohr)
      62              : !!  xred(3,natom)=reduced dimensionless atomic coordinates
      63              : !!
      64              : !! OUTPUT
      65              : !!  proj <type(wvl_projector_type)>=projectors information for wavelets.
      66              : !!   | keys=its access keys for compact storage.
      67              : !!
      68              : !! SIDE EFFECTS
      69              : !!
      70              : !! SOURCE
      71              : 
      72            0 : subroutine wvl_projectors_set(me, natom, proj, psps, rprimd, wfs, wvl, wvl_frmult, xred)
      73              : 
      74              : #if defined HAVE_BIGDFT
      75              :  use BigDFT_API, only: createProjectorsArrays, wvl_timing => timing
      76              : #endif
      77              : 
      78              : !Arguments ------------------------------------
      79              : !scalars
      80              :  integer, intent(in) :: natom, me
      81              :  real(dp), intent(in) :: wvl_frmult
      82              :  type(pseudopotential_type),intent(in) :: psps
      83              :  type(wvl_projectors_type),intent(inout) :: proj
      84              :  type(wvl_wf_type),intent(in) :: wfs
      85              :  type(wvl_internal_type), intent(in) :: wvl
      86              : !arrays
      87              :  real(dp),intent(in) :: rprimd(3,3),xred(3,natom)
      88              : 
      89              : !Local variables-------------------------------
      90              : !scalars
      91              : #if defined HAVE_BIGDFT
      92              :  integer :: idata
      93              :  logical,parameter :: wvl_debug=.false.
      94              :  character(len=500) :: message
      95              : !arrays
      96              :  real(dp),allocatable :: xcart(:,:)
      97              : #endif
      98              : 
      99              : ! *********************************************************************
     100              : 
     101              : #if defined HAVE_BIGDFT
     102              : !Consistency checks, are all pseudo true GTH pseudo with geometric information?
     103              :  do idata = 1, psps%npsp, 1
     104              :    if (.not. psps%gth_params%set(idata)) then
     105              :      write(message, '(a,a,a,a,I0,a,a,a)' ) ch10,&
     106              : &     ' wvl_projectors_set :  consistency checks failed,', ch10, &
     107              : &     '  no GTH parameters found for type number ', idata, '.', ch10, &
     108              : &     '  Check your input pseudo files.'
     109              :      ABI_ERROR(message)
     110              :    end if
     111              :    if (.not. psps%gth_params%hasGeometry(idata)) then
     112              :      write(message, '(a,a,a,a,a,a)' ) ch10,&
     113              : &     ' wvl_projectors_set :  consistency checks failed,', ch10, &
     114              : &     '  the given GTH parameters has no geometry information.', ch10, &
     115              : &     '  Upgrade your input pseudo files to GTH with geometric informatoins.'
     116              :      ABI_ERROR(message)
     117              :    end if
     118              :  end do
     119              : 
     120              :  if (wvl_debug) then
     121              :    call wvl_timing(me,'CrtProjectors ','ON')
     122              :  end if
     123              : 
     124              : !Store xcart for each atom
     125              :  ABI_MALLOC(xcart,(3, natom))
     126              :  call xred2xcart(natom, rprimd, xcart, xred)
     127              :  call createProjectorsArrays(wfs%ks%Lzd%Glr,xcart,wvl%atoms,wfs%ks%orbs,&
     128              :  psps%gth_params%radii_cf,wvl_frmult,wvl_frmult,wvl%h(1),wvl%h(2),&
     129              :  wvl%h(3),.false.,proj%nlpsp,proj%G)
     130              :  write(message, '(a,a,a,a,I0)' ) ch10,&
     131              : & ' wvl_projectors_set : allocate projectors data,', ch10, &
     132              : & '  size of the compressed array: ', proj%nlpsp%nprojel
     133              :  call wrtout(std_out,message,'COLL')
     134              : 
     135              : !Deallocations
     136              :  ABI_FREE(xcart)
     137              : 
     138              :  if (wvl_debug) then
     139              :    call wvl_timing(me,'CrtProjectors ','OF')
     140              :  end if
     141              : 
     142              : #else
     143            0 :  BIGDFT_NOTENABLED_ERROR()
     144              :  if (.false.) write(std_out,*) natom,me,wvl_frmult,psps%npsp,proj%nlpsp,wfs%ks,wvl%h(1),&
     145              : & rprimd(1,1),xred(1,1)
     146              : #endif
     147              : 
     148            0 : end subroutine wvl_projectors_set
     149              : !!***
     150              : 
     151              : !!****f* ABINIT/wvl_projectors_free
     152              : !!
     153              : !! NAME
     154              : !! wvl_projectors_free
     155              : !!
     156              : !! FUNCTION
     157              : !! Freeing routine.
     158              : !!
     159              : !! INPUTS
     160              : !!
     161              : !! OUTPUT
     162              : !!
     163              : !! SIDE EFFECTS
     164              : !!  proj <type(wvl_projectors_type)>=projectors information in a wavelet basis.
     165              : !!
     166              : !! SOURCE
     167              : 
     168            0 : subroutine wvl_projectors_free(proj)
     169              : 
     170              : #if defined HAVE_BIGDFT
     171              :   use BigDFT_API, only : free_DFT_PSP_projectors,deallocate_gwf
     172              : #endif
     173              : 
     174              : !Arguments ------------------------------------
     175              : !scalars
     176              :  type(wvl_projectors_type),intent(inout) :: proj
     177              : 
     178              : !Local variables -------------------------
     179              : #if defined HAVE_BIGDFT
     180              :  integer :: ii
     181              : #endif
     182              : 
     183              :   ! *********************************************************************
     184              : 
     185              : #if defined HAVE_BIGDFT
     186              : 
     187              :  call free_DFT_PSP_projectors(proj%nlpsp)
     188              : 
     189              :  if (allocated(proj%G)) then
     190              :    do ii=1,size(proj%G)
     191              : !    MT dec 2014: cannot call bigdft deallocation routine
     192              : !    because content of proj%G datastructure was created
     193              : !    without f_malloc (without memory profiling).
     194              : !    call deallocate_gwf(proj%G(ii))
     195              :      if (associated(proj%G(ii)%ndoc)) then
     196              :        ABI_FREE(proj%G(ii)%ndoc)
     197              :      end if
     198              :      if (associated(proj%G(ii)%nam)) then
     199              :        ABI_FREE(proj%G(ii)%nam)
     200              :      end if
     201              :      if (associated(proj%G(ii)%nshell)) then
     202              :        ABI_FREE(proj%G(ii)%nshell)
     203              :      end if
     204              :      if (associated(proj%G(ii)%psiat)) then
     205              :        ABI_FREE(proj%G(ii)%psiat)
     206              :      end if
     207              :      if (associated(proj%G(ii)%xp)) then
     208              :        ABI_FREE(proj%G(ii)%xp)
     209              :      end if
     210              :    end do
     211              :    ABI_FREE(proj%G)
     212              :  end if
     213              : 
     214              : #else
     215            0 :  BIGDFT_NOTENABLED_ERROR()
     216              :  if (.false.) write(std_out,*) proj%nlpsp
     217              : #endif
     218              : 
     219            0 : end subroutine wvl_projectors_free
     220              : !!***
     221              : 
     222              : end module m_wvl_projectors
     223              : !!***
        

Generated by: LCOV version 2.3-1