inpgen.f90 6.29 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
  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
41
  use m_read_old_inp
42
  
Daniel Wortmann's avatar
Daniel Wortmann committed
43 44
      IMPLICIT NONE
    
45
      REAL,    ALLOCATABLE :: atompos(:, :),atomid(:) 
Daniel Wortmann's avatar
Daniel Wortmann committed
46
      CHARACTER(len=20), ALLOCATABLE :: atomLabel(:)
47
      LOGICAL               :: l_fullinput,l_explicit,l_inpxml,l_include(4)
48
      
Daniel Wortmann's avatar
Daniel Wortmann committed
49 50 51 52 53 54
      TYPE(t_input)    :: input
      TYPE(t_atoms)    :: atoms
      TYPE(t_cell)     :: cell
      TYPE(t_sym)      :: sym
      TYPE(t_noco)     :: noco
      TYPE(t_vacuum)   :: vacuum
55 56 57 58 59 60 61 62 63 64 65
      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
66
      kpts_str=""
67
      
Daniel Wortmann's avatar
Daniel Wortmann committed
68 69
      !Start program and greet user
      CALL inpgen_help()
70
      l_explicit=judft_was_argument("-explicit")
71
      
Daniel Wortmann's avatar
Daniel Wortmann committed
72 73
      OPEN(6,file='out')

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

135 136 137 138 139 140
    CONTAINS
      SUBROUTINE determine_includes(l_include)
        LOGICAL,INTENT(out)::l_include(4)  !kpts,operations,species,position
        
        CHARACTER(len=100)::str=''
        LOGICAL           ::incl
141

142 143
        l_include=[.FALSE.,.FALSE.,.TRUE.,.TRUE.]
        
144 145 146
        IF (judft_was_argument("-inc")) THEN
           str=judft_string_for_argument("-inc")
           
147 148 149
           DO WHILE(LEN_TRIM(str)>0) 
              IF (str(1:1)=='-') THEN
                 incl=.FALSE.
150
                 str=str(2:)
151 152 153 154 155 156
              ELSE
                 incl=.TRUE.
                 IF (str(1:1)=='+') str=str(2:)
              ENDIF
              SELECT CASE(str(1:1))
              CASE ('k','K')
157
                 l_include(1)=incl
158
              CASE ('o','O')
159
                 l_include(2)=incl
160
              CASE ('s','S')
161
                 l_include(3)=incl
162
              CASE ('p','P')
163
                 l_include(4)=incl
164
              CASE ('a','A')
165
                 l_include(:)=incl
166 167 168 169
              END SELECT
              IF (INDEX(str,"'")>0) THEN
                 str=str(INDEX(str,"'")+1:)
              ELSE
170
                 str=""
171 172 173
              END IF
           END DO
        ENDIF
174
        
175
      END SUBROUTINE determine_includes
176
      
Daniel Wortmann's avatar
Daniel Wortmann committed
177
    END PROGRAM inpgen