r_inpXML.F90 76.1 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
MODULE m_rinpXML

9
10
11
12
13
14
15
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!
!!! The routine r_inpXML reads in the inp.xml file
!!!
!!!                               GM'16
!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
17
CONTAINS
SUBROUTINE r_inpXML(&
18
19
20
21
22
                     atoms,obsolete,vacuum,input,stars,sliceplot,banddos,dimension,&
                     cell,sym,xcpot,noco,jij,oneD,hybrid,kpts,enpara,&
                     noel,namex,relcor,a1,a2,a3,scale,dtild,xmlElectronStates,&
                     xmlPrintCoreStates,xmlCoreOccs,atomTypeSpecies,speciesRepAtomType,&
                     l_kpts,l_gga)
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

  USE iso_c_binding
  USE m_juDFT
  USE m_types
  USE m_symdata , ONLY : nammap, ord2, l_c2
  USE m_rwsymfile
  USE m_xmlIntWrapFort
  USE m_inv3
  USE m_spg2set
  USE m_closure, ONLY : check_close
  USE m_symproperties
  USE m_calculator
  USE m_icorrkeys
  USE m_constants
  USE m_hybridmix, ONLY : aMix_VHSE, omega_VHSE
  USE m_inpeig
  USE m_sort
  USE m_enpara,    ONLY : r_enpara

  IMPLICIT NONE

  TYPE(t_input),INTENT(INOUT)   :: input
  TYPE(t_sym),INTENT(INOUT)     :: sym
  TYPE(t_stars),INTENT(INOUT)   :: stars 
  TYPE(t_atoms),INTENT(INOUT)   :: atoms
  TYPE(t_vacuum),INTENT(INOUT)   :: vacuum
  TYPE(t_obsolete),INTENT(INOUT) :: obsolete
  TYPE(t_kpts),INTENT(INOUT)     :: kpts
  TYPE(t_oneD),INTENT(INOUT)     :: oneD
  TYPE(t_hybrid),INTENT(INOUT)   :: hybrid
  TYPE(t_Jij),INTENT(INOUT)      :: Jij
  TYPE(t_cell),INTENT(INOUT)     :: cell
  TYPE(t_banddos),INTENT(INOUT)  :: banddos
  TYPE(t_sliceplot),INTENT(INOUT):: sliceplot
  TYPE(t_xcpot),INTENT(INOUT)    :: xcpot
  TYPE(t_noco),INTENT(INOUT)     :: noco
  TYPE(t_dimension),INTENT(OUT)  :: dimension
  TYPE(t_enpara)   ,INTENT(OUT)  :: enpara
61
  LOGICAL, INTENT(OUT)           :: l_kpts, l_gga
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  INTEGER,          ALLOCATABLE, INTENT(INOUT) :: xmlElectronStates(:,:)
  INTEGER,          ALLOCATABLE, INTENT(INOUT) :: atomTypeSpecies(:)
  INTEGER,          ALLOCATABLE, INTENT(INOUT) :: speciesRepAtomType(:)
  REAL,             ALLOCATABLE, INTENT(INOUT) :: xmlCoreOccs(:,:,:)
  LOGICAL,          ALLOCATABLE, INTENT(INOUT) :: xmlPrintCoreStates(:,:)
  CHARACTER(len=3), ALLOCATABLE, INTENT(INOUT) :: noel(:)
  CHARACTER(len=4), INTENT(OUT)  :: namex
  CHARACTER(len=12), INTENT(OUT) :: relcor
  REAL, INTENT(OUT)              :: a1(3),a2(3),a3(3)
  REAL, INTENT(OUT)              :: scale, dtild
  
  CHARACTER(len=8) :: name(10)
  
  !+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     :: scpos  ,zc   
  INTEGER ieq,i,k,na,n,ii
  REAL s3,ah,a,hs2,rest
  LOGICAL l_hyb,l_sym,ldum
  INTEGER :: ierr
  ! ..
  !...  Local Arrays
Daniel Wortmann's avatar
Daniel Wortmann committed
91
  !   CHARACTER :: helpchar(atoms%ntype)
92
93
94
95
96
97
98
99
100
  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

101
  CHARACTER(len=20) :: tempNumberString
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  CHARACTER(len=150) :: format
  CHARACTER(len=20) :: mixingScheme
  CHARACTER(len=10) :: loType
  LOGICAL :: kptGamma, l_relcor
  INTEGER :: iAtomType, startCoreStates, endCoreStates
  CHARACTER(len=100) :: xPosString, yPosString, zPosString
  CHARACTER(len=200) :: coreStatesString
  !   REAL :: tempTaual(3,atoms%nat)
  REAL             :: coreStateOccs(29,2)
  INTEGER          :: coreStateNprnc(29), coreStateKappa(29)
  INTEGER          :: speciesXMLElectronStates(29)
  REAL             :: speciesXMLCoreOccs(2,29)
  LOGICAL          :: speciesXMLPrintCoreStates(29)

116
  INTEGER            :: iType, iLO, iSpecies, lNumCount, nNumCount, iLLO, jsp, j, l, absSum
117
118
119
120
121
  INTEGER            :: numberNodes, nodeSum, numSpecies, n2spg, n1, n2, ikpt, iqpt
  INTEGER            :: atomicNumber, coreStates, gridPoints, lmax, lnonsphr, lmaxAPW
  INTEGER            :: latticeDef, symmetryDef, nop48, firstAtomOfType, errorStatus
  INTEGER            :: loEDeriv, ntp1, ios, ntst, jrc, minNeigd, providedCoreStates, providedStates
  INTEGER            :: nv, nv2, kq1, kq2, kq3, nprncTemp, kappaTemp
122
  INTEGER            :: ldau_l(4), numVac, numU
123
124
125
126
  INTEGER            :: speciesEParams(0:3)
  INTEGER            :: mrotTemp(3,3,48)
  REAL               :: tauTemp(3,48)
  REAL               :: bk(3)
127
  LOGICAL            :: flipSpin, l_eV, invSym, l_qfix, relaxX, relaxY, relaxZ
128
  LOGICAL            :: l_vca, coreConfigPresent, l_enpara, l_orbcomp
129
  REAL               :: magMom, radius, logIncrement, qsc(3), latticeScale, dr
130
  REAL               :: aTemp, zp, rmtmax, sumWeight, ldau_u(4), ldau_j(4), tempReal
131
  REAL               :: weightScale, eParamUp, eParamDown
132
  LOGICAL            :: l_amf(4)
133
134
135
136
137
138
139
140
  REAL, PARAMETER    :: boltzmannConst = 3.1668114e-6 ! value is given in Hartree/Kelvin



  CHARACTER(LEN=200,KIND=c_char) :: schemaFilename, docFilename
  CHARACTER(LEN=255) :: valueString, lString, nString, token
  CHARACTER(LEN=255) :: xPathA, xPathB, xPathC, xPathD, xPathE
  CHARACTER(LEN=11)  :: latticeType
141
  CHARACTER(LEN=50)  :: versionString
142
143
144
145
146
147
148
149
150

  INTEGER, ALLOCATABLE :: lNumbers(:), nNumbers(:), speciesLLO(:)
  INTEGER, ALLOCATABLE :: loOrderList(:)
  INTEGER, ALLOCATABLE :: speciesNLO(:)
  INTEGER, ALLOCATABLE :: multtab(:,:), invOps(:), optype(:)
  INTEGER, ALLOCATABLE :: lmx1(:), nq1(:), nlhtp1(:)
  INTEGER, ALLOCATABLE :: speciesLOEDeriv(:)
  REAL,    ALLOCATABLE :: speciesLOeParams(:), speciesLLOReal(:)

151
152
153
154
155
156
157
! Variables for MT radius testing:

  REAL                 :: dtild1,kmax1,dvac1
  LOGICAL              :: l_test
  INTEGER, ALLOCATABLE :: jri1(:), lmax1(:)
  REAL, ALLOCATABLE    :: rmt1(:), dx1(:)

158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  EXTERNAL prp_xcfft_box

  interface
     function dropInputSchema() bind(C, name="dropInputSchema")
       use iso_c_binding
       INTEGER(c_int) dropInputSchema
     end function dropInputSchema
  end interface

  errorStatus = 0
  errorStatus = dropInputSchema()
  IF(errorStatus.NE.0) THEN
     STOP 'Error: Cannot print out FleurInputSchema.xsd'
  END IF

  schemaFilename = "FleurInputSchema.xsd"//C_NULL_CHAR
  docFilename = "inp.xml"//C_NULL_CHAR

  !TODO! these switches should be in the inp-file
  input%l_core_confpot=.true. !former CPP_CORE
  input%l_useapw=.false.   !former CPP_APW
Daniel Wortmann's avatar
Daniel Wortmann committed
179
  !WRITE(*,*) 'Start reading of inp.xml file'
180
181
182
183
184
185
186
  CALL xmlInitInterface()
  CALL xmlParseSchema(schemaFilename)
  CALL xmlParseDoc(docFilename)
  CALL xmlValidateDoc()
  CALL xmlInitXPath()

  ! Check version of inp.xml
187
188
  versionString = xmlGetAttributeValue('/fleurInput/@fleurInputVersion')
  IF((TRIM(ADJUSTL(versionString)).NE.'0.27').AND.(TRIM(ADJUSTL(versionString)).NE.'0.28')) THEN
189
190
191
192
193
194
195
196
197
     STOP 'version number of inp.xml file is not compatible with this fleur version'
  END IF

  ! Get number of atoms, atom types, and atom species

  numberNodes = xmlGetNumberOfNodes('/fleurInput/atomGroups/atomGroup/relPos')
  numberNodes = numberNodes + xmlGetNumberOfNodes('/fleurInput/atomGroups/atomGroup/absPos')
  numberNodes = numberNodes + xmlGetNumberOfNodes('/fleurInput/atomGroups/atomGroup/filmPos')

Daniel Wortmann's avatar
Daniel Wortmann committed
198
  atoms%nat = numberNodes
199
200
201

  numberNodes = xmlGetNumberOfNodes('/fleurInput/atomGroups/atomGroup')

Daniel Wortmann's avatar
Daniel Wortmann committed
202
  atoms%ntype = numberNodes
203
204
205
206
207
208
209
210
211
212
213
214
215

  numSpecies = xmlGetNumberOfNodes('/fleurInput/atomSpecies/species')

  ALLOCATE(atoms%nz(atoms%ntype))     !nz and zatom have the same content!
  ALLOCATE(atoms%zatom(atoms%ntype))  !nz and zatom have the same content!
  ALLOCATE(atoms%jri(atoms%ntype))
  ALLOCATE(atoms%dx(atoms%ntype))
  ALLOCATE(atoms%lmax(atoms%ntype))
  ALLOCATE(atoms%nlo(atoms%ntype))
  ALLOCATE(atoms%ncst(atoms%ntype))
  ALLOCATE(atoms%lnonsph(atoms%ntype))
  ALLOCATE(atoms%nflip(atoms%ntype))
  ALLOCATE(atoms%l_geo(atoms%ntype))
216
  ALLOCATE(atoms%lda_u(4*atoms%ntype))
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
  ALLOCATE(atoms%bmu(atoms%ntype))
  ALLOCATE(atoms%relax(3,atoms%ntype))
  ALLOCATE(atoms%neq(atoms%ntype))
  ALLOCATE(atoms%taual(3,atoms%nat))
  ALLOCATE(atoms%pos(3,atoms%nat))
  ALLOCATE(atoms%rmt(atoms%ntype))
  ALLOCATE(atoms%numStatesProvided(atoms%ntype))

  ALLOCATE(atoms%ncv(atoms%ntype)) ! For what is this?
  ALLOCATE(atoms%ngopr(atoms%nat)) ! For what is this?
  ALLOCATE(atoms%lapw_l(atoms%ntype)) ! Where do I put this?
  ALLOCATE(atoms%invsat(atoms%nat)) ! Where do I put this?

  ALLOCATE(noco%soc_opt(atoms%ntype+2),noco%l_relax(atoms%ntype),noco%b_con(2,atoms%ntype))
  ALLOCATE(noco%alphInit(atoms%ntype),noco%alph(atoms%ntype),noco%beta(atoms%ntype))

  ALLOCATE (Jij%alph1(atoms%ntype),Jij%l_magn(atoms%ntype),Jij%M(atoms%ntype))
  ALLOCATE (Jij%magtype(atoms%ntype),Jij%nmagtype(atoms%ntype))

  DEALLOCATE(atomTypeSpecies,speciesRepAtomType)
  ALLOCATE(atomTypeSpecies(atoms%ntype))
  ALLOCATE(speciesRepAtomType(numSpecies))
  atomTypeSpecies = -1
  speciesRepAtomType = -1

  DEALLOCATE(xmlElectronStates,xmlPrintCoreStates,xmlCoreOccs)
  ALLOCATE(xmlElectronStates(29,atoms%ntype))
  ALLOCATE(xmlPrintCoreStates(29,atoms%ntype))
  ALLOCATE(xmlCoreOccs(2,29,atoms%ntype))
  xmlElectronStates = noState_const
  xmlPrintCoreStates = .FALSE.
  xmlCoreOccs = 0.0

  ALLOCATE (kpts%ntetra(4,kpts%ntet),kpts%voltet(kpts%ntet))

  ! Read in constants

  xPathA = '/fleurInput/constants/constant'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  DO i = 1, numberNodes
     WRITE(xPathB,*) TRIM(ADJUSTL(xPathA)), '[',i,']'
     tempReal = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathB))//'/@value'))
     valueString = xmlGetAttributeValue(TRIM(ADJUSTL(xPathB))//'/@name')
     CALL ASSIGN_var(valueString,tempReal)
  END DO
262

263
264
265
266
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Comment section
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

267
268
269
270
271
272
273
274
275
276
277
  input%comment = '        '
  xPathA = '/fleurInput/comment'
  valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA)))))
  DO i = 1, LEN(TRIM(ADJUSTL(valueString)))
     IF (valueString(i:i).EQ.achar(10)) valueString(i:i) = ' ' !remove line breaks
  END DO
  valueString = TRIM(ADJUSTL(valueString))
  DO i = 1, 10
     j = (i-1) * 8 + 1
     input%comment(i) = valueString(j:j+7)
  END DO
278

279
280
281
282
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Start of calculationSetup section
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
  ! Read general cutoff parameters

  input%rkmax = evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/cutoffs/@Kmax'))
  stars%gmax = evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/cutoffs/@Gmax'))

  xPathA = '/fleurInput/calculationSetup/cutoffs/@GmaxXC'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  xcpot%gmaxxc = stars%gmax
  IF(numberNodes.EQ.1) THEN
     xcpot%gmaxxc = evaluateFirstOnly(xmlGetAttributeValue(xPathA))
  END IF
  stars%gmaxInit = stars%gmax

  xPathA = '/fleurInput/calculationSetup/cutoffs/@numbands'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  dimension%neigd = 0
  IF(numberNodes.EQ.1) THEN
     valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA)))))
     IF(TRIM(ADJUSTL(valueString)).EQ.'all') THEN
        STOP 'Feature to calculate all eigenfunctions not yet implemented.'
     ELSE
        READ(valueString,*) dimension%neigd
     END IF
  END IF

  ! Read SCF loop parametrization

  input%itmax = evaluateFirstIntOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/scfLoop/@itmax'))
311
  input%minDistance = evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/scfLoop/@minDistance'))
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
  input%maxiter = evaluateFirstIntOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/scfLoop/@maxIterBroyd'))

  valueString = TRIM(ADJUSTL(xmlGetAttributeValue('/fleurInput/calculationSetup/scfLoop/@imix')))
  SELECT CASE (valueString)
  CASE ('straight')
     input%imix = 1
  CASE ('Broyden1')
     input%imix = 3
  CASE ('Broyden2')
     input%imix = 5
  CASE ('Anderson')
     input%imix = 7
  CASE DEFAULT
     STOP 'Error: unknown mixing scheme selected!'
  END SELECT

  input%alpha = evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/scfLoop/@alpha'))
  input%spinf = evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/scfLoop/@spinf'))

  ! Get parameters for core electrons

  input%ctail = evaluateFirstBoolOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/coreElectrons/@ctail'))
334
335
336
337
338
  IF((TRIM(ADJUSTL(versionString)).EQ.'0.27')) THEN
     input%coretail_lmax = 99
  ELSE
     input%coretail_lmax = evaluateFirstIntOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/coreElectrons/@coretail_lmax'))
  END IF
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
  input%frcor = evaluateFirstBoolOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/coreElectrons/@frcor'))
  input%kcrel = evaluateFirstIntOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/coreElectrons/@kcrel'))

  ! Read in magnetism parameters

  input%jspins = evaluateFirstIntOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/magnetism/@jspins'))
  noco%l_noco = evaluateFirstBoolOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/magnetism/@l_noco'))
  Jij%l_J = evaluateFirstBoolOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/magnetism/@l_J'))
  input%swsp = evaluateFirstBoolOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/magnetism/@swsp'))
  input%lflip = evaluateFirstBoolOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/magnetism/@lflip'))

  dimension%jspd = input%jspins

  ! Read in Brillouin zone integration parameters

  kpts%nkpt3 = 0
  kpts%nmop = 0
  l_kpts = .FALSE.

  valueString = TRIM(ADJUSTL(xmlGetAttributeValue('/fleurInput/calculationSetup/bzIntegration/@mode')))
  SELECT CASE (valueString)
  CASE ('hist')
     input%gauss = .FALSE.
     input%tria = .FALSE.
  CASE ('gauss')
     input%gauss = .TRUE.
     input%tria = .FALSE.
  CASE ('tria')
     input%gauss = .FALSE.
     input%tria = .TRUE.
  CASE DEFAULT
     STOP 'Invalid bzIntegration mode selected!'
  END SELECT

  nodeSum = 0
  xPathA = '/fleurInput/calculationSetup/bzIntegration/@fermiSmearingEnergy'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  nodeSum = nodeSum + numberNodes
  IF (numberNodes.EQ.1) THEN
     input%tkb = evaluateFirstOnly(xmlGetAttributeValue(xPathA))
  END IF
  xPathA = '/fleurInput/calculationSetup/bzIntegration/@fermiSmearingTemp'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  nodeSum = nodeSum + numberNodes
  IF (numberNodes.EQ.1) THEN
     input%tkb = evaluateFirstOnly(xmlGetAttributeValue(xPathA))
     input%tkb = boltzmannConst * input%tkb
  END IF
  IF(nodeSum.GE.2) THEN
     STOP 'Error: Multiple fermi Smearing parameters provided in input file!'
  END IF

  xPathA = '/fleurInput/calculationSetup/bzIntegration/@valenceElectrons'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  IF (numberNodes.EQ.1) THEN
     input%zelec = evaluateFirstOnly(xmlGetAttributeValue(xPathA))
  ELSE
     STOP 'Error: Optionality of valence electrons in input file not yet implemented!'
  END IF

  ! Option kPointMesh
  xPathA = '/fleurInput/calculationSetup/bzIntegration/kPointMesh'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  IF (numberNodes.EQ.1) THEN
     l_kpts = .FALSE.
     kpts%nkpt3(1) = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@nx'))
     kpts%nkpt3(2) = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@ny'))
     kpts%nkpt3(3) = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@nz'))
     kpts%l_gamma = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@gamma'))
     kpts%nmop(1) = kpts%nkpt3(1)
     kpts%nmop(2) = kpts%nkpt3(2)
     kpts%nmop(3) = kpts%nkpt3(3)
     kpts%nkpt = kpts%nkpt3(1) * kpts%nkpt3(2) * kpts%nkpt3(3)
412
     kpts%specificationType = 2
413
414
415
416
417
418
419
420
421
  END IF

  ! Option kPointCount
  xPathA = '/fleurInput/calculationSetup/bzIntegration/kPointCount'
  numberNodes = xmlGetNumberOfNodes(xPathA)
  IF (numberNodes.EQ.1) THEN
     l_kpts = .FALSE.
     kpts%nkpt = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@count'))
     kpts%l_gamma = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@gamma'))
Daniel Wortmann's avatar
Daniel Wortmann committed
422
     kpts%nkpt = kpts%nkpt
423
     kpts%specificationType = 1
424

Daniel Wortmann's avatar
Daniel Wortmann committed
425
426
     ALLOCATE(kpts%bk(3,kpts%nkpt))
     ALLOCATE(kpts%wtkpt(kpts%nkpt))
427
     kpts%bk = 0.0
Daniel Wortmann's avatar
Daniel Wortmann committed
428
     kpts%wtkpt = 0.0
429
430
431
432
433
434
435
436
437
438
439
440
441
442
     kpts%posScale = 1.0

     numberNodes = xmlGetNumberOfNodes('/fleurInput/calculationSetup/bzIntegration/kPointCount/specialPoint')
     IF(numberNodes.EQ.1) THEN
        STOP 'Error: Single special k point provided. This does not make sense!'
     END IF
     kpts%numSpecialPoints = numberNodes
     IF(kpts%numSpecialPoints.GE.2) THEN
        DEALLOCATE(kpts%specialPoints)
        ALLOCATE(kpts%specialPoints(3,kpts%numSpecialPoints))
        ALLOCATE(kpts%specialPointNames(kpts%numSpecialPoints))
        DO i = 1, kpts%numSpecialPoints
           WRITE(xPathA,*) '/fleurInput/calculationSetup/bzIntegration/kPointCount/specialPoint[',i,']'
           valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA)))))
443
444
445
           kpts%specialPoints(1,i) = evaluatefirst(valueString)
           kpts%specialPoints(2,i) = evaluatefirst(valueString)
           kpts%specialPoints(3,i) = evaluatefirst(valueString)
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
           kpts%specialPointNames(i) = xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@name')
        END DO
     END IF
  ELSE
     DEALLOCATE(kpts%specialPoints)
     ALLOCATE(kpts%specialPoints(3,kpts%numSpecialPoints))
     ALLOCATE(kpts%specialPointNames(kpts%numSpecialPoints))
  END IF

  ! Option kPointList
  numberNodes = xmlGetNumberOfNodes('/fleurInput/calculationSetup/bzIntegration/kPointList')
  IF (numberNodes.EQ.1) THEN
     l_kpts = .TRUE.
     numberNodes = xmlGetNumberOfNodes('/fleurInput/calculationSetup/bzIntegration/kPointList/kPoint')
     kpts%nkpt = numberNodes
Daniel Wortmann's avatar
Daniel Wortmann committed
461
462
463
     kpts%nkpt = numberNodes
     ALLOCATE(kpts%bk(3,kpts%nkpt))
     ALLOCATE(kpts%wtkpt(kpts%nkpt))
464
     kpts%bk = 0.0
Daniel Wortmann's avatar
Daniel Wortmann committed
465
     kpts%wtkpt = 0.0
466
     kpts%specificationType = 3
467
468
469
470
471
472
473
474

     kpts%posScale = evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/bzIntegration/kPointList/@posScale'))
     weightScale = evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/calculationSetup/bzIntegration/kPointList/@weightScale'))

     DO i = 1, kpts%nkpt
        WRITE(xPathA,*) '/fleurInput/calculationSetup/bzIntegration/kPointList/kPoint[',i,']'
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA)))))
        READ(valueString,*) kpts%bk(1,i), kpts%bk(2,i), kpts%bk(3,i)
Daniel Wortmann's avatar
Daniel Wortmann committed
475
476
        kpts%wtkpt(i) = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@weight'))
        kpts%wtkpt(i) = kpts%wtkpt(i) / weightScale
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
     END DO
  END IF

  ! Read in optional SOC parameters if present

  xPathA = '/fleurInput/calculationSetup/soc'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  noco%l_soc = .FALSE.
  noco%theta = 0.0
  noco%phi = 0.0
  noco%soc_opt(atoms%ntype+2) = .FALSE.
  noco%soc_opt(atoms%ntype+1) = .FALSE.

  IF (numberNodes.EQ.1) THEN
     noco%theta = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@theta'))
     noco%phi = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@phi'))
     noco%l_soc = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_soc'))
     noco%soc_opt(atoms%ntype+2) = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@spav'))
     noco%soc_opt(atoms%ntype+1) = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@off'))
  END IF

  ! Read in optional noco parameters if present

  xPathA = '/fleurInput/calculationSetup/nocoParams'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  noco%l_ss = .FALSE.
  noco%l_mperp = .FALSE.
  noco%l_constr = .FALSE.
  Jij%l_disp = .FALSE.
  input%sso_opt = .FALSE.
  noco%mix_b = 0.0
  Jij%thetaJ = 0.0
  Jij%nmagn=1
  Jij%nsh = 0
  noco%qss = 0.0

  noco%l_relax(:) = .FALSE.
  noco%alphInit(:) = 0.0
  noco%alph(:) = 0.0
  noco%beta(:) = 0.0
  noco%b_con(:,:) = 0.0

  Jij%M(:) = 0.0
  Jij%l_magn(:) = .FALSE.
  Jij%l_wr=.TRUE.
  Jij%nqptd=1
  Jij%mtypes=1
  Jij%phnd=1

  IF ((noco%l_noco).AND.(numberNodes.EQ.0)) THEN
     STOP 'Error: l_noco is true but no noco parameters set in xml input file!'
  END IF

  IF (numberNodes.EQ.1) THEN
     noco%l_ss = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_ss'))
     noco%l_mperp = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_mperp'))
     noco%l_constr = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_constr'))
     Jij%l_disp = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_disp'))

     valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@sso_opt')))
     READ(valueString,'(2l1)') input%sso_opt(1),input%sso_opt(2)

     noco%mix_b = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@mix_b'))
     Jij%thetaJ = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@thetaJ'))
     Jij%nsh = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@nsh'))

     valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/qss')))
     READ(valueString,*) noco%qss(1), noco%qss(2), noco%qss(3)

548
     !WRITE(*,*) 'Note: TODO: Calculation of q points!'
549
550
551
552
553
554
555
556

     numberNodes = xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/qsc')
     IF (numberNodes.EQ.1) THEN
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/qsc')))
        READ(valueString,*) qsc(1), qsc(2), qsc(3)
        DO i = 1, 3
           noco%qss(i) = noco%qss(i) / qsc(i)
        END DO
557
558
        !WRITE(*,*) 'Note: TODO: Integrate qsc directly into qss in input file!'
        !WRITE(*,*) '(no problem for users)'
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
     END IF
  END IF

  ! Read in optional 1D parameters if present

  xPathA = '/fleurInput/calculationSetup/oneDParams'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  oneD%odd%d1 = .FALSE.

  IF (numberNodes.EQ.1) THEN
     oneD%odd%d1 = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@d1'))
     oneD%odd%M = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@MM'))
     oneD%odd%mb = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@vM'))
     oneD%odd%m_cyl = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@m_cyl'))
     oneD%odd%chi = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@chi'))
     oneD%odd%rot = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@rot'))
     oneD%odd%invs = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@invs1'))
     oneD%odd%zrfs = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@zrfs1'))
  END IF

  ! Read in optional expert modes switches

  xPathA = '/fleurInput/calculationSetup/expertModes'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  input%gw = 0
  obsolete%pot8 = .FALSE.
  input%isec1 = 999999
  input%secvar = .FALSE.

  IF (numberNodes.EQ.1) THEN
     input%gw = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@gw'))
     obsolete%pot8 = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@pot8'))
     input%isec1 = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@isec1'))
     input%secvar = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@secvar'))
  END IF

  ! Read in optional geometry optimization parameters

  xPathA = '/fleurInput/calculationSetup/geometryOptimization'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  input%l_f = .FALSE.
  input%qfix = 0

  IF (numberNodes.EQ.1) THEN
     input%l_f = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@l_f'))
     input%xa = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@xa'))
     input%thetad = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@thetad'))
     input%epsdisp = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@epsdisp'))
     input%epsforce = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@epsforce'))

     numberNodes = xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/@qfix')
     IF (numberNodes.EQ.1) THEN
        input%qfix = 1
        l_qfix = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@qfix'))
        IF (l_qfix) THEN
           input%qfix = 2
        END IF
     END IF
  END IF

  ! Read in optional q point mesh for spin spirals

  xPathA = '/fleurInput/calculationSetup/spinSpiralQPointMesh'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  !   IF ((noco%l_ss).AND.(numberNodes.EQ.0)) THEN
  !      STOP 'Error: l_ss is true but no q point mesh set in xml input file!'
  !   END IF

  Jij%nmopq = 0
  IF (numberNodes.EQ.1) THEN
     Jij%nmopq(1) = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@qx'))
     Jij%nmopq(2) = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@qy'))
     Jij%nmopq(3) = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@qz'))
  END IF

  ! Read in optional E-Field parameters

  xPathA = '/fleurInput/calculationSetup/eField'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  IF (numberNodes.EQ.1) THEN
     input%efield%zsigma = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@zsigma'))
     input%efield%sig_b(1) = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@sig_b_1'))
     input%efield%sig_b(2) = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@sig_b_2'))
     input%efield%plot_charge = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@plot_charge'))
     input%efield%plot_rho = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@plot_rho'))
     input%efield%autocomp = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@autocomp'))
     input%efield%dirichlet = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@dirichlet'))
     l_eV = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@eV'))

     STOP 'Error: Reading input for E-Fields not yet implemented completely!'
     !      ALLOCATE(input%efield%sigEF(3*k1d, 3*k2d, nvac))
     !      input%efield%sigEF = 0.0
     IF (l_eV) THEN
657
658
        input%efield%sig_b(:) = input%efield%sig_b/hartree_to_ev_const
        !         input%efield%sigEF(:,:,:) = input%efield%sigEF/hartree_to_ev_const
659
660
661
662
663
664
665
666
667
668
669
670
     END IF
  END IF

  ! Read in optional energy parameter limits

  xPathA = '/fleurInput/calculationSetup/energyParameterLimits'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  IF (numberNodes.EQ.1) THEN
     input%ellow = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@ellow'))
     input%elup = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@elup'))
  END IF
671
672
673
674
675

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! End of calculationSetup section
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

676
  ALLOCATE(enpara%evac0(2,input%jspins))
Daniel Wortmann's avatar
Daniel Wortmann committed
677
  ALLOCATE(enpara%lchg_v(2,input%jspins),enpara%skiplo(atoms%ntype,input%jspins))
678
  ALLOCATE(enpara%enmix(input%jspins))
679

680
  enpara%lchg_v = .FALSE.
681
682
683
684
685

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Start of cell section
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
  ! Read in lattice parameters

  a1 = 0.0
  a2 = 0.0
  a3 = 0.0
  cell%z1 = 0.0
  dtild = 0.0
  input%film = .FALSE.
  latticeType = 'bulkLattice'
  latticeDef = 0
  symmetryDef = 0
  cell%latnam = 'any'

  numberNodes = xmlGetNumberOfNodes('/fleurInput/cell/filmLattice')

  IF (numberNodes.EQ.1) THEN
     input%film = .TRUE.
     latticeType = 'filmLattice'
  END IF

  xPathA = '/fleurInput/cell/'//latticeType
  numberNodes = xmlGetNumberOfNodes(xPathA)

  IF (numberNodes.EQ.1) THEN
     latticeScale = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@scale'))
     scale = latticeScale
     valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@latnam')))
     READ(valueString,*) cell%latnam

     IF(input%film) THEN
        cell%z1 = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@dVac'))
        dtild = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@dTilda'))
        vacuum%dvac = cell%z1
        a3(3) = dtild
        enpara%evac0 = eVac0Default_const
        xPathB = TRIM(ADJUSTL(xPathA))//'/vacuumEnergyParameters'
        numberNodes = xmlGetNumberOfNodes(xPathB)
        IF(numberNodes.GE.1) THEN
           DO i = 1, numberNodes
              xPathC = ''
              WRITE(xPathC,'(a,i0,a)') TRIM(ADJUSTL(xPathB))//'[',i,']'
              numVac = evaluateFirstIntOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathC))//'/@vacuum'))
              eParamUp = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathC))//'/@spinUp'))
              eParamDown = eParamUp
              IF (xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathC))//'/@spinDown').GE.1) THEN
                 eParamDown = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathC))//'/@spinDown'))
              END IF
              enpara%evac0(numVac,1) = eParamUp
              IF(input%jspins.GT.1) enpara%evac0(numVac,2) = eParamDown
              IF(i.EQ.1) THEN
                 enpara%evac0(3-numVac,1) = eParamUp
                 IF(input%jspins.GT.1) enpara%evac0(3-numVac,2) = eParamDown
              END IF
           END DO
        END IF
     END IF

     numberNodes = xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/a1')
     IF (numberNodes.EQ.1) THEN
        latticeDef = 1
        a1(1) = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/a1'))
        numberNodes = xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/a2')
        IF (numberNodes.EQ.1) THEN
           latticeDef = 2
           a2(2) = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/a2'))
        END IF
        IF(.NOT.input%film) THEN
           a3(3) = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/c'))
        END IF
     END IF

     numberNodes = xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/row-1')
     IF (numberNodes.EQ.1) THEN
        latticeDef = 3
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/row-1')))
        a1(1) = evaluateFirst(valueString)
        a1(2) = evaluateFirst(valueString)
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/row-2')))
        a2(1) = evaluateFirst(valueString)
        a2(2) = evaluateFirst(valueString)
        IF(.NOT.input%film) THEN
           a3(3) = evaluateFirstOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/c'))
        END IF
     END IF

     numberNodes = xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/bravaisMatrix')
     IF (numberNodes.EQ.1) THEN
        latticeDef = 4
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/bravaisMatrix/row-1')))
        a1(1) = evaluateFirst(valueString)
        a1(2) = evaluateFirst(valueString)
        IF(.NOT.input%film) THEN
           a1(3) = evaluateFirst(valueString)
        END IF
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/bravaisMatrix/row-2')))
        a2(1) = evaluateFirst(valueString)
        a2(2) = evaluateFirst(valueString)
        IF(.NOT.input%film) THEN
           a2(3) = evaluateFirst(valueString)
        END IF
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/bravaisMatrix/row-3')))
        IF(.NOT.input%film) THEN
           a3(1) = evaluateFirst(valueString)
           a3(2) = evaluateFirst(valueString)
           a3(3) = evaluateFirst(valueString)
        ELSE
792
           !WRITE(*,*) 'Note: For film calculations only the upper left 2x2 part of the Bravais matrix is considered.'
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
        END IF
     END IF
  END IF ! Note: Further ways to define lattices might be added later. (1D lattice,...)

  ! Construction of amat requires additional information about the lattice 
  ! and is done later (scroll down)!

  ! Read in symmetry parameters

  sym%namgrp = 'any'

  xPathA = '/fleurInput/cell/symmetry'
  numberNodes = xmlGetNumberOfNodes('/fleurInput/cell/symmetry')

  IF (numberNodes.EQ.1) THEN
808
     sym%symSpecType = 2
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
     symmetryDef = 1
     valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@spgrp')))
     READ(valueString,*) sym%namgrp
     sym%invs = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@invs'))
     sym%zrfs = evaluateFirstBoolOnly(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@zrfs'))
     sym%invs2 = sym%invs.AND.sym%zrfs

     IF (sym%namgrp.EQ.'any ') THEN
        sym%nop = 48
        ! Read in sym.out file if sym%namgrp='any' set.
        CALL rw_symfile('r',94,'sym.out',48,cell%bmat,&
             &                        mrotTemp,tauTemp,sym%nop,sym%nop2,sym%symor)
        IF (ALLOCATED(sym%mrot)) THEN
           DEALLOCATE(sym%mrot)
        END IF
        ALLOCATE(sym%mrot(3,3,sym%nop))
        IF (ALLOCATED(sym%tau)) THEN
           DEALLOCATE(sym%tau)
        END IF
        ALLOCATE(sym%tau(3,sym%nop))

        DO k = 1, sym%nop
           DO i = 1, 3
              DO j = 1, 3
                 sym%mrot(j,i,k) = mrotTemp(j,i,k)
              END DO
              sym%tau(i,k) = tauTemp(i,k)
           END DO
        END DO
     ELSE
        n2spg = 0
        DO i = 1, 20
841
           IF (sym%namgrp.EQ.nammap(i)) n2spg = i
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
        END DO
        IF (n2spg == 0 ) THEN
           WRITE (*,*) 'Spacegroup ',sym%namgrp,' not known! Choose one of:'
           WRITE (*,'(20(a4,1x))') (nammap(i),i=1,20)
           CALL juDFT_error("Could not determine spacegroup!", calledby = "r_inpXML")
        END IF
        IF ((n2spg.GE.13).AND.(n2spg.LE.17)) THEN
           IF (.not.((cell%latnam.EQ.'hx3').OR.(cell%latnam.EQ.'hex'))) THEN
              CALL juDFT_error("Use only hex or hx3 with p3, p3m1, p31m, p6 or p6m!", calledby ="r_inpXML")
           END IF
        END IF
        sym%nop = ord2(n2spg)
        IF (sym%invs) THEN
           sym%nop = 2*sym%nop
           IF (sym%zrfs.and.(.not.l_c2(n2spg))) sym%nop = 2*sym%nop
        ELSE
           IF (sym%zrfs) sym%nop = 2*sym%nop
        END IF
        IF (ALLOCATED(sym%mrot)) THEN
           DEALLOCATE(sym%mrot)
        END IF
        ALLOCATE(sym%mrot(3,3,sym%nop))
        IF (ALLOCATED(sym%tau)) THEN
           DEALLOCATE(sym%tau)
        END IF
        ALLOCATE(sym%tau(3,sym%nop))
        CALL spg2set(sym%nop,sym%zrfs,sym%invs,sym%namgrp,cell%latnam,&
             &                     sym%mrot,sym%tau,sym%nop2,sym%symor)
     END IF
  END IF

  xPathA = '/fleurInput/cell/symmetryFile'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  IF (numberNodes.EQ.1) THEN
     symmetryDef = 2
878
     sym%symSpecType = 1
879
     sym%nop = 48
880
881
882
883
884
885
886
887
888
889
890
891
892
893
     valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@filename')))

     CALL rw_symfile('r',94,TRIM(ADJUSTL(valueString)),48,cell%bmat,&
          &                     mrotTemp,tauTemp,sym%nop,sym%nop2,sym%symor)

     IF (ALLOCATED(sym%mrot)) THEN
        DEALLOCATE(sym%mrot)
     END IF
     ALLOCATE(sym%mrot(3,3,sym%nop))
     IF (ALLOCATED(sym%tau)) THEN
        DEALLOCATE(sym%tau)
     END IF
     ALLOCATE(sym%tau(3,sym%nop))

894
895
896
     sym%invs = .FALSE.
     sym%zrfs = .FALSE.

897
     DO k = 1, sym%nop
898
        absSum = 0
899
900
901
        DO i = 1, 3
           DO j = 1, 3
              sym%mrot(j,i,k) = mrotTemp(j,i,k)
902
              absSum = absSum + ABS(sym%mrot(j,i,k))
903
904
905
           END DO
           sym%tau(i,k) = tauTemp(i,k)
        END DO
906
907
908
909
910
911
        IF (absSum.EQ.3) THEN
           IF (ALL(sym%tau(:,k).EQ.0.0)) THEN
              IF ((sym%mrot(1,1,k).EQ.-1).AND.(sym%mrot(2,2,k).EQ.-1).AND.(sym%mrot(3,3,k).EQ.-1)) sym%invs = .TRUE.
              IF ((sym%mrot(1,1,k).EQ.1).AND.(sym%mrot(2,2,k).EQ.1).AND.(sym%mrot(3,3,k).EQ.-1)) sym%zrfs = .TRUE.
           END IF
        END IF
912
     END DO
913
914

     sym%invs2 = sym%invs.AND.sym%zrfs
915
916
917
918
919
920
  END IF

  xPathA = '/fleurInput/cell/symmetryOperations'
  numberNodes = xmlGetNumberOfNodes(xPathA)

  IF (numberNodes.EQ.1) THEN
921
     sym%symSpecType = 3
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
     symmetryDef = 3

     numberNodes = xmlGetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/symOp')
     sym%nop = numberNodes

     IF (ALLOCATED(sym%mrot)) THEN
        DEALLOCATE(sym%mrot)
     END IF
     ALLOCATE(sym%mrot(3,3,sym%nop))
     IF (ALLOCATED(sym%tau)) THEN
        DEALLOCATE(sym%tau)
     END IF
     ALLOCATE(sym%tau(3,sym%nop))
     sym%symor = .TRUE.
     DO i = 1, sym%nop
        WRITE(xPathB,*) TRIM(ADJUSTL(xPathA))//'/symOp[',i,']/row-1'
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathB)))))
        READ(valueString,*) sym%mrot(1,1,i), sym%mrot(1,2,i), sym%mrot(1,3,i), sym%tau(1,i)

        WRITE(xPathB,*) TRIM(ADJUSTL(xPathA))//'/symOp[',i,']/row-2'
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathB)))))
        READ(valueString,*) sym%mrot(2,1,i), sym%mrot(2,2,i), sym%mrot(2,3,i), sym%tau(2,i)

        WRITE(xPathB,*) TRIM(ADJUSTL(xPathA))//'/symOp[',i,']/row-3'
        valueString = TRIM(ADJUSTL(xmlGetAttributeValue(TRIM(ADJUSTL(xPathB)))))
        READ(valueString,*) sym%mrot(3,1,i), sym%mrot(3,2,i), sym%mrot(3,3,i), sym%tau(3,i)

        IF ((sym%tau(1,i)**2 + sym%tau(2,i)**2 + sym%tau(3,i)**2).GT.1.e-8) THEN
           sym%symor = .FALSE.
        END IF
        DO j = 1,3
           IF (ABS(sym%tau(j,i)-0.33333) < 0.00001) THEN
              sym%tau(j,i) = 1./3.
           ENDIF
           IF (ABS(sym%tau(j,i)+0.33333) < 0.00001) THEN
              sym%tau(j,i) = -1./3.
           ENDIF
           IF (ABS(sym%tau(j,i)-0.66667) < 0.00001) THEN
              sym%tau(j,i) = 2./3.
           ENDIF
           IF (ABS(sym%tau(j,i)+0.66667) < 0.00001) THEN
              sym%tau(j,i) = -2./3.
           ENDIF
        ENDDO
     END DO
  END IF

  ! Calculate missing symmetry and cell properties and check consistency of parameters.

  ! Construction of amat
  SELECT CASE (latticeDef)
  CASE (1)
     IF (cell%latnam.EQ.'squ') THEN
        a2(2) = a1(1)
     ELSE IF (cell%latnam.EQ.'c-b') THEN
        aTemp = a1(1)
        a1(1) = aTemp*0.5*sqrt(2.0)
        a1(2) = -aTemp*0.5
        a2(1) = aTemp*0.5*sqrt(2.0)
        a2(2) = aTemp*0.5
     ELSE IF (cell%latnam.EQ.'hex') THEN
        aTemp = 0.5*a1(1)
        a1(1) = aTemp*sqrt(3.0)
        a1(2) = -aTemp
        a2(1) = a1(1)
        a2(2) = aTemp
     ELSE IF (cell%latnam.EQ.'hx3') THEN
        aTemp = 0.5*a1(1)
        a1(1) = aTemp
        a1(2) = -aTemp*sqrt(3.0)
        a2(1) = a1(1)
        a2(2) = -a1(2)
     ELSE IF (cell%latnam.EQ.'fcc') THEN
        aTemp = a1(1)
        a1(1) =       0.0 ; a1(2) = 0.5*aTemp ; a1(3) = 0.5*aTemp
        a2(1) = 0.5*aTemp ; a2(2) =       0.0 ; a2(3) = 0.5*aTemp
        a3(1) = 0.5*aTemp ; a3(2) = 0.5*aTemp ; a3(3) =       0.0
     ELSE IF (cell%latnam.EQ.'bcc') THEN
        aTemp = a1(1)
For faster browsing, not all history is shown. View entire blame