      subroutine fgivev(iarg)
      vector ichan
      vector gival
      vector val
      vector nclim
      vector icval(1)
      if ( iarg .eq. 0 ) then
         gival(1)=log10(val(4))
         gival(2)=log10(val(5))
         gival(3)=(gival(2)-gival(1)) / ( nclim(2) -nclim(1) + 1) 
         write(*,*)gival,nclim
      else
c      write(*,*)ichan
         i=ichan(2)
         j=ichan(3)
         ihisto=ichan(1)
         vbin=hij(ihisto,i,j)
         if (vbin .lt. val(4) ) then
             icval(1) = 8
         else if ( vbin .gt. val(5) ) then
             icval(1)=nclim(2) +7 
         else
            vbin=log10(vbin)
            icval(1)= ( vbin-gival(1)) / gival(3) + nclim(1) +7
         endif
*         write(*,*)i,j,ihisto,vbin,icval(1)
      endif
      return
      end
