Statistiques
| Révision :

root / src / ReadInput_gaussian.f90 @ 8

Historique | Voir | Annoter | Télécharger (4,28 ko)

1
 SUBROUTINE ReadInput_gaussian
2

    
3
! This routine reads an input template for Gaussian
4

    
5
  use VarTypes
6
  use Path_module
7
  use Io_module
8

    
9
  IMPLICIT NONE
10

    
11
  INTERFACE
12
     function valid(string) result (isValid)
13
       CHARACTER(*), intent(in) :: string
14
       logical                  :: isValid
15
     END function VALID
16
  END INTERFACE
17

    
18

    
19
  CHARACTER(132) ::  Line
20
  INTEGER(KINT) :: LineL, Idx, Iat
21
  INTEGER(KINT) :: I
22
  
23
  LOGICAL :: Debug
24

    
25

    
26
  Debug=Valid("readinput").OR.Valid("readinput_gaussian")
27

    
28
 if (debug) Call Header("Entering ReadInput_Gaussian")
29

    
30
  ! We read the Gaussian input file
31
  ! First, the root
32
     IF (DEBUG) WRITE(*,*) "Reading Gauss Root"
33
     ALLOCATE(Gauss_Root)
34
     NULLIFY(Gauss_Root%next)
35
     Current => Gauss_root
36
     LineL=1
37
     DO WHILE (LineL.NE.0)
38
        READ(IOIN,'(A)') Line
39
        Line=AdjustL(Line)
40
        LineL=len_Trim(Line)
41
! we do not read the %chk line
42
        Idx=INDEX(Line,"chk")
43
        IF ((LineL.NE.0).AND.(Idx.EQ.0)) THEN
44
           current%Line=TRIM(Line)
45
           ALLOCATE(current%next)
46
           Current => Current%next
47
           Nullify(Current%next)
48
        END IF
49
     END DO
50

    
51
!     Current => Gauss_root
52
!     DO WHILE (ASSOCIATED(Current%next))
53
!        WRITE(*,'(1X,A)') Trim(current%line)
54
!        Current => current%next
55
!     END DO
56

    
57
     ! Now the comment... 
58
     IF (DEBUG) WRITE(*,*) "Reading Gauss Comment"
59
     ALLOCATE(Gauss_Comment)
60
     NuLLIFY(Gauss_Comment%Next)
61
     Current => Gauss_comment
62
     LineL=1
63
     DO WHILE (LineL.NE.0)
64
        READ(IOIN,'(A)') Line
65
        Line=AdjustL(Line)
66
        LineL=len(Trim(Line))
67
        IF (LineL.NE.0) THEN
68
           current%Line=TRIM(Line)
69
           ALLOCATE(current%next)
70
           Current => Current%next
71
           Nullify(Current%next)
72
        END IF
73
     END DO
74

    
75
 !    Current => Gauss_comment
76
 !    DO WHILE (ASSOCIATED(Current%next))
77
 !       WRITE(*,'(1X,A)') Trim(current%line)
78
 !       Current => current%next
79
 !    END DO
80

    
81
     ! Now the charge
82
     IF (DEBUG) WRITE(*,*) "Reading Gauss Charge"
83
     READ(IOIN,'(A)') Gauss_Charge
84
     if (debug) WRITE(*,*) "Gauss_charge=",TRIM(Gauss_charge)
85
     ! We now read the Paste part...
86
     ALLOCATE(Gauss_Paste(NAt))
87
     LineL=1
88
     Iat=0
89
     Gauss_paste=" "
90
     DO While (LineL.GT.0)
91
        READ(IOIN,'(A)') Line
92
        Line=AdjustL(Line)
93
        LineL=Len_TRIM(Line)
94
        IF (LineL.GT.0) Iat=Iat+1
95
        Idx=Index(Line,'.',BACK=.TRUE.)
96
        Line=ADJUSTL(Line(Idx+1:))
97

    
98
        IF (LEN_TRIM(Line).GT.0) THEN 
99
           Gauss_paste(Iat)=ADJUSTL(TRIM(Line))
100
        END IF
101
     END DO
102

    
103
     IF (Iat.NE.Nat) THEN
104
        WRITE(*,*) "I found ", Iat," lines for the geometry instead of ",Nat
105
        WRITE(*,*) "ERROR. STOP"
106
        WRITE(IOOUT,*) "I found ", Iat," lines for the geometry instead of ",Nat
107
        WRITE(IOOUT,*) "ERROR. STOP"
108
        STOP
109
     END IF
110
     ! We now read the last part
111
     IF (DEBUG) WRITE(*,*) "Reading Gauss End"
112
     !     READ(IOIN,'(A)') Line
113
     ALLOCATE(Gauss_End)
114
     NuLLIFY(Gauss_End%Next)
115
     Current => Gauss_End
116
     LineL=1
117
     DO WHILE (1.EQ.1)
118
        READ(IOIN,'(A)',END=999) Line
119
        Line=AdjustL(Line)
120
        LineL=len(Trim(Line))
121
        current%Line=TRIM(Line)
122
        ALLOCATE(current%next)
123
        Current => Current%next
124
        Nullify(Current%next)
125
     END DO
126
999  CONTINUE
127

    
128
     IF (Debug) THEN
129
        ! Write the gaussian input file for testing purposes
130
        Current => Gauss_root
131
        DO WHILE (ASSOCIATED(Current%next))
132
           WRITE(*,'(1X,A)') Trim(current%line)
133
           Current => current%next
134
        END DO
135
        
136
        WRITE(*,*) 
137
        WRITE(*,*) 'Comment original'
138
        
139
        Current => Gauss_comment
140
        DO WHILE (ASSOCIATED(Current%next))
141
           WRITE(*,'(1X,A)') Trim(current%line)
142
           Current => current%next
143
        END DO
144
        
145
        WRITE(*,*) 
146
        WRITE(*,*) Trim(Gauss_charge)
147
        
148
        DO I=1,Nat
149
           WRITE(*,'(1X,A10,3(1X,F15.8),A)') Trim(AtName(I)),XyzGeomI(1,1:3,I), TRIM(Gauss_Paste(I))
150
        END DO
151
        
152
        WRITE(*,*) 
153
        Current => Gauss_End
154
        DO WHILE (ASSOCIATED(Current%next))
155
           WRITE(*,'(1X,A)') Trim(current%line)
156
           Current => current%next
157
        END DO
158
        
159
        WRITE(*,*) 
160

    
161
        Call Header("Exiting ReadInput_Gaussian")
162

    
163
     END IF
164

    
165

    
166

    
167
   END SUBROUTINE READINPUT_GAUSSIAN