c cee.for
c
c produce color edge-enhanced r,g,b grids from output of gradient and rainbow.
c
c Jeff Phillips 8 Aug 91
      dimension s(3000),r(3000),g(3000),b(3000)
      dimension id(14),pgm(2)
      character*50 ifile
      print *,'Enter name of gradient grid file:'
      read(5,100) ifile
      print *,'Enter gradient cutoff:'
      read(5,*) cut
  100 format(a)
      open(10,file=ifile,form='unformatted',status='old')
      open(11,file='red.grd',form='unformatted',status='old')
      open(12,file='green.grd',form='unformatted',status='old')
      open(13,file='blue.grd',form='unformatted',status='old')
      open(14,file='ered.grd',form='unformatted',status='unknown')
      open(15,file='egreen.grd',form='unformatted',status='unknown')
      open(16,file='eblue.grd',form='unformatted',status='unknown')
      read(10)id,pgm,ncol,nrow,nz,xo,dx,yo,dy
      if(ncol.gt.3000) stop 'ncol > 3000'
      read(11)id
      read(12)id
      read(13)id
      write(14)id,pgm,ncol,nrow,nz,xo,dx,yo,dy
      write(15)id,pgm,ncol,nrow,nz,xo,dx,yo,dy
      write(16)id,pgm,ncol,nrow,nz,xo,dx,yo,dy
      do 20 j=1,nrow
      read(10) dlt,(s(i),i=1,ncol)
      read(11) dlt,(r(i),i=1,ncol)
      read(12) dlt,(g(i),i=1,ncol)
      read(13) dlt,(b(i),i=1,ncol)
      do 10 i=1,ncol
      if (s(i).gt.cut) s(i)=cut
      r(i)=r(i)*(cut - s(i))/cut
      g(i)=g(i)*(cut - s(i))/cut
      b(i)=b(i)*(cut - s(i))/cut
   10 continue
      write(14) dlt,(r(i),i=1,ncol)
      write(15) dlt,(g(i),i=1,ncol)
      write(16) dlt,(b(i),i=1,ncol)
   20 continue
      stop
      end
