c  ICOR.FOR
c  To convert image to grid coordinates and dn to grid values.
      character*50 infile
      dimension id(14)
10    write(6,6)
6     format(1x,'Enter input grid file name:'/1x,'*'$)
      read(5,2)infile
2     format(a50)
      open(10,file=infile,status='old',form='unformatted')
      read(10)id,pgm1,pgm2,ncol,nrow,nz,x0,dx,y0,dy
33    write(6,3)(id(i),i=1,14),pgm1,pgm2
3     format(1x,14a4,/1x,2a4)
      write(6,4)ncol,nrow,nz
4     format(1x,'ncol =',0pi5,5x,'nrow =',i5,5x,'nz =',i3)
      write(6,5)x0,dx,y0,dy
5     format(1x,'x0 =',g14.7,2x,'dx =',g14.7,3x,'y0 =',g14.7,2x,'dy =',
     &g14.7)
      s=0
      c=0
20    print*,'Enter pixel number and line number:'
      print 1
1     format(' *'$)
      read*, ip,il
      ic=ip
      ir=nrow-il+1
      x=(ic-1)*dx
      y=(ir-1)*dy
      print*,' col = ',ic,',  row = ',ir
      print*,' x = ',x,',   y = ',y
24    print*,' Enter 1 to do another, 2 to compute function, 3 to quit.'
      read*,mode
      if (mode.eq.1)go to 20
      if (mode.ne.2)go to 300
      if(s.eq.0.and.c.eq.0) then
        print*,' Enter s and c from remapp.log file:'
        print 1
        read*,s,c
      endif
      print*,' Enter dn value:'
      print 1
      read*,idn
      f=(idn-c)/s
      print*,' Functional value = ',f
      go to 24
300   close (10)
      stop
      end
