Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50212/ifind2.f4
There are no other files named ifind2.f4 in the archive.
C*****THE PURPOSE OF IFIND2 IS TO FIND RECORDS BY THEIR ID. IT ASSUMES
C*****A RANDOM SEARCH  I.E.  THE ID@S THAT YOU ARE SEARCHING FOR ARE
C*****NOT NECESSARILY IN SEQUENCIAL ORDER.  IT ALSO ASSUMES THAT THE
C*****ID@S IN THE FILE ARE IN ASCENDING ORDER.  **ID** IS THE TRIAL ID.
C*****IF **IHOW** IS EQUAL TO -1, THEN THE ROUTINE SEARCHES UNTIL
C*****IT FINDS THE FIRST ID LESS THAN **ID**.  IF **IHOW** IS EQUAL TO
C*****ZERO, THEN THE ROUTINE SEARCHES UNTILL IT FINDS THE ID EQUAL TO
C***** **ID**.  IF **IHOW** IS EQUAL TO +1 THEN THE ROUTINE SEARCHES
C*****UNTILL IT FINDS THE FIRST ID GREATER THAN **ID**.  IF THE RECORD
C*****IS FOUND, THEN THE FUNCTION RETURNS WITH THE VALUE 1, AND LSR IS
C*****SET EQUAL TO THE ADDRESS OF THE FOUND RECORD.  IF THE RECORD IS
C*****NOT FOUND THEN LSR REMAINS THE SAME  AND THE FUNCTION RETURNS
C*****WITH THE VALUE ZERO.
      FUNCTION IFIND2 (ID,IHOW)
      DIMENSION IPAR(10), IB(10)
      COMMON IPAR
C*****SAVES ORIGINAL LSR
      ISLSR=IPAR(6)
C***** TESTS TO SEE IF SEARCHED RECORD IS IN THE LIMITS OF THE FILE
C*****ALSO TESTS TO SEE IF THE RECORD IS THE FIRST OR LAST IN THE FILE
      IPAR(6)=IPAR(3)-IPAR(5)
      CALL DIO (IPAR(6),1,IB,1)
      IF (IB(1)-ID) 300,305,11
300   IF (IHOW) 30,3,3
305   IF (IHOW) 62,30,3
11    IPAR(6)=IPAR(2)
      CALL DIO (IPAR(6),1,IB,1)
      IF (ID-IB(1)) 310,320,12
310   IF (IHOW) 3,3,30
320   IF (IHOW) 3,30,63
C*****END OF TEST
C*****IGRTR IS THE UPPER LIMIT.  ISMLR IS THE LOWER LIMIT
12    IGRTR=IPAR(3)
      ISMLR=IPAR(2)
C*****COMPUTE NUMBER OF RECORDS BETWEEN LIMITS
      NR=(IGRTR-ISMLR)/IPAR(5)
      IF (NR)3,3,2
C*****RETURNS WITH ZERO IF RECORD NOT FOUND
3     IFIND2=0
      IPAR(6)=ISLSR
      RETURN
2     IPAR(6)=((NR/2)*IPAR(5))+ISMLR
      CALL DIO (IPAR(6),1,IB,1)
      IF (IHOW)100,200,100
C*****SEARCH WITH IHOW = 0
200   IF (ID-IB(1)) 20,30,40
C*****RETURNS WITH ONE IF RECORD FOUND
30    IFIND2=1
35    RETURN
20    IGRTR=IPAR(6)
5     NR=(IGRTR-ISMLR)/IPAR(5)
      IF(NR-1)3,3,2
40     ISMLR=IPAR(6)
      GO TO 5
C*****SEARCHES WITH IHOW = +1 OR -1
100   IF(ID-IB(1)) 50,60,70
60    IF (IHOW)  62,63,63
62    IPAR(6)=IPAR(6)-IPAR(5)
      GO TO 30
63    IPAR(6)=IPAR(6)+IPAR(5)
      GO TO 30
50    IGRTR=IPAR(6)
6     NR=(IGRTR-ISMLR)/IPAR(5)
      IF (NR-1) 7,7,2
C*****RECORD FOUND.  EITHER EQUAL TO IGRTR OR ISMLR DEPENDING ON IHOW
7     IF(IHOW) 8,8,9
8     IPAR(6)=ISMLR
      GO TO 30
9     IPAR(6)= IGRTR
      GO TO 30
70    ISMLR=IPAR(6)
      GO TO 6
	END