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
|
|
|
!
|
2006-07-08 04:16:45 +08:00
|
|
|
USE kinds, ONLY : DP
|
2006-12-06 21:13:53 +08:00
|
|
|
USE ions_base, ONLY : nat, nsp, ityp, tau, if_pos
|
2006-07-08 04:16:45 +08:00
|
|
|
USE basis, ONLY : natomwfc
|
2006-08-23 01:01:13 +08:00
|
|
|
USE cell_base, ONLY : tpiba2, alat,omega, at, bg, ibrav
|
2006-07-08 04:16:45 +08:00
|
|
|
USE force_mod, ONLY : force
|
|
|
|
USE klist, ONLY : nkstot, nks, xk, wk
|
|
|
|
USE lsda_mod, ONLY : lsda, nspin, current_spin, isk
|
|
|
|
USE wvfct, ONLY : nbnd, nbndx, et, wg, npwx
|
|
|
|
USE symme, ONLY : irt, nsym, ftau, s
|
|
|
|
USE ktetra, ONLY : tetra, ntetra
|
|
|
|
USE extfield, ONLY : forcefield, tefield
|
|
|
|
USE cellmd, ONLY : cell_factor, lmovecell
|
|
|
|
USE gvect, ONLY : gg, ecutwfc, ngm, g, nr1, nr2, nr3, nrxx,&
|
|
|
|
nrx1, nrx2, nrx3, eigts1, eigts2, eigts3, &
|
|
|
|
nl, gstart
|
|
|
|
USE gsmooth, ONLY : ngms, nls, nrx1s, nr1s, nr2s, nr3s
|
2006-09-13 22:38:46 +08:00
|
|
|
USE spin_orb, ONLY : so, lspinorb
|
2007-11-19 04:25:11 +08:00
|
|
|
USE scf, ONLY : rho, rho_core, rhog_core, v
|
2006-07-08 04:16:45 +08:00
|
|
|
USE wavefunctions_module, ONLY : psic
|
|
|
|
USE vlocal, ONLY : strf
|
|
|
|
USE io_files, ONLY : tmp_dir, prefix, iunpun, nwordwfc, iunwfc
|
2007-02-21 21:01:31 +08:00
|
|
|
USE buffers, ONLY : open_buffer, close_buffer
|
2007-10-06 16:23:39 +08:00
|
|
|
USE uspp_param, ONLY : upf
|
2006-07-08 04:16:45 +08:00
|
|
|
USE noncollin_module, ONLY : noncolin, npol
|
|
|
|
USE mp_global, ONLY : kunit
|
|
|
|
USE pw_restart, ONLY : pw_readfile
|
|
|
|
USE xml_io_base, ONLY : pp_check_file
|
|
|
|
USE uspp, ONLY : okvan
|
2007-11-13 00:20:55 +08:00
|
|
|
USE paw_variables, ONLY : okpaw
|
2007-11-12 22:49:09 +08:00
|
|
|
USE paw_init, ONLY : paw_init_onecenter, allocate_paw_internals
|
2007-11-19 04:25:11 +08:00
|
|
|
USE ldaU, ONLY : eth
|
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-08-09 16:20:53 +08:00
|
|
|
INTEGER :: i, is, ik, ibnd, nb, nt, ios, isym, ierr
|
2006-03-14 01:21:46 +08:00
|
|
|
REAL(DP) :: rdum(1,1), ehart, etxc, vtxc, etotefield, charge
|
2006-08-09 16:20:53 +08:00
|
|
|
REAL(DP) :: sr(3,3,48)
|
2006-03-14 01:21:46 +08:00
|
|
|
LOGICAL :: exst
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
!
|
2006-06-07 10:01:57 +08:00
|
|
|
! ... first we check if the file can be used for post-processing
|
|
|
|
!
|
|
|
|
IF ( .NOT. pp_check_file() ) &
|
2006-06-08 22:52:26 +08:00
|
|
|
CALL infomsg( 'read_file', 'file ' // TRIM( tmp_dir ) // TRIM( prefix ) &
|
2007-06-27 00:46:01 +08:00
|
|
|
& // '.save not guaranteed to be safe for post-processing' )
|
2006-06-07 10:01:57 +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-09-14 17:55:56 +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
|
|
|
!
|
|
|
|
! ... 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 eigenvalues and weights (read from file)
|
|
|
|
!
|
|
|
|
nbndx = nbnd
|
|
|
|
ALLOCATE( et( nbnd, nkstot ) , wg( nbnd, nkstot ) )
|
|
|
|
!
|
|
|
|
CALL pw_readfile( 'nowave', ierr )
|
|
|
|
!
|
2007-02-19 19:16:43 +08:00
|
|
|
! ... distribute across pools k-points and related variables.
|
|
|
|
! ... nks is defined by the following routine as the number
|
|
|
|
!yy ... of k-points in the current pool
|
2007-02-19 00:39:14 +08:00
|
|
|
!
|
|
|
|
CALL divide_et_impera( xk, wk, isk, lsda, nkstot, nks )
|
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
CALL poolscatter( nbnd, nkstot, et, nks, et )
|
|
|
|
CALL poolscatter( nbnd, nkstot, wg, nks, wg )
|
|
|
|
!
|
2007-02-19 19:16:43 +08:00
|
|
|
! ... check on symmetry
|
|
|
|
!
|
2007-02-19 00:39:14 +08:00
|
|
|
IF (nat > 0) CALL checkallsym( nsym, s, nat, tau, &
|
2006-10-02 17:37:35 +08:00
|
|
|
ityp, at, bg, nr1, nr2, nr3, irt, ftau, alat, omega )
|
2006-03-14 01:21:46 +08:00
|
|
|
!
|
|
|
|
! ... read pseudopotentials
|
|
|
|
!
|
|
|
|
CALL pw_readfile( 'pseudo', ierr )
|
|
|
|
!
|
|
|
|
CALL readpp()
|
|
|
|
!
|
The following pseudopotential-related variables in module uspp_param:
zp, psd, dion, betar, jjj, qqq, qfunc, qfcoef, vloc_at, rinner,
nbeta, kkbeta, nqf, nqlc, lll, tvanp
have been replaced by the corresponding variables in structure 'upf'.
There shouldn't be any side effects, but who knows. There is still a
copy of the above variables that will be removed sooner or later.
Basically : variable([i,j,k,..,]n) => upf(n)%variable [(i,j,k,..)]
Note that upf%qfunc has for the time being three indices instead of two,
and that upf%kkbeta is the analogous of kkbeta and not what it used to be.
The logic of this operation will be clearer when it will be completed
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4308 c92efa57-630b-4861-b058-cf58834340f0
2007-10-05 17:26:23 +08:00
|
|
|
okvan = ANY ( upf(:)%tvanp )
|
2007-11-13 00:20:55 +08:00
|
|
|
okpaw = ANY ( upf(1:nsp)%tpawp )
|
2006-03-14 01:21:46 +08:00
|
|
|
!
|
|
|
|
! ... check for spin-orbit pseudopotentials
|
2006-01-05 00:42:23 +08:00
|
|
|
!
|
|
|
|
DO nt = 1, nsp
|
|
|
|
!
|
2007-10-06 16:23:39 +08:00
|
|
|
so(nt) = upf(nt)%has_so
|
2006-01-05 00:42:23 +08:00
|
|
|
!
|
|
|
|
END DO
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2006-12-06 21:13:53 +08:00
|
|
|
IF ( .NOT. lspinorb ) CALL average_pp ( nsp )
|
2006-09-13 22:38:46 +08:00
|
|
|
!
|
2007-02-19 19:16:43 +08:00
|
|
|
! ... allocate memory for G- and R-space fft arrays
|
|
|
|
!
|
|
|
|
CALL allocate_fft()
|
|
|
|
CALL ggen()
|
|
|
|
!
|
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()
|
2007-11-06 01:11:28 +08:00
|
|
|
IF (okpaw) THEN
|
|
|
|
CALL allocate_paw_internals()
|
2007-11-12 22:49:09 +08:00
|
|
|
CALL paw_init_onecenter()
|
2007-11-06 01:11:28 +08:00
|
|
|
CALL errore('read_file','post-processing paw routines not yet available',1)
|
|
|
|
ENDIF
|
2005-08-30 04:29:22 +08:00
|
|
|
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-07-08 04:16:45 +08:00
|
|
|
! ... bring rho to G-space
|
|
|
|
!
|
|
|
|
DO is = 1, nspin
|
|
|
|
!
|
2007-11-01 19:19:31 +08:00
|
|
|
psic(:) = rho%of_r(:,is)
|
2006-07-08 04:16:45 +08:00
|
|
|
!
|
|
|
|
CALL cft3( psic, nr1, nr2, nr3, nrx1, nrx2, nrx3, -1 )
|
|
|
|
!
|
2007-11-02 21:39:38 +08:00
|
|
|
rho%of_g(:,is) = psic(nl(:))
|
2006-07-08 04:16:45 +08:00
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
2006-03-14 01:21:46 +08:00
|
|
|
! ... recalculate the potential
|
|
|
|
!
|
2007-11-14 00:46:11 +08:00
|
|
|
CALL v_of_rho( rho, rho_core, rhog_core, &
|
2007-11-19 04:25:11 +08:00
|
|
|
ehart, etxc, vtxc, eth, etotefield, charge, v )
|
2006-03-14 01:21:46 +08:00
|
|
|
!
|
|
|
|
! ... reads the wavefunctions and writes them in 'distributed' form
|
|
|
|
! ... to unit iunwfc (for compatibility)
|
|
|
|
!
|
2007-02-21 21:01:31 +08:00
|
|
|
nwordwfc = nbnd*npwx*npol
|
2006-03-14 01:21:46 +08:00
|
|
|
!
|
2007-02-21 21:01:31 +08:00
|
|
|
CALL open_buffer ( iunwfc, 'wfc', nwordwfc, nks, exst )
|
2006-03-14 01:21:46 +08:00
|
|
|
!
|
|
|
|
CALL pw_readfile( 'wave', ierr )
|
|
|
|
!
|
2007-02-21 21:01:31 +08:00
|
|
|
CALL close_buffer ( iunwfc, 'KEEP' )
|
2006-03-14 01:21:46 +08:00
|
|
|
!
|
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
|
|
|
|
!
|
|
|
|
!
|
|
|
|
! ... 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
|
|
|
|
!
|
|
|
|
END SUBROUTINE set_dimensions
|
|
|
|
!
|
2004-11-04 21:35:00 +08:00
|
|
|
END SUBROUTINE read_file
|