c ABS.FOR
c
c  To output absolute value of input grid.
c  Lin Cordell, September 1992
c
      character*50 ifile,ofile
      dimension f(2000),id(14)
      call pfinit('abs')
      write(6,1)
1     format(' Enter input grid file name:'/' *'$)
      read(5,100)ifile
100	format(a50)
      call gopen(10,ifile,'old','read',ierr)
      if(ierr.ne.0) stop 'Error opening input grid file'
      call gheader('r',10,id,ncol,nrow,x0,dx,y0,dy,ierr)
      if(ierr.ne.0) stop 'Error reading grid header'
      if(ncol.gt.2000.or.dx.eq.0.e0) go to 900
        write(6,201)
201   format(1x,'Enter output grid file name:'/' *'$)
      read(5,100)ofile
      call gopen(11,ofile,'new','write',ierr)
      if(ierr.ne.0) stop 'Error opening output grid file'
      write(6,202)
202   format(' Enter new id:'/' *'$)
      read(5,203)(id(i),i=1,14)
203   format(14a4)
      call gheader('w',11,id,ncol,nrow,x0,dx,y0,dy,ierr)
      if(ierr.ne.0) stop 'Error writing grid header'
      do 20 j=1,nrow
      call grow('r',10,y,f,ncol,ierr)
      if(ierr.ne.0) stop 'Error reading row'
      do 10 i=1,ncol
      f(i)=abs(f(i))
10    continue
      call grow('w',11,y,f,ncol,ierr)
      if(ierr.ne.0) stop 'Error writing row'
20	continue
      go to 998
900   write(6,901)
901   format(' Can''t handle it.')
998   call gclose(11,'keep')
999   call gclose(10,'keep')
      end
