      function luchs(ivr,lst,n)
      character*12 ivr,lst(1)
      integer n,luchs,m,k,mc
C                                                                       
C  BINARY SEARCH ROUTINE - VECTOR lst IS SORTED IN ASCENDING ORDER        
C     ivr = VARIABLE TO BE LOCATED                                        
C     n = LENGTH OF THE VECTOR lst 
C     K = LOCATION OF VARIABLE M, IF FOUND, OTHERWISE K = 0             
C 
c      write(*,*)ivr,n
c      write(*,*)lst(1)
c      write(*,*)lst(n)
      luchs = 0
      IF(ivr.lt.lst(1))write(*,*) ' LT ',ivr,lst(1) 
      IF(ivr.gt.lst(n))write(*,*) ' GT ',ivr,lst(n)

      luchs = 0
      IF(ivr.lt.lst(1))go to 99
      IF(ivr.gt.lst(n))go to 99
c
      ml=1
      mu=n
c      write(*,*)ml,mu
c
 5    md = mu - ml
      if(md.lt.2)go to 7
      j = (md/2)+ml
      if(ivr.eq.lst(j))go to 98
      if(ivr.gt.lst(j))then
         ml = j
       else  
         mu = j
       endif  
      go to 5 
c
 7    if(ivr.eq.lst(mu))luchs=mu
      if(ivr.eq.lst(ml))luchs=ml
      return
 98   luchs = j
 99   return
      end
