fleur.F90 18.6 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
MODULE m_fleur
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  IMPLICIT NONE
CONTAINS
  SUBROUTINE fleur_execute(mpi_comm)

    !     ***************************************************************
    !
    !     based on flapw7 (c.l.fu, m.weinert, e.wimmer):
    !     full potential linearized augmented plane wave method for thin
    !     films and superlattices (version 7 ---- general symmetry)
    !     symmetry part       ---  e.wimmer
    !     potential generator ---  c.l.fu,r.podloucky
    !     matrix elements     ---  m.weinert
    !     charge density      ---  c.l.fu
    !                                c.l.fu        1987
    !     2nd variation diagon.  --- r.-q. wu      1992
    !     forces a la Yu et al   --- r.podloucky   1995
    !     full relativistic core --- a.shick       1996
    !     broyden mixing         --- r.pentcheva   1996
    !     gga (pw91, pbe)        --- t.asada       1997
    !     local orbitals         --- p.kurz        1997
    !     automatic symmetry     --- w.hofer       1997
    !     core tails & start     --- r.abt         1998
    !     spin orbit coupling    --- a.shick,x.nie 1998
    !     non-colinear magnet.   --- p.kurz        1999
    !     one-dimensional        --- y.mokrousov   2002
    !     exchange parameters    --- m.lezaic      2004
    !
    !                       g.bihlmayer, s.bluegel 1999
    !     ***************************************************************
    !----------------------------------------
    ! this routine is the main PROGRAM

    USE m_types
    USE m_constants
    USE m_fleur_init
    USE m_optional
43
    USE m_cdn_io
44
    USE m_broyd_io
45
    USE m_qfix
46 47 48 49 50 51 52 53 54 55 56 57 58 59
    USE m_vgen
    USE m_writexcstuff
    USE m_vmatgen
    USE m_eigen
    USE m_eigenso
    USE m_fermie
    USE m_force0
    USE m_cdngen
    USE m_totale
    USE m_potdis
    USE m_mix
    USE m_xmlOutput
    USE m_juDFT_time
    USE m_calc_hybrid
60
    USE m_rdmft
61 62 63 64 65 66
    USE m_wann_optional
    USE m_wannier
    USE m_bs_comfort
    USE m_gen_map
    USE m_dwigner
    USE m_ylm
67
#ifdef CPP_MPI
68
    USE m_mpi_bc_potden
69
#endif
70
    USE m_eig66_io
71
    USE m_chase_diag
72 73
    IMPLICIT NONE

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
    INTEGER, INTENT(IN)             :: mpi_comm

    TYPE(t_input)                   :: input
    TYPE(t_field)                   :: field, field2
    TYPE(t_dimension)               :: DIMENSION
    TYPE(t_atoms)                   :: atoms
    TYPE(t_sphhar)                  :: sphhar
    TYPE(t_cell)                    :: cell
    TYPE(t_stars)                   :: stars
    TYPE(t_sym)                     :: sym
    TYPE(t_noco)                    :: noco
    TYPE(t_vacuum)                  :: vacuum
    TYPE(t_sliceplot)               :: sliceplot
    TYPE(t_banddos)                 :: banddos
    TYPE(t_obsolete)                :: obsolete
    TYPE(t_enpara)                  :: enpara
    TYPE(t_results)                 :: results
    TYPE(t_kpts)                    :: kpts
    TYPE(t_hybrid)                  :: hybrid
    TYPE(t_oneD)                    :: oneD
    TYPE(t_mpi)                     :: mpi
    TYPE(t_coreSpecInput)           :: coreSpecInput
    TYPE(t_wann)                    :: wann
    TYPE(t_potden)                  :: vTot, vx, vCoul, vTemp
    TYPE(t_potden)                  :: inDen, outDen
    CLASS(t_xcpot),     ALLOCATABLE :: xcpot
    CLASS(t_forcetheo), ALLOCATABLE :: forcetheo

    ! local scalars
    INTEGER :: eig_id,archiveType
104
    INTEGER :: n,iter,iterHF
105 106
    LOGICAL :: l_opti,l_cont,l_qfix,l_wann_inp,l_real
    REAL    :: fermiEnergyTemp,fix
107
#ifdef CPP_MPI
108
    INCLUDE 'mpif.h'
109
    INTEGER :: ierr(2)
110
#endif
Gregor Michalicek's avatar
Gregor Michalicek committed
111

112
    mpi%mpi_comm = mpi_comm
113

114
    CALL timestart("Initialization")
115 116
    CALL fleur_init(mpi,input,field,DIMENSION,atoms,sphhar,cell,stars,sym,noco,vacuum,forcetheo,sliceplot,&
                    banddos,obsolete,enpara,xcpot,results,kpts,hybrid,oneD,coreSpecInput,wann,l_opti)
117
    CALL timestop("Initialization")
Daniel Wortmann's avatar
Daniel Wortmann committed
118

119 120 121
    IF((input%preconditioning_param /= 0).AND.input%film) THEN
       CALL juDFT_error('Currently no preconditioner for films', calledby = 'fleur')
    END IF
122

123 124
    IF (l_opti) CALL optional(mpi,atoms,sphhar,vacuum,dimension,&
                              stars,input,sym,cell,sliceplot,obsolete,xcpot,noco,oneD)
125

126
    !+Wannier (start)
127 128
    INQUIRE (file='wann_inp',exist=l_wann_inp)
    input%l_wann = input%l_wann.OR.l_wann_inp
129 130
    IF (input%l_wann.AND.(mpi%irank==0).AND.(.NOT.wann%l_bs_comf)) THEN
       IF(mpi%isize.NE.1) CALL juDFT_error('No Wannier+MPI at the moment',calledby = 'fleur')
131
       CALL wann_optional(input,kpts,atoms,sym,cell,oneD,noco,wann)
132 133
    END IF
    IF (wann%l_gwf) input%itmax = 1
134
    !-Wannier (end)
135

136 137 138
    iter     = 0
    iterHF   = 0
    l_cont = (iter < input%itmax)
139
    
140 141
    IF (mpi%irank.EQ.0) CALL openXMLElementNoAttributes('scfLoop')

142
    ! Initialize and load inDen density (start)
143
    CALL inDen%init(stars,atoms,sphhar,vacuum,input%jspins,noco%l_noco,POTDEN_TYPE_DEN)
144 145
    archiveType = CDN_ARCHIVE_TYPE_CDN1_const
    IF (noco%l_noco) archiveType = CDN_ARCHIVE_TYPE_NOCO_const
146 147
    IF(mpi%irank.EQ.0) THEN
       CALL readDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
148
                        0,fermiEnergyTemp,l_qfix,inDen)
149
       CALL timestart("Qfix")
150
       CALL qfix(stars,atoms,sym,vacuum, sphhar,input,cell,oneD,inDen,noco%l_noco,.FALSE.,.false.,fix)
151 152
       CALL timestop("Qfix")
       CALL writeDensity(stars,vacuum,atoms,cell,sphhar,input,sym,oneD,archiveType,CDN_INPUT_DEN_const,&
153
                         0,-1.0,fermiEnergyTemp,.FALSE.,inDen)
154
    END IF
155
    ! Initialize and load inDen density (end)
156

157
    ! Initialize potentials (start)
158 159 160 161
    CALL vTot%init(stars,atoms,sphhar,vacuum,DIMENSION%jspd,noco%l_noco,POTDEN_TYPE_POTTOT)
    CALL vCoul%init(stars,atoms,sphhar,vacuum,DIMENSION%jspd,noco%l_noco,POTDEN_TYPE_POTCOUL)
    CALL vx%init(stars,atoms,sphhar,vacuum,DIMENSION%jspd,.FALSE.,POTDEN_TYPE_POTCOUL)
    CALL vTemp%init(stars,atoms,sphhar,vacuum,DIMENSION%jspd,noco%l_noco,POTDEN_TYPE_POTTOT)
162
    ! Initialize potentials (end)
163

164
    ! Open/allocate eigenvector storage (start)
165 166 167 168 169 170 171
    l_real=sym%invs.AND..NOT.noco%l_noco
    eig_id=open_eig(mpi%mpi_comm,DIMENSION%nbasfcn,DIMENSION%neigd,kpts%nkpt,DIMENSION%jspd,&
                    noco%l_noco,.TRUE.,l_real,noco%l_soc,.FALSE.,mpi%n_size)

#ifdef CPP_CHASE
    CALL init_chase(mpi,dimension,atoms,kpts,noco,sym%invs.AND..NOT.noco%l_noco)
#endif
172
    ! Open/allocate eigenvector storage (end)
173

174
    scfloop:DO WHILE (l_cont)
175

176
       iter = iter + 1
177
       IF (mpi%irank.EQ.0) CALL openXMLElementFormPoly('iteration',(/'numberForCurrentRun','overallNumber      '/),&
178
                                                       (/iter,inden%iter/), RESHAPE((/19,13,5,5/),(/2,2/)))
Gregor Michalicek's avatar
Gregor Michalicek committed
179

180 181 182
!!$       !+t3e
!!$       IF (input%alpha.LT.10.0) THEN
!!$
183
!!$          IF (iter.GT.1) THEN
184 185 186 187 188 189
!!$             input%alpha = input%alpha - NINT(input%alpha)
!!$          END IF

       CALL resetIterationDependentTimers()
       CALL timestart("Iteration")
       IF (mpi%irank.EQ.0) THEN
190 191 192
          WRITE (6,FMT=8100) iter
          WRITE (16,FMT=8100) iter
8100      FORMAT (/,10x,'   iter=  ',i5)
193
       ENDIF !mpi%irank.eq.0
194
       input%total = .TRUE.
195

196
#ifdef CPP_MPI
197
       CALL mpi_bc_potden(mpi,stars,sphhar,atoms,input,vacuum,oneD,noco,inDen)
198 199
#endif

200 201
       dimension%neigd2 = dimension%neigd
       IF (noco%l_soc) dimension%neigd2 = dimension%neigd*2
202 203

       !HF
204 205 206
       IF (hybrid%l_hybrid) THEN
          SELECT TYPE(xcpot)
          TYPE IS(t_xcpot_inbuild)
207 208
             CALL calc_hybrid(eig_id,hybrid,kpts,atoms,input,DIMENSION,mpi,noco,&
                              cell,oneD,enpara,results,sym,xcpot,vTot,iter,iterHF)
209
          END SELECT
210 211 212 213
          IF(hybrid%l_calhf) THEN
             CALL system("rm broyd*")
             iter = 0
          END IF
214
       ENDIF
215 216 217

       CALL reset_eig(eig_id,noco%l_soc) ! This has to be placed after the calc_hybrid call but before eigen

218 219 220 221 222 223 224 225 226 227 228 229 230 231
       !#endif

!!$             DO pc = 1, wann%nparampts
!!$                !---> gwf
!!$                IF (wann%l_sgwf.OR.wann%l_ms) THEN
!!$                   noco%qss(:) = wann%param_vec(:,pc)
!!$                   noco%alph(:) = wann%param_alpha(:,pc)
!!$                ELSE IF (wann%l_socgwf) THEN
!!$                   IF(wann%l_dim(2)) noco%phi   = tpi_const * wann%param_vec(2,pc)
!!$                   IF(wann%l_dim(3)) noco%theta = tpi_const * wann%param_vec(3,pc)
!!$                END IF
       !---< gwf

       CALL timestart("generation of potential")
232 233
       CALL vgen(hybrid,field,input,xcpot,DIMENSION,atoms,sphhar,stars,vacuum,sym,&
                 obsolete,cell,oneD,sliceplot,mpi,results,noco,inDen,vTot,vx,vCoul)
234 235
       CALL timestop("generation of potential")

236
#ifdef CPP_MPI
237
       CALL MPI_BARRIER(mpi%mpi_comm,ierr)
238 239
#endif

240
       CALL forcetheo%start()
241
       forcetheoloop:DO WHILE(forcetheo%next_job(iter==input%itmax,noco))
242 243 244 245

          CALL timestart("generation of hamiltonian and diagonalization (total)")
          CALL timestart("eigen")
          vTemp = vTot
246
          CALL timestart("Updating energy parameters")
247
          CALL enpara%update(mpi,atoms,vacuum,input,vToT)
248
          CALL timestop("Updating energy parameters")
249
          CALL eigen(mpi,stars,sphhar,atoms,obsolete,xcpot,sym,kpts,DIMENSION,vacuum,input,&
250
                     cell,enpara,banddos,noco,oneD,hybrid,iter,eig_id,results,inDen,vTemp,vx)
251 252 253
          vTot%mmpMat = vTemp%mmpMat
!!$          eig_idList(pc) = eig_id
          CALL timestop("eigen")
254 255

          ! add all contributions to total energy
256
#ifdef CPP_MPI
257 258
          ! send all result of local total energies to the r
          IF (mpi%irank==0) THEN
259 260
             CALL MPI_Reduce(MPI_IN_PLACE,results%te_hfex%valence,1,MPI_REAL8,MPI_SUM,0,mpi%mpi_comm,ierr(1))
             CALL MPI_Reduce(MPI_IN_PLACE,results%te_hfex%core,1,MPI_REAL8,MPI_SUM,0,mpi%mpi_comm,ierr(1))
261
          ELSE
262 263 264
             CALL MPI_Reduce(results%te_hfex%valence,MPI_IN_PLACE,1,MPI_REAL8,MPI_SUM,0, mpi%mpi_comm,ierr(1))
             CALL MPI_Reduce(results%te_hfex%core,MPI_IN_PLACE,1,MPI_REAL8,MPI_SUM,0, mpi%mpi_comm,ierr(1))
          END IF
265 266
#endif

267 268
          ! WRITE(6,fmt='(A)') 'Starting 2nd variation ...'
          IF (noco%l_soc.AND..NOT.noco%l_noco) &
269 270
             CALL eigenso(eig_id,mpi,DIMENSION,stars,vacuum,atoms,sphhar,&
                          obsolete,sym,cell,noco,input,kpts, oneD,vTot,enpara,results)
271
          CALL timestop("generation of hamiltonian and diagonalization (total)")
272 273

#ifdef CPP_MPI
274
          CALL MPI_BARRIER(mpi%mpi_comm,ierr)
275 276
#endif

277 278 279
          ! fermi level and occupancies
          IF (noco%l_soc.AND.(.NOT.noco%l_noco)) DIMENSION%neigd = 2*DIMENSION%neigd
          IF ((mpi%irank.EQ.0)) THEN
280 281
             CALL timestart("determination of fermi energy")

282
             IF (noco%l_soc.AND.(.NOT.noco%l_noco)) THEN
283
                input%zelec = input%zelec*2
284
                CALL fermie(eig_id,mpi,kpts,obsolete,input,noco,enpara%epara_min,cell,results)
285 286 287 288
                results%seigscv = results%seigscv/2
                results%ts = results%ts/2
                input%zelec = input%zelec/2
             ELSE
289
                CALL fermie(eig_id,mpi,kpts,obsolete,input,noco,enpara%epara_min,cell,results)
290 291
             ENDIF
             CALL timestop("determination of fermi energy")
292

293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
!!$          !+Wannier
!!$          IF(wann%l_bs_comf)THEN
!!$             IF(pc.EQ.1) THEN
!!$                OPEN(777,file='out_eig.1')
!!$                OPEN(778,file='out_eig.2')
!!$                OPEN(779,file='out_eig.1_diag')
!!$                OPEN(780,file='out_eig.2_diag')
!!$             END IF
!!$
!!$             CALL bs_comfort(eig_id,DIMENSION,input,noco,kpts%nkpt,pc)
!!$
!!$             IF(pc.EQ.wann%nparampts)THEN
!!$                CLOSE(777)
!!$                CLOSE(778)
!!$                CLOSE(779)
!!$                CLOSE(780)
!!$             END IF
!!$          END IF
!!$          !-Wannier
312

313
          ENDIF
314
#ifdef CPP_MPI
315 316
          CALL MPI_BCAST(results%ef,1,MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(results%w_iks,SIZE(results%w_iks),MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
317 318
#endif

319
          IF (forcetheo%eval(eig_id,DIMENSION,atoms,kpts,sym,cell,noco,input,mpi,oneD,enpara,vToT,results)) THEN
320
             IF (noco%l_soc.AND.(.NOT.noco%l_noco)) DIMENSION%neigd=DIMENSION%neigd/2
321 322
             CYCLE forcetheoloop
          ENDIF
323

324
          CALL force_0(results)! ----> initialise force_old
325 326 327 328 329 330 331 332 333 334
          
!!$          !+Wannier functions
!!$          IF ((input%l_wann).AND.(.NOT.wann%l_bs_comf)) THEN
!!$             CALL wannier(DIMENSION,mpi,input,kpts,sym,atoms,stars,vacuum,sphhar,oneD,&
!!$                  wann,noco,cell,enpara,banddos,sliceplot,vTot,results,&
!!$                  eig_idList,(sym%invs).AND.(.NOT.noco%l_soc).AND.(.NOT.noco%l_noco),kpts%nkpt)
!!$          END IF
!!$          IF (wann%l_gwf) CALL juDFT_error("provide wann_inp if l_gwf=T", calledby = "fleur")
!!$          !-Wannier

335
          ! charge density generation
336
          CALL timestart("generation of new charge density (total)")
337
          CALL outDen%init(stars,atoms,sphhar,vacuum,input%jspins,noco%l_noco,POTDEN_TYPE_DEN)
338
          outDen%iter = inDen%iter
339 340
          CALL cdngen(eig_id,mpi,input,banddos,sliceplot,vacuum,DIMENSION,kpts,atoms,sphhar,stars,sym,&
                      enpara,cell,noco,vTot,results,oneD,coreSpecInput,archiveType,outDen)
341

342
          IF (.FALSE.) CALL rdmft(eig_id,mpi,input,kpts,banddos,cell,atoms,enpara,stars,vacuum,dimension,&
343
                                  sphhar,sym,field,vTot,oneD,noco,results)
344

345 346
          IF (noco%l_soc.AND.(.NOT.noco%l_noco)) DIMENSION%neigd=DIMENSION%neigd/2

347
#ifdef CPP_MPI
348 349 350 351 352 353 354 355 356
          CALL MPI_BCAST(enpara%evac0,SIZE(enpara%evac0),MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(enpara%el0,SIZE(enpara%el0),MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
          CALL MPI_BCAST(enpara%ello0,SIZE(enpara%ello0),MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
          
          IF (noco%l_noco) THEN
             DO n= 1,atoms%ntype
                IF (noco%l_relax(n)) THEN
                   CALL MPI_BCAST(noco%alph(n),1,MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
                   CALL MPI_BCAST(noco%beta(n),1,MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
357
                ENDIF
358 359 360
             ENDDO
             IF (noco%l_constr) THEN
                CALL MPI_BCAST(noco%b_con,SIZE(noco%b_con),MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
361
             ENDIF
362
          ENDIF
363
#endif
364
          CALL timestop("generation of new charge density (total)")
365

366
          IF (mpi%irank.EQ.0) THEN
367 368 369 370 371 372 373 374 375 376 377 378 379
             
!!$             !----> output potential and potential difference
!!$             IF (obsolete%disp) THEN
!!$                reap = .FALSE.
!!$                input%total = .FALSE.
!!$                CALL timestart("generation of potential (total)")
!!$                CALL vgen(hybrid,reap,input,xcpot,DIMENSION, atoms,sphhar,stars,vacuum,sym,&
!!$                     obsolete,cell,oneD,sliceplot,mpi, results,noco,outDen,inDenRot,vTot,vx,vCoul)
!!$                CALL timestop("generation of potential (total)")
!!$
!!$                CALL potdis(stars,vacuum,atoms,sphhar, input,cell,sym)
!!$             END IF
             
380
             ! total energy
381
             CALL timestart('determination of total energy')
382
             CALL totale(atoms,sphhar,stars,vacuum,DIMENSION,sym,input,noco,cell,oneD,&
383
                         xcpot,hybrid,vTot,vCoul,iter,inDen,results)
384
             CALL timestop('determination of total energy')
385 386
          END IF ! mpi%irank.EQ.0
          IF (hybrid%l_hybrid) CALL close_eig(eig_id)
387 388 389 390 391

       END DO forcetheoloop

       CALL forcetheo%postprocess()
       
392
       CALL enpara%mix(mpi,atoms,vacuum,input,vTot%mt(:,0,:,:),vtot%vacz)
393
       field2 = field
394 395

       ! mix input and output densities
396
       CALL timestart("mixing")
397 398
       CALL mix(field2,xcpot,dimension,obsolete,sliceplot,mpi,stars,atoms,sphhar,vacuum,input,&
                sym,cell,noco,oneD,hybrid,archiveType,inDen,outDen,results)
399 400
       CALL timestop("mixing")
       
401
       IF(mpi%irank == 0) THEN
402 403
         WRITE (6,FMT=8130) iter
         WRITE (16,FMT=8130) iter
404
8130     FORMAT (/,5x,'******* it=',i3,'  is completed********',/,/)
405
         WRITE(*,*) "Iteration:",iter," Distance:",results%last_distance
406
         CALL timestop("Iteration")
407
       END IF ! mpi%irank.EQ.0
408
          
409
#ifdef CPP_MPI
410 411
       CALL MPI_BCAST(results%last_distance,1,MPI_DOUBLE_PRECISION,0,mpi%mpi_comm,ierr)
       CALL MPI_BARRIER(mpi%mpi_comm,ierr)
412
#endif
413 414
       CALL priv_geo_end(mpi)

415
       l_cont = .TRUE.
Gregor Michalicek's avatar
Gregor Michalicek committed
416 417 418 419 420 421 422 423 424
       IF (hybrid%l_hybrid) THEN
          IF(hybrid%l_calhf) THEN
             iterHF = iterHF + 1
             l_cont = l_cont.AND.(iterHF < input%itmax)
             l_cont = l_cont.AND.(input%mindistance<=results%last_distance)
             CALL check_time_for_next_iteration(iterHF,l_cont)
          ELSE
             l_cont = l_cont.AND.(iter < 50) ! Security stop for non-converging nested PBE calculations
          END IF
425 426 427 428
          IF (hybrid%l_subvxc) THEN
             results%te_hfex%core    = 0
             results%te_hfex%valence = 0
          END IF
429 430 431 432
       ELSE
          l_cont = l_cont.AND.(iter < input%itmax)
          l_cont = l_cont.AND.((input%mindistance<=results%last_distance).OR.input%l_f)
          CALL check_time_for_next_iteration(iter,l_cont)
433
       END IF
434

435 436
       CALL writeTimesXML()

437 438 439 440
       IF ((mpi%irank.EQ.0).AND.(isCurrentXMLElement("iteration"))) THEN
          CALL closeXMLElement('iteration')
       END IF

441
    END DO scfloop ! DO WHILE (l_cont)
442 443

    IF (mpi%irank.EQ.0) CALL closeXMLElement('scfLoop')
444 445 446

    CALL close_eig(eig_id)

447
    CALL juDFT_end("all done",mpi%irank)
448
    
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
  CONTAINS
    SUBROUTINE priv_geo_end(mpi)
      TYPE(t_mpi),INTENT(IN)::mpi
      LOGICAL :: l_exist
      !Check if a new input was generated
      INQUIRE (file='inp_new',exist=l_exist)
      IF (l_exist) THEN
         CALL juDFT_end(" GEO new inp created ! ",mpi%irank)
      END IF
      !check for inp.xml
      INQUIRE (file='inp_new.xml',exist=l_exist)
      IF (.NOT.l_exist) RETURN
      IF (mpi%irank==0) THEN
         CALL system('mv inp.xml inp_old.xml')
         CALL system('mv inp_new.xml inp.xml')
         INQUIRE (file='qfix',exist=l_exist)
         IF (l_exist) THEN
            OPEN(2,file='qfix')
            WRITE(2,*)"F"
            CLOSE(2)
            PRINT *,"qfix set to F"
         ENDIF
471
         CALL resetBroydenHistory()
472 473 474
      ENDIF
      CALL juDFT_end(" GEO new inp.xml created ! ",mpi%irank)
    END SUBROUTINE priv_geo_end
475
    
476 477
  END SUBROUTINE fleur_execute
END MODULE m_fleur