c  program to convert any miniseed file to s nicer  miniseed,
c needed when seisan cannot read miniseed files, mar 07 jh
c  it uses chad's program msrepack
c
c           not tested much
c
c  aug 16 07 jh : fix pc bug


      implicit none
      character*80 infile                   ! input filename
      character*80 outfile                 
      character*80 question
      integer seiclen
      integer i,in
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

 10   continue
c
c input file names
c
      question=' Filename or number, filenr.lis for all'
      call filename(question,infile)
      if (infile(1:3).eq.'EOF') stop

      in=0
      if (infile(1:10).eq.'filenr.lis') then
        in=1
        open(60,file=infile,status='old',err=9999)
      endif

 20   continue

      if (in.eq.1) then 
         read(60,'(7x,a)') infile
         if(infile(1:4).eq.'    ') stop
      endif

      write(6,'(1x,a13,a)') ' input file: ',infile
      write(*,*) 
c
c   convert binary file to ascii
c
      i=seiclen(infile)   ! length of file name
c
c   make new output file name
c
      outfile(1:i+1)=infile(1:i)//'c'
      write(6,*)' Output file name: ', outfile
c
c   rewrite file using program msrepack, write steim1
c
      call systemc
     *('msrepack '//infile(1:i)//' -i -E 10 -o '//outfile(1:i+1),23+2*i)
c
c   go for next file
c
      if(in.eq.1) goto 20
      write(6,*)' Output file name: ', outfile

      goto 10
c
9999  continue

      stop
      end


