The Elk Code
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 
6 subroutine readstulr
7 use modmain
8 use modulr
9 implicit none
10 ! local variables
11 integer iq,jq,ifq,jfq
12 integer idm,i1,i2,i3
13 integer version_(3),ios
14 integer natmtot_,npcmtmax_,ngtc_,ngtot_
15 integer ndmag_,fsmtype_,nqpt_,nfqrz_
16 complex(8) z1
17 ! automatic arrays
18 complex(8) zv(natmtot)
19 ! allocatable arrays
20 integer, allocatable :: ivq_(:,:),iqrzf_(:),map(:)
21 complex(8), allocatable :: zfmt(:,:),zfir(:)
22 open(100,file='STATE_ULR.OUT',form='UNFORMATTED',action='READ',status='OLD', &
23  iostat=ios)
24 if (ios /= 0) then
25  write(*,*)
26  write(*,'("Error(readstulr): error opening STATE_ULR.OUT")')
27  write(*,*)
28  stop
29 end if
30 read(100) version_
31 if (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
37 end if
38 if ((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_
44 end if
45 read(100) natmtot_
46 if (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
53 end if
54 read(100) npcmtmax_
55 if (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
62 end if
63 read(100) ngtc_
64 if (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
71 end if
72 read(100) ngtot_
73 if (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
80 end if
81 read(100) ndmag_
82 if (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
89 end if
90 read(100) fsmtype_
91 if (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
98 end if
99 read(100) nqpt_
100 if (nqpt_ < 1) then
101  write(*,*)
102  write(*,'("Error(readstulr): nqpt_ < 1 : ",I8)') nqpt_
103  write(*,*)
104  stop
105 end if
106 read(100) nfqrz_
107 if (nfqrz_ < 1) then
108  write(*,*)
109  write(*,'("Error(readstulr): nfqrz_ < 1 : ",I8)') nfqrz_
110  write(*,*)
111  stop
112 end if
113 allocate(ivq_(3,nqpt_),iqrzf_(nfqrz_),map(nfqrz_))
114 read(100) ivq_
115 read(100) iqrzf_
116 read(100) efermi
117 ! generate map from old Q-vector grid to new
118 map(:)=0
119 do 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
129 end do
130 deallocate(ivq_,iqrzf_)
131 allocate(zfmt(npcmtmax,natmtot),zfir(ngtot))
132 ! read the Q-space density
133 rhoqmt(:,:,:)=0.d0
134 rhoqir(:,:)=0.d0
135 do 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
144 end do
145 ! read the Q-space Kohn-Sham potential
146 vsqmt(:,:,:)=0.d0
147 vsqir(:,:)=0.d0
148 do 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
157 end do
158 ! read the external Coulomb potential in Q-space
159 vclq(:)=0.d0
160 do 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
167 end do
168 if (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
224 end if
225 close(100)
226 deallocate(map,zfmt,zfir)
227 end subroutine
228 
subroutine readstulr
Definition: readstulr.f90:7
complex(8), dimension(:,:,:), pointer, contiguous vsqmt
Definition: modulr.f90:84
real(8) efermi
Definition: modmain.f90:907
integer npcmtmax
Definition: modmain.f90:216
integer ngtot
Definition: modmain.f90:390
integer ngtc
Definition: modmain.f90:392
logical spinpol
Definition: modmain.f90:228
complex(8), dimension(:,:), pointer, contiguous vsqir
Definition: modulr.f90:84
integer ndmag
Definition: modmain.f90:238
real(8), dimension(3) bfsmc
Definition: modmain.f90:257
complex(8), dimension(:,:,:,:), allocatable magqmt
Definition: modulr.f90:61
complex(8), dimension(:,:,:), pointer, contiguous bsqir
Definition: modulr.f90:85
complex(8), dimension(:,:,:), allocatable magqir
Definition: modulr.f90:61
complex(8), dimension(:), allocatable vclq
Definition: modulr.f90:66
integer, dimension(:,:,:), allocatable ivqiq
Definition: modmain.f90:531
complex(8), dimension(:,:,:,:), pointer, contiguous bsqmt
Definition: modulr.f90:85
integer, dimension(2, 3) intq
Definition: modmain.f90:517
complex(8), dimension(:,:,:), allocatable bfcmtq
Definition: modulr.f90:73
real(8), dimension(:,:), allocatable bfsmcmt
Definition: modmain.f90:263
integer, dimension(:), allocatable ifqrz
Definition: modmain.f90:541
integer, dimension(3), parameter version
Definition: modmain.f90:1289
complex(8), dimension(:,:,:), allocatable rhoqmt
Definition: modulr.f90:60
complex(8), dimension(:,:), allocatable bfcq
Definition: modulr.f90:71
Definition: modulr.f90:6
integer fsmtype
Definition: modmain.f90:251
complex(8), dimension(:,:), allocatable rhoqir
Definition: modulr.f90:60