File: debug_zmat.F

package info (click to toggle)
aces3 3.0.6-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 82,460 kB
  • sloc: fortran: 225,647; ansic: 20,413; cpp: 4,349; makefile: 953; sh: 137
file content (214 lines) | stat: -rw-r--r-- 6,655 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
C  Copyright (c) 2003-2010 University of Florida
C
C  This program is free software; you can redistribute it and/or modify
C  it under the terms of the GNU General Public License as published by
C  the Free Software Foundation; either version 2 of the License, or
C  (at your option) any later version.

C  This program is distributed in the hope that it will be useful,
C  but WITHOUT ANY WARRANTY; without even the implied warranty of
C  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
C  GNU General Public License for more details.

C  The GNU General Public License is included in this distribution
C  in the file COPYRIGHT.

C Read the Z-matrix and find errors.

#include "iachar.h"

      subroutine debug_zmat
      implicit none

c "parameters"
#include "mxatms.par"
#include "io_units.par"
#include "linelen.par"

      character*(linelen) zline, dline
      integer izl(2,7), ref(3)
      logical not_done

      integer atoi, linblnk, i, j, k, iatom

      character*1 achar, czTab, czSpace, czPercent, czComment

c ----------------------------------------------------------------------

      czTab     = achar(_IACHAR_TAB)
      czSpace   = achar(_IACHAR_SPACE)
      czComment = achar(_IACHAR_POUND)
      czPercent = achar(_IACHAR_PERCENT)

      inquire(file=zfil,opened=not_done)
      if (.not.not_done)
     &   open(unit=luz,file=zfil,form='formatted',status='old')
      rewind luz

c   o skip the header (zline=TITLE on end do)
      not_done = .true.
      do while (not_done)
         read(luz,'(a)') zline
         call parsez(zline,izl)
         i = izl(1,1)
         not_done = (i.eq.0).or.(zline(i:i).eq.czPercent)
      end do

c   o first element
      read(luz,'(a)') zline
      call parsez(zline,izl)
      if (izl(1,1).eq.0) then
         write(*,*)
     &      '@DEBUG_ZMAT: There are no elements in the Z-matrix.'
         call errex
      end if
      if (izl(1,2).ne.0) then
         write(*,*)
     &      '@DEBUG_ZMAT: There are extra tokens on the first line.'
         write(*,*)
     &      '             (Perhaps the title line is missing.)'
         write(*,*) ' 1 : ',zline(izl(1,1):izl(2,2)),' ...'
         write (*,*) ' izl(1,2) = ',izl(1,2)
         call errex
      end if

c   o second element
      read(luz,'(a)') zline
      call parsez(zline,izl)
      if (izl(1,3).eq.0) then
         write(*,*)
     &      '@DEBUG_ZMAT: Line 2 must have three values.'
         i = max( izl(2,2) , izl(2,1) )
         write(*,*) ' 2 : ',zline(izl(1,1):i)
         call errex
      end if
      if (izl(1,4).ne.0) then
         write(*,*)
     &      '@DEBUG_ZMAT: There are extra tokens on the second line.'
         write(*,*) ' 2 : ',zline(izl(1,1):izl(2,4)),' ...'
         call errex
      end if

c   o third element
      read(luz,'(a)') zline
      call parsez(zline,izl)
      if (izl(1,5).eq.0) then
         write(*,*)
     &      '@DEBUG_ZMAT: Line 3 must have five values.'
         i = max( izl(2,4) , izl(2,3) , izl(2,2) , izl(2,1) )
         write(*,*) ' 3 : ',zline(izl(1,1):i)
         call errex
      end if
      if (izl(1,6).ne.0) then
         write(*,*)
     &      '@DEBUG_ZMAT: There are extra tokens on the third line.'
         write(*,*) ' 3 : ',zline(izl(1,1):izl(2,6)),' ...'
         call errex
      end if

c   o remaining elements
      iatom = 4
      read(luz,'(a)') zline
      call parsez(zline,izl)
      not_done = .true.
      do while (not_done)

         if (izl(1,7).eq.0) then
            write(*,*)
     &         '@DEBUG_ZMAT: Line ',iatom,' must have seven values.'
            i = max( izl(2,6) , izl(2,5) , izl(2,4) ,
     &               izl(2,3) , izl(2,2) , izl(2,1) )
            write(*,*) iatom,' : ',zline(izl(1,1):i)
            call errex
         end if

         ref(1) = atoi( zline(izl(1,2):izl(2,2)) )
         ref(2) = atoi( zline(izl(1,4):izl(2,4)) )
         ref(3) = atoi( zline(izl(1,6):izl(2,6)) )

c        REUSED REFS

         if (ref(1).eq.ref(2)) then
            dline = zline
            call prep_dline_2(dline,izl,2,4)
            write(*,*) '@DEBUG_ZMAT: References cannot be reused.'
            write(*,*) iatom,' : ',zline(izl(1,1):izl(2,7))
            write(*,*) iatom,' : ',dline(izl(1,1):izl(2,7))
            write(*,*)
         end if

         if (ref(1).eq.ref(3)) then
            dline = zline
            call prep_dline_2(dline,izl,2,6)
            write(*,*) '@DEBUG_ZMAT: References cannot be reused.'
            write(*,*) iatom,' : ',zline(izl(1,1):izl(2,7))
            write(*,*) iatom,' : ',dline(izl(1,1):izl(2,7))
            write(*,*)
         end if

         if (ref(2).eq.ref(3)) then
            dline = zline
            call prep_dline_2(dline,izl,4,6)
            write(*,*) '@DEBUG_ZMAT: References cannot be reused.'
            write(*,*) iatom,' : ',zline(izl(1,1):izl(2,7))
            write(*,*) iatom,' : ',dline(izl(1,1):izl(2,7))
            write(*,*)
         end if

c        ZERO REFS

         do j = 1, 3
            if (ref(j).eq.0) then
               dline = zline
               i = ishft(j,1)
               call prep_dline_2(dline,izl,i,i)
               write(*,*) '@DEBUG_ZMAT: Reference ',j,' for element ',
     &                    iatom,' does not exist.'
               write(*,*) iatom,' : ',zline(izl(1,1):izl(2,7))
               write(*,*) iatom,' : ',dline(izl(1,1):izl(2,7))
               write(*,*)
            end if
         end do

c        UNDEFINED REFS

         do j = 1, 3
            if (ref(j).gt.iatom) then
               dline = zline
               i = ishft(j,1)
               call prep_dline_2(dline,izl,i,i)
               write(*,*) '@DEBUG_ZMAT: Reference ',j,' for element ',
     &                    iatom,' has not yet been defined.'
               write(*,*) iatom,' : ',zline(izl(1,1):izl(2,7))
               write(*,*) iatom,' : ',dline(izl(1,1):izl(2,7))
               write(*,*)
            end if
         end do

c        SELF-REF

         do j = 1, 3
            if (ref(j).eq.iatom) then
               dline = zline
               i = ishft(j,1)
               call prep_dline_2(dline,izl,i,i)
               write(*,*) '@DEBUG_ZMAT: Element ',iatom,
     &                    ' references itself.'
               write(*,*) iatom,' : ',zline(izl(1,1):izl(2,7))
               write(*,*) iatom,' : ',dline(izl(1,1):izl(2,7))
               write(*,*)
            end if
         end do

         iatom = iatom + 1
         read(luz,'(a)') zline
         call parsez(zline,izl)
         not_done = (linblnk(zline(1:80)).ne.0)

c     end do while (not_done)
      end do

      call errex
      return
      end