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 : ",I0)') natmtot
50  write(*,'(" STATE_ULR.OUT : ",I0)') 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 : ",I0)') npcmtmax
59  write(*,'(" STATE_ULR.OUT : ",I0)') 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 : ",I0)') ngtc
68  write(*,'(" STATE_ULR.OUT : ",I0)') 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 : ",I0)') ngtot
77  write(*,'(" STATE_ULR.OUT : ",I0)') 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 : ",I0)') ndmag
86  write(*,'(" STATE_ULR.OUT : ",I0)') 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 : ",I0)') fsmtype
95  write(*,'(" STATE_ULR.OUT : ",I0)') 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 : ",I0)') 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 : ",I0)') 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)).or.(i1 > intq(2,1)).or. &
123  (i2 < intq(1,2)).or.(i2 > intq(2,2)).or. &
124  (i3 < intq(1,3)).or.(i3 > intq(2,3))) cycle
125  jq=ivqiq(i1,i2,i3)
126  jfq=ifqrz(jq)
127  map(ifq)=jfq
128 end do
129 deallocate(ivq_,iqrzf_)
130 allocate(zfmt(npcmtmax,natmtot),zfir(ngtot))
131 ! read the Q-space density
132 rhoqmt(:,:,:)=0.d0
133 rhoqir(:,:)=0.d0
134 do ifq=1,nfqrz_
135  jfq=map(ifq)
136  if (jfq > 0) then
137  read(100) rhoqmt(:,:,jfq)
138  read(100) rhoqir(:,jfq)
139  else
140  read(100) zfmt
141  read(100) zfir(1:ngtc)
142  end if
143 end do
144 ! read the Q-space Kohn-Sham potential
145 vsqmt(:,:,:)=0.d0
146 vsqir(:,:)=0.d0
147 do ifq=1,nfqrz_
148  jfq=map(ifq)
149  if (jfq > 0) then
150  read(100) vsqmt(:,:,jfq)
151  read(100) vsqir(:,jfq)
152  else
153  read(100) zfmt
154  read(100) zfir
155  end if
156 end do
157 ! read the external Coulomb potential in Q-space
158 vclq(:)=0.d0
159 do ifq=1,nfqrz_
160  jfq=map(ifq)
161  if (jfq > 0) then
162  read(100) vclq(jfq)
163  else
164  read(100) z1
165  end if
166 end do
167 if (spinpol) then
168 ! read the Q-space magnetisation density
169  magqmt(:,:,:,:)=0.d0
170  magqir(:,:,:)=0.d0
171  do ifq=1,nfqrz_
172  jfq=map(ifq)
173  if (jfq > 0) then
174  do idm=1,ndmag
175  read(100) magqmt(:,:,idm,jfq)
176  read(100) magqir(:,idm,jfq)
177  end do
178  else
179  do idm=1,ndmag
180  read(100) zfmt
181  read(100) zfir(1:ngtc)
182  end do
183  end if
184  end do
185  bsqmt(:,:,:,:)=0.d0
186  bsqir(:,:,:)=0.d0
187  do ifq=1,nfqrz_
188  jfq=map(ifq)
189  if (jfq > 0) then
190  do idm=1,ndmag
191  read(100) bsqmt(:,:,idm,jfq)
192  read(100) bsqir(:,idm,jfq)
193  end do
194  else
195  do idm=1,ndmag
196  read(100) zfmt
197  read(100) zfir
198  end do
199  end if
200  end do
201 ! read the external magnetic fields in Q-space
202  bfcq(:,:)=0.d0
203  bfcmtq(:,:,:)=0.d0
204  do ifq=1,nfqrz_
205  jfq=map(ifq)
206  if (jfq > 0) then
207  do idm=1,ndmag
208  read(100) bfcq(idm,jfq)
209  read(100) bfcmtq(:,idm,jfq)
210  end do
211  else
212  do idm=1,ndmag
213  read(100) z1
214  read(100) zv
215  end do
216  end if
217  end do
218 ! read fixed spin moment effective fields
219  if (fsmtype /= 0) then
220  read(100) bfsmc
221  read(100) bfsmcmt
222  end if
223 end if
224 close(100)
225 deallocate(map,zfmt,zfir)
226 end subroutine
227 
subroutine readstulr
Definition: readstulr.f90:7
complex(8), dimension(:,:,:), pointer, contiguous vsqmt
Definition: modulr.f90:82
real(8) efermi
Definition: modmain.f90:903
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:82
integer ndmag
Definition: modmain.f90:238
real(8), dimension(3) bfsmc
Definition: modmain.f90:257
complex(8), dimension(:,:,:,:), allocatable magqmt
Definition: modulr.f90:59
complex(8), dimension(:,:,:), pointer, contiguous bsqir
Definition: modulr.f90:83
complex(8), dimension(:,:,:), allocatable magqir
Definition: modulr.f90:59
complex(8), dimension(:), allocatable vclq
Definition: modulr.f90:64
integer, dimension(:,:,:), allocatable ivqiq
Definition: modmain.f90:531
complex(8), dimension(:,:,:,:), pointer, contiguous bsqmt
Definition: modulr.f90:83
integer, dimension(2, 3) intq
Definition: modmain.f90:517
complex(8), dimension(:,:,:), allocatable bfcmtq
Definition: modulr.f90:71
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:1283
complex(8), dimension(:,:,:), allocatable rhoqmt
Definition: modulr.f90:58
complex(8), dimension(:,:), allocatable bfcq
Definition: modulr.f90:69
Definition: modulr.f90:6
integer fsmtype
Definition: modmain.f90:251
complex(8), dimension(:,:), allocatable rhoqir
Definition: modulr.f90:58