24integer is,ia,ias,lmmax,lm,ir,jr
25integer idm,jdm,mapidm(3),ios
26integer i1,i2,i3,j1,j2,j3,n
28integer nspecies_,natoms_,lmmaxo_
29integer nrmt_(maxspecies),nrmtmax_
30integer nrcmt_(maxspecies),nrcmtmax_
31integer ngridg_(3),ngtot_,ngvec_
32integer ndmag_,nspinor_,fsmtype_,ftmtype_
33integer dftu_,lmmaxdm_,xcgrad_
36integer,
allocatable :: mapir(:)
37real(8),
allocatable :: rsp_(:,:),rcmt_(:,:)
38real(8),
allocatable :: wcrmt_(:,:,:),wcrcmt_(:,:,:)
39real(8),
allocatable :: rfmt_(:,:,:),rfir_(:)
40real(8),
allocatable :: rvfmt_(:,:,:,:),rvfir_(:,:)
41real(8),
allocatable :: rvfcmt_(:,:,:,:),rfmt(:,:)
42real(8),
allocatable :: bfsmcmt_(:,:),fi(:),fo(:)
43complex(8),
allocatable :: vsig_(:)
44complex(8),
allocatable :: vmatmt_(:,:,:,:,:),vmftm_(:,:,:,:,:)
45open(100,file=
'STATE'//trim(
filext),form=
'UNFORMATTED',action=
'READ', &
46 status=
'OLD',iostat=ios)
49 write(*,
'("Error(readstate): error opening ",A)')
'STATE'//trim(
filext)
54if (version_(1) < 2)
then
56 write(*,
'("Error(readstate): unable to read STATE.OUT from versions earlier &
61if (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)
101if (spinpol_.and.(ndmag_ /= 1).and.(ndmag_ /= 3))
then
103 write(*,
'("Error(readstate): invalid ndmag in STATE.OUT : ",I8)') ndmag_
109if ((version_(1) > 2).or.(version_(2) >= 3))
then
116if ((version_(1) > 5).or.((version_(1) == 5).and.(version_(2) >= 1)))
then
121if ((version_(1) >= 10).or.((version_(1) == 9).and.(version_(2) >= 6)))
then
126ngtot_=ngridg_(1)*ngridg_(2)*ngridg_(3)
128allocate(mapir(
ngtot))
130 t1=dble(i3*ngridg_(3))/dble(
ngridg(3))
131 j3=modulo(nint(t1),ngridg_(3))
133 t1=dble(i2*ngridg_(2))/dble(
ngridg(2))
134 j2=modulo(nint(t1),ngridg_(2))
136 t1=dble(i1*ngridg_(1))/dble(
ngridg(1))
137 j1=modulo(nint(t1),ngridg_(1))
138 jr=j3*ngridg_(2)*ngridg_(1)+j2*ngridg_(1)+j1+1
145allocate(wcrmt_(12,nrmtmax_,
nspecies))
146allocate(wcrcmt_(12,nrcmtmax_,
nspecies))
148 call wspline(nrmt_(is),rsp_(:,is),wcrmt_(:,:,is))
149 call wspline(nrcmt_(is),rcmt_(:,is),wcrcmt_(:,:,is))
151allocate(rfmt_(lmmaxo_,nrmtmax_,
natmtot),rfir_(ngtot_))
170if ((version_(1) > 2).or.(version_(2) >= 2))
then
171 read(100) rfmt_,rfir_
173 allocate(vsig_(ngvec_))
174 read(100) rfmt_,rfir_,vsig_
185 if (
ndmag == ndmag_)
then
192 allocate(rvfmt_(lmmaxo_,nrmtmax_,
natmtot,ndmag_))
193 allocate(rvfir_(ngtot_,ndmag_))
194 allocate(rvfcmt_(lmmaxo_,nrcmtmax_,
natmtot,ndmag_))
195 read(100) rvfmt_,rvfir_
198 read(100) rvfmt_,rvfir_
201 read(100) rvfcmt_,rvfir_
208 deallocate(rvfmt_,rvfir_,rvfcmt_)
210 if (fsmtype_ /= 0)
then
234if (any(
xcgrad == [3,4,5,6]))
then
235 if (any(xcgrad_ == [3,4,5,6]))
then
236 read(100) rfmt_,rfir_
244deallocate(wcrmt_,wcrcmt_,rfmt_,rfir_,rfmt,fi,fo)
246if (((
dftu /= 0).and.(dftu_ /= 0)).or. &
247 ((
ftmtype /= 0).and.(ftmtype_ /= 0)))
then
248 allocate(vmatmt_(lmmaxdm_,nspinor_,lmmaxdm_,nspinor_,
natmtot))
253 vmatmt(1:lmmax,:,1:lmmax,:,:)=vmatmt_(1:lmmax,:,1:lmmax,:,:)
254 else if ((
nspinor == 1).and.(nspinor_ == 2))
then
255 vmatmt(1:lmmax,1,1:lmmax,1,:)=0.5d0*(vmatmt_(1:lmmax,1,1:lmmax,1,:) &
256 +vmatmt_(1:lmmax,2,1:lmmax,2,:))
258 vmatmt(1:lmmax,1,1:lmmax,1,:)=vmatmt_(1:lmmax,1,1:lmmax,1,:)
259 vmatmt(1:lmmax,2,1:lmmax,2,:)=vmatmt_(1:lmmax,1,1:lmmax,1,:)
264if ((
ftmtype /= 0).and.(ftmtype_ /= 0))
then
265 allocate(vmftm_(lmmaxdm_,nspinor_,lmmaxdm_,nspinor_,
natmtot))
268 vmftm_(:,:,:,:,:)=0.d0
270 vmftm(1:lmmax,:,1:lmmax,:,:)=vmftm_(1:lmmax,:,1:lmmax,:,:)
271 else if ((
nspinor == 1).and.(nspinor_ == 2))
then
272 vmftm(1:lmmax,1,1:lmmax,1,:)=0.5d0*(vmftm_(1:lmmax,1,1:lmmax,1,:) &
273 +vmftm_(1:lmmax,2,1:lmmax,2,:))
275 vmftm(1:lmmax,1,1:lmmax,1,:)=vmftm_(1:lmmax,1,1:lmmax,1,:)
276 vmftm(1:lmmax,2,1:lmmax,2,:)=vmftm_(1:lmmax,1,1:lmmax,1,:)
288real(8),
intent(out) :: rfmtp(npmtmax,natmtot)
293 fi(1:nrmt_(is))=rfmt_(lm,1:nrmt_(is),ias)
294 call rfinterp(nrmt_(is),rsp_(:,is),wcrmt_(:,:,is),fi,
nrmt(is),
rsp(:,is),fo)
306real(8),
intent(out) :: rvfmt(npmtmax,natmtot,ndmag)
316 fi(1:nrmt_(is))=rvfmt_(lm,1:nrmt_(is),ias,jdm)
317 call rfinterp(nrmt_(is),rsp_(:,is),wcrmt_(:,:,is),fi,
nrmt(is),
rsp(:,is), &
330real(8),
intent(out) :: rvfcmt(npcmtmax,natmtot,ndmag)
340 fi(1:nrcmt_(is))=rvfcmt_(lm,1:nrcmt_(is),ias,jdm)
341 call rfinterp(nrcmt_(is),rcmt_(:,is),wcrcmt_(:,:,is),fi,
nrcmt(is), &
354real(8),
intent(out) :: rvfir(ngtot,ndmag)
358 rvfir(1:ngtot,idm)=rvfir_(mapir(1:ngtot),jdm)
360 rvfir(1:ngtot,idm)=0.d0
real(8), dimension(:,:,:), allocatable bxcmt
real(8), dimension(:,:,:), pointer, contiguous magmt
real(8), dimension(:), pointer, contiguous rhoir
real(8), dimension(:,:), pointer, contiguous magir
real(8), dimension(:,:), pointer, contiguous vsmt
real(8), dimension(:,:), pointer, contiguous bsirc
real(8), dimension(:), pointer, contiguous vsirc
real(8), dimension(:,:,:), pointer, contiguous bsmt
real(8), dimension(:,:), pointer, contiguous rhomt