The Elk Code
 
Loading...
Searching...
No Matches
readstulr.f90
Go to the documentation of this file.
1
2! Copyright (C) 2018 T. Mueller, J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6subroutine readstulr
7use modmain
8use modulr
9implicit none
10! local variables
11integer iq,jq,ifq,jfq
12integer idm,i1,i2,i3
13integer version_(3),ios
14integer natmtot_,npcmtmax_,ngtc_,ngtot_
15integer ndmag_,fsmtype_,nqpt_,nfqrz_
16complex(8) z1
17! automatic arrays
18complex(8) zv(natmtot)
19! allocatable arrays
20integer, allocatable :: ivq_(:,:),iqrzf_(:),map(:)
21complex(8), allocatable :: zfmt(:,:),zfir(:)
22open(100,file='STATE_ULR.OUT',form='UNFORMATTED',action='READ',status='OLD', &
23 iostat=ios)
24if (ios /= 0) then
25 write(*,*)
26 write(*,'("Error(readstulr): error opening STATE_ULR.OUT")')
27 write(*,*)
28 stop
29end if
30read(100) version_
31if (version_(1) < 10) then
32 write(*,*)
33 write(*,'("Error(readstulr): unable to read STATE_ULR.OUT from versions &
34 &earlier than 10.0.0")')
35 write(*,*)
36 stop
37end if
38if ((version(1) /= version_(1)).or.(version(2) /= version_(2)).or. &
39 (version(3) /= version_(3))) then
40 write(*,*)
41 write(*,'("Warning(readstulr): different versions")')
42 write(*,'(" current : ",I0,".",I0,".",I0)') version
43 write(*,'(" STATE_ULR.OUT : ",I0,".",I0,".",I0)') version_
44end if
45read(100) natmtot_
46if (natmtot /= natmtot_) then
47 write(*,*)
48 write(*,'("Error(readstulr): differing natmtot")')
49 write(*,'(" current : ",I6)') natmtot
50 write(*,'(" STATE_ULR.OUT : ",I6)') natmtot_
51 write(*,*)
52 stop
53end if
54read(100) npcmtmax_
55if (npcmtmax /= npcmtmax_) then
56 write(*,*)
57 write(*,'("Error(readstulr): differing npcmtmax")')
58 write(*,'(" current : ",I6)') npcmtmax
59 write(*,'(" STATE_ULR.OUT : ",I6)') npcmtmax_
60 write(*,*)
61 stop
62end if
63read(100) ngtc_
64if (ngtc /= ngtc_) then
65 write(*,*)
66 write(*,'("Error(readstulr): differing ngtc")')
67 write(*,'(" current : ",I8)') ngtc
68 write(*,'(" STATE_ULR.OUT : ",I8)') ngtc_
69 write(*,*)
70 stop
71end if
72read(100) ngtot_
73if (ngtot /= ngtot_) then
74 write(*,*)
75 write(*,'("Error(readstulr): differing ngtot")')
76 write(*,'(" current : ",I8)') ngtot
77 write(*,'(" STATE_ULR.OUT : ",I8)') ngtot_
78 write(*,*)
79 stop
80end if
81read(100) ndmag_
82if (ndmag /= ndmag_) then
83 write(*,*)
84 write(*,'("Error(readstulr): differing ndmag")')
85 write(*,'(" current : ",I1)') ndmag
86 write(*,'(" STATE_ULR.OUT : ",I1)') ndmag_
87 write(*,*)
88 stop
89end if
90read(100) fsmtype_
91if (fsmtype /= fsmtype_) then
92 write(*,*)
93 write(*,'("Error(readstulr): differing fsmtype")')
94 write(*,'(" current : ",I4)') fsmtype
95 write(*,'(" STATE_ULR.OUT : ",I4)') fsmtype_
96 write(*,*)
97 stop
98end if
99read(100) nqpt_
100if (nqpt_ < 1) then
101 write(*,*)
102 write(*,'("Error(readstulr): nqpt_ < 1 : ",I8)') nqpt_
103 write(*,*)
104 stop
105end if
106read(100) nfqrz_
107if (nfqrz_ < 1) then
108 write(*,*)
109 write(*,'("Error(readstulr): nfqrz_ < 1 : ",I8)') nfqrz_
110 write(*,*)
111 stop
112end if
113allocate(ivq_(3,nqpt_),iqrzf_(nfqrz_),map(nfqrz_))
114read(100) ivq_
115read(100) iqrzf_
116read(100) efermi
117! generate map from old Q-vector grid to new
118map(:)=0
119do ifq=1,nfqrz_
120 iq=iqrzf_(ifq)
121 i1=ivq_(1,iq); i2=ivq_(2,iq); i3=ivq_(3,iq)
122 if ((i1 >= intq(1,1)).and.(i1 <= intq(2,1)).and. &
123 (i2 >= intq(1,2)).and.(i2 <= intq(2,2)).and. &
124 (i3 >= intq(1,3)).and.(i3 <= intq(2,3))) then
125 jq=ivqiq(i1,i2,i3)
126 jfq=ifqrz(jq)
127 map(ifq)=jfq
128 end if
129end do
130deallocate(ivq_,iqrzf_)
131allocate(zfmt(npcmtmax,natmtot),zfir(ngtot))
132! read the Q-space density
133rhoqmt(:,:,:)=0.d0
134rhoqir(:,:)=0.d0
135do ifq=1,nfqrz_
136 jfq=map(ifq)
137 if (jfq > 0) then
138 read(100) rhoqmt(:,:,jfq)
139 read(100) rhoqir(:,jfq)
140 else
141 read(100) zfmt
142 read(100) zfir(1:ngtc)
143 end if
144end do
145! read the Q-space Kohn-Sham potential
146vsqmt(:,:,:)=0.d0
147vsqir(:,:)=0.d0
148do ifq=1,nfqrz_
149 jfq=map(ifq)
150 if (jfq > 0) then
151 read(100) vsqmt(:,:,jfq)
152 read(100) vsqir(:,jfq)
153 else
154 read(100) zfmt
155 read(100) zfir
156 end if
157end do
158! read the external Coulomb potential in Q-space
159vclq(:)=0.d0
160do ifq=1,nfqrz_
161 jfq=map(ifq)
162 if (jfq > 0) then
163 read(100) vclq(jfq)
164 else
165 read(100) z1
166 end if
167end do
168if (spinpol) then
169! read the Q-space magnetisation density
170 magqmt(:,:,:,:)=0.d0
171 magqir(:,:,:)=0.d0
172 do ifq=1,nfqrz_
173 jfq=map(ifq)
174 if (jfq > 0) then
175 do idm=1,ndmag
176 read(100) magqmt(:,:,idm,jfq)
177 read(100) magqir(:,idm,jfq)
178 end do
179 else
180 do idm=1,ndmag
181 read(100) zfmt
182 read(100) zfir(1:ngtc)
183 end do
184 end if
185 end do
186 bsqmt(:,:,:,:)=0.d0
187 bsqir(:,:,:)=0.d0
188 do ifq=1,nfqrz_
189 jfq=map(ifq)
190 if (jfq > 0) then
191 do idm=1,ndmag
192 read(100) bsqmt(:,:,idm,jfq)
193 read(100) bsqir(:,idm,jfq)
194 end do
195 else
196 do idm=1,ndmag
197 read(100) zfmt
198 read(100) zfir
199 end do
200 end if
201 end do
202! read the external magnetic fields in Q-space
203 bfcq(:,:)=0.d0
204 bfcmtq(:,:,:)=0.d0
205 do ifq=1,nfqrz_
206 jfq=map(ifq)
207 if (jfq > 0) then
208 do idm=1,ndmag
209 read(100) bfcq(idm,jfq)
210 read(100) bfcmtq(:,idm,jfq)
211 end do
212 else
213 do idm=1,ndmag
214 read(100) z1
215 read(100) zv
216 end do
217 end if
218 end do
219! read fixed spin moment effective fields
220 if (fsmtype /= 0) then
221 read(100) bfsmc
222 read(100) bfsmcmt
223 end if
224end if
225close(100)
226deallocate(map,zfmt,zfir)
227end subroutine
228
integer, dimension(2, 3) intq
Definition modmain.f90:517
integer ngtot
Definition modmain.f90:390
real(8) efermi
Definition modmain.f90:904
logical spinpol
Definition modmain.f90:228
integer fsmtype
Definition modmain.f90:251
real(8), dimension(:,:), allocatable bfsmcmt
Definition modmain.f90:263
integer, dimension(:,:,:), allocatable ivqiq
Definition modmain.f90:531
integer ngtc
Definition modmain.f90:392
real(8), dimension(3) bfsmc
Definition modmain.f90:257
integer, dimension(:), allocatable ifqrz
Definition modmain.f90:541
integer npcmtmax
Definition modmain.f90:216
integer, dimension(3), parameter version
Definition modmain.f90:1288
integer ndmag
Definition modmain.f90:238
complex(8), dimension(:), allocatable vclq
Definition modulr.f90:65
complex(8), dimension(:,:,:,:), pointer, contiguous bsqmt
Definition modulr.f90:84
complex(8), dimension(:,:), allocatable bfcq
Definition modulr.f90:70
complex(8), dimension(:,:,:), pointer, contiguous vsqmt
Definition modulr.f90:83
complex(8), dimension(:,:,:), allocatable magqir
Definition modulr.f90:60
complex(8), dimension(:,:,:), allocatable rhoqmt
Definition modulr.f90:59
complex(8), dimension(:,:,:), pointer, contiguous bsqir
Definition modulr.f90:84
complex(8), dimension(:,:), pointer, contiguous vsqir
Definition modulr.f90:83
complex(8), dimension(:,:,:,:), allocatable magqmt
Definition modulr.f90:60
complex(8), dimension(:,:), allocatable rhoqir
Definition modulr.f90:59
complex(8), dimension(:,:,:), allocatable bfcmtq
Definition modulr.f90:72
subroutine readstulr
Definition readstulr.f90:7