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