      subroutine bcspefnd(x, nx, zxget, i)
C...Translated by Pacific-Sierra Research VAST-90 2.06G2  10:50:51  10/ 1/01  
C...Switches: -p4 -yb
      implicit none
C-----------------------------------------------
C   D u m m y   A r g u m e n t s
C-----------------------------------------------
      integer nx, i
      real zxget
      real, dimension(nx) :: x
C-----------------------------------------------
C   L o c a l   V a r i a b l e s
C-----------------------------------------------
      integer :: nxm, i1, i2, ij, ii
      real :: dx
C-----------------------------------------------
c
c
c  find index i such that x(i).le.zxget.le.x(i+1)
c
c  x(1...nx) is strict increasing and x(1).le.zxget.le.x(nx)
c  (this is assumed to already have been checked -- no check here!)
c
      nxm = nx - 1
      if (i<1 .or. i>nxm) then
         i1 = 1
         i2 = nx - 1
         go to 10
      endif
c
      if (x(i) > zxget) then
c  look down
         dx = x(i+1) - x(i)
         if (x(i) - zxget > 4*dx) then
            i1 = 1
            i2 = i - 1
            go to 10
         else
            i2 = i - 1
            do ij = i2, 1, -1
               if (x(ij)<=zxget .and. zxget<=x(ij+1)) then
                  i = ij
                  return 
               endif
            end do
            i = 1
            return 
         endif
      else if (x(i+1) < zxget) then
c  look up
         dx = x(i+1) - x(i)
         if (zxget - x(i+1) > 4*dx) then
            i1 = i + 1
            i2 = nxm
            go to 10
         else
            i2 = i + 1
            do ij = i2, nxm
               if (x(ij)<=zxget .and. zxget<=x(ij+1)) then
                  i = ij
                  return 
               endif
            end do
            ij = nxm
            return 
         endif
      else
c  already there...
         return 
      endif
c
c---------------------------
c  binary search
c
   10 continue
c
      if (i1 == i2) then
c found by proc. of elimination
         i = i1
         return 
      endif
c
      ii = (i1 + i2)/2
c
      if (zxget < x(ii)) then
         i2 = ii - 1
      else if (zxget > x(ii+1)) then
         i1 = ii + 1
      else
c found
         i = ii
         return 
      endif
c
      go to 10
c
      end subroutine bcspefnd
