Statistiques
| Révision :

root / src / ReadInput_gaussian.f90

Historique | Voir | Annoter | Télécharger (7,29 ko)

1 5 pfleura2
 SUBROUTINE ReadInput_gaussian
2 5 pfleura2
3 5 pfleura2
! This routine reads an input template for Gaussian
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 10 pfleura2
48 10 pfleura2
49 10 pfleura2
    SUBROUTINE die(routine, msg, file, line, unit)
50 10 pfleura2
51 10 pfleura2
      Use VarTypes
52 10 pfleura2
      Use io_module
53 10 pfleura2
54 10 pfleura2
      implicit none
55 10 pfleura2
      character(len=*), intent(in)           :: routine, msg
56 10 pfleura2
      character(len=*), intent(in), optional :: file
57 10 pfleura2
      integer(KINT), intent(in), optional      :: line, unit
58 10 pfleura2
59 10 pfleura2
    END SUBROUTINE die
60 10 pfleura2
61 10 pfleura2
62 5 pfleura2
  END INTERFACE
63 5 pfleura2
64 5 pfleura2
65 10 pfleura2
  CHARACTER(132) ::  Line,LineUp
66 5 pfleura2
  INTEGER(KINT) :: LineL, Idx, Iat
67 10 pfleura2
  INTEGER(KINT) :: I,NTmp
68 10 pfleura2
  REAL(KREAL) :: Lat(3,3)
69 5 pfleura2
70 5 pfleura2
  LOGICAL :: Debug
71 5 pfleura2
72 5 pfleura2
73 5 pfleura2
  Debug=Valid("readinput").OR.Valid("readinput_gaussian")
74 5 pfleura2
75 5 pfleura2
 if (debug) Call Header("Entering ReadInput_Gaussian")
76 5 pfleura2
77 5 pfleura2
  ! We read the Gaussian input file
78 5 pfleura2
  ! First, the root
79 5 pfleura2
     IF (DEBUG) WRITE(*,*) "Reading Gauss Root"
80 5 pfleura2
     ALLOCATE(Gauss_Root)
81 5 pfleura2
     NULLIFY(Gauss_Root%next)
82 5 pfleura2
     Current => Gauss_root
83 5 pfleura2
     LineL=1
84 5 pfleura2
     DO WHILE (LineL.NE.0)
85 5 pfleura2
        READ(IOIN,'(A)') Line
86 5 pfleura2
        Line=AdjustL(Line)
87 5 pfleura2
        LineL=len_Trim(Line)
88 5 pfleura2
! we do not read the %chk line
89 5 pfleura2
        Idx=INDEX(Line,"chk")
90 5 pfleura2
        IF ((LineL.NE.0).AND.(Idx.EQ.0)) THEN
91 5 pfleura2
           current%Line=TRIM(Line)
92 5 pfleura2
           ALLOCATE(current%next)
93 5 pfleura2
           Current => Current%next
94 5 pfleura2
           Nullify(Current%next)
95 5 pfleura2
        END IF
96 5 pfleura2
     END DO
97 5 pfleura2
98 5 pfleura2
!     Current => Gauss_root
99 5 pfleura2
!     DO WHILE (ASSOCIATED(Current%next))
100 5 pfleura2
!        WRITE(*,'(1X,A)') Trim(current%line)
101 5 pfleura2
!        Current => current%next
102 5 pfleura2
!     END DO
103 5 pfleura2
104 5 pfleura2
     ! Now the comment...
105 5 pfleura2
     IF (DEBUG) WRITE(*,*) "Reading Gauss Comment"
106 5 pfleura2
     ALLOCATE(Gauss_Comment)
107 5 pfleura2
     NuLLIFY(Gauss_Comment%Next)
108 5 pfleura2
     Current => Gauss_comment
109 5 pfleura2
     LineL=1
110 5 pfleura2
     DO WHILE (LineL.NE.0)
111 5 pfleura2
        READ(IOIN,'(A)') Line
112 5 pfleura2
        Line=AdjustL(Line)
113 5 pfleura2
        LineL=len(Trim(Line))
114 5 pfleura2
        IF (LineL.NE.0) THEN
115 5 pfleura2
           current%Line=TRIM(Line)
116 5 pfleura2
           ALLOCATE(current%next)
117 5 pfleura2
           Current => Current%next
118 5 pfleura2
           Nullify(Current%next)
119 5 pfleura2
        END IF
120 5 pfleura2
     END DO
121 5 pfleura2
122 5 pfleura2
 !    Current => Gauss_comment
123 5 pfleura2
 !    DO WHILE (ASSOCIATED(Current%next))
124 5 pfleura2
 !       WRITE(*,'(1X,A)') Trim(current%line)
125 5 pfleura2
 !       Current => current%next
126 5 pfleura2
 !    END DO
127 5 pfleura2
128 5 pfleura2
     ! Now the charge
129 5 pfleura2
     IF (DEBUG) WRITE(*,*) "Reading Gauss Charge"
130 5 pfleura2
     READ(IOIN,'(A)') Gauss_Charge
131 5 pfleura2
     if (debug) WRITE(*,*) "Gauss_charge=",TRIM(Gauss_charge)
132 5 pfleura2
     ! We now read the Paste part...
133 5 pfleura2
     ALLOCATE(Gauss_Paste(NAt))
134 5 pfleura2
     LineL=1
135 5 pfleura2
     Iat=0
136 10 pfleura2
     IPer=0
137 10 pfleura2
     FPBC=.FALSE.
138 5 pfleura2
     Gauss_paste=" "
139 5 pfleura2
     DO While (LineL.GT.0)
140 5 pfleura2
        READ(IOIN,'(A)') Line
141 5 pfleura2
        Line=AdjustL(Line)
142 5 pfleura2
        LineL=Len_TRIM(Line)
143 10 pfleura2
        IF (LineL.GT.0) THEN
144 10 pfleura2
           LineUp=Line
145 10 pfleura2
           Call UpCase(LineUp)
146 10 pfleura2
           if (LineUp(1:2)=="TV") THEN
147 10 pfleura2
              FPBC=.TRUE.
148 10 pfleura2
              IPer=IPer+1
149 10 pfleura2
              If (Iper>3) THEN
150 10 pfleura2
                 Call Die("ReadInput Gaussian","Iper>3",Unit=IOOUT)
151 10 pfleura2
              END IF
152 10 pfleura2
              NTmp=Index(LineUp," ")
153 10 pfleura2
              LineUp=LineUp(NTmp:)
154 10 pfleura2
              Read(LineUp,*) Lat(IPer,1:3)
155 10 pfleura2
           ELSE
156 10 pfleura2
              Iat=Iat+1
157 10 pfleura2
! we search for additional information at the end of the line
158 10 pfleura2
! for example ONIOM layers
159 10 pfleura2
! TO detect the end of the line, we use the fact that all reals
160 10 pfleura2
! should contain a '.', and that we have 3 reals/line.
161 10 pfleura2
              Idx=Index(Line,'.')
162 10 pfleura2
              Line=ADJUSTL(Line(Idx+1:))
163 10 pfleura2
              Idx=Index(Line,'.')
164 10 pfleura2
              Line=ADJUSTL(Line(Idx+1:))
165 10 pfleura2
              Idx=Index(Line,'.')
166 10 pfleura2
              Line=ADJUSTL(Line(Idx+1:))
167 10 pfleura2
              Idx=Index(Line,' ')
168 10 pfleura2
              If (Idx>0) THEN
169 10 pfleura2
                 Line=ADJUSTL(Line(Idx:))
170 10 pfleura2
                 IF (LEN_TRIM(Line).GT.0) THEN
171 10 pfleura2
                    Gauss_paste(Iat)=ADJUSTL(TRIM(Line))
172 10 pfleura2
                 END IF
173 10 pfleura2
              ELSE
174 10 pfleura2
                 Gauss_paste(Iat)=""
175 10 pfleura2
              END IF
176 10 pfleura2
           END IF
177 5 pfleura2
        END IF
178 10 pfleura2
179 5 pfleura2
     END DO
180 5 pfleura2
181 10 pfleura2
182 5 pfleura2
     IF (Iat.NE.Nat) THEN
183 10 pfleura2
        WRITE(Line,*) "I found ", Iat," lines for the geometry instead of ",Nat
184 10 pfleura2
        Call Die("ReadInput Gaussian","Line",UNIT=IOOUT)
185 5 pfleura2
     END IF
186 10 pfleura2
187 10 pfleura2
  IF (FPBC) THEN
188 10 pfleura2
     Lat_a(1:3)=Lat(1,1:3)
189 10 pfleura2
     Lat_b(1:3)=Lat(2,1:3)
190 10 pfleura2
     Lat_c(1:3)=Lat(3,1:3)
191 10 pfleura2
     If (IPer>=1) THEN
192 10 pfleura2
        kaBeg=-1
193 10 pfleura2
        kaEnd=1
194 10 pfleura2
     END IF
195 10 pfleura2
     If (IPer>=2) THEN
196 10 pfleura2
        kbBeg=-1
197 10 pfleura2
        kbEnd=1
198 10 pfleura2
     END IF
199 10 pfleura2
     If (IPer==3) THEN
200 10 pfleura2
        kcBeg=-1
201 10 pfleura2
        kcEnd=1
202 10 pfleura2
     END IF
203 10 pfleura2
     If (IPer>3) THEN
204 10 pfleura2
        Call Die("Readinput_gaussian","Found too many Tv lines !",Unit=IOOUT)
205 10 pfleura2
     END IF
206 10 pfleura2
  END IF
207 10 pfleura2
208 10 pfleura2
209 5 pfleura2
     ! We now read the last part
210 5 pfleura2
     IF (DEBUG) WRITE(*,*) "Reading Gauss End"
211 5 pfleura2
     !     READ(IOIN,'(A)') Line
212 5 pfleura2
     ALLOCATE(Gauss_End)
213 5 pfleura2
     NuLLIFY(Gauss_End%Next)
214 5 pfleura2
     Current => Gauss_End
215 5 pfleura2
     LineL=1
216 5 pfleura2
     DO WHILE (1.EQ.1)
217 5 pfleura2
        READ(IOIN,'(A)',END=999) Line
218 5 pfleura2
        Line=AdjustL(Line)
219 5 pfleura2
        LineL=len(Trim(Line))
220 5 pfleura2
        current%Line=TRIM(Line)
221 5 pfleura2
        ALLOCATE(current%next)
222 5 pfleura2
        Current => Current%next
223 5 pfleura2
        Nullify(Current%next)
224 5 pfleura2
     END DO
225 5 pfleura2
999  CONTINUE
226 5 pfleura2
227 5 pfleura2
     IF (Debug) THEN
228 5 pfleura2
        ! Write the gaussian input file for testing purposes
229 5 pfleura2
        Current => Gauss_root
230 5 pfleura2
        DO WHILE (ASSOCIATED(Current%next))
231 5 pfleura2
           WRITE(*,'(1X,A)') Trim(current%line)
232 5 pfleura2
           Current => current%next
233 5 pfleura2
        END DO
234 5 pfleura2
235 5 pfleura2
        WRITE(*,*)
236 10 pfleura2
!        WRITE(*,*) '//INFO// Comment original:'
237 5 pfleura2
238 5 pfleura2
        Current => Gauss_comment
239 5 pfleura2
        DO WHILE (ASSOCIATED(Current%next))
240 5 pfleura2
           WRITE(*,'(1X,A)') Trim(current%line)
241 5 pfleura2
           Current => current%next
242 5 pfleura2
        END DO
243 5 pfleura2
244 5 pfleura2
        WRITE(*,*)
245 5 pfleura2
        WRITE(*,*) Trim(Gauss_charge)
246 5 pfleura2
247 5 pfleura2
        DO I=1,Nat
248 10 pfleura2
           WRITE(*,'(1X,A10,3(1X,F15.8),1X,A)') Trim(AtName(I)),XyzGeomI(1,1:3,I), TRIM(Gauss_Paste(I))
249 5 pfleura2
        END DO
250 5 pfleura2
251 5 pfleura2
        WRITE(*,*)
252 5 pfleura2
        Current => Gauss_End
253 5 pfleura2
        DO WHILE (ASSOCIATED(Current%next))
254 5 pfleura2
           WRITE(*,'(1X,A)') Trim(current%line)
255 5 pfleura2
           Current => current%next
256 5 pfleura2
        END DO
257 5 pfleura2
258 5 pfleura2
        WRITE(*,*)
259 5 pfleura2
260 5 pfleura2
        Call Header("Exiting ReadInput_Gaussian")
261 5 pfleura2
262 5 pfleura2
     END IF
263 5 pfleura2
264 5 pfleura2
265 5 pfleura2
266 5 pfleura2
   END SUBROUTINE READINPUT_GAUSSIAN