Statistics
| Revision:

root / src / ReadInput_gaussian.f90 @ 5

History | View | Annotate | Download (4.3 kB)

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,Line2
20
  INTEGER(KINT) :: LineL, Idx, Iat
21
  INTEGER(KINT) :: I
22
  REAL(KREAL) :: Xtmp,YTmp,ZTmp  
23
  LOGICAL :: Tchk
24
  
25
  LOGICAL :: Debug
26

    
27

    
28
  Debug=Valid("readinput").OR.Valid("readinput_gaussian")
29

    
30
 if (debug) Call Header("Entering ReadInput_Gaussian")
31

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

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

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

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

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

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

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

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

    
163
        Call Header("Exiting ReadInput_Gaussian")
164

    
165
     END IF
166

    
167

    
168

    
169
   END SUBROUTINE READINPUT_GAUSSIAN