inpgen.f90 6.3 KB
Newer Older
Daniel Wortmann's avatar
Daniel Wortmann committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
!--------------------------------------------------------------------------------
! 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.
!--------------------------------------------------------------------------------

PROGRAM inpgen
!----------------------------------------------------------------------------+
!   Set up a FLEUR inp-file from basic input data; for use and docu please   !
!   refer to inpgen.html (or see http://www.flapw.de/docs/inpgen.html)       !
!                                                                            |
!   The program is based on the input conventions of the FLAIR-code, so that !
!   some compatibility is ensured. The symmetry generator was written by     ! 
!   M.Weinert and implemented in the FLAIR-code by G.Schneider.              !
!                                                                    gb`02   |
!----------------------------------------------------------------------------+
17 18 19 20 21 22
  USE m_juDFT
  USE m_inpgen_help
  USE m_read_inpgen_input
  USE m_make_crystal
  USE m_make_atomic_defaults
  USE m_make_defaults
Daniel Wortmann's avatar
Daniel Wortmann committed
23
  USE m_make_kpoints
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  USE m_winpxml
  USE m_xsf_io
  USE m_types_input
  USE m_types_atoms
  USE m_types_cell
  USE m_types_sym
  USE m_types_noco
  USE m_types_vacuum
  USE m_types_banddos
  USE m_types_hybrid
  USE m_types_xcpot_inbuild_nofunction
  USE m_types_forcetheo
  USE m_types_kpts
  USE m_types_enpara
  USE m_types_oneD
  USE m_types_sliceplot
  USE m_types_stars
  
Daniel Wortmann's avatar
Daniel Wortmann committed
42 43
      IMPLICIT NONE
    
44
      REAL,    ALLOCATABLE :: atompos(:, :),atomid(:) 
Daniel Wortmann's avatar
Daniel Wortmann committed
45
      CHARACTER(len=20), ALLOCATABLE :: atomLabel(:)
46
      LOGICAL               :: l_fullinput,l_explicit,l_inpxml,l_include(4)
47
      
Daniel Wortmann's avatar
Daniel Wortmann committed
48 49 50 51 52 53
      TYPE(t_input)    :: input
      TYPE(t_atoms)    :: atoms
      TYPE(t_cell)     :: cell
      TYPE(t_sym)      :: sym
      TYPE(t_noco)     :: noco
      TYPE(t_vacuum)   :: vacuum
54 55 56 57 58 59 60 61 62 63 64
      TYPE(t_banddos)  :: banddos
      TYPE(t_hybrid)   :: hybrid
      TYPE(t_xcpot_inbuild_nf)::xcpot
      TYPE(t_enpara)   :: enpara
      TYPE(t_forcetheo):: forcetheo
      TYPE(t_kpts)     :: kpts
      TYPE(t_oned)     :: oned
      TYPE(t_sliceplot):: sliceplot
      TYPE(t_stars)    :: stars
      
      CHARACTER(len=40):: kpts_str
65
      kpts_str=""
66
      
Daniel Wortmann's avatar
Daniel Wortmann committed
67 68
      !Start program and greet user
      CALL inpgen_help()
69
      l_explicit=judft_was_argument("-explicit")
70
      
Daniel Wortmann's avatar
Daniel Wortmann committed
71 72
      OPEN(6,file='out')

Daniel Wortmann's avatar
Daniel Wortmann committed
73
      INQUIRE(file='inp.xml',exist=l_inpxml)
Daniel Wortmann's avatar
Daniel Wortmann committed
74 75
      IF (l_inpxml.AND..NOT.(judft_was_argument("-inp.xml").or.judft_was_argument("-overwrite")))&
           CALL judft_error("inp.xml exists and can not be overwritten")
Daniel Wortmann's avatar
Daniel Wortmann committed
76 77 78 79
      
      IF (judft_was_argument("-inp")) THEN
         STOP "not yet"
         !CALL read_old_input()
80
         l_fullinput=.TRUE.
Daniel Wortmann's avatar
Daniel Wortmann committed
81
      ELSEIF (judft_was_argument("-inp.xml")) THEN
82 83
         call read_old_inp(input,DIMENSION,atoms,sphhar,cell,stars,sym,noco,vacuum,forcetheo,&
              sliceplot,banddos,enpara,xcpot,kpts,hybrid, oneD)
84
         l_fullinput=.TRUE.
Daniel Wortmann's avatar
Daniel Wortmann committed
85 86 87
      ELSEIF(judft_was_argument("-f")) THEN
         !read the input
         
88 89 90
         CALL read_inpgen_input(atompos,atomid,atomlabel,kpts_str,&
              input,sym,noco,vacuum,stars,xcpot,cell,hybrid)
         l_fullinput=.FALSE.
Daniel Wortmann's avatar
Daniel Wortmann committed
91 92 93
      ELSE
         CALL judft_error("You should either specify -inp,-inp.xml or -f command line options. Check -h if unsure")
      ENDIF
94
      IF (.NOT.l_fullinput) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
95
         !First we determine the spacegoup and map the atoms to groups
96
         CALL make_crystal(input%film,atomid,atompos,atomlabel,vacuum%dvac,noco,&
Daniel Wortmann's avatar
Daniel Wortmann committed
97 98 99 100
              cell,sym,atoms)          
         
         !All atom related parameters are set here. Note that some parameters might
         !have been set in the read_input call before by adding defaults to the atompar module
Daniel Wortmann's avatar
Daniel Wortmann committed
101
         CALL make_atomic_defaults(input,vacuum,cell,oneD,atoms,enpara)
Daniel Wortmann's avatar
Daniel Wortmann committed
102 103
         
         !Set all defaults that have not been specified before or can not be specified in inpgen
104 105
         CALL make_defaults(atoms,sym,cell,vacuum,input,stars,&
                   xcpot,noco,hybrid)
Daniel Wortmann's avatar
Daniel Wortmann committed
106 107 108 109
      ENDIF
      !
      ! k-points can also be modified here
      !
110
      call make_kpoints(kpts,cell,sym,input%film,noco%l_ss.or.noco%l_soc,kpts_str)
Daniel Wortmann's avatar
Daniel Wortmann committed
111
      !
Daniel Wortmann's avatar
Daniel Wortmann committed
112
      !Now the IO-section
Daniel Wortmann's avatar
Daniel Wortmann committed
113
      !
Daniel Wortmann's avatar
Daniel Wortmann committed
114
      IF (.NOT.l_inpxml.or.judft_was_argument("-overwrite")) THEN
115
         call determine_includes(l_include)
Daniel Wortmann's avatar
Daniel Wortmann committed
116
         !the inp.xml file
117
         !CALL dump_FleurInputSchema()
Daniel Wortmann's avatar
Daniel Wortmann committed
118 119
         CALL w_inpxml(&
              atoms,vacuum,input,stars,sliceplot,forcetheo,banddos,&
Daniel Wortmann's avatar
Daniel Wortmann committed
120 121
              cell,sym,xcpot,noco,oneD,hybrid,kpts,enpara,&
              5,l_explicit,l_include,"inp.xml")
122
         if (.not.l_include) CALL sym%print_XML(99,"sym.xml")
Daniel Wortmann's avatar
Daniel Wortmann committed
123
      ENDIF
Daniel Wortmann's avatar
Daniel Wortmann committed
124
      if (.not.l_include) CALL kpts%print_XML(99,"kpts.xml")
Daniel Wortmann's avatar
Daniel Wortmann committed
125 126
      
      ! Structure in  xsf-format
Daniel Wortmann's avatar
Daniel Wortmann committed
127 128 129
      OPEN (55,file="struct.xsf")
      CALL xsf_WRITE_atoms(55,atoms,input%film,.FALSE.,cell%amat)
      CLOSE (55)
Daniel Wortmann's avatar
Daniel Wortmann committed
130
      CLOSE(6)
Daniel Wortmann's avatar
Daniel Wortmann committed
131
      
Daniel Wortmann's avatar
Daniel Wortmann committed
132
      CALL juDFT_end("All done")
Daniel Wortmann's avatar
Daniel Wortmann committed
133

134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
    contains
      subroutine determine_includes(l_include)
        logical,intent(out)::l_include(4)  !kpts,operations,species,position

        l_include=[.false.,.false.,.true.,.true.]

        IF (judft_was_argument("-inc")) THEN
           str=judft_string_for_argument("-inc")
           
           do while(len_trim(str)>0) then
              if (str(1:1)=='-') then
                 incl=.false.
                 str=str(2:)
              else
                 incl=.true.
                 if (str(1:1)=='+') str=str(2:)
              endif
              select case(str(1:1))
              case ('k','K')
                 l_include(1)=incl
              case ('o','O')
                 l_include(2)=incl
              case ('s','S')
                 l_include(3)=incl
              case ('p','P')
                 l_include(4)=incl
              case ('a','A')
                 l_include(:)=incl
              end select
              if (index(str,"'")>0) then
                 str=str(index(str,"'")+1:)
              else
                 str=""
              end if
           end do
        endif
        
        IF (LEN_TRIM(str)>1) CALL judft_error("Do not specify k-points in file and on command line")
        str=judft_string_for_argument("-k")
     END IF
      
Daniel Wortmann's avatar
Daniel Wortmann committed
175
    END PROGRAM inpgen