c--- bin2xyzX: converts from C-binary file to ascii file for GMT
      type header_type
        character*30 name(6)
        real*4 period
        integer*4 nlev
        real*4 xlev(20)
        real*4 extra(10)
      end type header_type
      type(header_type) :: headr
      integer*4 readn
      dimension z(200000)
      character name*30,name2*30,name1*30
      call getarg(1,name)
      open(unit=1,file=name)
  900 format(a256)
c      write(6,*) "enter name of input file"
c      read(5,900) name1
      call getarg(2,name1)
      read(1,*) ymin, ymax, dy
      read(1,*) xmin, xmax, dx
      nx= ceiling((xmax-xmin)/dx +1)
      ny= ceiling((ymax-ymin)/dy +1)
      nrec= nx*ny
      call openr(name1)
      ndata= 308
      call gethead(headr,ndata,readn)
      call getbuf2(z,nrec,readn)
      do 10 i=1,nrec
      iy= (i-1)/nx 
      ix= i- 1- iy*nx
      xlat= ymax- iy*dy
      xlon= xmin+ ix*dx
      write(6,*) xlon,xlat,z(i)
 10   continue
      end
