w_inpXML.f90 27.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
MODULE m_winpXML

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!
!!!   XML input file generator
!!!
!!!   This subroutine is supposed to write out a file inp.xml
!!!   containing all required input data.
!!!                                         GM'16
!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
CONTAINS
SUBROUTINE w_inpXML(&
&                   atoms,obsolete,vacuum,input,stars,sliceplot,banddos,&
&                   cell,sym,xcpot,noco,jij,oneD,hybrid,kpts,div,l_gamma,&
&                   noel,namex,relcor,a1,a2,a3,scale,dtild_opt,name_opt,&
17
&                   xmlElectronStates,xmlPrintCoreStates,xmlCoreOccs,&
18
&                   atomTypeSpecies,speciesRepAtomType,l_outFile,numSpecies,&
19
&                   enpara)
20 21 22

   USE m_types
   USE m_juDFT_init
23
   USE m_constants
24
   USE m_xmlOutput
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

   IMPLICIT NONE

! arguments

   TYPE(t_input),INTENT(IN)   :: input
   TYPE(t_sym),INTENT(IN)     :: sym
   TYPE(t_stars),INTENT(IN)   :: stars 
   TYPE(t_atoms),INTENT(IN)   :: atoms
   TYPE(t_vacuum),INTENT(IN)   :: vacuum
   TYPE(t_obsolete),INTENT(IN) :: obsolete
   TYPE(t_kpts),INTENT(IN)     :: kpts
   TYPE(t_oneD),INTENT(IN)     :: oneD
   TYPE(t_hybrid),INTENT(IN)   :: hybrid
   TYPE(t_Jij),INTENT(IN)      :: Jij
   TYPE(t_cell),INTENT(IN)     :: cell
   TYPE(t_banddos),INTENT(IN)  :: banddos
   TYPE(t_sliceplot),INTENT(IN):: sliceplot
   TYPE(t_xcpot),INTENT(IN)    :: xcpot
44
   TYPE(t_noco),INTENT(IN)     :: noco
45
   TYPE(t_enpara),INTENT(IN)   :: enpara
46
   INTEGER, INTENT (IN)        :: numSpecies
47 48
   INTEGER, INTENT (IN)        :: div(3)
   INTEGER, INTENT (IN)        :: atomTypeSpecies(atoms%ntype)
49 50
   INTEGER, INTENT (IN)        :: speciesRepAtomType(numSpecies)
   LOGICAL, INTENT (IN)        :: l_gamma, l_outFile
51 52
   REAL,    INTENT (IN)        :: a1(3),a2(3),a3(3),scale
   REAL, INTENT (IN)     :: xmlCoreOccs(2,29,atoms%ntype)
53
   INTEGER, INTENT (IN)  :: xmlElectronStates(29,atoms%ntype)
54 55
   LOGICAL, INTENT (IN)  :: xmlPrintCoreStates(29,atoms%ntype)
   CHARACTER(len=3),INTENT(IN) :: noel(atoms%ntypd)
56
   CHARACTER(len=4),INTENT(IN) :: namex
57 58 59 60 61
   CHARACTER(len=12),INTENT(IN):: relcor
   REAL,INTENT(IN),OPTIONAL    :: dtild_opt
   CHARACTER(len=8),INTENT(IN),OPTIONAL:: name_opt(10)


62
   INTEGER :: iSpecies, fileNum
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
   CHARACTER(len=8) :: name(10)

!+lda+u
   REAL    u,j
   INTEGER l
   LOGICAL l_amf
   CHARACTER(len=3) ch_test
   NAMELIST /ldaU/ l,u,j,l_amf
!-lda+u
!+odim
   INTEGER MM,vM,m_cyl
   LOGICAL invs1,zrfs1
   INTEGER chi,rot
   LOGICAL d1,band
   NAMELIST /odim/ d1,MM,vM,m_cyl,chi,rot,invs1,zrfs1
!-odim
! ..
! ..  Local Variables
   REAL     ::dtild ,scpos, zc, sumWeight
   INTEGER  ::nw,idsprs, n1, n2
   INTEGER ieq,i,k,na,n,ilo
   REAL s3,ah,a,hs2,rest
   LOGICAL l_hyb,l_sym,ldum
   INTEGER :: ierr
! ..
!...  Local Arrays
   CHARACTER :: helpchar(atoms%ntypd)
   CHARACTER(len=  4) :: chntype
   CHARACTER(len= 41) :: chform
   CHARACTER(len=100) :: line

!     added for HF and hybrid functionals
   REAL                  ::  aMix,omega
   INTEGER               :: idum
   CHARACTER (len=1)     ::  check

   CHARACTER(len=20) :: tempNumberString, speciesName
   CHARACTER(len=150) :: format
   CHARACTER(len=20) :: mixingScheme
   CHARACTER(len=10) :: loType
   CHARACTER(len=10) :: bzIntMode
   CHARACTER(len=200) :: symFilename
105
   LOGICAL :: kptGamma, l_relcor, l_explicit
106 107
   INTEGER :: iAtomType, startCoreStates, endCoreStates
   CHARACTER(len=100) :: xPosString, yPosString, zPosString
108
   CHARACTER(len=200) :: coreStatesString, valenceStatesString
109 110 111 112 113 114 115
   REAL :: tempTaual(3,atoms%nat)
   REAL :: a1Temp(3),a2Temp(3),a3Temp(3)
   REAL :: amatTemp(3,3), bmatTemp(3,3)
   CHARACTER(len=7) :: coreStateList(29) !'(1s1/2)'
   CHARACTER(len=4) :: nobleGasConfigList(6) !'[He]'

   DATA coreStateList / '(1s1/2)','(2s1/2)','(2p1/2)','(2p3/2)','(3s1/2)',&
116
&                       '(3p1/2)','(3p3/2)','(3d3/2)','(3d5/2)','(4s1/2)',&
117 118 119 120 121 122 123 124 125 126 127 128 129 130
&                       '(4p1/2)','(4p3/2)','(5s1/2)','(4d3/2)','(4d5/2)',&
&                       '(5p1/2)','(5p3/2)','(6s1/2)','(4f5/2)','(4f7/2)',&
&                       '(5d3/2)','(5d5/2)','(6p1/2)','(6p3/2)','(7s1/2)',&
&                       '(5f5/2)','(5f7/2)','(6d3/2)','(6d5/2)' /

   DATA nobleGasConfigList / '[He]','[Ne]','[Ar]','[Kr]','[Xe]','[Rn]' /

   IF (PRESENT(dtild_opt)) dtild=dtild_opt
   IF (PRESENT(name_opt)) name=name_opt

   symFilename = 'sym.out'
   kptGamma = l_gamma
   band = .false.
   nw=1
131 132
   IF (TRIM(ADJUSTL(namex)).EQ.'hf'.OR.TRIM(ADJUSTL(namex)).EQ.'exx'.OR.&
       TRIM(ADJUSTL(namex)).EQ.'hse'.OR.TRIM(ADJUSTL(namex)).EQ.'vhse') l_hyb = .true.
133 134 135 136 137 138 139 140 141 142 143 144 145
   l_relcor=.true.
   IF(relcor.EQ.'relativi') THEN
      l_relcor=.true.
   ELSE 
      l_relcor=.false.
   END IF

   DO i = 1, 3
      a1Temp(i) = a1(i)
      a2Temp(i) = a2(i)
      a3Temp(i) = a3(i)
   END DO

146 147 148
   fileNum = -1
   IF(l_outFile) THEN
      fileNum = getXMLOutputUnitNumber()
149
      CALL openXMLElementNoAttributes('inputData')
150 151 152 153
   ELSE
      fileNum = 5
      OPEN (fileNum,file='inp.xml',form='formatted',status='unknown')
      REWIND (fileNum)
154

155 156 157
      WRITE (fileNum,'(a)') '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
      WRITE (fileNum,'(a)') '<fleurInput fleurInputVersion="0.27">'
   END IF
158 159

   IF(PRESENT(name_opt)) THEN
160 161 162
      WRITE (fileNum,'(a)') '   <comment>'
      WRITE (fileNum,'(a6,10a8)') '      ',name
      WRITE (fileNum,'(a)') '   </comment>'
163 164
   END IF

165
   WRITE (fileNum,'(a)') '   <calculationSetup>'
166 167 168

!      <cutoffs Kmax="3.60000" Gmax="11.000000" GmaxXC="9.200000" numbands="0"/>
   110 FORMAT('      <cutoffs Kmax="',f0.8,'" Gmax="',f0.8,'" GmaxXC="',f0.8,'" numbands="',i0,'"/>')
169
   WRITE (fileNum,110) input%rkmax,stars%gmax,xcpot%gmaxxc,input%gw_neigd
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184

!      <scfLoop itmax="9" maxIterBroyd="99" imix="Anderson" alpha="0.05" spinf="2.00"/>
   120 FORMAT('      <scfLoop itmax="',i0,'" maxIterBroyd="',i0,'" imix="',a,'" alpha="',f0.8,'" spinf="',f0.8,'"/>')
   SELECT CASE (input%imix)
      CASE (1) 
         mixingScheme='straight'
      CASE (3) 
         mixingScheme='Broyden1'
      CASE (5) 
         mixingScheme='Broyden2'
      CASE (7) 
         mixingScheme='Anderson'
      CASE DEFAULT 
         mixingScheme='errorUnknownMixing'
   END SELECT
185
   WRITE (fileNum,120) input%itmax,input%maxiter,TRIM(mixingScheme),input%alpha,input%spinf
186 187 188

!      <coreElectrons ctail="T" frcor="F" kcrel="0"/>
   130 FORMAT('      <coreElectrons ctail="',l1,'" frcor="',l1,'" kcrel="',i0,'"/>')
189
   WRITE (fileNum,130) input%ctail,input%frcor,input%kcrel
190 191 192

!      <magnetism jspins="1" l_noco="F" l_J="F" swsp="F" lflip="F"/>
   140 FORMAT('      <magnetism jspins="',i0,'" l_noco="',l1,'" l_J="',l1,'" swsp="',l1,'" lflip="',l1,'"/>')
193
   WRITE (fileNum,140) input%jspins,noco%l_noco,jij%l_J,input%swsp,input%lflip
194 195 196

!      <soc theta="0.00000" phi="0.00000" l_soc="F" spav="F" off="F" soc66="F"/>
   150 FORMAT('      <soc theta="',f0.8,'" phi="',f0.8,'" l_soc="',l1,'" spav="',l1,'" off="',l1,'" soc66="',l1,'"/>')
197
   WRITE (fileNum,150) noco%theta,noco%phi,noco%l_soc,noco%soc_opt(atoms%ntype+2),noco%soc_opt(atoms%ntype+1),obsolete%eig66(2)
198 199 200 201 202 203 204 205

   IF (noco%l_noco) THEN
      160 FORMAT('      <nocoParams l_ss="',l1,'" l_mperp="',l1,'" l_constr="',l1,'" l_disp="',l1,'" sso_opt="',a3,'" mix_b="',f0.8,'" thetaJ="',f0.8,'" nsh="',i0,'"/>')
      STOP 'Output of Noco input not yet implemented!'
   END IF

   IF (oneD%odd%d1) THEN
      170 FORMAT('      <oneDParams d1="',l1,'" MM="',i0,'" vM="',i0,'" m_cyl="',i0,'" chi="',i0,'" rot="',i0,'" invs1="',l1,'" zrfs1="',l1,'"/>')
206
      WRITE (fileNum,170) oneD%odd%d1,oneD%odd%M,oneD%odd%mb,oneD%odd%m_cyl,oneD%odd%chi,oneD%odd%rot,oneD%odd%invs,oneD%odd%zrfs
207 208 209 210
   END IF

!      <expertModes gw="0" pot8="F" eig66="F" lpr="0" isec1="99" secvar="F" />
   180 FORMAT('      <expertModes gw="',i0,'" pot8="',l1,'" eig66="',l1,'" lpr="',i0,'" isec1="',i0,'" secvar="',l1,'"/>')
211
   WRITE (fileNum,180) input%gw,obsolete%pot8,obsolete%eig66(1),obsolete%lpr,input%isec1,input%secvar
212 213 214

!      <geometryOptimization l_f="F" xa="2.00000" thetad="330.00000" epsdisp="0.00001" epsforce="0.00001"/>
   190 FORMAT('      <geometryOptimization l_f="',l1,'" xa="',f0.8,'" thetad="',f0.8,'" epsdisp="',f0.8,'" epsforce="',f0.8,'"/>')
215
   WRITE (fileNum,190) input%l_f,input%xa,input%thetad,input%epsdisp,input%epsforce
216 217 218 219 220 221 222 223 224 225 226 227 228

   IF(input%gauss.AND.input%tria) THEN
      STOP 'Error: bz integration modes gauss AND tria selected!'
   END IF

   bzIntMode = 'hist'
   IF(input%gauss) THEN
      bzIntMode = 'gauss'
   ELSE IF(input%tria) THEN
      bzIntMode = 'tria'
   END IF
!      <bzIntegration valenceElectrons="8.00000" mode="hist" fermiSmearingEnergy="0.00100">
   200 FORMAT('      <bzIntegration valenceElectrons="',f0.8,'" mode="',a,'" fermiSmearingEnergy="',f0.8,'">')
229
   WRITE (fileNum,200) input%zelec,TRIM(ADJUSTL(bzIntMode)),input%tkb
230

231 232
   l_explicit = juDFT_was_argument("-explicit").OR.l_outFile
   IF(l_explicit) THEN
233
      sumWeight = 0.0
234
      DO i = 1, kpts%nkpt
235 236 237
         sumWeight = sumWeight + kpts%weight(i)
      END DO
      205 FORMAT('         <kPointList posScale="',f0.8,'" weightScale="',f0.8,'" count="',i0,'">')
238
      WRITE (fileNum,205) kpts%posScale, sumWeight, kpts%nkpt
239 240
      DO i = 1, kpts%nkpt
         206 FORMAT('            <kPoint weight="',f12.6,'">',f12.6,' ',f12.6,' ',f12.6,'</kPoint>')
241
         WRITE (fileNum,206) kpts%weight(i), kpts%bk(1,i), kpts%bk(2,i), kpts%bk(3,i)
242
      END DO
243
      WRITE (fileNum,'(a)')('         </kPointList>')
244 245 246
   ELSE IF( (div(1) == 0).OR.(div(2) == 0) ) THEN
!            <kPointCount count="100" gamma="F"/>
      208 FORMAT('         <kPointCount count="',i0,'" gamma="',l1,'"/>')
247
      WRITE (fileNum,208) kpts%nkpt,kptGamma
248 249 250
   ELSE
!            <kPointMesh nx="10" ny="10" nz="10" gamma="F"/>
      210 FORMAT('         <kPointMesh nx="',i0,'" ny="',i0,'" nz="',i0,'" gamma="',l1,'"/>')
251
      WRITE (fileNum,210) div(1),div(2),div(3),kptGamma
252
   END IF
253
   WRITE (fileNum,'(a)') '      </bzIntegration>'
254 255 256

!      <energyParameterLimits ellow="-2.00000" elup="2.00000"/>
   220 FORMAT('      <energyParameterLimits ellow="',f0.8,'" elup="',f0.8,'"/>')
257
   WRITE (fileNum,220) input%ellow,input%elup
258

259 260
   WRITE (fileNum,'(a)') '   </calculationSetup>'
   WRITE (fileNum,'(a)') '   <cell>'
261

262 263
   IF(l_explicit) THEN
      WRITE(fileNum,'(a)') '      <symmetryOperations>'
264
      DO i = 1, sym%nop
265
      WRITE(fileNum,'(a)') '         <symOp>'
266
      224 FORMAT('            <row-1>',i0,' ',i0,' ',i0,' ',f0.15,'</row-1>')
267
      WRITE(fileNum,224) sym%mrot(1,1,i), sym%mrot(1,2,i), sym%mrot(1,3,i), sym%tau(1,i)
268
      225 FORMAT('            <row-2>',i0,' ',i0,' ',i0,' ',f0.15,'</row-2>')
269
      WRITE(fileNum,225) sym%mrot(2,1,i), sym%mrot(2,2,i), sym%mrot(2,3,i), sym%tau(2,i)
270
      226 FORMAT('            <row-3>',i0,' ',i0,' ',i0,' ',f0.15,'</row-3>')
271 272
      WRITE(fileNum,226) sym%mrot(3,1,i), sym%mrot(3,2,i), sym%mrot(3,3,i), sym%tau(3,i)
      WRITE(fileNum,'(a)') '         </symOp>'
273
      END DO
274
      WRITE(fileNum,'(a)') '      </symmetryOperations>'
275 276
   ELSE IF(TRIM(ADJUSTL(sym%namgrp)).EQ.'any') THEN
      228 FORMAT('      <symmetryFile filename="',a,'"/>')
277
      WRITE(fileNum,228) TRIM(ADJUSTL(symFilename))
278 279 280
   ELSE
!      <symmetry spgrp="any" invs="T" zrfs="F"/>
      230 FORMAT('      <symmetry spgrp="',a,'" invs="',l1,'" zrfs="',l1,'"/>')
281
      WRITE (fileNum,230) TRIM(ADJUSTL(sym%namgrp)),sym%invs,sym%zrfs
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303

   END IF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Note: Different options for the cell definition!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

   IF (cell%latnam.EQ.'c-b') THEN
      a1Temp(1) = sqrt(2.)* a1Temp(1)
   END IF
   IF (cell%latnam.EQ.'hex') THEN
      s3 = sqrt(3.)
      a1Temp(1) = 2*a1Temp(1)/sqrt(3.)
   END IF
   IF (cell%latnam.EQ.'hx3') THEN
      a1Temp(1) = 2*a1Temp(1)
   END IF

   IF (input%film) THEN
!      <xsd:attribute name="dVac" type="xsd:double" use="required"/>
!      <xsd:attribute name="dTilda" type="xsd:double" use="required"/>
!      <filmLattice ...>
      241 FORMAT('      <filmLattice scale="',f0.8,'" latnam="',a,'" dVac="',f0.8,'" dTilda="',f0.8,'">')
304
      WRITE(fileNum,241) scale, TRIM(ADJUSTL(cell%latnam)), vacuum%dvac, dtild
305
      IF (cell%latnam.EQ.'any') THEN
306
         WRITE (fileNum,'(a)') '         <bravaisMatrix>'
307
         255 FORMAT('            <row-1>',f0.12,' ',f0.12,' ',f0.12,'</row-1>')
308
         WRITE (fileNum,255) a1Temp(1),a1Temp(2),a1Temp(3)
309
         265 FORMAT('            <row-2>',f0.12,' ',f0.12,' ',f0.12,'</row-2>')
310
         WRITE (fileNum,265) a2Temp(1),a2Temp(2),a2Temp(3)
311
         275 FORMAT('            <row-3>',f0.12,' ',f0.12,' ',f0.12,'</row-3>')
312 313
         WRITE (fileNum,275) a3Temp(1),a3Temp(2),a3Temp(3)
         WRITE (fileNum,'(a)') '         </bravaisMatrix>'
314 315 316 317 318
      ELSE
         IF ((cell%latnam.EQ.'squ').OR.(cell%latnam.EQ.'hex').OR.&
     &       (cell%latnam.EQ.'c-b').OR.(cell%latnam.EQ.'hx3').OR.&
     &       (cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
            256 FORMAT('         <a1>',f0.12,'</a1>')
319
            WRITE (fileNum,256) a1Temp(1)
320 321 322
         END IF
         IF ((cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
            266 FORMAT('         <a2>',f0.12,'</a2>')
323
            WRITE (fileNum,266) a2Temp(2)
324 325 326 327
         END IF

         IF (cell%latnam.EQ.'obl') THEN
            257 FORMAT('         <row-1>',f0.12,' ',f0.12,'</row-1>')
328
            WRITE (fileNum,257) a1Temp(1), a1Temp(2)
329
            267 FORMAT('         <row-2>',f0.12,' ',f0.12,'</row-2>')
330
            WRITE (fileNum,267) a2Temp(1), a2Temp(2)
331 332 333
         END IF
      END IF

334
      268 FORMAT('         <vacuumEnergyParameters vacuum="',i0,'" spinUp="',f0.8,'" spinDown="',f0.8,'"/>')
335 336 337 338
      DO i = 1, vacuum%nvac
         WRITE(fileNum,268) i, enpara%evac0(i,1), enpara%evac0(i,input%jspins)
      END DO

339
      WRITE (fileNum,'(a)') '      </filmLattice>'
340 341 342
   ELSE

      242 FORMAT('      <bulkLattice scale="',f0.12,'" latnam="',a,'">')
343
      WRITE (fileNum,242) scale, TRIM(ADJUSTL(cell%latnam))
344 345 346 347

      IF (cell%latnam.EQ.'any') THEN

!         <bravaisMatrix scale="1.0000000">
348
         WRITE (fileNum,'(a)') '         <bravaisMatrix>'
349 350 351

!            <row-1>0.00000 5.13000 5.13000</row-1>
         250 FORMAT('            <row-1>',f0.12,' ',f0.12,' ',f0.12,'</row-1>')
352
         WRITE (fileNum,250) a1Temp(1),a1Temp(2),a1Temp(3)
353 354
!            <row-2>5.13000 0.00000 5.13000</row-2>
         260 FORMAT('            <row-2>',f0.12,' ',f0.12,' ',f0.12,'</row-2>')
355
         WRITE (fileNum,260) a2Temp(1),a2Temp(2),a2Temp(3)
356 357
!            <row-3>5.13000 5.13000 0.00000</row-3>
         270 FORMAT('            <row-3>',f0.12,' ',f0.12,' ',f0.12,'</row-3>')
358
         WRITE (fileNum,270) a3Temp(1),a3Temp(2),a3Temp(3)
359

360
         WRITE (fileNum,'(a)') '         </bravaisMatrix>'
361 362 363 364 365 366
      END IF

      IF ((cell%latnam.EQ.'squ').OR.(cell%latnam.EQ.'hex').OR.&
     &    (cell%latnam.EQ.'c-b').OR.(cell%latnam.EQ.'hx3').OR.&
     &    (cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
         252 FORMAT('         <a1>',f0.12,'</a1>')
367
         WRITE (fileNum,252) a1Temp(1)
368 369 370

         IF ((cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
            262 FORMAT('         <a2>',f0.12,'</a2>')
371
            WRITE (fileNum,262) a2Temp(2)
372 373 374
         END IF

         272 FORMAT('         <c>',f0.12,'</c>')
375
         WRITE (fileNum,272) dtild
376 377 378 379
      END IF

      IF (cell%latnam.EQ.'obl') THEN
         254 FORMAT('         <row-1>',f0.12,' ',f0.12,'</row-1>')
380
         WRITE (fileNum,254) a1Temp(1), a1Temp(2)
381 382

         264 FORMAT('         <row-2>',f0.12,' ',f0.12,'</row-2>')
383
         WRITE (fileNum,264) a2Temp(1), a2Temp(2)
384 385

         274 FORMAT('         <c>',f0.12,'</c>')
386
         WRITE (fileNum,274) dtild
387 388
      END IF

389
      WRITE (fileNum,'(a)') '      </bulkLattice>'
390
   END IF
391
   WRITE (fileNum,'(a)') '   </cell>'
392 393 394

!   <xcFunctional name="pbe" relativisticCorrections="F">
   280 FORMAT('   <xcFunctional name="',a,'" relativisticCorrections="',l1,'"/>')
395
   WRITE (fileNum,280) TRIM(namex), l_relcor
396 397 398 399

!      <xcParams igrd="1" lwb="F" ndvgrd="6" idsprs="0" chng="-0.100e-11"/>

!   290 FORMAT('      <xcParams igrd="',i0,'" lwb="',l1,'" ndvgrd="',i0,'" idsprs="',i0,'" chng="',e,'"/>')
400 401
!   WRITE (fileNum,290) xcpot%igrd,obsolete%lwb,obsolete%ndvgrd,0,obsolete%chng
!   WRITE (fileNum,'(a)') '   </xcFunctional>'
402

403 404
   WRITE (fileNum,'(a)') '   <atomSpecies>'
   DO iSpecies=1, numSpecies
405 406 407 408 409 410 411
      iAtomType = speciesRepAtomType(iSpecies)
      IF(iAtomType.EQ.-1) THEN
         EXIT
      END IF
!      <species name="Si-1" element="Si" atomicNumber="14" coreStates="4" magMom="0.0" flipSpin="F">
      300 FORMAT('      <species name="',a,'" element="',a,'" atomicNumber="',i0,'" coreStates="',i0,'" magMom="',f0.8,'" flipSpin="',l1,'">')
      tempNumberString = ''
412
      WRITE(tempNumberString,'(i0)') iSpecies
413
      speciesName = TRIM(ADJUSTL(noel(iAtomType))) // '-' // TRIM(ADJUSTL(tempNumberString))
414
      WRITE (fileNum,300) TRIM(ADJUSTL(speciesName)),TRIM(ADJUSTL(noel(iAtomType))),atoms%nz(iAtomType),atoms%ncst(iAtomType),atoms%bmu(iAtomType),atoms%nflip(iAtomType)
415 416 417

!         <mtSphere radius="2.160000" gridPoints="521" logIncrement="0.022000"/>
      310 FORMAT('         <mtSphere radius="',f0.8,'" gridPoints="',i0,'" logIncrement="',f0.8,'"/>')
418
      WRITE (fileNum,310) atoms%rmt(iAtomType),atoms%jri(iAtomType),atoms%dx(iAtomType)
419 420 421

!         <atomicCutoffs lmax="8" lnonsphr="6"/>
      320 FORMAT('         <atomicCutoffs lmax="',i0,'" lnonsphr="',i0,'"/>')
422
      WRITE (fileNum,320) atoms%lmax(iAtomType),atoms%lnonsph(iAtomType)
423

424
      IF (ALL((enpara%el0(0:3,iAtomType,1)-INT(enpara%el0(0:3,iAtomType,1))).LE.0.00000001)) THEN
425
!         <energyParameters s="3" p="3" d="3" f="4"/>
426
         321 FORMAT('         <energyParameters s="',i0,'" p="',i0,'" d="',i0,'" f="',i0,'"/>')
427 428
         WRITE (fileNum,321) INT(enpara%el0(0,iAtomType,1)),INT(enpara%el0(1,iAtomType,1)),&
                             INT(enpara%el0(2,iAtomType,1)),INT(enpara%el0(3,iAtomType,1))
429 430
      END IF

431
      IF(ANY(xmlElectronStates(:,iAtomType).NE.noState_const)) THEN
432 433 434
         endCoreStates = 1
         startCoreStates = 1
         coreStatesString = ''
435
         valenceStatesString = ''
436
         DO i = 1, 29
437
            IF (xmlElectronStates(i,iAtomType).EQ.coreState_const) endCoreStates = i
438 439
         END DO
         IF ((endCoreStates.GE.24).AND.&
440
&            (ALL(xmlPrintCoreStates(1:24,iAtomType).EQV..FALSE.)).AND.&
441
&            (ALL(xmlElectronStates(1:24,iAtomType).EQ.coreState_const)) ) THEN
442 443 444
            coreStatesString = nobleGasConfigList(6)
            startCoreStates = 25
         ELSE IF ((endCoreStates.GE.17).AND.&
445
&                 (ALL(xmlPrintCoreStates(1:17,iAtomType).EQV..FALSE.)).AND.&
446
&                 (ALL(xmlElectronStates(1:17,iAtomType).EQ.coreState_const))) THEN
447 448 449
            coreStatesString = nobleGasConfigList(5)
            startCoreStates = 18
         ELSE IF ((endCoreStates.GE.12).AND.&
450
&                 (ALL(xmlPrintCoreStates(1:12,iAtomType).EQV..FALSE.)).AND.&
451
&                 (ALL(xmlElectronStates(1:12,iAtomType).EQ.coreState_const))) THEN
452 453 454
            coreStatesString = nobleGasConfigList(4)
            startCoreStates = 13
         ELSE IF ((endCoreStates.GE.7).AND.&
455
&                 (ALL(xmlPrintCoreStates(1:7,iAtomType).EQV..FALSE.)).AND.&
456
&                 (ALL(xmlElectronStates(1:7,iAtomType).EQ.coreState_const))) THEN
457 458 459
            coreStatesString = nobleGasConfigList(3)
            startCoreStates = 8
         ELSE IF ((endCoreStates.GE.4).AND.&
460
&                 (ALL(xmlPrintCoreStates(1:4,iAtomType).EQV..FALSE.)).AND.&
461
&                 (ALL(xmlElectronStates(1:4,iAtomType).EQ.coreState_const))) THEN
462 463 464
            coreStatesString = nobleGasConfigList(2)
            startCoreStates = 5
         ELSE IF ((endCoreStates.GE.1).AND.&
465
&                 (ALL(xmlPrintCoreStates(1:1,iAtomType).EQV..FALSE.)).AND.&
466 467
&                 (ALL(xmlElectronStates(1:1,iAtomType).EQ.coreState_const))) THEN
            coreStatesString = nobleGasConfigList(1)
468 469 470
            startCoreStates = 2
         END IF
         DO i = startCoreStates, endCoreStates
471
            IF(xmlElectronStates(i,iAtomType).EQ.coreState_const) THEN
472 473 474
               coreStatesString = TRIM(ADJUSTL(coreStatesString)) // ' ' // coreStateList(i)
            END IF
         END DO
475 476 477 478 479
         DO i = 1, 29
            IF(xmlElectronStates(i,iAtomType).EQ.valenceState_const) THEN
               valenceStatesString = TRIM(ADJUSTL(valenceStatesString)) // ' ' // coreStateList(i)
            END IF
         END DO
480
         WRITE (fileNum,'(a)') '         <electronConfig>'
481
!         <coreConfig>[He] (2s1/2) (2p1/2) (2p3/2)</coreConfig>
482
         322 FORMAT('            <coreConfig>',a,'</coreConfig>')
483
         WRITE(fileNum,322) TRIM(ADJUSTL(coreStatesString))
484
         323 FORMAT('            <valenceConfig>',a,'</valenceConfig>')
485
         WRITE(fileNum,323) TRIM(ADJUSTL(valenceStatesString))
486 487
         DO i = startCoreStates, 29
            IF ((xmlElectronStates(i,iAtomType).NE.noState_const).AND.(xmlPrintCoreStates(i,iAtomType))) THEN
488
!         <coreStateOccupation state="(2s1/2)" spinUp="1.0" spinDown="1.0"/>
489
               325 FORMAT('            <stateOccupation state="',a,'" spinUp="',f0.8,'" spinDown="',f0.8,'"/>')
490
               WRITE(fileNum,325) coreStateList(i), xmlCoreOccs(1,i,iAtomType), xmlCoreOccs(2,i,iAtomType)
491 492
            END IF
         END DO
493
         WRITE (fileNum,'(a)') '         </electronConfig>'
494 495 496 497 498
      END IF

      DO ilo = 1, atoms%nlo(iAtomType)
!         <lo type="HELO" l="0" n="4"/>
         l = atoms%llo(ilo,iAtomType)
499 500 501 502
         n = INT(enpara%ello0(ilo,iAtomType,1))
         loType = 'SCLO'
         IF(n.LT.0) THEN
            loType = 'HELO'
503
         END IF
504 505 506
         n = ABS(n)
         324 FORMAT('         <lo type="',a,'" l="',i0,'" n="',i0,'" eDeriv="',i0,'"/>')
         WRITE (fileNum,324) TRIM(ADJUSTL(loType)), l, n, atoms%ulo_der(ilo,iAtomType)
507 508
      END DO

509
      WRITE (fileNum,'(a)') '      </species>'
510
   END DO
511 512
   WRITE (fileNum,'(a)') '   </atomSpecies>'
   WRITE (fileNum,'(a)') '   <atomGroups>'
513 514 515 516 517 518
   na = 0
   DO iAtomType=1, atoms%ntype
      iSpecies = atomTypeSpecies(iAtomType)
!      <atomGroup species="Si-1">
      330 FORMAT('      <atomGroup species="',a,'">')
      tempNumberString = ''
519
      WRITE(tempNumberString,'(i0)') iSpecies
520
      speciesName = TRIM(ADJUSTL(noel(iAtomType))) // '-' // TRIM(ADJUSTL(tempNumberString))
521
      WRITE (fileNum,330) TRIM(ADJUSTL(speciesName))
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541

      DO ieq=1,atoms%neq(iAtomType)
         na = na + 1
         tempTaual(1,na) = atoms%taual(1,na)
         tempTaual(2,na) = atoms%taual(2,na)
         tempTaual(3,na) = atoms%taual(3,na)
         DO i = 2,9
            rest = ABS(i*tempTaual(1,na) - NINT(i*tempTaual(1,na)) ) + ABS(i*tempTaual(2,na) - NINT(i*tempTaual(2,na)))
            IF (.not.input%film) THEN
               rest = rest + ABS(i*tempTaual(3,na) - NINT(i*tempTaual(3,na)) )
            END IF
            IF (rest.LT.(i*0.000001)) EXIT
         END DO
         scpos = 1.0
         IF (i.LT.10) scpos = real(i)  ! common factor found (x,y)
         DO i = 1,2
            tempTaual(i,na) = tempTaual(i,na)*scpos
         ENDDO
         IF (.not.input%film) tempTaual(3,na) = tempTaual(3,na)*scpos
         IF (input%film) THEN
542
            tempTaual(3,na) = dtild*tempTaual(3,na)/scale
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
         END IF
!+odim in 1D case all the coordinates are given in cartesian YM
         IF (oneD%odd%d1) THEN
            tempTaual(1,na) = tempTaual(1,na)*a1(1)
            tempTaual(2,na) = tempTaual(2,na)*a2(2)
         END IF
!-odim
         IF (oneD%odd%d1) THEN
            STOP '1D position output not implemented!'
         ELSE IF (input%film) THEN
!         <filmPos> x/myConstant  y/myConstant  1/myConstant</filmPos>
            340 FORMAT('         <filmPos>',a,' ',a,' ',a,'</filmPos>')
            xPosString = ''
            yPosString = ''
            zPosString = ''
            IF((scpos.NE.1.0).AND.((tempTaual(1,na).NE.0.0).OR.(tempTaual(2,na).NE.0.0).OR.(tempTaual(3,na).NE.0.0))) THEN
               WRITE(xPosString,'(f0.12,a1,f0.12)') tempTaual(1,na), '/', scpos
               WRITE(yPosString,'(f0.12,a1,f0.12)') tempTaual(2,na), '/', scpos
            ELSE
               WRITE(xPosString,'(f0.12)') tempTaual(1,na)
               WRITE(yPosString,'(f0.12)') tempTaual(2,na)
            END IF
            WRITE(zPosString,'(f0.12)') tempTaual(3,na)
566
            WRITE (fileNum,340) TRIM(ADJUSTL(xPosString)),TRIM(ADJUSTL(yPosString)),TRIM(ADJUSTL(zPosString))
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
         ELSE
!         <relPos> x/myConstant  y/myConstant  z/myConstant</relPos>
            350 FORMAT('         <relPos>',a,' ',a,' ',a,'</relPos>')
            xPosString = ''
            yPosString = ''
            zPosString = ''
            IF((scpos.NE.1.0).AND.((tempTaual(1,na).NE.0.0).OR.(tempTaual(2,na).NE.0.0).OR.(tempTaual(3,na).NE.0.0))) THEN
               WRITE(xPosString,'(f0.12,a1,f0.12)') tempTaual(1,na), '/', scpos
               WRITE(yPosString,'(f0.12,a1,f0.12)') tempTaual(2,na), '/', scpos
               WRITE(zPosString,'(f0.12,a1,f0.12)') tempTaual(3,na), '/', scpos
            ELSE
               WRITE(xPosString,'(f0.12)') tempTaual(1,na)
               WRITE(yPosString,'(f0.12)') tempTaual(2,na)
               WRITE(zPosString,'(f0.12)') tempTaual(3,na)
            END IF
582
            WRITE (fileNum,350) TRIM(ADJUSTL(xPosString)),TRIM(ADJUSTL(yPosString)),TRIM(ADJUSTL(zPosString))
583 584 585 586
         END IF
      END DO
!         <force calculate="F" relaxX="T" relaxY="T" relaxZ="T"/>
      360 FORMAT('         <force calculate="',l1,'" relaxXYZ="',3l1,'"/>')
587
      WRITE (fileNum,360) atoms%l_geo(iAtomType),atoms%relax(1,iAtomType),atoms%relax(2,iAtomType),atoms%relax(3,iAtomType)
588

589
      WRITE (fileNum,'(a)') '      </atomGroup>'
590
   END DO
591
   WRITE (fileNum,'(a)') '   </atomGroups>'
592 593

   368 FORMAT('   <output dos="',l1,'" band="',l1,'" vacdos="',l1,'" slice="',l1,'">')
594
   WRITE (fileNum,368) banddos%dos,band,banddos%vacdos,sliceplot%slice
595 596 597

!      <checks vchk="F" cdinf="F" disp="F"/>
   370 FORMAT('      <checks vchk="',l1,'" cdinf="',l1,'" disp="',l1,'"/>')
598
   WRITE (fileNum,370) input%vchk,input%cdinf,obsolete%disp
599 600 601

!      <densityOfStates ndir="0" minEnergy="-0.50000" maxEnergy="0.50000" sigma="0.01500"/>  
   380 FORMAT('      <densityOfStates ndir="',i0,'" minEnergy="',f0.8,'" maxEnergy="',f0.8,'" sigma="',f0.8,'"/>')
602
   WRITE (fileNum,380) banddos%ndir,banddos%e2_dos,banddos%e1_dos,banddos%sig_dos
603 604 605

!      <vacuumDOS layers="0" integ="F" star="F" nstars="0" locx1="0.00" locy1="0.00" locx2="0.00" locy2="0.00" nstm="0" tworkf="0.000000"/>
   390 FORMAT('      <vacuumDOS layers="',i0,'" integ="',l1,'" star="',l1,'" nstars="',i0,'" locx1="',f0.8,'" locy1="',f0.8,'" locx2="',f0.8,'" locy2="',f0.8,'" nstm="',i0,'" tworkf="',f0.8,'"/>')
606
   WRITE (fileNum,390) vacuum%layers,input%integ,vacuum%starcoeff,vacuum%nstars,vacuum%locx(1),vacuum%locy(1),vacuum%locx(2),vacuum%locy(2),vacuum%nstm,vacuum%tworkf
607 608 609

!      <plotting iplot="F" score="F" plplot="F"/>
   400 FORMAT('      <plotting iplot="',l1,'" score="',l1,'" plplot="',l1,'"/>')
610
   WRITE (fileNum,400) sliceplot%iplot,input%score,sliceplot%plpot
611 612 613

!      <chargeDensitySlicing numkpt="0" minEigenval="0.000000" maxEigenval="0.000000" nnne="0" pallst="F"/>
   410 FORMAT('      <chargeDensitySlicing numkpt="',i0,'" minEigenval="',f0.8,'" maxEigenval="',f0.8,'" nnne="',i0,'" pallst="',l1,'"/>')
614
   WRITE (fileNum,410) sliceplot%kk,sliceplot%e1s,sliceplot%e2s,sliceplot%nnne,input%pallst
615 616 617

!      <specialOutput form66="F" eonly="F" bmt="F"/>
   420 FORMAT('      <specialOutput form66="',l1,'" eonly="',l1,'" bmt="',l1,'"/>')
618
   WRITE (fileNum,420) obsolete%form66,input%eonly,input%l_bmt
619

620
   WRITE (fileNum,'(a)') '   </output>'
621 622 623
   IF(l_outFile) THEN
      CALL closeXMLElement('inputData')
   ELSE
624 625 626
      WRITE (fileNum,'(a)') '</fleurInput>'
      CLOSE (fileNum)
   END IF
627 628 629

END SUBROUTINE w_inpXML
END MODULE m_winpXML