LCOV - code coverage report
Current view: top level - io - rw_inp.f90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 207 500 41.4 %
Date: 2019-09-08 04:53:50 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             :       MODULE m_rwinp
       8             :       use m_juDFT
       9             :       CONTAINS
      10          28 :       SUBROUTINE rw_inp(&
      11             :      &                  ch_rw,atoms,obsolete,vacuum,input,stars,sliceplot,banddos,&
      12             :      &                  cell,sym,xcpot,noco,oneD,hybrid,kpts,&
      13          28 :      &                  noel,namex,relcor,a1,a2,a3,dtild_opt,name_opt)
      14             : 
      15             : !*********************************************************************
      16             : !* This subroutine reads or writes an inp - file on unit iofile      *
      17             : !* for ch_rw = 'R' read, ch_rw = 'W' write.                          *
      18             : !*                                                           Gustav  *
      19             : !*********************************************************************
      20             :       USE m_calculator
      21             :       USE m_types
      22             :   
      23             :       IMPLICIT NONE
      24             : ! ..
      25             : ! ..   Arguments ..
      26             :       CHARACTER,INTENT(IN)          :: ch_rw
      27             : 
      28             :       TYPE(t_input),INTENT(INOUT)   :: input
      29             :       TYPE(t_sym),INTENT(INOUT)     :: sym
      30             :       TYPE(t_stars),INTENT(INOUT)   :: stars 
      31             :       TYPE(t_atoms),INTENT(INOUT)   :: atoms
      32             :       TYPE(t_vacuum),INTENT(INOUT)   :: vacuum
      33             :       TYPE(t_obsolete),INTENT(INOUT) :: obsolete
      34             :       TYPE(t_kpts),INTENT(INOUT)     :: kpts
      35             :       TYPE(t_oneD),INTENT(INOUT)     :: oneD
      36             :       TYPE(t_hybrid),INTENT(INOUT)   :: hybrid
      37             :       TYPE(t_cell),INTENT(INOUT)     :: cell
      38             :       TYPE(t_banddos),INTENT(INOUT)  :: banddos
      39             :       TYPE(t_sliceplot),INTENT(INOUT):: sliceplot
      40             :       TYPE(t_xcpot_inbuild),INTENT(INOUT)    :: xcpot
      41             :       TYPE(t_noco),INTENT(INOUT)     :: noco
      42             :     
      43             :       REAL,INTENT(INOUT)           :: a1(3),a2(3),a3(3)
      44             :       CHARACTER(len=3),INTENT(OUT) :: noel(atoms%ntype)
      45             :       CHARACTER(len=4),INTENT(OUT) :: namex 
      46             :       CHARACTER(len=12),INTENT(OUT):: relcor
      47             :       REAL,INTENT(IN),OPTIONAL     :: dtild_opt
      48             :       CHARACTER(len=8),INTENT(IN),OPTIONAL:: name_opt(10)
      49             : 
      50             : 
      51             : 
      52             :       CHARACTER(len=8) :: name(10)
      53             : 
      54             : !+lda+u
      55             :       REAL    u,j
      56             :       INTEGER l, i_u
      57             :       LOGICAL l_amf
      58             :       CHARACTER(len=3) ch_test
      59             :       NAMELIST /ldaU/ l,u,j,l_amf
      60             : !-lda+u
      61             : !+odim
      62             :       INTEGER MM,vM,m_cyl
      63             :       LOGICAL invs1,zrfs1
      64             :       INTEGER chi,rot
      65             :       LOGICAL d1,band
      66             :       NAMELIST /odim/ d1,MM,vM,m_cyl,chi,rot,invs1,zrfs1
      67             : !-odim
      68             : ! ..
      69             : ! ..  Local Variables
      70             :       REAL     ::scpos  ,zc,dtild   
      71             :       INTEGER  ::nw,idsprs
      72             :       INTEGER ieq,i,k,na,n,ilo
      73             :       REAL s3,ah,a,hs2,rest
      74             :       LOGICAL l_hyb,l_sym,ldum
      75             :       INTEGER :: ierr, intDummy
      76             : ! ..
      77             : !...  Local Arrays
      78             :       CHARACTER :: helpchar(atoms%ntype)
      79             :       CHARACTER(len=  4) :: chntype
      80             :       CHARACTER(len= 41) :: chform
      81             :       CHARACTER(len=100) :: line
      82             : 
      83             : !     added for HF and hybrid functionals
      84             :       REAL                  ::  aMix,omega
      85             :       INTEGER               :: idum
      86             :       CHARACTER (len=1)     ::  check
      87             : 
      88          28 :       IF (PRESENT(dtild_opt)) dtild=dtild_opt
      89          28 :       IF (PRESENT(name_opt)) name=name_opt
      90             : 
      91             : !     Initialize variables
      92          28 :       l_hyb = .false.
      93             : 
      94             : !---------------------------------------------------------------------
      95          28 :       IF (ch_rw.eq.'r') THEN
      96             : !--------------------------------------------------------------------
      97          28 :       OPEN (5,file='inp',form='formatted',status='old')
      98             :       
      99             :       !default not read in in old inp-file
     100          28 :       input%qfix=2
     101             : !
     102          28 :       a1(:) = 0
     103          28 :       a2(:) = 0
     104          28 :       a3(:) = 0
     105             :       
     106             : 
     107          28 :       WRITE (6,*) '-------- dump of inp-file ------------'
     108             : !
     109             :       !<-- Added possibility to define variables here
     110             : 
     111           0 :       DO
     112          28 :          READ (UNIT = 5,FMT = 7182,END=77,ERR=77) ch_test
     113          28 :          BACKSPACE(5)
     114          28 :          IF (ch_test   /="def") EXIT
     115           0 :          READ(unit = 5,FMT="(4x,a)") line
     116           0 :          n = INDEX(line,"=")
     117           0 :          IF (n == 0.OR.n>len_TRIM(line)-1) STOP&
     118           0 :      &        "Error in variable definitions"
     119          28 :          CALL ASSIGN_var(line(:n-1),evaluate(line(n+1:)))
     120             :       ENDDO
     121             : 
     122             :       ! check if isec1 consists of 2 or 3 digits
     123          28 :       READ(UNIT=5,FMT='(29x,a)') check
     124          28 :       BACKSPACE 5
     125          28 :       IF( check .eq. ',' ) THEN
     126             :         READ (UNIT=5,FMT=8000,END=99,ERR=99) &
     127           2 :      &                input%strho,input%film,banddos%dos,intDummy,banddos%ndir,input%secvar
     128           2 :         WRITE (6,9000) input%strho,input%film,banddos%dos,99,banddos%ndir,input%secvar
     129             :  8000 FORMAT (6x,l1,6x,l1,5x,l1,7x,i2,6x,i2,8x,l1)
     130             :       ELSE
     131             :         READ (UNIT=5,FMT=8001,END=99,ERR=99) &
     132          26 :      &                input%strho,input%film,banddos%dos,intDummy,banddos%ndir,input%secvar
     133          26 :         WRITE (6,9000) input%strho,input%film,banddos%dos,99,banddos%ndir,input%secvar
     134             :  8001 FORMAT (6x,l1,6x,l1,5x,l1,7x,i3,6x,i2,8x,l1)
     135             :       END IF
     136             : 
     137             : !
     138          28 :       READ (UNIT=5,FMT=7000,END=99,ERR=99) name
     139         308 :       input%comment = name
     140          28 :       WRITE (6,9010) name
     141             :  7000 FORMAT (10a8)
     142             : !
     143             :       READ (UNIT=5,FMT=7020,END=99,ERR=99)&
     144          28 :      &     cell%latnam,sym%namgrp,sym%invs,sym%zrfs,sym%invs2,input%jspins,noco%l_noco
     145             :       WRITE (6,9020)&
     146          28 :      &     cell%latnam,sym%namgrp,sym%invs,sym%zrfs,sym%invs2,input%jspins,noco%l_noco
     147             :  7020 FORMAT (a3,1x,a4,6x,l1,6x,l1,7x,l1,8x,i1,8x,l1,5x,l1)
     148             : !
     149             :       IF ((cell%latnam.EQ.'squ').OR.(cell%latnam.EQ.'hex').OR.&
     150             :      &    (cell%latnam.EQ.'c-b').OR.(cell%latnam.EQ.'hx3').OR.&
     151          28 :      &    (cell%latnam.EQ.'fcc').OR.(cell%latnam.EQ.'bcc')) THEN
     152          28 :          READ (UNIT = 5,FMT =*,iostat = ierr) a1(1)
     153          28 :          IF (ierr /= 0) THEN
     154           0 :             BACKSPACE(5)
     155           0 :             READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     156           0 :             a1(1)      = evaluatefirst(line)
     157             :          ENDIF
     158          28 :          WRITE (6,9030) a1(1)
     159           0 :       ELSEIF ((cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
     160           0 :          READ (UNIT = 5,FMT=*,iostat=ierr) a1(1),a2(2)
     161           0 :          IF (ierr /= 0) THEN
     162           0 :             BACKSPACE(5)
     163           0 :             READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     164           0 :             a1(1)      = evaluatefirst(line)
     165           0 :             a2(2)      = evaluatefirst(line)
     166             :          ENDIF
     167           0 :          WRITE (6,9030) a1(1),a2(2)
     168           0 :       ELSEIF (cell%latnam.EQ.'obl') THEN
     169           0 :          READ (UNIT = 5,FMT =*,iostat= ierr) a1(1),a1(2)
     170           0 :          IF (ierr /= 0) THEN
     171           0 :             BACKSPACE(5)
     172           0 :             READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     173           0 :             a1(1)      = evaluatefirst(line)
     174           0 :             a1(2)      = evaluatefirst(line)
     175             :          ENDIF
     176           0 :          READ (UNIT = 5,FMT =*,iostat= ierr) a2(1),a2(2)
     177           0 :          IF (ierr /= 0) THEN
     178           0 :             BACKSPACE(5)
     179           0 :             READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     180           0 :             a2(1)      = evaluatefirst(line)
     181           0 :             a2(2)      = evaluatefirst(line)
     182             :          ENDIF
     183           0 :          WRITE (6,9030) a1(1),a1(2)
     184           0 :          WRITE (6,9030) a2(1),a2(2)
     185           0 :       ELSEIF (cell%latnam.EQ.'any') THEN
     186           0 :           READ (UNIT=5,FMT=*,iostat= ierr) a1
     187           0 :           IF (ierr /= 0) THEN
     188           0 :              BACKSPACE(5)
     189           0 :              READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     190           0 :              a1(1)       = evaluatefirst(line)
     191           0 :              a1(2)        = evaluatefirst(line)
     192           0 :              a1(3)        = evaluatefirst(line)
     193             :           ENDIF
     194           0 :           READ (UNIT=5,FMT=*,iostat= ierr) a2
     195           0 :           IF (ierr /= 0) THEN
     196           0 :              BACKSPACE(5)
     197           0 :              READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     198           0 :              a2(1)       = evaluatefirst(line)
     199           0 :              a2(2)        = evaluatefirst(line)
     200           0 :              a2(3)        = evaluatefirst(line)
     201             :           ENDIF
     202           0 :           WRITE (6,9030) a1(1),a1(2),a1(3)
     203           0 :           WRITE (6,9030) a2(1),a2(2),a2(3)
     204             :       ELSE
     205           0 :           WRITE (6,*) 'rw_inp: cell%latnam ',cell%latnam,' unknown'
     206           0 :            CALL juDFT_error("Unkown lattice name",calledby="rw_inp")
     207             :       ENDIF
     208             : !
     209             : !
     210          28 :       IF (cell%latnam.EQ.'squ') THEN
     211          28 :          a2(2) = a1(1)
     212             :       END IF
     213             : !
     214             : !     Centered rectangular, special case for bcc(110)
     215             : !
     216          28 :       IF (cell%latnam.EQ.'c-b') THEN
     217           0 :          a = a1(1)
     218           0 :          hs2 = sqrt(2.)*0.5e0
     219           0 :          a1(1) = a*hs2
     220           0 :          a1(2) = -a*0.5e0
     221           0 :          a2(1) = a*hs2
     222           0 :          a2(2) = a*0.5e0
     223             :       END IF
     224             : !
     225             : !     Centered rectangular, general case
     226             : !     on input: a ---> half of long diagonal
     227             : !               b ---> half of short diagonal
     228             : !
     229          28 :       IF (cell%latnam.EQ.'c-r') THEN
     230           0 :          a1(2) = -a2(2)
     231           0 :          a2(1) =  a1(1)
     232             :       END IF
     233          28 :       IF (cell%latnam.EQ.'hex') THEN
     234           0 :          s3 = sqrt(3.)
     235           0 :          ah = a1(1)/2.
     236           0 :          a1(1) = ah*s3
     237           0 :          a1(2) = -ah
     238           0 :          a2(1) = a1(1)
     239           0 :          a2(2) = ah
     240             :       END IF
     241          28 :       IF (cell%latnam.EQ.'hx3') THEN
     242           0 :          s3 = sqrt(3.)
     243           0 :          ah = a1(1)/2.
     244           0 :          a1(1) = ah
     245           0 :          a1(2) = -ah*s3
     246           0 :          a2(1) = a1(1)
     247           0 :          a2(2) = -a1(2)
     248             :       END IF
     249             : 
     250          28 :       input%scaleA1 = 1.0
     251          28 :       input%scaleA2 = 1.0
     252          28 :       input%scaleC  = 1.0
     253             : 
     254          28 :       IF (sym%namgrp.EQ.'any ') THEN
     255          14 :         INQUIRE (file='sym.out',exist=l_sym)
     256          14 :         IF (.not.l_sym)&
     257             :      &       CALL juDFT_error(&
     258             :      &       "for namgrp ='any' please provide a sym.out -file !"&
     259           0 :      &       ,calledby ="rw_inp")
     260             :       ENDIF
     261          28 :       IF (cell%latnam.EQ.'any') THEN
     262             : !        CALL juDFT_error("please specify lattice type (squ,p-r,c-r,hex,hx3,obl)",calledby="rw_inp")
     263           0 :         READ (UNIT=5,FMT=*,iostat=ierr) a3(1),a3(2),a3(3),vacuum%dvac,input%scaleCell
     264           0 :         IF (ierr /= 0) THEN
     265           0 :            BACKSPACE(5)
     266           0 :            READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     267           0 :            a3(1)           = evaluatefirst(line)
     268           0 :            a3(2)           = evaluatefirst(line)
     269           0 :            a3(3)           = evaluatefirst(line)
     270           0 :            vacuum%dvac     = evaluatefirst(line)
     271           0 :            input%scaleCell = evaluatefirst(line)
     272             :         ENDIF
     273           0 :         WRITE (6,9031) a3(1),a3(2),a3(3),vacuum%dvac,input%scaleCell
     274             :       ELSE
     275          28 :          READ (UNIT = 5,FMT =*,iostat= ierr) vacuum%dvac,dtild,input%scaleCell
     276          28 :          IF (ierr /= 0) THEN
     277           0 :             BACKSPACE(5)
     278           0 :             READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     279           0 :             vacuum%dvac     = evaluatefirst(line)
     280           0 :             dtild           = evaluatefirst(line)
     281           0 :             input%scaleCell = evaluatefirst(line)
     282             :         ENDIF
     283          28 :         WRITE (6,9030) vacuum%dvac,dtild,input%scaleCell
     284          28 :         a3(3) = dtild
     285             :       ENDIF
     286             : !
     287          28 :       READ (UNIT=5,FMT=7110,END=99,ERR=99) namex,relcor,aMix,omega
     288          28 :       namex = TRIM(ADJUSTL(namex))
     289             :  7110 FORMAT (a4,3x,a12,2f6.3)
     290             :       IF ((namex.EQ.'pw91').OR.(namex.EQ.'l91 ').OR.&
     291             :      &    (namex.EQ.'pbe') .OR.(namex.EQ.'rpbe').OR.&
     292             :      &    (namex.EQ.'Rpbe').OR.(namex.EQ.'wc')  .OR.&
     293             :      &    (namex.EQ.'pbe0').OR.(namex.EQ.'hse ').OR.&
     294          56 :      &    (namex.EQ.'lhse').OR.(namex.EQ.'vhse')) THEN                    ! some defaults
     295          16 :          obsolete%lwb=.false. ; obsolete%ndvgrd=6; idsprs=0 ; obsolete%chng=-0.1e-11
     296             :       ENDIF
     297             :       ! set mixing and screening for variable HSE functional
     298          28 :       WRITE (6,9040) namex,relcor
     299             :      
     300             : ! look what comes in the next two lines
     301             : !
     302          28 :       READ (UNIT=5,FMT=7182,END=77,ERR=77) ch_test
     303          28 :       IF (ch_test.EQ.'igr') THEN                          ! GGA input
     304          28 :          BACKSPACE (5)
     305             :          READ (UNIT=5,FMT=7121,END=99,ERR=99)&
     306          28 :      &                   idum,obsolete%lwb,obsolete%ndvgrd,idsprs,obsolete%chng
     307          28 :          IF (idsprs.ne.0)&
     308           0 :      &        CALL juDFT_warn("idsprs no longer supported in rw_inp")
     309          28 :          WRITE (6,9121) idum,obsolete%lwb,obsolete%ndvgrd,idsprs,obsolete%chng
     310             :  7121    FORMAT (5x,i1,5x,l1,8x,i1,8x,i1,6x,d10.3)
     311             : 
     312          28 :          READ (UNIT=5,FMT=7182,END=77,ERR=77) ch_test
     313          28 :          IF (ch_test.EQ.'igg') THEN                      ! GGA 2nd line
     314             :            GOTO 76
     315          28 :          ELSEIF (ch_test.EQ.'&od') THEN                  ! continue with 1D
     316             :            GOTO 78
     317             :          ELSE
     318          28 :            oneD%odd%d1 = .false.
     319          28 :            GOTO 77
     320             :          ENDIF
     321           0 :       ELSEIF (ch_test.EQ.'&od') THEN                  ! continue with 1D
     322             :          GOTO 78
     323           0 :       ELSEIF ( ch_test .eq. 'gcu' ) then              ! HF
     324           0 :         BACKSPACE (5)
     325           0 :         READ (UNIT=5,FMT=7999,END=99,ERR=99) hybrid%gcutm1,hybrid%tolerance1,&
     326           0 :      &     hybrid%ewaldlambda,hybrid%lexp,hybrid%bands1
     327           0 :         WRITE (6,9999) hybrid%gcutm1,hybrid%tolerance1,hybrid%ewaldlambda,hybrid%lexp,hybrid%bands1
     328             :  7999   FORMAT (6x,f8.5,6x,f10.8,8x,i2,6x,i2,7x,i4)
     329             :  9999   FORMAT ('gcutm=',f8.5,',mtol=',f10.8,',lambda=',i2,&
     330             :      &          ',lexp=',i2,',bands=',i4)
     331           0 :          oneD%odd%d1 = .false.
     332           0 :          goto 76
     333             :       ELSE
     334             :          GOTO 77
     335             :       ENDIF
     336             : !-odim
     337             :       READ (UNIT=5,FMT=7182,END=99,ERR=99) ch_test
     338             :  7182 FORMAT (a3)
     339           0 :    78 IF (ch_test.EQ.'&od') THEN
     340           0 :         BACKSPACE (5)
     341           0 :         READ (5,odim)
     342           0 :         oneD%odd%d1 = d1 ; oneD%odd%mb = vM ; oneD%odd%M = MM ; oneD%odd%m_cyl = m_cyl
     343           0 :         oneD%odd%chi = chi ; oneD%odd%rot = rot
     344           0 :         oneD%odd%invs = invs1 ; oneD%odd%zrfs = zrfs1
     345           0 :         WRITE (6,8182) d1,MM,vM,m_cyl,chi,rot,invs1,zrfs1
     346             :       END IF
     347             : !+odim
     348           0 :       GOTO 76
     349          28 :    77 BACKSPACE (5)                                ! continue with atoms
     350          28 :    76 IF (ch_test /= '&od') THEN
     351          28 :         WRITE (6,*) '   '
     352          28 :         oneD%odd%d1 = .false.
     353          28 :         oneD%odd%M = 1 ; oneD%odd%mb = 1 ; oneD%odd%m_cyl = 1
     354          28 :         oneD%odd%chi = 1 ; oneD%odd%rot = 1
     355          28 :         oneD%odd%invs = .FALSE. ; oneD%odd%zrfs = .FALSE.
     356             :       END IF
     357          28 :       READ (UNIT=5,FMT=*,END=99,ERR=99) atoms%ntype
     358          28 :       WRITE (6,9050) atoms%ntype
     359             : !
     360          28 :       na = 0
     361          28 :       READ (UNIT=5,FMT=7110,END=99,ERR=99)
     362          28 :       WRITE (6,9060)
     363          28 :       atoms%n_u = 0
     364         184 :       DO n=1,atoms%ntype
     365             : !
     366          64 :          READ (UNIT=5,FMT=7140,END=99,ERR=99) noel(n),atoms%nz(n),&
     367         128 :      &                      atoms%ncst(n),atoms%lmax(n),atoms%jri(n),atoms%rmt(n),atoms%dx(n)
     368          64 :          WRITE (6,9070) noel(n),atoms%nz(n),atoms%ncst(n),atoms%lmax(n),atoms%jri(n),&
     369         128 :      &                      atoms%rmt(n),atoms%dx(n)
     370             :  7140    FORMAT (a3,i3,3i5,2f10.6)
     371             : !
     372             : !+lda+u
     373          64 :          READ (UNIT=5,FMT=7180,END=199,ERR=199) ch_test
     374             :  7180    FORMAT (a3)
     375          64 :          IF (ch_test.EQ.'&ld') THEN
     376           0 :             l=0 ; u=0.0 ; j=0.0 ; l_amf = .false.
     377           0 :             BACKSPACE (5)
     378           0 :             READ (5,ldaU)
     379           0 :             atoms%n_u = atoms%n_u + 1
     380           0 :             atoms%lda_u(atoms%n_u)%l = l
     381           0 :             atoms%lda_u(atoms%n_u)%u = u
     382           0 :             atoms%lda_u(atoms%n_u)%j = j
     383           0 :             atoms%lda_u(atoms%n_u)%l_amf = l_amf
     384           0 :             atoms%lda_u(atoms%n_u)%atomType = n
     385           0 :             WRITE (6,8180) l,u,j,l_amf
     386             :          END IF
     387             :  199     CONTINUE
     388             : !-lda+u
     389             : !
     390             : !---> read extra info for local orbitals, and l_geo. if l_geo=T
     391             : !---> calculate force on this atom.
     392             : !---> p.kurz 97-06-05
     393             : !
     394             : !     add parameters lcutm and select for HF and hybrid functionals
     395             :         IF ( namex=='hf  ' .OR. namex=='pbe0' .OR. namex=='exx '&
     396          64 :      &       .OR. namex=='hse ' .OR. namex=='vhse' ) THEN
     397           0 :           l_hyb = .TRUE.
     398           0 :           READ (UNIT=5,FMT=7160,END=99,ERR=99) atoms%neq(n),&
     399           0 :      &                  atoms%l_geo(n),hybrid%lcutm1(n),hybrid%select1(1,n),hybrid%select1(2,n),&
     400           0 :      &                  hybrid%select1(3,n),hybrid%select1(4,n),atoms%nlo(n),&
     401           0 :      &                  (atoms%llo(ilo,n),ilo=1,atoms%nlo(n))
     402             :  7160     FORMAT (i2,8x,l1,7x,i2,8x,i2,1x,i2,1x,i2,1x,i2,5x,i2,5x,60i3)
     403           0 :           WRITE (6,9090) atoms%neq(n),atoms%l_geo(n),hybrid%lcutm1(n),hybrid%select1(1,n),&
     404           0 :      &       hybrid%select1(2,n),hybrid%select1(3,n),hybrid%select1(4,n),atoms%nlo(n),&
     405           0 :      &       (atoms%llo(ilo,n),ilo=1,atoms%nlo(n))
     406             :         ELSE
     407          64 :           READ (UNIT=5,FMT=7161,END=99,ERR=99) atoms%neq(n),&
     408         206 :      &                    atoms%l_geo(n),atoms%nlo(n),(atoms%llo(ilo,n),ilo=1,atoms%nlo(n))
     409             :  7161     FORMAT (i2,8x,l1,5x,i2,5x,60i3)
     410          64 :           WRITE (6,9091) atoms%neq(n),atoms%l_geo(n),atoms%nlo(n),&
     411         206 :      &                                    (atoms%llo(ilo,n),ilo=1,atoms%nlo(n))
     412             :         END IF 
     413             : !
     414         134 :          DO ieq=1,atoms%neq(n)
     415          70 :             na = na + 1
     416             :             READ (UNIT = 5,FMT = 7170,iostat = ierr)&
     417          70 :      &                      (atoms%taual(i,na),i=1,3),scpos
     418          70 :             IF (ierr.NE.0) THEN
     419           0 :                BACKSPACE(5)
     420             :                !<-- read positions with new format
     421           0 :                READ (UNIT = 5,FMT ="(a)",END = 99,ERR = 99) line
     422           0 :                atoms%taual(1,na) = evaluatefirst(line)
     423           0 :                atoms%taual(2,na) = evaluatefirst(line)
     424           0 :                atoms%taual(3,na) = evaluatefirst(line)
     425           0 :                scpos = evaluatefirst(line)
     426           0 :                IF (scpos == 0.0)  scpos          = 1.0
     427             :                !>
     428             :             ENDIF
     429          70 :             WRITE (6,9100) (atoms%taual(i,na),i=1,3),scpos
     430             :  7170       FORMAT (4f10.6)
     431          70 :             IF (scpos.EQ.0.) scpos = 1.
     432         350 :             DO i = 1,2
     433         210 :                atoms%taual(i,na) = atoms%taual(i,na)/scpos
     434             :             ENDDO
     435          70 :             IF (.not.input%film) atoms%taual(3,na) = atoms%taual(3,na)/scpos
     436             : !+odim
     437             : ! in 1D case all the coordinates are given cartesian'ly
     438         134 :             IF (oneD%odd%d1) THEN
     439           0 :                atoms%taual(1,na) = atoms%taual(1,na)/a1(1)
     440           0 :                atoms%taual(2,na) = atoms%taual(2,na)/a2(2)
     441             :             END IF
     442             : !-odim
     443             :          ENDDO
     444          64 :          READ (5,*)
     445          92 :          WRITE (6,9060)
     446             :       ENDDO
     447             : !
     448          28 :       READ (UNIT=5,FMT=7210,END=99,ERR=99) stars%gmax,xcpot%gmaxxc
     449          28 :       WRITE (6,9110) stars%gmax,xcpot%gmaxxc
     450          28 :       stars%gmaxInit = stars%gmax
     451             :  7210 FORMAT (2f10.6)
     452             : !
     453          28 :       INQUIRE(file='fl7para',exist=ldum)  ! fl7para must not exist for input%gw=2
     454          42 :       IF (input%gw.eq.-1.and.ldum) THEN         ! in the first run of rw_inp
     455           0 :         ldum = .true.                     ! (then, input%gw=-1 at this point).
     456             :       ELSE                                !
     457          28 :         ldum = .false.                    !
     458             :       ENDIF                               !
     459          28 :       input%gw = 0
     460             :       READ (UNIT=5,FMT=7220,END=99,ERR=7215)&
     461          28 :            &                                       input%vchk,input%cdinf,ldum,input%gw,input%gw_neigd
     462          28 :       if (ldum) call judft_error("pot8 not longer supported")
     463          28 : 7215  IF(input%strho) input%gw=0
     464          28 :       if (ldum) call judft_error("pot8 not longer supported")
     465          28 :       IF(input%gw.eq.2 .OR. l_hyb) THEN
     466           0 :          IF(ldum)  CALL juDFT_error&
     467             :      &        ("Remove fl7para before run with gw = 2!",calledby&
     468           0 :      &        ="rw_inp")
     469           0 :          IF(input%gw_neigd==0)  CALL juDFT_error("No numbands-value given."&
     470           0 :      &        ,calledby ="rw_inp")
     471             :       ELSE
     472          28 :         INQUIRE(file='QGpsi',exist=ldum)
     473          28 :         IF(ldum)           CALL juDFT_error&
     474           0 :      &       ("QGpsi exists but gw /= 2 in inp.",calledby ="rw_inp")
     475             :       ENDIF
     476             :   
     477          28 :       BACKSPACE(5)                                         ! Make sure that input%vchk,input%cdinf,obsolete%pot8 are all given.
     478          28 :       READ (UNIT=5,FMT=7220,END=99,ERR=99) input%vchk,input%cdinf,ldum
     479          28 :       if (ldum) call judft_error("pot8 not longer supported")
     480          28 :       WRITE (6,9120) input%vchk,input%cdinf,.false.,input%gw,input%gw_neigd
     481             :  7220 FORMAT (5x,l1,1x,6x,l1,1x,5x,l1,1x,3x,i1,1x,9x,i4)
     482             : !
     483          28 :       DO i=1,100 ; line(i:i)=' ' ; ENDDO
     484             :       
     485          28 :       input%eig66(2)=.false.
     486             :       
     487             :       READ (UNIT=5,FMT=6000,END=99,ERR=99)&
     488          28 :      &                idum,ldum,input%l_f,input%eonly,input%eig66(1)!,input%eig66(2)
     489          28 :       WRITE (6,9130) 0,.false.,input%l_f,input%eonly,input%eig66(1)!,input%eig66(2)
     490             :  6000 FORMAT (4x,i1,8x,l1,5x,l1,7x,l1,7x,l1)
     491             : !
     492             : !+roa
     493          28 :       WRITE (chntype,'(i4)') 2*atoms%ntype
     494          28 :       chform = '('//chntype//'i3 )'
     495             :       READ (UNIT=5,FMT=chform,END=99,ERR=99) &
     496         120 :      &                (atoms%lnonsph(n),n=1,atoms%ntype)!,(hybrid%lcutwf(n),n=1,atoms%ntype)
     497         120 :       WRITE (6,FMT=chform) (atoms%lnonsph(n),n=1,atoms%ntype)!,(hybrid%lcutwf(n),n=1,atoms%ntype)
     498             :  6010 FORMAT (25i3)
     499             : !
     500          28 :       READ (UNIT=5,FMT=6010,END=99,ERR=99) nw,obsolete%lepr
     501          28 :       IF (nw.ne.1) CALL juDFT_error("Multiple window calculations not supported")
     502          28 :       WRITE (6,9140) nw,obsolete%lepr
     503             : !
     504          28 :       zc=0.0
     505          28 :       READ (UNIT=5,FMT=*,END=99,ERR=99)
     506             :          !WRITE (6,'(a8,i2)') 'Window #',nw
     507             : !
     508          28 :       READ (UNIT=5,FMT=6040,END=99,ERR=99) input%ellow,input%elup,input%zelec
     509          28 :       WRITE (6,9150) input%ellow,input%elup,input%zelec
     510             : 6040  FORMAT (4f10.5)
     511          28 :       zc = zc + input%zelec
     512             : !
     513          28 :       READ (UNIT=5,FMT='(f10.5)',END=99,ERR=99) input%rkmax
     514          28 :       WRITE (6,FMT='(f10.5,1x,A)') input%rkmax, '=kmax'
     515             :      
     516          28 :       READ (UNIT=5,FMT=8010,END=99,ERR=99) input%gauss,input%delgau,input%tria
     517          28 :       WRITE (6,9160) input%gauss,input%delgau,input%tria
     518             :  8010 FORMAT (6x,l1,f10.5,5x,l1)
     519             : !
     520          28 :       input%tkb=input%delgau
     521             : !
     522          28 :       READ(5,fmt='(27x,l1)',END=99,ERR=99) noco%l_soc
     523        2856 :       DO i=1,100 ; line(i:i)=' ' ; ENDDO
     524          28 :       BACKSPACE(5)
     525          28 :       READ(5,fmt='(A)',END=99,ERR=99) line
     526          28 :       BACKSPACE(5)
     527          28 :       IF (line(9:10)=='pi') THEN
     528           0 :         READ(5,fmt='(f8.4)') noco%theta
     529           0 :         noco%theta= noco%theta*4.*ATAN(1.)
     530             :       ELSE
     531          28 :         READ(5,fmt='(f10.6)',END=99,ERR=99) noco%theta
     532             :       ENDIF
     533          28 :       BACKSPACE(5)
     534          28 :       IF (line(19:20)=='pi') THEN
     535           0 :         READ(5,fmt='(10x,f8.4)',END=99,ERR=99) noco%phi
     536           0 :         noco%phi= noco%phi*4.*ATAN(1.)
     537             :       ELSE
     538          28 :         READ(5,fmt='(10x,f10.6)',END=99,ERR=99) noco%phi
     539             :       ENDIF
     540          28 :       IF ( line(30:34)=='spav=' ) THEN
     541          28 :         BACKSPACE(5)
     542          28 :         READ(5,fmt='(34x,l1)',END=99,ERR=99) noco%l_spav
     543             :       ELSE
     544           0 :         noco%l_spav= .false.
     545             :       ENDIF
     546             : !!$      IF ( line(37:40)=='off=' ) THEN
     547             : !!$        BACKSPACE(5)
     548             : !!$        chform= '(40x,l1,1x,'//chntype//'a1)'
     549             : !!$        CALL judft_error("soc_opt no longer supported")
     550             : !!$      ENDIF
     551             :     
     552             :       READ (UNIT=5,FMT=8050,END=99,ERR=99)&
     553          28 :      &                 input%frcor,sliceplot%slice,input%ctail
     554          28 :       input%coretail_lmax=99
     555          28 :       input%kcrel=0
     556          28 :       BACKSPACE(5)
     557          28 :       READ (UNIT=5,fmt='(A)') line
     558          56 :       input%l_bmt= ( line(52:56)=='bmt=T' ).or.( line(52:56)=='bmt=t' )
     559          28 :       WRITE (6,9170)  input%frcor,sliceplot%slice,input%ctail
     560             :  8050 FORMAT (6x,l1,7x,l1,7x,l1,6x,l1,7x,i1,5x,l1,5x,l1)
     561             :       
     562             :       ! check if itmax consists of 2 or 3 digits
     563          28 :       READ(unit=5,FMT='(8x,a)') check
     564          28 :       BACKSPACE 5
     565             : 
     566          28 :       IF( check .eq. ',' ) THEN
     567             :         READ (UNIT=5,FMT=8060,END=99,ERR=99) &
     568           2 :      & input%itmax,input%maxiter,input%imix,input%alpha,input%spinf
     569           2 :         WRITE (6,9180) input%itmax,input%maxiter,input%imix,input%alpha,input%spinf
     570             :  8060   FORMAT (6x,i2,9x,i3,6x,i2,7x,f6.2,7x,f6.2)
     571             :       ELSE
     572             :         READ (UNIT=5,FMT=8061,END=99,ERR=99) &
     573          26 :      & input%itmax,input%maxiter,input%imix,input%alpha,input%spinf
     574          26 :         WRITE (6,9180) input%itmax,input%maxiter,input%imix,input%alpha,input%spinf
     575             :  8061   FORMAT (6x,i3,9x,i3,6x,i2,7x,f6.2,7x,f6.2)
     576             :       END IF
     577             :       
     578          28 :       input%preconditioning_param = 0.0 
     579             : 
     580          28 :       chform = '(5x,l1,'//chntype//'f6.2)'
     581             : !      chform = '(5x,l1,23f6.2)'
     582             :       READ (UNIT=5,FMT=chform,END=99,ERR=99)&
     583          28 :      &                                   input%swsp, (atoms%bmu(i),i=1,atoms%ntype)
     584          28 :       chform = '(6x,l1,'//chntype//'i3 )'
     585             : !      chform = '(6x,l1,23i3 )'
     586             :       READ (UNIT=5,FMT=chform,END=99,ERR=99)&
     587         120 :      &                                   input%lflip, (atoms%nflip(i),i=1,atoms%ntype)
     588             : !-
     589          28 :       chform = '("swsp=",l1,'//chntype//'f6.2)'
     590             : !      chform = '("swsp=",l1,23f6.2)'
     591         120 :       WRITE (6,FMT=chform) input%swsp, (atoms%bmu(i),i=1,atoms%ntype)
     592          28 :       chform = '("lflip=",l1,'//chntype//'i3 )'
     593             : !      chform = '("lflip=",l1,23i3 )'
     594          28 :       WRITE (6,FMT=chform) input%lflip, (atoms%nflip(i),i=1,atoms%ntype)
     595             : !-roa
     596             : !+stm
     597             :       READ (UNIT=5,FMT=8075,END=99,ERR=99)&
     598          28 :      &      banddos%vacdos,vacuum%layers,input%integ,vacuum%starcoeff,vacuum%nstars,&
     599          56 :      &      vacuum%locx(1),vacuum%locy(1),vacuum%locx(2),vacuum%locy(2),vacuum%nstm,vacuum%tworkf
     600          28 :       WRITE (6,9210) banddos%vacdos,vacuum%layers,input%integ,vacuum%starcoeff,vacuum%nstars,&
     601          56 :      &      vacuum%locx(1),vacuum%locy(1),vacuum%locx(2),vacuum%locy(2),vacuum%nstm,vacuum%tworkf
     602             :  8075 FORMAT (7x,l1,8x,i2,7x,l1,6x,l1,8x,i2,4(4x,f5.2),6x,i1,8x,f10.6)
     603             : !-stm
     604          28 :       IF (banddos%vacdos) THEN
     605           0 :         IF (input%integ) THEN
     606             :           READ (UNIT=5,FMT=8076,END=99,ERR=99)&
     607           0 :      &                    ((vacuum%izlay(i,k),k=1,2),i=1,vacuum%layers)
     608           0 :           WRITE (6,9220) ((vacuum%izlay(i,k),k=1,2),i=1,vacuum%layers)
     609             :  8076     FORMAT (10(2(i3,1x),1x))
     610             :         ELSE
     611             :           READ (UNIT=5,FMT=8077,END=99,ERR=99)&
     612           0 :      &                    (vacuum%izlay(i,1),i=1,vacuum%layers)
     613           0 :           WRITE (6,9230) (vacuum%izlay(i,1),i=1,vacuum%layers)
     614             :  8077     FORMAT (20(i3,1x))
     615             :         END IF
     616             :       ELSE
     617          28 :         READ (UNIT=5,FMT=*,END=99,ERR=99)
     618          28 :         WRITE (6,fmt='(1x)')
     619             :       END IF
     620             : !
     621          28 :       band = .false.
     622          28 :       READ (UNIT=5,FMT=8050,END=992,ERR=992) sliceplot%iplot,input%score,sliceplot%plpot,band
     623          28 :       WRITE (6,9240) sliceplot%iplot,input%score,sliceplot%plpot,band
     624          28 :       IF (band) THEN
     625           4 :         banddos%dos=.true. ; banddos%ndir = -4
     626             :       ENDIF
     627             :       GOTO 993
     628           0 :  992  BACKSPACE(5)
     629           0 :       READ (UNIT=5,FMT=8050,END=99,ERR=99) sliceplot%iplot,input%score,sliceplot%plpot
     630           0 :       WRITE (6,9240) sliceplot%iplot,input%score,sliceplot%plpot,band
     631             : !
     632             :  993  READ (UNIT=5,FMT='(i3,2f10.6,6x,i3,8x,l1)',END=99,ERR=99)&
     633          28 :      &                sliceplot%kk,sliceplot%e1s,sliceplot%e2s,sliceplot%nnne,input%pallst
     634          28 :       WRITE (6,9250) sliceplot%kk,sliceplot%e1s,sliceplot%e2s,sliceplot%nnne,input%pallst
     635             : !
     636          28 :       READ (UNIT=5,FMT=8090,END=99,ERR=99) !
     637             :                      !input%xa,input%thetad,input%epsdisp,input%epsforce
     638          28 :       WRITE (6,*) "No relaxation with old input anymore" 
     639             :       !input%xa,input%thetad,input%epsdisp,input%epsforce
     640             :  8090 FORMAT (3x,f10.5,8x,f10.5,9x,f10.5,10x,f10.5)
     641             : !
     642             : 
     643             : !+/-odim YM : changed to '70' in the format, sometimes caused probl.
     644          28 :       chform = '(6x,'//chntype//'(3i1,1x))'
     645             :       READ (UNIT=5,FMT=chform,END=99,ERR=99)&
     646         120 :      &      ((atoms%relax(i,k),i=1,3),k=1,atoms%ntype)
     647          28 :       chform = '("relax ",'//chntype//'(3i1,1x))'
     648         120 :       WRITE (6,FMT=chform) ((atoms%relax(i,k),i=1,3),k=1,atoms%ntype)
     649             : 
     650             : ! read dos_params! These will be set automatically if not present!
     651          28 :       banddos%e1_dos=0.0
     652          28 :       banddos%e2_dos=-1.0
     653          28 :       banddos%sig_dos=1e-4
     654             :       READ (UNIT=5,FMT='(9x,f10.5,10x,f10.5,9x,f10.5)',&
     655          28 :      &     END=98,ERR=98) banddos%e2_dos,banddos%e1_dos,banddos%sig_dos
     656             : 
     657          28 :       kpts%posScale = 1.0
     658             :  
     659             : ! added for exact-exchange or hybrid functional calculations:
     660             : ! read in the number of k-points and nx,ny and nz given in the last line
     661             : ! of the input file,
     662             : ! we demand that the values given there are consistent with the kpts-file
     663             : 
     664          56 :       IF(namex=='hf  '.OR.namex=='pbe0'.OR.namex=='exx '.OR.namex=='hse '.OR.namex=='vhse'.OR.&
     665             :          (banddos%dos.AND.(banddos%ndir == -3))) THEN
     666           0 :          READ (UNIT=5,FMT='(5x,i5,4x,i2,4x,i2,4x,i2)',END=98,ERR=98) idum,kpts%nkpt3(1),kpts%nkpt3(2),kpts%nkpt3(3)
     667             : 
     668           0 :          IF(idum.EQ.0) THEN
     669           0 :             WRITE(*,*) ''
     670           0 :             WRITE(*,*) 'nkpt is set to 0.'
     671           0 :             WRITE(*,*) 'For this fleur mode it has to be larger than 0!'
     672           0 :             WRITE(*,*) ''
     673           0 :             CALL juDFT_error("Invalid declaration of k-point set (1)",calledby="rw_inp")
     674             :          END IF
     675             :       
     676           0 :          IF( kpts%nkpt3(1)*kpts%nkpt3(2)*kpts%nkpt3(3) .ne. idum ) THEN
     677           0 :             WRITE(*,*) ''
     678           0 :             WRITE(*,*) 'nx*ny*nz is not equal to nkpt.'
     679           0 :             WRITE(*,*) 'For this fleur mode this is required!'
     680           0 :             WRITE(*,*) ''
     681           0 :             CALL juDFT_error("Invalid declaration of k-point set (2)",calledby="rw_inp")
     682             :          END IF
     683             :       END IF
     684             : 
     685             : ! for a exx calcuation a second mixed basis set is needed to
     686             : ! represent the response function, its parameters are read in here
     687             : 
     688          28 :       IF(namex=='exx ') THEN
     689           0 :          CALL judft_error("No EXX calculations in this FLEUR version")
     690             :         !READ (UNIT=5,FMT='(7x,f8.5,7x,f10.8,7x,i3)',END=98,ERR=98) hybrid%gcutm2,hybrid%tolerance2,hybrid%bands2
     691             : 
     692             :         !DO i=1,atoms%ntype
     693             :           !READ (UNIT=5,FMT='(7x,i2,9x,i2,1x,i2,1x,i2,1x,i2)',&
     694             :             !END IF=98,ERR=98) hybrid%lcutm2(i),hybrid%select2(1,i),hybrid%select2(2,i),&
     695             :             !           hybrid%select2(3,i),hybrid%select2(4,i)
     696             :         !END DO
     697             :         
     698             :         !ALLOCATE( hybrid%l_exxc(maxval(atoms%ncst),atoms%ntype) )
     699             :         !DO i=1,atoms%ntype
     700             :    !       READ(UNIT=5,FMT='(60(2x,l1))',END=98,ERR=98)(hybrid%l_exxc(k,i),k=1,atoms%ncst(i))
     701             :        ! END DO
     702             :       END IF
     703             : 
     704             :  98   CONTINUE
     705             :       WRITE (6,'(a,f10.5,a,f10.5,a,f10.5)')&
     706          28 :      &     'emin_dos=',banddos%e2_dos,',emax_dos=',banddos%e1_dos,',sig_dos=',banddos%sig_dos
     707          28 :       CLOSE (5)
     708             : 
     709             : 
     710             : 
     711             : 
     712             : !---------------------------------------------------------------------
     713           0 :       ELSEIF ((ch_rw.eq.'W').OR.(ch_rw.eq.'w'))  THEN
     714             : !---------------------------------------------------------------------
     715             : 
     716           0 :       IF (ch_rw.eq.'W') THEN
     717           0 :       OPEN (5,file='inp_new',form='formatted',status='unknown')
     718           0 :       REWIND (5)
     719             :       ELSE
     720           0 :       OPEN(5,file='inp',form='formatted',status='unknown')
     721             :       ENDIF
     722             : 
     723             :       IF (namex.EQ.'hf  ' .OR. namex .EQ. 'exx ' .OR. namex .EQ. 'hse '&
     724           0 :      &  .OR. namex.EQ.'vhse' )&
     725             :      &  l_hyb = .true.
     726           0 :       WRITE (5,9000) input%strho,input%film,banddos%dos,99,banddos%ndir,input%secvar
     727             :  9000 FORMAT ('strho=',l1,',film=',l1,',dos=',l1,',isec1=',i3,&
     728             :      &        ',ndir=',i2,',secvar=',l1)
     729           0 :       WRITE (5,9010) name
     730             :  9010 FORMAT (10a8)
     731           0 :       WRITE(5,9020) cell%latnam,sym%namgrp,sym%invs,sym%zrfs,sym%invs2,input%jspins,noco%l_noco
     732             :  9020 FORMAT (a3,1x,a4,',invs=',l1,',zrfs=',l1,',invs2=',l1,&
     733             :      &       ',jspins=',i1,',l_noco=',l1,',l_J=',l1)
     734             : !
     735           0 :       IF (cell%latnam.EQ.'c-b') THEN
     736           0 :          a1(1) = sqrt(2.)* a1(1)
     737             :       END IF
     738           0 :       IF (cell%latnam.EQ.'hex') THEN
     739           0 :          s3 = sqrt(3.)
     740           0 :          a1(1) = 2*a1(1)/sqrt(3.)
     741             :       END IF
     742           0 :       IF (cell%latnam.EQ.'hx3') THEN
     743           0 :          a1(1) = 2*a1(1)
     744             :       END IF
     745             : !
     746             :       IF ((cell%latnam.EQ.'squ').OR.(cell%latnam.EQ.'hex').OR.&
     747           0 :      &    (cell%latnam.EQ.'c-b').OR.(cell%latnam.EQ.'hx3')) THEN
     748           0 :           WRITE (5,9030) a1(1)
     749           0 :       ELSEIF ((cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
     750           0 :           WRITE (5,9030) a1(1),a2(2)
     751           0 :       ELSEIF (cell%latnam.EQ.'obl') THEN
     752           0 :           WRITE (5,9030) a1(1),a1(2)
     753           0 :           WRITE (5,9030) a2(1),a2(2)
     754           0 :       ELSEIF (cell%latnam.EQ.'any') THEN
     755           0 :           WRITE (5,9030) a1(1),a1(2),a1(3)
     756           0 :           WRITE (5,9030) a2(1),a2(2),a2(3)
     757             :       ELSE
     758           0 :           WRITE (6,*) 'rw_inp: cell%latnam ',cell%latnam,' unknown'
     759           0 :            CALL juDFT_error("Invalid lattice name",calledby="rw_inp")
     760             :       ENDIF
     761             : !
     762           0 :       IF (cell%latnam.EQ.'any') THEN
     763           0 :         WRITE (5,9031)  a3(1),a3(2),a3(3),vacuum%dvac,input%scaleCell
     764           0 :         dtild = a3(3)
     765             :       ELSE
     766           0 :         WRITE (5,9030) vacuum%dvac,dtild,input%scaleCell
     767           0 :         a3(3) = input%scaleCell * dtild
     768             :       ENDIF
     769             :  9030 FORMAT (3f15.8)
     770             :  9031 FORMAT (5f15.8)
     771           0 :       IF (namex.EQ.'vhse') THEN
     772           0 :         WRITE (5,9041) namex,relcor,0.25,0.11
     773             :       ELSE
     774           0 :         WRITE (5,9040) namex,relcor
     775             :       ENDIF
     776             :  9040 FORMAT (a4,3x,a12)
     777             :  9041 FORMAT (a4,3x,a12,2f6.3)
     778             :       IF ((namex.EQ.'pw91').OR.(namex.EQ.'l91').OR.&
     779             :      &    (namex.eq.'pbe').OR.(namex.eq.'rpbe').OR.&
     780           0 :    &    (namex.EQ.'Rpbe').OR.(namex.eq.'wc') ) THEN
     781           0 :         WRITE (5,FMT=9121) idum,obsolete%lwb,obsolete%ndvgrd,0,obsolete%chng
     782             :  9121    FORMAT ('igrd=',i1,',lwb=',l1,',ndvgrd=',i1,',idsprs=',i1,&
     783             :      &           ',chng=',d10.3)
     784             :       ENDIF
     785             :       IF( namex.EQ.'hf  ' .OR. namex .EQ. 'exx ' .OR. namex .EQ. 'hse '&
     786           0 :      &    .OR. namex.EQ.'vhse' ) THEN
     787           0 :         WRITE (5,9999) hybrid%gcutm1,hybrid%tolerance1,hybrid%ewaldlambda,hybrid%lexp,hybrid%bands1
     788           0 :         l_hyb = .true.
     789             :       END IF
     790             : 
     791             : 
     792             : !-odim
     793           0 :       IF (oneD%odd%d1) THEN
     794           0 :         WRITE (5,8182) oneD%odd%d1,oneD%odd%M,oneD%odd%mb,&
     795           0 :      &                      oneD%odd%m_cyl,oneD%odd%chi,oneD%odd%rot,oneD%odd%invs,oneD%odd%zrfs
     796             :  8182   FORMAT ('&odim d1=',l1,',MM=',i3,',vM=',i3,&
     797             :      &          ',m_cyl=',i3,',chi=',i3,',rot=',i3,&
     798             :      &          ',invs1=',l1,',zrfs1=',l1,'/')
     799             :       ELSE
     800           0 :         WRITE (5,*) '   '
     801             :       END IF
     802             : !+odim
     803           0 :       WRITE (5,9050) atoms%ntype
     804             :  9050 FORMAT (i3)
     805           0 :       na = 0
     806           0 :       WRITE (5,9060)
     807             :  9060 FORMAT ('**********************************')
     808           0 :       i_u = 1
     809           0 :       DO n=1,atoms%ntype
     810           0 :          WRITE (5,9070) noel(n),atoms%nz(n),atoms%ncst(n),atoms%lmax(n),atoms%jri(n),&
     811           0 :      &                       atoms%rmt(n),atoms%dx(n)
     812             :  9070    FORMAT (a3,i3,3i5,2f10.6)
     813             : !+lda_u
     814           0 :          IF (i_u.LE.atoms%n_u) THEN
     815           0 :             DO WHILE (atoms%lda_u(i_u)%atomType.LT.n)
     816           0 :                i_u = i_u + 1
     817           0 :                IF (i_u.GE.atoms%n_u) EXIT
     818             :             END DO
     819           0 :             IF (atoms%lda_u(i_u)%atomType.EQ.n) THEN
     820           0 :                WRITE (5,8180) atoms%lda_u(i_u)%l,atoms%lda_u(i_u)%u,atoms%lda_u(i_u)%j,atoms%lda_u(i_u)%l_amf
     821             :  8180          FORMAT ('&ldaU l=',i1,',u=',f4.2,',j=',f4.2,',l_amf=',l1,'/')
     822             :             ELSE
     823           0 :                WRITE (5,*) '   '
     824             :             ENDIF
     825             :          ELSE
     826           0 :             WRITE (5,*) '   '
     827             :          END IF
     828             : !-lda_u
     829           0 :         IF ( l_hyb ) THEN
     830           0 :           WRITE (5,9090) atoms%neq(n),atoms%l_geo(n),hybrid%lcutm1(n),hybrid%select1(1,n),&
     831           0 :      &          hybrid%select1(2,n),hybrid%select1(3,n),hybrid%select1(4,n),atoms%nlo(n),&
     832           0 :      &          (atoms%llo(ilo,n),ilo=1,atoms%nlo(n))
     833             :  9090     FORMAT ( i2,',force =',l1,',lcutm=',i2,',select=',&
     834             :      &        i2,',',i2,';',i2,',',i2,',nlo=',i2,',llo=',60i3 )
     835             :         ELSE
     836           0 :           WRITE (5,9091) atoms%neq(n),atoms%l_geo(n),atoms%nlo(n),&
     837           0 :      &          (atoms%llo(ilo,n),ilo=1,atoms%nlo(n))
     838             :  9091     FORMAT (i2,',force =',l1,',nlo=',i2,',llo=',60i3)
     839             :         END IF
     840           0 :          DO ieq=1,atoms%neq(n)
     841           0 :             na = na + 1
     842             : 
     843           0 :             scpos = 1.0
     844           0 :             DO i = 2,9
     845             :                rest = ABS(i*atoms%taual(1,na) - NINT(i*atoms%taual(1,na)) )&
     846           0 :                     + ABS(i*atoms%taual(2,na) - NINT(i*atoms%taual(2,na)) )
     847           0 :                IF (rest.LT.(i*0.000001)) EXIT
     848             :             ENDDO
     849           0 :             IF (i.LT.10) scpos = real(i)  ! common factor found (x,y)
     850           0 :             IF (.NOT.input%film) THEN           ! now check z-coordinate
     851           0 :               DO i = 2,9
     852           0 :                 rest = ABS(i*atoms%taual(3,na) - NINT(i*atoms%taual(3,na)) )
     853           0 :                 IF (rest.LT.(i*scpos*0.000001)) THEN
     854           0 :                   scpos = i*scpos
     855           0 :                   EXIT
     856             :                 ENDIF
     857             :               ENDDO
     858             :             ENDIF
     859           0 :             DO i = 1,2
     860           0 :                atoms%taual(i,na) = atoms%taual(i,na)*scpos
     861             :             ENDDO
     862           0 :             IF (.NOT.input%film) atoms%taual(3,na) = atoms%taual(3,na)*scpos
     863           0 :             IF (input%film) atoms%taual(3,na) = a3(3)*atoms%taual(3,na)/input%scaleCell
     864             : !+odim in 1D case all the coordinates are given in cartesian YM
     865           0 :             IF (oneD%odd%d1) THEN
     866           0 :                atoms%taual(1,na) = atoms%taual(1,na)*a1(1)
     867           0 :                atoms%taual(2,na) = atoms%taual(2,na)*a2(2)
     868             :             END IF
     869             : !-odim
     870           0 :             WRITE (5,9100) (atoms%taual(i,na),i=1,3),scpos
     871             :  9100       FORMAT (4f10.6)
     872             :          ENDDO
     873           0 :          WRITE (5,9060)
     874             :       ENDDO
     875           0 :       IF ((xcpot%gmaxxc.LE.0).OR.(xcpot%gmaxxc.GT.stars%gmax)) xcpot%gmaxxc=stars%gmax
     876           0 :       WRITE (5,9110) stars%gmax,xcpot%gmaxxc
     877             :  9110 FORMAT (2f10.6)
     878           0 :       WRITE (5,9120) input%vchk,input%cdinf,.false.,input%gw,input%gw_neigd
     879             :  9120 FORMAT ('vchk=',l1,',cdinf=',l1,',pot8=',l1,',gw=',i1,&
     880             :      &        ',numbands=',i4)
     881           0 :       WRITE (5,9130) 0,.false.,input%l_f,input%eonly
     882             :  9130 FORMAT ('lpr=',i1,',form66=',l1,',l_f=',l1,',eonly=',l1)
     883           0 :       IF ( l_hyb ) THEN
     884           0 :         WRITE (chntype,'(i3)') 2*atoms%ntype
     885           0 :         chform = '('//chntype//'i3 )'
     886             :         WRITE (5,FMT=chform) &
     887           0 :      &        (atoms%lnonsph(n),n=1,atoms%ntype),(hybrid%lcutwf(n),n=1,atoms%ntype)
     888             :       ELSE
     889           0 :          WRITE (chntype,'(i3)') atoms%ntype
     890           0 :          chform = '('//chntype//'i3 )'
     891           0 :          WRITE (5,FMT=chform) (atoms%lnonsph(n),n=1,atoms%ntype)
     892             :       END IF
     893             :  9140 FORMAT (25i3)
     894           0 :       WRITE (5,9140) 1,obsolete%lepr
     895             : 
     896           0 :       WRITE (5,'(a)') 'ellow, elup, valence electrons:'
     897             :       
     898           0 :       WRITE (5,9150) input%ellow,input%elup,input%zelec
     899             : 9150  FORMAT (4f10.5)
     900           0 :       WRITE (5,fmt='(f10.5,1x,A)') input%rkmax, '=kmax'
     901           0 :       WRITE (5,9160) input%gauss,input%delgau,input%tria
     902             :  9160 FORMAT ('gauss=',l1,f10.5,'tria=',l1)
     903           0 :       WRITE (5,9170) input%frcor,sliceplot%slice,input%ctail
     904             :  9170 FORMAT ('frcor=',l1,',slice=',l1,',ctail=',l1)
     905           0 :       WRITE (5,9180) input%itmax,input%maxiter,input%imix,input%alpha,input%spinf
     906             :  9180 FORMAT ('itmax=',i3,',maxiter=',i3,',imix=',i2,',alpha=',&
     907             :      &        f6.2,',spinf=',f6.2)
     908             : !+roa
     909           0 :       WRITE (chntype,'(i3)') atoms%ntype
     910           0 :       chform = '("swsp=",l1,'//chntype//'f6.2)'
     911           0 :       WRITE (5,FMT=chform) input%swsp, (atoms%bmu(i),i=1,atoms%ntype)
     912           0 :       chform = '("lflip=",l1,'//chntype//'i3 )'
     913           0 :       WRITE (5,FMT=chform) input%lflip, (atoms%nflip(i),i=1,atoms%ntype)
     914             : !-roa
     915             : !+stm
     916           0 :       WRITE (5,9210) banddos%vacdos,vacuum%layers,input%integ,vacuum%starcoeff,vacuum%nstars,&
     917           0 :      &      vacuum%locx(1),vacuum%locy(1),vacuum%locx(2),vacuum%locy(2),vacuum%nstm,vacuum%tworkf
     918             :  9210 FORMAT ('vacdos=',l1,',layers=',i2,',integ=',l1,',star=',l1,&
     919             :      & ',nstars=',i2,4(4x,f5.2),',nstm=',i1,',tworkf=',f10.6)
     920             : !-stm
     921           0 :       IF (banddos%vacdos) THEN
     922           0 :         IF (input%integ) THEN
     923           0 :           WRITE (5,9220) ((vacuum%izlay(i,k),k=1,2),i=1,vacuum%layers)
     924             :  9220     FORMAT (10(2(i3,1x),1x))
     925             :         ELSE
     926           0 :           WRITE (5,9230) (vacuum%izlay(i,1),i=1,vacuum%layers)
     927             :  9230     FORMAT (20(i3,1x))
     928             :         END IF
     929             :       ELSE
     930           0 :         WRITE (5,*)
     931             :       END IF
     932           0 :       band = .false.
     933           0 :       WRITE (5,9240) sliceplot%iplot,input%score,sliceplot%plpot,band
     934             :  9240 FORMAT ('iplot=',l1,',score=',l1,',plpot=',l1,',band=',l1)
     935           0 :       WRITE (5,9250) sliceplot%kk,sliceplot%e1s,sliceplot%e2s,sliceplot%nnne,input%pallst
     936             :  9250 FORMAT (i3,2f10.6,',nnne=',i3,',pallst=',l1)
     937           0 :       WRITE(5,*) "No relaxation with old input anymore"
     938             :       !WRITE (5,9260) input%xa,input%thetad,input%epsdisp,input%epsforce
     939             :  9260 FORMAT ('xa=',f10.5,',thetad=',f10.5,',epsdisp=',f10.5,&
     940             :      &        ',epsforce=',f10.5)
     941             : !+/-gb
     942           0 :       chform = '("relax ",'//chntype//'(3i1,1x))'
     943           0 :       WRITE (5,FMT=chform) ((atoms%relax(i,k),i=1,3),k=1,atoms%ntype)
     944             :       WRITE (5,'(a,f10.5,a,f10.5,a,f10.5)')&
     945           0 :      &     'emin_dos=',banddos%e2_dos,',emax_dos=',banddos%e1_dos,',sig_dos=',banddos%sig_dos
     946             : 
     947           0 :       IF (ch_rw.eq.'W') CLOSE (5)
     948             :       ELSE
     949           0 :         WRITE (6,*) 'specify either W to write or R to read!'
     950             :       ENDIF
     951             : 
     952          28 :       RETURN
     953             : 
     954             :       !Error handling only here
     955           0 :   99  WRITE (6,*) 'Error reading inp-file'
     956           0 :       CLOSE (6)
     957           0 :       CALL juDFT_error("error reading inp-file",calledby="rw_inp")
     958             : 
     959             :       END SUBROUTINE rw_inp
     960             :       END MODULE m_rwinp

Generated by: LCOV version 1.13