LCOV - code coverage report
Current view: top level - src/79_seqpar_mpi - m_lobpcg.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.1 % 29 27
Test Date: 2026-09-19 17:42:43 Functions: 100.0 % 1 1

            Line data    Source code
       1              : !!****m* ABINIT/m_lobpcg
       2              : !! NAME
       3              : !!  m_lobpcg
       4              : !!
       5              : !! FUNCTION
       6              : !!  This module provides the procedures used in the LOBPCGWF routine.
       7              : !!  They permit to hide the complex/real form of the WFs.
       8              : !!
       9              : !! COPYRIGHT
      10              : !! Copyright (C) 2009-2026 ABINIT group (FBottin,CS,FDahm,MT)
      11              : !! This file is distributed under the terms of the
      12              : !! GNU General Public License, see ~abinit/COPYING
      13              : !! or http://www.gnu.org/copyleft/gpl.txt .
      14              : !! For the initials of contributors, see ~abinit/doc/developers/contributors.txt.
      15              : !!
      16              : !! NOTES
      17              : !!
      18              : !! SOURCE
      19              : 
      20              : #if defined HAVE_CONFIG_H
      21              : #include "config.h"
      22              : #endif
      23              : 
      24              : #include "abi_common.h"
      25              : 
      26              : MODULE m_lobpcg
      27              : 
      28              :  use defs_basis
      29              :  use m_abicore
      30              :  use m_errors
      31              :  use m_wfutils
      32              :  use m_abi_linalg
      33              :  use m_cgtools
      34              :  use m_dtset
      35              : 
      36              :  use defs_abitypes,       only : mpi_type
      37              :  use m_time,              only : timab
      38              : 
      39              :  implicit none
      40              : 
      41              :  private
      42              : 
      43              : !public procedures.
      44              :  public :: xprecon
      45              : !!***
      46              : 
      47              : CONTAINS
      48              : !----------------------------------------------------------------------
      49              : 
      50              : 
      51              : !! NAME
      52              : !!  xprecon
      53              : !!
      54              : !! FUNCTION
      55              : !!  precondition $<G|(H-e_{n,k})|C_{n,k}>$
      56              : !!  for a block of band (band-FFT parallelisation)
      57              : !!
      58              : !! COPYRIGHT
      59              : !! Copyright (C) 1998-2026 ABINIT group (FBottin,CS)
      60              : !! this file is distributed under the terms of the
      61              : !! gnu general public license, see ~abinit/COPYING
      62              : !! or http://www.gnu.org/copyleft/gpl.txt .
      63              : !! for the initials of contributors, see ~abinit/doc/developers/contributors.txt .
      64              : !!
      65              : !! INPUTS
      66              : !!  blocksize= size of blocks of bands
      67              : !!  $cg(vectsize,blocksize)=<G|C_{n,k}> for a block of bands$.
      68              : !!  $eval(blocksize,blocksize)=current block of bands eigenvalues=<C_{n,k}|H|C_{n,k}>$.
      69              : !!  $ghc(vectsize,blocksize)=<G|H|C_{n,k}> for a block of bands$.
      70              : !!  iterationnumber=number of iterative minimizations in LOBPCG
      71              : !!  kinpw(npw)=(modified) kinetic energy for each plane wave (Hartree)
      72              : !!  mpi_enreg=information about MPI parallelization
      73              : !!  nspinor=number of spinorial components of the wavefunctions (on current proc)
      74              : !!  $vect(vectsize,blocksize)=<G|H|C_{n,k}> for a block of bands$.
      75              : !!  npw=number of planewaves at this k point.
      76              : !!  optekin= 1 if the kinetic energy used in preconditionning is modified
      77              : !!             according to Kresse, Furthmuller, PRB 54, 11169 (1996) [[cite:Kresse1996]]
      78              : !!           0 otherwise
      79              : !!  optpcon= 0 the TPA preconditionning matrix does not depend on band
      80              : !!           1 the TPA preconditionning matrix (not modified)
      81              : !!           2 the TPA preconditionning matrix is independant of iterationnumber
      82              : !!  vectsize= size of vectors
      83              : !!
      84              : !! OUTPUT
      85              : !!  vect(2,npw)=<g|(h-eval)|c_{n,k}>*(polynomial ratio)
      86              : !!
      87              : !! SOURCE
      88              : 
      89        34551 : subroutine xprecon(cg,eval,blocksize,iterationnumber,kinpw,&
      90        34551 : &  mpi_enreg,npw,nspinor,optekin,optpcon,pcon,ghc,vect,vectsize,&
      91              : &  timopt,tim_xprecon) ! optional arguments
      92              : 
      93              : !Arguments ------------------------------------
      94              : !scalars
      95              :  integer,intent(in) :: blocksize,iterationnumber,npw,nspinor,optekin
      96              :  integer,intent(in) :: optpcon,vectsize
      97              :  integer, intent(in), optional :: timopt,tim_xprecon
      98              :  type(mpi_type),intent(in) :: mpi_enreg
      99              : !arrays
     100              :  real(dp),intent(inout) :: cg(vectsize,blocksize),eval(blocksize,blocksize)
     101              :  real(dp),intent(in) :: kinpw(npw)
     102              :  real(dp),intent(inout) :: ghc(vectsize,blocksize)
     103              :  real(dp),intent(inout) :: pcon(npw,blocksize),vect(vectsize,blocksize)
     104              : 
     105              : !Local variables-------------------------------
     106        34551 :  complex(dp),dimension(:,:),allocatable :: z_cg,z_eval,z_ghc,z_vect
     107              :  real(dp) :: tsec(2)
     108              : ! *********************************************************************
     109              : 
     110        34551 :  if (present(tim_xprecon).and.present(timopt)) then
     111        34551 :    if(abs(timopt)==3) then
     112            0 :     call timab(tim_xprecon,1,tsec)
     113              :    end if
     114              :  end if
     115              : 
     116        34551 :  if ( x_cplx == 1 ) then
     117              :    call cg_precon_block(cg,eval,blocksize,iterationnumber,kinpw,&
     118         2079 : &    npw,nspinor,mpi_enreg%me_g0,optekin,optpcon,pcon,ghc,vect,vectsize,mpi_enreg%comm_bandspinorfft)
     119              :  else
     120       129888 :    ABI_MALLOC(z_cg,(vectsize,blocksize))
     121       129888 :    ABI_MALLOC(z_eval,(blocksize,blocksize))
     122        97416 :    ABI_MALLOC(z_ghc,(vectsize,blocksize))
     123        97416 :    ABI_MALLOC(z_vect,(vectsize,blocksize))
     124              : 
     125        32472 :    call abi_xcopy(x_cplx*vectsize*blocksize,cg,1,z_cg,1)
     126        32472 :    call abi_xcopy(x_cplx*vectsize*blocksize,ghc,1,z_ghc,1)
     127        32472 :    call abi_xcopy(x_cplx*vectsize*blocksize,vect,1,z_vect,1)
     128        32472 :    call abi_xcopy(x_cplx*blocksize*blocksize,eval,1,z_eval,1)
     129              : 
     130              :    call cg_zprecon_block(z_cg,z_eval,blocksize,iterationnumber,kinpw,&
     131        32472 : &    npw,nspinor,optekin,optpcon,pcon,z_ghc,z_vect,vectsize,mpi_enreg%comm_bandspinorfft)
     132              : 
     133        32472 :    call abi_xcopy(x_cplx*vectsize*blocksize,z_cg,1,cg,1)
     134        32472 :    call abi_xcopy(x_cplx*vectsize*blocksize,z_ghc,1,ghc,1)
     135        32472 :    call abi_xcopy(x_cplx*vectsize*blocksize,z_vect,1,vect,1)
     136        32472 :    call abi_xcopy(x_cplx*blocksize*blocksize,z_eval,1,eval,1)
     137              : 
     138        32472 :    ABI_FREE(z_cg)
     139        32472 :    ABI_FREE(z_eval)
     140        32472 :    ABI_FREE(z_ghc)
     141        32472 :    ABI_FREE(z_vect)
     142              :  endif
     143              : 
     144        34551 :  if (present(tim_xprecon).and.present(timopt)) then
     145        34551 :    if(abs(timopt)==3) then
     146            0 :      call timab(tim_xprecon,2,tsec)
     147              :    end if
     148              :  end if
     149              : 
     150        34551 : end subroutine xprecon
     151              : !!***
     152              : 
     153              : !----------------------------------------------------------------------
     154              : 
     155              : END MODULE m_lobpcg
     156              : !!***
        

Generated by: LCOV version 2.3-1