C------------------------------------------------------------- ************ C ISRCHIEQ C ************ INTEGER FUNCTION ISRCHIEQ(N,ARRAY,INC,TARGET) C C Returns the location of the first element in an integer ARRAY C that is equal to an integer TARGET. Returns N+1 if TARGET C is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,ARRAY(1),TARGET,IX,I ISRCHIEQ = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .EQ. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHIEQ = I RETURN END C------------------------------------------------------------- ************ C ISRCHFEQ C ************ INTEGER FUNCTION ISRCHFEQ(N,ARRAY,INC,TARGET) C C Returns the location of the first element in a real ARRAY C that is equal to a real TARGET. Returns N+1 if TARGET C is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,IX,I REAL ARRAY(1),TARGET ISRCHFEQ = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .EQ. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHFEQ = I RETURN END C------------------------------------------------------------- ************ C ISRCHINE C ************ INTEGER FUNCTION ISRCHINE(N,ARRAY,INC,TARGET) C C Returns the location of the first element in an integer ARRAY C that is not equal to an integer TARGET. Returns N+1 if C TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,ARRAY(1),TARGET,IX,I ISRCHINE = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .NE. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHINE = I RETURN END C------------------------------------------------------------- ************ C ISRCHFNE C ************ INTEGER FUNCTION ISRCHFNE(N,ARRAY,INC,TARGET) C C Returns the location of the first element in a real ARRAY C that is not equal to a real TARGET. Returns N+1 if C TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,IX,I REAL ARRAY(1),TARGET ISRCHFNE = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .NE. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHFNE = I RETURN END C------------------------------------------------------------- ************ C ISRCHILT C ************ INTEGER FUNCTION ISRCHILT(N,ARRAY,INC,TARGET) C C Returns the location of the first element in an integer ARRAY C that is less than an integer TARGET. Returns N+1 if TARGET C is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,ARRAY(1),TARGET,IX,I ISRCHILT = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LT. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHILT = I RETURN END C------------------------------------------------------------- ************ C ISRCHFLT C ************ INTEGER FUNCTION ISRCHFLT(N,ARRAY,INC,TARGET) C C Returns the location of the first element in a real ARRAY C that is less than a real TARGET. Returns N+1 if TARGET C is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,IX,I REAL ARRAY(1),TARGET ISRCHFLT = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LT. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHFLT = I RETURN END C------------------------------------------------------------- ************ C ISRCHILE C ************ INTEGER FUNCTION ISRCHILE(N,ARRAY,INC,TARGET) C C Returns the location of the first element in an integer ARRAY C that is less than or equal to an integer TARGET. Returns C N+1 if TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,ARRAY(1),TARGET,IX,I ISRCHILE = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LE. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHILE = I RETURN END C------------------------------------------------------------- ************ C ISRCHFLE C ************ INTEGER FUNCTION ISRCHFLE(N,ARRAY,INC,TARGET) C C Returns the location of the first element in a real ARRAY C that is less than or equal to a real TARGET. Returns C N+1 if TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,IX,I REAL ARRAY(1),TARGET ISRCHFLE = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LE. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHFLE = I RETURN END C------------------------------------------------------------- ************ C ISRCHIGT C ************ INTEGER FUNCTION ISRCHIGT(N,ARRAY,INC,TARGET) C C Returns the location of the first element in an integer ARRAY C that is greater than an integer TARGET. Returns N+1 if C TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,ARRAY(1),TARGET,IX,I ISRCHIGT = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GT. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHIGT = I RETURN END C------------------------------------------------------------- ************ C ISRCHFGT C ************ INTEGER FUNCTION ISRCHFGT(N,ARRAY,INC,TARGET) C C Returns the location of the first element in a real ARRAY C that is greater than a real TARGET. Returns N+1 if C TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,IX,I REAL ARRAY(1),TARGET ISRCHFGT = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GT. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHFGT = I RETURN END C------------------------------------------------------------- ************ C ISRCHIGE C ************ INTEGER FUNCTION ISRCHIGE(N,ARRAY,INC,TARGET) C C Returns the location of the first element in an integer ARRAY C that is greater than or equal to an integer TARGET. Returns C N+1 if TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,ARRAY(1),TARGET,IX,I ISRCHIGE = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GE. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHIGE = I RETURN END C------------------------------------------------------------- ************ C ISRCHFGE C ************ INTEGER FUNCTION ISRCHFGE(N,ARRAY,INC,TARGET) C C Returns the location of the first element in a real ARRAY C that is greater than or equal to a real TARGET. Returns C N+1 if TARGET is not found and 0 if N < 1. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,IX,I REAL ARRAY(1),TARGET ISRCHFGE = 0 IF (N .LT. 1) RETURN IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GE. TARGET) GO TO 20 IX = IX + INC 10 CONTINUE 20 ISRCHFGE = I RETURN END C------------------------------------------------------------- ************ C WHENIEQ C ************ SUBROUTINE WHENIEQ(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in an integer ARRAY C that are equal to an integer TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,ARRAY(1),INC,TARGET,INDEX(1),NVAL,IX,I IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .EQ. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENFEQ C ************ SUBROUTINE WHENFEQ(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in a real ARRAY C that are equal to a real TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX(1),NVAL,IX,I REAL ARRAY(1),TARGET IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .EQ. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENINE C ************ SUBROUTINE WHENINE(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in an integer ARRAY C that are not equal to an integer TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,ARRAY(1),INC,TARGET,INDEX(1),NVAL,IX,I IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .NE. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENFNE C ************ SUBROUTINE WHENFNE(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in a real ARRAY C that are not equal to a real TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX(1),NVAL,IX,I REAL ARRAY(1),TARGET IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .NE. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENILT C ************ SUBROUTINE WHENILT(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in an integer ARRAY C that are less than an integer TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,ARRAY(1),INC,TARGET,INDEX(1),NVAL,IX,I IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LT. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENFLT C ************ SUBROUTINE WHENFLT(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in a real ARRAY C that are less than a real TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX(1),NVAL,IX,I REAL ARRAY(1),TARGET IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LT. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENILE C ************ SUBROUTINE WHENILE(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in an integer ARRAY C that are less than or equal to an integer TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,ARRAY(1),INC,TARGET,INDEX(1),NVAL,IX,I IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LE. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENFLE C ************ SUBROUTINE WHENFLE(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in a real ARRAY C that are less than or equal to a real TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX(1),NVAL,IX,I REAL ARRAY(1),TARGET IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .LE. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENIGT C ************ SUBROUTINE WHENIGT(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in an integer ARRAY C that are greater than an integer TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,ARRAY(1),INC,TARGET,INDEX(1),NVAL,IX,I IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GT. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENFGT C ************ SUBROUTINE WHENFGT(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in a real ARRAY C that are greater than a real TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX(1),NVAL,IX,I REAL ARRAY(1),TARGET IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GT. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENIGE C ************ SUBROUTINE WHENIGE(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in an integer ARRAY C that are greater than or equal to an integer TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,ARRAY(1),INC,TARGET,INDEX(1),NVAL,IX,I IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GE. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C WHENFGE C ************ SUBROUTINE WHENFGE(N,ARRAY,INC,TARGET,INDEX,NVAL) C C Returns the locations of all elements in a real ARRAY C that are greater than or equal to a real TARGET. C Martin J. McBride. 7/17/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX(1),NVAL,IX,I REAL ARRAY(1),TARGET IF (N .LT. 1) RETURN IX = 1 NVAL = 0 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 DO 10 I = 1,N IF (ARRAY(IX) .GE. TARGET) THEN NVAL = NVAL + 1 INDEX(NVAL) = I END IF IX = IX + INC 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C IILZ C ************ INTEGER FUNCTION IILZ(N,L,INCL) C C Returns the number of zero values before the first nonzero C value in a vector, L, declared integer. Returns 0 if C N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,L(1),INCL,I,IX IILZ = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX) .NE. 0) RETURN IILZ = IILZ + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C IFLZ C ************ INTEGER FUNCTION IFLZ(N,L,INCL) C C Returns the number of zero values before the first nonzero C value in a vector, L, declared real. Returns 0 if N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INCL,I,IX REAL L(1) IFLZ = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX) .NE. 0.0) RETURN IFLZ = IFLZ + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C ILLZ C ************ INTEGER FUNCTION ILLZ(N,L,INCL) C C Returns the number of false values before the first true C value in a vector, L, declared logical. Returns 0 if C N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INCL,IX,I LOGICAL L(1) ILLZ = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX)) RETURN ILLZ = ILLZ + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C ILIZ C ************ INTEGER FUNCTION ILIZ(N,L,INCL) C C Returns the number of positive or zero values before the C first negative value in a vector, L, declared integer. C Returns 0 if N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INCL,IX,I,L(1) ILIZ = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX) .LT. 0) RETURN ILIZ = ILIZ + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C ILFZ C ************ INTEGER FUNCTION ILFZ(N,L,INCL) C C Returns the number of positive or zero values before the C first negative value in a vector, L, declared real. C Returns 0 if N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INCL,IX,I REAL L(1) ILFZ = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX) .LT. 0.0) RETURN ILFZ = ILFZ + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C ILSUM C ************ INTEGER FUNCTION ILSUM(N,L,INCL) C C Returns the total number of true values in a vector, L, C declared logical. Returns 0 if N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INCL,IX,I LOGICAL L(1) ILSUM = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX)) ILSUM = ILSUM + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C IISUM C ************ INTEGER FUNCTION IISUM(N,L,INCL) C C Returns the total number of negative values in a vector, C L, declared integer. Returns 0 if N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INCL,IX,I,L(1) IISUM = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX) .LT. 0) IISUM = IISUM + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------ ************ C IFSUM C ************ INTEGER FUNCTION IFSUM(N,L,INCL) C C Returns the total number of negative values in a vector, C L, declared real. Returns 0 if N < 1. C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INCL,IX,I REAL L(1) IFSUM = 0 IF (N .LT. 1) RETURN IX = 1 IF (INCL .LT. 0) IX = (-N+1)*INCL + 1 DO 10 I = 1,N IF (L(IX) .LT. 0.0) IFSUM = IFSUM + 1 IX = IX + INCL 10 CONTINUE RETURN END C------------------------------------------------------------- ************ C OSRCHI C ************ SUBROUTINE OSRCHI(N,ARRAY,INC,TARGET,INDEX,IWHERE,INUM) C C Searches an ordered integer array and returns the index of the C first location that contains the integer target. If the C target is not found, OSRCHI returns the index of the loca- C tion that would contain the target. OSRCHI can also return C the total number of occurrences of the target in the array C (this is done if INUM is passed as a nonzero value). C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX,IWHERE,INUM,IX,I,J INTEGER ARRAY(1),TARGET LOGICAL COUNT C Initialization of variables. COUNT = .TRUE. IF (INUM .EQ. 0) COUNT = .FALSE. INDEX = 0 IWHERE = 0 IF (N .LT. 1) RETURN INUM = 0 IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 C Search array for target, or position of where target would be if it existed. DO 20 I = 1,N IF (ARRAY(IX) .EQ. TARGET) THEN INDEX = I IWHERE = I IF (COUNT) THEN J = I 10 IF (ARRAY(IX) .NE. TARGET .OR. J .GT. N) GO TO 15 INUM = INUM + 1 IX = IX + INC J = J + 1 GO TO 10 15 CONTINUE ENDIF RETURN ELSE IF (ARRAY(IX) .GT. TARGET) THEN IWHERE = I INDEX = N + 1 RETURN ENDIF IX = IX + INC 20 CONTINUE C Set index and iwhere at end of array if target is larger than all elements. INDEX = I IWHERE = I RETURN END C------------------------------------------------------------- ************ C OSRCHF C ************ SUBROUTINE OSRCHF(N,ARRAY,INC,TARGET,INDEX,IWHERE,INUM) C C Searches an ordered real array and returns the index of the C first location that contains the real target. If the C target is not found, OSRCHF returns the index of the loca- C tion that would contain the target. OSRCHF can also return C the total number of occurrences of the target in the array C (this is done if INUM is passed as a nonzero value). C Martin J. McBride. 8/6/85. C General Electric CRD, Information System Operation. C INTEGER N,INC,INDEX,IWHERE,INUM,IX,I,J REAL ARRAY(1),TARGET LOGICAL COUNT C Initialization of variables. COUNT = .TRUE. IF (INUM .EQ. 0) COUNT = .FALSE. INDEX = 0 IWHERE = 0 IF (N .LT. 1) RETURN INUM = 0 IX = 1 IF (INC .LT. 0) IX = (-INC)*(N-1) + 1 C Search array for target, or position of where target would be if it existed. DO 20 I = 1,N IF (ARRAY(IX) .EQ. TARGET) THEN INDEX = I IWHERE = I IF (COUNT) THEN J = I 10 IF (ARRAY(IX) .NE. TARGET .OR. J .GT. N) GO TO 15 INUM = INUM + 1 IX = IX + INC J = J + 1 GO TO 10 15 CONTINUE ENDIF RETURN ELSE IF (ARRAY(IX) .GT. TARGET) THEN IWHERE = I INDEX = N + 1 RETURN ENDIF IX = IX + INC 20 CONTINUE C Set index and iwhere at end of array if target is larger than all elements. INDEX = I IWHERE = I RETURN END