24 integer is,ia,ias,lmmax,lm,ir,jr
25 integer idm,jdm,mapidm(3),ios
26 integer i1,i2,i3,j1,j2,j3,n
28 integer nspecies_,natoms_,lmmaxo_
29 integer nrmt_(maxspecies),nrmtmax_
30 integer nrcmt_(maxspecies),nrcmtmax_
31 integer ngridg_(3),ngtot_,ngvec_
32 integer ndmag_,nspinor_,fsmtype_,ftmtype_
33 integer dftu_,lmmaxdm_,xcgrad_
36 integer,
allocatable :: mapir(:)
37 real(8),
allocatable :: rsp_(:,:),rcmt_(:,:)
38 real(8),
allocatable :: wcrmt_(:,:,:),wcrcmt_(:,:,:)
39 real(8),
allocatable :: rfmt_(:,:,:),rfir_(:)
40 real(8),
allocatable :: rvfmt_(:,:,:,:),rvfir_(:,:)
41 real(8),
allocatable :: rvfcmt_(:,:,:,:),rfmt(:,:)
42 real(8),
allocatable :: bfsmcmt_(:,:),fi(:),fo(:)
43 complex(8),
allocatable :: vsig_(:)
44 complex(8),
allocatable :: vmatmt_(:,:,:,:,:),vmftm_(:,:,:,:,:)
45 open(100,file=
'STATE'//trim(
filext),form=
'UNFORMATTED',action=
'READ', &
46 status=
'OLD',iostat=ios)
49 write(*,
'("Error(readstate): error opening ",A)')
'STATE'//trim(
filext)
54 if (version_(1) < 2)
then 56 write(*,
'("Error(readstate): unable to read STATE.OUT from versions earlier & 61 if (any(
version(:) /= version_(:)))
then 63 write(*,
'("Warning(readstate): different versions")')
64 write(*,
'(" current : ",I0,".",I0,".",I0)')
version 65 write(*,
'(" STATE.OUT : ",I0,".",I0,".",I0)') version_
71 write(*,
'("Error(readstate): differing nspecies")')
72 write(*,
'(" current : ",I4)')
nspecies 73 write(*,
'(" STATE.OUT : ",I4)') nspecies_
85 if (
natoms(is) /= natoms_)
then 87 write(*,
'("Error(readstate): differing natoms for species ",I4)') is
88 write(*,
'(" current : ",I4)')
natoms(is)
89 write(*,
'(" STATE.OUT : ",I4)') natoms_
94 read(100) rsp_(1:nrmt_(is),is)
96 read(100) rcmt_(1:nrcmt_(is),is)
101 if (spinpol_.and.(ndmag_ /= 1).and.(ndmag_ /= 3))
then 103 write(*,
'("Error(readstate): invalid ndmag in STATE.OUT : ",I8)') ndmag_
109 if (version_(1) > 2)
then 116 if ((version_(1) > 5).or.((version_(1) == 5).and.(version_(2) > 0)))
then 121 if ((version_(1) > 9).or.((version_(1) == 9).and.(version_(2) > 5)))
then 126 if ((version_(1) > 10).or.((version_(1) == 10).and.(version_(2) > 6)))
then 129 ngtot_=ngridg_(1)*ngridg_(2)*ngridg_(3)
131 allocate(mapir(
ngtot))
133 t1=dble(i3*ngridg_(3))/dble(
ngridg(3))
134 j3=modulo(nint(t1),ngridg_(3))
136 t1=dble(i2*ngridg_(2))/dble(
ngridg(2))
137 j2=modulo(nint(t1),ngridg_(2))
139 t1=dble(i1*ngridg_(1))/dble(
ngridg(1))
140 j1=modulo(nint(t1),ngridg_(1))
141 jr=j3*ngridg_(2)*ngridg_(1)+j2*ngridg_(1)+j1+1
148 allocate(wcrmt_(12,nrmtmax_,
nspecies))
149 allocate(wcrcmt_(12,nrcmtmax_,
nspecies))
151 call wspline(nrmt_(is),rsp_(:,is),wcrmt_(:,:,is))
152 call wspline(nrcmt_(is),rcmt_(:,is),wcrcmt_(:,:,is))
154 allocate(rfmt_(lmmaxo_,nrmtmax_,
natmtot),rfir_(ngtot_))
157 allocate(fi(n),fo(n))
159 read(100) rfmt_,rfir_
165 read(100) rfmt_,rfir_
169 read(100) rfmt_,rfir_
173 if (version_(1) > 2)
then 174 read(100) rfmt_,rfir_
176 allocate(vsig_(ngvec_))
177 read(100) rfmt_,rfir_,vsig_
188 if (
ndmag == ndmag_)
then 195 allocate(rvfmt_(lmmaxo_,nrmtmax_,
natmtot,ndmag_))
196 allocate(rvfir_(ngtot_,ndmag_))
197 allocate(rvfcmt_(lmmaxo_,nrcmtmax_,
natmtot,ndmag_))
198 read(100) rvfmt_,rvfir_
201 read(100) rvfmt_,rvfir_
204 read(100) rvfcmt_,rvfir_
211 deallocate(rvfmt_,rvfir_,rvfcmt_)
213 if (fsmtype_ /= 0)
then 237 if (any(
xcgrad == [3,4,5,6]))
then 238 if (any(xcgrad_ == [3,4,5,6]))
then 239 read(100) rfmt_,rfir_
247 deallocate(wcrmt_,wcrcmt_,rfmt_,rfir_,rfmt,fi,fo)
249 if (((
dftu /= 0).and.(dftu_ /= 0)).or. &
250 ((
ftmtype /= 0).and.(ftmtype_ /= 0)))
then 251 allocate(vmatmt_(lmmaxdm_,nspinor_,lmmaxdm_,nspinor_,
natmtot))
256 vmatmt(1:lmmax,:,1:lmmax,:,:)=vmatmt_(1:lmmax,:,1:lmmax,:,:)
257 else if ((
nspinor == 1).and.(nspinor_ == 2))
then 258 vmatmt(1:lmmax,1,1:lmmax,1,:)=0.5d0*(vmatmt_(1:lmmax,1,1:lmmax,1,:) &
259 +vmatmt_(1:lmmax,2,1:lmmax,2,:))
261 vmatmt(1:lmmax,1,1:lmmax,1,:)=vmatmt_(1:lmmax,1,1:lmmax,1,:)
262 vmatmt(1:lmmax,2,1:lmmax,2,:)=vmatmt_(1:lmmax,1,1:lmmax,1,:)
267 if ((
ftmtype /= 0).and.(ftmtype_ /= 0))
then 268 allocate(vmftm_(lmmaxdm_,nspinor_,lmmaxdm_,nspinor_,
natmtot))
271 vmftm_(:,:,:,:,:)=0.d0
273 vmftm(1:lmmax,:,1:lmmax,:,:)=vmftm_(1:lmmax,:,1:lmmax,:,:)
274 else if ((
nspinor == 1).and.(nspinor_ == 2))
then 275 vmftm(1:lmmax,1,1:lmmax,1,:)=0.5d0*(vmftm_(1:lmmax,1,1:lmmax,1,:) &
276 +vmftm_(1:lmmax,2,1:lmmax,2,:))
278 vmftm(1:lmmax,1,1:lmmax,1,:)=vmftm_(1:lmmax,1,1:lmmax,1,:)
279 vmftm(1:lmmax,2,1:lmmax,2,:)=vmftm_(1:lmmax,1,1:lmmax,1,:)
287 subroutine rgfmt(rfmtp)
290 real(8),
intent(out) :: rfmtp(npmtmax,natmtot)
295 fi(1:nrmt_(is))=rfmt_(lm,1:nrmt_(is),ias)
296 call rfinterp(nrmt_(is),rsp_(:,is),wcrmt_(:,:,is),fi,
nrmt(is),
rsp(:,is),fo)
308 real(8),
intent(out) :: rvfmt(npmtmax,natmtot,ndmag)
318 fi(1:nrmt_(is))=rvfmt_(lm,1:nrmt_(is),ias,jdm)
319 call rfinterp(nrmt_(is),rsp_(:,is),wcrmt_(:,:,is),fi,
nrmt(is),
rsp(:,is), &
332 real(8),
intent(out) :: rvfcmt(npcmtmax,natmtot,ndmag)
342 fi(1:nrcmt_(is))=rvfcmt_(lm,1:nrcmt_(is),ias,jdm)
343 call rfinterp(nrcmt_(is),rcmt_(:,is),wcrcmt_(:,:,is),fi,
nrcmt(is), &
353 subroutine rgvir(rvfir)
356 real(8),
intent(out) :: rvfir(ngtot,ndmag)
360 rvfir(1:ngtot,idm)=rvfir_(mapir(1:ngtot),jdm)
362 rvfir(1:ngtot,idm)=0.d0
real(8), dimension(:,:), allocatable rcmt
real(8), dimension(:), allocatable wxcir
integer, dimension(3) ngridg
real(8), dimension(:,:), allocatable vxcmt
real(8), dimension(:), pointer, contiguous rhoir
integer, parameter lmmaxdm
integer, dimension(maxatoms, maxspecies) idxas
real(8), dimension(:,:), allocatable vclmt
real(8), dimension(:,:), pointer, contiguous rhomt
real(8), dimension(3) bfsmc
subroutine rfinterp(ni, xi, wci, fi, no, xo, fo)
real(8), dimension(:), allocatable vsir
real(8), dimension(3) momfix
real(8), dimension(:), allocatable vxcir
real(8), dimension(:,:), allocatable wxcmt
subroutine wspline(n, x, wc)
subroutine rgvfcmt(rvfcmt)
real(8), dimension(:,:,:), allocatable bxcmt
real(8), dimension(:,:), allocatable bsir
real(8), dimension(:,:,:), pointer, contiguous magmt
pure subroutine rfmtpack(tpack, nr, nri, rfmt1, rfmt2)
real(8), dimension(:), allocatable vclir
complex(8), dimension(:,:,:,:,:), allocatable vmatmt
real(8), dimension(3, maxatoms, maxspecies) mommtfix
real(8), dimension(:,:), allocatable bxcir
complex(8), dimension(:,:,:,:,:), allocatable vmftm
real(8), dimension(:), pointer, contiguous vsirc
integer, dimension(maxspecies) natoms
integer, dimension(maxatoms *maxspecies) idxis
real(8), dimension(:,:), allocatable bfsmcmt
integer, dimension(3), parameter version
real(8), dimension(:,:), pointer, contiguous magir
real(8), dimension(:,:), allocatable rsp
integer, dimension(maxspecies) nrcmt
integer, dimension(maxspecies) nrcmti
pure subroutine r3vo(x, y)
real(8), dimension(:,:), pointer, contiguous bsirc
real(8), dimension(:,:), pointer, contiguous vsmt
integer, dimension(maxspecies) nrmti
subroutine rfirftoc(rfir, rfirc)
real(8), dimension(:,:,:), pointer, contiguous bsmt
integer, dimension(maxspecies) nrmt