1 /* zzekac04.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__1 = 1;
11 static integer c__3 = 3;
12 static logical c_false = FALSE_;
13 static integer c__256 = 256;
14 
15 /* $Procedure     ZZEKAC04 ( EK, add class 4 column to segment ) */
zzekac04_(integer * handle,integer * segdsc,integer * coldsc,integer * ivals,integer * entszs,logical * nlflgs)16 /* Subroutine */ int zzekac04_(integer *handle, integer *segdsc, integer *
17 	coldsc, integer *ivals, integer *entszs, logical *nlflgs)
18 {
19     /* System generated locals */
20     integer i__1;
21 
22     /* Builtin functions */
23     integer s_rnge(char *, integer, char *, integer);
24 
25     /* Local variables */
26     integer page[256], nelt, from, size;
27     extern /* Subroutine */ int zzekcnam_(integer *, integer *, char *,
28 	    ftnlen), zzeksfwd_(integer *, integer *, integer *, integer *),
29 	    zzekpgwi_(integer *, integer *, integer *), zzekspsh_(integer *,
30 	    integer *);
31     integer i__, n, p, ndata, pbase;
32     extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
33 	     ftnlen, ftnlen);
34     integer class__, nlink, p2, nrows;
35     extern logical return_(void);
36     char column[32];
37     integer adrbuf[254], bufptr, colidx, cursiz, nulptr, remain, to;
38     logical cntinu, fixsiz, newreq, nullok;
39     extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
40 	    integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
41 	    ftnlen), cleari_(integer *, integer *);
42     integer row;
43     extern /* Subroutine */ int zzekaps_(integer *, integer *, integer *,
44 	    logical *, integer *, integer *);
45 
46 /* $ Abstract */
47 
48 /*     Add an entire class 4 column to an EK segment. */
49 
50 /* $ Disclaimer */
51 
52 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
53 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
54 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
55 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
56 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
57 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
58 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
59 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
60 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
61 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
62 
63 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
64 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
65 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
66 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
67 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
68 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
69 
70 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
71 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
72 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
73 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
74 
75 /* $ Required_Reading */
76 
77 /*     EK */
78 
79 /* $ Keywords */
80 
81 /*     EK */
82 
83 /* $ Declarations */
84 /* $ Disclaimer */
85 
86 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
87 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
88 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
89 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
90 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
91 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
92 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
93 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
94 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
95 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
96 
97 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
98 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
99 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
100 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
101 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
102 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
103 
104 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
105 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
106 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
107 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
108 
109 
110 /*     Include Section:  EK Boolean Enumerated Type */
111 
112 
113 /*        ekbool.inc Version 1   21-DEC-1994 (NJB) */
114 
115 
116 /*     Within the EK system, boolean values sometimes must be */
117 /*     represented by integer or character codes.  The codes and their */
118 /*     meanings are listed below. */
119 
120 /*     Integer code indicating `true': */
121 
122 
123 /*     Integer code indicating `false': */
124 
125 
126 /*     Character code indicating `true': */
127 
128 
129 /*     Character code indicating `false': */
130 
131 
132 /*     End Include Section:  EK Boolean Enumerated Type */
133 
134 /* $ Disclaimer */
135 
136 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
137 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
138 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
139 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
140 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
141 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
142 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
143 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
144 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
145 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
146 
147 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
148 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
149 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
150 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
151 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
152 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
153 
154 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
155 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
156 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
157 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
158 
159 
160 /*     Include Section:  EK Column Descriptor Parameters */
161 
162 /*        ekcoldsc.inc Version 6    23-AUG-1995 (NJB) */
163 
164 
165 /*     Note:  The column descriptor size parameter CDSCSZ  is */
166 /*     declared separately in the include section CDSIZE$INC.FOR. */
167 
168 /*     Offset of column descriptors, relative to start of segment */
169 /*     integer address range.  This number, when added to the last */
170 /*     integer address preceding the segment, yields the DAS integer */
171 /*     base address of the first column descriptor.  Currently, this */
172 /*     offset is exactly the size of a segment descriptor.  The */
173 /*     parameter SDSCSZ, which defines the size of a segment descriptor, */
174 /*     is declared in the include file eksegdsc.inc. */
175 
176 
177 /*     Size of column descriptor */
178 
179 
180 /*     Indices of various pieces of column descriptors: */
181 
182 
183 /*     CLSIDX is the index of the column's class code.  (We use the */
184 /*     word `class' to distinguish this item from the column's data */
185 /*     type.) */
186 
187 
188 /*     TYPIDX is the index of the column's data type code (CHR, INT, DP, */
189 /*     or TIME).  The type is actually implied by the class, but it */
190 /*     will frequently be convenient to look up the type directly. */
191 
192 
193 
194 /*     LENIDX is the index of the column's string length value, if the */
195 /*     column has character type.  A value of IFALSE in this element of */
196 /*     the descriptor indicates that the strings have variable length. */
197 
198 
199 /*     SIZIDX is the index of the column's element size value.  This */
200 /*     descriptor element is meaningful for columns with fixed-size */
201 /*     entries.  For variable-sized columns, this value is IFALSE. */
202 
203 
204 /*     NAMIDX is the index of the base address of the column's name. */
205 
206 
207 /*     IXTIDX is the data type of the column's index.  IXTIDX */
208 /*     contains a type value only if the column is indexed. For columns */
209 /*     that are not indexed, the location IXTIDX contains the boolean */
210 /*     value IFALSE. */
211 
212 
213 /*     IXPIDX is a pointer to the column's index.  IXTPDX contains a */
214 /*     meaningful value only if the column is indexed.  The */
215 /*     interpretation of the pointer depends on the data type of the */
216 /*     index. */
217 
218 
219 /*     NFLIDX is the index of a flag indicating whether nulls are */
220 /*     permitted in the column.  The value at location NFLIDX is */
221 /*     ITRUE if nulls are permitted and IFALSE otherwise. */
222 
223 
224 /*     ORDIDX is the index of the column's ordinal position in the */
225 /*     list of columns belonging to the column's parent segment. */
226 
227 
228 /*     METIDX is the index of the column's integer metadata pointer. */
229 /*     This pointer is a DAS integer address. */
230 
231 
232 /*     The last position in the column descriptor is reserved.  No */
233 /*     parameter is defined to point to this location. */
234 
235 
236 /*     End Include Section:  EK Column Descriptor Parameters */
237 
238 /* $ Disclaimer */
239 
240 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
241 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
242 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
243 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
244 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
245 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
246 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
247 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
248 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
249 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
250 
251 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
252 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
253 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
254 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
255 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
256 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
257 
258 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
259 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
260 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
261 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
262 
263 
264 /*     Include Section:  EK Column Name Size */
265 
266 /*        ekcnamsz.inc Version 1    17-JAN-1995 (NJB) */
267 
268 
269 /*     Size of column name, in characters. */
270 
271 
272 /*     End Include Section:  EK Column Name Size */
273 
274 /* $ Disclaimer */
275 
276 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
277 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
278 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
279 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
280 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
281 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
282 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
283 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
284 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
285 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
286 
287 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
288 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
289 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
290 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
291 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
292 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
293 
294 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
295 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
296 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
297 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
298 
299 
300 /*     Include Section:  EK Data Page Parameters */
301 
302 /*        ekfilpar.inc  Version 1  03-APR-1995 (NJB) */
303 
304 /*     These parameters apply to EK files using architecture 4. */
305 /*     These files use a paged DAS file as their underlying file */
306 /*     structure. */
307 
308 /*     In paged DAS EK files, data pages are structured:  they contain */
309 /*     metadata as well as data.  The metadata is located in the last */
310 /*     few addresses of each page, so as to interfere as little as */
311 /*     possible with calculation of data addresses. */
312 
313 /*     Each data page belongs to exactly one segment.  Some bookkeeping */
314 /*     information, such as record pointers, is also stored in data */
315 /*     pages. */
316 
317 /*     Each page contains a forward pointer that allows rapid lookup */
318 /*     of data items that span multiple pages.  Each page also keeps */
319 /*     track of the current number of links from its parent segment */
320 /*     to the page.  Link counts enable pages to `know' when they */
321 /*     are no longer in use by a segment; unused pages are deallocated */
322 /*     and returned to the free list. */
323 
324 /*     The parameters in this include file depend on the parameters */
325 /*     declared in the include file ekpage.inc.  If those parameters */
326 /*     change, this file must be updated.  The specified parameter */
327 /*     declarations we need from that file are: */
328 
329 /*        INTEGER               PGSIZC */
330 /*        PARAMETER           ( PGSIZC = 1024 ) */
331 
332 /*        INTEGER               PGSIZD */
333 /*        PARAMETER           ( PGSIZD = 128 ) */
334 
335 /*        INTEGER               PGSIZI */
336 /*        PARAMETER           ( PGSIZI = 256 ) */
337 
338 
339 
340 /*     Character pages use an encoding mechanism to represent integer */
341 /*     metadata.  Each integer is encoded in five consecutive */
342 /*     characters. */
343 
344 
345 /*     Character data page parameters: */
346 
347 
348 /*     Size of encoded integer: */
349 
350 
351 /*     Usable page size: */
352 
353 
354 /*     Location of character forward pointer: */
355 
356 
357 /*     Location of character link count: */
358 
359 
360 /*     Double precision data page parameters: */
361 
362 /*     Usable page size: */
363 
364 
365 /*     Location of d.p. forward pointer: */
366 
367 
368 /*     Location of d.p. link count: */
369 
370 
371 /*     Integer data page parameters: */
372 
373 /*     Usable page size: */
374 
375 
376 /*     Location of integer forward pointer: */
377 
378 
379 /*     Location of integer link count: */
380 
381 
382 /*     End Include Section:  EK Data Page Parameters */
383 
384 /* $ Disclaimer */
385 
386 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
387 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
388 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
389 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
390 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
391 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
392 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
393 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
394 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
395 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
396 
397 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
398 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
399 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
400 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
401 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
402 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
403 
404 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
405 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
406 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
407 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
408 
409 
410 /*     Include Section:  EK Das Paging Parameters */
411 
412 /*        ekpage.inc  Version 4    25-AUG-1995 (NJB) */
413 
414 
415 
416 /*     The EK DAS paging system makes use of the integer portion */
417 /*     of an EK file's DAS address space to store the few numbers */
418 /*     required to describe the system's state.  The allocation */
419 /*     of DAS integer addresses is shown below. */
420 
421 
422 /*                       DAS integer array */
423 
424 /*        +--------------------------------------------+ */
425 /*        |            EK architecture code            |  Address = 1 */
426 /*        +--------------------------------------------+ */
427 /*        |      Character page size (in DAS words)    | */
428 /*        +--------------------------------------------+ */
429 /*        |        Character page base address         | */
430 /*        +--------------------------------------------+ */
431 /*        |      Number of character pages in file     | */
432 /*        +--------------------------------------------+ */
433 /*        |   Number of character pages on free list   | */
434 /*        +--------------------------------------------+ */
435 /*        |      Character free list head pointer      |  Address = 6 */
436 /*        +--------------------------------------------+ */
437 /*        |                                            |  Addresses = */
438 /*        |           Metadata for d.p. pages          |    7--11 */
439 /*        |                                            | */
440 /*        +--------------------------------------------+ */
441 /*        |                                            |  Addresses = */
442 /*        |         Metadata for integer pages         |    12--16 */
443 /*        |                                            | */
444 /*        +--------------------------------------------+ */
445 /*                              . */
446 /*                              . */
447 /*                              . */
448 /*        +--------------------------------------------+ */
449 /*        |                                            |  End Address = */
450 /*        |                Unused space                |  integer page */
451 /*        |                                            |  end */
452 /*        +--------------------------------------------+ */
453 /*        |                                            |  Start Address = */
454 /*        |             First integer page             |  integer page */
455 /*        |                                            |  base */
456 /*        +--------------------------------------------+ */
457 /*                              . */
458 /*                              . */
459 /*                              . */
460 /*        +--------------------------------------------+ */
461 /*        |                                            | */
462 /*        |              Last integer page             | */
463 /*        |                                            | */
464 /*        +--------------------------------------------+ */
465 
466 /*     The following parameters indicate positions of elements in the */
467 /*     paging system metadata array: */
468 
469 
470 
471 /*     Number of metadata items per data type: */
472 
473 
474 /*     Character metadata indices: */
475 
476 
477 /*     Double precision metadata indices: */
478 
479 
480 /*     Integer metadata indices: */
481 
482 
483 /*     Size of metadata area: */
484 
485 
486 /*     Page sizes, in units of DAS words of the appropriate type: */
487 
488 
489 /*     Default page base addresses: */
490 
491 
492 /*     End Include Section:  EK Das Paging Parameters */
493 
494 /* $ Disclaimer */
495 
496 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
497 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
498 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
499 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
500 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
501 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
502 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
503 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
504 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
505 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
506 
507 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
508 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
509 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
510 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
511 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
512 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
513 
514 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
515 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
516 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
517 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
518 
519 
520 /*     Include Section:  EK Record Pointer Parameters */
521 
522 /*        ekrecptr.inc Version 2  18-JUL-1995 (NJB) */
523 
524 
525 /*     This file declares parameters used in EK record pointers. */
526 /*     Each segment references data in a given record via two levels */
527 /*     of indirection:  a record number points to a record pointer, */
528 /*     which is a structured array of metadata and data pointers. */
529 
530 /*     Record pointers always occupy contiguous ranges of integer */
531 /*     addresses. */
532 
533 /*     The parameter declarations in this file depend on the assumption */
534 /*     that integer pages contain 256 DAS integer words and that the */
535 /*     maximum number of columns in a segment is 100.  Record pointers */
536 /*     are stored in integer data pages, so they must fit within the */
537 /*     usable data area afforded by these pages.  The size of the usable */
538 /*     data area is given by the parameter IPSIZE which is declared in */
539 /*     ekdatpag.inc.  The assumed value of IPSIZE is 254. */
540 
541 
542 /*     The first element of each record pointer is a status indicator. */
543 /*     The meanings of status indicators depend on whether the parent EK */
544 /*     is shadowed or not.  For shadowed EKs, allowed status values and */
545 /*     their meanings are: */
546 
547 /*        OLD       The record has not been modified since */
548 /*                  the EK containing the record was opened. */
549 
550 /*        UPDATE    The record is an update of a previously existing */
551 /*                  record.  The original record is now on the */
552 /*                  modified record list. */
553 
554 /*        NEW       The record has been added since the EK containing the */
555 /*                  record was opened.  The record is not an update */
556 /*                  of a previously existing record. */
557 
558 /*        DELOLD    This status applies only to a backup record. */
559 /*                  DELOLD status indicates that the record corresponds */
560 /*                  to a deleted OLD record in the source segment. */
561 
562 /*        DELNEW    This status applies only to a backup record. */
563 /*                  DELNEW status indicates that the record corresponds */
564 /*                  to a deleted NEW record in the source segment. */
565 
566 /*        DELUPD    This status applies only to a backup record. */
567 /*                  DELUPD status indicates that the record corresponds */
568 /*                  to a deleted UPDATEd record in the source segment. */
569 
570 /*     In EKs that are not shadowed, all records have status OLD. */
571 
572 
573 
574 /*     The following parameters refer to indices within the record */
575 /*     pointer structure: */
576 
577 /*     Index of status indicator: */
578 
579 
580 /*     Each record pointer contains a pointer to its companion:  for a */
581 /*     record belonging to a shadowed EK, this is the backup counterpart, */
582 /*     or if the parent EK is itself a backup EK, a pointer to the */
583 /*     record's source record.  The pointer is UNINIT (see below) if the */
584 /*     record is unmodified. */
585 
586 /*     Record companion pointers contain record numbers, not record */
587 /*     base addresses. */
588 
589 /*     Index of record's companion pointer: */
590 
591 
592 /*     Each data item is referenced by an integer.  The meaning of */
593 /*     this integer depends on the representation of data in the */
594 /*     column to which the data item belongs.  Actual lookup of a */
595 /*     data item must be done by subroutines appropriate to the class of */
596 /*     the column to which the item belongs.  Note that data items don't */
597 /*     necessarily occupy contiguous ranges of DAS addresses. */
598 
599 /*     Base address of data pointers: */
600 
601 
602 /*     Maximum record pointer size: */
603 
604 
605 /*     Data pointers are given the value UNINIT to start with; this */
606 /*     indicates that the data item is uninitialized.  UNINIT is */
607 /*     distinct from the value NULL.  NOBACK indicates an uninitialized */
608 /*     backup column entry. */
609 
610 
611 /*     End Include Section:  EK Record Pointer Parameters */
612 
613 /* $ Disclaimer */
614 
615 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
616 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
617 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
618 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
619 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
620 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
621 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
622 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
623 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
624 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
625 
626 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
627 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
628 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
629 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
630 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
631 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
632 
633 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
634 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
635 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
636 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
637 
638 
639 /*     Include Section:  EK Segment Descriptor Parameters */
640 
641 /*        eksegdsc.inc  Version 8  06-NOV-1995 (NJB) */
642 
643 
644 /*     All `base addresses' referred to below are the addresses */
645 /*     *preceding* the item the base applies to.  This convention */
646 /*     enables simplied address calculations in many cases. */
647 
648 /*     Size of segment descriptor.  Note:  the include file ekcoldsc.inc */
649 /*     must be updated if this parameter is changed.  The parameter */
650 /*     CDOFF in that file should be kept equal to SDSCSZ. */
651 
652 
653 /*     Index of the segment type code: */
654 
655 
656 /*     Index of the segment's number.  This number is the segment's */
657 /*     index in the list of segments contained in the EK to which */
658 /*     the segment belongs. */
659 
660 
661 /*     Index of the DAS integer base address of the segment's integer */
662 /*     meta-data: */
663 
664 
665 /*     Index of the DAS character base address of the table name: */
666 
667 
668 /*     Index of the segment's column count: */
669 
670 
671 /*     Index of the segment's record count: */
672 
673 
674 /*     Index of the root page number of the record tree: */
675 
676 
677 /*     Index of the root page number of the character data page tree: */
678 
679 
680 /*     Index of the root page number of the double precision data page */
681 /*     tree: */
682 
683 
684 /*     Index of the root page number of the integer data page tree: */
685 
686 
687 /*     Index of the `modified' flag: */
688 
689 
690 /*     Index of the `initialized' flag: */
691 
692 
693 /*     Index of the shadowing flag: */
694 
695 
696 /*     Index of the companion file handle: */
697 
698 
699 /*     Index of the companion segment number: */
700 
701 
702 /*     The next three items are, respectively, the page numbers of the */
703 /*     last character, d.p., and integer data pages allocated by the */
704 /*     segment: */
705 
706 
707 /*     The next three items are, respectively, the page-relative */
708 /*     indices of the last DAS word in use in the segment's */
709 /*     last character, d.p., and integer data pages: */
710 
711 
712 /*     Index of the DAS character base address of the column name list: */
713 
714 
715 /*     The last descriptor element is reserved for future use.  No */
716 /*     parameter is defined to point to this location. */
717 
718 
719 /*     End Include Section:  EK Segment Descriptor Parameters */
720 
721 /* $ Disclaimer */
722 
723 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
724 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
725 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
726 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
727 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
728 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
729 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
730 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
731 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
732 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
733 
734 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
735 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
736 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
737 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
738 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
739 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
740 
741 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
742 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
743 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
744 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
745 
746 
747 /*     Include Section:  EK Data Types */
748 
749 /*        ektype.inc Version 1  27-DEC-1994 (NJB) */
750 
751 
752 /*     Within the EK system, data types of EK column contents are */
753 /*     represented by integer codes.  The codes and their meanings */
754 /*     are listed below. */
755 
756 /*     Integer codes are also used within the DAS system to indicate */
757 /*     data types; the EK system makes no assumptions about compatibility */
758 /*     between the codes used here and those used in the DAS system. */
759 
760 
761 /*     Character type: */
762 
763 
764 /*     Double precision type: */
765 
766 
767 /*     Integer type: */
768 
769 
770 /*     `Time' type: */
771 
772 /*     Within the EK system, time values are represented as ephemeris */
773 /*     seconds past J2000 (TDB), and double precision numbers are used */
774 /*     to store these values.  However, since time values require special */
775 /*     treatment both on input and output, and since the `TIME' column */
776 /*     has a special role in the EK specification and code, time values */
777 /*     are identified as a type distinct from double precision numbers. */
778 
779 
780 /*     End Include Section:  EK Data Types */
781 
782 /* $ Brief_I/O */
783 
784 /*     Variable  I/O  Description */
785 /*     --------  ---  -------------------------------------------------- */
786 /*     HANDLE     I   Handle attached to new EK file. */
787 /*     SEGDSC     I   Segment descriptor. */
788 /*     COLDSC     I   Column descriptor. */
789 /*     IVALS      I   Integer values to add to column. */
790 /*     ENTSZS     I   Array of sizes of column entries. */
791 /*     NLFLGS     I   Array of null flags for column entries. */
792 
793 /* $ Detailed_Input */
794 
795 /*     HANDLE         the handle of an EK file that is open for writing. */
796 /*                    A `begin segment for fast load' operation must */
797 /*                    have already been performed for the designated */
798 /*                    segment. */
799 
800 /*     SEGDSC         is a descriptor for the segment to which data is */
801 /*                    to be added.  The segment descriptor is not */
802 /*                    updated by this routine, but some fields in the */
803 /*                    descriptor will become invalid after this routine */
804 /*                    returns. */
805 
806 /*     COLDSC         is a descriptor for the column to be added.  The */
807 /*                    column attributes must be filled in, but any */
808 /*                    pointers may be uninitialized. */
809 
810 /*     ENTSZS         is an array containing sizes of column entries. */
811 /*                    The Ith element of ENTSZS gives the size of the */
812 /*                    Ith column entry.  ENTSZS is used only for columns */
813 /*                    having variable-size entries.  For such columns, */
814 /*                    the dimension of ENTSZS must be at least NROWS. */
815 /*                    The size of null entries should be set to zero. */
816 
817 /*                    For columns having fixed-size entries, the */
818 /*                    dimension of this array may be any positive value. */
819 
820 /*     IVALS          is an array containing the entire set of column */
821 /*                    entries for the specified column.  The entries */
822 /*                    are listed in row-order:  the column entry for the */
823 /*                    first row of the segment is first, followed by the */
824 /*                    column entry for the second row, and so on.  The */
825 /*                    number of column entries must match the declared */
826 /*                    number of rows in the segment.  For columns having */
827 /*                    fixed-size entries, a null entry must be allocated */
828 /*                    the same amount of space occupied by a non-null */
829 /*                    entry in the array IVALS.  For columns having */
830 /*                    variable-size entries, null entries do not require */
831 /*                    any space in the IVALS array, but in any case must */
832 /*                    have their allocated space described correctly by */
833 /*                    the corresponding element of the ENTSZS array */
834 /*                    (described below). */
835 
836 /*     ENTSZS         is an array containing sizes of column entries. */
837 /*                    The Ith element of ENTSZS gives the size of the */
838 /*                    Ith column entry.  ENTSZS is used only for columns */
839 /*                    having variable-size entries.  For such columns, */
840 /*                    the dimension of ENTSZS must be at least NROWS. */
841 /*                    The size of null entries should be set to zero. */
842 
843 /*                    For columns having fixed-size entries, the */
844 /*                    dimension of this array may be any positive value. */
845 
846 /*     NLFLGS         is an array of logical flags indicating whether */
847 /*                    the corresponding entries are null.  If the Ith */
848 /*                    element of NLFLGS is .FALSE., the Ith column entry */
849 /*                    defined by IVALS is added to the specified segment */
850 /*                    in the specified kernel file. */
851 
852 /*                    If the Ith element of NLFGLS is .TRUE., the */
853 /*                    contents of the Ith column entry are undefined. */
854 
855 /*                    NLFLGS is used only for columns that allow null */
856 /*                    values; it's ignored for other columns. */
857 
858 /* $ Detailed_Output */
859 
860 /*     None.  See $Particulars for a description of the effect of this */
861 /*     routine. */
862 
863 /* $ Parameters */
864 
865 /*     None. */
866 
867 /* $ Exceptions */
868 
869 /*     1)  If HANDLE is invalid, the error will be diagnosed by routines */
870 /*         called by this routine. */
871 
872 /*     2)  If an I/O error occurs while reading or writing the indicated */
873 /*         file, the error will be diagnosed by routines called by this */
874 /*         routine. */
875 
876 /* $ Files */
877 
878 /*     See the EK Required Reading for a discussion of the EK file */
879 /*     format. */
880 
881 /* $ Particulars */
882 
883 /*     This routine operates by side effects:  it modifies the named */
884 /*     EK file by adding data to the specified column.  This routine */
885 /*     writes the entire contents of the specified column in one shot. */
886 /*     This routine creates columns much more efficiently than can be */
887 /*     done by sequential calls to EKACEI, but has the drawback that */
888 /*     the caller must use more memory for the routine's inputs.  This */
889 /*     routine cannot be used to add data to a partially completed */
890 /*     column. */
891 
892 /* $ Examples */
893 
894 /*     See EKACLI. */
895 
896 /* $ Restrictions */
897 
898 /*     1)  This routine assumes the EK scratch area has been set up */
899 /*         properly for a fast load operation.  This routine writes */
900 /*         to the EK scratch area as well. */
901 
902 /*     2)  Only one segment can be created at a time using the fast */
903 /*         load routines. */
904 
905 /*     3)  No other EK operation may interrupt a fast load.  For */
906 /*         example, it is not valid to issue a query while a fast load */
907 /*         is in progress. */
908 
909 /* $ Literature_References */
910 
911 /*     None. */
912 
913 /* $ Author_and_Institution */
914 
915 /*     N.J. Bachman   (JPL) */
916 
917 /* $ Version */
918 
919 /* -    SPICELIB Version 1.1.0, 22-JUL-1996 (NJB) */
920 
921 /*        Bug fix:  case of 100% null data values is now handled */
922 /*        correctly.  Previous version line was changed from "Beta" */
923 /*        to "SPICELIB." */
924 
925 /* -    SPICELIB Version 1.0.0, 26-SEP-1995 (NJB) */
926 
927 /* -& */
928 /* $ Revisions */
929 
930 /* -    SPICELIB Version 1.1.0, 22-JUL-1996 (NJB) */
931 
932 /*        Bug fix:  case of 100% null data values is now handled */
933 /*        correctly.  The test to determine when to write a page */
934 /*        was fixed to handle this case. */
935 
936 /*        Previous version line was changed from "Beta" */
937 /*        to "SPICELIB." */
938 
939 /* -& */
940 
941 /*     SPICELIB functions */
942 
943 
944 /*     Local parameters */
945 
946 
947 /*     Local variables */
948 
949 
950 /*     Standard SPICE error handling. */
951 
952     if (return_()) {
953 	return 0;
954     } else {
955 	chkin_("ZZEKAC04", (ftnlen)8);
956     }
957 
958 /*     Grab the column's attributes. */
959 
960     class__ = coldsc[0];
961     nulptr = coldsc[7];
962     colidx = coldsc[8];
963     size = coldsc[3];
964     nullok = nulptr != -1;
965     fixsiz = size != -1;
966 
967 /*     This column had better be class 4. */
968 
969     if (class__ != 4) {
970 	zzekcnam_(handle, coldsc, column, (ftnlen)32);
971 	setmsg_("Column class code # found in descriptor for column #.  Clas"
972 		"s should be 4.", (ftnlen)73);
973 	errint_("#", &class__, (ftnlen)1);
974 	errch_("#", column, (ftnlen)1, (ftnlen)32);
975 	sigerr_("SPICE(NOCLASS)", (ftnlen)14);
976 	chkout_("ZZEKAC04", (ftnlen)8);
977 	return 0;
978     }
979 
980 /*     Push the column's ordinal index on the stack.  This allows us */
981 /*     to identify the column the addresses belong to. */
982 
983     zzekspsh_(&c__1, &colidx);
984 
985 /*     Find the number of rows in the segment. */
986 
987     nrows = segdsc[5];
988 
989 /*     Record the number of data values to write. */
990 
991     if (nullok) {
992 
993 /*        Sum the sizes of the non-null column entries; these are the */
994 /*        ones that will take up space. */
995 
996 	ndata = 0;
997 	i__1 = nrows;
998 	for (i__ = 1; i__ <= i__1; ++i__) {
999 	    if (! nlflgs[i__ - 1]) {
1000 		if (fixsiz) {
1001 		    ndata += size;
1002 		} else {
1003 		    ndata += entszs[i__ - 1];
1004 		}
1005 	    }
1006 	}
1007     } else {
1008 	if (fixsiz) {
1009 	    ndata = nrows * size;
1010 	} else {
1011 	    ndata = 0;
1012 	    i__1 = nrows;
1013 	    for (i__ = 1; i__ <= i__1; ++i__) {
1014 		ndata += entszs[i__ - 1];
1015 	    }
1016 	}
1017     }
1018     if (ndata > 0) {
1019 
1020 /*        There's some data to write, so allocate a page.  Also */
1021 /*        prepare a data buffer to be written out as a page. */
1022 
1023 	zzekaps_(handle, segdsc, &c__3, &c_false, &p, &pbase);
1024 	cleari_(&c__256, page);
1025     }
1026 
1027 /*     Write the input data out to the target file a page at a time. */
1028 /*     Null values don't get written. */
1029 
1030 /*     While we're at it, we'll push onto the EK stack the addresses */
1031 /*     of the column entries.  We use the constant NULL rather than an */
1032 /*     address to represent null entries. */
1033 
1034 /*     We'll use FROM to indicate the element of IVALS we're */
1035 /*     considering, TO to indicate the element of PAGE to write */
1036 /*     to, and BUFPTR to indicate the element of ADRBUF to write */
1037 /*     addresses to.  The variable NELT is the count of the column entry */
1038 /*     elements written for the current entry.  The variable N indicates */
1039 /*     the number of integers written to the current page. */
1040 
1041     remain = ndata;
1042     from = 1;
1043     to = 1;
1044     bufptr = 1;
1045     row = 1;
1046     nelt = 1;
1047     n = 0;
1048     nlink = 0;
1049     while(row <= nrows) {
1050 
1051 /*        NEWREQ is set to TRUE if we discover that the next column */
1052 /*        entry must start on a new page. */
1053 
1054 	newreq = FALSE_;
1055 	if (nullok && nlflgs[row - 1]) {
1056 	    if (fixsiz) {
1057 		cursiz = size;
1058 	    } else {
1059 		cursiz = entszs[row - 1];
1060 	    }
1061 	    from += cursiz;
1062 	    adrbuf[(i__1 = bufptr - 1) < 254 && 0 <= i__1 ? i__1 : s_rnge(
1063 		    "adrbuf", i__1, "zzekac04_", (ftnlen)415)] = -2;
1064 	    ++bufptr;
1065 	    ++row;
1066 	    nelt = 1;
1067 	    cntinu = FALSE_;
1068 	} else {
1069 	    if (nelt == 1) {
1070 
1071 /*              We're about to write out a new column entry.  We must */
1072 /*              insert the element count into the page before writing the */
1073 /*              data.  The link count for the current page must be */
1074 /*              incremented to account for this new entry. */
1075 
1076 /*              At this point, we're guaranteed at least two free */
1077 /*              spaces in the current page. */
1078 
1079 		if (fixsiz) {
1080 		    cursiz = size;
1081 		} else {
1082 		    cursiz = entszs[row - 1];
1083 		}
1084 		adrbuf[(i__1 = bufptr - 1) < 254 && 0 <= i__1 ? i__1 : s_rnge(
1085 			"adrbuf", i__1, "zzekac04_", (ftnlen)441)] = to +
1086 			pbase;
1087 		++bufptr;
1088 		page[(i__1 = to - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge("page"
1089 			, i__1, "zzekac04_", (ftnlen)443)] = cursiz;
1090 		++to;
1091 		++n;
1092 		++nlink;
1093 	    }
1094 
1095 /*           At this point, there's at least one free space in the */
1096 /*           current page. */
1097 
1098 	    page[(i__1 = to - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge("page",
1099 		    i__1, "zzekac04_", (ftnlen)454)] = ivals[from - 1];
1100 	    ++to;
1101 	    ++n;
1102 	    ++from;
1103 	    --remain;
1104 
1105 /*           Decide whether we must continue the current entry on another */
1106 /*           data page. */
1107 
1108 	    cntinu = nelt < cursiz && n == 254;
1109 	    if (nelt == cursiz) {
1110 
1111 /*              The current element is the last of the current column */
1112 /*              entry. */
1113 
1114 /*              Determine whether we must start the next column entry on */
1115 /*              a new page.  To start a column entry on the current page, */
1116 /*              we must have enough room for the element count and at */
1117 /*              least the first entry element. */
1118 
1119 		if (remain > 0) {
1120 		    newreq = n > 252;
1121 		}
1122 		nelt = 1;
1123 		++row;
1124 	    } else {
1125 		++nelt;
1126 	    }
1127 	}
1128 	if (bufptr > 254 || row > nrows) {
1129 
1130 /*           The address buffer is full or we're out of input values */
1131 /*           to look at, so push the buffer contents on the stack. */
1132 
1133 	    i__1 = bufptr - 1;
1134 	    zzekspsh_(&i__1, adrbuf);
1135 	    bufptr = 1;
1136 	}
1137 	if (cntinu || newreq || row > nrows && ndata > 0) {
1138 
1139 /*           It's time to write out the current page.  First set the link */
1140 /*           count. */
1141 
1142 	    page[255] = nlink;
1143 
1144 /*           Write out the data page. */
1145 
1146 	    zzekpgwi_(handle, &p, page);
1147 
1148 /*           If there's more data to write, allocate another page. */
1149 
1150 	    if (remain > 0) {
1151 		zzekaps_(handle, segdsc, &c__3, &c_false, &p2, &pbase);
1152 		cleari_(&c__256, page);
1153 		n = 0;
1154 		nlink = 0;
1155 		to = 1;
1156 
1157 /*              If we're continuing an element from the previous page, */
1158 /*              link the previous page to the current one. */
1159 
1160 		if (cntinu) {
1161 		    zzeksfwd_(handle, &c__3, &p, &p2);
1162 		}
1163 		p = p2;
1164 	    }
1165 
1166 /*           We've allocated a new data page if we needed one. */
1167 
1168 	}
1169 
1170 /*        We've written out the last completed data page. */
1171 
1172     }
1173 
1174 /*     We've processed all entries of the input array. */
1175 
1176     chkout_("ZZEKAC04", (ftnlen)8);
1177     return 0;
1178 } /* zzekac04_ */
1179 
1180