w_inpXML.f90 29.7 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! 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.
!--------------------------------------------------------------------------------

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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,&
22
&                   noel,namex,relcor,a1,a2,a3,dtild_opt,name_opt,&
23
&                   xmlElectronStates,xmlPrintCoreStates,xmlCoreOccs,&
24
&                   atomTypeSpecies,speciesRepAtomType,l_outFile,filename,&
25
&                   l_explicitIn,numSpecies,enpara)
26 27

   USE m_types
Daniel Wortmann's avatar
Daniel Wortmann committed
28
   USE m_juDFT
29
   USE m_constants
30
   USE m_xmlOutput
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

   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
50
   TYPE(t_noco),INTENT(IN)     :: noco
51
   TYPE(t_enpara),INTENT(IN)   :: enpara
52
   INTEGER, INTENT (IN)        :: numSpecies
53 54
   INTEGER, INTENT (IN)        :: div(3)
   INTEGER, INTENT (IN)        :: atomTypeSpecies(atoms%ntype)
55
   INTEGER, INTENT (IN)        :: speciesRepAtomType(numSpecies)
56
   LOGICAL, INTENT (IN)        :: l_gamma, l_outFile, l_explicitIn
57
   REAL,    INTENT (IN)        :: a1(3),a2(3),a3(3)
58
   REAL, INTENT (IN)     :: xmlCoreOccs(2,29,atoms%ntype)
59
   INTEGER, INTENT (IN)  :: xmlElectronStates(29,atoms%ntype)
60
   LOGICAL, INTENT (IN)  :: xmlPrintCoreStates(29,atoms%ntype)
Daniel Wortmann's avatar
Daniel Wortmann committed
61
   CHARACTER(len=3),INTENT(IN) :: noel(atoms%ntype)
62
   CHARACTER(len=4),INTENT(IN) :: namex
63
   CHARACTER(len=12),INTENT(IN):: relcor
64
   CHARACTER(LEN=*),INTENT(IN) :: filename
65 66 67 68
   REAL,INTENT(IN),OPTIONAL    :: dtild_opt
   CHARACTER(len=8),INTENT(IN),OPTIONAL:: name_opt(10)


69
   INTEGER :: iSpecies, fileNum
70 71 72 73
   CHARACTER(len=8) :: name(10)

!+lda+u
   REAL    u,j
Daniel Wortmann's avatar
Daniel Wortmann committed
74 75
   INTEGER l, i_u
   INTEGER uIndices(2,atoms%ntype)
76 77 78 79 80 81 82 83 84 85 86 87 88
   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
89
   REAL     ::dtild, zc, sumWeight
90 91 92 93 94 95 96
   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
Daniel Wortmann's avatar
Daniel Wortmann committed
97
   CHARACTER :: helpchar(atoms%ntype)
98 99
   CHARACTER(len=  4) :: chntype
   CHARACTER(len= 41) :: chform
100
   CHARACTER(len=100) :: line
101 102 103 104 105 106

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

107
   CHARACTER(len=20) :: speciesName
108 109 110 111 112
   CHARACTER(len=150) :: format
   CHARACTER(len=20) :: mixingScheme
   CHARACTER(len=10) :: loType
   CHARACTER(len=10) :: bzIntMode
   CHARACTER(len=200) :: symFilename
113
   LOGICAL :: kptGamma, l_relcor, l_explicit, l_nocoOpt
114
   INTEGER :: iAtomType, startCoreStates, endCoreStates
115
   CHARACTER(len=100) :: posString(3)
116
   CHARACTER(len=200) :: coreStatesString, valenceStatesString
117
   REAL :: tempTaual(3,atoms%nat), scpos(3)
118 119 120 121 122 123
   REAL :: a1Temp(3),a2Temp(3),a3Temp(3)
   REAL :: amatTemp(3,3), bmatTemp(3,3)

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

124
   l_explicit = l_explicitIn.OR.l_outFile
125
   l_nocoOpt = noco%l_noco.OR.juDFT_was_argument("-noco")
126

127 128 129 130
   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
   ELSE
      fileNum = 5
152
      OPEN (fileNum,file=TRIM(ADJUSTL(filename)),form='formatted',status='unknown')
153
      REWIND (fileNum)
154

155
      WRITE (fileNum,'(a)') '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
156
      WRITE (fileNum,'(a)') '<fleurInput fleurInputVersion="0.29">'
157
   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

!      <scfLoop itmax="9" maxIterBroyd="99" imix="Anderson" alpha="0.05" spinf="2.00"/>
172
   120 FORMAT('      <scfLoop itmax="',i0,'" minDistance="',f0.8,'" maxIterBroyd="',i0,'" imix="',a,'" alpha="',f0.8,'" spinf="',f0.8,'"/>')
173 174 175 176 177 178 179 180 181 182 183 184
   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%minDistance,input%maxiter,TRIM(mixingScheme),input%alpha,input%spinf
186 187

!      <coreElectrons ctail="T" frcor="F" kcrel="0"/>
188 189
   130 FORMAT('      <coreElectrons ctail="',l1,'" frcor="',l1,'" kcrel="',i0,'" coretail_lmax="',i0,'"/>')
   WRITE (fileNum,130) input%ctail,input%frcor,input%kcrel,input%coretail_lmax
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

!      <soc theta="0.00000" phi="0.00000" l_soc="F" spav="F" off="F" soc66="F"/>
196 197 198 199 200 201 202 203 204 205 206 207 208 209
150 FORMAT('      <soc theta="')
151 FORMAT('" phi="')
152 FORMAT('" l_soc="',l1,'" spav="',l1'"/>')
   WRITE (fileNum,150,advance="NO")
   DO i=1,SIZE(noco%theta)
      WRITE(fileNum,"(f0.8)",advance="NO") noco%theta(i)
      IF (i<size(noco%theta)) WRITE(fileNum,"(a1)",advance="NO") " "
   ENDDO
   WRITE (fileNum,151,advance="NO")
   DO i=1,SIZE(noco%phi)
      WRITE(fileNum,"(f0.8)",advance="NO") noco%phi(i)
      IF (i<size(noco%theta)) WRITE(fileNum,"(a1)",advance="NO") " "
   ENDDO
   WRITE (fileNum,152) noco%l_soc,noco%l_spav
210

211
   IF (l_nocoOpt.OR.l_explicit) THEN
212 213 214
160   FORMAT('      <nocoParams l_ss="',l1,'" l_mperp="',l1,'" l_constr="',l1,'" l_disp="',l1,&
           '" mix_b="',f0.8,'" thetaJ="',f0.8,'" nsh="',i0,'">')
      WRITE (fileNum,160) noco%l_ss, noco%l_mperp, noco%l_constr, Jij%l_disp, noco%mix_b, Jij%thetaJ, Jij%nsh
215
      162 FORMAT('         <qss>',f0.10,' ',f0.10,' ',f0.10,'</qss>')
216 217
      WRITE(fileNum,162) noco%qss(1), noco%qss(2), noco%qss(3)
      WRITE (fileNum,'(a)') '      </nocoParams>'
218 219 220 221
   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,'"/>')
222
      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
223 224 225
   END IF

!      <expertModes gw="0" pot8="F" eig66="F" lpr="0" isec1="99" secvar="F" />
226 227
   180 FORMAT('      <expertModes gw="',i0,'" pot8="',l1,'" isec1="',i0,'" secvar="',l1,'"/>')
   WRITE (fileNum,180) input%gw,obsolete%pot8,input%isec1,input%secvar
228 229 230

!      <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,'"/>')
231
   WRITE (fileNum,190) input%l_f,input%xa,input%thetad,input%epsdisp,input%epsforce
232 233 234 235 236 237 238 239 240 241 242

   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
243 244

!      <ldaU l_linMix="F" mixParam="0.05" spinf="1.0" />
Gregor Michalicek's avatar
Gregor Michalicek committed
245
   195 FORMAT('      <ldaU l_linMix="',l1,'" mixParam="',f0.6,'" spinf="',f0.6,'"/>')
246 247
   WRITE (fileNum,195) input%ldauLinMix,input%ldauMixParam,input%ldauSpinf

248 249
!      <bzIntegration valenceElectrons="8.00000" mode="hist" fermiSmearingEnergy="0.00100">
   200 FORMAT('      <bzIntegration valenceElectrons="',f0.8,'" mode="',a,'" fermiSmearingEnergy="',f0.8,'">')
250
   WRITE (fileNum,200) input%zelec,TRIM(ADJUSTL(bzIntMode)),input%tkb
251

Daniel Wortmann's avatar
Daniel Wortmann committed
252
   IF(kpts%specificationType.EQ.3) THEN
253
      sumWeight = 0.0
254
      DO i = 1, kpts%nkpt
Daniel Wortmann's avatar
Daniel Wortmann committed
255
         sumWeight = sumWeight + kpts%wtkpt(i)
256 257
      END DO
      205 FORMAT('         <kPointList posScale="',f0.8,'" weightScale="',f0.8,'" count="',i0,'">')
258
      WRITE (fileNum,205) kpts%posScale, sumWeight, kpts%nkpt
259 260
      DO i = 1, kpts%nkpt
         206 FORMAT('            <kPoint weight="',f12.6,'">',f12.6,' ',f12.6,' ',f12.6,'</kPoint>')
Daniel Wortmann's avatar
Daniel Wortmann committed
261
         WRITE (fileNum,206) kpts%wtkpt(i), kpts%bk(1,i), kpts%bk(2,i), kpts%bk(3,i)
262
      END DO
263
      WRITE (fileNum,'(a)')('         </kPointList>')
Daniel Wortmann's avatar
Daniel Wortmann committed
264
   ELSE IF(kpts%specificationType.EQ.1) THEN
265

266 267 268 269 270 271 272 273 274 275
      IF (kpts%numSpecialPoints.GE.2) THEN
         207 FORMAT('         <kPointCount count="',i0,'" gamma="',l1,'">')
         WRITE (fileNum,207) kpts%nkpt,kptGamma
         209 FORMAT('            <specialPoint name="',a,'">', f10.6,' ',f10.6,' ',f10.6,'</specialPoint>')
         DO i = 1, kpts%numSpecialPoints
            WRITE(fileNum,209) TRIM(ADJUSTL(kpts%specialPointNames(i))),&
                               kpts%specialPoints(1,i),kpts%specialPoints(2,i),kpts%specialPoints(3,i)
         END DO
         WRITE (fileNum,'(a)') '         </kPointCount>'
      ELSE
276
!            <kPointCount count="100" gamma="F"/>
277 278 279
         208 FORMAT('         <kPointCount count="',i0,'" gamma="',l1,'"/>')
         WRITE (fileNum,208) kpts%nkpt,kptGamma
      END IF
280

281
   ELSE IF (kpts%specificationType.EQ.2) THEN
282 283
!            <kPointMesh nx="10" ny="10" nz="10" gamma="F"/>
      210 FORMAT('         <kPointMesh nx="',i0,'" ny="',i0,'" nz="',i0,'" gamma="',l1,'"/>')
284
      WRITE (fileNum,210) div(1),div(2),div(3),kptGamma
285 286 287
   ELSE !(kpts%specificationType.EQ.4)
      212 FORMAT('         <kPointDensity denX="',f0.6,'" denY="',f0.6,'" denZ="',f0.6,'" gamma="',l1,'"/>')
      WRITE (fileNum,212) kpts%kPointDensity(1),kpts%kPointDensity(2),kpts%kPointDensity(3),kptGamma
288
   END IF
289
   WRITE (fileNum,'(a)') '      </bzIntegration>'
290 291 292

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

295 296
   WRITE (fileNum,'(a)') '   </calculationSetup>'
   WRITE (fileNum,'(a)') '   <cell>'
297

Daniel Wortmann's avatar
Daniel Wortmann committed
298
   IF(sym%symSpecType.EQ.3) THEN
299
      WRITE(fileNum,'(a)') '      <symmetryOperations>'
300
      DO i = 1, sym%nop
301
      WRITE(fileNum,'(a)') '         <symOp>'
302
      224 FORMAT('            <row-1>',i0,' ',i0,' ',i0,' ',f0.10,'</row-1>')
303
      WRITE(fileNum,224) sym%mrot(1,1,i), sym%mrot(1,2,i), sym%mrot(1,3,i), sym%tau(1,i)
304
      225 FORMAT('            <row-2>',i0,' ',i0,' ',i0,' ',f0.10,'</row-2>')
305
      WRITE(fileNum,225) sym%mrot(2,1,i), sym%mrot(2,2,i), sym%mrot(2,3,i), sym%tau(2,i)
306
      226 FORMAT('            <row-3>',i0,' ',i0,' ',i0,' ',f0.10,'</row-3>')
307 308
      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>'
309
      END DO
310
      WRITE(fileNum,'(a)') '      </symmetryOperations>'
Daniel Wortmann's avatar
Daniel Wortmann committed
311
   ELSE IF(sym%symSpecType.EQ.1) THEN
312
      228 FORMAT('      <symmetryFile filename="',a,'"/>')
313
      WRITE(fileNum,228) TRIM(ADJUSTL(symFilename))
Daniel Wortmann's avatar
Daniel Wortmann committed
314
   ELSE !(sym%symSpecType.EQ.2)
315 316
!      <symmetry spgrp="any" invs="T" zrfs="F"/>
      230 FORMAT('      <symmetry spgrp="',a,'" invs="',l1,'" zrfs="',l1,'"/>')
317
      WRITE (fileNum,230) TRIM(ADJUSTL(sym%namgrp)),sym%invs,sym%zrfs
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339

   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,'">')
340
      WRITE(fileNum,241) input%scaleCell, TRIM(ADJUSTL(cell%latnam)), vacuum%dvac, dtild
341
      IF (cell%latnam.EQ.'any') THEN
342
         WRITE (fileNum,'(a)') '         <bravaisMatrix>'
343
         255 FORMAT('            <row-1>',f0.10,' ',f0.10,' ',f0.10,'</row-1>')
344
         WRITE (fileNum,255) a1Temp(1),a1Temp(2),a1Temp(3)
345
         265 FORMAT('            <row-2>',f0.10,' ',f0.10,' ',f0.10,'</row-2>')
346
         WRITE (fileNum,265) a2Temp(1),a2Temp(2),a2Temp(3)
347
         275 FORMAT('            <row-3>',f0.10,' ',f0.10,' ',f0.10,'</row-3>')
348 349
         WRITE (fileNum,275) a3Temp(1),a3Temp(2),a3Temp(3)
         WRITE (fileNum,'(a)') '         </bravaisMatrix>'
350 351 352 353
      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
354 355
            256 FORMAT('         <a1 scale="',f0.10,'">',f0.10,'</a1>')
            WRITE (fileNum,256) input%scaleA1, a1Temp(1) / input%scaleA1
356 357
         END IF
         IF ((cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
358 359
            266 FORMAT('         <a2 scale="',f0.10,'">',f0.10,'</a2>')
            WRITE (fileNum,266) input%scaleA2, a2Temp(2) / input%scaleA2
360 361 362
         END IF

         IF (cell%latnam.EQ.'obl') THEN
363
            257 FORMAT('         <row-1>',f0.10,' ',f0.10,'</row-1>')
364
            WRITE (fileNum,257) a1Temp(1), a1Temp(2)
365
            267 FORMAT('         <row-2>',f0.10,' ',f0.10,'</row-2>')
366
            WRITE (fileNum,267) a2Temp(1), a2Temp(2)
367 368 369
         END IF
      END IF

370
      268 FORMAT('         <vacuumEnergyParameters vacuum="',i0,'" spinUp="',f0.8,'" spinDown="',f0.8,'"/>')
371 372 373 374
      DO i = 1, vacuum%nvac
         WRITE(fileNum,268) i, enpara%evac0(i,1), enpara%evac0(i,input%jspins)
      END DO

375
      WRITE (fileNum,'(a)') '      </filmLattice>'
376 377
   ELSE

378
      242 FORMAT('      <bulkLattice scale="',f0.10,'" latnam="',a,'">')
379
      WRITE (fileNum,242) input%scaleCell, TRIM(ADJUSTL(cell%latnam))
380 381 382

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

383
!         <bravaisMatrix>
384
         WRITE (fileNum,'(a)') '         <bravaisMatrix>'
385 386

!            <row-1>0.00000 5.13000 5.13000</row-1>
387
         250 FORMAT('            <row-1>',f0.10,' ',f0.10,' ',f0.10,'</row-1>')
388
         WRITE (fileNum,250) a1Temp(1),a1Temp(2),a1Temp(3)
389
!            <row-2>5.13000 0.00000 5.13000</row-2>
390
         260 FORMAT('            <row-2>',f0.10,' ',f0.10,' ',f0.10,'</row-2>')
391
         WRITE (fileNum,260) a2Temp(1),a2Temp(2),a2Temp(3)
392
!            <row-3>5.13000 5.13000 0.00000</row-3>
393
         270 FORMAT('            <row-3>',f0.10,' ',f0.10,' ',f0.10,'</row-3>')
394
         WRITE (fileNum,270) a3Temp(1),a3Temp(2),a3Temp(3)
395

396
         WRITE (fileNum,'(a)') '         </bravaisMatrix>'
397 398 399 400 401
      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
402 403
         252 FORMAT('         <a1 scale="',f0.10,'">',f0.10,'</a1>')
         WRITE (fileNum,252) input%scaleA1, a1Temp(1) / input%scaleA1
404 405

         IF ((cell%latnam.EQ.'c-r').OR.(cell%latnam.EQ.'p-r')) THEN
406 407
            262 FORMAT('         <a2 scale="',f0.10,'">',f0.10,'</a2>')
            WRITE (fileNum,262) input%scaleA2, a2Temp(2) / input%scaleA2
408 409
         END IF

410 411
         272 FORMAT('         <c scale="',f0.10,'">',f0.10,'</c>')
         WRITE (fileNum,272) input%scaleC, a3Temp(3) / input%scaleC
412 413 414
      END IF

      IF (cell%latnam.EQ.'obl') THEN
415
         254 FORMAT('         <row-1>',f0.10,' ',f0.10,'</row-1>')
416
         WRITE (fileNum,254) a1Temp(1), a1Temp(2)
417

418
         264 FORMAT('         <row-2>',f0.10,' ',f0.10,'</row-2>')
419
         WRITE (fileNum,264) a2Temp(1), a2Temp(2)
420

421 422
         274 FORMAT('         <c scale="',f0.10,'">',f0.10,'</c>')
         WRITE (fileNum,274) input%scaleC, a3Temp(3) / input%scaleC
423 424
      END IF

425
      WRITE (fileNum,'(a)') '      </bulkLattice>'
426
   END IF
427
   WRITE (fileNum,'(a)') '   </cell>'
428 429 430

!   <xcFunctional name="pbe" relativisticCorrections="F">
   280 FORMAT('   <xcFunctional name="',a,'" relativisticCorrections="',l1,'"/>')
431
   WRITE (fileNum,280) TRIM(namex), l_relcor
432 433


Daniel Wortmann's avatar
Daniel Wortmann committed
434 435 436 437 438 439
   uIndices = -1
   DO i_u = 1, atoms%n_u
      IF(uIndices(1,atoms%lda_u(i_u)%atomType).EQ.-1) uIndices(1,atoms%lda_u(i_u)%atomType) = i_u
      uIndices(2,atoms%lda_u(i_u)%atomType) = i_u
   END DO

440 441
   WRITE (fileNum,'(a)') '   <atomSpecies>'
   DO iSpecies=1, numSpecies
442 443 444 445 446 447
      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,'">')
448
      speciesName = TRIM(ADJUSTL(atoms%speciesName(iSpecies)))
449
      WRITE (fileNum,300) TRIM(ADJUSTL(speciesName)),TRIM(ADJUSTL(noel(iAtomType))),atoms%nz(iAtomType),atoms%ncst(iAtomType),atoms%bmu(iAtomType),atoms%nflip(iAtomType)
450 451 452

!         <mtSphere radius="2.160000" gridPoints="521" logIncrement="0.022000"/>
      310 FORMAT('         <mtSphere radius="',f0.8,'" gridPoints="',i0,'" logIncrement="',f0.8,'"/>')
453
      WRITE (fileNum,310) atoms%rmt(iAtomType),atoms%jri(iAtomType),atoms%dx(iAtomType)
454 455 456

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

459
      IF (ALL((enpara%el0(0:3,iAtomType,1)-INT(enpara%el0(0:3,iAtomType,1))).LE.0.00000001)) THEN
460
!         <energyParameters s="3" p="3" d="3" f="4"/>
461
         321 FORMAT('         <energyParameters s="',i0,'" p="',i0,'" d="',i0,'" f="',i0,'"/>')
462 463
         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))
464 465
      END IF

466
      IF(ANY(xmlElectronStates(:,iAtomType).NE.noState_const)) THEN
467 468 469
         endCoreStates = 1
         startCoreStates = 1
         coreStatesString = ''
470
         valenceStatesString = ''
471
         DO i = 1, 29
472
            IF (xmlElectronStates(i,iAtomType).EQ.coreState_const) endCoreStates = i
473 474
         END DO
         IF ((endCoreStates.GE.24).AND.&
475
&            (ALL(xmlPrintCoreStates(1:24,iAtomType).EQV..FALSE.)).AND.&
476
&            (ALL(xmlElectronStates(1:24,iAtomType).EQ.coreState_const)) ) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
477
            coreStatesString = nobleGasConfigList_const(6)
478 479
            startCoreStates = 25
         ELSE IF ((endCoreStates.GE.17).AND.&
480
&                 (ALL(xmlPrintCoreStates(1:17,iAtomType).EQV..FALSE.)).AND.&
481
&                 (ALL(xmlElectronStates(1:17,iAtomType).EQ.coreState_const))) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
482
            coreStatesString = nobleGasConfigList_const(5)
483 484
            startCoreStates = 18
         ELSE IF ((endCoreStates.GE.12).AND.&
485
&                 (ALL(xmlPrintCoreStates(1:12,iAtomType).EQV..FALSE.)).AND.&
486
&                 (ALL(xmlElectronStates(1:12,iAtomType).EQ.coreState_const))) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
487
            coreStatesString = nobleGasConfigList_const(4)
488 489
            startCoreStates = 13
         ELSE IF ((endCoreStates.GE.7).AND.&
490
&                 (ALL(xmlPrintCoreStates(1:7,iAtomType).EQV..FALSE.)).AND.&
491
&                 (ALL(xmlElectronStates(1:7,iAtomType).EQ.coreState_const))) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
492
            coreStatesString = nobleGasConfigList_const(3)
493 494
            startCoreStates = 8
         ELSE IF ((endCoreStates.GE.4).AND.&
495
&                 (ALL(xmlPrintCoreStates(1:4,iAtomType).EQV..FALSE.)).AND.&
496
&                 (ALL(xmlElectronStates(1:4,iAtomType).EQ.coreState_const))) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
497
            coreStatesString = nobleGasConfigList_const(2)
498 499
            startCoreStates = 5
         ELSE IF ((endCoreStates.GE.1).AND.&
500
&                 (ALL(xmlPrintCoreStates(1:1,iAtomType).EQV..FALSE.)).AND.&
501
&                 (ALL(xmlElectronStates(1:1,iAtomType).EQ.coreState_const))) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
502
            coreStatesString = nobleGasConfigList_const(1)
503 504 505
            startCoreStates = 2
         END IF
         DO i = startCoreStates, endCoreStates
506
            IF(xmlElectronStates(i,iAtomType).EQ.coreState_const) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
507
               coreStatesString = TRIM(ADJUSTL(coreStatesString)) // ' ' // coreStateList_const(i)
508 509
            END IF
         END DO
510 511
         DO i = 1, 29
            IF(xmlElectronStates(i,iAtomType).EQ.valenceState_const) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
512
               valenceStatesString = TRIM(ADJUSTL(valenceStatesString)) // ' ' // coreStateList_const(i)
513 514
            END IF
         END DO
515
         WRITE (fileNum,'(a)') '         <electronConfig>'
516
!         <coreConfig>[He] (2s1/2) (2p1/2) (2p3/2)</coreConfig>
517
         322 FORMAT('            <coreConfig>',a,'</coreConfig>')
518
         WRITE(fileNum,322) TRIM(ADJUSTL(coreStatesString))
519
         323 FORMAT('            <valenceConfig>',a,'</valenceConfig>')
520
         WRITE(fileNum,323) TRIM(ADJUSTL(valenceStatesString))
521 522
         DO i = startCoreStates, 29
            IF ((xmlElectronStates(i,iAtomType).NE.noState_const).AND.(xmlPrintCoreStates(i,iAtomType))) THEN
523
!         <coreStateOccupation state="(2s1/2)" spinUp="1.0" spinDown="1.0"/>
524
               325 FORMAT('            <stateOccupation state="',a,'" spinUp="',f0.8,'" spinDown="',f0.8,'"/>')
Daniel Wortmann's avatar
Daniel Wortmann committed
525
               WRITE(fileNum,325) coreStateList_const(i), xmlCoreOccs(1,i,iAtomType), xmlCoreOccs(2,i,iAtomType)
526 527
            END IF
         END DO
528
         WRITE (fileNum,'(a)') '         </electronConfig>'
529 530
      END IF

Daniel Wortmann's avatar
Daniel Wortmann committed
531 532 533 534 535 536 537 538
      IF (uIndices(1,iAtomType).NE.-1) THEN
!         <ldaU l="2" U="5.5" J="0.9" l_amf="F"/>
         DO i_u = uIndices(1,iAtomType), uIndices(2,iAtomType)
            326 FORMAT('         <ldaU l="',i0,'" U="',f0.5,'" J="',f0.5,'" l_amf="',l1,'"/>')
            WRITE (fileNum,326) 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
         END DO
      END IF

539 540 541
      DO ilo = 1, atoms%nlo(iAtomType)
!         <lo type="HELO" l="0" n="4"/>
         l = atoms%llo(ilo,iAtomType)
542 543 544 545
         n = INT(enpara%ello0(ilo,iAtomType,1))
         loType = 'SCLO'
         IF(n.LT.0) THEN
            loType = 'HELO'
546
         END IF
547 548 549
         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)
550 551
      END DO

552
      WRITE (fileNum,'(a)') '      </species>'
553
   END DO
554 555
   WRITE (fileNum,'(a)') '   </atomSpecies>'
   WRITE (fileNum,'(a)') '   <atomGroups>'
556 557 558 559 560
   na = 0
   DO iAtomType=1, atoms%ntype
      iSpecies = atomTypeSpecies(iAtomType)
!      <atomGroup species="Si-1">
      330 FORMAT('      <atomGroup species="',a,'">')
561
      speciesName = TRIM(ADJUSTL(atoms%speciesName(iSpecies)))
562
      WRITE (fileNum,330) TRIM(ADJUSTL(speciesName))
563 564 565 566 567

      DO ieq=1,atoms%neq(iAtomType)
         na = na + 1
         tempTaual(1,na) = atoms%taual(1,na)
         tempTaual(2,na) = atoms%taual(2,na)
568 569
         tempTaual(3,na) = atoms%taual(3,na)
         scpos = 1.0
570
         DO i = 2,40
571 572 573 574
            rest = ABS(i*tempTaual(1,na) - NINT(i*tempTaual(1,na)))
            IF ((scpos(1).EQ.1.0).AND.(rest.LT.(i*0.000001))) scpos(1) = real(i)
            rest = ABS(i*tempTaual(2,na) - NINT(i*tempTaual(2,na)))
            IF ((scpos(2).EQ.1.0).AND.(rest.LT.(i*0.000001))) scpos(2) = real(i)
575
            IF (.not.input%film) THEN
576 577
               rest = ABS(i*tempTaual(3,na) - NINT(i*tempTaual(3,na)) )
               IF ((scpos(3).EQ.1.0).AND.(rest.LT.(i*0.000001))) scpos(3) = real(i)
578
            END IF
579
         END DO
580
         DO i = 1,2
581 582 583
            tempTaual(i,na) = tempTaual(i,na)*scpos(i)
         END DO
         IF (.not.input%film) tempTaual(3,na) = tempTaual(3,na)*scpos(3)
584
         IF (input%film) THEN
585
            tempTaual(3,na) = dtild*tempTaual(3,na)/input%scaleCell
586 587 588 589 590 591 592 593 594 595 596
         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>
597
            340 FORMAT('         <filmPos label="',a20,'">',a,' ',a,' ',a,'</filmPos>')
598 599 600 601 602 603 604 605 606
            posString(:) = ''
            DO i = 1, 2
               IF((scpos(i).NE.1.0).AND.(tempTaual(i,na).NE.0.0)) THEN
                  WRITE(posString(i),'(f0.3,a1,f0.3)') tempTaual(i,na), '/', scpos(i)
               ELSE
                  WRITE(posString(i),'(f0.10)') tempTaual(i,na)
               END IF
            END DO
            WRITE(posString(3),'(f0.10)') tempTaual(3,na)
607 608
            WRITE (fileNum,340) TRIM(ADJUSTL(atoms%label(na))), &
                                TRIM(ADJUSTL(posString(1))),TRIM(ADJUSTL(posString(2))),TRIM(ADJUSTL(posString(3)))
609 610
         ELSE
!         <relPos> x/myConstant  y/myConstant  z/myConstant</relPos>
611
            350 FORMAT('         <relPos label="',a20,'">',a,' ',a,' ',a,'</relPos>')
612 613 614 615 616 617 618 619
            posString(:) = ''
            DO i = 1, 3
               IF((scpos(i).NE.1.0).AND.(tempTaual(i,na).NE.0.0)) THEN
                  WRITE(posString(i),'(f0.3,a1,f0.3)') tempTaual(i,na), '/', scpos(i)
               ELSE
                  WRITE(posString(i),'(f0.10)') tempTaual(i,na)
               END IF
            END DO
620 621
            WRITE (fileNum,350) TRIM(ADJUSTL(atoms%label(na))), &
                                TRIM(ADJUSTL(posString(1))),TRIM(ADJUSTL(posString(2))),TRIM(ADJUSTL(posString(3)))
622 623 624 625
         END IF
      END DO
!         <force calculate="F" relaxX="T" relaxY="T" relaxZ="T"/>
      360 FORMAT('         <force calculate="',l1,'" relaxXYZ="',3l1,'"/>')
626
      WRITE (fileNum,360) atoms%l_geo(iAtomType),atoms%relax(1,iAtomType),atoms%relax(2,iAtomType),atoms%relax(3,iAtomType)
627

628
      IF(l_nocoOpt.OR.l_explicit) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
629 630
         362 FORMAT('         <nocoParams l_relax="',l1,'" l_magn="',l1,'" M="',f0.8,'" alpha="',f0.8,'" beta="',&
                    f0.8,'" b_cons_x="',f0.8,'" b_cons_y="',f0.8,'"/>')
631 632 633 634 635
         WRITE(fileNum,362) noco%l_relax(iAtomType), Jij%l_magn(iAtomType), Jij%M(iAtomType), noco%alphInit(iAtomType),&
                            noco%beta(iAtomType),noco%b_con(1,iAtomType),noco%b_con(2,iAtomType)
      END IF


636
      WRITE (fileNum,'(a)') '      </atomGroup>'
637
   END DO
638
   WRITE (fileNum,'(a)') '   </atomGroups>'
639 640

   368 FORMAT('   <output dos="',l1,'" band="',l1,'" vacdos="',l1,'" slice="',l1,'">')
641
   WRITE (fileNum,368) banddos%dos,band,banddos%vacdos,sliceplot%slice
642 643 644

!      <checks vchk="F" cdinf="F" disp="F"/>
   370 FORMAT('      <checks vchk="',l1,'" cdinf="',l1,'" disp="',l1,'"/>')
645
   WRITE (fileNum,370) input%vchk,input%cdinf,obsolete%disp
646 647 648

!      <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,'"/>')
649
   WRITE (fileNum,380) banddos%ndir,banddos%e2_dos,banddos%e1_dos,banddos%sig_dos
650 651

!      <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"/>
Daniel Wortmann's avatar
Daniel Wortmann committed
652
   390 FORMAT('      <vacuumDOS layers="',i0,'" integ="',l1,'" star="',l1,'" nstars="',i0,'" locx1="',f0.5,'" locy1="',f0.5,'" locx2="',f0.5,'" locy2="',f0.5,'" nstm="',i0,'" tworkf="',f0.5,'"/>')
653
   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
654 655 656

!      <plotting iplot="F" score="F" plplot="F"/>
   400 FORMAT('      <plotting iplot="',l1,'" score="',l1,'" plplot="',l1,'"/>')
657
   WRITE (fileNum,400) sliceplot%iplot,input%score,sliceplot%plpot
658 659 660

!      <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,'"/>')
661
   WRITE (fileNum,410) sliceplot%kk,sliceplot%e1s,sliceplot%e2s,sliceplot%nnne,input%pallst
662 663

!      <specialOutput form66="F" eonly="F" bmt="F"/>
664 665
   420 FORMAT('      <specialOutput eonly="',l1,'" bmt="',l1,'"/>')
   WRITE (fileNum,420) input%eonly,input%l_bmt
666

667
   WRITE (fileNum,'(a)') '   </output>'
668 669 670
   IF(l_outFile) THEN
      CALL closeXMLElement('inputData')
   ELSE
671 672 673
      WRITE (fileNum,'(a)') '</fleurInput>'
      CLOSE (fileNum)
   END IF
674 675 676

END SUBROUTINE w_inpXML
END MODULE m_winpXML