cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c     g2xyz.for
c      Converts grid to binary xyz file.

      character id*56,pgm*8
      real z(5000), xyz(3)
      parameter (dval=1.E+37)

      call getfile(21,'*GIVE GRID INFILE:','in','unformatted')
      call getfile(22,'*GIVE XYZ OUTFILE:','out','unformatted')

      read(21) id,pgm,ncol,nrow,nz,xo,dx,yo,dy
c      call gprspecs(id,pgm,ncol,nrow,nz,xo,dx,yo,dy)

      do 50 j=1,nrow
      call getrow(21,ncol,z)
         xyz(2)=yo+dy*(j-1)
      do 40 i=1,ncol
      if(z(i).lt.dval) then
         xyz(1)=xo+dx*(i-1)
         xyz(3)=z(i)
         write(22) xyz
      endif
 40   continue
 50   continue
 
      close(21)
      close(22)

      stop
      end


write(22) xyz
      endif
 40   continue
 50   continue
 
      close(21)
      close(22)

      stop

