optional.F90 8.13 KB
Newer Older
1 2 3 4 5 6 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 43 44 45 46 47
!--------------------------------------------------------------------------------
! 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.
!--------------------------------------------------------------------------------
MODULE m_optional
  USE m_juDFT
CONTAINS
  SUBROUTINE OPTIONAL(mpi, atoms,sphhar,vacuum,DIMENSION,&
       stars,input,sym, cell, sliceplot,obsolete, xcpot, noco, oneD)
    !
    !----------------------------------------
    ! this routine is called by: fleur.F90
    !
    ! optional --+-- plot -+- loddop
    !            |         +- outcdn -+- cotra0
    !            |                    +- cotra1
    !            |                    +- starf2 -- spgrot
    !            |                    +- starf3
    !            |                    +- ylm3
    !            +-- stden -+- atom2 -+- setcor
    !            |          |         +- stpot1
    !            |          |         +- differ -+- inwint
    !            |          |         |          +- outint
    !            |          |         +- vxcall (-> see vgen.F) or:
    !            |          |         +- potl0 -+- grdchlh
    !            |          |         |         +- mkgl0
    !            |          |         |         +- vxcallg (-> see vgen.F)
    !            |          |         +- intgr1
    !            |          +- cdnovlp -+- spgrot
    !            |          |           +- rcerf --wofz
    !            |          |           +- diflgr
    !            |          |           +- qpw_to_nmt -+- phasy1 -+- spgrot
    !            |          |                          |          +- ylm3
    !            |          |                          +- sphbes
    !            |          +- qfix -- cdntot -+- intgr3
    !            |          |                  +- qsf
    !            |          |                  +- pwint -- spgrot
    !            |          +- wrtdop
    !            |          +- points -- qranf
    !            |          +- sphpts -- qranf
    !            |          +- checkdop -+- starf3
    !            |                       +- cotra0
    !            |                       +- starf2 -- spgrot
    !            |                       +- fitchk
    !            |                       +- cotra1
    !            |                       +- ylm3
48 49
    !            +-- cdnsp -+- readDensity
    !            |          +- writeDensity
50
    !            |          +- intgr3
51 52
    !            +-- flipcdn -+- readDensity
    !            |            +- writeDensity
53 54
    !            +-- f2u -- wrtdop
    !            +-- u2f -- loddop
55
    !            +-- bmt -+- readDensity
56 57 58 59 60 61 62
    !                     +- wrtdop
    !----------------------------------------
    USE m_bmt
    USE m_plotdop
    USE m_stden
    USE m_cdnsp
    USE m_flipcdn
63
    USE m_cdn_io
64 65 66 67 68 69
    USE m_f2u
    USE m_u2f
    USE m_types
    IMPLICIT NONE
    !     ..
    !     .. Scalar Arguments ..
70

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    TYPE(t_mpi),INTENT(IN)      :: mpi
    TYPE(t_atoms),INTENT(IN)    :: atoms
    TYPE(t_dimension),INTENT(IN):: DIMENSION
    TYPE(t_sphhar),INTENT(IN)   :: sphhar
    TYPE(t_obsolete),INTENT(IN) :: obsolete
    TYPE(t_sym),INTENT(IN)      :: sym
    TYPE(t_stars),INTENT(IN)    :: stars
    TYPE(t_oneD),INTENT(IN)     :: oneD
    TYPE(t_input),INTENT(INOUT) :: input
    TYPE(t_noco),INTENT(IN)     :: noco
    TYPE(t_vacuum),INTENT(IN)   :: vacuum
    TYPE(t_cell),INTENT(IN)     :: cell
    TYPE(t_xcpot),INTENT(IN)    :: xcpot
    TYPE(t_sliceplot),INTENT(IN):: sliceplot
    !     ..
    !     .. Local Scalars ..
87
    INTEGER :: it, archiveType
88
    CHARACTER*10 :: cdnfname
89
    LOGICAL :: strho
90 91 92 93
#ifdef CPP_MPI
    include 'mpif.h'
    INTEGER :: ierr(2)
#endif
94 95
    !     ..
    it = 1
96

97 98 99 100 101 102 103 104 105
    IF (mpi%irank == 0) THEN
10     IF (sliceplot%plpot) input%score = .FALSE.
       IF (sliceplot%iplot) THEN
          CALL timestart("Plotting")
          IF (input%strho)  CALL juDFT_error("strho = T and iplot=T",calledby&
               &        ="optional")
          IF (noco%l_noco) THEN
             cdnfname = 'cdn'
             CALL plotdop(&
106
                  &           oneD,dimension,stars,vacuum,sphhar,atoms,&
107 108 109 110
                  &           input,sym,cell,sliceplot,&
                  &           noco%l_noco,cdnfname)
             cdnfname = 'mdnx'
             CALL plotdop(&
111
                  &           oneD,dimension,stars,vacuum,sphhar,atoms,&
112 113 114 115
                  &           input,sym,cell,sliceplot,&
                  &           noco%l_noco,cdnfname)
             cdnfname = 'mdny'
             CALL plotdop(&
116
                  &           oneD,dimension,stars,vacuum,sphhar,atoms,&
117 118 119 120
                  &           input,sym,cell,sliceplot,&
                  &           noco%l_noco,cdnfname)
             cdnfname = 'mdnz'
             CALL plotdop(&
121
                  &           oneD,dimension,stars,vacuum,sphhar,atoms,&
122 123 124 125 126 127 128 129 130
                  &           input,sym,cell,sliceplot,&
                  &           noco%l_noco,cdnfname)
          ELSE
             IF (sliceplot%slice) THEN
                cdnfname = 'cdn_slice'
             ELSE
                cdnfname = 'cdn1'
             ENDIF
             CALL plotdop(&
131
                  &           oneD,dimension,stars,vacuum,sphhar,atoms,&
132 133 134 135 136 137 138 139 140
                  &           input,sym,cell,sliceplot,&
                  &           noco%l_noco,cdnfname)
          ENDIF
          CALL timestop("Plotting")
       END IF
    ENDIF ! mpi%irank == 0
    !
    !     --->generate starting charge density
    !
141 142
    strho=input%strho
    IF (.NOT.(strho.OR.obsolete%l_f2u.OR.obsolete%l_u2f.OR.sliceplot%iplot)) THEN
143
       archiveType = CDN_ARCHIVE_TYPE_CDN1_const
144
       IF (noco%l_noco) THEN
145
          archiveType = CDN_ARCHIVE_TYPE_NOCO_const
146
       END IF
147 148 149 150 151 152
       IF (mpi%irank == 0) THEN
          strho = .NOT.isDensityFilePresent(archiveType)
       END IF
#ifdef CPP_MPI
       CALL MPI_BCAST(strho,1,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
#endif
153 154
    ENDIF
    IF (strho) THEN
155
       strho=input%total 
156 157 158 159 160 161 162 163 164 165 166 167
       input%total = .FALSE.
       !
       CALL timestart("generation of start-density")
       CALL stden(mpi,&
            &              sphhar,stars,atoms,sym,&
            &              DIMENSION,vacuum,&
            &              input,&
            &              cell,&
            &              xcpot,&
            &              obsolete,&
            &              oneD)
       !
168
       input%total=strho
169
       CALL timestop("generation of start-density")
170 171 172 173 174 175
    END IF
    IF (mpi%irank == 0) THEN
       !
       !     --->generate spin polarized charge density
       !
       IF (input%swsp) THEN
176
          CALL timestart("optional: spin polarized density")
177 178
          CALL cdnsp(&
               &              atoms,input,vacuum,sphhar,&
179
               &              stars,sym,oneD,cell,dimension)
180 181 182 183 184 185 186
          !
          CALL timestop("optional: spin polarized density")
       END IF
       !
       !     --->flip magnetic moments
       !
       IF (input%lflip) THEN
187

188 189 190
          CALL timestart('optional: flip magnetic moments')
          CALL flipcdn(&
               &                atoms,input,vacuum,sphhar,&
191
               &                stars,sym,oneD,cell,noco%l_noco)
192 193 194
          !
          CALL timestop('optional: flip magnetic moments')
       END IF
195

196
       IF (obsolete%l_u2f) THEN
197

198 199 200 201 202 203 204
          CALL timestart('optional: conversion to formatted')
          CALL u2f(&
               &           stars,input,atoms,sphhar,vacuum,&
               &           cell,sym,noco%l_noco)
          !
          CALL timestop('optional: conversion to formatted')
       ENDIF
205

206
       IF (obsolete%l_f2u) THEN
207

208 209 210 211 212 213 214
          CALL timestart('optional: conversion to unformatted')
          CALL f2u(&
               &           stars,input,atoms,sphhar,vacuum,&
               &           cell,sym,noco%l_noco)
          !
          CALL timestop('optional: conversion to unformatted')
       ENDIF
215

216 217 218
       IF (input%l_bmt) THEN
          CALL bmt(&
               &           stars,input,noco,atoms,sphhar,vacuum,&
219
               &           cell,sym,oneD)
220
       ENDIF
221

222 223 224
    ENDIF ! mpi%irank == 0
  END SUBROUTINE OPTIONAL
END MODULE m_optional