PROGRAM LIMITS 100 FORMAT(A20) 101 FORMAT(A80) 200 FORMAT(' Type name of data file...:'$) 201 FORMAT(' Number of events in file = ',I9// &' Writing last event for checking:'// &2(1X,I2),1X,I4,2(1X,I2),1X,F5.2,1X,F6.2,1X,F7.2,1X,I3, &1X,F3.1) 202 FORMAT(/' West limit = ',F7.2/' East limit = ',F7.2/ &' South limit = ',F6.2/' North limit = ',F6.2) 203 FORMAT(/' Maximum magnitude = ',F3.1) CHARACTER*2 TEST2 CHARACTER*7 TEST7 CHARACTER*20 FILEIN,INIFILE CHARACTER*80 LINE INTEGER I,IPOS(10) INTEGER IDAY,IMONTH,IYEAR,IHOUR,IMIN,IDEPTH,NEVTS REAL RSECOND,RLAT,RLON,RMAG,EFLON,RITLON,BOTLAT,TOPLAT REAL RMAXMAG DATA INIFILE/'MYREAD.INI'/ DATA IPOS /10*-1/ EFLON=180.0 RITLON=-180.0 BOTLAT=90.0 TOPLAT=-90.0 RMAXMAG=-9.0 C C Get file names and open data file C WRITE(6,200) READ(5,100) FILEIN OPEN(UNIT=1,NAME=FILEIN,ERR=90,STATUS='UNKNOWN') C C Examine first line of data file to see C if it's a header line. Look for longitude C (lamda - LLLLLLL) because it won't be found C accidentally in some other sort of file. C READ(1,101) LINE DO 1 I=0,73 READ(LINE,102) TEST7 102 FORMAT(X,A7) IF(TEST7.EQ.'LLLLLLL') GOTO2 1 CONTINUE C C If we get to here, there's no header in the file, C so get the last used one from the .ini file. C OPEN(UNIT=2,NAME=INIFILE,ERR=91,STATUS='OLD') READ(2,101) LINE CLOSE(2) C C Now start sorting out the positions of each code C in the line. IPOS(whatever) records the number of C characters in the line before the various positions C in the order day, month, year, hour, minute, second, C lat,long, depth, magnitude. C 2 DO 3 I=0,78 READ(LINE,103) TEST2 103 FORMAT(X,A2) IF(TEST2.EQ.'DD') IPOS(1)=I IF(TEST2.EQ.'MM') IPOS(2)=I IF(TEST2.EQ.'YY'.AND.IPOS(3).EQ.-1) IPOS(3)=I IF(TEST2.EQ.'HH') IPOS(4)=I IF(TEST2.EQ.'II') IPOS(5)=I IF(TEST2.EQ.'SS'.AND.IPOS(6).EQ.-1) IPOS(6)=I IF(TEST2.EQ.'PP'.AND.IPOS(7).EQ.-1) IPOS(7)=I IF(TEST2.EQ.'LL'.AND.IPOS(8).EQ.-1) IPOS(8)=I IF(TEST2.EQ.'KK'.AND.IPOS(9).EQ.-1) IPOS(9)=I IF(TEST2.EQ.'RR'.AND.IPOS(10).EQ.-1) IPOS(10)=I 3 CONTINUE C C Now check that all parameters have been located C DO 4 I=1,10 IF(IPOS(I).EQ.-1) STOP 'A parameter was missing' 4 CONTINUE C C A header has been successfully read - record it for C future reference. C OPEN(UNIT=2,NAME=INIFILE,ERR=91,STATUS='UNKNOWN') WRITE(2,101) LINE CLOSE(2) C C Now the file itself can be read for data. If the first C line was not a header (TEST7 didn't return 'LLLLLLL') C then read the first event before getting another one. C Read the whole file and return the number of events and C write out the last of them. C NEVTS=0 IF(TEST7.NE.'LLLLLLL') GOTO 6 5 READ(1,101,END=7) LINE 6 I=IPOS(1) READ(LINE,300) IDAY I=IPOS(2) READ(LINE,300) IMONTH I=IPOS(4) READ(LINE,300) IHOUR I=IPOS(5) READ(LINE,300) IMIN 300 FORMAT(X,I2) I=IPOS(9) READ(LINE,301) IDEPTH 301 FORMAT(X,I3) I=IPOS(3) 302 FORMAT(X,I4) READ(LINE,302) IYEAR I=IPOS(10) READ(LINE,303) RMAG 303 FORMAT(X,F3.1) I=IPOS(6) READ(LINE,304) RSECOND 304 FORMAT(X,F5.2) I=IPOS(7) READ(LINE,305) RLAT 305 FORMAT(X,F6.2) I=IPOS(8) READ(LINE,306) RLON 306 FORMAT(X,F7.2) NEVTS=NEVTS+1 C C Now see if this event changes the catalogue limits C IF(RLON.LT.EFLON) EFLON=RLON IF(RLON.GT.RITLON) RITLON=RLON IF(RLAT.LT.BOTLAT) BOTLAT=RLAT IF(RLAT.GT.TOPLAT) TOPLAT=RLAT IF(RMAG.GT.RMAXMAG) RMAXMAG=RMAG GOTO 5 7 WRITE(6,201) NEVTS,IDAY,IMONTH,IYEAR,IHOUR,IMIN,RSECOND, &RLAT,RLON,IDEPTH,RMAG WRITE(6,202) EFLON,RITLON,BOTLAT,TOPLAT WRITE(6,203) RMAXMAG CLOSE(1) STOP ' Successful completion' 90 STOP ' Couldn''t open data file' 91 STOP ' Couldn''t open ini file' END