optional.F90 6.47 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
    USE m_types
65 66
    USE m_pldngen
   
67 68 69
    IMPLICIT NONE
    !     ..
    !     .. Scalar Arguments ..
70

71 72 73 74 75 76 77 78 79 80 81 82
    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
83
    CLASS(t_xcpot),INTENT(IN)   :: xcpot
84 85 86
    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
    IF (sliceplot%iplot .AND. (mpi%irank==0) ) THEN
       IF (noco%l_noco) THEN
99
          CALL pldngen(mpi,sym,stars,atoms,sphhar,vacuum,&
100 101 102 103 104
               cell,input,noco,oneD,sliceplot)
       ENDIF
    ENDIF

       
105
    IF (mpi%irank == 0) THEN
106
       IF (sliceplot%plpot) input%score = .FALSE.
107 108
       IF (sliceplot%iplot) THEN
          CALL timestart("Plotting")
109
          IF (input%strho) CALL juDFT_error("strho = T and iplot=T",calledby = "optional")
110 111
          CALL plotdop(oneD,dimension,stars,vacuum,sphhar,atoms,&
                       input,sym,cell,sliceplot,noco)
112 113 114 115 116 117
          CALL timestop("Plotting")
       END IF
    ENDIF ! mpi%irank == 0
    !
    !     --->generate starting charge density
    !
118
    strho=input%strho
119
    IF (.NOT.(strho.OR.sliceplot%iplot)) THEN
120
       archiveType = CDN_ARCHIVE_TYPE_CDN1_const
121
       IF (noco%l_noco) THEN
122
          archiveType = CDN_ARCHIVE_TYPE_NOCO_const
123
       END IF
124 125 126 127 128 129
       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
130 131
    ENDIF
    IF (strho) THEN
132
       strho=input%total 
133 134 135
       input%total = .FALSE.
       !
       CALL timestart("generation of start-density")
136 137
       CALL stden(mpi,sphhar,stars,atoms,sym,DIMENSION,vacuum,&
                  input,cell,xcpot,obsolete,noco,oneD)
138
       !
139
       input%total=strho
140
       CALL timestop("generation of start-density")
141 142 143 144 145 146
    END IF
    IF (mpi%irank == 0) THEN
       !
       !     --->generate spin polarized charge density
       !
       IF (input%swsp) THEN
147
          CALL timestart("optional: spin polarized density")
148
          CALL cdnsp(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell,dimension)
149 150 151 152 153 154 155
          !
          CALL timestop("optional: spin polarized density")
       END IF
       !
       !     --->flip magnetic moments
       !
       IF (input%lflip) THEN
156

157
          CALL timestart('optional: flip magnetic moments')
158
          CALL flipcdn(atoms,input,vacuum,sphhar,stars,sym,noco,oneD,cell)
159 160 161
          !
          CALL timestop('optional: flip magnetic moments')
       END IF
162

163 164
 
 
165
       IF (input%l_bmt) THEN
166
          CALL bmt(stars,input,noco,atoms,sphhar,vacuum,cell,sym,oneD)
167
       ENDIF
168

169
    ENDIF ! mpi%irank == 0
170 171 172 173 174 175 176

    IF (sliceplot%iplot)      CALL juDFT_end("density plot o.k.",mpi%irank)
    IF (input%strho)          CALL juDFT_end("starting density generated",mpi%irank)
    IF (input%swsp)           CALL juDFT_end("spin polarised density generated",mpi%irank)
    IF (input%lflip)          CALL juDFT_end("magnetic moments flipped",mpi%irank)
    IF (input%l_bmt)          CALL juDFT_end('"cdnbmt" written',mpi%irank)
    
177 178
  END SUBROUTINE OPTIONAL
END MODULE m_optional