C******************** START FILE IUFSLO.FOR ; GROUP UFILS0 ******************
C----------------------------------------------------------
C  IUFSLO
C  LOCATE ALPHABETIC POSITION OF KEYWORD IN LIST
C
      INTEGER FUNCTION IUFSLO(ZKEY,LISLEN,ZLIST,IORDER,IEQ)
      INTEGER IORDER(LISLEN)
      CHARACTER*10 ZKEY
      CHARACTER*30 ZLIST(LISLEN)
C
C  ZKEY-- KEYWORD (10 CHARS) WHOSE ORDER IS TO BE LOCATED
C  ZLIST-- LIST OF KEYWORDS IS IN FIRST COL. OF ZLIST
C  IORDER-- ALPHABETIC ORDER OF ZLIST
C  LISLEN-- LENGTH OF LIST,IORDER
C
C  IEQ-- OUTPUT FLAG-- IEQ=1 IF ZKEY = ZLIST(IORDER(ILOC))
C    OTHERWISE SHOULD BE INSERTED BEFORE THE INDICATED ELEMENT
C    TO MAINTAIN ALPHABETIC ORDER
C  UTILIZE BINARY SEARCH ALGORITHM
C  ASSUME THAT ZKEY=ZLIST(J) FOR SOME J NOT POSSIBLE
C  (CHECK AGAINST SCALAR KEYWORD DUPLICATION IS PROVIDED IN
C  SUBROUTINE UF0RDR FOR UFILES FILES)
C
C  USE INTEGER SUBFUNCTION IUFORD(KEY1,KEY2)
C   =0  IF KEY1=KEY2
C   =-1 IF KEY1<KEY2
C   =+1 IF KEY1>KEY2
C
C
C  CHECK IF ENTRY GOES AT END OF LIST
      IEQ=0
      IUFSLO=LISLEN+1
      IOL=IUFORD(ZKEY,ZLIST(IORDER(LISLEN)))
C  SEE IF GOES AT END OF LIST
      IF(IOL.GT.0) GO TO 8000
      IMID=LISLEN
      IF(IOL.EQ.0) GO TO 500
C
C  BINARY SEARCH TO LOCATE ENTRY BEFORE WHICH TO INSERT ZKEY
C
      ITOP=1
      IBOT=LISLEN
C
 110  CONTINUE
      IMID=(ITOP+IBOT)/2
      IOL=IUFORD(ZKEY,ZLIST(IORDER(IMID)))
      IF(IOL.EQ.0) GO TO 500
      IF(IOL.LT.0) THEN
C  ZKEY GOES HIGHER IN LIST
        IBOT=IMID
C  DONE?
        IF(IBOT.EQ.ITOP) GO TO 200
      ELSE
C  ZKEY GOES LOWER IN LIST
        ITOP=IMID+1
      ENDIF
      GO TO 110
C  POSITION LOCATED
 200  CONTINUE
      IUFSLO=ITOP
      RETURN
C  POSITION LOCATED-- ZKEY IS A DUPLICATE
 500  CONTINUE
      IUFSLO=IMID
      IEQ=1
8000  CONTINUE
      RETURN
      END
C******************** END FILE IUFSLO.FOR ; GROUP UFILS0 ******************
