readwfc.f90 2.32 KB
Newer Older
sponce's avatar
sponce committed
1 2 3 4 5 6 7 8 9
  !                                                                            
  ! Copyright (C) 2010-2016 Samuel Ponce', Roxana Margine, Carla Verdi, Feliciano Giustino 
  ! Copyright (C) 2007-2009 Jesse Noffsinger, Brad Malone, Feliciano Giustino  
  !                                                                            
  ! 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 .             
  !                                                                            
  !--------------------------------------------------------
Samuel Poncé's avatar
Samuel Poncé committed
10
  SUBROUTINE readwfc( ipool, recn, evc0 )
sponce's avatar
sponce committed
11 12 13 14 15 16 17 18
  !--------------------------------------------------------
  !
  !  open wfc files as direct access, read, and close again
  !
  ! RM - Nov/Dec 2014
  ! Imported the noncolinear case implemented by xlzhang
  !
  !-------------------------------------------------------------
Samuel Poncé's avatar
Samuel Poncé committed
19 20 21 22 23 24 25
#if defined (__ALPHA)
#  define DIRECT_IO_FACTOR 2
# else
#  define DIRECT_IO_FACTOR 8
#endif
  !
  USE kinds,    ONLY : DP
sponce's avatar
sponce committed
26
  USE io_files, ONLY : prefix, tmp_dir
27
  USE units_lr, ONLY : lrwfc, iuwfc
sponce's avatar
sponce committed
28
  USE wvfct,    ONLY : npwx
sponce's avatar
sponce committed
29
  USE pwcom,    ONLY : nbnd
Samuel Poncé's avatar
Samuel Poncé committed
30 31
  USE noncollin_module, ONLY : npol
  USE mp_global,        ONLY : nproc_pool, me_pool, npool
sponce's avatar
sponce committed
32
  !
Samuel Poncé's avatar
Samuel Poncé committed
33
  IMPLICIT NONE
sponce's avatar
sponce committed
34
  !
Samuel Poncé's avatar
Samuel Poncé committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48
  INTEGER, INTENT(in) :: recn
  !! kpoint number
  INTEGER, INTENT(in) :: ipool
  !! poolfile number to be read (not used in serial case)
  !
  COMPLEX(DP), INTENT(out) :: evc0(npwx*npol,nbnd)
  !! wavefunction is read from file
  !
  ! Local variables
  !
  INTEGER :: unf_recl, ios
  CHARACTER(len=256) :: tempfile
  CHARACTER(len=3) :: nd_nmbr0
  ! file number for shuffle
sponce's avatar
sponce committed
49 50 51
  !
  !  open the wfc file, read and close
  !
Samuel Poncé's avatar
Samuel Poncé committed
52
  CALL set_ndnmbr( ipool, me_pool, nproc_pool, npool, nd_nmbr0 )
sponce's avatar
sponce committed
53
  !
54
#if defined(__MPI)
sponce's avatar
sponce committed
55 56 57 58 59 60
  tempfile = trim(tmp_dir) // trim(prefix) // '.wfc' // nd_nmbr0
# else
  tempfile = trim(tmp_dir) // trim(prefix) // '.wfc'
#endif
  unf_recl = DIRECT_IO_FACTOR * lrwfc
  !
Samuel Poncé's avatar
Samuel Poncé committed
61 62 63 64 65
  OPEN(iuwfc, file = tempfile, form = 'unformatted', &
       access = 'direct', iostat = ios, recl = unf_recl)
  IF (ios /= 0) CALL errore('readwfc', 'error opening wfc file', iuwfc)
  READ (iuwfc, rec = recn) evc0
  CLOSE(iuwfc, status = 'keep')
sponce's avatar
sponce committed
66
  !
Samuel Poncé's avatar
Samuel Poncé committed
67
  RETURN
sponce's avatar
sponce committed
68
  !
Samuel Poncé's avatar
Samuel Poncé committed
69
  END SUBROUTINE readwfc