      subroutine dofile (infile, agcode, maxag)

      character*(*) infile, agcode(maxag)

c process a fixed format file

      include 'basics.inc'

      character*96 record
      character*6 chival
      character*6 created
      integer nym
      integer*4 decade

      numrec = 0
      open (unit=nin, file=infile,
     2        status='old',
     2        iostat=ios)

c July 16th 2003 Peter - following changed to NOT die if a file
c does not exist     
     
c      if (ios .ne. 0) call abort ('Unable to open input file'//infile)
      
      if (ios .ne. 0) then
          print '(1x,a,a,a)', 'File - ',infile,' does not exist'
          return     
      end if
      
      do while (ios .eq. 0)
        call readin (ios, record, lenrec)
        if (ios .eq. 0) then
          numrec = numrec + 1
          if (lenrec .gt. 0) then
            norec = 1
            if (record(1:2) .eq. ' 0') then
              if (numrec .ne. 1) call abort('Header not first record')
              nym = itchk (record(11:14))*100 + itchk(record(15:16))
              created = record(24:29)
              neditn = itchk(record(30:35))
              if (mout .ne. nout) then
              
                 decade = itchk(record(24:25))
               
                   if ( decade .gt. 50 ) then
                 
                call putout (nout, ' Month='//record(11:14)
     2               //record(15:16)
     2               //', created 19'//created(1:2)//'/'
     2               //created(3:4)//'/'//created(5:6)
     2               //', format edition'//record(30:35)) 
                                
                   else
              
               call putout (nout, ' Month='//record(11:14)
     2               //record(15:16)
     2               //', created 20'//created(1:2)//'/'
     2               //created(3:4)//'/'//created(5:6)
     2               //', format edition'//record(30:35))
     
                   end if
     
              end if
              
            else if (record(1:2) .eq. '90') then      ! agency
            
c following line changed - 03/02/2003 - allows for incorrect 
c positioning of col 20/21 '1' in 2000 files (ONLY)
c              if (itchk(record(20:21)) .eq. 1) then

      if ( ( (lenrec .eq. 21) .and. (record(21:21) .eq. '1') ) .or.
     2     ( (lenrec .eq. 20) .and. (record(20:20) .eq. '1') )  ) then

                nag = itchk (record(11:13))
              if (nag .gt. maxag) call abort ('Too many agencies')
                agcode(nag) = record(14:19)
              end if
            else if (record(1:2) .eq. '91') then      ! station
            else

c process the events on the file

              call events (record, agcode, ios)
            end if
          end if
        end if
      end do
      if (ios .ne. -1)
     2       call abort ('Unusual I/O status code of'//chival(ios))
      close (unit=nin)
      return
      end
