c     ROW2ASC.FOR
c     converts 1-row grid to ascii x,y,f(x) file (an "xyz" file, i.e.)
c     Lin Cordell 12 August 92
c
      character*50 infile,outfile
      dimension f(2000),id(14),pgm(2)
      ifft=2
c  Input
      print 101,' Enter input file name (a 1-row grid):'
101   format(a,/' *'$)
      read(5,100)infile
100   format(a50)
      open(10,file=infile,form='unformatted',status='old',err=995)
      read(10)id,pgm,ncol,nrow,nz,x0,dx,y0,dy
      if(ncol.le.2000.and.dx.ne.0.e0.and.nz.eq.1)go to 3
      write(6,2)
2     format(1x,'Can''t handle it.')
      go to 999
3     continue
      read(10) y,(f(i),i=1,ncol)
      print 101,' Enter output file name:'
      read (5,100)outfile
      open(11,file=outfile,status='new',form='formatted')
      do 7 i=1,ncol
      x=x0+(i-1)*dx
      write(11,*)x,y,f(i)
7     continue
      go to 999
995   print*,' Cant find the file.'
999   continue
      stop
      end
