2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2001 PWSCF group
|
|
|
|
! 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 .
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
2003-03-14 18:22:48 +08:00
|
|
|
subroutine readpp
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! Read pseudopotentials
|
|
|
|
!
|
|
|
|
#include "machine.h"
|
2004-01-06 18:53:30 +08:00
|
|
|
USE atom, ONLY: numeric, xmin, dx
|
|
|
|
USE us, ONLY: tvanp, iver
|
|
|
|
USE basis, ONLY: ntyp
|
|
|
|
USE varie, ONLY: newpseudo
|
|
|
|
USE funct, ONLY: iexch, icorr, igcx, igcc
|
|
|
|
USE io_files, ONLY: pseudo_dir, psfile
|
2003-03-14 18:22:48 +08:00
|
|
|
!
|
2004-01-06 18:53:30 +08:00
|
|
|
implicit none
|
|
|
|
character(len=256) :: file_pseudo
|
2003-01-20 05:58:50 +08:00
|
|
|
! file name complete with path
|
|
|
|
integer :: iunps, isupf, l, nt, ios, pseudo_type
|
2003-09-09 18:10:13 +08:00
|
|
|
integer :: iexch_, icorr_, igcx_, igcc_
|
2003-01-20 05:58:50 +08:00
|
|
|
external pseudo_type
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
iunps = 4
|
|
|
|
l = len_trim (pseudo_dir)
|
|
|
|
do nt = 1, ntyp
|
2004-01-06 02:11:01 +08:00
|
|
|
!
|
|
|
|
! iver, xmin, dx are not read from UPF format
|
|
|
|
!
|
|
|
|
iver(:,nt) = 0
|
|
|
|
xmin(nt) = 0.d0
|
|
|
|
dx(nt) = 0.d0
|
2003-01-20 05:58:50 +08:00
|
|
|
! add / if needed
|
2003-02-08 00:04:36 +08:00
|
|
|
if (pseudo_dir (l:l) .ne.'/') then
|
2003-09-23 22:45:12 +08:00
|
|
|
file_pseudo = pseudo_dir (1:l) //'/'//psfile (nt)
|
2003-02-08 00:04:36 +08:00
|
|
|
else
|
2003-09-23 22:45:12 +08:00
|
|
|
file_pseudo = pseudo_dir (1:l) //psfile (nt)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-08-21 00:16:26 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
open (unit = iunps, file = file_pseudo, status = 'old', form = &
|
|
|
|
'formatted', iostat = ios)
|
2003-06-18 22:58:40 +08:00
|
|
|
call errore ('readin', 'file '//trim(file_pseudo)//' not found', ios)
|
2003-02-08 00:04:36 +08:00
|
|
|
call read_pseudo (nt, iunps, isupf)
|
2003-08-21 00:16:26 +08:00
|
|
|
! The new pseudopotential UPF format is detected via the presence
|
|
|
|
! of the keyword '<PP_HEADER>' at the beginning of the file
|
2003-02-08 00:04:36 +08:00
|
|
|
if (isupf /= 0) then
|
|
|
|
rewind (unit = iunps)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! The type of the pseudopotential is determined by the file name:
|
|
|
|
! *.vdb or *.van Vanderbilt US pseudopotential code pseudo_type=1
|
|
|
|
! *.RRKJ3 Andrea's US new code pseudo_type=2
|
|
|
|
! none of the above: PWSCF norm-conserving format pseudo_type=0
|
|
|
|
!
|
2004-01-06 18:53:30 +08:00
|
|
|
if ( pseudo_type (psfile (nt) ) == 1 .or. &
|
|
|
|
pseudo_type (psfile (nt) ) == 2 ) then
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! The vanderbilt pseudopotential is always in numeric form
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
numeric (nt) = .true.
|
2003-01-20 05:58:50 +08:00
|
|
|
open (unit = iunps, file = file_pseudo, status = 'old', &
|
|
|
|
form = 'formatted', iostat = ios)
|
|
|
|
|
|
|
|
!
|
|
|
|
! newpseudo distinguishes beteween US pseudopotentials
|
2003-02-08 00:04:36 +08:00
|
|
|
! produced by Vanderbilt code and those produced
|
2003-01-20 05:58:50 +08:00
|
|
|
! by Andrea's atomic code.
|
|
|
|
!
|
2004-01-06 18:53:30 +08:00
|
|
|
if (pseudo_type (psfile (nt) ) == 1) then
|
2003-02-08 00:04:36 +08:00
|
|
|
newpseudo (nt) = .false.
|
|
|
|
tvanp (nt) = .true.
|
|
|
|
call readvan (nt, iunps)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2004-01-06 18:53:30 +08:00
|
|
|
if (pseudo_type (psfile (nt) ) == 2) then
|
2003-02-08 00:04:36 +08:00
|
|
|
newpseudo (nt) = .true.
|
2003-01-20 05:58:50 +08:00
|
|
|
! tvanp is read inside readnewvan
|
2003-02-08 00:04:36 +08:00
|
|
|
call readnewvan (nt, iunps)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
close (iunps)
|
|
|
|
else
|
|
|
|
tvanp (nt) = .false.
|
|
|
|
newpseudo (nt) = .false.
|
2003-01-20 05:58:50 +08:00
|
|
|
open (unit = iunps, file = file_pseudo, status = 'old', &
|
2003-06-18 22:58:40 +08:00
|
|
|
form='formatted', iostat = ios)
|
2003-01-20 05:58:50 +08:00
|
|
|
! numeric is read inside read_ncpp
|
2003-02-08 00:04:36 +08:00
|
|
|
call read_ncpp (nt, iunps)
|
|
|
|
close (iunps)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
else
|
2003-01-20 05:58:50 +08:00
|
|
|
! UPF is always numeric
|
2003-02-08 00:04:36 +08:00
|
|
|
numeric (nt) = .true.
|
2003-01-20 05:58:50 +08:00
|
|
|
! UPF is RRKJ3-like
|
2003-02-08 00:04:36 +08:00
|
|
|
newpseudo (nt) = .true.
|
|
|
|
close (iunps)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-09-09 18:10:13 +08:00
|
|
|
!
|
|
|
|
if (nt == 1) then
|
|
|
|
iexch_ = iexch
|
|
|
|
icorr_ = icorr
|
2004-01-06 18:53:30 +08:00
|
|
|
igcx_ = igcx
|
2003-09-09 18:10:13 +08:00
|
|
|
igcc_ = igcc
|
|
|
|
else
|
|
|
|
if ( iexch_ /= iexch .or. icorr_ /= icorr .or. &
|
2004-01-06 18:53:30 +08:00
|
|
|
igcx_ /= igcx .or. igcc_ /= igcc ) then
|
2003-09-09 18:10:13 +08:00
|
|
|
CALL errore( 'readpp','inconsistent DFT read',nt)
|
|
|
|
end if
|
|
|
|
end if
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine readpp
|
|
|
|
!-----------------------------------------------------------------------
|
2003-09-23 22:45:12 +08:00
|
|
|
integer function pseudo_type (psfile)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-09-23 22:45:12 +08:00
|
|
|
character (len=*) :: psfile
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: l
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-09-23 22:45:12 +08:00
|
|
|
l = len_trim (psfile)
|
2003-02-08 00:04:36 +08:00
|
|
|
pseudo_type = 0
|
2003-09-23 22:45:12 +08:00
|
|
|
if (psfile (l - 3:l) .eq.'.vdb'.or.psfile (l - 3:l) .eq.'.van') &
|
2003-01-20 05:58:50 +08:00
|
|
|
pseudo_type = 1
|
|
|
|
if (l > 5) then
|
2003-09-23 22:45:12 +08:00
|
|
|
if (psfile (l - 5:l) .eq.'.RRKJ3') pseudo_type = 2
|
2003-01-20 05:58:50 +08:00
|
|
|
end if
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
end function pseudo_type
|
|
|
|
|