! ----------------------------------------
!  picks2seplib.f90 - Created by Morgan Brown
!           Tue Feb 20 10:29:46 2001.
! ----------------------------------------
!       Usage: picks2seplib.x fname=filename.txt > tv.H
!  Parameters: fname - Name of Rickmovie pick file (less than 50 characters).
! Description: Takes a Rickmovie pick file and writes the abcissas and ordinates to
!              a sepfile.
! ----------------------------------------
program picks2seplib

  use sep

  implicit none

  integer                     :: n1, n2, fstat, ipick, npick
  real                        :: d1, d2, o1, o2
  real, dimension(:), pointer :: t, v
  character(len=1)            :: a
  character(50)               :: fname

  call sep_init(SOURCE)
  call from_param('fname',fname)

2000 format( a3, 1x, f8.5,f8.5, 1x, f10.0, 44x)

  open( unit=20, file=fname, status='old' )
  npick = 0; fstat=0
  do while( fstat==0 )
     read( 20, 2000, iostat=fstat )
     npick = npick + 1
  end do
  close( unit=20 )

  open( unit=20, file=fname, status='old' )
  allocate( t(npick-1), v(npick-1) )
  do ipick=1,npick-1
     read( 20, 2000, iostat=fstat )  a, t(ipick), v(ipick)
  end do
  close( unit=20 )

  call to_history( 'n1', npick-1)
  call to_history( 'n2', 2)

  call sep_close()

  call sep_write( t)
  call sep_write( v)

  call exit(0)

end program picks2seplib





