1 /* zzekleri.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 ZZEKLERI ( EK, LLE, using record pointers, integer ) */
zzekleri_(integer * handle,integer * segdsc,integer * coldsc,integer * ikey,integer * recptr,logical * null,integer * prvidx,integer * prvptr)9 /* Subroutine */ int zzekleri_(integer *handle, integer *segdsc, integer *
10 	coldsc, integer *ikey, integer *recptr, logical *null, integer *
11 	prvidx, integer *prvptr)
12 {
13     extern /* Subroutine */ int zzekeri1_(integer *, integer *, integer *,
14 	    integer *, integer *, logical *, integer *, integer *), zzekcnam_(
15 	    integer *, integer *, char *, ftnlen), chkin_(char *, ftnlen),
16 	    errch_(char *, char *, ftnlen, ftnlen);
17     integer dtype, itype;
18     extern logical failed_(void);
19     logical indexd;
20     char column[32];
21     extern /* Subroutine */ int setmsg_(char *, ftnlen), sigerr_(char *,
22 	    ftnlen), chkout_(char *, ftnlen), errint_(char *, integer *,
23 	    ftnlen);
24 
25 /* $ Abstract */
26 
27 /*     Find the last column value less than or equal to a specified key, */
28 /*     for a specified, indexed integer EK column, using dictionary */
29 /*     ordering on integer data values and record pointers. */
30 
31 /* $ Disclaimer */
32 
33 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
34 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
35 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
36 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
37 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
38 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
39 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
40 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
41 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
42 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
43 
44 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
45 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
46 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
47 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
48 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
49 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
50 
51 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
52 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
53 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
54 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
55 
56 /* $ Required_Reading */
57 
58 /*     EK */
59 
60 /* $ Keywords */
61 
62 /*     EK */
63 /*     PRIVATE */
64 
65 /* $ Declarations */
66 /* $ Disclaimer */
67 
68 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
69 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
70 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
71 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
72 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
73 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
74 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
75 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
76 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
77 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
78 
79 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
80 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
81 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
82 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
83 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
84 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
85 
86 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
87 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
88 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
89 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
90 
91 
92 /*     Include Section:  EK Boolean Enumerated Type */
93 
94 
95 /*        ekbool.inc Version 1   21-DEC-1994 (NJB) */
96 
97 
98 /*     Within the EK system, boolean values sometimes must be */
99 /*     represented by integer or character codes.  The codes and their */
100 /*     meanings are listed below. */
101 
102 /*     Integer code indicating `true': */
103 
104 
105 /*     Integer code indicating `false': */
106 
107 
108 /*     Character code indicating `true': */
109 
110 
111 /*     Character code indicating `false': */
112 
113 
114 /*     End Include Section:  EK Boolean Enumerated Type */
115 
116 /* $ Disclaimer */
117 
118 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
119 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
120 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
121 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
122 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
123 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
124 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
125 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
126 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
127 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
128 
129 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
130 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
131 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
132 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
133 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
134 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
135 
136 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
137 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
138 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
139 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
140 
141 
142 /*     Include Section:  EK Column Name Size */
143 
144 /*        ekcnamsz.inc Version 1    17-JAN-1995 (NJB) */
145 
146 
147 /*     Size of column name, in characters. */
148 
149 
150 /*     End Include Section:  EK Column Name Size */
151 
152 /* $ Disclaimer */
153 
154 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
155 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
156 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
157 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
158 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
159 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
160 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
161 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
162 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
163 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
164 
165 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
166 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
167 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
168 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
169 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
170 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
171 
172 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
173 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
174 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
175 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
176 
177 
178 /*     Include Section:  EK Column Descriptor Parameters */
179 
180 /*        ekcoldsc.inc Version 6    23-AUG-1995 (NJB) */
181 
182 
183 /*     Note:  The column descriptor size parameter CDSCSZ  is */
184 /*     declared separately in the include section CDSIZE$INC.FOR. */
185 
186 /*     Offset of column descriptors, relative to start of segment */
187 /*     integer address range.  This number, when added to the last */
188 /*     integer address preceding the segment, yields the DAS integer */
189 /*     base address of the first column descriptor.  Currently, this */
190 /*     offset is exactly the size of a segment descriptor.  The */
191 /*     parameter SDSCSZ, which defines the size of a segment descriptor, */
192 /*     is declared in the include file eksegdsc.inc. */
193 
194 
195 /*     Size of column descriptor */
196 
197 
198 /*     Indices of various pieces of column descriptors: */
199 
200 
201 /*     CLSIDX is the index of the column's class code.  (We use the */
202 /*     word `class' to distinguish this item from the column's data */
203 /*     type.) */
204 
205 
206 /*     TYPIDX is the index of the column's data type code (CHR, INT, DP, */
207 /*     or TIME).  The type is actually implied by the class, but it */
208 /*     will frequently be convenient to look up the type directly. */
209 
210 
211 
212 /*     LENIDX is the index of the column's string length value, if the */
213 /*     column has character type.  A value of IFALSE in this element of */
214 /*     the descriptor indicates that the strings have variable length. */
215 
216 
217 /*     SIZIDX is the index of the column's element size value.  This */
218 /*     descriptor element is meaningful for columns with fixed-size */
219 /*     entries.  For variable-sized columns, this value is IFALSE. */
220 
221 
222 /*     NAMIDX is the index of the base address of the column's name. */
223 
224 
225 /*     IXTIDX is the data type of the column's index.  IXTIDX */
226 /*     contains a type value only if the column is indexed. For columns */
227 /*     that are not indexed, the location IXTIDX contains the boolean */
228 /*     value IFALSE. */
229 
230 
231 /*     IXPIDX is a pointer to the column's index.  IXTPDX contains a */
232 /*     meaningful value only if the column is indexed.  The */
233 /*     interpretation of the pointer depends on the data type of the */
234 /*     index. */
235 
236 
237 /*     NFLIDX is the index of a flag indicating whether nulls are */
238 /*     permitted in the column.  The value at location NFLIDX is */
239 /*     ITRUE if nulls are permitted and IFALSE otherwise. */
240 
241 
242 /*     ORDIDX is the index of the column's ordinal position in the */
243 /*     list of columns belonging to the column's parent segment. */
244 
245 
246 /*     METIDX is the index of the column's integer metadata pointer. */
247 /*     This pointer is a DAS integer address. */
248 
249 
250 /*     The last position in the column descriptor is reserved.  No */
251 /*     parameter is defined to point to this location. */
252 
253 
254 /*     End Include Section:  EK Column Descriptor Parameters */
255 
256 /* $ Disclaimer */
257 
258 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
259 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
260 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
261 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
262 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
263 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
264 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
265 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
266 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
267 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
268 
269 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
270 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
271 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
272 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
273 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
274 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
275 
276 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
277 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
278 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
279 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
280 
281 
282 /*     Include Section:  EK Segment Descriptor Parameters */
283 
284 /*        eksegdsc.inc  Version 8  06-NOV-1995 (NJB) */
285 
286 
287 /*     All `base addresses' referred to below are the addresses */
288 /*     *preceding* the item the base applies to.  This convention */
289 /*     enables simplied address calculations in many cases. */
290 
291 /*     Size of segment descriptor.  Note:  the include file ekcoldsc.inc */
292 /*     must be updated if this parameter is changed.  The parameter */
293 /*     CDOFF in that file should be kept equal to SDSCSZ. */
294 
295 
296 /*     Index of the segment type code: */
297 
298 
299 /*     Index of the segment's number.  This number is the segment's */
300 /*     index in the list of segments contained in the EK to which */
301 /*     the segment belongs. */
302 
303 
304 /*     Index of the DAS integer base address of the segment's integer */
305 /*     meta-data: */
306 
307 
308 /*     Index of the DAS character base address of the table name: */
309 
310 
311 /*     Index of the segment's column count: */
312 
313 
314 /*     Index of the segment's record count: */
315 
316 
317 /*     Index of the root page number of the record tree: */
318 
319 
320 /*     Index of the root page number of the character data page tree: */
321 
322 
323 /*     Index of the root page number of the double precision data page */
324 /*     tree: */
325 
326 
327 /*     Index of the root page number of the integer data page tree: */
328 
329 
330 /*     Index of the `modified' flag: */
331 
332 
333 /*     Index of the `initialized' flag: */
334 
335 
336 /*     Index of the shadowing flag: */
337 
338 
339 /*     Index of the companion file handle: */
340 
341 
342 /*     Index of the companion segment number: */
343 
344 
345 /*     The next three items are, respectively, the page numbers of the */
346 /*     last character, d.p., and integer data pages allocated by the */
347 /*     segment: */
348 
349 
350 /*     The next three items are, respectively, the page-relative */
351 /*     indices of the last DAS word in use in the segment's */
352 /*     last character, d.p., and integer data pages: */
353 
354 
355 /*     Index of the DAS character base address of the column name list: */
356 
357 
358 /*     The last descriptor element is reserved for future use.  No */
359 /*     parameter is defined to point to this location. */
360 
361 
362 /*     End Include Section:  EK Segment Descriptor Parameters */
363 
364 /* $ Disclaimer */
365 
366 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
367 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
368 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
369 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
370 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
371 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
372 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
373 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
374 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
375 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
376 
377 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
378 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
379 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
380 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
381 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
382 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
383 
384 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
385 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
386 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
387 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
388 
389 
390 /*     Include Section:  EK Data Types */
391 
392 /*        ektype.inc Version 1  27-DEC-1994 (NJB) */
393 
394 
395 /*     Within the EK system, data types of EK column contents are */
396 /*     represented by integer codes.  The codes and their meanings */
397 /*     are listed below. */
398 
399 /*     Integer codes are also used within the DAS system to indicate */
400 /*     data types; the EK system makes no assumptions about compatibility */
401 /*     between the codes used here and those used in the DAS system. */
402 
403 
404 /*     Character type: */
405 
406 
407 /*     Double precision type: */
408 
409 
410 /*     Integer type: */
411 
412 
413 /*     `Time' type: */
414 
415 /*     Within the EK system, time values are represented as ephemeris */
416 /*     seconds past J2000 (TDB), and double precision numbers are used */
417 /*     to store these values.  However, since time values require special */
418 /*     treatment both on input and output, and since the `TIME' column */
419 /*     has a special role in the EK specification and code, time values */
420 /*     are identified as a type distinct from double precision numbers. */
421 
422 
423 /*     End Include Section:  EK Data Types */
424 
425 /* $ Brief_I/O */
426 
427 /*     Variable  I/O  Description */
428 /*     --------  ---  -------------------------------------------------- */
429 /*     HANDLE     I   File handle. */
430 /*     SEGDSC     I   Segment descriptor. */
431 /*     COLDSC     I   Column descriptor. */
432 /*     IKEY       I   Integer key. */
433 /*     RECPTR     I   Record pointer. */
434 /*     NULL       I   Null flag. */
435 /*     PRVIDX     O   Ordinal position of predecessor of IKEY. */
436 /*     PRVPTR     O   Pointer to record containing predecessor of IKEY. */
437 
438 /* $ Detailed_Input */
439 
440 /*     HANDLE         is an EK file handle.  The file may be open for */
441 /*                    reading or writing. */
442 
443 /*     SEGDSC         is the segment descriptor of the segment */
444 /*                    containing the column specified by COLDSC. */
445 
446 /*     COLDSC         is the column descriptor of the column to be */
447 /*                    searched. */
448 
449 /*     IKEY, */
450 /*     RECPTR         are, respectively, an integer key and a */
451 /*                    pointer to the EK record containing that key. */
452 /*                    The last column entry less than or equal to */
453 /*                    this key is sought.  The order relation used */
454 /*                    is dictionary ordering on the pair (IKEY, RECPTR). */
455 
456 /*     NULL           is a logical flag indicating whether the input */
457 /*                    key is null.  When NULL is .TRUE., IKEY is */
458 /*                    ignored by this routine. */
459 
460 /* $ Detailed_Output */
461 
462 /*     PRVIDX         is the ordinal position, according to the order */
463 /*                    relation implied by the column's index, of the */
464 /*                    record containing the last element less than or */
465 /*                    equal to IKEY, where the order relation is */
466 /*                    as indicated above.  If the column contains */
467 /*                    elements equal to IKEY, PRVIDX is the index of the */
468 /*                    last such element. */
469 
470 /*                    If all elements of the column are greater than */
471 /*                    IKEY, PRVIDX is set to zero. */
472 
473 /*     PRVPTR         is a pointer to the record containing the element */
474 /*                    whose ordinal position is PRVIDX. */
475 
476 /*                    If all elements of the column are greater than */
477 /*                    IKEY, PRVPTR is set to zero. */
478 
479 /* $ Parameters */
480 
481 /*     None. */
482 
483 /* $ Exceptions */
484 
485 /*     1)  If HANDLE is invalid, the error will be diagnosed by routines */
486 /*         called by this routine. */
487 
488 /*     2)  If the data type of the input column is not integer, */
489 /*         the error SPICE(INVALIDTYPE) is signalled. */
490 
491 /*     3)  If the input column is not indexed, the error */
492 /*         SPICE(NOTINDEXED) is signalled. */
493 
494 /*     4)  If the index type of the input column is not recognized, */
495 /*         the error SPICE(INVALIDTYPE) is signalled. */
496 
497 /*     5)  If an I/O error occurs while reading or writing the indicated */
498 /*         file, the error will be diagnosed by routines called by this */
499 /*         routine. */
500 
501 /* $ Files */
502 
503 /*     See the EK Required Reading for a discussion of the EK file */
504 /*     format. */
505 
506 /* $ Particulars */
507 
508 /*     This routine finds the last column element less than or equal */
509 /*     to a specified integer key, within a specified segment and */
510 /*     column.  The order relation used is dictionary ordering on the */
511 /*     pair (IKEY, RECPTR). */
512 
513 /*     In order to support the capability of creating an index for a */
514 /*     column that has already been populated with data, this routine */
515 /*     does not require that the number of elements referenced by the */
516 /*     input column's index match the pointer of elements in the column; */
517 /*     the index is allowed to reference fewer elements.  However, */
518 /*     every record referenced by the index must be populated with data. */
519 
520 /* $ Examples */
521 
522 /*     See ZZEKIII1. */
523 
524 /* $ Restrictions */
525 
526 /*     None. */
527 
528 /* $ Literature_References */
529 
530 /*     None. */
531 
532 /* $ Author_and_Institution */
533 
534 /*     N.J. Bachman   (JPL) */
535 
536 /* $ Version */
537 
538 /* -    Beta Version 1.1.0, 18-JUN-1999 (WLT) */
539 
540 /*        Removed an unbalanced call to CHKOUT */
541 
542 /* -    Beta Version 1.0.0, 19-OCT-1995 (NJB) */
543 
544 /* -& */
545 
546 /*     SPICELIB functions */
547 
548 
549 /*     Local variables */
550 
551 
552 /*     Use discovery check-in. */
553 
554     if (failed_()) {
555 	return 0;
556     }
557 
558 /*     If the column's not indexed, we have no business being here. */
559 
560     indexd = coldsc[5] != -1;
561     if (! indexd) {
562 	zzekcnam_(handle, coldsc, column, (ftnlen)32);
563 	chkin_("ZZEKLERI", (ftnlen)8);
564 	setmsg_("Column # is not indexed.", (ftnlen)24);
565 	errch_("#", column, (ftnlen)1, (ftnlen)32);
566 	sigerr_("SPICE(NOTINDEXED)", (ftnlen)17);
567 	chkout_("ZZEKLERI", (ftnlen)8);
568 	return 0;
569     }
570 
571 /*     Check the column's data type. */
572 
573     dtype = coldsc[1];
574     if (dtype != 3) {
575 	zzekcnam_(handle, coldsc, column, (ftnlen)32);
576 	chkin_("ZZEKLERI", (ftnlen)8);
577 	setmsg_("Column # should be INT but has type #.", (ftnlen)38);
578 	errch_("#", column, (ftnlen)1, (ftnlen)32);
579 	errint_("#", &dtype, (ftnlen)1);
580 	sigerr_("SPICE(INVALIDTYPE)", (ftnlen)18);
581 	chkout_("ZZEKLERI", (ftnlen)8);
582 	return 0;
583     }
584 
585 /*     Hand the problem off to the subroutine that understands this */
586 /*     column's index type. */
587 
588     itype = coldsc[5];
589     if (itype == 1) {
590 	zzekeri1_(handle, segdsc, coldsc, ikey, recptr, null, prvidx, prvptr);
591     } else {
592 	zzekcnam_(handle, coldsc, column, (ftnlen)32);
593 	chkin_("ZZEKLERI", (ftnlen)8);
594 	setmsg_("Column # has index type #.", (ftnlen)26);
595 	errch_("#", column, (ftnlen)1, (ftnlen)32);
596 	errint_("#", &itype, (ftnlen)1);
597 	sigerr_("SPICE(INVALIDTYPE)", (ftnlen)18);
598 	chkout_("ZZEKLERI", (ftnlen)8);
599 	return 0;
600     }
601     return 0;
602 } /* zzekleri_ */
603 
604