wann_read_inp.f90 24.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

module m_wann_read_inp

contains
subroutine wann_read_inp(input,l_p0,wann)
!********************************************
!     Read the Wannier input file 'wann_inp'.
!     Frank Freimuth
!********************************************
   use m_judft
   use m_types

   implicit none

   TYPE(t_input), intent(in)   :: input
   TYPE(t_wann), intent(inout) :: wann
   logical,intent(in)          :: l_p0

   logical           :: l_file,l_orbcompinp
   integer           :: i,ios,n
   character(len=30) :: task
   real              :: version_real

!-----some defaults
   wann%l_atomlist=.false.
   wann%l_ndegen=.false.
   wann%l_orbitalmom=.false.
   wann%l_orbcomp=.false.
   wann%l_orbcomprs=.false.
   wann%l_perturbrs=.false.
   wann%l_denmat=.false.                                             
   wann%l_perturb=.false.
   wann%l_nedrho=.false.
   wann%l_anglmomrs=.false.
   wann%l_anglmom=.false.
   wann%l_socspicom=.false.
   wann%l_socspicomrs=.false.
   wann%l_offdiposoprs=.false.
   wann%l_offdiposop=.false.
   wann%l_spindisp=.false.
   wann%l_spindisprs=.false.
   wann%l_torque=.false.
   wann%l_torquers=.false.
   wann%l_berry=.false.
   wann%l_perpmag=.false.
   wann%l_perpmagrs=.false.
   wann%l_perpmagat=.false.
   wann%l_perpmagatrs=.false.
   wann%l_socmatrs=.false.
   wann%l_socmat=.false.
   wann%l_soctomom=.false.
   wann%l_kptsreduc2=.false.
   wann%l_nablars=.false.
   wann%l_nablapaulirs=.false.
   wann%l_surfcurr=.false.
   wann%l_updown=.false.
   wann%l_ahe=.false.
   wann%l_she=.false.
   wann%l_rmat=.false.
   wann%l_nabla=.false.
   wann%l_socodi=.false.
   wann%l_pauli=.false.
   wann%l_pauliat=.false.
   wann%l_potmat=.false.
   wann%l_projgen=.false.
   wann%l_stopopt=.false.
   wann%l_kpointgen=.false.
   wann%l_w90kpointgen=.false.
   wann%l_plot_symm=.false.
   wann%l_socmmn0=.false.
   wann%l_bzsym=.false.
   wann%l_hopping=.false.
   wann%l_kptsreduc=.false.
   wann%l_prepwan90=.false.
   wann%l_plot_umdat=.false.
   wann%l_wann_plot=.false.
   wann%l_bynumber=.false.
   wann%l_matrixmmn=.false.
   wann%l_matrixamn=.false.
   wann%l_projmethod=.false.
   wann%l_wannierize=.false.
   wann%l_plotw90=.false.
   wann%l_byenergy=.false.
   wann%l_proj_plot=.false.
   wann%l_bestproj=.false.
   wann%l_ikptstart=.false.
   wann%l_lapw=.false.
   wann%l_plot_lapw=.false.
   wann%l_fermi=.false.
   wann%l_dipole=.false.
   wann%l_dipole2=.false.
   wann%l_dipole3=.false.
   wann%l_mmn0=.false.
   wann%l_mmn0at=.false.
   wann%l_manyfiles=.false.
   wann%l_collectmanyfiles=.false.
   wann%l_ldauwan=.false.
   wann%l_lapw_kpts=.false.
   wann%l_lapw_gfleur=.false.
   wann%l_unformatted=.false.
   wann%l_finishnocoplot=.false.
   wann%l_finishgwf=.false.
   wann%l_skipkov=.false.
   wann%l_matrixuHu=.false.
   wann%l_matrixuHu_dmi=.false.
   wann%ikptstart=1
   wann%wan90version=2 ! Set the standard to Wannier90-1.2

!-----read the input file 'wann_inp'
   l_file=.false.
   inquire(file='wann_inp',exist=l_file)
   IF ((.not.l_file).AND.(.NOT.input%l_inpXML)) THEN
      CALL juDFT_error ("wann_inp not found", calledby="wann_read_inp")
   END IF
   IF (l_file) THEN
      wann%band_min(1:2)=-1
      wann%band_max(1:2)=-1
      wann%l_byindex=.false.
      open(916,file='wann_inp',form='formatted')
      i=0
      do 
         i=i+1
         read(916,'(a)',iostat=ios)task
         if(ios.ne.0)exit
         if(l_p0) write(6,*)"line ",i,":",task
         if(task(1:1).eq.'!')cycle
         if(index(task,'=F').ne.0.or.index(task,'=f').ne.0)cycle
         read(task,*,iostat=ios)task
         if(index(task,'=').ne.0)then
            task=task(1:(index(task,'=')-1))
         endif
         if(l_p0) write(6,*)"==>key: ",task
         if(trim(task).eq.'endjobs')then
            exit
         elseif(trim(task).eq.'nabla')then
            wann%l_nabla=.true.
         elseif(trim(task).eq.'kptsreduc2')then
            wann%l_kptsreduc2=.true.
            backspace(916)
            read(916,*,iostat=ios)task,wann%mhp(1),wann%mhp(2),wann%mhp(3)
            if (ios /= 0) CALL juDFT_error ("error reading mhp", calledby="wann_read_inp")
            if(l_p0)write(6,*)"mhp=",wann%mhp(1),wann%mhp(2),wann%mhp(3)
         elseif(trim(task).eq.'nablars')then
            wann%l_nablars=.true.
         elseif(trim(task).eq.'nablapaulirs')then
            wann%l_nablapaulirs=.true.
         elseif(trim(task).eq.'socspicom')then
            wann%l_socspicom=.true.
         elseif(trim(task).eq.'orbitalmom')then
            wann%l_orbitalmom=.true.
         elseif(trim(task).eq.'anglmom')then
            wann%l_anglmom=.true.
         elseif(trim(task).eq.'ndegen')then
            wann%l_ndegen=.true.
         elseif(trim(task).eq.'unformatted')then
            wann%l_unformatted=.true.
         elseif(trim(task).eq.'orbcomp')then
            wann%l_orbcomp=.true.
         elseif(trim(task).eq.'orbcomprs')then
            wann%l_orbcomprs=.true.
         elseif(trim(task).eq.'denmat')then
            wann%l_denmat=.true.
         elseif(trim(task).eq.'nedrho')then
            wann%l_nedrho=.true.
         elseif(trim(task).eq.'perturb')then
            wann%l_perturb=.true.
         elseif(trim(task).eq.'perturbrs')then
            wann%l_perturbrs=.true.
         elseif(trim(task).eq.'rmat')then
            wann%l_rmat=.true.
         elseif(trim(task).eq.'anglmomrs')then
            wann%l_anglmomrs=.true.
         elseif(trim(task).eq.'socspicomrs')then
            wann%l_socspicomrs=.true.
         elseif(trim(task).eq.'she')then
            wann%l_she=.true.
         elseif(trim(task).eq.'berry')then
            wann%l_berry=.true.
         elseif(trim(task).eq.'offdiposop')then
            wann%l_offdiposop=.true.
         elseif(trim(task).eq.'offdiposoprs')then
            wann%l_offdiposoprs=.true.
         elseif(trim(task).eq.'spindisp')then
            wann%l_spindisp=.true.
         elseif(trim(task).eq.'spindisprs')then
            wann%l_spindisprs=.true.
         elseif(trim(task).eq.'torque')then
            wann%l_torque=.true.
         elseif(trim(task).eq.'torquers')then
            wann%l_torquers=.true.
         elseif(trim(task).eq.'perpmag')then
            wann%l_perpmag=.true.
         elseif(trim(task).eq.'perpmagrs')then
            wann%l_perpmagrs=.true.
         elseif(trim(task).eq.'perpmagat')then
            wann%l_perpmagat=.true.
         elseif(trim(task).eq.'perpmagatrs')then
            wann%l_perpmagatrs=.true.
         elseif(trim(task).eq.'socmat')then
            wann%l_socmat=.true.
         elseif(trim(task).eq.'socmatrs')then
            wann%l_socmatrs=.true.
         elseif(trim(task).eq.'soctomom')then
            wann%l_soctomom=.true.
         elseif(trim(task).eq.'surfcurr')then
            wann%l_surfcurr=.true.
         elseif(trim(task).eq.'lapw_kpts')then
            wann%l_lapw_kpts=.true.
         elseif(trim(task).eq.'updown')then
            wann%l_updown=.true.
         elseif(trim(task).eq.'stopopt')then
            wann%l_stopopt=.true.
         elseif(trim(task).eq.'projgen')then
            wann%l_projgen=.true.
         elseif(trim(task).eq.'kpointgen')then
            wann%l_kpointgen=.true.
         elseif(trim(task).eq.'potmat')then
            wann%l_potmat=.true.
         elseif(trim(task).eq.'w90kpointgen')then
            wann%l_w90kpointgen=.true.
         elseif(trim(task).eq.'lapw_gfleur')then
            wann%l_lapw_gfleur=.true.
            backspace(916)
            read(916,*,iostat=ios)task,wann%gfthick,wann%gfcut
            if (ios /= 0) CALL juDFT_error ("error reading gfcut", calledby="wann_read_inp")
            if(l_p0)write(6,*)"gfcut=",wann%gfthick,wann%gfcut
         elseif(trim(task).eq.'lapw')then
            wann%l_lapw=.true.
            backspace(916)
            read(916,*,iostat=ios)task,wann%unigrid(:)
            if (ios /= 0) CALL juDFT_error ("error reading unigrid", calledby="wann_read_inp")
            if(l_p0)write(6,*)"unigrid=",wann%unigrid(:)
         elseif(trim(task).eq.'plot_lapw')then
            wann%l_plot_lapw=.true.
         elseif(trim(task).eq.'bzsym')then
            wann%l_bzsym=.true.
         elseif(trim(task).eq.'mmn0')then
            wann%l_mmn0=.true.
         elseif(trim(task).eq.'mmn0at')then
            wann%l_mmn0at=.true.
         elseif(trim(task).eq.'manyfiles')then
            wann%l_manyfiles=.true.
         elseif(trim(task).eq.'collectmanyfiles')then
            wann%l_collectmanyfiles=.true.
         elseif(trim(task).eq.'bestproj')then
            wann%l_bestproj=.true.
         elseif(trim(task).eq.'pauli')then
            wann%l_pauli=.true.
         elseif(trim(task).eq.'pauliat')then
            wann%l_pauliat=.true.
         elseif(trim(task).eq.'proj_plot')then
            wann%l_proj_plot=.true.
         elseif(trim(task).eq.'hopping')then
            wann%l_hopping=.true.
         elseif(trim(task).eq.'plot_symm')then
            wann%l_plot_symm=.true.
         elseif(trim(task).eq.'kptsreduc')then
            wann%l_kptsreduc=.true.
         elseif(trim(task).eq.'fermi')then
            wann%l_fermi=.true.
         elseif(trim(task).eq.'prepwan90')then
            wann%l_prepwan90=.true.
         elseif(trim(task).eq.'plot_umdat')then
            wann%l_plot_umdat=.true.
         elseif(trim(task).eq.'wann_plot')then
            wann%l_wann_plot=.true.
         elseif(trim(task).eq.'bynumber')then
            wann%l_bynumber=.true.
         elseif(trim(task).eq.'matrixmmn')then
            wann%l_matrixmmn=.true.
         elseif(trim(task).eq.'projmethod')then
            wann%l_projmethod=.true.
         elseif(trim(task).eq.'matrixamn')then
            wann%l_matrixamn=.true.
         elseif(trim(task).eq.'wannierize')then
            wann%l_wannierize=.true.
         elseif(trim(task).eq.'plotw90')then
            wann%l_plotw90=.true.
         elseif(trim(task).eq.'dipole')then
            wann%l_dipole=.true.
         elseif(trim(task).eq.'dipole3')then
            wann%l_dipole3=.true.
         elseif(trim(task).eq.'ldauwan')then
            wann%l_ldauwan=.true.
         elseif(trim(task).eq.'byenergy')then
            wann%l_byenergy=.true.
         elseif(trim(task).eq.'finishnocoplot') then
            wann%l_finishnocoplot=.true.
         elseif(trim(task).eq.'finishgwf') then
            wann%l_finishgwf=.true.
         elseif(trim(task).eq.'skipkov') then
            wann%l_skipkov=.true.
         elseif(trim(task).eq.'matrixuhu') then
            wann%l_matrixuHu=.true.
         elseif(trim(task).eq.'matrixuhu-dmi') then
            wann%l_matrixuHu_dmi=.true.
         elseif(trim(task).eq.'wan90version')then
            backspace(916)
            read(916,*,iostat=ios)task,version_real
            if (ios /= 0) CALL judft_error("error reading wan90version", calledby="wann_read_inp")
            if(abs(version_real-1.1).lt.1.e-9)then
               wann%wan90version=1
            elseif(abs(version_real-1.2).lt.1.e-9)then
               wann%wan90version=2
            elseif(abs(version_real-2.0).lt.1.e-9)then
               wann%wan90version=3
            else
              CALL judft_error ("chosen w90 version unknown", calledby="wann_read_inp")
            endif
         elseif(trim(task).eq.'atomlist')then
            wann%l_atomlist=.true.
            backspace(916)
            read(916,*,iostat=ios)task,wann%atomlist_num
            if (ios /= 0) CALL judft_error ("error reading atomlist_num", calledby="wann_read_inp")
            if(allocated(wann%atomlist))deallocate(wann%atomlist)
            allocate(wann%atomlist(wann%atomlist_num))
            backspace(916)
            read(916,*,iostat=ios)task,wann%atomlist_num,wann%atomlist
            if (ios /= 0) CALL judft_error ("error reading atomlist", calledby="wann_read_inp")
            if(l_p0)write(6,*)"atomlist_num=",wann%atomlist_num
            if(l_p0)write(6,*)"atomlist=",wann%atomlist
         elseif(trim(task).eq.'byindex')then
            wann%l_byindex=.true.
            backspace(916)
            read(916,*,iostat=ios)task,wann%band_min(1),wann%band_max(1)
            if (ios /= 0) CALL juDFT_error("error reading byindex,band_min,band_max", calledby="wann_read_inp")
            if(l_p0)write(6,*)"band_min=",wann%band_min(1)
            if(l_p0)write(6,*)"band_max=",wann%band_max(1)
            if(wann%band_min(2).eq.-1)then
               wann%band_min(2)=wann%band_min(1)
               wann%band_max(2)=wann%band_max(1)
            endif
         elseif(trim(task).eq.'byindex2')then
            wann%l_byindex=.true.
            backspace(916)
            read(916,*,iostat=ios)task,wann%band_min(2),wann%band_max(2)
            if (ios /= 0) CALL juDFT_error ("error reading byindex2,band_min2,band_max", calledby="wann_read_inp")
            if(l_p0)write(6,*)"band_min2=",wann%band_min(2)
            if(l_p0)write(6,*)"band_max2=",wann%band_max(2)
            if(wann%band_min(1).eq.-1)then
               wann%band_min(1)=wann%band_min(2)
               wann%band_max(1)=wann%band_max(2)
            endif
         elseif(trim(task).eq.'ikptstart')then
            wann%l_ikptstart=.true.
            backspace(916)
            read(916,*,iostat=ios)task,wann%ikptstart
            if (ios /= 0) CALL juDFT_error ("error reading ikptstart", calledby="wann_read_inp")
            if(l_p0)write(6,*)"ikptstart=",wann%ikptstart
         else
            write(6,*)"unrecognized key: ",task
            CALL juDFT_error ("unrecognized key in wann_inp", calledby="wann_read_inp")
         endif
      enddo

      if (ios /= 0) CALL juDFT_error ("error reading wann_inp", calledby="wann_read_inp")
      if(l_p0.and.ios.lt.0)write(6,*)"end of wann_inp reached"
      close(916)

   ELSE IF (input%l_inpXML) THEN

      DO i = 1, SIZE(wann%jobList)
         task = TRIM(ADJUSTL(wann%jobList(i)))
         if(l_p0) write(6,*)"task ",i,":",task
         if(task(1:1).eq.'!')cycle
         if(index(task,'=F').ne.0.or.index(task,'=f').ne.0)cycle
         read(task,*,iostat=ios)task
         if(index(task,'=').ne.0)then
            task=task(1:(index(task,'=')-1))
         endif
         if(l_p0) write(6,*)"==>key: ",task
         if(trim(task).eq.'endjobs') THEN
            EXIT
         elseif(trim(task).eq.'nabla')then
            wann%l_nabla=.true.
!         elseif(trim(task).eq.'kptsreduc2')then
!            wann%l_kptsreduc2=.true.
!            backspace(916)
!            read(916,*,iostat=ios)task,wann%mhp(1),wann%mhp(2),wann%mhp(3)
!            if (ios /= 0) CALL juDFT_error ("error reading mhp", calledby="wann_read_inp")
!            if(l_p0)write(6,*)"mhp=",wann%mhp(1),wann%mhp(2),wann%mhp(3)
         elseif(trim(task).eq.'nablars')then
            wann%l_nablars=.true.
         elseif(trim(task).eq.'nablapaulirs')then
            wann%l_nablapaulirs=.true.
         elseif(trim(task).eq.'socspicom')then
            wann%l_socspicom=.true.
         elseif(trim(task).eq.'orbitalmom')then
            wann%l_orbitalmom=.true.
         elseif(trim(task).eq.'anglmom')then
            wann%l_anglmom=.true.
         elseif(trim(task).eq.'ndegen')then
            wann%l_ndegen=.true.
         elseif(trim(task).eq.'unformatted')then
            wann%l_unformatted=.true.
         elseif(trim(task).eq.'orbcomp')then
            wann%l_orbcomp=.true.
         elseif(trim(task).eq.'orbcomprs')then
            wann%l_orbcomprs=.true.
         elseif(trim(task).eq.'denmat')then
            wann%l_denmat=.true.
         elseif(trim(task).eq.'nedrho')then
            wann%l_nedrho=.true.
         elseif(trim(task).eq.'perturb')then
            wann%l_perturb=.true.
         elseif(trim(task).eq.'perturbrs')then
            wann%l_perturbrs=.true.
         elseif(trim(task).eq.'rmat')then
            wann%l_rmat=.true.
         elseif(trim(task).eq.'anglmomrs')then
            wann%l_anglmomrs=.true.
         elseif(trim(task).eq.'socspicomrs')then
            wann%l_socspicomrs=.true.
         elseif(trim(task).eq.'she')then
            wann%l_she=.true.
         elseif(trim(task).eq.'berry')then
            wann%l_berry=.true.
         elseif(trim(task).eq.'offdiposop')then
            wann%l_offdiposop=.true.
         elseif(trim(task).eq.'offdiposoprs')then
            wann%l_offdiposoprs=.true.
         elseif(trim(task).eq.'spindisp')then
            wann%l_spindisp=.true.
         elseif(trim(task).eq.'spindisprs')then
            wann%l_spindisprs=.true.
         elseif(trim(task).eq.'torque')then
            wann%l_torque=.true.
         elseif(trim(task).eq.'torquers')then
            wann%l_torquers=.true.
         elseif(trim(task).eq.'perpmag')then
            wann%l_perpmag=.true.
         elseif(trim(task).eq.'perpmagrs')then
            wann%l_perpmagrs=.true.
         elseif(trim(task).eq.'perpmagat')then
            wann%l_perpmagat=.true.
         elseif(trim(task).eq.'perpmagatrs')then
            wann%l_perpmagatrs=.true.
         elseif(trim(task).eq.'socmat')then
            wann%l_socmat=.true.
         elseif(trim(task).eq.'socmatrs')then
            wann%l_socmatrs=.true.
         elseif(trim(task).eq.'soctomom')then
            wann%l_soctomom=.true.
         elseif(trim(task).eq.'surfcurr')then
            wann%l_surfcurr=.true.
         elseif(trim(task).eq.'lapw_kpts')then
            wann%l_lapw_kpts=.true.
         elseif(trim(task).eq.'updown')then
            wann%l_updown=.true.
         elseif(trim(task).eq.'stopopt')then
            wann%l_stopopt=.true.
         elseif(trim(task).eq.'projgen')then
            wann%l_projgen=.true.
         elseif(trim(task).eq.'kpointgen')then
            wann%l_kpointgen=.true.
         elseif(trim(task).eq.'potmat')then
            wann%l_potmat=.true.
         elseif(trim(task).eq.'w90kpointgen')then
            wann%l_w90kpointgen=.true.
!         elseif(trim(task).eq.'lapw_gfleur')then
!            wann%l_lapw_gfleur=.true.
!            backspace(916)
!            read(916,*,iostat=ios)task,wann%gfthick,wann%gfcut
!            if (ios /= 0) CALL juDFT_error ("error reading gfcut", calledby="wann_read_inp")
!            if(l_p0)write(6,*)"gfcut=",wann%gfthick,wann%gfcut
!         elseif(trim(task).eq.'lapw')then
!            wann%l_lapw=.true.
!            backspace(916)
!            read(916,*,iostat=ios)task,wann%unigrid(:)
!            if (ios /= 0) CALL juDFT_error ("error reading unigrid", calledby="wann_read_inp")
!            if(l_p0)write(6,*)"unigrid=",wann%unigrid(:)
         elseif(trim(task).eq.'plot_lapw')then
            wann%l_plot_lapw=.true.
         elseif(trim(task).eq.'bzsym')then
            wann%l_bzsym=.true.
         elseif(trim(task).eq.'mmn0')then
            wann%l_mmn0=.true.
         elseif(trim(task).eq.'mmn0at')then
            wann%l_mmn0at=.true.
         elseif(trim(task).eq.'manyfiles')then
            wann%l_manyfiles=.true.
         elseif(trim(task).eq.'collectmanyfiles')then
            wann%l_collectmanyfiles=.true.
         elseif(trim(task).eq.'bestproj')then
            wann%l_bestproj=.true.
         elseif(trim(task).eq.'pauli')then
            wann%l_pauli=.true.
         elseif(trim(task).eq.'pauliat')then
            wann%l_pauliat=.true.
         elseif(trim(task).eq.'proj_plot')then
            wann%l_proj_plot=.true.
         elseif(trim(task).eq.'hopping')then
            wann%l_hopping=.true.
         elseif(trim(task).eq.'plot_symm')then
            wann%l_plot_symm=.true.
         elseif(trim(task).eq.'kptsreduc')then
            wann%l_kptsreduc=.true.
         elseif(trim(task).eq.'fermi')then
            wann%l_fermi=.true.
         elseif(trim(task).eq.'prepwan90')then
            wann%l_prepwan90=.true.
         elseif(trim(task).eq.'plot_umdat')then
            wann%l_plot_umdat=.true.
         elseif(trim(task).eq.'wann_plot')then
            wann%l_wann_plot=.true.
         elseif(trim(task).eq.'bynumber')then
            wann%l_bynumber=.true.
         elseif(trim(task).eq.'matrixmmn')then
            wann%l_matrixmmn=.true.
         elseif(trim(task).eq.'projmethod')then
            wann%l_projmethod=.true.
         elseif(trim(task).eq.'matrixamn')then
            wann%l_matrixamn=.true.
         elseif(trim(task).eq.'wannierize')then
            wann%l_wannierize=.true.
         elseif(trim(task).eq.'plotw90')then
            wann%l_plotw90=.true.
         elseif(trim(task).eq.'dipole')then
            wann%l_dipole=.true.
         elseif(trim(task).eq.'dipole3')then
            wann%l_dipole3=.true.
         elseif(trim(task).eq.'ldauwan')then
            wann%l_ldauwan=.true.
         elseif(trim(task).eq.'byenergy')then
            wann%l_byenergy=.true.
         elseif(trim(task).eq.'finishnocoplot') then
            wann%l_finishnocoplot=.true.
         elseif(trim(task).eq.'finishgwf') then
            wann%l_finishgwf=.true.
         elseif(trim(task).eq.'skipkov') then
            wann%l_skipkov=.true.
         elseif(trim(task).eq.'matrixuhu') then
            wann%l_matrixuHu=.true.
         elseif(trim(task).eq.'matrixuhu-dmi') then
            wann%l_matrixuHu_dmi=.true.
!         elseif(trim(task).eq.'wan90version')then
!            backspace(916)
!            read(916,*,iostat=ios)task,version_real
!            if (ios /= 0) CALL judft_error("error reading wan90version", calledby="wann_read_inp")
!            if(abs(version_real-1.1).lt.1.e-9)then
!               wann%wan90version=1
!            elseif(abs(version_real-1.2).lt.1.e-9)then
!               wann%wan90version=2
!            elseif(abs(version_real-2.0).lt.1.e-9)then
!               wann%wan90version=3
!            else
!              CALL judft_error ("chosen w90 version unknown", calledby="wann_read_inp")
!            endif
!         elseif(trim(task).eq.'atomlist')then
!            wann%l_atomlist=.true.
!            backspace(916)
!            read(916,*,iostat=ios)task,wann%atomlist_num
!            if (ios /= 0) CALL judft_error ("error reading atomlist_num", calledby="wann_read_inp")
!            if(allocated(wann%atomlist))deallocate(wann%atomlist)
!            allocate(wann%atomlist(wann%atomlist_num))
!            backspace(916)
!            read(916,*,iostat=ios)task,wann%atomlist_num,wann%atomlist
!            if (ios /= 0) CALL judft_error ("error reading atomlist", calledby="wann_read_inp")
!            if(l_p0)write(6,*)"atomlist_num=",wann%atomlist_num
!            if(l_p0)write(6,*)"atomlist=",wann%atomlist
!         elseif(trim(task).eq.'ikptstart')then
!            wann%l_ikptstart=.true.
!            backspace(916)
!            read(916,*,iostat=ios)task,wann%ikptstart
!            if (ios /= 0) CALL juDFT_error ("error reading ikptstart", calledby="wann_read_inp")
!            if(l_p0)write(6,*)"ikptstart=",wann%ikptstart
         else
            write(6,*)"unrecognized key: ",task
            CALL juDFT_error ("unrecognized key in wannier jobList", calledby="wann_read_inp")
         endif
      enddo

578
      IF (wann%l_byindex) THEN
579 580 581 582 583 584
         if(l_p0)write(6,*)"band_min1=",wann%band_min(1)
         if(l_p0)write(6,*)"band_max1=",wann%band_max(1)
         if(l_p0)write(6,*)"band_min2=",wann%band_min(2)
         if(l_p0)write(6,*)"band_max2=",wann%band_max(2)
      END IF

585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
   END IF ! l_file


!-----input file for orbital decomposition
   if(wann%l_orbcomp.or.wann%l_orbcomprs)then
      inquire(file='orbcomp_inp',exist=l_orbcompinp)
      if(l_orbcompinp)then
         open(159,file='orbcomp_inp')
         read(159,*)wann%oc_num_orbs,wann%l_oc_f
         if(allocated(wann%oc_orbs))deallocate(wann%oc_orbs)
         allocate(wann%oc_orbs(wann%oc_num_orbs))
         do n=1,wann%oc_num_orbs
            read(159,*)wann%oc_orbs(n)
         enddo
         close(159)
      else !default is all atoms including f
!         wann%oc_num_orbs=natd
         wann%l_oc_f=.true.
         if(allocated(wann%oc_orbs))deallocate(wann%oc_orbs)
         allocate(wann%oc_orbs(wann%oc_num_orbs))
         do n=1,wann%oc_num_orbs
            wann%oc_orbs(n)=n
         enddo
      endif
   endif

!-----default atom list: all atoms
   if(.not.wann%l_atomlist)then
     if(allocated(wann%atomlist))deallocate(wann%atomlist)
     allocate(wann%atomlist(wann%atomlist_num))
     do n=1,wann%atomlist_num
       wann%atomlist(n)=n
     enddo
   endif      

end subroutine wann_read_inp

end module m_wann_read_inp