2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
! Copyright (C) 2001-2005 Quantum-ESPRESSO group
|
2003-01-20 05:58:50 +08:00
|
|
|
! 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 .
|
|
|
|
!
|
2004-06-26 01:25:37 +08:00
|
|
|
#include "f_defs.h"
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
!----------------------------------------------------------------------------
|
|
|
|
SUBROUTINE read_file()
|
|
|
|
!----------------------------------------------------------------------------
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
! ... This routine allocates space for all quantities already computed
|
|
|
|
! ... in the pwscf program and reads them from the data file.
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-11-04 21:35:00 +08:00
|
|
|
USE kinds, ONLY : DP
|
2005-08-30 04:29:22 +08:00
|
|
|
USE ions_base, ONLY : nat, nsp, ityp, tau, if_pos
|
2004-11-04 21:35:00 +08:00
|
|
|
USE basis, ONLY : natomwfc
|
2006-02-25 01:46:50 +08:00
|
|
|
USE cell_base, ONLY : tpiba2, alat,omega, at, bg
|
2004-11-04 21:35:00 +08:00
|
|
|
USE force_mod, ONLY : force
|
|
|
|
USE klist, ONLY : nkstot, nks, xk, wk
|
|
|
|
USE lsda_mod, ONLY : lsda, nspin, current_spin, isk
|
2006-03-14 01:21:46 +08:00
|
|
|
USE wvfct, ONLY : nbnd, nbndx, et, wg, npwx
|
2005-12-13 22:45:35 +08:00
|
|
|
USE symme, ONLY : irt, nsym, ftau, s
|
2004-11-04 21:35:00 +08:00
|
|
|
USE ktetra, ONLY : tetra, ntetra
|
|
|
|
USE extfield, ONLY : forcefield, tefield
|
|
|
|
USE cellmd, ONLY : cell_factor, lmovecell
|
2006-02-25 01:46:50 +08:00
|
|
|
USE gvect, ONLY : gg, ecutwfc, ngm, g, nr1, nr2, nr3, nrxx,&
|
|
|
|
nrx1, nrx2, nrx3, eigts1, eigts2, eigts3, &
|
|
|
|
nl, gstart
|
2004-11-04 21:35:00 +08:00
|
|
|
USE gsmooth, ONLY : ngms, nls, nrx1s, nr1s, nr2s, nr3s
|
2006-01-05 00:42:23 +08:00
|
|
|
USE spin_orb, ONLY : so
|
2006-02-25 01:46:50 +08:00
|
|
|
USE scf, ONLY : rho, rho_core, vr
|
2004-11-04 21:35:00 +08:00
|
|
|
USE vlocal, ONLY : strf
|
2006-03-14 01:21:46 +08:00
|
|
|
USE io_files, ONLY : tmp_dir, prefix, iunpun, nwordwfc, iunwfc
|
2006-01-19 23:44:56 +08:00
|
|
|
USE uspp_param, ONLY : nbeta, jjj, tvanp
|
2004-06-14 23:22:24 +08:00
|
|
|
USE noncollin_module, ONLY : noncolin, npol
|
2004-11-04 21:35:00 +08:00
|
|
|
USE mp_global, ONLY : kunit
|
2005-08-30 04:29:22 +08:00
|
|
|
USE pw_restart, ONLY : pw_readfile
|
2006-01-19 23:44:56 +08:00
|
|
|
USE uspp, ONLY : okvan
|
2004-06-12 21:44:18 +08:00
|
|
|
!
|
2004-11-04 21:35:00 +08:00
|
|
|
IMPLICIT NONE
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
INTEGER :: i, ik, ibnd, nb, nt, ios, ierr
|
|
|
|
REAL(DP) :: rdum(1,1), ehart, etxc, vtxc, etotefield, charge
|
|
|
|
LOGICAL :: exst
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
! ... here we read the variables that dimension the system
|
|
|
|
! ... in parallel execution, only root proc reads the file
|
|
|
|
! ... and then broadcasts the values to all other procs
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2006-01-19 01:20:40 +08:00
|
|
|
! ... a reset of the internal flags is necessary because some codes call
|
2005-12-13 22:45:35 +08:00
|
|
|
! ... read_file() more than once
|
|
|
|
!
|
|
|
|
CALL pw_readfile( 'reset', ierr )
|
|
|
|
CALL pw_readfile( 'dim', ierr )
|
|
|
|
!
|
|
|
|
CALL errore( 'read_file ', 'problem reading file ' // &
|
2006-03-14 17:23:11 +08:00
|
|
|
& TRIM( tmp_dir ) // TRIM( prefix ) // '.save', ierr )
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
|
|
|
! ... allocate space for atomic positions, symmetries, forces, tetrahedra
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2006-02-02 01:56:16 +08:00
|
|
|
IF ( nat <= 0 ) &
|
2005-08-30 04:29:22 +08:00
|
|
|
CALL errore( 'read_file', 'wrong number of atoms', 1 )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
! ... allocation
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
ALLOCATE( ityp( nat ) )
|
|
|
|
!
|
|
|
|
ALLOCATE( tau( 3, nat ) )
|
|
|
|
ALLOCATE( if_pos( 3, nat ) )
|
|
|
|
ALLOCATE( force( 3, nat ) )
|
|
|
|
!
|
|
|
|
IF ( tefield ) ALLOCATE( forcefield( 3, nat ) )
|
|
|
|
!
|
2005-12-18 05:21:19 +08:00
|
|
|
ALLOCATE( irt( 48, nat ) )
|
|
|
|
ALLOCATE( tetra( 4, MAX( ntetra, 1 ) ) )
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
|
|
|
! ... here we read all the variables defining the system
|
|
|
|
! ... in parallel execution, only root proc read the file
|
2005-12-13 22:45:35 +08:00
|
|
|
! ... and then broadcast the values to all other procs
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
2006-01-31 00:17:30 +08:00
|
|
|
!-------------------------------------------------------------------------------
|
2006-03-14 01:21:46 +08:00
|
|
|
! ... XML punch-file
|
2006-01-31 00:17:30 +08:00
|
|
|
!-------------------------------------------------------------------------------
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
CALL set_dimensions()
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
|
|
|
! ... parallel execution: distribute across pools k-points and
|
2006-03-14 01:21:46 +08:00
|
|
|
! ... related variables (not a smart implementation):
|
2005-08-30 04:29:22 +08:00
|
|
|
! ... nks and nkstot are redefined by the following routine
|
|
|
|
!
|
|
|
|
CALL divide_et_impera( xk, wk, isk, lsda, nkstot, nks )
|
|
|
|
!
|
|
|
|
! ... check whether LSDA
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
IF ( lsda ) THEN
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
nspin = 2
|
2005-08-30 04:29:22 +08:00
|
|
|
npol = 1
|
|
|
|
!
|
|
|
|
ELSE IF ( noncolin ) THEN
|
|
|
|
!
|
|
|
|
nspin = 4
|
|
|
|
npol = 2
|
|
|
|
current_spin = 1
|
|
|
|
!
|
2004-11-04 21:35:00 +08:00
|
|
|
ELSE
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
|
|
|
nspin = 1
|
|
|
|
npol = 1
|
2003-02-08 00:04:36 +08:00
|
|
|
current_spin = 1
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
cell_factor = 1.D0
|
|
|
|
lmovecell = .FALSE.
|
|
|
|
!
|
|
|
|
! ... allocate memory for G- and R-space fft arrays
|
|
|
|
!
|
|
|
|
CALL allocate_fft()
|
|
|
|
CALL ggen()
|
|
|
|
!
|
|
|
|
! ... allocate memory for eigenvalues and weights (read from file)
|
|
|
|
!
|
|
|
|
nbndx = nbnd
|
|
|
|
ALLOCATE( et( nbnd, nkstot ) , wg( nbnd, nkstot ) )
|
|
|
|
!
|
|
|
|
CALL pw_readfile( 'nowave', ierr )
|
|
|
|
!
|
|
|
|
CALL poolscatter( nbnd, nkstot, et, nks, et )
|
|
|
|
CALL poolscatter( nbnd, nkstot, wg, nks, wg )
|
|
|
|
!
|
|
|
|
CALL checkallsym( nsym, s, nat, tau, &
|
|
|
|
ityp, at, bg, nr1, nr2, nr3, irt, ftau )
|
|
|
|
!
|
|
|
|
! ... read pseudopotentials
|
|
|
|
!
|
|
|
|
CALL pw_readfile( 'pseudo', ierr )
|
|
|
|
!
|
|
|
|
CALL readpp()
|
|
|
|
!
|
|
|
|
okvan = ANY ( tvanp(1:nsp) )
|
|
|
|
!
|
|
|
|
! ... check for spin-orbit pseudopotentials
|
2006-01-05 00:42:23 +08:00
|
|
|
!
|
|
|
|
DO nt = 1, nsp
|
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
so(nt) = ( nbeta(nt) > 0 )
|
2006-01-05 00:42:23 +08:00
|
|
|
!
|
|
|
|
DO nb = 1, nbeta(nt)
|
|
|
|
!
|
|
|
|
so(nt) = so(nt) .AND. ( ABS( jjj(nb,nt) ) > 1.D-7 )
|
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
END DO
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
! ... allocate the potential and wavefunctions
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
CALL allocate_locpot()
|
|
|
|
CALL allocate_nlpot()
|
|
|
|
CALL allocate_wfc()
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
! ... read the charge density
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
CALL pw_readfile( 'rho', ierr )
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
|
|
|
! ... re-calculate the local part of the pseudopotential vltot
|
|
|
|
! ... and the core correction charge (if any) - This is done here
|
|
|
|
! ... for compatibility with the previous version of read_file
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
CALL init_vloc()
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-30 04:29:22 +08:00
|
|
|
CALL struc_fact( nat, tau, nsp, ityp, ngm, g, bg, &
|
|
|
|
nr1, nr2, nr3, strf, eigts1, eigts2, eigts3 )
|
|
|
|
!
|
|
|
|
CALL setlocal()
|
|
|
|
!
|
|
|
|
CALL set_rhoc()
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
! ... recalculate the potential
|
|
|
|
!
|
|
|
|
CALL v_of_rho( rho, rho_core, nr1, nr2, nr3, nrx1, nrx2, nrx3, &
|
|
|
|
nrxx, nl, ngm, gstart, nspin, g, gg, alat, omega, &
|
|
|
|
ehart, etxc, vtxc, etotefield, charge, vr )
|
|
|
|
!
|
|
|
|
! ... reads the wavefunctions and writes them in 'distributed' form
|
|
|
|
! ... to unit iunwfc (for compatibility)
|
|
|
|
!
|
|
|
|
nwordwfc = 2*nbnd*npwx*npol
|
|
|
|
!
|
|
|
|
CALL diropn( iunwfc, 'wfc', nwordwfc, exst )
|
|
|
|
!
|
|
|
|
CALL pw_readfile( 'wave', ierr )
|
|
|
|
!
|
|
|
|
CLOSE( UNIT = iunwfc, STATUS = 'KEEP' )
|
|
|
|
!
|
2004-11-04 21:35:00 +08:00
|
|
|
RETURN
|
2005-08-30 04:29:22 +08:00
|
|
|
!
|
|
|
|
CONTAINS
|
|
|
|
!
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
SUBROUTINE set_dimensions()
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
USE constants, ONLY : pi
|
|
|
|
USE cell_base, ONLY : alat, tpiba, tpiba2
|
|
|
|
USE gvect, ONLY : ecutwfc, dual, gcutm
|
|
|
|
USE gsmooth, ONLY : gcutms, doublegrid
|
|
|
|
USE klist, ONLY : nks, nkstot
|
|
|
|
!
|
|
|
|
!
|
|
|
|
! ... Set the units in real and reciprocal space
|
|
|
|
!
|
|
|
|
tpiba = 2.D0 * pi / alat
|
|
|
|
tpiba2 = tpiba**2
|
|
|
|
!
|
|
|
|
! ... Compute the cut-off of the G vectors
|
|
|
|
!
|
|
|
|
gcutm = dual * ecutwfc / tpiba2
|
|
|
|
!
|
|
|
|
doublegrid = ( dual > 4.D0 )
|
|
|
|
!
|
|
|
|
IF ( doublegrid ) THEN
|
|
|
|
!
|
|
|
|
gcutms = 4.D0 * ecutwfc / tpiba2
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
gcutms = gcutm
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
nks = nkstot
|
|
|
|
!
|
|
|
|
END SUBROUTINE set_dimensions
|
|
|
|
!
|
2004-11-04 21:35:00 +08:00
|
|
|
END SUBROUTINE read_file
|