precondition_m_wfcts.f90 1.29 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
!
! Copyright (C) 2015-2016 M. Govoni 
! 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 precondition_m_wfcts (m,f,pf,eprec)
  !-----------------------------------------------------------------------
  !
  USE kinds,                 ONLY : DP
  USE wvfct,                 ONLY : g2kin
  USE noncollin_module,      ONLY : noncolin,npol
  USE pwcom,                 ONLY : npw,npwx
  !
  IMPLICIT NONE
  !
  ! I/O
  !
  INTEGER,INTENT(IN) :: m
  COMPLEX(DP),INTENT(IN) :: f(npwx*npol,m)
  COMPLEX(DP),INTENT(OUT) :: pf(npwx*npol,m)
  REAL(DP),INTENT(IN) :: eprec(m)
  !
  ! Workspace
  !
  INTEGER :: ibnd, ig
  !
  pf = 0._DP
  !
  DO ibnd=1,m
     !
!$OMP PARALLEL DO
     DO ig=1,npw 
        pf(ig,ibnd) = f(ig,ibnd) / MAX(1._DP,g2kin(ig)/eprec(ibnd))
     ENDDO
!$OMP END PARALLEL DO
     IF( noncolin ) THEN 
!$OMP PARALLEL DO
        DO ig=1,npw
           pf(npwx+ig,ibnd) = f(npwx+ig,ibnd) / MAX(1._DP,g2kin(ig)/eprec(ibnd))
        ENDDO
!$OMP END PARALLEL DO
     ENDIF
     !
  ENDDO
  !
END SUBROUTINE