The Elk Code
readinput.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2008 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 !BOP
7 ! !ROUTINE: readinput
8 ! !INTERFACE:
9 subroutine readinput
10 ! !USES:
11 use modmain
12 use moddftu
13 use modrdm
14 use modphonon
15 use modtest
16 use modrandom
17 use modpw
18 use modtddft
19 use modulr
20 use modvars
21 use modgw
22 use modbog
23 use modw90
24 use modtdhfc
25 use modmpi
26 use modomp
27 use modramdisk
28 ! !DESCRIPTION:
29 ! Reads in the input parameters from the file {\tt elk.in}. Also sets default
30 ! values for the input parameters.
31 !
32 ! !REVISION HISTORY:
33 ! Created September 2002 (JKD)
34 !EOP
35 !BOC
36 implicit none
37 ! local variables
38 logical lv
39 integer is,ia,ias,ios
40 integer i,j,k,l
41 real(8) sc,sc1,sc2,sc3
42 real(8) scx,scy,scz
43 real(8) scu,scu1,scu2,scu3
44 real(8) solscf,zn
45 real(8) axang(4),rot(3,3)
46 real(8) rndavec,v(3),t1
47 character(256) block,symb,str
48 
49 !------------------------!
50 ! default values !
51 !------------------------!
52 ntasks=0
53 avec(:,:)=0.d0
54 avec(1,1)=1.d0
55 avec(2,2)=1.d0
56 avec(3,3)=1.d0
57 davec(:,:)=0.d0
58 sc=1.d0
59 sc1=1.d0
60 sc2=1.d0
61 sc3=1.d0
62 scx=1.d0
63 scy=1.d0
64 scz=1.d0
65 epslat=1.d-6
66 primcell=.false.
67 tshift=.true.
68 ngridk(:)=1
69 dngridk(:)=0
70 vkloff(:)=0.d0
71 autokpt=.false.
72 radkpt=40.d0
73 reducek=1
74 ngridq(:)=-1
75 reduceq=1
76 rgkmax=7.d0
77 drgkmax=0.d0
78 gmaxvr=12.d0
79 dgmaxvr=0.d0
80 lmaxapw=8
81 dlmaxapw=0
82 lmaxo=6
83 dlmaxo=0
84 lmaxi=1
85 fracinr=0.01d0
86 trhonorm=.true.
87 xctype(1)=3
88 xctype(2:3)=0
89 xctsp(1)=3
90 xctsp(2:3)=0
91 ktype(1)=52
92 ktype(2:3)=0
93 stype=3
94 swidth=0.001d0
95 autoswidth=.false.
96 mstar=10.d0
97 epsocc=1.d-10
98 epschg=1.d-3
99 nempty0=4.d0
100 dnempty0=0.d0
101 maxscl=200
102 mixtype=3
103 mixsave=.false.
104 amixpm(1)=0.05d0
105 amixpm(2)=1.d0
106 ! Broyden parameters recommended by M. Meinert
107 mixsdb=5
108 broydpm(1)=0.4d0
109 broydpm(2)=0.15d0
110 mixrho=.false.
111 epspot=1.d-6
112 epsengy=1.d-4
113 epsforce=5.d-3
114 epsstress=2.d-3
115 molecule=.false.
116 nspecies=0
117 natoms(:)=0
118 atposl(:,:,:)=0.d0
119 datposl(:,:,:)=0.d0
120 atposc(:,:,:)=0.d0
121 bfcmt0(:,:,:)=0.d0
122 sppath=''
123 scrpath=''
124 nvp1d=2
125 if (allocated(vvlp1d)) deallocate(vvlp1d)
126 allocate(vvlp1d(3,nvp1d))
127 vvlp1d(:,1)=0.d0
128 vvlp1d(:,2)=1.d0
129 npp1d=200
130 ip01d=1
131 vclp2d(:,:)=0.d0
132 vclp2d(1,1)=1.d0
133 vclp2d(2,2)=1.d0
134 np2d(:)=40
135 vclp3d(:,:)=0.d0
136 vclp3d(1,1)=1.d0
137 vclp3d(2,2)=1.d0
138 vclp3d(3,3)=1.d0
139 np3d(:)=20
140 nwplot=500
141 ngrkf=100
142 nswplot=1
143 wplot(1)=-0.5d0
144 wplot(2)=0.5d0
145 dosocc=.false.
146 tpdos=.true.
147 dosmsum=.false.
148 dosssum=.false.
149 lmirep=.true.
150 spinpol=.false.
151 spinorb=.false.
152 socscf=1.d0
153 bforb=.false.
154 bfdmag=.false.
155 atpopt=1
156 maxatpstp=200
157 tau0atp=0.2d0
158 deltast=0.005d0
159 avecref(:,:)=0.d0
160 latvopt=0
161 maxlatvstp=30
162 tau0latv=0.2d0
163 lradstp=4
164 chgexs=0.d0
165 dchgexs=0.d0
166 scissor=0.d0
167 noptcomp=1
168 ! list of all optical tensor components
169 do k=1,3; do j=1,3; do i=1,3
170  l=(k-1)*9+(j-1)*3+i
171  optcomp(:,l)=[i,j,k]
172 end do; end do; end do
173 optcomp(:,1)=1
174 intraband=.false.
175 epsband=1.d-12
176 demaxbnd=2.5d0
177 autolinengy=.false.
178 dlefe=-0.1d0
179 autodlefe=.true.
180 deapw=0.2d0
181 delorb=0.05d0
182 bfieldc0(:)=0.d0
183 dbfieldc0(:)=0.d0
184 efieldc(:)=0.d0
185 dmaxefc=1.d6
186 afieldc(:)=0.d0
187 dafieldc(:)=0.d0
188 afspc(:,:)=0.d0
189 dafspc(:,:)=0.d0
190 fsmtype=0
191 momfix(:)=0.d0
192 momfixm=0.d0
193 dmomfix(:)=0.d0
194 mommtfix(:,:,:)=1.d6
195 mommtfixm(:,:)=-1.d0
196 taufsm=0.01d0
197 rmtdelta=0.05d0
198 isgkmax=-1
199 symtype=1
200 deltaph=0.01d0
201 nphwrt=1
202 if (allocated(vqlwrt)) deallocate(vqlwrt)
203 allocate(vqlwrt(3,nphwrt))
204 vqlwrt(:,:)=0.d0
205 notelns=0
206 tforce=.false.
207 maxitoep=400
208 tau0oep=0.1d0
209 nkstlist=1
210 kstlist(:,1)=1
211 vklem(:)=0.d0
212 deltaem=0.025d0
213 ndspem=1
214 nosource=.false.
215 spinsprl=.false.
216 ssdph=.true.
217 vqlss(:)=0.d0
218 dvqlss(:)=0.d0
219 nwrite=0
220 dftu=0
221 inpdftu=1
222 ndftu=0
223 ujdu(:,:)=0.d0
224 fdu(:,:)=0.d0
225 edu(:,:)=0.d0
226 lamdu(:)=0.d0
227 udufix(:)=0.d0
228 dudufix(:)=0.d0
229 tmwrite=.false.
230 rdmxctype=2
231 rdmmaxscl=2
232 maxitn=200
233 maxitc=0
234 taurdmn=0.5d0
235 taurdmc=0.25d0
236 rdmalpha=0.656d0
237 rdmtemp=0.d0
238 reducebf=1.d0
239 ptnucl=.true.
240 tefvr=.true.
241 tefvit=.false.
242 nefvit=2
243 vecql(:)=0.d0
244 mustar=0.15d0
245 sqaxis(1:2)=0.d0
246 sqaxis(3)=1.d0
247 test=.false.
248 spincore=.false.
249 solscf=1.d0
250 emaxelnes=-1.2d0
251 wsfac(1)=-1.1d6; wsfac(2)=1.1d6
252 vhmat(:,:)=0.d0
253 vhmat(1,1)=1.d0
254 vhmat(2,2)=1.d0
255 vhmat(3,3)=1.d0
256 reduceh=.true.
257 hybrid0=.false.
258 hybridc=1.d0
259 ecvcut=-3.5d0
260 esccut=-0.4d0
261 gmaxrf=3.d0
262 mbwgrf=-1
263 emaxrf=1.d6
264 ntemp=40
265 nvbse0=2
266 ncbse0=3
267 nvxbse=0
268 ncxbse=0
269 bsefull=.false.
270 hxbse=.true.
271 hdbse=.true.
272 fxctype=-1
273 fxclrc(1)=0.d0
274 fxclrc(2)=0.d0
275 rndatposc=0.d0
276 rndbfcmt=0.d0
277 rndavec=0.d0
278 c_tb09=0.d0
279 tc_tb09=.false.
280 hmaxvr=20.d0
281 hkmax=12.d0
282 lorbcnd=.false.
283 lorbordc=3
284 nrmtscf=1.d0
285 dnrmtscf=0.d0
286 lmaxdb=3
287 epsdev=0.0025d0
288 npmae0=-1
289 wrtvars=.false.
290 ftmtype=0
291 ntmfix=0
292 tauftm=0.1d0
293 cmagz=.false.
294 axang(:)=0.d0
295 dncgga=1.d-8
296 tstime=1000.d0
297 dtimes=0.1d0
298 npulse=0
299 nramp=0
300 nstep=0
301 ntswrite(1)=500
302 ntswrite(2)=1
303 nxoapwlo=0
304 nxlo=0
305 tdrho1d=.false.
306 tdrho2d=.false.
307 tdrho3d=.false.
308 tdmag1d=.false.
309 tdmag2d=.false.
310 tdmag3d=.false.
311 tdjr1d=.false.
312 tdjr2d=.false.
313 tdjr3d=.false.
314 tddos=.false.
315 tdlsj=.false.
316 tdjtk=.false.
317 tdxrmk=.false.
318 rndevt0=0.d0
319 sxcscf=1.d0
320 dsxcscf=0.d0
321 avecu(:,:)=0.d0
322 avecu(1,1)=1.d0
323 avecu(2,2)=1.d0
324 avecu(3,3)=1.d0
325 scu=1.d0
326 scu1=1.d0
327 scu2=1.d0
328 scu3=1.d0
329 q0cut=0.d0
330 ngridkpa(:)=-1
331 rndbfcu=0.d0
332 bfieldcu(:)=0.d0
333 efieldcu(:)=0.d0
334 tplotq0=.true.
335 trdvclr=.false.
336 trdbfcr=.false.
337 wmaxgw=-10.d0
338 tsediag=.false.
339 actype=10
340 npole=3
341 nspade=100
342 tfav0=.true.
343 rmtscf=1.d0
344 mrmtav=0
345 rmtall=-1.d0
346 maxthd=0
347 maxthd1=0
348 maxthdmkl=0
349 maxlvl=4
350 tdphi=0.d0
351 thetamld=45.d0*pi/180.d0
352 ntsbackup=0
353 ! Wannier90 variables
354 seedname='wannier'
355 num_wann=0
356 num_bands=0
357 num_iter=500
358 dis_num_iter=500
359 trial_step=1.d-3
360 nxlwin=0
361 wrtunk=.false.
362 tbdip=.false.
363 tjr=.false.
364 tauefm=0.01d0
365 epsefm=1.d-6
366 ehfb=1.d0
367 t0gclq0=.false.
368 tafindt=.false.
369 afindpm(:)=0.d0
370 afindpm(2)=1.d0
371 nkspolar=4
372 ntsforce=100
373 wphcut=1.d-6
374 ephscf(1)=8.d0
375 ephscf(2)=0.02d0
376 anomalous=.false.
377 tephde=.false.
378 bdiag=.false.
379 ecutb=0.001d0
380 ediag=.false.
381 pwxpsn=2
382 ramdisk=.true.
383 wrtdisk=.true.
384 epsdmat=1.d-8
385 tm3vdl=.false.
386 batch=.false.
387 tafspt=.false.
388 tbaspat=.false.
389 trdatdv=.false.
390 atdfc=0.d0
391 maxforce=-1.d0
392 msmgmt=0
393 ntsorth=1000
394 deltabf=0.5d0
395 jtconst0=.false.
396 trmt0=.true.
397 ksgwrho=.false.
398 npfftg=4
399 npfftgc=4
400 npfftq=4
401 npfftw=4
402 tphnat=.false.
403 ecutthc=0.01d0
404 tbdipu=.false.
405 bdipscf=1.d0
406 
407 !--------------------------!
408 ! read from elk.in !
409 !--------------------------!
410 open(50,file='elk.in',status='OLD',form='FORMATTED',iostat=ios)
411 if (ios /= 0) then
412  write(*,*)
413  write(*,'("Error(readinput): error opening elk.in")')
414  write(*,*)
415  stop
416 end if
417 10 continue
418 read(50,*,end=30) block
419 ! check for a comment
420 if ((block(1:1) == '!').or.(block(1:1) == '#')) goto 10
421 select case(trim(block))
422 case('tasks')
423  do i=1,maxtasks
424  read(50,'(A)',err=20) str
425  if (trim(str) == '') then
426  if (i == 1) then
427  write(*,*)
428  write(*,'("Error(readinput): no tasks to perform")')
429  write(*,*)
430  stop
431  end if
432  ntasks=i-1
433  goto 10
434  end if
435  read(str,*,iostat=ios) tasks(i)
436  if (ios /= 0) then
437  write(*,*)
438  write(*,'("Error(readinput): error reading tasks")')
439  write(*,'("(blank line required after tasks block)")')
440  write(*,*)
441  stop
442  end if
443  end do
444  write(*,*)
445  write(*,'("Error(readinput): too many tasks")')
446  write(*,'("Adjust maxtasks in modmain and recompile code")')
447  write(*,*)
448  stop
449 case('species')
450 ! generate a species file
451  call genspecies(50)
452 case('fspecies')
453 ! generate fractional species files
454  do is=1,maxspecies
455  read(50,'(A)',err=20) str
456  if (trim(str) == '') goto 10
457  read(str,*,iostat=ios) zn,symb
458  if (ios /= 0) then
459  write(*,*)
460  write(*,'("Error(readinput): error reading fractional species")')
461  write(*,'("(blank line required after fspecies block)")')
462  write(*,*)
463  stop
464  end if
465  if (zn > 0.d0) then
466  write(*,*)
467  write(*,'("Error(readinput): fractional nuclear Z > 0 : ",G18.10)') zn
468  write(*,*)
469  stop
470  end if
471  call genfspecies(zn,symb)
472  end do
473  write(*,*)
474  write(*,'("Error(readinput): too many fractional nucleus species")')
475  write(*,*)
476  stop
477 case('avec')
478  do i=1,3
479  read(50,'(A)',err=20) str
480  read(str,*,err=20) avec(:,i)
481  read(str,*,iostat=ios) avec(:,i),davec(:,i)
482  end do
483 case('scale')
484  read(50,*,err=20) sc
485 case('scale1')
486  read(50,*,err=20) sc1
487 case('scale2')
488  read(50,*,err=20) sc2
489 case('scale3')
490  read(50,*,err=20) sc3
491 case('scalex')
492  read(50,*,err=20) scx
493 case('scaley')
494  read(50,*,err=20) scy
495 case('scalez')
496  read(50,*,err=20) scz
497 case('epslat')
498  read(50,*,err=20) epslat
499  if (epslat <= 0.d0) then
500  write(*,*)
501  write(*,'("Error(readinput): epslat <= 0 : ",G18.10)') epslat
502  write(*,*)
503  stop
504  end if
505 case('primcell')
506  read(50,*,err=20) primcell
507 case('tshift')
508  read(50,*,err=20) tshift
509 case('autokpt')
510  read(50,*,err=20) autokpt
511 case('radkpt')
512  read(50,*,err=20) radkpt
513  if (radkpt <= 0.d0) then
514  write(*,*)
515  write(*,'("Error(readinput): radkpt <= 0 : ",G18.10)') radkpt
516  write(*,*)
517  stop
518  end if
519 case('ngridk')
520  read(50,'(A)',err=20) str
521  read(str,*,err=20) ngridk(:)
522  read(str,*,iostat=ios) ngridk(:),dngridk(:)
523  if (any(ngridk(:) < 1)) then
524  write(*,*)
525  write(*,'("Error(readinput): invalid ngridk :",3(X,I0))') ngridk
526  write(*,*)
527  stop
528  end if
529  autokpt=.false.
530 case('vkloff')
531  read(50,*,err=20) vkloff(:)
532  if (any(vkloff(:) < 0.d0).or.any(vkloff(:) >= 1.d0)) then
533  write(*,*)
534  write(*,'("Error(readinput): vkloff components should be in [0,1) : ",&
535  &3G18.10)') vkloff
536  write(*,*)
537  stop
538  end if
539 case('reducek')
540  read(50,*,err=20) reducek
541 case('ngridq')
542  read(50,*,err=20) ngridq(:)
543  if (any(ngridq(:) < 1)) then
544  write(*,*)
545  write(*,'("Error(readinput): invalid ngridq :",3(X,I0))') ngridq
546  write(*,*)
547  stop
548  end if
549 case('reduceq')
550  read(50,*,err=20) reduceq
551 case('rgkmax')
552  read(50,'(A)',err=20) str
553  read(str,*,err=20) rgkmax
554  read(str,*,iostat=ios) rgkmax,drgkmax
555  if (rgkmax <= 0.d0) then
556  write(*,*)
557  write(*,'("Error(readinput): rgkmax <= 0 : ",G18.10)') rgkmax
558  write(*,*)
559  stop
560  end if
561 case('gmaxvr')
562  read(50,'(A)',err=20) str
563  read(str,*,err=20) gmaxvr
564  read(str,*,iostat=ios) gmaxvr,dgmaxvr
565 case('lmaxapw')
566  read(50,'(A)',err=20) str
567  read(str,*,err=20) lmaxapw
568  read(str,*,iostat=ios) lmaxapw,dlmaxapw
569  if (lmaxapw < 0) then
570  write(*,*)
571  write(*,'("Error(readinput): lmaxapw < 0 : ",I0)') lmaxapw
572  write(*,*)
573  stop
574  end if
575  if (lmaxapw >= maxlapw) then
576  write(*,*)
577  write(*,'("Error(readinput): lmaxapw too large : ",I0)') lmaxapw
578  write(*,'("Adjust maxlapw in modmain and recompile code")')
579  write(*,*)
580  stop
581  end if
582 case('lmaxo','lmaxvr')
583  read(50,'(A)',err=20) str
584  read(str,*,err=20) lmaxo
585  read(str,*,iostat=ios) lmaxo,dlmaxo
586  if (lmaxo < 3) then
587  write(*,*)
588  write(*,'("Error(readinput): lmaxo < 3 : ",I0)') lmaxo
589  write(*,*)
590  stop
591  end if
592 case('lmaxi','lmaxinr')
593  read(50,*,err=20) lmaxi
594  if (lmaxi < 1) then
595  write(*,*)
596  write(*,'("Error(readinput): lmaxi < 1 : ",I0)') lmaxi
597  write(*,*)
598  stop
599  end if
600 case('lmaxmat')
601  read(50,*,err=20)
602  write(*,'("Info(readinput): variable ''lmaxmat'' is no longer used")')
603 case('fracinr')
604  read(50,*,err=20) fracinr
605 case('trhonorm')
606  read(50,*,err=20) trhonorm
607 case('spinpol')
608  read(50,*,err=20) spinpol
609 case('spinorb')
610  read(50,*,err=20) spinorb
611 case('socscf')
612  read(50,*,err=20) socscf
613  if (socscf < 0.d0) then
614  write(*,*)
615  write(*,'("Error(readinput): socscf < 0 : ",G18.10)') socscf
616  write(*,*)
617  stop
618  end if
619 case('bforb')
620  read(50,*,err=20) bforb
621 case('bfdmag')
622  read(50,*,err=20) bfdmag
623 case('xctype')
624  read(50,'(A)',err=20) str
625  str=trim(str)//' 0 0'
626  read(str,*,err=20) xctype(:)
627 case('xctsp')
628  read(50,'(A)',err=20) str
629  str=trim(str)//' 0 0'
630  read(str,*,err=20) xctsp(:)
631 case('ktype')
632  read(50,'(A)',err=20) str
633  str=trim(str)//' 0 0'
634  read(str,*,err=20) ktype(:)
635  if (ktype(3) /= 0) then
636  write(*,*)
637  write(*,'("Error(readinput): ktype(3) should be zero : ",I0)') ktype(3)
638  write(*,*)
639  stop
640  end if
641 case('stype')
642  read(50,*,err=20) stype
643 case('swidth')
644  read(50,*,err=20) swidth
645  if (swidth < 1.d-9) then
646  write(*,*)
647  write(*,'("Error(readinput): swidth too small or negative : ",G18.10)') &
648  swidth
649  write(*,*)
650  stop
651  end if
652 case('autoswidth')
653  read(50,*,err=20) autoswidth
654 case('mstar')
655  read(50,*,err=20) mstar
656  if (mstar <= 0.d0) then
657  write(*,*)
658  write(*,'("Error(readinput): mstar <= 0 : ",G18.10)') mstar
659  write(*,*)
660  stop
661  end if
662 case('epsocc')
663  read(50,*,err=20) epsocc
664  if (epsocc <= 0.d0) then
665  write(*,*)
666  write(*,'("Error(readinput): epsocc <= 0 : ",G18.10)') epsocc
667  write(*,*)
668  stop
669  end if
670 case('epschg')
671  read(50,*,err=20) epschg
672  if (epschg <= 0.d0) then
673  write(*,*)
674  write(*,'("Error(readinput): epschg <= 0 : ",G18.10)') epschg
675  write(*,*)
676  stop
677  end if
678 case('nempty','nempty0')
679  read(50,'(A)',err=20) str
680  read(str,*,err=20) nempty0
681  read(str,*,iostat=ios) nempty0,dnempty0
682  if (nempty0 <= 0.d0) then
683  write(*,*)
684  write(*,'("Error(readinput): nempty <= 0 : ",G18.10)') nempty0
685  write(*,*)
686  stop
687  end if
688 case('mixtype')
689  read(50,*,err=20) mixtype
690 case('mixsave')
691  read(50,*,err=20) mixsave
692 case('amixpm','beta0','betamax')
693  if (trim(block) == 'amixpm') then
694  read(50,*,err=20) amixpm(:)
695  else if (trim(block) == 'beta0') then
696  read(50,*,err=20) amixpm(1)
697  else
698  read(50,*,err=20) amixpm(2)
699  end if
700  if (amixpm(1) < 0.d0) then
701  write(*,*)
702  write(*,'("Error(readinput): beta0 [amixpm(1)] < 0 : ",G18.10)') amixpm(1)
703  write(*,*)
704  stop
705  end if
706  if ((amixpm(2) < 0.d0).or.(amixpm(2) > 1.d0)) then
707  write(*,*)
708  write(*,'("Error(readinput): betamax [amixpm(2)] not in [0,1] : ",G18.10)')&
709  amixpm(2)
710  write(*,*)
711  stop
712  end if
713 case('mixsdb')
714  read(50,*,err=20) mixsdb
715  if (mixsdb < 2) then
716  write(*,*)
717  write(*,'("Error(readinput): mixsdb < 2 : ",I0)') mixsdb
718  write(*,*)
719  stop
720  end if
721 case('broydpm')
722  read(50,*,err=20) broydpm(:)
723  if ((broydpm(1) < 0.d0).or.(broydpm(1) > 1.d0).or. &
724  (broydpm(2) < 0.d0).or.(broydpm(2) > 1.d0)) then
725  write(*,*)
726  write(*,'("Error(readinput): invalid Broyden mixing parameters : ",&
727  &2G18.10)') broydpm
728  write(*,*)
729  stop
730  end if
731 case('mixrho')
732  read(50,*,err=20) mixrho
733 case('maxscl')
734  read(50,*,err=20) maxscl
735  if (maxscl < 0) then
736  write(*,*)
737  write(*,'("Error(readinput): maxscl < 0 : ",I0)') maxscl
738  write(*,*)
739  stop
740  end if
741 case('epspot')
742  read(50,*,err=20) epspot
743 case('epsengy')
744  read(50,*,err=20) epsengy
745 case('epsforce')
746  read(50,*,err=20) epsforce
747 case('epsstress')
748  read(50,*,err=20) epsstress
749 case('sppath')
750  read(50,*,err=20) sppath
751  sppath=adjustl(sppath)
752 case('scrpath')
753  read(50,*,err=20) scrpath
754 case('molecule')
755  read(50,*,err=20) molecule
756 case('atoms')
757  read(50,*,err=20) nspecies
758  if (nspecies < 1) then
759  write(*,*)
760  write(*,'("Error(readinput): nspecies < 1 : ",I0)') nspecies
761  write(*,*)
762  stop
763  end if
764  if (nspecies > maxspecies) then
765  write(*,*)
766  write(*,'("Error(readinput): nspecies too large : ",I0)') nspecies
767  write(*,'("Adjust maxspecies in modmain and recompile code")')
768  write(*,*)
769  stop
770  end if
771  do is=1,nspecies
772  read(50,*,err=20) spfname(is)
773  spfname(is)=adjustl(spfname(is))
774  read(50,*,err=20) natoms(is)
775  if (natoms(is) < 1) then
776  write(*,*)
777  write(*,'("Error(readinput): natoms < 1 : ",I0)') natoms(is)
778  write(*,'(" for species ",I0)') is
779  write(*,*)
780  stop
781  end if
782  if (natoms(is) > maxatoms) then
783  write(*,*)
784  write(*,'("Error(readinput): natoms too large : ",I0)') natoms(is)
785  write(*,'(" for species ",I0)') is
786  write(*,'("Adjust maxatoms in modmain and recompile code")')
787  write(*,*)
788  stop
789  end if
790  do ia=1,natoms(is)
791  read(50,'(A)',err=20) str
792  read(str,*,err=20) atposl(:,ia,is)
793  read(str,*,iostat=ios) atposl(:,ia,is),bfcmt0(:,ia,is),datposl(:,ia,is)
794  end do
795  end do
796 case('plot1d')
797  read(50,*,err=20) nvp1d,npp1d
798  if (nvp1d < 1) then
799  write(*,*)
800  write(*,'("Error(readinput): nvp1d < 1 : ",I0)') nvp1d
801  write(*,*)
802  stop
803  end if
804  if (npp1d < nvp1d) then
805  write(*,*)
806  write(*,'("Error(readinput): npp1d < nvp1d :",2(X,I0))') npp1d,nvp1d
807  write(*,*)
808  stop
809  end if
810  if (allocated(vvlp1d)) deallocate(vvlp1d)
811  allocate(vvlp1d(3,nvp1d))
812  do i=1,nvp1d
813  read(50,*,err=20) vvlp1d(:,i)
814  end do
815 case('ip01d')
816  read(50,*,err=20) ip01d
817  if (ip01d < 1) then
818  write(*,*)
819  write(*,'("Error(readinput): ip01d < 1 : ",I0)') ip01d
820  write(*,*)
821  stop
822  end if
823 case('plot2d')
824  read(50,*,err=20) vclp2d(:,0)
825  read(50,*,err=20) vclp2d(:,1)
826  read(50,*,err=20) vclp2d(:,2)
827  read(50,*,err=20) np2d(:)
828  if ((np2d(1) < 1).or.(np2d(2) < 1)) then
829  write(*,*)
830  write(*,'("Error(readinput): np2d < 1 :",2(X,I0))') np2d
831  write(*,*)
832  stop
833  end if
834 case('plot3d')
835  read(50,*,err=20) vclp3d(:,0)
836  read(50,*,err=20) vclp3d(:,1)
837  read(50,*,err=20) vclp3d(:,2)
838  read(50,*,err=20) vclp3d(:,3)
839  read(50,*,err=20) np3d(:)
840  if ((np3d(1) < 1).or.(np3d(2) < 1).or.(np3d(3) < 1)) then
841  write(*,*)
842  write(*,'("Error(readinput): np3d < 1 :",3(X,I0))') np3d
843  write(*,*)
844  stop
845  end if
846 case('wplot','dos')
847  read(50,*,err=20) nwplot,ngrkf,nswplot
848  if (nwplot < 2) then
849  write(*,*)
850  write(*,'("Error(readinput): nwplot < 2 : ",I0)') nwplot
851  write(*,*)
852  stop
853  end if
854  if (ngrkf < 1) then
855  write(*,*)
856  write(*,'("Error(readinput): ngrkf < 1 : ",I0)') ngrkf
857  write(*,*)
858  stop
859  end if
860  if (nswplot < 0) then
861  write(*,*)
862  write(*,'("Error(readinput): nswplot < 0 : ",I0)') nswplot
863  write(*,*)
864  stop
865  end if
866  read(50,*,err=20) wplot(:)
867  if (wplot(1) > wplot(2)) then
868  write(*,*)
869  write(*,'("Error(readinput): wplot(1) > wplot(2) : ",2G18.10)') wplot
870  write(*,*)
871  stop
872  end if
873 case('dosocc')
874  read(50,*,err=20) dosocc
875 case('tpdos')
876  read(50,*,err=20) tpdos
877 case('dosmsum')
878  read(50,*,err=20) dosmsum
879 case('dosssum')
880  read(50,*,err=20) dosssum
881 case('lmirep')
882  read(50,*,err=20) lmirep
883 case('atpopt')
884  read(50,*,err=20) atpopt
885 case('maxatpstp','maxatmstp')
886  read(50,*,err=20) maxatpstp
887  if (maxatpstp < 1) then
888  write(*,*)
889  write(*,'("Error(readinput): maxatpstp < 1 : ",I0)') maxatpstp
890  write(*,*)
891  stop
892  end if
893 case('tau0atp','tau0atm')
894  read(50,*,err=20) tau0atp
895 case('deltast')
896  read(50,*,err=20) deltast
897  if (deltast <= 0.d0) then
898  write(*,*)
899  write(*,'("Error(readinput): deltast <= 0 : ",G18.10)') deltast
900  write(*,*)
901  stop
902  end if
903 case('avecref')
904  read(50,*,err=20) avecref(:,1)
905  read(50,*,err=20) avecref(:,2)
906  read(50,*,err=20) avecref(:,3)
907 case('latvopt')
908  read(50,*,err=20) latvopt
909 case('maxlatvstp')
910  read(50,*,err=20) maxlatvstp
911  if (maxlatvstp < 1) then
912  write(*,*)
913  write(*,'("Error(readinput): maxlatvstp < 1 : ",I0)') maxlatvstp
914  write(*,*)
915  stop
916  end if
917 case('tau0latv')
918  read(50,*,err=20) tau0latv
919 case('nstfsp')
920  read(50,*,err=20)
921  write(*,'("Info(readinput): variable ''nstfsp'' is no longer used")')
922 case('lradstp')
923  read(50,*,err=20) lradstp
924  if (lradstp < 1) then
925  write(*,*)
926  write(*,'("Error(readinput): lradstp < 1 : ",I0)') lradstp
927  write(*,*)
928  stop
929  end if
930 case('chgexs')
931  read(50,'(A)',err=20) str
932  read(str,*,err=20) chgexs
933  read(str,*,iostat=ios) chgexs,dchgexs
934 case('nprad')
935  read(50,*,err=20)
936  write(*,'("Info(readinput): variable ''nprad'' is no longer used")')
937 case('scissor')
938  read(50,*,err=20) scissor
939 case('noptcomp')
940  read(50,*,err=20) noptcomp
941  if ((noptcomp < 1).or.(noptcomp > 27)) then
942  write(*,*)
943  write(*,'("Error(readinput): noptcomp should be from 1 to 27 : ",I0)') &
944  noptcomp
945  write(*,*)
946  stop
947  end if
948 case('optcomp')
949  do i=1,27
950  read(50,'(A)',err=20) str
951  if (trim(str) == '') then
952  if (i == 1) then
953  write(*,*)
954  write(*,'("Error(readinput): empty optical component list")')
955  write(*,*)
956  stop
957  end if
958  noptcomp=i-1
959  goto 10
960  end if
961  str=trim(str)//' 1 1'
962  read(str,*,iostat=ios) optcomp(:,i)
963  if (ios /= 0) then
964  write(*,*)
965  write(*,'("Error(readinput): error reading optical component list")')
966  write(*,'("(blank line required after optcomp block)")')
967  write(*,*)
968  stop
969  end if
970  if (any(optcomp(:,i) < 1).or.any(optcomp(:,i) > 3)) then
971  write(*,*)
972  write(*,'("Error(readinput): invalid optcomp :",3(X,I0))') optcomp(:,i)
973  write(*,*)
974  stop
975  end if
976  end do
977  write(*,*)
978  write(*,'("Error(readinput): optical component list too long")')
979  write(*,*)
980  stop
981 case('intraband')
982  read(50,*,err=20) intraband
983 case('evaltol')
984  read(50,*,err=20)
985  write(*,'("Info(readinput): variable ''evaltol'' is no longer used")')
986 case('deband')
987  read(50,*,err=20)
988  write(*,'("Info(readinput): variable ''deband'' is no longer used")')
989 case('epsband')
990  read(50,*,err=20) epsband
991  if (epsband <= 0.d0) then
992  write(*,*)
993  write(*,'("Error(readinput): epsband <= 0 : ",G18.10)') epsband
994  write(*,*)
995  stop
996  end if
997 case('demaxbnd')
998  read(50,*,err=20) demaxbnd
999  if (demaxbnd <= 0.d0) then
1000  write(*,*)
1001  write(*,'("Error(readinput): demaxbnd <= 0 : ",G18.10)') demaxbnd
1002  write(*,*)
1003  stop
1004  end if
1005 case('autolinengy')
1006  read(50,*,err=20) autolinengy
1007 case('dlefe')
1008  read(50,*,err=20) dlefe
1009 case('autodlefe')
1010  read(50,*,err=20) autodlefe
1011 case('deapw')
1012  read(50,*,err=20) deapw
1013  if (abs(deapw) < 1.d-8) then
1014  write(*,*)
1015  write(*,'("Error(readinput): invalid deapw : ",G18.10)') deapw
1016  write(*,*)
1017  stop
1018  end if
1019 case('delorb')
1020  read(50,*,err=20) delorb
1021  if (abs(delorb) < 1.d-8) then
1022  write(*,*)
1023  write(*,'("Error(readinput): invalid delorb : ",G18.10)') delorb
1024  write(*,*)
1025  stop
1026  end if
1027 case('bfieldc')
1028  read(50,'(A)',err=20) str
1029  read(str,*,err=20) bfieldc0(:)
1030  read(str,*,iostat=ios) bfieldc0(:),dbfieldc0(:)
1031 case('efieldc')
1032  read(50,*,err=20) efieldc(:)
1033 case('dmaxefc')
1034  read(50,*,err=20) dmaxefc
1035  if (dmaxefc < 0) then
1036  write(*,*)
1037  write(*,'("Error(readinput): dmaxefc < 0 : ",G18.10)') dmaxefc
1038  write(*,*)
1039  stop
1040  end if
1041 case('afieldc')
1042  read(50,'(A)',err=20) str
1043  read(str,*,err=20) afieldc(:)
1044  read(str,*,iostat=ios) afieldc(:),dafieldc(:)
1045 case('afspc')
1046  do i=1,3
1047  read(50,'(A)',err=20) str
1048  read(str,*,err=20) afspc(i,:)
1049  read(str,*,iostat=ios) afspc(i,:),dafspc(i,:)
1050  end do
1051 case('fsmtype','fixspin')
1052  read(50,*,err=20) fsmtype
1053 case('momfix')
1054  read(50,'(A)',err=20) str
1055  read(str,*,err=20) momfix(:)
1056  read(str,*,iostat=ios) momfix(:),dmomfix(:)
1057 case('momfixm')
1058  read(50,*,err=20) momfixm
1059  if (momfixm < 0.d0) then
1060  write(*,*)
1061  write(*,'("Error(readinput): momfixm < 0 : ",G18.10)') momfixm
1062  write(*,*)
1063  stop
1064  end if
1065 case('mommtfix')
1066  do ias=1,maxspecies*maxatoms
1067  read(50,'(A)',err=20) str
1068  if (trim(str) == '') goto 10
1069  read(str,*,iostat=ios) is,ia,mommtfix(:,ia,is)
1070  if (ios /= 0) then
1071  write(*,*)
1072  write(*,'("Error(readinput): error reading muffin-tin fixed spin &
1073  &moments")')
1074  write(*,'("(blank line required after mommtfix block)")')
1075  write(*,*)
1076  stop
1077  end if
1078  end do
1079 case('mommtfixm')
1080  do ias=1,maxspecies*maxatoms
1081  read(50,'(A)',err=20) str
1082  if (trim(str) == '') goto 10
1083  read(str,*,iostat=ios) is,ia,mommtfixm(ia,is)
1084  if (ios /= 0) then
1085  write(*,*)
1086  write(*,'("Error(readinput): error reading muffin-tin fixed spin &
1087  &moment magnitudes")')
1088  write(*,'("(blank line required after mommtfixm block)")')
1089  write(*,*)
1090  stop
1091  end if
1092  end do
1093 case('taufsm')
1094  read(50,*,err=20) taufsm
1095  if (taufsm < 0.d0) then
1096  write(*,*)
1097  write(*,'("Error(readinput): taufsm < 0 : ",G18.10)') taufsm
1098  write(*,*)
1099  stop
1100  end if
1101 case('autormt')
1102  read(50,*,err=20)
1103  write(*,'("Info(readinput): variable ''autormt'' is no longer used")')
1104 case('rmtdelta')
1105  read(50,*,err=20) rmtdelta
1106  if (rmtdelta < 0.d0) then
1107  write(*,*)
1108  write(*,'("Warning(readinput): rmtdelta < 0 : ",G18.10)') rmtdelta
1109  end if
1110 case('isgkmax')
1111  read(50,*,err=20) isgkmax
1112 case('nosym')
1113  read(50,*,err=20) lv
1114  if (lv) symtype=0
1115 case('symtype')
1116  read(50,*,err=20) symtype
1117  if ((symtype < 0).or.(symtype > 2)) then
1118  write(*,*)
1119  write(*,'("Error(readinput): symtype not defined : ",I0)') symtype
1120  write(*,*)
1121  stop
1122  end if
1123 case('deltaph')
1124  read(50,*,err=20) deltaph
1125  if (deltaph <= 0.d0) then
1126  write(*,*)
1127  write(*,'("Error(readinput): deltaph <= 0 : ",G18.10)') deltaph
1128  write(*,*)
1129  stop
1130  end if
1131 case('phwrite')
1132  read(50,*,err=20) nphwrt
1133  if (nphwrt < 1) then
1134  write(*,*)
1135  write(*,'("Error(readinput): nphwrt < 1 : ",I0)') nphwrt
1136  write(*,*)
1137  stop
1138  end if
1139  if (allocated(vqlwrt)) deallocate(vqlwrt)
1140  allocate(vqlwrt(3,nphwrt))
1141  do i=1,nphwrt
1142  read(50,*,err=20) vqlwrt(:,i)
1143  end do
1144 case('notes')
1145  if (allocated(notes)) deallocate(notes)
1146  allocate(notes(0))
1147  notelns=0
1148  do
1149  read(50,'(A)') str
1150  if (trim(str) == '') goto 10
1151  notes=[notes(1:notelns),str]
1152  notelns=notelns+1
1153  end do
1154 case('tforce')
1155  read(50,*,err=20) tforce
1156 case('tfibs')
1157  read(50,*,err=20)
1158  write(*,'("Info(readinput): variable ''tfibs'' is no longer used")')
1159 case('maxitoep')
1160  read(50,*,err=20) maxitoep
1161  if (maxitoep < 1) then
1162  write(*,*)
1163  write(*,'("Error(readinput): maxitoep < 1 : ",I0)') maxitoep
1164  write(*,*)
1165  stop
1166  end if
1167 case('tauoep')
1168  read(50,*,err=20)
1169  write(*,'("Info(readinput): variable ''tauoep'' is no longer used")')
1170 case('tau0oep')
1171  read(50,*,err=20) tau0oep
1172  if (tau0oep < 0.d0) then
1173  write(*,*)
1174  write(*,'("Error(readinput): tau0oep < 0 : ",G18.10)') tau0oep
1175  write(*,*)
1176  stop
1177  end if
1178 case('kstlist')
1179  do i=1,maxkst
1180  read(50,'(A)',err=20) str
1181  if (trim(str) == '') then
1182  if (i == 1) then
1183  write(*,*)
1184  write(*,'("Error(readinput): empty k-point and state list")')
1185  write(*,*)
1186  stop
1187  end if
1188  nkstlist=i-1
1189  goto 10
1190  end if
1191  str=trim(str)//' 1'
1192  read(str,*,iostat=ios) kstlist(:,i)
1193  if (ios /= 0) then
1194  write(*,*)
1195  write(*,'("Error(readinput): error reading k-point and state list")')
1196  write(*,'("(blank line required after kstlist block)")')
1197  write(*,*)
1198  stop
1199  end if
1200  end do
1201  write(*,*)
1202  write(*,'("Error(readinput): k-point and state list too long")')
1203  write(*,*)
1204  stop
1205 case('vklem')
1206  read(50,*,err=20) vklem
1207 case('deltaem')
1208  read(50,*,err=20) deltaem
1209  if (deltaem <= 0.d0) then
1210  write(*,*)
1211  write(*,'("Error(readinput): deltaem <= 0 : ",G18.10)') deltaem
1212  write(*,*)
1213  stop
1214  end if
1215 case('ndspem')
1216  read(50,*,err=20) ndspem
1217  if ((ndspem < 1).or.(ndspem > 4)) then
1218  write(*,*)
1219  write(*,'("Error(readinput): ndspem out of range : ",I0)') ndspem
1220  write(*,*)
1221  stop
1222  end if
1223 case('nosource')
1224  read(50,*,err=20) nosource
1225 case('spinsprl')
1226  read(50,*,err=20) spinsprl
1227 case('ssdph')
1228  read(50,*,err=20) ssdph
1229 case('vqlss')
1230  read(50,'(A)',err=20) str
1231  read(str,*,err=20) vqlss
1232  read(str,*,iostat=ios) vqlss,dvqlss
1233 case('nwrite')
1234  read(50,*,err=20) nwrite
1235 case('DFT+U','dft+u','lda+u')
1236  read(50,*,err=20) dftu,inpdftu
1237  do i=1,maxdftu
1238  read(50,'(A)',err=20) str
1239  if (trim(str) == '') then
1240  ndftu=i-1
1241  goto 10
1242  end if
1243  select case(inpdftu)
1244  case(1)
1245  read(str,*,iostat=ios) is,l,ujdu(1:2,i)
1246  case(2)
1247  read(str,*,iostat=ios) is,l,(fdu(k,i),k=0,2*l,2)
1248  case(3)
1249  read(str,*,iostat=ios) is,l,(edu(k,i),k=0,l)
1250  case(4)
1251  read(str,*,iostat=ios) is,l,lamdu(i)
1252  case(5)
1253  read(str,*,iostat=ios) is,l,udufix(i),dudufix(i)
1254  read(str,*,iostat=ios) is,l,udufix(i)
1255  case default
1256  write(*,*)
1257  write(*,'("Error(readinput): invalid inpdftu : ",I0)') inpdftu
1258  write(*,*)
1259  stop
1260  end select
1261  if (ios /= 0) then
1262  write(*,*)
1263  write(*,'("Error(readinput): error reading DFT+U parameters")')
1264  write(*,'("(blank line required after dft+u block)")')
1265  write(*,*)
1266  stop
1267  end if
1268  if ((is < 1).or.(is >= maxspecies)) then
1269  write(*,*)
1270  write(*,'("Error(readinput): invalid species number in dft+u block : ", &
1271  &I0)') is
1272  write(*,*)
1273  stop
1274  end if
1275  if (l < 0) then
1276  write(*,*)
1277  write(*,'("Error(readinput): l < 0 in dft+u block : ",I0)') l
1278  write(*,*)
1279  stop
1280  end if
1281  if (l > lmaxdm) then
1282  write(*,*)
1283  write(*,'("Error(readinput): l > lmaxdm in dft+u block :",2(X,I0))') l, &
1284  lmaxdm
1285  write(*,*)
1286  stop
1287  end if
1288 ! check for repeated entries
1289  do j=1,i-1
1290  if ((is == isldu(1,j)).and.(l == isldu(2,j))) then
1291  write(*,*)
1292  write(*,'("Error(readinput): repeated entry in DFT+U block")')
1293  write(*,*)
1294  stop
1295  end if
1296  end do
1297  isldu(1,i)=is
1298  isldu(2,i)=l
1299  end do
1300  write(*,*)
1301  write(*,'("Error(readinput): too many DFT+U entries")')
1302  write(*,'("Adjust maxdftu in modmain and recompile code")')
1303  write(*,*)
1304  stop
1305 case('tmwrite','tmomlu')
1306  read(50,*,err=20) tmwrite
1307 case('readadu','readalu')
1308  read(50,*,err=20)
1309  write(*,'("Info(readinput): variable ''readadu'' is no longer used")')
1310 case('rdmxctype')
1311  read(50,*,err=20) rdmxctype
1312 case('rdmmaxscl')
1313  read(50,*,err=20) rdmmaxscl
1314  if (rdmmaxscl < 0) then
1315  write(*,*)
1316  write(*,'("Error(readinput): rdmmaxscl < 0 : ",I0)') rdmmaxscl
1317  write(*,*)
1318  end if
1319 case('maxitn')
1320  read(50,*,err=20) maxitn
1321 case('maxitc')
1322  read(50,*,err=20) maxitc
1323 case('taurdmn')
1324  read(50,*,err=20) taurdmn
1325  if (taurdmn < 0.d0) then
1326  write(*,*)
1327  write(*,'("Error(readinput): taurdmn < 0 : ",G18.10)') taurdmn
1328  write(*,*)
1329  stop
1330  end if
1331 case('taurdmc')
1332  read(50,*,err=20) taurdmc
1333  if (taurdmc < 0.d0) then
1334  write(*,*)
1335  write(*,'("Error(readinput): taurdmc < 0 : ",G18.10)') taurdmc
1336  write(*,*)
1337  stop
1338  end if
1339 case('rdmalpha')
1340  read(50,*,err=20) rdmalpha
1341  if ((rdmalpha <= 0.d0).or.(rdmalpha >= 1.d0)) then
1342  write(*,*)
1343  write(*,'("Error(readinput): rdmalpha not in (0,1) : ",G18.10)') rdmalpha
1344  write(*,*)
1345  stop
1346  end if
1347 case('rdmtemp')
1348  read(50,*,err=20) rdmtemp
1349  if (rdmtemp < 0.d0) then
1350  write(*,*)
1351  write(*,'("Error(readinput): rdmtemp < 0 : ",G18.10)') rdmtemp
1352  write(*,*)
1353  stop
1354  end if
1355 case('reducebf')
1356  read(50,*,err=20) reducebf
1357  if ((reducebf < 0.5d0).or.(reducebf > 1.d0)) then
1358  write(*,*)
1359  write(*,'("Error(readinput): reducebf not in [0.5,1] : ",G18.10)') reducebf
1360  write(*,*)
1361  stop
1362  end if
1363 case('ptnucl')
1364  read(50,*,err=20) ptnucl
1365 case('tefvr','tseqr')
1366  read(50,*,err=20) tefvr
1367 case('tefvit','tseqit')
1368  read(50,*,err=20) tefvit
1369 case('minitefv','minseqit')
1370  read(50,*,err=20)
1371  write(*,'("Info(readinput): variable ''minitefv'' is no longer used")')
1372 case('nefvit','maxitefv','maxseqit','nseqit')
1373  read(50,*,err=20) nefvit
1374  if (nefvit == 0) then
1375  write(*,*)
1376  write(*,'("Error(readinput): nefvit = 0")')
1377  write(*,*)
1378  stop
1379  end if
1380 case('befvit','bseqit')
1381  read(50,*,err=20)
1382  write(*,'("Info(readinput): variable ''befvit'' is no longer used")')
1383 case('epsefvit','epsseqit')
1384  read(50,*,err=20)
1385  write(*,'("Info(readinput): variable ''epsefvit'' is no longer used")')
1386 case('tauseq')
1387  read(50,*,err=20)
1388  write(*,'("Info(readinput): variable ''tauseq'' is no longer used")')
1389 case('vecql')
1390  read(50,*,err=20) vecql(:)
1391 case('mustar')
1392  read(50,*,err=20) mustar
1393 case('sqaxis','sqados')
1394  read(50,*,err=20) sqaxis(:)
1395 case('test')
1396  read(50,*,err=20) test
1397 case('frozencr')
1398  read(50,*,err=20)
1399  write(*,'("Info(readinput): variable ''frozencr'' is no longer used")')
1400 case('spincore')
1401  read(50,*,err=20) spincore
1402 case('solscf')
1403  read(50,*,err=20) solscf
1404  if (solscf < 0.d0) then
1405  write(*,*)
1406  write(*,'("Error(readinput): solscf < 0 : ",G18.10)') solscf
1407  write(*,*)
1408  stop
1409  end if
1410 case('emaxelnes')
1411  read(50,*,err=20) emaxelnes
1412 case('wsfac')
1413  read(50,*,err=20) wsfac(:)
1414 case('vhmat')
1415  read(50,*,err=20) vhmat(1,:)
1416  read(50,*,err=20) vhmat(2,:)
1417  read(50,*,err=20) vhmat(3,:)
1418 case('reduceh')
1419  read(50,*,err=20) reduceh
1420 case('hybrid')
1421  read(50,*,err=20) hybrid0
1422 case('hybridc','hybmix')
1423  read(50,*,err=20) hybridc
1424  if ((hybridc < 0.d0).or.(hybridc > 1.d0)) then
1425  write(*,*)
1426  write(*,'("Error(readinput): invalid hybridc : ",G18.10)') hybridc
1427  write(*,*)
1428  stop
1429  end if
1430 case('ecvcut')
1431  read(50,*,err=20) ecvcut
1432 case('esccut')
1433  read(50,*,err=20) esccut
1434 case('nvbse')
1435  read(50,*,err=20) nvbse0
1436  if (nvbse0 < 0) then
1437  write(*,*)
1438  write(*,'("Error(readinput): nvbse < 0 : ",I0)') nvbse0
1439  write(*,*)
1440  stop
1441  end if
1442 case('ncbse')
1443  read(50,*,err=20) ncbse0
1444  if (ncbse0 < 0) then
1445  write(*,*)
1446  write(*,'("Error(readinput): ncbse < 0 : ",I0)') ncbse0
1447  write(*,*)
1448  stop
1449  end if
1450 case('istxbse')
1451  do i=1,maxxbse
1452  read(50,'(A)',err=20) str
1453  if (trim(str) == '') then
1454  if (i == 1) then
1455  write(*,*)
1456  write(*,'("Error(readinput): empty BSE extra valence state list")')
1457  write(*,*)
1458  stop
1459  end if
1460  nvxbse=i-1
1461  goto 10
1462  end if
1463  read(str,*,iostat=ios) istxbse(i)
1464  if (ios /= 0) then
1465  write(*,*)
1466  write(*,'("Error(readinput): error reading BSE valence state list")')
1467  write(*,'("(blank line required after istxbse block)")')
1468  write(*,*)
1469  stop
1470  end if
1471  end do
1472  write(*,*)
1473  write(*,'("Error(readinput): BSE extra valence state list too long")')
1474  write(*,*)
1475  stop
1476 case('jstxbse')
1477  do i=1,maxxbse
1478  read(50,'(A)',err=20) str
1479  if (trim(str) == '') then
1480  if (i == 1) then
1481  write(*,*)
1482  write(*,'("Error(readinput): empty BSE extra conduction state list")')
1483  write(*,*)
1484  stop
1485  end if
1486  ncxbse=i-1
1487  goto 10
1488  end if
1489  read(str,*,iostat=ios) jstxbse(i)
1490  if (ios /= 0) then
1491  write(*,*)
1492  write(*,'("Error(readinput): error reading BSE conduction state list")')
1493  write(*,'("(blank line required after jstxbse block)")')
1494  write(*,*)
1495  stop
1496  end if
1497  end do
1498  write(*,*)
1499  write(*,'("Error(readinput): BSE extra conduction state list too long")')
1500  write(*,*)
1501  stop
1502 case('bsefull')
1503  read(50,*,err=20) bsefull
1504 case('hxbse')
1505  read(50,*,err=20) hxbse
1506 case('hdbse')
1507  read(50,*,err=20) hdbse
1508 case('gmaxrf','gmaxrpa')
1509  read(50,*,err=20) gmaxrf
1510  if (gmaxrf < 0.d0) then
1511  write(*,*)
1512  write(*,'("Error(readinput): gmaxrf < 0 : ",G18.10)') gmaxrf
1513  write(*,*)
1514  stop
1515  end if
1516 case('mbwgrf')
1517  read(50,*,err=20) mbwgrf
1518 case('emaxrf')
1519  read(50,*,err=20) emaxrf
1520  if (emaxrf < 0.d0) then
1521  write(*,*)
1522  write(*,'("Error(readinput): emaxrf < 0 : ",G18.10)') emaxrf
1523  write(*,*)
1524  stop
1525  end if
1526 case('fxctype')
1527  read(50,'(A)',err=20) str
1528  str=trim(str)//' 0 0'
1529  read(str,*,err=20) fxctype
1530 case('fxclrc')
1531  read(50,'(A)',err=20) str
1532  str=trim(str)//' 0.0'
1533  read(str,*,err=20) fxclrc(:)
1534 case('ntemp')
1535  read(50,*,err=20) ntemp
1536  if (ntemp < 1) then
1537  write(*,*)
1538  write(*,'("Error(readinput): ntemp < 1 : ",I0)') ntemp
1539  write(*,*)
1540  stop
1541  end if
1542 case('trimvg')
1543  write(*,'("Info(readinput): variable ''trimvg'' is no longer used")')
1544  read(50,*,err=20)
1545 case('rndstate','rndseed')
1546  read(50,*,err=20) rndstate(0)
1547  rndstate(0)=abs(rndstate(0))
1548 case('rndatposc')
1549  read(50,*,err=20) rndatposc
1550 case('rndbfcmt')
1551  read(50,*,err=20) rndbfcmt
1552 case('rndavec')
1553  read(50,*,err=20) rndavec
1554 case('c_tb09')
1555  read(50,*,err=20) c_tb09
1556 ! set flag to indicate Tran-Blaha constant has been read in
1557  tc_tb09=.true.
1558 case('lowq','highq','vhighq','uhighq')
1559  read(50,*,err=20) lv
1560  if (lv) then
1561  if (trim(block) == 'lowq') then
1562  rgkmax=6.5d0
1563  gmaxvr=10.d0
1564  lmaxapw=7
1565  lmaxo=5
1566  nxlo=2
1567  lorbcnd=.true.
1568  radkpt=25.d0
1569  autokpt=.true.
1570  vkloff(:)=0.5d0
1571  nempty0=4.d0
1572  epspot=1.d-5
1573  epsengy=5.d-4
1574  epsforce=1.d-2
1575  epsstress=3.d-3
1576  autolinengy=.true.
1577  gmaxrf=2.5d0
1578  lradstp=6
1579  else if (trim(block) == 'highq') then
1580 ! parameter set for high-quality calculation
1581  rgkmax=max(rgkmax,8.d0)
1582  gmaxvr=max(gmaxvr,16.d0)
1583  lmaxapw=max(lmaxapw,9)
1584  lmaxo=max(lmaxo,7)
1585  nrmtscf=max(nrmtscf,1.5d0)
1586  nxlo=max(nxlo,2)
1587  lorbcnd=.true.
1588  radkpt=max(radkpt,50.d0)
1589  autokpt=.true.
1590  vkloff(:)=0.d0
1591  nempty0=max(nempty0,10.d0)
1592  epspot=min(epspot,1.d-7)
1593  epsengy=min(epsengy,1.d-5)
1594  epsforce=min(epsforce,5.d-4)
1595  epsstress=min(epsstress,1.d-3)
1596  autolinengy=.true.
1597  gmaxrf=max(gmaxrf,4.d0)
1598  else if (trim(block) == 'vhighq') then
1599 ! parameter set for very high-quality calculation
1600  rgkmax=max(rgkmax,9.d0)
1601  gmaxvr=max(gmaxvr,18.d0)
1602  lmaxapw=max(lmaxapw,11)
1603  lmaxo=max(lmaxo,9)
1604  nrmtscf=max(nrmtscf,2.d0)
1605  nxlo=max(nxlo,3)
1606  lorbcnd=.true.
1607  radkpt=max(radkpt,90.d0)
1608  autokpt=.true.
1609  vkloff(:)=0.d0
1610  nempty0=max(nempty0,20.d0)
1611  epspot=min(epspot,1.d-7)
1612  epsengy=min(epsengy,1.d-6)
1613  epsforce=min(epsforce,2.d-4)
1614  epsstress=min(epsstress,5.d-4)
1615  autolinengy=.true.
1616  gmaxrf=max(gmaxrf,5.d0)
1617  else
1618 ! parameter set for ultra high-quality calculation
1619  rgkmax=max(rgkmax,10.d0)
1620  gmaxvr=max(gmaxvr,20.d0)
1621  lmaxapw=max(lmaxapw,12)
1622  lmaxo=max(lmaxo,9)
1623  nrmtscf=max(nrmtscf,4.d0)
1624  nxlo=max(nxlo,3)
1625  lorbcnd=.true.
1626  radkpt=max(radkpt,120.d0)
1627  autokpt=.true.
1628  vkloff(:)=0.d0
1629  nempty0=max(nempty0,40.d0)
1630  epspot=min(epspot,1.d-7)
1631  epsengy=min(epsengy,1.d-6)
1632  epsforce=min(epsforce,1.d-4)
1633  epsstress=min(epsstress,2.d-4)
1634  autolinengy=.true.
1635  gmaxrf=max(gmaxrf,6.d0)
1636  end if
1637  if (mp_mpi) then
1638  write(*,*)
1639  write(*,'("Info(readinput): parameters set by ",A," option")') trim(block)
1640  write(*,'(" rgkmax : ",G18.10)') rgkmax
1641  write(*,'(" gmaxvr : ",G18.10)') gmaxvr
1642  write(*,'(" lmaxapw : ",I0)') lmaxapw
1643  write(*,'(" lmaxo : ",I0)') lmaxo
1644  write(*,'(" nrmtscf : ",G18.10)') nrmtscf
1645  write(*,'(" nxlo : ",I0)') nxlo
1646  write(*,'(" lorbcnd : ",L1)') lorbcnd
1647  write(*,'(" radkpt : ",G18.10)') radkpt
1648  write(*,'(" autokpt : ",L1)') autokpt
1649  write(*,'(" vkloff : ",3G18.10)') vkloff
1650  write(*,'(" nempty0 : ",G18.10)') nempty0
1651  write(*,'(" epspot : ",G18.10)') epspot
1652  write(*,'(" epsengy : ",G18.10)') epsengy
1653  write(*,'(" epsforce : ",G18.10)') epsforce
1654  write(*,'(" epsstress : ",G18.10)') epsstress
1655  write(*,'(" autolinengy : ",L1)') autolinengy
1656  write(*,'(" gmaxrf : ",G18.10)') gmaxrf
1657  if (trim(block) == 'lowq') then
1658  write(*,'(" lradstp : ",I0)') lradstp
1659  end if
1660  end if
1661  end if
1662 case('hmaxvr')
1663  read(50,*,err=20) hmaxvr
1664  if (hmaxvr < 0.d0) then
1665  write(*,*)
1666  write(*,'("Error(readinput): hmaxvr < 0 : ",G18.10)') hmaxvr
1667  write(*,*)
1668  stop
1669  end if
1670 case('hkmax')
1671  read(50,*,err=20) hkmax
1672  if (hkmax <= 0.d0) then
1673  write(*,*)
1674  write(*,'("Error(readinput): hkmax <= 0 : ",G18.10)') hkmax
1675  write(*,*)
1676  stop
1677  end if
1678 case('lorbcnd')
1679  read(50,*,err=20) lorbcnd
1680 case('lorbordc')
1681  read(50,*,err=20) lorbordc
1682  if (lorbordc < 2) then
1683  write(*,*)
1684  write(*,'("Error(readinput): lorbordc < 2 : ",I0)') lorbordc
1685  write(*,*)
1686  stop
1687  end if
1688  if (lorbordc > maxlorbord) then
1689  write(*,*)
1690  write(*,'("Error(readinput): lorbordc too large : ",I0)') lorbordc
1691  write(*,'("Adjust maxlorbord in modmain and recompile code")')
1692  write(*,*)
1693  stop
1694  end if
1695 case('nrmtscf')
1696  read(50,'(A)',err=20) str
1697  read(str,*,err=20) nrmtscf
1698  read(str,*,iostat=ios) nrmtscf,dnrmtscf
1699  if (nrmtscf < 0.5d0) then
1700  write(*,*)
1701  write(*,'("Error(readinput): nrmtscf < 0.5 : ",G18.10)') nrmtscf
1702  write(*,*)
1703  stop
1704  end if
1705 case('lmaxdb','lmaxdos')
1706  read(50,*,err=20) lmaxdb
1707  if (lmaxdb < 0) then
1708  write(*,*)
1709  write(*,'("Error(readinput): lmaxdb < 0 : ",I0)') lmaxdb
1710  write(*,*)
1711  stop
1712  end if
1713 case('epsdev')
1714  read(50,*,err=20) epsdev
1715  if (epsdev <= 0.d0) then
1716  write(*,*)
1717  write(*,'("Error(readinput): epsdev <= 0 : ",G18.10)') epsdev
1718  write(*,*)
1719  stop
1720  end if
1721 case('msmooth')
1722  read(50,*,err=20)
1723  write(*,'("Info(readinput): variable ''msmooth'' is no longer used")')
1724 case('npmae')
1725  read(50,*,err=20) npmae0
1726 case('wrtvars')
1727  read(50,*,err=20) wrtvars
1728 case('ftmtype')
1729  read(50,*,err=20) ftmtype
1730 case('tmomfix')
1731  write(*,*)
1732  write(*,'("Error(readinput): variable ''tmomfix'' is no longer used")')
1733  write(*,'(" use tm3fix instead")')
1734  write(*,*)
1735  stop
1736 case('tm3fix')
1737  read(50,*,err=20) ntmfix
1738  if (ntmfix < 1) then
1739  write(*,*)
1740  write(*,'("Error(readinput): ntmfix < 1 : ",I0)') ntmfix
1741  write(*,*)
1742  stop
1743  end if
1744  if (allocated(itmfix)) deallocate(itmfix)
1745  allocate(itmfix(7,ntmfix))
1746  if (allocated(wkprfix)) deallocate(wkprfix)
1747  allocate(wkprfix(ntmfix))
1748  do i=1,ntmfix
1749  read(50,*,err=20) is,ia,l
1750  if ((is < 1).or.(ia < 1).or.(l < 0)) then
1751  write(*,*)
1752  write(*,'("Error(readinput): invalid is, ia or l in tm3fix block :",&
1753  &3(X,I0))') is,ia,l
1754  write(*,*)
1755  stop
1756  end if
1757  itmfix(1,i)=is
1758  itmfix(2,i)=ia
1759  itmfix(3,i)=l
1760 ! read k, p, r, t for the 3-index tensor
1761  read(50,*,err=20) itmfix(4:7,i)
1762 ! read 3-index tensor component with conventional normalisation
1763  read(50,*,err=20) wkprfix(i)
1764  end do
1765 case('tauftm')
1766  read(50,*,err=20) tauftm
1767  if (tauftm < 0.d0) then
1768  write(*,*)
1769  write(*,'("Error(readinput): tauftm < 0 : ",G18.10)') tauftm
1770  write(*,*)
1771  stop
1772  end if
1773 case('ftmstep')
1774  read(50,*,err=20)
1775  write(*,'("Info(readinput): variable ''ftmstep'' is no longer used")')
1776 case('cmagz','forcecmag')
1777  read(50,*,err=20) cmagz
1778 case('rotavec')
1779  read(50,*,err=20) axang(:)
1780 case('tstime')
1781  read(50,*,err=20) tstime
1782  if (tstime <= 0.d0) then
1783  write(*,*)
1784  write(*,'("Error(readinput): tstime <= 0 : ",G18.10)') tstime
1785  write(*,*)
1786  stop
1787  end if
1788 case('dtimes')
1789  read(50,*,err=20) dtimes
1790  if (dtimes <= 0.d0) then
1791  write(*,*)
1792  write(*,'("Error(readinput): dtimes <= 0 : ",G18.10)') dtimes
1793  write(*,*)
1794  stop
1795  end if
1796 case('pulse')
1797  read(50,*,err=20) npulse
1798  if (npulse < 1) then
1799  write(*,*)
1800  write(*,'("Error(readinput): npulse < 1 : ",I0)') npulse
1801  write(*,*)
1802  stop
1803  end if
1804  if (allocated(pulse)) deallocate(pulse)
1805  allocate(pulse(12,npulse))
1806  do i=1,npulse
1807  read(50,'(A)',err=20) str
1808  str=trim(str)//' 1.0 0.0 0.0 0.0'
1809  read(str,*,err=20) pulse(:,i)
1810  end do
1811 case('ramp')
1812  read(50,*,err=20) nramp
1813  if (nramp < 1) then
1814  write(*,*)
1815  write(*,'("Error(readinput): nramp < 1 : ",I0)') nramp
1816  write(*,*)
1817  stop
1818  end if
1819  if (allocated(ramp)) deallocate(ramp)
1820  allocate(ramp(12,nramp))
1821  do i=1,nramp
1822  read(50,'(A)',err=20) str
1823  str=trim(str)//' 1.0 0.0 0.0 0.0'
1824  read(str,*,err=20) ramp(:,i)
1825  end do
1826 case('step')
1827  read(50,*,err=20) nstep
1828  if (nstep < 1) then
1829  write(*,*)
1830  write(*,'("Error(readinput): nstep < 1 : ",I0)') nstep
1831  write(*,*)
1832  stop
1833  end if
1834  if (allocated(step)) deallocate(step)
1835  allocate(step(9,nstep))
1836  do i=1,nstep
1837  read(50,'(A)',err=20) str
1838  str=trim(str)//' 1.0 0.0 0.0 0.0'
1839  read(str,*,err=20) step(:,i)
1840  end do
1841 case('ncgga')
1842  read(50,*,err=20)
1843  write(*,'("Info(readinput): variable ''ncgga'' is no longer used")')
1844 case('dncgga')
1845  read(50,*,err=20) dncgga
1846  if (dncgga < 0.d0) then
1847  write(*,*)
1848  write(*,'("Error(readinput): dncgga < 0 : ",G18.10)') dncgga
1849  write(*,*)
1850  stop
1851  end if
1852 case('ntswrite')
1853  read(50,'(A)',err=20) str
1854  str=trim(str)//' 1'
1855  read(str,*,err=20) ntswrite(:)
1856 case('nxoapwlo','nxapwlo')
1857  read(50,*,err=20) nxoapwlo
1858  if (nxoapwlo < 0) then
1859  write(*,*)
1860  write(*,'("Error(readinput): nxoapwlo < 0 : ",I0)') nxoapwlo
1861  write(*,*)
1862  stop
1863  end if
1864 case('nxlo')
1865  read(50,*,err=20) nxlo
1866  if (nxlo < 0) then
1867  write(*,*)
1868  write(*,'("Error(readinput): nxlo < 0 : ",I0)') nxlo
1869  write(*,*)
1870  stop
1871  end if
1872 case('tdrho1d')
1873  read(50,*,err=20) tdrho1d
1874 case('tdrho2d')
1875  read(50,*,err=20) tdrho2d
1876 case('tdrho3d')
1877  read(50,*,err=20) tdrho3d
1878 case('tdmag1d')
1879  read(50,*,err=20) tdmag1d
1880 case('tdmag2d')
1881  read(50,*,err=20) tdmag2d
1882 case('tdmag3d')
1883  read(50,*,err=20) tdmag3d
1884 case('tdjr1d','tdcd1d')
1885  read(50,*,err=20) tdjr1d
1886 case('tdjr2d','tdcd2d')
1887  read(50,*,err=20) tdjr2d
1888 case('tdjr3d','tdcd3d')
1889  read(50,*,err=20) tdjr3d
1890 case('tddos')
1891  read(50,*,err=20) tddos
1892 case('tdlsj')
1893  read(50,*,err=20) tdlsj
1894 case('tdjtk')
1895  read(50,*,err=20) tdjtk
1896 case('tdxrmk')
1897  read(50,*,err=20) tdxrmk
1898 case('epseph')
1899  read(50,*,err=20)
1900  write(*,'("Info(readinput): variable ''epseph'' is no longer used")')
1901 case('rndevt0')
1902  read(50,*,err=20) rndevt0
1903 case('sxcscf','ssxc','rstsf')
1904  read(50,'(A)',err=20) str
1905  read(str,*,err=20) sxcscf
1906  read(str,*,iostat=ios) sxcscf,dsxcscf
1907 case('tempk')
1908  read(50,*,err=20) tempk
1909  if (tempk <= 0.d0) then
1910  write(*,*)
1911  write(*,'("Error(readinput): tempk <= 0 : ",G18.10)') tempk
1912  write(*,*)
1913  stop
1914  end if
1915 ! set Fermi-Dirac smearing
1916  stype=3
1917 ! set the smearing width
1919 case('avecu')
1920  read(50,*,err=20) avecu(:,1)
1921  read(50,*,err=20) avecu(:,2)
1922  read(50,*,err=20) avecu(:,3)
1923 case('scaleu')
1924  read(50,*,err=20) scu
1925 case('scaleu1')
1926  read(50,*,err=20) scu1
1927 case('scaleu2')
1928  read(50,*,err=20) scu2
1929 case('scaleu3')
1930  read(50,*,err=20) scu3
1931 case('q0cut')
1932  read(50,*,err=20) q0cut
1933 case('ngridkpa')
1934  read(50,*,err=20) ngridkpa
1935 case('rndbfcu')
1936  read(50,*,err=20) rndbfcu
1937 case('bfieldcu','bfielduc')
1938  read(50,*,err=20) bfieldcu
1939 case('efieldcu','efielduc')
1940  read(50,*,err=20) efieldcu
1941 case('tplotq0')
1942  read(50,*,err=20) tplotq0
1943 case('trdvclr')
1944  read(50,*,err=20) trdvclr
1945 case('trdbfcr')
1946  read(50,*,err=20) trdbfcr
1947 case('evtype')
1948  read(50,*,err=20)
1949  write(*,'("Info(readinput): variable ''evtype'' is no longer used")')
1950 case('wmaxgw')
1951  read(50,*,err=20) wmaxgw
1952 case('twdiag')
1953  read(50,*,err=20)
1954  write(*,'("Info(readinput): variable ''twdiag'' is no longer used")')
1955 case('tsediag')
1956  read(50,*,err=20) tsediag
1957 case('actype')
1958  read(50,*,err=20) actype
1959 case('npole')
1960  read(50,*,err=20) npole
1961  if (npole < 1) then
1962  write(*,*)
1963  write(*,'("Error(readinput): npole < 1 : ",I0)') npole
1964  write(*,*)
1965  stop
1966  end if
1967 case('nspade')
1968  read(50,*,err=20) nspade
1969  if (nspade < 1) then
1970  write(*,*)
1971  write(*,'("Error(readinput): nspade < 1 : ",I0)') nspade
1972  write(*,*)
1973  stop
1974  end if
1975 case('tfav0')
1976  read(50,*,err=20) tfav0
1977 case('rmtscf')
1978  read(50,*,err=20) rmtscf
1979  if (rmtscf <= 0.d0) then
1980  write(*,*)
1981  write(*,'("Error(readinput): rmtscf <= 0 : ",G18.10)') rmtscf
1982  write(*,*)
1983  stop
1984  end if
1985 case('mrmtav')
1986  read(50,*,err=20) mrmtav
1987 case('rmtall')
1988  read(50,*,err=20) rmtall
1989 case('maxthd','omp_num_threads','OMP_NUM_THREADS')
1990  read(50,*,err=20) maxthd
1991 case('maxthd1')
1992  read(50,*,err=20) maxthd1
1993 case('maxthdmkl')
1994  read(50,*,err=20) maxthdmkl
1995 case('maxlvl','omp_max_active_levels','OMP_MAX_ACTIVE_LEVELS')
1996  read(50,*,err=20) maxlvl
1997  if (maxlvl < 1) then
1998  write(*,*)
1999  write(*,'("Error(readinput): maxlvl < 1 : ",I0)') maxlvl
2000  write(*,*)
2001  stop
2002  end if
2003 case('stable')
2004  read(50,*,err=20) lv
2005  if (lv) then
2006  autolinengy=.true.
2007  mrmtav=1
2008  lmaxapw=max(lmaxapw,10)
2009  gmaxvr=max(gmaxvr,24.d0)
2010  msmgmt=max(msmgmt,1)
2011  if (mp_mpi) then
2012  write(*,*)
2013  write(*,'("Info(readinput): parameters set by stable option")')
2014  write(*,'(" autolinengy : ",L1)') autolinengy
2015  write(*,'(" mrmtav : ",I0)') mrmtav
2016  write(*,'(" lmaxapw : ",I0)') lmaxapw
2017  write(*,'(" gmaxvr : ",G18.10)') gmaxvr
2018  write(*,'(" msmgmt : ",I0)') msmgmt
2019  end if
2020  end if
2021 case('metagga')
2022  read(50,*,err=20) lv
2023  if (lv) then
2024  lmaxi=max(lmaxi,2)
2025  gmaxvr=max(gmaxvr,16.d0)
2026  nrmtscf=max(nrmtscf,3.d0)
2027  msmgmt=max(msmgmt,4)
2028  epspot=1.d6
2029  epsengy=min(epsengy,1.d-6)
2030  if (mp_mpi) then
2031  write(*,*)
2032  write(*,'("Info(readinput): parameters set by metagga option")')
2033  write(*,'(" lmaxi : ",I0)') lmaxi
2034  write(*,'(" gmaxvr : ",G18.10)') gmaxvr
2035  write(*,'(" nrmtscf : ",G18.10)') nrmtscf
2036  write(*,'(" msmgmt : ",I0)') msmgmt
2037  write(*,'(" epspot : ",G18.10)') epspot
2038  write(*,'(" epsengy : ",G18.10)') epsengy
2039  end if
2040  end if
2041 case('t0tdlr')
2042  read(50,*,err=20)
2043  write(*,'("Info(readinput): variable ''t0tdlr'' is no longer used")')
2044 case('tdphi')
2045  read(50,*,err=20) tdphi
2046 ! convert phase from degrees to radians
2047  tdphi=tdphi*pi/180.d0
2048 case('thetamld')
2049  read(50,*,err=20) thetamld
2050 ! convert MLD angle from degrees to radians
2051  thetamld=thetamld*pi/180.d0
2052 case('ntsbackup')
2053  read(50,*,err=20) ntsbackup
2054 case('seedname')
2055  read(50,*,err=20) seedname
2056  seedname=adjustl(seedname)
2057 case('num_wann')
2058  read(50,*,err=20) num_wann
2059 case('idxw90','wann_bands')
2060  read(50,'(A)',err=20) str
2061  num_bands=1024
2062  if (allocated(idxw90)) deallocate(idxw90)
2063  allocate(idxw90(num_bands))
2064  call numlist(str,num_bands,idxw90)
2065 case('num_iter')
2066  read(50,*,err=20) num_iter
2067 case('dis_num_iter')
2068  read(50,*,err=20) dis_num_iter
2069 case('trial_step')
2070  read(50,*,err=20) trial_step
2071 case('xlwin','wannierExtra')
2072  if (allocated(xlwin)) deallocate(xlwin)
2073  allocate(xlwin(0))
2074  nxlwin=0
2075  do
2076  read(50,'(A)',err=20) str
2077  if (trim(str) == '') goto 10
2078  xlwin=[xlwin(1:nxlwin),str]
2079  nxlwin=nxlwin+1
2080  end do
2081 case('wrtunk')
2082  read(50,*,err=20) wrtunk
2083 case('tbdip')
2084  read(50,*,err=20) tbdip
2085 case('tjr','tcden')
2086  read(50,*,err=20) tjr
2087 case('tauefm')
2088  read(50,*,err=20) tauefm
2089 case('epsefm')
2090  read(50,*,err=20) epsefm
2091 case('ehfb')
2092  read(50,*,err=20) ehfb
2093 case('t0gclq0')
2094  read(50,*,err=20) t0gclq0
2095 case('tafindt')
2096  read(50,*,err=20) tafindt
2097 case('afindscf')
2098  read(50,*,err=20)
2099  write(*,'("Info(readinput): variable ''afindscf'' is no longer used")')
2100 case('afindpm')
2101  read(50,*,err=20) afindpm(:)
2102  if (afindpm(2) == 0.d0) then
2103  write(*,*)
2104  write(*,'("Error(readinput): afindpm(2) = 0")')
2105  write(*,*)
2106  stop
2107  end if
2108 case('nkspolar')
2109  read(50,*,err=20) nkspolar
2110  if (nkspolar < 1) then
2111  write(*,*)
2112  write(*,'("Error(readinput): nkspolar < 1 : ",I0)') nkspolar
2113  write(*,*)
2114  stop
2115  end if
2116 case('ntsforce')
2117  read(50,*,err=20) ntsforce
2118  if (ntsforce < 1) then
2119  write(*,*)
2120  write(*,'("Error(readinput): ntsforce < 1 : ",I0)') ntsforce
2121  write(*,*)
2122  stop
2123  end if
2124 case('wphcut')
2125  read(50,*,err=20) wphcut
2126  if (wphcut <= 0.d0) then
2127  write(*,*)
2128  write(*,'("Error(readinput): wphcut <= 0 : ",G18.10)') wphcut
2129  write(*,*)
2130  stop
2131  end if
2132 case('ephscf')
2133  read(50,*,err=20) ephscf(:)
2134 case('anomalous')
2135  read(50,*,err=20) anomalous
2136 case('tephde')
2137  read(50,*,err=20) tephde
2138 case('bdiag')
2139  read(50,*,err=20) bdiag
2140 case('ecutb')
2141  read(50,*,err=20) ecutb
2142  if (ecutb <= 0.d0) then
2143  write(*,*)
2144  write(*,'("Error(readinput): ecutb <= 0 : ",G18.10)') ecutb
2145  write(*,*)
2146  stop
2147  end if
2148 case('ediag')
2149  read(50,*,err=20) ediag
2150 case('pwxpsn')
2151  read(50,*,err=20) pwxpsn
2152  if (pwxpsn < 1) then
2153  write(*,*)
2154  write(*,'("Error(readinput): pwxpsn < 1 : ",I0)') pwxpsn
2155  write(*,*)
2156  stop
2157  end if
2158 case('ramdisk')
2159  read(50,*,err=20) ramdisk
2160 case('wrtdisk','wrtdsk')
2161  read(50,*,err=20) wrtdisk
2162 case('epsdmat')
2163  read(50,*,err=20) epsdmat
2164 case('tm3vdl','tm3old')
2165  read(50,*,err=20) tm3vdl
2166 case('batch')
2167  read(50,*,err=20) batch
2168 case('tafspt')
2169  read(50,*,err=20) tafspt
2170 case('tbaspat')
2171  read(50,*,err=20) tbaspat
2172 case('trdatdv')
2173  read(50,*,err=20) trdatdv
2174 case('atdfc')
2175  read(50,*,err=20) atdfc
2176  if (atdfc < 0.d0) then
2177  write(*,*)
2178  write(*,'("Error(readinput): atdfc < 0 : ",G18.10)') atdfc
2179  write(*,*)
2180  stop
2181  end if
2182 case('maxforce')
2183  read(50,*,err=20) maxforce
2184 case('msmgmt','msmg2mt')
2185  read(50,*,err=20) msmgmt
2186 case('ntsorth')
2187  read(50,*,err=20) ntsorth
2188 case('deltabf')
2189  read(50,*,err=20) deltabf
2190  if (deltabf <= 0.d0) then
2191  write(*,*)
2192  write(*,'("Error(readinput): deltabf <= 0 : ",G18.10)') deltabf
2193  write(*,*)
2194  stop
2195  end if
2196 case('jtconst0')
2197  read(50,*,err=20) jtconst0
2198 case('trmt0')
2199  read(50,*,err=20) trmt0
2200 case('ksgwrho')
2201  read(50,*,err=20) ksgwrho
2202 case('npfftg')
2203  read(50,*,err=20) npfftg
2204 case('npfftgc')
2205  read(50,*,err=20) npfftgc
2206 case('npfftq')
2207  read(50,*,err=20) npfftq
2208 case('npfftw')
2209  read(50,*,err=20) npfftw
2210 case('tphnat')
2211  read(50,*,err=20) tphnat
2212 case('ecutthc')
2213  read(50,*,err=20) ecutthc
2214  if (ecutthc <= 0.d0) then
2215  write(*,*)
2216  write(*,'("Error(readinput): ecutthc <= 0 : ",G18.10)') ecutthc
2217  write(*,*)
2218  stop
2219  end if
2220 case('tbdipu')
2221  read(50,*,err=20) tbdipu
2222 case('bdipscf')
2223  read(50,*,err=20) bdipscf
2224 case('')
2225  goto 10
2226 case default
2227  write(*,*)
2228  write(*,'("Error(readinput): invalid block name : ",A)') trim(block)
2229  write(*,*)
2230  stop
2231 end select
2232 goto 10
2233 20 continue
2234 write(*,*)
2235 write(*,'("Error(readinput): error reading from elk.in")')
2236 write(*,'("Problem occurred in ''",A,"'' block")') trim(block)
2237 write(*,'("Check input convention in manual")')
2238 write(*,*)
2239 stop
2240 30 continue
2241 close(50)
2242 ! scale the speed of light
2243 solsc=sol*solscf
2244 ! scale and rotate the lattice vectors (not referenced again in code)
2245 avec(:,:)=sc*avec(:,:)
2246 avec(:,1)=sc1*avec(:,1)
2247 avec(:,2)=sc2*avec(:,2)
2248 avec(:,3)=sc3*avec(:,3)
2249 avec(1,:)=scx*avec(1,:)
2250 avec(2,:)=scy*avec(2,:)
2251 avec(3,:)=scz*avec(3,:)
2252 t1=axang(4)
2253 if (t1 /= 0.d0) then
2254  t1=t1*pi/180.d0
2255  call axangrot(axang(:),t1,rot)
2256  do i=1,3
2257  v(:)=avec(:,i)
2258  call r3mv(rot,v,avec(:,i))
2259  end do
2260 end if
2261 ! randomise lattice vectors if required
2262 if (rndavec > 0.d0) then
2263  do i=1,3
2264  do j=1,3
2265  t1=rndavec*(randomu()-0.5d0)
2266  avec(i,j)=avec(i,j)+t1
2267  end do
2268  end do
2269 end if
2270 ! check if reference lattice vectors should be used
2271 tavref=(any(abs(avecref(:,:)) > epslat))
2272 ! case of isolated molecule
2273 if (molecule) then
2274 ! convert atomic positions from Cartesian to lattice coordinates
2275  call r3minv(avec,ainv)
2276  do is=1,nspecies
2277  do ia=1,natoms(is)
2278  call r3mv(ainv,atposl(:,ia,is),v)
2279  atposl(:,ia,is)=v(:)
2280  end do
2281  end do
2282 end if
2283 ! randomise atomic positions if required
2284 if (rndatposc > 0.d0) then
2285  call r3minv(avec,ainv)
2286  do is=1,nspecies
2287  do ia=1,natoms(is)
2288  call r3mv(avec,atposl(:,ia,is),v)
2289  do i=1,3
2290  t1=rndatposc*(randomu()-0.5d0)
2291  v(i)=v(i)+t1
2292  end do
2293  call r3mv(ainv,v,atposl(:,ia,is))
2294  end do
2295  end do
2296 end if
2297 ! randomise the muffin-tin magnetic fields if required
2298 if (rndbfcmt > 0.d0) then
2299  do is=1,nspecies
2300  do ia=1,natoms(is)
2301  do i=1,3
2302  t1=rndbfcmt*(randomu()-0.5d0)
2303  bfcmt0(i,ia,is)=bfcmt0(i,ia,is)+t1
2304  end do
2305  end do
2306  end do
2307 end if
2308 ! set fxctype to fxctype if required
2309 if (fxctype(1) == -1) fxctype(:)=xctype(:)
2310 ! find primitive cell if required
2311 if (primcell) call findprimcell
2312 ! scale the ultracell vectors if required
2313 avecu(:,1)=scu1*avecu(:,1)
2314 avecu(:,2)=scu2*avecu(:,2)
2315 avecu(:,3)=scu3*avecu(:,3)
2316 avecu(:,:)=scu*avecu(:,:)
2317 ! read in atomic species data
2318 call readspecies
2319 return
2320 
2321 end subroutine
2322 !EOC
2323 
real(8) socscf
Definition: modmain.f90:232
integer ngrkf
Definition: modmain.f90:1069
real(8) ecvcut
Definition: modmain.f90:117
integer maxlatvstp
Definition: modmain.f90:1033
real(8), dimension(3, 3) dafspc
Definition: modmain.f90:331
real(8) epsband
Definition: modmain.f90:820
subroutine genfspecies(zn, symb)
Definition: genfspecies.f90:7
character(256) scrpath
Definition: modmain.f90:1297
real(8) dchgexs
Definition: modmain.f90:724
real(8), dimension(3, maxatoms, maxspecies) bfcmt0
Definition: modmain.f90:275
integer, parameter maxspecies
Definition: modmain.f90:30
integer ncxbse
Definition: modmain.f90:1179
real(8) scissor
Definition: modmain.f90:907
real(8), dimension(3, 3) afspc
Definition: modmain.f90:331
subroutine findprimcell
real(8) dmaxefc
Definition: modmain.f90:318
real(8) epsforce
Definition: modmain.f90:1059
logical tjr
Definition: modmain.f90:620
integer, dimension(maxxbse) jstxbse
Definition: modmain.f90:1181
integer lorbordc
Definition: modmain.f90:837
integer maxthd1
Definition: modomp.f90:13
integer mixtype
Definition: modmain.f90:695
integer, dimension(3) ktype
Definition: modmain.f90:606
real(8), dimension(3, 3) davec
Definition: modmain.f90:12
real(8), dimension(3, maxatoms, maxspecies) datposl
Definition: modmain.f90:52
integer maxthd
Definition: modomp.f90:11
integer, dimension(3) xctype
Definition: modmain.f90:588
logical spinpol
Definition: modmain.f90:228
integer, parameter maxlapw
Definition: modmain.f90:195
integer npfftg
Definition: modmain.f90:404
integer mbwgrf
Definition: modmain.f90:1160
integer, dimension(3) xctsp
Definition: modmain.f90:142
logical tshift
Definition: modmain.f90:352
character(256) sppath
Definition: modmain.f90:72
real(8) rmtall
Definition: modmain.f90:158
real(8) taufsm
Definition: modmain.f90:265
logical tefvit
Definition: modmain.f90:871
real(8) reducebf
Definition: modmain.f90:279
logical autokpt
Definition: modmain.f90:444
integer msmgmt
Definition: modmain.f90:222
logical tfav0
Definition: modmain.f90:997
real(8) dnrmtscf
Definition: modmain.f90:148
real(8) sxcscf
Definition: modmain.f90:668
real(8), dimension(3, 3) ainv
Definition: modmain.f90:14
real(8), dimension(2) amixpm
Definition: modmain.f90:702
logical lorbcnd
Definition: modmain.f90:835
real(8) rmtscf
Definition: modmain.f90:154
subroutine r3minv(a, b)
Definition: r3minv.f90:10
logical spinsprl
Definition: modmain.f90:283
Definition: modomp.f90:6
real(8), parameter kboltz
Definition: modmain.f90:1257
real(8) swidth
Definition: modmain.f90:891
logical hybrid0
Definition: modmain.f90:1146
real(8) epsocc
Definition: modmain.f90:899
real(8) dncgga
Definition: modmain.f90:604
character(256), dimension(maxspecies) spfname
Definition: modmain.f90:74
real(8) dnempty0
Definition: modmain.f90:879
real(8), dimension(3, 0:3) vclp3d
Definition: modmain.f90:1126
integer, dimension(maxxbse) istxbse
Definition: modmain.f90:1181
integer nvxbse
Definition: modmain.f90:1179
integer notelns
Definition: modmain.f90:1299
integer, parameter maxxbse
Definition: modmain.f90:1177
subroutine numlist(str, n, list)
Definition: numlist.f90:10
logical mixrho
Definition: modmain.f90:687
logical nosource
Definition: modmain.f90:664
real(8), dimension(3) vkloff
Definition: modmain.f90:450
integer maxthdmkl
Definition: modomp.f90:15
integer lmaxo
Definition: modmain.f90:201
real(8), dimension(3) vqlss
Definition: modmain.f90:293
logical trhonorm
Definition: modmain.f90:618
integer, parameter maxkst
Definition: modmain.f90:919
real(8) c_tb09
Definition: modmain.f90:678
real(8), parameter pi
Definition: modmain.f90:1226
real(8), dimension(3) vecql
Definition: modmain.f90:1098
real(8) nempty0
Definition: modmain.f90:879
integer nkstlist
Definition: modmain.f90:921
logical dosmsum
Definition: modmain.f90:1081
integer nxlo
Definition: modmain.f90:841
logical tc_tb09
Definition: modmain.f90:680
integer dlmaxo
Definition: modmain.f90:201
integer ntasks
Definition: modmain.f90:1287
integer lmaxapw
Definition: modmain.f90:197
real(8) nrmtscf
Definition: modmain.f90:148
integer symtype
Definition: modmain.f90:340
real(8) epschg
Definition: modmain.f90:712
real(8), dimension(2) broydpm
Definition: modmain.f90:706
logical tefvr
Definition: modmain.f90:868
real(8), dimension(3) momfix
Definition: modmain.f90:253
integer mixsdb
Definition: modmain.f90:704
logical bforb
Definition: modmain.f90:234
logical tforce
Definition: modmain.f90:983
real(8) rmtdelta
Definition: modmain.f90:160
real(8), dimension(3, 3) avecref
Definition: modmain.f90:1024
Definition: modrdm.f90:6
integer ncbse0
Definition: modmain.f90:1175
integer maxlvl
Definition: modomp.f90:17
real(8), dimension(2) wplot
Definition: modmain.f90:1073
real(8), dimension(3, maxatoms, maxspecies) atposl
Definition: modmain.f90:51
real(8) emaxrf
Definition: modmain.f90:1156
real(8) gmaxrf
Definition: modmain.f90:1154
real(8) delorb
Definition: modmain.f90:802
logical lmirep
Definition: modmain.f90:1092
real(8) esccut
Definition: modmain.f90:119
Definition: modw90.f90:6
real(8), dimension(3) sqaxis
Definition: modmain.f90:1095
logical intraband
Definition: modmain.f90:1089
real(8) rndatposc
Definition: modmain.f90:56
real(8) radkpt
Definition: modmain.f90:446
integer, parameter maxlorbord
Definition: modmain.f90:782
integer nvbse0
Definition: modmain.f90:1175
Definition: modbog.f90:6
real(8) deltaem
Definition: modmain.f90:481
integer lmaxdb
Definition: modmain.f90:1075
real(8), dimension(3) dbfieldc0
Definition: modmain.f90:271
pure subroutine axangrot(v, th, rot)
Definition: axangrot.f90:10
real(8), dimension(3, 3) avec
Definition: modmain.f90:12
real(8) rndbfcmt
Definition: modmain.f90:277
real(8), dimension(2) wsfac
Definition: modmain.f90:1102
real(8) tempk
Definition: modmain.f90:684
integer, dimension(3, 27) optcomp
Definition: modmain.f90:1087
integer, dimension(2, maxkst) kstlist
Definition: modmain.f90:923
real(8) rgkmax
Definition: modmain.f90:493
integer, dimension(3) ngridk
Definition: modmain.f90:448
real(8) maxforce
Definition: modmain.f90:994
logical cmagz
Definition: modmain.f90:242
integer lradstp
Definition: modmain.f90:171
integer, parameter maxatoms
Definition: modmain.f90:32
real(8), dimension(3) dafieldc
Definition: modmain.f90:325
integer, parameter maxtasks
Definition: modmain.f90:1285
real(8), parameter sol
Definition: modmain.f90:1245
logical tpdos
Definition: modmain.f90:1079
real(8), dimension(3) dvqlss
Definition: modmain.f90:293
real(8), dimension(3) afieldc
Definition: modmain.f90:325
integer latvopt
Definition: modmain.f90:1031
real(8), dimension(3, 0:2) vclp2d
Definition: modmain.f90:1122
real(8), dimension(3, maxatoms, maxspecies) mommtfix
Definition: modmain.f90:259
logical mixsave
Definition: modmain.f90:700
integer ip01d
Definition: modmain.f90:1112
logical tavref
Definition: modmain.f90:1026
integer npfftq
Definition: modmain.f90:535
real(8) solsc
Definition: modmain.f90:1247
real(8) tau0atp
Definition: modmain.f90:1005
integer, dimension(3) ngridq
Definition: modmain.f90:515
real(8) momfixm
Definition: modmain.f90:255
real(8) drgkmax
Definition: modmain.f90:493
logical t0gclq0
Definition: modmain.f90:555
Definition: modgw.f90:6
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36
integer nwrite
Definition: modmain.f90:1053
logical ssdph
Definition: modmain.f90:285
integer noptcomp
Definition: modmain.f90:1085
real(8) epslat
Definition: modmain.f90:24
integer maxitoep
Definition: modmain.f90:1136
real(8), dimension(maxatoms, maxspecies) mommtfixm
Definition: modmain.f90:261
integer ndspem
Definition: modmain.f90:483
integer stype
Definition: modmain.f90:887
logical hxbse
Definition: modmain.f90:1203
Definition: modmpi.f90:6
subroutine readspecies
Definition: readspecies.f90:7
logical dosssum
Definition: modmain.f90:1083
real(8) mstar
Definition: modmain.f90:895
real(8) epspot
Definition: modmain.f90:1055
real(8) dsxcscf
Definition: modmain.f90:668
integer nefvit
Definition: modmain.f90:873
logical ptnucl
Definition: modmain.f90:83
Definition: modpw.f90:6
real(8), dimension(:,:), allocatable vvlp1d
Definition: modmain.f90:1114
real(8) dlefe
Definition: modmain.f90:830
logical autolinengy
Definition: modmain.f90:828
integer nswplot
Definition: modmain.f90:1071
logical tbdip
Definition: modmain.f90:643
real(8) deapw
Definition: modmain.f90:764
logical spinorb
Definition: modmain.f90:230
integer maxatpstp
Definition: modmain.f90:1003
real(8), dimension(3) bfieldc0
Definition: modmain.f90:271
real(8) tau0oep
Definition: modmain.f90:1138
integer, dimension(3) dngridk
Definition: modmain.f90:448
subroutine readinput
Definition: readinput.f90:10
integer nspecies
Definition: modmain.f90:34
integer, dimension(2) np2d
Definition: modmain.f90:1124
logical bsefull
Definition: modmain.f90:1200
real(8), dimension(3) dmomfix
Definition: modmain.f90:253
logical autodlefe
Definition: modmain.f90:833
integer, dimension(3) np3d
Definition: modmain.f90:1128
integer reducek
Definition: modmain.f90:455
real(8) emaxelnes
Definition: modmain.f90:1100
real(8) tau0latv
Definition: modmain.f90:1035
real(8) bdipscf
Definition: modmain.f90:645
logical autoswidth
Definition: modmain.f90:893
integer nkspolar
Definition: modmain.f90:485
integer reduceq
Definition: modmain.f90:519
character(256), dimension(:), allocatable notes
Definition: modmain.f90:1301
pure subroutine r3mv(a, x, y)
Definition: r3mv.f90:10
Definition: modulr.f90:6
integer nwplot
Definition: modmain.f90:1067
real(8) deltabf
Definition: modmain.f90:281
integer mrmtav
Definition: modmain.f90:156
real(8) epsstress
Definition: modmain.f90:1061
real(8) chgexs
Definition: modmain.f90:724
real(8) demaxbnd
Definition: modmain.f90:823
integer nvp1d
Definition: modmain.f90:1108
real(8), dimension(3, maxatoms, maxspecies) atposc
Definition: modmain.f90:54
subroutine genspecies(fnum)
Definition: genspecies.f90:7
logical hdbse
Definition: modmain.f90:1203
integer, dimension(maxtasks) tasks
Definition: modmain.f90:1291
integer npp1d
Definition: modmain.f90:1110
logical molecule
Definition: modmain.f90:47
real(8) epsengy
Definition: modmain.f90:1057
real(8), dimension(3) efieldc
Definition: modmain.f90:312
integer dlmaxapw
Definition: modmain.f90:197
integer npfftgc
Definition: modmain.f90:408
integer nxoapwlo
Definition: modmain.f90:839
real(8), dimension(3) vklem
Definition: modmain.f90:479
real(8) hybridc
Definition: modmain.f90:1148
logical dosocc
Definition: modmain.f90:1077
logical trmt0
Definition: modmain.f90:165
integer maxscl
Definition: modmain.f90:1043
real(8) dgmaxvr
Definition: modmain.f90:384
logical spincore
Definition: modmain.f90:937
integer npmae0
Definition: modmain.f90:302
integer isgkmax
Definition: modmain.f90:491
real(8) atdfc
Definition: modmain.f90:66
logical primcell
Definition: modmain.f90:49
integer atpopt
Definition: modmain.f90:1001
real(8) fracinr
Definition: modmain.f90:209
real(8) deltast
Definition: modmain.f90:1016
integer fsmtype
Definition: modmain.f90:251
logical trdatdv
Definition: modmain.f90:62
real(8) gmaxvr
Definition: modmain.f90:384
integer lmaxi
Definition: modmain.f90:205
logical bfdmag
Definition: modmain.f90:236