      program travel_times
c
c read P arrival times from Nordic file and write out as station, dist,
c observed travel time and calculated travel time
c
c program will have to be improved
c
c Lars Ottemoeller, June 06, 2000
c
c  oct 25 jh : read secs as f6.2

      implicit none
      include 'seidim.inc'
      integer nstat,read01,nphase,nhead,nrecord,id,i,write01
      integer year,mon,day,hour1,min1,sec1,hour2,min2,sec2
      double precision msec1,msec2,res
      character*1 evid,exp
      character*80 data(max_data),infile,outfile


c
c print version
c
      include 'version.inc'
      out_version_date='July 23, 2001'
      if (version_new) out_version_date=version_date
      call print_ver

      read01=1
      write01=2
      outfile='tt.out'
      write(*,*) ' file name '
      read(*,'(a)') infile
      open(read01,file=infile,status='old')
      open(write01,file=outfile,status='unknown')
      write(write01,'(a)') ' STAT  DIST  OBSTT   THTT '
 10   continue
      call indata
     *  (read01,nstat,nphase,nhead,nrecord,evid,exp,data,id)      

      if (nrecord.eq.0) goto 999
      write(*,*) data(1)(2:20)
      read(data(1)(2:20),'(i4,1x,i2,i2,1x,i2,i2,1x,f4.1)')
     *  year,mon,day,hour1,min1,sec1
      call timsec(year,mon,day,hour1,min1,sec1,msec1)
      do i=nhead+1,nrecord
         if (data(i)(11:11).eq.'P'.and.
     *          data(i)(65:68).ne.'    ') then
           read(data(i)(19:28),'(2i2,f6.2)') hour2,min2,sec2
           call timsec(year,mon,day,hour2,min2,sec2,msec2)
           read(data(i)(65:68),'(f4.1)') res
           write(write01,'(1x,a5,1x,a5,1x,f7.2,1x,f7.2)')
     *      data(i)(2:6),data(i)(71:75),msec2-msec1,msec2-msec1-res
         endif

      enddo

      goto 10
999   continue
      close(read01)
      close(write01)
      write(*,*) ' output file: ',outfile
      stop
      end

