1 /* isrchi.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure             ISRCHI  ( Search in an integer array ) */
isrchi_(integer * value,integer * ndim,integer * array)9 integer isrchi_(integer *value, integer *ndim, integer *array)
10 {
11     /* System generated locals */
12     integer ret_val, i__1;
13 
14     /* Local variables */
15     integer i__;
16 
17 /* $ Abstract */
18 
19 /*      Search for a given value within a integer array. Return */
20 /*      the index of the first matching array entry, or zero if */
21 /*      the key value was not found. */
22 
23 /* $ Disclaimer */
24 
25 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
26 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
27 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
28 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
29 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
30 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
31 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
32 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
33 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
34 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
35 
36 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
37 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
38 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
39 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
40 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
41 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
42 
43 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
44 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
45 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
46 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
47 
48 /* $ Required_Reading */
49 
50 /*     None. */
51 
52 /* $ Keywords */
53 
54 /*      ARRAY,  SEARCH */
55 
56 /* $ Declarations */
57 /* $ Brief_I/O */
58 
59 /*      VARIABLE  I/O              DESCRIPTION */
60 /*      --------  ---  -------------------------------------------------- */
61 /*       VALUE     I     Key value to be found in ARRAY. */
62 /*       NDIM      I     Dimension of ARRAY. */
63 /*       ARRAY     I     Integer array to search. */
64 
65 /*       The function returns the index of the first matching array */
66 /*       element or zero if the value is not found. */
67 
68 /* $ Detailed_Input */
69 
70 /*      VALUE      is the key value to be found in the array. */
71 
72 /*      NDIM       is the dimension of the array. */
73 
74 /*      ARRAY      is the integer array to be searched. */
75 
76 /* $ Detailed_Output */
77 
78 /*      The function returns the index of the first matching array */
79 /*      element in ARRAY. If VALUE is not found, ISRCHI is zero. */
80 
81 /* $ Parameters */
82 
83 /*      None. */
84 
85 /* $ Particulars */
86 
87 /*      None. */
88 
89 /* $ Examples */
90 
91 /*      The following table shows the value of ISRCHI given the contents */
92 /*      of ARRAY and VALUE: */
93 
94 /*        ARRAY        VALUE   ISRCHI */
95 /*      ----------     -----   ------ */
96 /*      1, 0, 4, 2       4        3 */
97 /*      1, 0, 4, 2       2        4 */
98 /*      1, 0, 4, 2       3        0 */
99 
100 /* $ Restrictions */
101 
102 /*      None. */
103 
104 /* $ Exceptions */
105 
106 /*     Error free. */
107 
108 /*     1) If NDIM < 1 the function value is zero. */
109 
110 /* $ Files */
111 
112 /*      None. */
113 
114 /* $ Author_and_Institution */
115 
116 /*      W.M. Owen       (JPL) */
117 
118 /* $ Literature_References */
119 
120 /*      None. */
121 
122 /* $ Version */
123 
124 /* -    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
125 
126 /*        Comment section for permuted index source lines was added */
127 /*        following the header. */
128 
129 /* -    SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
130 
131 /* -& */
132 /* $ Index_Entries */
133 
134 /*     search in an integer array */
135 
136 /* -& */
137 
138 /*     Local variables */
139 
140     ret_val = 0;
141     i__1 = *ndim;
142     for (i__ = 1; i__ <= i__1; ++i__) {
143 	if (array[i__ - 1] == *value) {
144 	    ret_val = i__;
145 	    return ret_val;
146 	}
147     }
148     return ret_val;
149 } /* isrchi_ */
150 
151