      integer function indx(ax,xx,nx)
*
*  finds index of ax in monotonously increasing or decreasing array xx
*
      implicit real*8 (a-h,o-z)
      dimension xx(nx)
      sx = xx(nx) - xx(1)
      jl = 1
      jh = nx
 1    if (jh-jl.gt.1) then
         j = (jh + jl)/2
         if ((ax-xx(j))*sx .gt. 0.0) then
            jl = j
         else
            jh = j
         end if
         goto 1
      end if
      indx = jh
      end
