Statistiques
| Révision :

root / src / ReadInput_vasp.f90

Historique | Voir | Annoter | Télécharger (6,13 ko)

1 5 pfleura2
 SUBROUTINE ReadInput_Vasp
2 5 pfleura2
3 5 pfleura2
! This routine reads an input template for Vasp
4 5 pfleura2
5 12 pfleura2
!----------------------------------------------------------------------
6 12 pfleura2
!  Copyright 2003-2014 Ecole Normale Supérieure de Lyon,
7 12 pfleura2
!  Centre National de la Recherche Scientifique,
8 12 pfleura2
!  Université Claude Bernard Lyon 1. All rights reserved.
9 12 pfleura2
!
10 12 pfleura2
!  This work is registered with the Agency for the Protection of Programs
11 12 pfleura2
!  as IDDN.FR.001.100009.000.S.P.2014.000.30625
12 12 pfleura2
!
13 12 pfleura2
!  Authors: P. Fleurat-Lessard, P. Dayal
14 12 pfleura2
!  Contact: optnpath@gmail.com
15 12 pfleura2
!
16 12 pfleura2
! This file is part of "Opt'n Path".
17 12 pfleura2
!
18 12 pfleura2
!  "Opt'n Path" is free software: you can redistribute it and/or modify
19 12 pfleura2
!  it under the terms of the GNU Affero General Public License as
20 12 pfleura2
!  published by the Free Software Foundation, either version 3 of the License,
21 12 pfleura2
!  or (at your option) any later version.
22 12 pfleura2
!
23 12 pfleura2
!  "Opt'n Path" is distributed in the hope that it will be useful,
24 12 pfleura2
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
25 12 pfleura2
!
26 12 pfleura2
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 12 pfleura2
!  GNU Affero General Public License for more details.
28 12 pfleura2
!
29 12 pfleura2
!  You should have received a copy of the GNU Affero General Public License
30 12 pfleura2
!  along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>.
31 12 pfleura2
!
32 12 pfleura2
! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr,
33 12 pfleura2
! for commercial licensing opportunities.
34 12 pfleura2
!----------------------------------------------------------------------
35 12 pfleura2
36 5 pfleura2
  use VarTypes
37 5 pfleura2
  use Path_module
38 5 pfleura2
  use Io_module
39 5 pfleura2
40 5 pfleura2
  IMPLICIT NONE
41 5 pfleura2
42 5 pfleura2
  INTERFACE
43 5 pfleura2
     function valid(string) result (isValid)
44 5 pfleura2
       CHARACTER(*), intent(in) :: string
45 5 pfleura2
       logical                  :: isValid
46 5 pfleura2
     END function VALID
47 5 pfleura2
  END INTERFACE
48 5 pfleura2
49 8 pfleura2
  CHARACTER(LCHARS) ::  Line
50 8 pfleura2
  INTEGER(KINT) ::  Iat
51 5 pfleura2
  INTEGER(KINT) :: I,J
52 5 pfleura2
53 5 pfleura2
  INTEGER(KINT), ALLOCATABLE :: NbAtType(:) !na
54 5 pfleura2
  INTEGER(KINT) :: NbType, NbTypeUser
55 5 pfleura2
56 5 pfleura2
  REAL(KREAL) :: B(3),xtmp,ytmp,ztmp
57 5 pfleura2
58 5 pfleura2
  LOGICAL :: TChk
59 5 pfleura2
60 5 pfleura2
  LOGICAL :: Debug
61 5 pfleura2
62 5 pfleura2
63 5 pfleura2
  Debug=Valid("readinput").OR.Valid("readinput_vasp")
64 5 pfleura2
65 5 pfleura2
  if (debug) Call Header("Entering ReadInput_Vasp")
66 5 pfleura2
67 10 pfleura2
  FPBC=.TRUE.
68 10 pfleura2
69 5 pfleura2
 if (Input/="VASP") THEN
70 5 pfleura2
71 5 pfleura2
     ! Input was not Vasp, so many parameters are missing like lattice
72 5 pfleura2
     ! constants...
73 5 pfleura2
     ! we read them now !
74 5 pfleura2
     ALLOCATE(FFF(3,nat))
75 5 pfleura2
     ! First geometry is a bit special for VASP as we have to set
76 5 pfleura2
     ! many things
77 5 pfleura2
     IF (DEBUG) WRITE(*,*) "Reading Vasp Parameters"
78 5 pfleura2
     READ(IOIN,'(A)') Vasp_Title
79 5 pfleura2
     READ(IOIN,*) Vasp_param
80 5 pfleura2
81 5 pfleura2
     READ(IOIN,*) Lat_a
82 5 pfleura2
     READ(IOIN,*) Lat_b
83 5 pfleura2
     READ(IOIN,*) Lat_c
84 5 pfleura2
85 5 pfleura2
     Lat_a=Lat_a*Vasp_param
86 5 pfleura2
     Lat_b=Lat_b*Vasp_param
87 5 pfleura2
     Lat_c=Lat_c*Vasp_param
88 5 pfleura2
89 5 pfleura2
     ALLOCATE(NbAtType(nat))
90 5 pfleura2
     READ(IOIN,'(A)') Vasp_types
91 5 pfleura2
     ! First, how many different types ?
92 5 pfleura2
     NbAtType=0
93 5 pfleura2
     READ(Vasp_types,*,END=998) NbAtType
94 5 pfleura2
998  CONTINUE
95 5 pfleura2
     NbType=0
96 5 pfleura2
     DO WHILE (NbAtType(NbType+1).NE.0)
97 5 pfleura2
        NbType=NbType+1
98 5 pfleura2
     END DO
99 5 pfleura2
100 5 pfleura2
     ! Do we know the atom types ?
101 5 pfleura2
     IF (AtTypes(1).EQ.'  ') THEN
102 5 pfleura2
        ! user has not provided atom types... we have to find them ourselves
103 5 pfleura2
        ! by looking into the POTCAR file...
104 5 pfleura2
        INQUIRE(File="POTCAR", EXIST=Tchk)
105 5 pfleura2
        IF (.NOT.Tchk) THEN
106 5 pfleura2
           WRITE(*,*) "ERROR! No AtTypes provided, and POTCAR file not found"
107 5 pfleura2
           STOP
108 5 pfleura2
        END IF
109 5 pfleura2
        OPEN(IOTMP,File="POTCAR")
110 5 pfleura2
        DO I=1,NbType
111 5 pfleura2
           Line='Empty'
112 5 pfleura2
           DO WHILE (Line(1:2).NE.'US')
113 5 pfleura2
              READ(IOTMP,'(A)') Line
114 5 pfleura2
              Line=AdjustL(Line)
115 5 pfleura2
           END DO
116 5 pfleura2
           Line=adjustl(Line(3:))
117 5 pfleura2
           AtTypes(I)=Line(1:2)
118 5 pfleura2
        END DO
119 5 pfleura2
        if (debug) WRITE(*,'(A,100(1X,A2))') "ReadG:VASP AtTypes",AtTypes(1:NbType)
120 5 pfleura2
        CLOSE(IOTMP)
121 5 pfleura2
122 5 pfleura2
     ELSE  !AtTypes(1).EQ.'  '
123 5 pfleura2
        ! user has provided atom types
124 5 pfleura2
        NbTypeUser=0
125 5 pfleura2
        DO WHILE (AtTypes(NbTypeUser+1).NE.'  ')
126 5 pfleura2
           NbTypeUser=NbTypeUser+1
127 5 pfleura2
        END DO
128 5 pfleura2
        IF (NbType.NE.NbTypeUser) THEN
129 5 pfleura2
           WRITE(*,*) "ERROR Read_Geom : NbType in POSCAR do not match AtTypes"
130 5 pfleura2
           STOP
131 5 pfleura2
        END IF
132 5 pfleura2
     END IF
133 5 pfleura2
134 5 pfleura2
     IAt=1
135 5 pfleura2
     DO I=1,NbType
136 5 pfleura2
        DO J=1,NbAtType(I)
137 5 pfleura2
           AtName(Iat)=AtTypes(I)
138 5 pfleura2
           Iat=Iat+1
139 5 pfleura2
        END DO
140 5 pfleura2
     END DO
141 5 pfleura2
     DEALLOCATE(NbAtType)
142 5 pfleura2
143 5 pfleura2
     NbTypes=NbType
144 5 pfleura2
145 5 pfleura2
     READ(IOIN,'(A)') Vasp_comment
146 5 pfleura2
     READ(IOIN,'(A)') Vasp_direct
147 5 pfleura2
     V_direct=Adjustl(Vasp_direct)
148 5 pfleura2
     Call UpCase(V_direct)
149 5 pfleura2
150 5 pfleura2
! PFL 2011 Mar 8 ->
151 5 pfleura2
! We have to read the FFF flags :
152 5 pfleura2
     DO I=1,Nat
153 5 pfleura2
        READ(IOIN,*) Xtmp,ytmp,ztmp,FFF(1:3,I)
154 5 pfleura2
        DO J=1,3
155 5 pfleura2
           FFF(J,I)=AdjustL(FFF(J,I))
156 5 pfleura2
           CALL Upcase(FFF(J,I))
157 5 pfleura2
        END DO
158 5 pfleura2
     END DO
159 5 pfleura2
! <- PFL 2011 Mar 8
160 5 pfleura2
161 5 pfleura2
  END IF
162 5 pfleura2
163 5 pfleura2
  ! In the case of VASP there is always the problem  of moving from one side
164 5 pfleura2
  ! of the box to the other...
165 5 pfleura2
166 5 pfleura2
     Renum=.TRUE.
167 5 pfleura2
168 5 pfleura2
     ! V_direct has been set in Read_geom
169 5 pfleura2
     IF (V_direct(1:6).EQ.'DIRECT') THEN
170 5 pfleura2
        Latr(1:3,1)=Lat_a
171 5 pfleura2
        Latr(1:3,2)=Lat_b
172 5 pfleura2
        Latr(1:3,3)=Lat_c
173 5 pfleura2
        B=1.
174 10 pfleura2
! TO DO: replace by LAPACK
175 5 pfleura2
        CALL Gaussj(Latr,3,3,B,1,1)
176 5 pfleura2
     ELSE
177 5 pfleura2
        Latr=0.
178 5 pfleura2
        Latr(1,1)=1.d0
179 5 pfleura2
        Latr(2,2)=1.d0
180 5 pfleura2
        Latr(3,3)=1.d0
181 5 pfleura2
     END IF
182 5 pfleura2
183 5 pfleura2
     ! Actualization of Frozen using the FFFF...
184 5 pfleura2
     ! Frozen has the advantage ie if given, it imposes _ALL_ the FFF flags.
185 5 pfleura2
     IF (Frozen(1).NE.0) THEN
186 5 pfleura2
        WRITE(IOOUT,*) "Frozen is given. Flags of the given POSCAR are overriden"
187 5 pfleura2
        FFF='T'
188 5 pfleura2
189 5 pfleura2
        NFroz=0
190 5 pfleura2
        DO WHILE (Frozen(NFroz+1).NE.0)
191 5 pfleura2
           NFroz=NFroz+1
192 5 pfleura2
           FFF(1:3,Frozen(NFroz))='F'
193 5 pfleura2
        END DO
194 5 pfleura2
     ELSE
195 5 pfleura2
        WRITE(IOOUT,*) "Frozen not given : using  Flags of the given POSCAR"
196 5 pfleura2
        NFroz=0
197 5 pfleura2
        Frozen=0
198 5 pfleura2
        DO I=1,Nat
199 5 pfleura2
           IF ((FFF(1,I).EQ.'F').OR.(FFF(2,I).EQ.'F').OR.(FFF(3,I).EQ.'F')) THEN
200 5 pfleura2
              FFF(1:3,I)='F'
201 5 pfleura2
              NFroz=NFroz+1
202 5 pfleura2
              Frozen(NFroz)=I
203 5 pfleura2
           END IF
204 5 pfleura2
        END DO
205 5 pfleura2
        WRITE(IOOUT,*) "Frozen atoms:",Frozen(1:NFroz)
206 5 pfleura2
     END IF
207 5 pfleura2
208 5 pfleura2
     IF (Vmd) THEN
209 5 pfleura2
        if (debug) WRITE(*,*) "DBG MAIN, L803, VMD=T,NbTypes,AtTypes",NbTypes,AtTypes(1:NbTypes)
210 5 pfleura2
        Line=""
211 5 pfleura2
        DO I=1,NbTypes
212 5 pfleura2
           Line=TRIM(Line) // " " // TRIM(AdjustL(AtTypes(I)))
213 5 pfleura2
        END DO
214 5 pfleura2
        Vasp_Title=Trim(Line) // " " // Trim(adjustL(Vasp_Title))
215 5 pfleura2
        if (debug) WRITE(*,*) "DBG MAIN, L809, VMD=T, Vasp_Title=",TRIM(Vasp_Title)
216 5 pfleura2
     END IF
217 5 pfleura2
218 5 pfleura2
 if (debug) Call Header("Exiting ReadInput_Vasp")
219 5 pfleura2
220 5 pfleura2
   END SUBROUTINE READINPUT_VASP