fleur_init.F90 22.4 KB
Newer Older
1 2 3 4 5
!--------------------------------------------------------------------------------
! 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.
!--------------------------------------------------------------------------------
6 7 8
      MODULE m_fleur_init
      IMPLICIT NONE
      CONTAINS
9
        SUBROUTINE fleur_init(mpi,&
Daniel Wortmann's avatar
Daniel Wortmann committed
10
                 input,DIMENSION,atoms,sphhar,cell,stars,sym,noco,vacuum,&
11 12 13
                 sliceplot,banddos,obsolete,enpara,xcpot,results,jij,kpts,hybrid,&
                 oneD,l_opti)
          USE m_judft
14
          USE m_juDFT_init
15
          USE m_types
16
          USE m_rinpXML
17 18 19 20 21 22
          USE m_dimens
          USE m_inped
          USE m_setup
          USE m_gen_map
          USE m_dwigner
          USE m_gen_bz
23
          USE m_icorrkeys
24
          USE m_ylm
25
          USE m_InitParallelProcesses
26
          USE m_xmlOutput
27
          USE m_winpXML
Daniel Wortmann's avatar
Daniel Wortmann committed
28
          USE m_setupMPI
29 30 31 32 33 34 35
#ifdef CPP_MPI
          USE m_mpi_bc_all,  ONLY : mpi_bc_all
#endif
          IMPLICIT NONE
          !     Types, these variables contain a lot of data!
          TYPE(t_mpi)    ,INTENT(INOUT):: mpi
          TYPE(t_input)    ,INTENT(OUT):: input
Daniel Wortmann's avatar
Daniel Wortmann committed
36
          TYPE(t_dimension),INTENT(OUT):: DIMENSION
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
          TYPE(t_atoms)    ,INTENT(OUT):: atoms
          TYPE(t_sphhar)   ,INTENT(OUT):: sphhar
          TYPE(t_cell)     ,INTENT(OUT):: cell
          TYPE(t_stars)    ,INTENT(OUT):: stars
          TYPE(t_sym)      ,INTENT(OUT):: sym
          TYPE(t_noco)     ,INTENT(OUT):: noco
          TYPE(t_vacuum)   ,INTENT(OUT):: vacuum
          TYPE(t_sliceplot),INTENT(OUT):: sliceplot
          TYPE(t_banddos)  ,INTENT(OUT):: banddos
          TYPE(t_obsolete) ,INTENT(OUT):: obsolete 
          TYPE(t_enpara)   ,INTENT(OUT):: enpara
          TYPE(t_xcpot)    ,INTENT(OUT):: xcpot
          TYPE(t_results)  ,INTENT(OUT):: results
          TYPE(t_jij)      ,INTENT(OUT):: jij
          TYPE(t_kpts)     ,INTENT(OUT):: kpts
          TYPE(t_hybrid)   ,INTENT(OUT):: hybrid
          TYPE(t_oneD)     ,INTENT(OUT):: oneD
          LOGICAL,          INTENT(OUT):: l_opti
         

57 58 59 60 61 62
          INTEGER, ALLOCATABLE          :: xmlElectronStates(:,:)
          INTEGER, ALLOCATABLE          :: atomTypeSpecies(:)
          INTEGER, ALLOCATABLE          :: speciesRepAtomType(:)
          REAL, ALLOCATABLE             :: xmlCoreOccs(:,:,:)
          LOGICAL, ALLOCATABLE          :: xmlPrintCoreStates(:,:)
          CHARACTER(len=3), ALLOCATABLE :: noel(:)
63
          !     .. Local Scalars ..
64
          INTEGER    :: i,n,l,m1,m2,isym,iisym,numSpecies
65
          COMPLEX    :: cdum
66 67
          CHARACTER(len=4)              :: namex
          CHARACTER(len=12)             :: relcor
68
          CHARACTER(LEN=20)             :: filename
69 70
          REAL                          :: a1(3),a2(3),a3(3)
          REAL                          :: scale, dtild
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
#ifdef CPP_MPI
          INCLUDE 'mpif.h'
          INTEGER ierr(3)
          CALL MPI_COMM_RANK (mpi%mpi_comm,mpi%irank,ierr)
          CALL MPI_COMM_SIZE (mpi%mpi_comm,mpi%isize,ierr)

          sliceplot%iplot=.FALSE.
#else
          mpi%irank=0 ; mpi%isize=1; mpi%mpi_comm=1
#endif

          results%seigscv         = 0.0
          results%te_vcoul        = 0.0
          results%te_veff         = 0.0
          results%te_exc          = 0.0
          results%te_hfex%valence = 0.0
          results%te_hfex%core    = 0.0
          results%e_ldau          = 0.0
          results%ts              = 0.0
          input%gw                = -1
          input%gw_neigd          =  0
          !-t3e
          IF (mpi%irank.EQ.0) THEN
94
             CALL startXMLOutput()
95 96 97 98 99 100 101
#ifndef  __TOS_BGQ__
             !Do not open out-file on BlueGene
             OPEN (6,file='out',form='formatted',status='unknown')
#endif
             OPEN (16,file='inf',form='formatted',status='unknown')
          ENDIF

102
          input%l_inpXML = .FALSE.
103
          kpts%ntet = 1
104
          kpts%numSpecialPoints = 1
105
          INQUIRE (file='inp.xml',exist=input%l_inpXML)
106
          IF(.NOT.(juDFT_was_argument("-xmlInput").OR.juDFT_was_argument("-xml"))) THEN
107 108 109 110
             input%l_inpXML = .FALSE.
          END IF
          IF (input%l_inpXML) THEN
             IF (mpi%irank.EQ.0) THEN
111
                ALLOCATE(kpts%specialPoints(3,kpts%numSpecialPoints))
112 113 114 115 116 117 118 119 120
                ALLOCATE(noel(1),atomTypeSpecies(1),speciesRepAtomType(1))
                ALLOCATE(xmlElectronStates(1,1),xmlPrintCoreStates(1,1))
                ALLOCATE(xmlCoreOccs(1,1,1))
                namex = '    '
                relcor = '            '
                a1 = 0.0
                a2 = 0.0
                a3 = 0.0
                scale = 1.0
121
                CALL r_inpXML(&
Daniel Wortmann's avatar
Daniel Wortmann committed
122
                              atoms,obsolete,vacuum,input,stars,sliceplot,banddos,DIMENSION,&
123 124 125
                              cell,sym,xcpot,noco,Jij,oneD,hybrid,kpts,enpara,sphhar,l_opti,&
                              noel,namex,relcor,a1,a2,a3,scale,dtild,xmlElectronStates,&
                              xmlPrintCoreStates,xmlCoreOccs,atomTypeSpecies,speciesRepAtomType)
126

Daniel Wortmann's avatar
Daniel Wortmann committed
127
                ALLOCATE (results%force(3,atoms%ntype,DIMENSION%jspd))
128 129 130
                ALLOCATE (results%force_old(3,atoms%ntype))
                results%force(:,:,:) = 0.0

131
                filename = ''
132 133 134 135
                numSpecies = SIZE(speciesRepAtomType)
                CALL w_inpXML(&
     &                        atoms,obsolete,vacuum,input,stars,sliceplot,banddos,&
     &                        cell,sym,xcpot,noco,jij,oneD,hybrid,kpts,(/1,1,1/),kpts%l_gamma,&
136
     &                        noel,namex,relcor,a1,a2,a3,scale,dtild,input%comment,&
137
     &                        xmlElectronStates,xmlPrintCoreStates,xmlCoreOccs,&
138
     &                        atomTypeSpecies,speciesRepAtomType,.TRUE.,filename,&
139
     &                        .TRUE.,numSpecies,enpara)
140 141
                DEALLOCATE(noel,atomTypeSpecies,speciesRepAtomType)
                DEALLOCATE(xmlElectronStates,xmlPrintCoreStates,xmlCoreOccs)
142
             END IF
143 144 145

#ifdef CPP_MPI
             CALL initParallelProcesses(atoms,vacuum,input,stars,sliceplot,banddos,&
Daniel Wortmann's avatar
Daniel Wortmann committed
146
                                        DIMENSION,cell,sym,xcpot,noco,jij,oneD,hybrid,&
147 148 149
                                        kpts,enpara,sphhar,mpi,results,obsolete)
#endif

150 151
          ELSE ! else branch of "IF (input%l_inpXML) THEN"

152
          CALL dimens(&
153
               &            mpi,input,&
154 155
               &            sym,stars,&
               &            atoms,sphhar,&
Daniel Wortmann's avatar
Daniel Wortmann committed
156
               &            DIMENSION,vacuum,&
157 158 159 160
               &            obsolete,kpts,&
               &            oneD,hybrid,Jij)


Daniel Wortmann's avatar
Daniel Wortmann committed
161 162
          DIMENSION%nn2d= (2*stars%k1d+1)* (2*stars%k2d+1)
          DIMENSION%nn3d= (2*stars%k1d+1)* (2*stars%k2d+1)* (2*stars%k3d+1)
163 164 165 166 167 168 169 170
          !-odim
          IF (oneD%odd%d1) THEN
             oneD%odd%k3 = stars%k3d
             oneD%odd%nn2d = (2*(oneD%odd%k3) + 1)*(2*(oneD%odd%M) + 1)
          ELSE
             oneD%odd%k3 = 0 ; oneD%odd%M =0 ; oneD%odd%nn2d = 1
          ENDIF
          !-odim
Gregor Michalicek's avatar
Gregor Michalicek committed
171
          atoms%nat = atoms%natd ! This is preliminary. The value of nat changes later.
172 173 174 175
          ALLOCATE ( atoms%nz(atoms%ntypd),atoms%relax(3,atoms%ntypd),atoms%nlhtyp(atoms%ntype))
          ALLOCATE ( sphhar%clnu(sphhar%memd,0:sphhar%nlhd,sphhar%ntypsd),stars%ustep(stars%n3d) )
          ALLOCATE ( stars%ig(-stars%k1d:stars%k1d,-stars%k2d:stars%k2d,-stars%k3d:stars%k3d),stars%ig2(stars%n3d),stars%igz(stars%n3d) )
          ALLOCATE ( atoms%jri(atoms%ntypd),stars%kv2(2,stars%n2d),stars%kv3(3,stars%n3d),sphhar%llh(0:sphhar%nlhd,sphhar%ntypsd) )
176
          ALLOCATE (sym%mrot(3,3,sym%nop),sym%tau(3,sym%nop))
177 178 179 180
          ALLOCATE ( atoms%lmax(atoms%ntypd),sphhar%mlh(sphhar%memd,0:sphhar%nlhd,sphhar%ntypsd))!,sym%mrot(3,3,sym%nop) )
          ALLOCATE ( atoms%ncv(atoms%ntypd),atoms%neq(atoms%ntypd),atoms%ngopr(atoms%natd) )
          ALLOCATE ( sphhar%nlh(sphhar%ntypsd),sphhar%nmem(0:sphhar%nlhd,sphhar%ntypsd) )
          ALLOCATE ( stars%nstr2(stars%n2d),atoms%ntypsy(atoms%natd),stars%nstr(stars%n3d) )
Daniel Wortmann's avatar
Daniel Wortmann committed
181
          ALLOCATE ( stars%igfft(0:DIMENSION%nn3d-1,2),stars%igfft2(0:DIMENSION%nn2d-1,2),atoms%nflip(atoms%ntypd) )
182 183 184 185 186 187 188 189 190 191
          ALLOCATE ( atoms%ncst(atoms%ntypd) )
          ALLOCATE ( vacuum%izlay(vacuum%layerd,2) )
          ALLOCATE ( sym%invarop(atoms%natd,sym%nop),sym%invarind(atoms%natd) )
          ALLOCATE ( sym%multab(sym%nop,sym%nop),sym%invtab(sym%nop) )
          ALLOCATE ( atoms%invsat(atoms%natd),sym%invsatnr(atoms%natd) )
          ALLOCATE ( atoms%lnonsph(atoms%ntypd) )
          ALLOCATE ( atoms%dx(atoms%ntypd),atoms%pos(3,atoms%natd))!,sym%tau(3,sym%nop) )
          ALLOCATE ( atoms%rmsh(atoms%jmtd,atoms%ntypd),atoms%rmt(atoms%ntypd),stars%sk2(stars%n2d),stars%sk3(stars%n3d) )
          ALLOCATE ( stars%phi2(stars%n2d) )
          ALLOCATE ( atoms%taual(3,atoms%natd),atoms%volmts(atoms%ntypd),atoms%zatom(atoms%ntypd) )
Daniel Wortmann's avatar
Daniel Wortmann committed
192 193 194
          ALLOCATE ( enpara%el0(0:atoms%lmaxd,atoms%ntypd,DIMENSION%jspd) )
          ALLOCATE ( enpara%evac0(2,DIMENSION%jspd),stars%rgphs(-stars%k1d:stars%k1d,-stars%k2d:stars%k2d,-stars%k3d:stars%k3d)  )
          ALLOCATE ( results%force(3,atoms%ntypd,DIMENSION%jspd) )
195 196
          ALLOCATE ( results%force_old(3,atoms%ntypd) )
          ALLOCATE ( kpts%bk(3,kpts%nkptd),kpts%wtkpt(kpts%nkptd) )
Daniel Wortmann's avatar
Daniel Wortmann committed
197
          ALLOCATE ( stars%pgfft(0:DIMENSION%nn3d-1),stars%pgfft2(0:DIMENSION%nn2d-1) )
198 199
          ALLOCATE ( stars%ufft(0:27*stars%k1d*stars%k2d*stars%k3d-1) )
          ALLOCATE ( atoms%bmu(atoms%ntypd),atoms%vr0(atoms%ntypd) )
Daniel Wortmann's avatar
Daniel Wortmann committed
200 201 202 203
          ALLOCATE ( enpara%lchange(0:atoms%lmaxd,atoms%ntypd,DIMENSION%jspd) )
          ALLOCATE ( enpara%lchg_v(2,DIMENSION%jspd),atoms%l_geo(atoms%ntypd) )
          ALLOCATE ( atoms%nlo(atoms%ntypd),atoms%llo(atoms%nlod,atoms%ntypd),enpara%skiplo(atoms%ntypd,DIMENSION%jspd) )
          ALLOCATE ( enpara%ello0(atoms%nlod,atoms%ntypd,DIMENSION%jspd),enpara%llochg(atoms%nlod,atoms%ntypd,DIMENSION%jspd) )
204
          ALLOCATE ( atoms%lo1l(0:atoms%llod,atoms%ntypd),atoms%nlol(0:atoms%llod,atoms%ntypd),atoms%lapw_l(atoms%ntypd) )
205
          ALLOCATE ( noco%alphInit(atoms%ntypd),noco%alph(atoms%ntypd),noco%beta(atoms%ntypd),noco%l_relax(atoms%ntypd) )
206 207 208
          ALLOCATE ( jij%alph1(atoms%ntypd),jij%l_magn(atoms%ntypd),jij%M(atoms%ntypd) )
          ALLOCATE ( jij%magtype(atoms%ntypd),jij%nmagtype(atoms%ntypd) )
          ALLOCATE ( noco%b_con(2,atoms%ntypd),atoms%lda_u(atoms%ntypd),atoms%l_dulo(atoms%nlod,atoms%ntypd) )
Daniel Wortmann's avatar
Daniel Wortmann committed
209
          ALLOCATE ( enpara%enmix(DIMENSION%jspd),sym%d_wgn(-3:3,-3:3,3,sym%nop) )
210 211
          ALLOCATE ( atoms%ulo_der(atoms%nlod,atoms%ntypd) )
          ALLOCATE ( noco%soc_opt(atoms%ntypd+2) )
212
          ALLOCATE ( atoms%numStatesProvided(atoms%ntypd))
213
          ALLOCATE ( kpts%ntetra(4,kpts%ntet), kpts%voltet(kpts%ntet))
214 215 216 217 218 219 220 221 222 223 224 225 226
          !+odim
          ALLOCATE ( oneD%ig1(-oneD%odd%k3:oneD%odd%k3,-oneD%odd%M:oneD%odd%M) )
          ALLOCATE ( oneD%kv1(2,oneD%odd%n2d),oneD%nstr1(oneD%odd%n2d) )
          ALLOCATE ( oneD%ngopr1(atoms%natd),oneD%mrot1(3,3,oneD%odd%nop),oneD%tau1(3,oneD%odd%nop) )
          ALLOCATE ( oneD%invtab1(oneD%odd%nop),oneD%multab1(oneD%odd%nop,oneD%odd%nop) )
          ALLOCATE ( oneD%igfft1(0:oneD%odd%nn2d-1,2),oneD%pgfft1(0:oneD%odd%nn2d-1) )
          stars%sk2(:) = 0.0 ; stars%phi2(:) = 0.0
          !-odim

          ! HF/hybrid functionals/EXX
          ALLOCATE ( hybrid%nindx(0:atoms%lmaxd,atoms%ntypd) )
          ALLOCATE ( hybrid%select1(4,atoms%ntypd),hybrid%lcutm1(atoms%ntypd),&
               &           hybrid%select2(4,atoms%ntypd),hybrid%lcutm2(atoms%ntypd),hybrid%lcutwf(atoms%ntypd) )
Daniel Wortmann's avatar
Daniel Wortmann committed
227
          ALLOCATE ( hybrid%ddist(DIMENSION%jspd) )
228 229 230
          hybrid%ddist     = 1.
          !

231
          atoms%numStatesProvided(:) = 0
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

          atoms%vr0(:)         = 0.0
          jij%M(:)             = 0.0
          jij%l_magn(:)        =.FALSE.
          results%force(:,:,:) = 0.0

          CALL timestart("preparation:stars,lattice harmonics,+etc")
          !--- J< 
          jij%l_wr=.TRUE.
          jij%nqptd=1
          jij%nmagn=1
          jij%mtypes=1
          jij%phnd=1
          !--- J>
          !+t3e
          IF (mpi%irank.EQ.0) THEN
             !-t3e
             CALL inped( &
                  &           atoms,obsolete,vacuum,&
                  &           input,banddos,xcpot,sym,&
                  &           cell,sliceplot,noco,&
                  &           stars,oneD,jij,hybrid,kpts)
             !
             IF (xcpot%igrd.NE.0) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
256
                ALLOCATE (stars%ft2_gfx(0:DIMENSION%nn2d-1),stars%ft2_gfy(0:DIMENSION%nn2d-1))
257 258 259 260 261 262 263 264 265 266 267 268 269
                !-odim
                ALLOCATE (oneD%pgft1x(0:oneD%odd%nn2d-1),oneD%pgft1xx(0:oneD%odd%nn2d-1),&
                     &             oneD%pgft1xy(0:oneD%odd%nn2d-1),&
                     &             oneD%pgft1y(0:oneD%odd%nn2d-1),oneD%pgft1yy(0:oneD%odd%nn2d-1))
             ELSE
                ALLOCATE (stars%ft2_gfx(0:1),stars%ft2_gfy(0:1))
                !-odim
                ALLOCATE (oneD%pgft1x(0:1),oneD%pgft1xx(0:1),oneD%pgft1xy(0:1),&
                     &             oneD%pgft1y(0:1),oneD%pgft1yy(0:1))
             ENDIF
             oneD%odd%nq2 = oneD%odd%n2d
             !-odim
             !+t3e
270
             INQUIRE(file="cdn1",exist=l_opti)
Daniel Wortmann's avatar
Daniel Wortmann committed
271 272
             IF (noco%l_noco) INQUIRE(file="rhomat_inp",exist=l_opti)
             l_opti=.NOT.l_opti
273 274 275 276 277 278 279 280 281 282 283
             IF ((sliceplot%iplot).OR.(input%strho).OR.(input%swsp).OR.&
                  &    (input%lflip).OR.(obsolete%l_f2u).OR.(obsolete%l_u2f).OR.(input%l_bmt)) l_opti = .TRUE.

             obsolete%form76 = .FALSE.
             IF (noco%l_soc.AND.obsolete%form66) THEN
                IF (.NOT.input%eonly)  CALL juDFT_error("form66 = T only with eonly = T !",calledby="fleur")
                obsolete%form66 = .FALSE.
                obsolete%form76 = .TRUE.
             ENDIF
             !
             CALL setup(&
Daniel Wortmann's avatar
Daniel Wortmann committed
284
                  &     atoms,kpts,DIMENSION,sphhar,&
285 286 287 288 289 290 291 292
                  &     obsolete,sym,stars,oneD,input,noco,&
                  &     vacuum,cell,xcpot,&
                  &     sliceplot,enpara,l_opti)
             !
             stars%ng3=stars%ng3 ; stars%ng2=stars%ng2 
             !+t3e
          ENDIF ! mpi%irank.eq.0
          CALL timestop("preparation:stars,lattice harmonics,+etc")
293 294 295

          END IF ! end of else branch of "IF (input%l_inpXML) THEN"

Daniel Wortmann's avatar
Daniel Wortmann committed
296 297 298
          !Finalize the MPI setup
          CALL setupMPI(kpts%nkpt,mpi)

299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
          !
          !-odim
          oneD%odd%nq2 = oneD%odd%n2d
          oneD%odd%kimax2 = oneD%odd%nq2 - 1
          oneD%odd%nat = atoms%natd

          oneD%odi%d1 = oneD%odd%d1 ; oneD%odi%mb = oneD%odd%mb ; oneD%odi%M = oneD%odd%M
          oneD%odi%k3 = oneD%odd%k3 ; oneD%odi%chi = oneD%odd%chi ; oneD%odi%rot = oneD%odd%rot
          oneD%odi%invs = oneD%odd%invs ; oneD%odi%zrfs = oneD%odd%zrfs
          oneD%odi%n2d = oneD%odd%n2d ; oneD%odi%nq2 = oneD%odd%nq2 ; oneD%odi%nn2d = oneD%odd%nn2d
          oneD%odi%kimax2 = oneD%odd%kimax2 ; oneD%odi%m_cyl = oneD%odd%m_cyl
          oneD%odi%ig => oneD%ig1 ; oneD%odi%kv => oneD%kv1 ; oneD%odi%nst2 => oneD%nstr1

          oneD%ods%nop = oneD%odd%nop ; oneD%ods%nat = oneD%odd%nat
          oneD%ods%mrot => oneD%mrot1 ; oneD%ods%tau => oneD%tau1 ; oneD%ods%ngopr => oneD%ngopr1
          oneD%ods%invtab => oneD%invtab1 ; oneD%ods%multab => oneD%multab1

          oneD%odl%nn2d = oneD%odd%nn2d
          oneD%odl%igf => oneD%igfft1 ; oneD%odl%pgf => oneD%pgfft1

          oneD%odg%nn2d = oneD%odd%nn2d
          oneD%odg%pgfx => oneD%pgft1x ; oneD%odg%pgfy => oneD%pgft1y
          oneD%odg%pgfxx => oneD%pgft1xx ; oneD%odg%pgfyy => oneD%pgft1yy ; oneD%odg%pgfxy => oneD%pgft1xy
          !+odim
          !
#ifdef CPP_MPI
          CALL MPI_BCAST(l_opti,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(noco%l_noco,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(noco%l_soc,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(input%strho ,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(input%jspins,1,MPI_INTEGER,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(atoms%n_u,1,MPI_INTEGER,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(atoms%lmaxd,1,MPI_INTEGER,0,mpi%mpi_comm,ierr)
#endif
          CALL ylmnorm_init(atoms%lmaxd)
          !
          !--> determine more dimensions
          !
Daniel Wortmann's avatar
Daniel Wortmann committed
337 338 339
          DIMENSION%nbasfcn = DIMENSION%nvd + atoms%natd*atoms%nlod*(2*atoms%llod+1)
          DIMENSION%lmd     = atoms%lmaxd* (atoms%lmaxd+2)
          DIMENSION%lmplmd  = (DIMENSION%lmd* (DIMENSION%lmd+3))/2
340

Daniel Wortmann's avatar
Daniel Wortmann committed
341
       
342
          IF (mpi%irank.EQ.0) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
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
             !--- J< 
             jij%l_jenerg = .FALSE.
             IF (jij%l_J) THEN
                OPEN (113,file='qpts',status='old')
                INQUIRE(file='jenerg',exist=jij%l_jenerg)
                OPEN (114,file='jenerg',status='unknown')
                READ (113,*) jij%nqptd
             ENDIF
          ENDIF!(mpi%irank.EQ.0)

#ifdef CPP_MPI
          CALL MPI_BCAST(jij%nqptd,1,MPI_INTEGER,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(jij%l_jenerg,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
#endif
          ALLOCATE ( jij%qj(3,jij%nqptd) )
          jij%nqpt=jij%nqptd
          !+t3e
          IF (mpi%irank.EQ.0) THEN
             !-t3e
             IF (jij%l_J) THEN
                IF(jij%l_disp)THEN
                   WRITE(6,*) 'q points for the magnon spectrum calculation:'
                ELSE
                   WRITE(6,*) 'q points for the J-constants calculation:'
                ENDIF
                WRITE(6,*)'      q1       ','      q2       ','      q3'
                DO i=1,jij%nqpt
                   READ (113,3333) jij%qj(1:3,i)
                   WRITE(6,3333) jij%qj(1:3,i)
                ENDDO
3333            FORMAT(3(f14.10,1x))
             ENDIF !(jij%l_J)
             !+t3e
          ENDIF
          !-t3e
          !--- J>


#ifdef CPP_MPI
          CALL mpi_bc_all(&
               &           mpi,stars,sphhar,atoms,obsolete,&
Daniel Wortmann's avatar
Daniel Wortmann committed
385
               &           sym,kpts,jij,DIMENSION,input,&
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 412 413 414 415 416 417 418 419 420 421 422 423
               &           banddos,sliceplot,vacuum,cell,enpara,&
               &           noco,oneD,xcpot,hybrid)
          ! initialize record length of the eig file

#endif 
          atoms%nlotot = 0
          DO n = 1, atoms%ntype
             DO l = 1,atoms%nlo(n)
                atoms%nlotot = atoms%nlotot + atoms%neq(n) * ( 2*atoms%llo(l,n) + 1 )
             ENDDO
          ENDDO


          jij%qn = 0.0
          !-t3e
          !-odim
          oneD%odd%nq2 = oneD%odd%n2d
          oneD%odd%kimax2 = oneD%odd%nq2 - 1
          oneD%odd%nat = atoms%natd

          oneD%odi%d1 = oneD%odd%d1 ; oneD%odi%mb = oneD%odd%mb ; oneD%odi%M = oneD%odd%M
          oneD%odi%k3 = oneD%odd%k3 ; oneD%odi%chi = oneD%odd%chi ; oneD%odi%rot = oneD%odd%rot
          oneD%odi%invs = oneD%odd%invs ; oneD%odi%zrfs = oneD%odd%zrfs
          oneD%odi%n2d = oneD%odd%n2d ; oneD%odi%nq2 = oneD%odd%nq2 ; oneD%odi%nn2d = oneD%odd%nn2d
          oneD%odi%kimax2 = oneD%odd%kimax2 ; oneD%odi%m_cyl = oneD%odd%m_cyl
          oneD%odi%ig => oneD%ig1 ; oneD%odi%kv => oneD%kv1 ; oneD%odi%nst2 => oneD%nstr1

          oneD%ods%nop = oneD%odd%nop ; oneD%ods%nat = oneD%odd%nat
          oneD%ods%mrot => oneD%mrot1 ; oneD%ods%tau => oneD%tau1 ; oneD%ods%ngopr => oneD%ngopr1
          oneD%ods%invtab => oneD%invtab1 ; oneD%ods%multab => oneD%multab1

          oneD%odl%nn2d = oneD%odd%nn2d
          oneD%odl%igf => oneD%igfft1 ; oneD%odl%pgf => oneD%pgfft1

          oneD%odg%nn2d = oneD%odd%nn2d
          oneD%odg%pgfx => oneD%pgft1x ; oneD%odg%pgfy => oneD%pgft1y
          oneD%odg%pgfxx => oneD%pgft1xx ; oneD%odg%pgfyy => oneD%pgft1yy ; oneD%odg%pgfxy => oneD%pgft1xy
          !+odim
Daniel Wortmann's avatar
Daniel Wortmann committed
424
          IF (noco%l_noco) DIMENSION%nbasfcn = 2*DIMENSION%nbasfcn
425 426 427 428 429 430
          !
          !--- J<
          IF (jij%l_J) THEN
             input%itmax = 1
             jij%phnd=2
             jij%nkpt_l = CEILING(REAL(kpts%nkptd)/mpi%isize)
Daniel Wortmann's avatar
Daniel Wortmann committed
431
             ALLOCATE ( jij%eig_l(DIMENSION%neigd+5,jij%nkpt_l) )
432 433
          ELSE
             jij%nkpt_l = 1
Daniel Wortmann's avatar
Daniel Wortmann committed
434
             ALLOCATE ( jij%eig_l(DIMENSION%neigd+5,1) )
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
          ENDIF
          !--- J>


          IF( sym%invs .OR. noco%l_soc ) THEN
             sym%nsym = sym%nop
          ELSE
             ! combine time reversal symmetry with the spatial symmetry opera
             ! thus the symmetry operations are doubled
             sym%nsym = 2*sym%nop
          END IF


          IF (    (xcpot%icorr.EQ.icorr_hf ) .OR. (xcpot%icorr.EQ.icorr_pbe0)&
               &    .OR.(xcpot%icorr.EQ.icorr_exx) .OR. (xcpot%icorr.EQ.icorr_hse)&
               &    .OR.(xcpot%icorr.EQ.icorr_vhse) ) THEN
             IF (input%film .OR. oneD%odi%d1)&
                  &    CALL juDFT_error("2D film and 1D calculations not implemented"&
                  &                 //"for HF/EXX/PBE0/HSE", calledby ="fleur",&
                  &                 hint="Use a supercell or a different functional")

             IF( ANY( atoms%l_geo  ) )&
                  &     CALL juDFT_error("Forces not implemented for HF/PBE0/HSE ",&
                  &                    calledby ="fleur")

             IF (.NOT. obsolete%pot8) STOP 'Choose pot8=T'
             !calculate whole Brilloun zone
             CALL gen_bz(kpts,sym)
             CALL gen_map(&
                  &          atoms,sym,oneD,hybrid)
             !
             ! calculate d_wgn
             !
             ALLOCATE (hybrid%d_wgn2(-atoms%lmaxd:atoms%lmaxd,-atoms%lmaxd:atoms%lmaxd,0:atoms%lmaxd,sym%nsym))
             CALL d_wigner(sym%nop,sym%mrot,cell%bmat,atoms%lmaxd,hybrid%d_wgn2(:,:,1:,:sym%nop))
             hybrid%d_wgn2(:,:,0,:) = 1

             DO isym = sym%nop+1,sym%nsym
                iisym = isym - sym%nop
                DO l = 0,atoms%lmaxd
                   DO m2 = -l,l
                      DO m1 = -l,-1
                         cdum                  = hybrid%d_wgn2( m1,m2,l,iisym)
                         hybrid%d_wgn2( m1,m2,l,isym) = hybrid%d_wgn2(-m1,m2,l,iisym)*(-1)**m1
                         hybrid%d_wgn2(-m1,m2,l,isym) = cdum                  *(-1)**m1
                      END DO
                      hybrid%d_wgn2(0,m2,l,isym) = hybrid%d_wgn2(0,m2,l,iisym)
                   END DO
                END DO
             END DO
          ELSE
             IF ( banddos%dos .AND. banddos%ndir == -3 ) THEN
                CALL gen_bz(kpts,sym)
             END IF
             ALLOCATE(hybrid%map(0,0),hybrid%tvec(0,0,0),hybrid%d_wgn2(0,0,0,0))
             hybrid%l_calhf   = .FALSE.
          END IF

Daniel Wortmann's avatar
Daniel Wortmann committed
493 494 495 496
          !new check mode will only run the init-part of FLEUR
          IF (judft_was_argument("-check")) CALL judft_end("Check-mode done",mpi%irank)


497 498
     END SUBROUTINE
     END MODULE