set_eprec.f90 1.42 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
!
Marco Govoni's avatar
Marco Govoni committed
2
! Copyright (C) 2015-2019 M. Govoni 
Marco Govoni's avatar
Marco Govoni committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
! This file is part of WEST.
!
! Contributors to this file: 
! Marco Govoni
!
!-----------------------------------------------------------------------
SUBROUTINE set_eprec(m,wfc,eprec)
  !-----------------------------------------------------------------------
  !
  ! Set eprec, for precondiconditioning
  !
  USE kinds,                 ONLY : DP
  USE wvfct,                 ONLY : g2kin
  USE noncollin_module,      ONLY : noncolin,npol
  USE pwcom,                 ONLY : npw,npwx
  USE mp,                    ONLY : mp_sum
  USE mp_global,             ONLY : intra_bgrp_comm
  !
Victor Yu's avatar
Victor Yu committed
26
27
  IMPLICIT NONE
  !
Marco Govoni's avatar
Marco Govoni committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  ! I/O
  !
  INTEGER,INTENT(IN) :: m
  COMPLEX(DP),INTENT(IN) :: wfc(npwx*npol,m)
  REAL(DP),INTENT(OUT) :: eprec(m)
  !
  ! Workspace
  !
  INTEGER :: ibnd, ig 
  !
  eprec = 0._DP
  !
  DO ibnd = 1, m
     !
     DO ig = 1, npw
        eprec(ibnd) = eprec(ibnd) + CONJG( wfc(ig,ibnd) ) * wfc(ig,ibnd) * g2kin(ig)
     ENDDO
     !
     IF (noncolin) THEN 
        DO ig = 1, npw
           eprec(ibnd) = eprec(ibnd) + CONJG( wfc(ig+npwx,ibnd) ) * wfc(ig+npwx,ibnd) * g2kin(ig)
        ENDDO
     ENDIF 
     !
  ENDDO
  !
  CALL mp_sum(eprec,intra_bgrp_comm)
  !
  eprec = eprec * 1.35_DP
  !
END SUBROUTINE