w_inpXML.f90 22.2 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
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
!!!
17 18 19
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
CONTAINS
SUBROUTINE w_inpXML(&
Daniel Wortmann's avatar
Daniel Wortmann committed
20 21
     atoms,vacuum,input,stars,sliceplot,forcetheo,banddos,&
     cell,sym,xcpot,noco,oneD,hybrid,kpts,enpara,&
22
     l_explicitIn,l_includeIn,filename)
23

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

   use m_types_input
   use m_types_sym
   use m_types_stars 
   use m_types_atoms
   use m_types_vacuum
   use m_types_kpts
   use m_types_oneD
   use m_types_hybrid
   use m_types_cell
   use m_types_banddos
   use m_types_sliceplot
   USE m_types_xcpot
   USE m_types_xcpot_inbuild_nofunction
   USE m_types_noco
   use m_types_enpara
   USE m_types_forcetheo 
  
42
   USE m_juDFT
43
   USE m_constants
44
   USE m_xmlOutput
45 46

   IMPLICIT NONE
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

! 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_kpts),INTENT(IN)     :: kpts
   TYPE(t_oneD),INTENT(IN)     :: oneD
   TYPE(t_hybrid),INTENT(IN)   :: hybrid
   TYPE(t_cell),INTENT(IN)     :: cell
   TYPE(t_banddos),INTENT(IN)  :: banddos
   TYPE(t_sliceplot),INTENT(IN):: sliceplot
   CLASS(t_xcpot),INTENT(IN)   :: xcpot
62
   TYPE(t_noco),INTENT(IN)     :: noco
63
   TYPE(t_enpara),INTENT(IN)   :: enpara
64
   CLASS(t_forcetheo),INTENT(IN):: forcetheo !nothing is done here so far....
65
   LOGICAL, INTENT (IN)        :: l_explicitIn,l_includeIn(4)
Daniel Wortmann's avatar
Daniel Wortmann committed
66
   CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: filename
67 68


69
   INTEGER          :: iSpecies,fileNum
70
   CHARACTER(len=8) :: name(10)
Daniel Wortmann's avatar
Daniel Wortmann committed
71
   INTEGER          :: numSpecies
Daniel Wortmann's avatar
Daniel Wortmann committed
72
   INTEGER          :: speciesRepAtomType(atoms%ntype)
Daniel Wortmann's avatar
Daniel Wortmann committed
73 74 75 76 77
   CHARACTER(len=20):: speciesNames(atoms%ntype)
   LOGICAL          :: known_species
   
   
 
78 79
!+lda+u
   REAL    u,j
Daniel Wortmann's avatar
Daniel Wortmann committed
80
   INTEGER l, i_u
81 82 83 84 85 86 87 88 89 90 91 92 93 94
   INTEGER uIndices(2,atoms%ntype)
   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
95
   REAL     :: zc, sumWeight,occ(2)
96 97 98
   INTEGER  ::nw,idsprs, n1, n2
   INTEGER ieq,i,k,na,n,ilo
   REAL s3,ah,a,hs2,rest
99
   LOGICAL l_hyb,ldum
100 101 102 103 104 105
   INTEGER :: ierr
! ..
!...  Local Arrays
   CHARACTER :: helpchar(atoms%ntype)
   CHARACTER(len=  4) :: chntype
   CHARACTER(len= 41) :: chform
106
   CHARACTER(len=100) :: line
107 108 109 110

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

113
   CHARACTER(len=20) :: speciesName
114 115 116 117
   CHARACTER(len=150) :: format
   CHARACTER(len=20) :: mixingScheme
   CHARACTER(len=10) :: loType
   CHARACTER(len=10) :: bzIntMode
118
   LOGICAL ::   l_explicit, l_nocoOpt,l_include(4)
119
   INTEGER :: iAtomType, startCoreStates, endCoreStates
120
   CHARACTER(len=100) :: posString(3)
121
   CHARACTER(len=7) :: str
122
   REAL :: tempTaual(3,atoms%nat), scpos(3)
123 124
   REAL :: amatTemp(3,3), bmatTemp(3,3)

Daniel Wortmann's avatar
Daniel Wortmann committed
125 126
   l_include=l_includeIn.or..not.present(filename)
   l_explicit = l_explicitIn.OR..not.present(filename)
127
   l_nocoOpt = noco%l_noco.OR.juDFT_was_argument("-noco")
128

129 130
   band = .false.
   nw=1
131
  
132 133


Daniel Wortmann's avatar
Daniel Wortmann committed
134
   IF(PRESENT(filename)) THEN
135
      filenum=98
Daniel Wortmann's avatar
Daniel Wortmann committed
136
      OPEN (fileNum,file=TRIM(ADJUSTL(filename)),form='formatted',status='replace')
137
      WRITE (fileNum,'(a)') '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
138
      WRITE (fileNum,'(a)') '<fleurInput fleurInputVersion="0.29">'
Daniel Wortmann's avatar
Daniel Wortmann committed
139
   ELSE
140
      fileNum = getXMLOutputUnitNumber()
Daniel Wortmann's avatar
Daniel Wortmann committed
141
      CALL openXMLElementNoAttributes('inputData')
142
   END IF
143

144 145 146 147
   WRITE (fileNum,'(a)') '   <comment>'
   WRITE (fileNum,'(a6,10a8)') '      ',input%comment
   WRITE (fileNum,'(a)') '   </comment>'
   
148
   WRITE (fileNum,'(a)') '   <calculationSetup>'
149 150 151

!      <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,'"/>')
152
   WRITE (fileNum,110) input%rkmax,stars%gmaxInit,xcpot%gmaxxc,input%gw_neigd
153

154 155
!      <scfLoop itmax="9" maxIterBroyd="99" imix="Anderson" alpha="0.05" preconditioning_param="0.0" spinf="2.00"/>
   120 FORMAT('      <scfLoop itmax="',i0,'" minDistance="',f0.8,'" maxIterBroyd="',i0,'" imix="',a,'" alpha="',f0.8,'" preconditioning_param="',f3.1,'" spinf="',f0.8,'"/>')
156 157 158 159 160 161 162 163 164 165 166 167
   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
168
   WRITE (fileNum,120) input%itmax,input%minDistance,input%maxiter,TRIM(mixingScheme),input%alpha,input%preconditioning_param,input%spinf
169 170

!      <coreElectrons ctail="T" frcor="F" kcrel="0"/>
171 172
   130 FORMAT('      <coreElectrons ctail="',l1,'" frcor="',l1,'" kcrel="',i0,'" coretail_lmax="',i0,'"/>')
   WRITE (fileNum,130) input%ctail,input%frcor,input%kcrel,input%coretail_lmax
173 174

!      <magnetism jspins="1" l_noco="F" l_J="F" swsp="F" lflip="F"/>
175 176
   140 FORMAT('      <magnetism jspins="',i0,'" l_noco="',l1,'" swsp="',l1,'" lflip="',l1,'"/>')
   WRITE (fileNum,140) input%jspins,noco%l_noco,input%swsp,input%lflip
177

178 179 180 181
   !      <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,'"/>')
   WRITE (fileNum,150) noco%theta,noco%phi,noco%l_soc,noco%l_spav

182 183 184 185
   IF (l_explicit.OR.hybrid%l_hybrid) THEN
      155 FORMAT('      <prodBasis gcutm="',f0.8,'" tolerance="',f0.8,'" ewaldlambda="',i0,'" lexp="',i0,'" bands="',i0,'"/>')
      WRITE (fileNum,155) hybrid%gcutm1,hybrid%tolerance1,hybrid%ewaldlambda,hybrid%lexp,hybrid%bands1
   END IF
186

187
   IF (l_nocoOpt.OR.l_explicit) THEN
188 189 190
160   FORMAT('      <nocoParams l_ss="',l1,'" l_mperp="',l1,'" l_constr="',l1,&
           '" mix_b="',f0.8,'">')
      WRITE (fileNum,160) noco%l_ss, noco%l_mperp, noco%l_constr, noco%mix_b
191
      162 FORMAT('         <qss>',f0.10,' ',f0.10,' ',f0.10,'</qss>')
192 193
      WRITE(fileNum,162) noco%qss(1), noco%qss(2), noco%qss(3)
      WRITE (fileNum,'(a)') '      </nocoParams>'
194 195 196 197
   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,'"/>')
198
      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
199 200
   END IF

Gregor Michalicek's avatar
Gregor Michalicek committed
201 202 203
!      <expertModes gw="0"  eig66="F" lpr="0" secvar="F" />
   180 FORMAT('      <expertModes gw="',i0,'" secvar="',l1,'"/>')
   WRITE (fileNum,180) input%gw,input%secvar
204 205

!      <geometryOptimization l_f="F" xa="2.00000" thetad="330.00000" epsdisp="0.00001" epsforce="0.00001"/>
206 207
   190 FORMAT('      <geometryOptimization l_f="',l1,'" forcealpha="',f0.8,'" forcemix="',i0,'" epsdisp="',f0.8,'" epsforce="',f0.8,'"/>')
   WRITE (fileNum,190) input%l_f,input%forcealpha,input%forcemix,input%epsdisp,input%epsforce
208 209 210 211 212 213 214 215 216 217 218

   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
219 220

!      <ldaU l_linMix="F" mixParam="0.05" spinf="1.0" />
221
   195 FORMAT('      <ldaU l_linMix="',l1,'" mixParam="',f0.6,'" spinf="',f0.6,'"/>')
222 223
   WRITE (fileNum,195) input%ldauLinMix,input%ldauMixParam,input%ldauSpinf

224 225
!      <bzIntegration valenceElectrons="8.00000" mode="hist" fermiSmearingEnergy="0.00100">
   200 FORMAT('      <bzIntegration valenceElectrons="',f0.8,'" mode="',a,'" fermiSmearingEnergy="',f0.8,'">')
226
   WRITE (fileNum,200) input%zelec,TRIM(ADJUSTL(bzIntMode)),input%tkb
227

228
   if (l_include(1)) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
229
      call kpts%print_xml(fileNum)
230
   else
Daniel Wortmann's avatar
Daniel Wortmann committed
231 232
      WRITE (fileNum,'(a)')'         <!-- k-points included here -->'
      WRITE (fileNum,'(a)')'         <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="kpts.xml"> </xi:include>'
233
   end if
234
   WRITE (fileNum,'(a)') '      </bzIntegration>'
235 236 237

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

240 241
   WRITE (fileNum,'(a)') '   </calculationSetup>'
   WRITE (fileNum,'(a)') '   <cell>'
242
   if (l_include(2)) THEN
243 244
      call sym%print_xml(fileNum)
   else
Daniel Wortmann's avatar
Daniel Wortmann committed
245 246
      WRITE (fileNum,'(a)')'      <!-- symmetry operations included here -->'
      WRITE (fileNum,'(a)')'      <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sym.xml"> </xi:include>'
247
   end if
248 249 250 251 252 253 254
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Note: Different options for the cell definition!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   IF (input%film) THEN
!      <xsd:attribute name="dVac" type="xsd:double" use="required"/>
!      <xsd:attribute name="dTilda" type="xsd:double" use="required"/>
!      <filmLattice ...>
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
      241 FORMAT('      <filmLattice scale="',f0.8,'" dVac="',f0.8,'" dTilda="',f0.8,'">')
      WRITE(fileNum,241) 1.0,  vacuum%dvac, cell%amat(3,3)
   ELSE
242   FORMAT('      <bulkLattice scale="',f0.10,'">')
      WRITE (fileNum,242) 1.0
   ENDIF
   !         <bravaisMatrix>
   WRITE (fileNum,'(a)') '         <bravaisMatrix>'
   !            <row-1>0.00000 5.13000 5.13000</row-1>
250 FORMAT('            <row-1>',f0.10,' ',f0.10,' ',f0.10,'</row-1>')
   WRITE (fileNum,250) cell%amat(:,1)
   !            <row-2>5.13000 0.00000 5.13000</row-2>
260 FORMAT('            <row-2>',f0.10,' ',f0.10,' ',f0.10,'</row-2>')
   WRITE (fileNum,260) cell%amat(:,2)
   !            <row-3>5.13000 5.13000 0.00000</row-3>
270 FORMAT('            <row-3>',f0.10,' ',f0.10,' ',f0.10,'</row-3>')
   WRITE (fileNum,270)  cell%amat(:,3)
   WRITE (fileNum,'(a)') '         </bravaisMatrix>'
      
   IF (input%film) THEN
268 FORMAT('         <vacuumEnergyParameters vacuum="',i0,'" spinUp="',f0.8,'" spinDown="',f0.8,'"/>')
276 277 278 279
      DO i = 1, vacuum%nvac
         WRITE(fileNum,268) i, enpara%evac0(i,1), enpara%evac0(i,input%jspins)
      END DO

280
      WRITE (fileNum,'(a)') '      </filmLattice>'
281
   ELSE
282
      WRITE (fileNum,'(a)') '      </bulkLattice>'
283
   END IF
284
   WRITE (fileNum,'(a)') '   </cell>'
285

286 287 288 289 290 291
   SELECT TYPE(xcpot)
   CLASS IS (t_xcpot_inbuild_nf)
      !   <xcFunctional name="pbe" relativisticCorrections="F">
      280 FORMAT('   <xcFunctional name="',a,'" relativisticCorrections="',l1,'"/>')
      WRITE (fileNum,280) xcpot%get_name(),xcpot%relativistic_correction()
   END SELECT
292

Daniel Wortmann's avatar
Daniel Wortmann committed
293 294 295 296 297 298
   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

Daniel Wortmann's avatar
Daniel Wortmann committed
299 300 301 302
   !Build list of species
   speciesNames=''
   numSpecies=0
   DO n=1,atoms%ntype
Daniel Wortmann's avatar
Daniel Wortmann committed
303
      known_species=ANY(atoms%speciesname(n)==speciesNames(:numSpecies))
Daniel Wortmann's avatar
Daniel Wortmann committed
304 305 306 307 308 309
      if (.not.known_species) THEN
         numSpecies=numSpecies+1
         speciesNames(numSpecies)=atoms%speciesname(n)
         speciesRepAtomType(numSpecies)=n
      end if
   enddo
310

311
   if (.not.l_include(3)) then
312 313 314 315 316 317
      open(99,file='species.xml')
      WRITE (fileNum,'(a)')'      <!-- species included here -->'
      WRITE (fileNum,'(a)')'      <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="species.xml"> </xi:include>'
      fileNum=99
   endif

318 319
   WRITE (fileNum,'(a)') '   <atomSpecies>'
   DO iSpecies=1, numSpecies
320 321 322 323 324
      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">
Daniel Wortmann's avatar
Daniel Wortmann committed
325
      300 FORMAT('      <species name="',a,'" element="',a,'" atomicNumber="',i0,'" flipSpin="',l1,'">')
326
      speciesName = TRIM(ADJUSTL(atoms%speciesName(iSpecies)))
Daniel Wortmann's avatar
Daniel Wortmann committed
327
      WRITE (fileNum,300) TRIM(ADJUSTL(speciesName)),TRIM(ADJUSTL(namat_const(atoms%nz(iAtomType)))),atoms%nz(iAtomType),atoms%nflip(iAtomType)
328 329 330

!         <mtSphere radius="2.160000" gridPoints="521" logIncrement="0.022000"/>
      310 FORMAT('         <mtSphere radius="',f0.8,'" gridPoints="',i0,'" logIncrement="',f0.8,'"/>')
331
      WRITE (fileNum,310) atoms%rmt(iAtomType),atoms%jri(iAtomType),atoms%dx(iAtomType)
332 333 334

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

Daniel Wortmann's avatar
Daniel Wortmann committed
337
      IF (ALL(enpara%qn_el(0:3,iAtomType,1).ne.0)) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
338
!!         <energyParameters s="3" p="3" d="3" f="4"/>
Daniel Wortmann's avatar
Daniel Wortmann committed
339 340 341
         321 FORMAT('         <energyParameters s="',i0,'" p="',i0,'" d="',i0,'" f="',i0,'"/>')
         WRITE (fileNum,321) enpara%qn_el(0:3,iAtomType,1)
      END IF
342

343 344 345 346 347 348 349
      IF(l_explicit.OR.hybrid%l_hybrid) THEN
         315 FORMAT('         <prodBasis lcutm="',i0,'" lcutwf="',i0,'" select="',a,'"/>')
         line = ''
         WRITE(line,'(i0,1x,i0,1x,i0,1x,i0)') hybrid%select1(1:4,iAtomType)
         WRITE (fileNum,315) hybrid%lcutm1(iAtomType), hybrid%lcutwf(iAtomType), TRIM(ADJUSTL(line))
      END IF

350

351
         WRITE (fileNum,'(a)') '         <electronConfig>'
352
!         <coreConfig>[He] (2s1/2) (2p1/2) (2p3/2)</coreConfig>
353
         322 FORMAT('            <coreConfig>',a,'</coreConfig>')
354 355 356 357 358 359 360 361 362 363 364 365
         WRITE(fileNum,322) TRIM(ADJUSTL(atoms%econf(iAtomType)%coreconfig))
323      FORMAT('            <valenceConfig>',a,'</valenceConfig>')
         IF (len_TRIM(atoms%econf(iAtomType)%valenceconfig)>1) THEN
            WRITE(fileNum,323) TRIM(ADJUSTL(atoms%econf(iAtomType)%valenceconfig))
         END IF
         DO i =1, MERGE(atoms%econf(iAtomType)%num_states,atoms%econf(iAtomType)%num_core_states,(len_TRIM(atoms%econf(iAtomType)%valenceconfig)>1))
            occ=atoms%econf(iAtomType)%occupation(i,:)
            IF (ABS(occ(1)-occ(2))>1E-5.OR.ABS(occ(1)-ABS(atoms%econf(iAtomType)%kappa(i)))>1E-5) THEN
               !State not fully occupied
325            FORMAT('            <stateOccupation state="',a,'" spinUp="',f0.8,'" spinDown="',f0.8,'"/>')
               str=atoms%econf(iAtomType)%get_state_string(i)
               WRITE(fileNum,325) str, occ(1),occ(2)
366 367
            END IF
         END DO
368
         WRITE (fileNum,'(a)') '         </electronConfig>'
369

Daniel Wortmann's avatar
Daniel Wortmann committed
370 371 372 373 374 375 376 377
      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

378 379
      DO ilo = 1, atoms%nlo(iAtomType)
!         <lo type="HELO" l="0" n="4"/>
Daniel Wortmann's avatar
Daniel Wortmann committed
380
         l = atoms%llo(ilo,iAtomType)       
381
         n = enpara%qn_ello(ilo,iAtomType,1)
382 383 384
         loType = 'SCLO'
         IF(n.LT.0) THEN
            loType = 'HELO'
385
         END IF
386 387 388
         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)
389 390
      END DO

391
      WRITE (fileNum,'(a)') '      </species>'
392
   END DO
393
   WRITE (fileNum,'(a)') '   </atomSpecies>'
394

395
   if (.not.l_include(3)) then
396 397 398 399
      close(99)
      fileNum=98
   endif

400
   if (.not.l_include(4)) then
401 402 403 404 405 406
      open(99,file='atoms.xml')
      WRITE (fileNum,'(a)')'      <!-- atoms group included here -->'
      WRITE (fileNum,'(a)')'      <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="atoms.xml"> </xi:include>'
      fileNum=98
   endif

407
   WRITE (fileNum,'(a)') '   <atomGroups>'
408 409 410 411
   na = 0
   DO iAtomType=1, atoms%ntype
!      <atomGroup species="Si-1">
      330 FORMAT('      <atomGroup species="',a,'">')
Daniel Wortmann's avatar
Daniel Wortmann committed
412
      speciesName = TRIM(ADJUSTL(atoms%speciesName(iAtomType)))
413
      WRITE (fileNum,330) TRIM(ADJUSTL(speciesName))
414 415 416 417 418

      DO ieq=1,atoms%neq(iAtomType)
         na = na + 1
         tempTaual(1,na) = atoms%taual(1,na)
         tempTaual(2,na) = atoms%taual(2,na)
419 420
         tempTaual(3,na) = atoms%taual(3,na)
         scpos = 1.0
421
         DO i = 2,40
422 423 424 425
            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)
426
            IF (.not.input%film) THEN
427 428
               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)
429
            END IF
430
         END DO
431
         DO i = 1,2
432 433 434
            tempTaual(i,na) = tempTaual(i,na)*scpos(i)
         END DO
         IF (.not.input%film) tempTaual(3,na) = tempTaual(3,na)*scpos(3)
435
         IF (input%film) THEN
436
            tempTaual(3,na) = cell%amat(3,3)*tempTaual(3,na)/input%scaleCell
437
         END IF
438 439
!+odim in 1D case all the coordinates are given in cartesian YM
         IF (oneD%odd%d1) THEN
440 441
            !tempTaual(1,na) = tempTaual(1,na)*a1(1)
            !tempTaual(2,na) = tempTaual(2,na)*a2(2)
442
         END IF
443 444 445 446 447
!-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>
448
            340 FORMAT('         <filmPos label="',a20,'">',a,' ',a,' ',a,'</filmPos>')
449 450 451 452 453 454 455 456 457
            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)
458 459
            WRITE (fileNum,340) TRIM(ADJUSTL(atoms%label(na))), &
                                TRIM(ADJUSTL(posString(1))),TRIM(ADJUSTL(posString(2))),TRIM(ADJUSTL(posString(3)))
460 461
         ELSE
!         <relPos> x/myConstant  y/myConstant  z/myConstant</relPos>
462
            350 FORMAT('         <relPos label="',a20,'">',a,' ',a,' ',a,'</relPos>')
463 464 465 466 467 468 469 470
            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
471 472
            WRITE (fileNum,350) TRIM(ADJUSTL(atoms%label(na))), &
                                TRIM(ADJUSTL(posString(1))),TRIM(ADJUSTL(posString(2))),TRIM(ADJUSTL(posString(3)))
473 474 475 476
         END IF
      END DO
!         <force calculate="F" relaxX="T" relaxY="T" relaxZ="T"/>
      360 FORMAT('         <force calculate="',l1,'" relaxXYZ="',3l1,'"/>')
477
      WRITE (fileNum,360) atoms%l_geo(iAtomType),atoms%relax(1,iAtomType),atoms%relax(2,iAtomType),atoms%relax(3,iAtomType)
478

479
      IF(l_nocoOpt.OR.l_explicit) THEN
480
         362 FORMAT('         <nocoParams l_relax="',l1,'" alpha="',f0.8,'" beta="',&
Daniel Wortmann's avatar
Daniel Wortmann committed
481
                    f0.8,'" b_cons_x="',f0.8,'" b_cons_y="',f0.8,'"/>')
482
         WRITE(fileNum,362) noco%l_relax(iAtomType), noco%alphInit(iAtomType),&
483 484 485 486
                            noco%beta(iAtomType),noco%b_con(1,iAtomType),noco%b_con(2,iAtomType)
      END IF


487
      WRITE (fileNum,'(a)') '      </atomGroup>'
488
   END DO
489
   WRITE (fileNum,'(a)') '   </atomGroups>'
490
   if (.not.l_include(4)) then
491 492 493
      close(99)
      fileNum=98
   endif
494

495 496
   368 FORMAT('   <output dos="',l1,'" band="',l1,'" vacdos="',l1,'" slice="',l1,'" mcd="',l1,'">')
   WRITE (fileNum,368) banddos%dos,band,banddos%vacdos,sliceplot%slice,banddos%l_mcd
497 498

!      <checks vchk="F" cdinf="F" disp="F"/>
499 500
   370 FORMAT('      <checks vchk="',l1,'" cdinf="',l1,'"/>')
   WRITE (fileNum,370) input%vchk,input%cdinf
501 502 503

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

!      <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
507
   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,'"/>')
508
   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
509 510 511

!      <plotting iplot="F" score="F" plplot="F"/>
   400 FORMAT('      <plotting iplot="',l1,'" score="',l1,'" plplot="',l1,'"/>')
512
   WRITE (fileNum,400) sliceplot%iplot,input%score,sliceplot%plpot
513 514 515

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

!      <specialOutput form66="F" eonly="F" bmt="F"/>
519 520
   420 FORMAT('      <specialOutput eonly="',l1,'" bmt="',l1,'"/>')
   WRITE (fileNum,420) input%eonly,input%l_bmt
521

522 523 524 525
!      <magneticCircularDichroism energyLo="-10.0" energyUp="0.0"/>
   430 FORMAT('      <magneticCircularDichroism energyLo="',f0.8,'" energyUp="',f0.8,'"/>')
   WRITE (fileNum,430) banddos%e_mcd_lo,banddos%e_mcd_up

526
   WRITE (fileNum,'(a)') '   </output>'
Daniel Wortmann's avatar
Daniel Wortmann committed
527 528
   IF(present(filename)) THEN
      WRITE (fileNum,'(a)')'  <!-- We include the file relax.inp here to enable relaxations (see documentation) -->'
529
      WRITE (fileNum,'(a)')'  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="relax.xml"> <xi:fallback/> </xi:include>'
530 531
      WRITE (fileNum,'(a)') '</fleurInput>'
      CLOSE (fileNum)
Daniel Wortmann's avatar
Daniel Wortmann committed
532 533
   ELSE
      CALL closeXMLElement('inputData')
534
   END IF
535

536
END SUBROUTINE w_inpXML
537
END MODULE m_winpXML