/* $Procedure ZZEKAC01 ( EK, add class 1 column to segment ) */ /* Subroutine */ int zzekac01_(integer *handle, integer *segdsc, integer * coldsc, integer *ivals, logical *nlflgs, integer *rcptrs, integer * wkindx) { /* System generated locals */ integer i__1, i__2; /* Builtin functions */ integer s_rnge(char *, integer, char *, integer); /* Local variables */ integer page[256], tree, from; extern /* Subroutine */ int zzektr1s_(integer *, integer *, integer *, integer *), zzekcnam_(integer *, integer *, char *, ftnlen), zzekordi_(integer *, logical *, logical *, integer *, integer *), zzekpgwi_(integer *, integer *, integer *), zzekspsh_(integer *, integer *), zzektrit_(integer *, integer *); integer i__, n, p, mbase, ndata, pbase; extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *, ftnlen, ftnlen); integer class__, nnull, nrows; extern logical return_(void); char column[32]; integer adrbuf[254], bufptr, colidx, dscbas, idxtyp, nulptr, nwrite, remain, to; logical indexd, nullok; extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen), cleari_(integer *, integer *), dasudi_(integer *, integer *, integer *, integer *), zzekaps_(integer *, integer *, integer *, logical *, integer *, integer *); /* $ Abstract */ /* Add an entire class 1 column to an EK segment. */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* $ Required_Reading */ /* EK */ /* $ Keywords */ /* EK */ /* $ Declarations */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Boolean Enumerated Type */ /* ekbool.inc Version 1 21-DEC-1994 (NJB) */ /* Within the EK system, boolean values sometimes must be */ /* represented by integer or character codes. The codes and their */ /* meanings are listed below. */ /* Integer code indicating `true': */ /* Integer code indicating `false': */ /* Character code indicating `true': */ /* Character code indicating `false': */ /* End Include Section: EK Boolean Enumerated Type */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Column Descriptor Parameters */ /* ekcoldsc.inc Version 6 23-AUG-1995 (NJB) */ /* Note: The column descriptor size parameter CDSCSZ is */ /* declared separately in the include section CDSIZE$INC.FOR. */ /* Offset of column descriptors, relative to start of segment */ /* integer address range. This number, when added to the last */ /* integer address preceding the segment, yields the DAS integer */ /* base address of the first column descriptor. Currently, this */ /* offset is exactly the size of a segment descriptor. The */ /* parameter SDSCSZ, which defines the size of a segment descriptor, */ /* is declared in the include file eksegdsc.inc. */ /* Size of column descriptor */ /* Indices of various pieces of column descriptors: */ /* CLSIDX is the index of the column's class code. (We use the */ /* word `class' to distinguish this item from the column's data */ /* type.) */ /* TYPIDX is the index of the column's data type code (CHR, INT, DP, */ /* or TIME). The type is actually implied by the class, but it */ /* will frequently be convenient to look up the type directly. */ /* LENIDX is the index of the column's string length value, if the */ /* column has character type. A value of IFALSE in this element of */ /* the descriptor indicates that the strings have variable length. */ /* SIZIDX is the index of the column's element size value. This */ /* descriptor element is meaningful for columns with fixed-size */ /* entries. For variable-sized columns, this value is IFALSE. */ /* NAMIDX is the index of the base address of the column's name. */ /* IXTIDX is the data type of the column's index. IXTIDX */ /* contains a type value only if the column is indexed. For columns */ /* that are not indexed, the location IXTIDX contains the boolean */ /* value IFALSE. */ /* IXPIDX is a pointer to the column's index. IXTPDX contains a */ /* meaningful value only if the column is indexed. The */ /* interpretation of the pointer depends on the data type of the */ /* index. */ /* NFLIDX is the index of a flag indicating whether nulls are */ /* permitted in the column. The value at location NFLIDX is */ /* ITRUE if nulls are permitted and IFALSE otherwise. */ /* ORDIDX is the index of the column's ordinal position in the */ /* list of columns belonging to the column's parent segment. */ /* METIDX is the index of the column's integer metadata pointer. */ /* This pointer is a DAS integer address. */ /* The last position in the column descriptor is reserved. No */ /* parameter is defined to point to this location. */ /* End Include Section: EK Column Descriptor Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Column Name Size */ /* ekcnamsz.inc Version 1 17-JAN-1995 (NJB) */ /* Size of column name, in characters. */ /* End Include Section: EK Column Name Size */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Data Page Parameters */ /* ekfilpar.inc Version 1 03-APR-1995 (NJB) */ /* These parameters apply to EK files using architecture 4. */ /* These files use a paged DAS file as their underlying file */ /* structure. */ /* In paged DAS EK files, data pages are structured: they contain */ /* metadata as well as data. The metadata is located in the last */ /* few addresses of each page, so as to interfere as little as */ /* possible with calculation of data addresses. */ /* Each data page belongs to exactly one segment. Some bookkeeping */ /* information, such as record pointers, is also stored in data */ /* pages. */ /* Each page contains a forward pointer that allows rapid lookup */ /* of data items that span multiple pages. Each page also keeps */ /* track of the current number of links from its parent segment */ /* to the page. Link counts enable pages to `know' when they */ /* are no longer in use by a segment; unused pages are deallocated */ /* and returned to the free list. */ /* The parameters in this include file depend on the parameters */ /* declared in the include file ekpage.inc. If those parameters */ /* change, this file must be updated. The specified parameter */ /* declarations we need from that file are: */ /* INTEGER PGSIZC */ /* PARAMETER ( PGSIZC = 1024 ) */ /* INTEGER PGSIZD */ /* PARAMETER ( PGSIZD = 128 ) */ /* INTEGER PGSIZI */ /* PARAMETER ( PGSIZI = 256 ) */ /* Character pages use an encoding mechanism to represent integer */ /* metadata. Each integer is encoded in five consecutive */ /* characters. */ /* Character data page parameters: */ /* Size of encoded integer: */ /* Usable page size: */ /* Location of character forward pointer: */ /* Location of character link count: */ /* Double precision data page parameters: */ /* Usable page size: */ /* Location of d.p. forward pointer: */ /* Location of d.p. link count: */ /* Integer data page parameters: */ /* Usable page size: */ /* Location of integer forward pointer: */ /* Location of integer link count: */ /* End Include Section: EK Data Page Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Das Paging Parameters */ /* ekpage.inc Version 4 25-AUG-1995 (NJB) */ /* The EK DAS paging system makes use of the integer portion */ /* of an EK file's DAS address space to store the few numbers */ /* required to describe the system's state. The allocation */ /* of DAS integer addresses is shown below. */ /* DAS integer array */ /* +--------------------------------------------+ */ /* | EK architecture code | Address = 1 */ /* +--------------------------------------------+ */ /* | Character page size (in DAS words) | */ /* +--------------------------------------------+ */ /* | Character page base address | */ /* +--------------------------------------------+ */ /* | Number of character pages in file | */ /* +--------------------------------------------+ */ /* | Number of character pages on free list | */ /* +--------------------------------------------+ */ /* | Character free list head pointer | Address = 6 */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for d.p. pages | 7--11 */ /* | | */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for integer pages | 12--16 */ /* | | */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | End Address = */ /* | Unused space | integer page */ /* | | end */ /* +--------------------------------------------+ */ /* | | Start Address = */ /* | First integer page | integer page */ /* | | base */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | */ /* | Last integer page | */ /* | | */ /* +--------------------------------------------+ */ /* The following parameters indicate positions of elements in the */ /* paging system metadata array: */ /* Number of metadata items per data type: */ /* Character metadata indices: */ /* Double precision metadata indices: */ /* Integer metadata indices: */ /* Size of metadata area: */ /* Page sizes, in units of DAS words of the appropriate type: */ /* Default page base addresses: */ /* End Include Section: EK Das Paging Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Record Pointer Parameters */ /* ekrecptr.inc Version 2 18-JUL-1995 (NJB) */ /* This file declares parameters used in EK record pointers. */ /* Each segment references data in a given record via two levels */ /* of indirection: a record number points to a record pointer, */ /* which is a structured array of metadata and data pointers. */ /* Record pointers always occupy contiguous ranges of integer */ /* addresses. */ /* The parameter declarations in this file depend on the assumption */ /* that integer pages contain 256 DAS integer words and that the */ /* maximum number of columns in a segment is 100. Record pointers */ /* are stored in integer data pages, so they must fit within the */ /* usable data area afforded by these pages. The size of the usable */ /* data area is given by the parameter IPSIZE which is declared in */ /* ekdatpag.inc. The assumed value of IPSIZE is 254. */ /* The first element of each record pointer is a status indicator. */ /* The meanings of status indicators depend on whether the parent EK */ /* is shadowed or not. For shadowed EKs, allowed status values and */ /* their meanings are: */ /* OLD The record has not been modified since */ /* the EK containing the record was opened. */ /* UPDATE The record is an update of a previously existing */ /* record. The original record is now on the */ /* modified record list. */ /* NEW The record has been added since the EK containing the */ /* record was opened. The record is not an update */ /* of a previously existing record. */ /* DELOLD This status applies only to a backup record. */ /* DELOLD status indicates that the record corresponds */ /* to a deleted OLD record in the source segment. */ /* DELNEW This status applies only to a backup record. */ /* DELNEW status indicates that the record corresponds */ /* to a deleted NEW record in the source segment. */ /* DELUPD This status applies only to a backup record. */ /* DELUPD status indicates that the record corresponds */ /* to a deleted UPDATEd record in the source segment. */ /* In EKs that are not shadowed, all records have status OLD. */ /* The following parameters refer to indices within the record */ /* pointer structure: */ /* Index of status indicator: */ /* Each record pointer contains a pointer to its companion: for a */ /* record belonging to a shadowed EK, this is the backup counterpart, */ /* or if the parent EK is itself a backup EK, a pointer to the */ /* record's source record. The pointer is UNINIT (see below) if the */ /* record is unmodified. */ /* Record companion pointers contain record numbers, not record */ /* base addresses. */ /* Index of record's companion pointer: */ /* Each data item is referenced by an integer. The meaning of */ /* this integer depends on the representation of data in the */ /* column to which the data item belongs. Actual lookup of a */ /* data item must be done by subroutines appropriate to the class of */ /* the column to which the item belongs. Note that data items don't */ /* necessarily occupy contiguous ranges of DAS addresses. */ /* Base address of data pointers: */ /* Maximum record pointer size: */ /* Data pointers are given the value UNINIT to start with; this */ /* indicates that the data item is uninitialized. UNINIT is */ /* distinct from the value NULL. NOBACK indicates an uninitialized */ /* backup column entry. */ /* End Include Section: EK Record Pointer Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Segment Descriptor Parameters */ /* eksegdsc.inc Version 8 06-NOV-1995 (NJB) */ /* All `base addresses' referred to below are the addresses */ /* *preceding* the item the base applies to. This convention */ /* enables simplied address calculations in many cases. */ /* Size of segment descriptor. Note: the include file ekcoldsc.inc */ /* must be updated if this parameter is changed. The parameter */ /* CDOFF in that file should be kept equal to SDSCSZ. */ /* Index of the segment type code: */ /* Index of the segment's number. This number is the segment's */ /* index in the list of segments contained in the EK to which */ /* the segment belongs. */ /* Index of the DAS integer base address of the segment's integer */ /* meta-data: */ /* Index of the DAS character base address of the table name: */ /* Index of the segment's column count: */ /* Index of the segment's record count: */ /* Index of the root page number of the record tree: */ /* Index of the root page number of the character data page tree: */ /* Index of the root page number of the double precision data page */ /* tree: */ /* Index of the root page number of the integer data page tree: */ /* Index of the `modified' flag: */ /* Index of the `initialized' flag: */ /* Index of the shadowing flag: */ /* Index of the companion file handle: */ /* Index of the companion segment number: */ /* The next three items are, respectively, the page numbers of the */ /* last character, d.p., and integer data pages allocated by the */ /* segment: */ /* The next three items are, respectively, the page-relative */ /* indices of the last DAS word in use in the segment's */ /* last character, d.p., and integer data pages: */ /* Index of the DAS character base address of the column name list: */ /* The last descriptor element is reserved for future use. No */ /* parameter is defined to point to this location. */ /* End Include Section: EK Segment Descriptor Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Data Types */ /* ektype.inc Version 1 27-DEC-1994 (NJB) */ /* Within the EK system, data types of EK column contents are */ /* represented by integer codes. The codes and their meanings */ /* are listed below. */ /* Integer codes are also used within the DAS system to indicate */ /* data types; the EK system makes no assumptions about compatibility */ /* between the codes used here and those used in the DAS system. */ /* Character type: */ /* Double precision type: */ /* Integer type: */ /* `Time' type: */ /* Within the EK system, time values are represented as ephemeris */ /* seconds past J2000 (TDB), and double precision numbers are used */ /* to store these values. However, since time values require special */ /* treatment both on input and output, and since the `TIME' column */ /* has a special role in the EK specification and code, time values */ /* are identified as a type distinct from double precision numbers. */ /* End Include Section: EK Data Types */ /* $ Brief_I/O */ /* Variable I/O Description */ /* -------- --- -------------------------------------------------- */ /* HANDLE I Handle attached to new EK file. */ /* SEGDSC I Segment descriptor. */ /* COLDSC I Column descriptor. */ /* IVALS I Integer values to add to column. */ /* NLFLGS I Array of null flags for column entries. */ /* RCPTRS I Array of record pointers for segment. */ /* WKINDX I-O Work space for column index. */ /* $ Detailed_Input */ /* HANDLE the handle of an EK file that is open for writing. */ /* A `begin segment for fast load' operation must */ /* have already been performed for the designated */ /* segment. */ /* SEGDSC is a descriptor for the segment to which data is */ /* to be added. The segment descriptor is not */ /* updated by this routine, but some fields in the */ /* descriptor will become invalid after this routine */ /* returns. */ /* COLDSC is a descriptor for the column to be added. The */ /* column attributes must be filled in, but any */ /* pointers may be uninitialized. */ /* IVALS is an array containing the entire set of column */ /* entries for the specified column. The entries */ /* are listed in row-order: the column entry for the */ /* first row of the segment is first, followed by the */ /* column entry for the second row, and so on. The */ /* number of column entries must match the declared */ /* number of rows in the segment. Elements must be */ /* allocated for each column entry, including null */ /* entries. */ /* NLFLGS is an array of logical flags indicating whether */ /* the corresponding entries are null. If the Ith */ /* element of NLFLGS is .FALSE., the Ith column entry */ /* defined by IVALS is added to the specified segment */ /* in the specified kernel file. */ /* If the Ith element of NLFGLS is .TRUE., the */ /* contents of the Ith column entry are undefined. */ /* NLFLGS is used only for columns that allow null */ /* values; it's ignored for other columns. */ /* RCPTRS is an array of record pointers for the input */ /* segment. These pointers are base addresses of the */ /* `record pointer structures' for the segment. */ /* These pointers are used instead of record numbers */ /* in column indexes: the indexes map ordinal */ /* positions to record pointers. */ /* WKINDX is a work space array used for building a column */ /* index. If the column is indexed, the dimension of */ /* WKINDX must be at NROWS, where NROWS is the number */ /* of rows in the column. If the column is not */ /* indexed, this work space is not used, so the */ /* dimension may be any positive value. */ /* $ Detailed_Output */ /* None. See $Particulars for a description of the effect of this */ /* routine. */ /* $ Parameters */ /* None. */ /* $ Exceptions */ /* 1) If HANDLE is invalid, the error will be diagnosed by routines */ /* called by this routine. */ /* 2) If an I/O error occurs while reading or writing the indicated */ /* file, the error will be diagnosed by routines called by this */ /* routine. */ /* $ Files */ /* See the EK Required Reading for a discussion of the EK file */ /* format. */ /* $ Particulars */ /* This routine operates by side effects: it modifies the named */ /* EK file by adding data to the specified column. This routine */ /* writes the entire contents of the specified column in one shot. */ /* This routine creates columns much more efficiently than can be */ /* done by sequential calls to EKACEI, but has the drawback that */ /* the caller must use more memory for the routine's inputs. This */ /* routine cannot be used to add data to a partially completed */ /* column. */ /* $ Examples */ /* See EKACLI. */ /* $ Restrictions */ /* 1) This routine assumes the EK scratch area has been set up */ /* properly for a fast load operation. This routine writes */ /* to the EK scratch area as well. */ /* $ Literature_References */ /* None. */ /* $ Author_and_Institution */ /* N.J. Bachman (JPL) */ /* $ Version */ /* - SPICELIB Version 1.1.0, 22-JUL-1996 (NJB) */ /* Bug fix: case of 100% null data values is now handled */ /* correctly. Previous version line was changed from "Beta" */ /* to "SPICELIB." */ /* - SPICELIB Version 1.0.0, 25-SEP-1995 (NJB) */ /* -& */ /* $ Revisions */ /* - SPICELIB Version 1.1.0, 22-JUL-1996 (NJB) */ /* Bug fix: case of 100% null data values is now handled */ /* correctly. The test to determine when to write a page */ /* was fixed to handle this case. */ /* Previous version line was changed from "Beta" */ /* to "SPICELIB." */ /* -& */ /* SPICELIB functions */ /* Local parameters */ /* Local variables */ /* Standard SPICE error handling. */ if (return_()) { return 0; } else { chkin_("ZZEKAC01", (ftnlen)8); } /* Grab the column's attributes. */ class__ = coldsc[0]; idxtyp = coldsc[5]; nulptr = coldsc[7]; colidx = coldsc[8]; nullok = nulptr != -1; indexd = idxtyp != -1; /* This column had better be class 1. */ if (class__ != 1) { zzekcnam_(handle, coldsc, column, (ftnlen)32); setmsg_("Column class code # found in descriptor for column #. Clas" "s should be 1.", (ftnlen)73); errint_("#", &class__, (ftnlen)1); errch_("#", column, (ftnlen)1, (ftnlen)32); sigerr_("SPICE(NOCLASS)", (ftnlen)14); chkout_("ZZEKAC01", (ftnlen)8); return 0; } /* If the column is indexed, the index type should be 1; we don't */ /* know how to create any other type of index. */ if (indexd && idxtyp != 1) { zzekcnam_(handle, coldsc, column, (ftnlen)32); setmsg_("Index type code # found in descriptor for column #. Code s" "hould be 1.", (ftnlen)70); errint_("#", &idxtyp, (ftnlen)1); errch_("#", column, (ftnlen)1, (ftnlen)32); sigerr_("SPICE(UNRECOGNIZEDTYPE)", (ftnlen)23); chkout_("ZZEKAC01", (ftnlen)8); return 0; } /* Push the column's ordinal index on the stack. This allows us */ /* to identify the column the addresses belong to. */ zzekspsh_(&c__1, &colidx); /* Find the number of rows in the segment. */ nrows = segdsc[5]; /* Decide how many pages we'll need to store the data. Also */ /* record the number of data values to write. */ if (nullok) { /* Count the non-null rows; these are the ones that will take */ /* up space. */ nnull = 0; i__1 = nrows; for (i__ = 1; i__ <= i__1; ++i__) { if (nlflgs[i__ - 1]) { ++nnull; } } ndata = nrows - nnull; } else { ndata = nrows; } if (ndata > 0) { /* There's some data to write, so allocate a page. Also */ /* prepare a data buffer to be written out as a page. */ zzekaps_(handle, segdsc, &c__3, &c_false, &p, &pbase); cleari_(&c__256, page); } /* Write the input data out to the target file a page at a time. */ /* Null values don't get written. */ /* While we're at it, we'll push onto the EK stack the addresses */ /* of the column entries. We use the constant NULL rather than an */ /* address to represent null entries. */ /* We'll use FROM to indicate the element of IVALS we're */ /* considering, TO to indicate the element of PAGE to write */ /* to, and BUFPTR to indicate the element of ADRBUF to write */ /* addresses to. The variable N indicates the number of data */ /* items in the current page. */ remain = nrows; from = 1; to = 1; bufptr = 1; nwrite = 0; n = 0; while(remain > 0) { if (nullok && nlflgs[from - 1]) { adrbuf[(i__1 = bufptr - 1) < 254 && 0 <= i__1 ? i__1 : s_rnge( "adrbuf", i__1, "zzekac01_", (ftnlen)378)] = -2; } else { adrbuf[(i__1 = bufptr - 1) < 254 && 0 <= i__1 ? i__1 : s_rnge( "adrbuf", i__1, "zzekac01_", (ftnlen)382)] = to + pbase; page[(i__1 = to - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge("page", i__1, "zzekac01_", (ftnlen)383)] = ivals[from - 1]; ++to; ++nwrite; ++n; } ++from; --remain; if (bufptr == 254 || remain == 0) { /* The address buffer is full or we're out of input values */ /* to look at, so push the buffer contents on the stack. */ zzekspsh_(&bufptr, adrbuf); bufptr = 1; } else { ++bufptr; } if (n == 254 || nwrite == ndata && ndata != 0) { /* Either the current data page is full, or we've buffered */ /* the last of the available data. It's time to write out the */ /* current page. First set the link count. */ page[255] = n; /* Write out the data page. */ zzekpgwi_(handle, &p, page); /* If there's more data to write, allocate another page. */ if (nwrite < ndata) { zzekaps_(handle, segdsc, &c__3, &c_false, &p, &pbase); cleari_(&c__256, page); n = 0; to = 1; } } } /* If the column is supposed to have an index, now is the time to */ /* build that index. We'll find the order vector for the input */ /* values, overwrite the elements of the order vector with the */ /* corresponding elements of the input array of record pointers, then */ /* load this sorted copy of the record pointer array into a tree in */ /* one shot. */ if (indexd) { zzekordi_(ivals, &nullok, nlflgs, &nrows, wkindx); i__1 = nrows; for (i__ = 1; i__ <= i__1; ++i__) { wkindx[i__ - 1] = rcptrs[wkindx[i__ - 1] - 1]; } zzektrit_(handle, &tree); zzektr1s_(handle, &tree, &nrows, wkindx); /* Update the segment's metadata to point to the index. The */ /* pointer indicates the root page of the tree. */ mbase = segdsc[2]; dscbas = mbase + 24 + (colidx - 1) * 11; i__1 = dscbas + 7; i__2 = dscbas + 7; dasudi_(handle, &i__1, &i__2, &tree); } chkout_("ZZEKAC01", (ftnlen)8); return 0; } /* zzekac01_ */
/* $Procedure ZZEKTR1S ( EK tree, one-shot load ) */ /* Subroutine */ int zzektr1s_(integer *handle, integer *tree, integer *size, integer *values) { /* System generated locals */ integer i__1, i__2, i__3; /* Builtin functions */ integer s_rnge(char *, integer, char *, integer); /* Local variables */ integer base, page[256], nbig, node, subd, next, unit; extern /* Subroutine */ int zzekpgal_(integer *, integer *, integer *, integer *), zzekpgri_(integer *, integer *, integer *), zzekpgwi_( integer *, integer *, integer *); extern integer zzektrbs_(integer *); integer d__, i__, n, q, child, s; extern integer zzektrsz_(integer *, integer *); extern /* Subroutine */ int chkin_(char *, ftnlen); integer level, nkids, npred, nkeys, tsize, kidbas; extern /* Subroutine */ int cleari_(integer *, integer *), dasudi_( integer *, integer *, integer *, integer *); integer basidx; extern /* Subroutine */ int dashlu_(integer *, integer *); integer bigsiz, nnodes, nsmall, stnbig[10], stnbas[10], stnode[10]; extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen); extern logical return_(void); integer maxsiz, reqsiz, stlsiz[10], stnext[10], stnkey[10], stsbsz[10], subsiz, totnod; extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen); integer div, key; /* $ Abstract */ /* One-shot tree load: insert an entire array into an empty */ /* tree. */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* $ Required_Reading */ /* EK */ /* $ Keywords */ /* EK */ /* PRIVATE */ /* $ Declarations */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Das Paging Parameters */ /* ekpage.inc Version 4 25-AUG-1995 (NJB) */ /* The EK DAS paging system makes use of the integer portion */ /* of an EK file's DAS address space to store the few numbers */ /* required to describe the system's state. The allocation */ /* of DAS integer addresses is shown below. */ /* DAS integer array */ /* +--------------------------------------------+ */ /* | EK architecture code | Address = 1 */ /* +--------------------------------------------+ */ /* | Character page size (in DAS words) | */ /* +--------------------------------------------+ */ /* | Character page base address | */ /* +--------------------------------------------+ */ /* | Number of character pages in file | */ /* +--------------------------------------------+ */ /* | Number of character pages on free list | */ /* +--------------------------------------------+ */ /* | Character free list head pointer | Address = 6 */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for d.p. pages | 7--11 */ /* | | */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for integer pages | 12--16 */ /* | | */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | End Address = */ /* | Unused space | integer page */ /* | | end */ /* +--------------------------------------------+ */ /* | | Start Address = */ /* | First integer page | integer page */ /* | | base */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | */ /* | Last integer page | */ /* | | */ /* +--------------------------------------------+ */ /* The following parameters indicate positions of elements in the */ /* paging system metadata array: */ /* Number of metadata items per data type: */ /* Character metadata indices: */ /* Double precision metadata indices: */ /* Integer metadata indices: */ /* Size of metadata area: */ /* Page sizes, in units of DAS words of the appropriate type: */ /* Default page base addresses: */ /* End Include Section: EK Das Paging Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Tree Parameters */ /* ektree.inc Version 3 22-OCT-1995 (NJB) */ /* The parameters in this file define the tree structure */ /* used by the EK system. This structure is a variant of the */ /* B*-tree structure described in Knuth's book, that is */ /* Knuth, Donald E. "The Art of Computer Programming, */ /* Volume 3/Sorting and Searching" 1973, pp 471-479. */ /* The trees used in the EK system differ from generic B*-trees */ /* primarily in the way keys are treated. Rather than storing */ /* unique primary key values in each node, EK trees store integer */ /* counts that represent the ordinal position of each data value, */ /* counting from the lowest indexed element in the subtree whose */ /* root is the node in question. Thus the keys are unique within */ /* a node but not across multiple nodes: in fact the Nth key in */ /* every leaf node is N. The absolute ordinal position of a data */ /* item is defined recursively as the sum of the key of the data item */ /* and the absolute ordinal position of the data item in the parent */ /* node that immediately precedes all elements of the node in */ /* question. This data structure allows EK trees to support lookup */ /* of data items based on their ordinal position in a data set. The */ /* two prime applications of this capability in the EK system are: */ /* 1) Using trees to index the records in a table, allowing */ /* the Nth record to be located efficiently. */ /* 2) Using trees to implement order vectors that can be */ /* maintained when insertions and deletions are done. */ /* Root node */ /* +--------------------------------------------+ */ /* | Tree version code | */ /* +--------------------------------------------+ */ /* | Number of nodes in tree | */ /* +--------------------------------------------+ */ /* | Number of keys in tree | */ /* +--------------------------------------------+ */ /* | Depth of tree | */ /* +--------------------------------------------+ */ /* | Number of keys in root | */ /* +--------------------------------------------+ */ /* | Space for n keys, | */ /* | | */ /* | n = 2 * INT( ( 2*m - 2 )/3 ) | */ /* | | */ /* | where m is the max number of children per | */ /* | node in the child nodes | */ /* +--------------------------------------------+ */ /* | Space for n+1 child pointers, | */ /* | where n is as defined above. | */ /* +--------------------------------------------+ */ /* | Space for n data pointers, | */ /* | where n is as defined above. | */ /* +--------------------------------------------+ */ /* Child node */ /* +--------------------------------------------+ */ /* | Number of keys present in node | */ /* +--------------------------------------------+ */ /* | Space for m-1 keys | */ /* +--------------------------------------------+ */ /* | Space for m child pointers | */ /* +--------------------------------------------+ */ /* | Space for m-1 data pointers | */ /* +--------------------------------------------+ */ /* The following parameters give the maximum number of children */ /* allowed in the root and child nodes. During insertions, the */ /* number of children may overflow by 1. */ /* Maximum number of children allowed in a child node: */ /* Maximum number of keys allowed in a child node: */ /* Minimum number of children allowed in a child node: */ /* Minimum number of keys allowed in a child node: */ /* Maximum number of children allowed in the root node: */ /* Maximum number of keys allowed in the root node: */ /* Minimum number of children allowed in the root node: */ /* The following parameters indicate positions of elements in the */ /* tree node structures shown above. */ /* The following parameters are for the root node only: */ /* Location of version code: */ /* Version code: */ /* Location of node count: */ /* Location of total key count for the tree: */ /* Location of tree depth: */ /* Location of count of keys in root node: */ /* Base address of keys in the root node: */ /* Base address of child pointers in root node: */ /* Base address of data pointers in the root node (allow room for */ /* overflow): */ /* Size of root node: */ /* The following parameters are for child nodes only: */ /* Location of number of keys in node: */ /* Base address of keys in child nodes: */ /* Base address of child pointers in child nodes: */ /* Base address of data pointers in child nodes (allow room */ /* for overflow): */ /* Size of child node: */ /* A number of EK tree routines must declare stacks of fixed */ /* depth; this depth limit imposes a limit on the maximum depth */ /* that an EK tree can have. Because of the large branching */ /* factor of EK trees, the depth limit is of no practical */ /* importance: The number of keys that can be held in an EK */ /* tree of depth N is */ /* N-1 */ /* MXKIDC - 1 */ /* MXKIDR * ------------- */ /* MXKIDC - 1 */ /* This formula yields a capacity of over 1 billion keys for a */ /* tree of depth 6. */ /* End Include Section: EK Tree Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Data Types */ /* ektype.inc Version 1 27-DEC-1994 (NJB) */ /* Within the EK system, data types of EK column contents are */ /* represented by integer codes. The codes and their meanings */ /* are listed below. */ /* Integer codes are also used within the DAS system to indicate */ /* data types; the EK system makes no assumptions about compatibility */ /* between the codes used here and those used in the DAS system. */ /* Character type: */ /* Double precision type: */ /* Integer type: */ /* `Time' type: */ /* Within the EK system, time values are represented as ephemeris */ /* seconds past J2000 (TDB), and double precision numbers are used */ /* to store these values. However, since time values require special */ /* treatment both on input and output, and since the `TIME' column */ /* has a special role in the EK specification and code, time values */ /* are identified as a type distinct from double precision numbers. */ /* End Include Section: EK Data Types */ /* $ Brief_I/O */ /* Variable I/O Description */ /* -------- --- -------------------------------------------------- */ /* HANDLE I File handle. */ /* TREE I Root of tree. */ /* SIZE I Size of tree. */ /* VALUES I Values to insert. */ /* $ Detailed_Input */ /* HANDLE is a file handle of an EK open for write access. */ /* TREE is the root node number of the tree of interest. */ /* The tree must be empty. */ /* SIZE is the size of the tree to create: SIZE is the */ /* number of values that will be inserted into the */ /* tree. */ /* VALUES is an array of integer values to be inserted into */ /* the tree. */ /* $ Detailed_Output */ /* None. See $Particulars for a description of the effect of this */ /* routine. */ /* $ Parameters */ /* None. */ /* $ Exceptions */ /* 1) If HANDLE is invalid, the error will be diagnosed by routines */ /* called by this routine. The file will not be modified. */ /* 2) If an I/O error occurs while reading or writing the indicated */ /* file, the error will be diagnosed by routines called by this */ /* routine. */ /* 3) If the input tree is not empty, the error SPICE(NONEMPTYTREE) */ /* is signalled. */ /* 4) If the depth of the tree needed to hold the number of values */ /* indicated by SIZE exceeds the maximum depth limit, the error */ /* SPICE(COUNTTOOLARGE) is signalled. */ /* $ Files */ /* See the EK Required Reading for a discussion of the EK file */ /* format. */ /* $ Particulars */ /* This routine creates an EK tree and loads the tree with the */ /* integer values supplied in the array VALUES. The ordinal */ /* positions of the values in the tree correspond to the positions */ /* of the values in the input array: for example, the 10th element */ /* of the array is pointed to by the key 10. */ /* This routine loads a tree much faster than can be done by */ /* sequentially loading the set of values by successive calls to */ /* ZZEKTRIN. On the other hand, the caller must declare an array */ /* large enough to hold all of the values to be loaded. Note that */ /* a partially full tree cannot be extended using this routine. */ /* $ Examples */ /* See EKFFLD. */ /* $ Restrictions */ /* None. */ /* $ Literature_References */ /* 1) Knuth, Donald E. "The Art of Computer Programming, Volume */ /* 3/Sorting and Searching" 1973, pp 471-479. */ /* EK trees are closely related to the B* trees described by */ /* Knuth. */ /* $ Author_and_Institution */ /* N.J. Bachman (JPL) */ /* $ Version */ /* - Beta Version 1.1.0, 18-JUN-1999 (WLT) */ /* Removed redundant calls to CHKIN */ /* - Beta Version 1.0.0, 22-OCT-1995 (NJB) */ /* -& */ /* SPICELIB functions */ /* Non-SPICELIB functions */ /* Local variables */ /* Standard SPICE error handling. */ if (return_()) { return 0; } else { chkin_("ZZEKTR1S", (ftnlen)8); } /* Make sure the input tree is empty. */ tsize = zzektrsz_(handle, tree); if (tsize > 0) { dashlu_(handle, &unit); setmsg_("Tree has size #; should be empty.EK = #; TREE = #.", (ftnlen) 50); errint_("#", &tsize, (ftnlen)1); errfnm_("#", &unit, (ftnlen)1); errint_("#", tree, (ftnlen)1); sigerr_("SPICE(NONEMPTYTREE)", (ftnlen)19); chkout_("ZZEKTR1S", (ftnlen)8); return 0; } /* Compute the tree depth required. The largest tree of a given */ /* depth D contains the root node plus S(D) child nodes, where */ /* S(1) = 1 */ /* and if D is at least 2, */ /* D - 2 */ /* ____ */ /* \ i */ /* S(D) = MAX_SIZE * / MAX_SIZE */ /* Root ---- Child */ /* i = 0 */ /* D - 2 */ /* ____ */ /* \ i */ /* = MXKIDR * / MXKIDC */ /* ---- */ /* i = 0 */ /* D-1 */ /* MXKIDC - 1 */ /* = MXKIDR * ------------- */ /* MXKIDC - 1 */ /* If all of these nodes are full, the number of keys that */ /* can be held in this tree is */ /* MXKEYR + S(D) * MXKEYC */ /* We want the minimum value of D such that this expression */ /* is greater than or equal to SIZE. */ tsize = 82; d__ = 1; s = 1; while(tsize < *size) { ++d__; if (d__ == 2) { s = 82; } else { /* For computational purposes, the relationship */ /* S(D+1) = MXKIDR + MXKIDC * S(D) */ /* is handy. */ s = s * 63 + 83; } tsize = s * 62 + 82; } /* If the tree must be deeper than we expected, we've a problem. */ if (d__ > 10) { dashlu_(handle, &unit); setmsg_("Tree has depth #; max supported depth is #.EK = #; TREE = #." , (ftnlen)60); errint_("#", &d__, (ftnlen)1); errint_("#", &c__10, (ftnlen)1); errfnm_("#", &unit, (ftnlen)1); errint_("#", tree, (ftnlen)1); sigerr_("SPICE(COUNTTOOLARGE)", (ftnlen)20); chkout_("ZZEKTR1S", (ftnlen)8); return 0; } /* The basic error checks are done. At this point, we can build the */ /* tree. */ /* The approach is to fill in the tree in a top-down fashion. */ /* We decide how big each subtree of the root will be; this */ /* information allows us to decide which keys actually belong */ /* in the root. Having filled in the root, we repeat the process */ /* for each subtree of the root in left-to-right order. */ /* We use a stack to keep track of the ancestors of the */ /* node we're currently considering. The table below shows the */ /* items we save on the stack and the stack variables associated */ /* with those items: */ /* Item Stack Variable */ /* ---- --------------- */ /* Node number STNODE */ /* Size, in keys, of the */ /* subtree headed by node STSBSZ */ /* Number of keys in node STNKEY */ /* Larger subtree size STLSIZ */ /* Number of large subtrees STNBIG */ /* Index of next subtree to visit STNEXT */ /* Base index of node STNBAS */ node = *tree; subsiz = *size; next = 1; level = 1; basidx = 0; while(level > 0) { /* At this point, LEVEL, NEXT, NODE, SUBSIZ and BASIDX are set. */ if (next == 1) { /* This node has not been visited yet. We'll fill in this */ /* node before proceeding to fill in its descendants. The */ /* first step is to compute the number and sizes of the */ /* subtrees of this node. */ /* Decide the large subtree size and the number of subtrees of */ /* this node. The depth SUBD of the subtrees of this node is */ /* D - LEVEL. Each subtree has size bounded by the sizes of */ /* the subtree of depth SUBD in which all nodes contain MNKEYC */ /* keys and the by the subtree of depth SUBD in which all nodes */ /* contain MXKEYC keys. If this node is not the root and is */ /* not a leaf node, the number of subtrees must be between */ /* MNKIDC and MXKIDC. */ if (level == 1) { /* We're working on the root. The number of subtrees is */ /* anywhere between 0 and MXKIDR, inclusive. We'll create */ /* a tree with the minimum number of subtrees of the root. */ if (d__ > 1) { /* We'll find the number of subtrees of maximum size */ /* that we would need to hold the non-root keys of the */ /* tree. We'll then determine the actual required sizes */ /* of these subtrees. */ subd = d__ - 1; nnodes = 0; i__1 = subd; for (i__ = 1; i__ <= i__1; ++i__) { nnodes = nnodes * 63 + 1; } maxsiz = nnodes * 62; /* If we had NKIDS subtrees of size MAXSIZ, NKIDS */ /* would be the smallest integer such that */ /* ( NKIDS - 1 ) + NKIDS * MAXSIZ > SUBSIZ */ /* - */ /* or equivalently, */ /* NKIDS * ( MAXSIZ + 1 ) > SUBSIZ + 1 */ /* - */ /* We'll compute this value of NKIDS. */ q = subsiz + 1; div = maxsiz + 1; nkids = (q + div - 1) / div; /* The minimum number of keys we must store in child */ /* nodes is the number of keys in the tree, minus those */ /* that can be accommodated in the root: */ n = subsiz - (nkids - 1); /* Now we can figure out how large the subtrees would */ /* have to be in order to hold N keys, if all subtrees */ /* had the same size. */ bigsiz = (n + nkids - 1) / nkids; /* We may have more capacity than we need if all subtrees */ /* have size BIGSIZ. So, we'll allow some subtrees to */ /* have size BIGSIZ-1. Not all subtrees can have the */ /* smaller size (otherwise BIGSIZ would have been */ /* smaller). The first NBIG subtrees will have the */ /* larger size. */ nsmall = nkids * bigsiz - n; nbig = nkids - nsmall; nkeys = nkids - 1; } else { /* All keys are in the root. */ nkeys = *size; nkids = 0; } /* Read in the root page. */ zzekpgri_(handle, tree, page); /* We have enough information to fill in the root node. */ /* We'll allocate nodes for the immediate children. */ /* There is one key `between' each child pointer. */ i__1 = nkeys; for (i__ = 1; i__ <= i__1; ++i__) { /* The Ith key may be found by considering the number */ /* of keys in the subtree between the Ith key and its */ /* predecessor in the root. */ if (i__ == 1) { npred = 0; } else { npred = page[(i__2 = i__ + 3) < 256 && 0 <= i__2 ? i__2 : s_rnge("page", i__2, "zzektr1s_", ( ftnlen)480)]; } if (d__ > 1) { /* The tree contains subtrees. */ if (i__ <= nbig) { key = npred + bigsiz + 1; } else { key = npred + bigsiz; } } else { key = i__; } page[(i__2 = i__ + 4) < 256 && 0 <= i__2 ? i__2 : s_rnge( "page", i__2, "zzektr1s_", (ftnlen)499)] = key; page[(i__2 = i__ + 171) < 256 && 0 <= i__2 ? i__2 : s_rnge("page", i__2, "zzektr1s_", (ftnlen)500)] = values[key - 1]; } totnod = 1; i__1 = nkids; for (i__ = 1; i__ <= i__1; ++i__) { /* Allocate a node for the Ith child. Store pointers */ /* to these nodes. */ zzekpgal_(handle, &c__3, &child, &base); page[(i__2 = i__ + 87) < 256 && 0 <= i__2 ? i__2 : s_rnge( "page", i__2, "zzektr1s_", (ftnlen)513)] = child; ++totnod; } /* Fill in the root's metadata. There is one item that */ /* we'll have to fill in when we're done: the number of */ /* nodes in the tree. We know the rest of the information */ /* now. */ page[2] = *size; page[3] = d__; page[4] = nkeys; page[1] = 0; /* Write out the root. */ zzekpgwi_(handle, tree, page); } else if (level < d__) { /* The current node is a non-leaf child node. */ cleari_(&c__256, page); /* The tree headed by this node has depth D-LEVEL+1 and */ /* must hold SUBSIZ keys. We must figure out the size */ /* and number of subtrees of the current node. Unlike in */ /* the case of the root, we must have between MNKIDC */ /* and MXKIDC subtrees of this node. We start out by */ /* computing the required subtree size if there were */ /* exactly MNKIDC subtrees. In this case, the total */ /* number of keys in the subtrees would be */ /* SUBSIZ - MNKEYC */ n = subsiz - 41; reqsiz = (n + 40) / 41; /* Compute the maximum allowable number of keys in */ /* a subtree. */ subd = d__ - level; nnodes = 0; i__1 = subd; for (i__ = 1; i__ <= i__1; ++i__) { nnodes = nnodes * 63 + 1; } maxsiz = nnodes * 62; /* If the number REQSIZ we came up with is a valid size, */ /* we'll be able to get the correct number of children */ /* by using subtrees of size REQSIZ and REQSIZ-1. Note */ /* that it's impossible for REQSIZ to be too small, */ /* since the smallest possible number of subtrees is */ /* MNKIDC. */ if (reqsiz <= maxsiz) { /* Decide how many large and small subtrees we need. */ nkids = 42; bigsiz = reqsiz; nsmall = bigsiz * nkids - n; nbig = nkids - nsmall; } else { /* See how many subtrees of size MAXSIZ it would take */ /* to hold the requisite number of keys. We know the */ /* number is more than MNKIDC. If we have NKIDS */ /* subtrees of size MAXSIZ, the total number of */ /* keys in the subtree headed by NODE is */ /* ( NKIDS - 1 ) + ( NKIDS * MAXSIZ ) */ /* or */ /* NKIDS * ( MAXSIZ + 1 ) - 1 */ /* We must find the smallest value of NKIDS such */ /* that the above quantity is greater than or equal */ /* to SUBSIZ. */ q = subsiz + 1; div = maxsiz + 1; nkids = (q + div - 1) / div; /* We know that NKIDS subtrees of size MAXSIZ, plus */ /* NKIDS-1 keys in NODE, can hold at least SUBSIZ */ /* keys. We now want to find the smallest subtree */ /* size such that NKIDS subtrees of that size, */ /* together with the NKIDS-1 keys in NODE, contain */ /* at least SUBSIZ keys. The size we seek will */ /* become BIGSIZ, the larger of the two subtree */ /* sizes we'll use. So BIGSIZ is the smallest */ /* integer such that */ /* ( NKIDS - 1 ) + ( NKIDS * BIGSIZ ) > SUBSIZ */ /* - */ /* or equivalently */ /* BIGSIZ * NKIDS > SUBSIZ - NKIDS + 1 */ /* - */ q = subsiz - nkids + 1; div = nkids; bigsiz = (q + div - 1) / div; nsmall = bigsiz * nkids - q; nbig = nkids - nsmall; } /* Fill in the keys for the current node. */ nkeys = nkids - 1; i__1 = nkeys; for (i__ = 1; i__ <= i__1; ++i__) { /* The Ith key may be found by considering the number */ /* of keys in the subtree between the Ith key and its */ /* predecessor in the current node. */ if (i__ == 1) { npred = basidx; } else { npred = basidx + page[(i__2 = i__ - 1) < 256 && 0 <= i__2 ? i__2 : s_rnge("page", i__2, "zzektr1s_" , (ftnlen)652)]; } if (i__ <= nbig) { key = npred + bigsiz + 1; } else { key = npred + bigsiz; } page[(i__2 = i__) < 256 && 0 <= i__2 ? i__2 : s_rnge( "page", i__2, "zzektr1s_", (ftnlen)661)] = key - basidx; page[(i__2 = i__ + 127) < 256 && 0 <= i__2 ? i__2 : s_rnge("page", i__2, "zzektr1s_", (ftnlen)662)] = values[key - 1]; } i__1 = nkids; for (i__ = 1; i__ <= i__1; ++i__) { /* Allocate a node for the Ith child. Store pointers */ /* to these nodes. */ zzekpgal_(handle, &c__3, &child, &base); page[(i__2 = i__ + 63) < 256 && 0 <= i__2 ? i__2 : s_rnge( "page", i__2, "zzektr1s_", (ftnlen)674)] = child; ++totnod; } /* We can now fill in the metadata for the current node. */ page[0] = nkeys; zzekpgwi_(handle, &node, page); } /* Unless the current node is a leaf node, prepare to visit */ /* the first child of the current node. */ if (level < d__) { /* Push our current state. */ stnode[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stnode", i__1, "zzektr1s_", (ftnlen)696)] = node; stsbsz[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stsbsz", i__1, "zzektr1s_", (ftnlen)697)] = subsiz; stnkey[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stnkey", i__1, "zzektr1s_", (ftnlen)698)] = nkeys; stlsiz[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stlsiz", i__1, "zzektr1s_", (ftnlen)699)] = bigsiz; stnbig[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stnbig", i__1, "zzektr1s_", (ftnlen)700)] = nbig; stnext[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stnext", i__1, "zzektr1s_", (ftnlen)701)] = 2; stnbas[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stnbas", i__1, "zzektr1s_", (ftnlen)702)] = basidx; /* NEXT is already set to 1. BASIDX is set, since the */ /* base index of the first child is that of the parent. */ if (level == 1) { kidbas = 88; } else { kidbas = 64; } ++level; node = page[(i__1 = kidbas) < 256 && 0 <= i__1 ? i__1 : s_rnge("page", i__1, "zzektr1s_", (ftnlen)715)]; subsiz = bigsiz; } else if (level > 1) { /* The current node is a child leaf node. There are no */ /* calculations to do; we simply assign keys and pointers, */ /* write out metadata, and pop our state. */ nkeys = subsiz; i__1 = nkeys; for (i__ = 1; i__ <= i__1; ++i__) { key = basidx + i__; page[(i__2 = i__) < 256 && 0 <= i__2 ? i__2 : s_rnge( "page", i__2, "zzektr1s_", (ftnlen)730)] = i__; page[(i__2 = i__ + 127) < 256 && 0 <= i__2 ? i__2 : s_rnge("page", i__2, "zzektr1s_", (ftnlen)731)] = values[key - 1]; } /* We can now fill in the metadata for the current node. */ page[0] = nkeys; zzekpgwi_(handle, &node, page); /* A leaf node is a subtree unto itself, and we're */ /* done with this subtree. Pop our state. */ --level; if (level >= 1) { node = stnode[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnode", i__1, "zzektr1s_", (ftnlen)750) ]; nkeys = stnkey[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnkey", i__1, "zzektr1s_", ( ftnlen)751)]; bigsiz = stlsiz[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stlsiz", i__1, "zzektr1s_", ( ftnlen)752)]; nbig = stnbig[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnbig", i__1, "zzektr1s_", (ftnlen)753) ]; next = stnext[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnext", i__1, "zzektr1s_", (ftnlen)754) ]; basidx = stnbas[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnbas", i__1, "zzektr1s_", ( ftnlen)755)]; nkids = nkeys + 1; /* Read in the current node. */ zzekpgri_(handle, &node, page); } } else { /* The only node is the root. Pop out. */ level = 0; } /* We've decided which node to go to next at this point. */ /* At this point, LEVEL, NEXT, NODE, SUBSIZ and BASIDX are set. */ } else { /* The current node has been visited already. Visit the */ /* next child, if there is one. */ if (next <= nkids) { /* Prepare to visit the next child of the current node. */ stnext[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge( "stnext", i__1, "zzektr1s_", (ftnlen)787)] = next + 1; if (level == 1) { kidbas = 88; } else { kidbas = 64; } node = page[(i__1 = kidbas + next - 1) < 256 && 0 <= i__1 ? i__1 : s_rnge("page", i__1, "zzektr1s_", (ftnlen)797)] ; if (next <= nbig) { subsiz = stlsiz[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stlsiz", i__1, "zzektr1s_", ( ftnlen)801)]; } else { subsiz = stlsiz[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stlsiz", i__1, "zzektr1s_", ( ftnlen)803)] - 1; } if (next <= nbig + 1) { basidx = stnbas[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnbas", i__1, "zzektr1s_", ( ftnlen)809)] + (next - 1) * stlsiz[(i__2 = level - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge("stlsiz", i__2, "zzektr1s_", (ftnlen)809)] + (next - 1); } else { basidx = stnbas[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnbas", i__1, "zzektr1s_", ( ftnlen)815)] + nbig * stlsiz[(i__2 = level - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge("stlsiz", i__2, "zzektr1s_", (ftnlen)815)] + (next - nbig - 1) * ( stlsiz[(i__3 = level - 1) < 10 && 0 <= i__3 ? i__3 : s_rnge("stlsiz", i__3, "zzektr1s_", ( ftnlen)815)] - 1) + (next - 1); } ++level; next = 1; /* LEVEL, NEXT, NODE, SUBSIZ, and BASIDX are set. */ } else { /* We're done with the current subtree. Pop the stack. */ --level; if (level >= 1) { node = stnode[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnode", i__1, "zzektr1s_", (ftnlen)836) ]; nkeys = stnkey[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnkey", i__1, "zzektr1s_", ( ftnlen)837)]; bigsiz = stlsiz[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stlsiz", i__1, "zzektr1s_", ( ftnlen)838)]; nbig = stnbig[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnbig", i__1, "zzektr1s_", (ftnlen)839) ]; next = stnext[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnext", i__1, "zzektr1s_", (ftnlen)840) ]; basidx = stnbas[(i__1 = level - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("stnbas", i__1, "zzektr1s_", ( ftnlen)841)]; nkids = nkeys + 1; /* Read in the current node. */ zzekpgri_(handle, &node, page); } } } /* On this pass through the loop, we either--- */ /* - Visited a node for the first time and filled in the */ /* node. */ /* - Advanced to a new node that has not yet been visited. */ /* - Exited from a completed subtree. */ /* Each of these actions can be performed a finite number of */ /* times. Therefore, we made progress toward loop termination. */ } /* The last chore is setting the total number of nodes in the root. */ base = zzektrbs_(tree); i__1 = base + 2; i__2 = base + 2; dasudi_(handle, &i__1, &i__2, &totnod); chkout_("ZZEKTR1S", (ftnlen)8); return 0; } /* zzektr1s_ */
/* $Procedure ZZEKTR13 ( EK tree, 1-3 split ) */ /* Subroutine */ int zzektr13_(integer *handle, integer *tree) { /* System generated locals */ integer i__1, i__2; /* Builtin functions */ integer s_rnge(char *, integer, char *, integer); /* Local variables */ integer base, root; extern /* Subroutine */ int zzekpgal_(integer *, integer *, integer *, integer *), zzekpgri_(integer *, integer *, integer *), zzekpgwi_( integer *, integer *, integer *); integer i__, child[2], delta; extern /* Subroutine */ int chkin_(char *, ftnlen); integer rpage[256]; extern /* Subroutine */ int movei_(integer *, integer *, integer *); integer c1page[256], c2page[256], middle; extern /* Subroutine */ int cleari_(integer *, integer *), sigerr_(char *, ftnlen), chkout_(char *, ftnlen); integer nrkeys; extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen); /* $ Abstract */ /* Execute a 1-3 split: split the root node to create two new */ /* children, leaving a single key in the root. */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* $ Required_Reading */ /* EK */ /* $ Keywords */ /* EK */ /* PRIVATE */ /* $ Declarations */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Tree Parameters */ /* ektree.inc Version 3 22-OCT-1995 (NJB) */ /* The parameters in this file define the tree structure */ /* used by the EK system. This structure is a variant of the */ /* B*-tree structure described in Knuth's book, that is */ /* Knuth, Donald E. "The Art of Computer Programming, */ /* Volume 3/Sorting and Searching" 1973, pp 471-479. */ /* The trees used in the EK system differ from generic B*-trees */ /* primarily in the way keys are treated. Rather than storing */ /* unique primary key values in each node, EK trees store integer */ /* counts that represent the ordinal position of each data value, */ /* counting from the lowest indexed element in the subtree whose */ /* root is the node in question. Thus the keys are unique within */ /* a node but not across multiple nodes: in fact the Nth key in */ /* every leaf node is N. The absolute ordinal position of a data */ /* item is defined recursively as the sum of the key of the data item */ /* and the absolute ordinal position of the data item in the parent */ /* node that immediately precedes all elements of the node in */ /* question. This data structure allows EK trees to support lookup */ /* of data items based on their ordinal position in a data set. The */ /* two prime applications of this capability in the EK system are: */ /* 1) Using trees to index the records in a table, allowing */ /* the Nth record to be located efficiently. */ /* 2) Using trees to implement order vectors that can be */ /* maintained when insertions and deletions are done. */ /* Root node */ /* +--------------------------------------------+ */ /* | Tree version code | */ /* +--------------------------------------------+ */ /* | Number of nodes in tree | */ /* +--------------------------------------------+ */ /* | Number of keys in tree | */ /* +--------------------------------------------+ */ /* | Depth of tree | */ /* +--------------------------------------------+ */ /* | Number of keys in root | */ /* +--------------------------------------------+ */ /* | Space for n keys, | */ /* | | */ /* | n = 2 * INT( ( 2*m - 2 )/3 ) | */ /* | | */ /* | where m is the max number of children per | */ /* | node in the child nodes | */ /* +--------------------------------------------+ */ /* | Space for n+1 child pointers, | */ /* | where n is as defined above. | */ /* +--------------------------------------------+ */ /* | Space for n data pointers, | */ /* | where n is as defined above. | */ /* +--------------------------------------------+ */ /* Child node */ /* +--------------------------------------------+ */ /* | Number of keys present in node | */ /* +--------------------------------------------+ */ /* | Space for m-1 keys | */ /* +--------------------------------------------+ */ /* | Space for m child pointers | */ /* +--------------------------------------------+ */ /* | Space for m-1 data pointers | */ /* +--------------------------------------------+ */ /* The following parameters give the maximum number of children */ /* allowed in the root and child nodes. During insertions, the */ /* number of children may overflow by 1. */ /* Maximum number of children allowed in a child node: */ /* Maximum number of keys allowed in a child node: */ /* Minimum number of children allowed in a child node: */ /* Minimum number of keys allowed in a child node: */ /* Maximum number of children allowed in the root node: */ /* Maximum number of keys allowed in the root node: */ /* Minimum number of children allowed in the root node: */ /* The following parameters indicate positions of elements in the */ /* tree node structures shown above. */ /* The following parameters are for the root node only: */ /* Location of version code: */ /* Version code: */ /* Location of node count: */ /* Location of total key count for the tree: */ /* Location of tree depth: */ /* Location of count of keys in root node: */ /* Base address of keys in the root node: */ /* Base address of child pointers in root node: */ /* Base address of data pointers in the root node (allow room for */ /* overflow): */ /* Size of root node: */ /* The following parameters are for child nodes only: */ /* Location of number of keys in node: */ /* Base address of keys in child nodes: */ /* Base address of child pointers in child nodes: */ /* Base address of data pointers in child nodes (allow room */ /* for overflow): */ /* Size of child node: */ /* A number of EK tree routines must declare stacks of fixed */ /* depth; this depth limit imposes a limit on the maximum depth */ /* that an EK tree can have. Because of the large branching */ /* factor of EK trees, the depth limit is of no practical */ /* importance: The number of keys that can be held in an EK */ /* tree of depth N is */ /* N-1 */ /* MXKIDC - 1 */ /* MXKIDR * ------------- */ /* MXKIDC - 1 */ /* This formula yields a capacity of over 1 billion keys for a */ /* tree of depth 6. */ /* End Include Section: EK Tree Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Das Paging Parameters */ /* ekpage.inc Version 4 25-AUG-1995 (NJB) */ /* The EK DAS paging system makes use of the integer portion */ /* of an EK file's DAS address space to store the few numbers */ /* required to describe the system's state. The allocation */ /* of DAS integer addresses is shown below. */ /* DAS integer array */ /* +--------------------------------------------+ */ /* | EK architecture code | Address = 1 */ /* +--------------------------------------------+ */ /* | Character page size (in DAS words) | */ /* +--------------------------------------------+ */ /* | Character page base address | */ /* +--------------------------------------------+ */ /* | Number of character pages in file | */ /* +--------------------------------------------+ */ /* | Number of character pages on free list | */ /* +--------------------------------------------+ */ /* | Character free list head pointer | Address = 6 */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for d.p. pages | 7--11 */ /* | | */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for integer pages | 12--16 */ /* | | */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | End Address = */ /* | Unused space | integer page */ /* | | end */ /* +--------------------------------------------+ */ /* | | Start Address = */ /* | First integer page | integer page */ /* | | base */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | */ /* | Last integer page | */ /* | | */ /* +--------------------------------------------+ */ /* The following parameters indicate positions of elements in the */ /* paging system metadata array: */ /* Number of metadata items per data type: */ /* Character metadata indices: */ /* Double precision metadata indices: */ /* Integer metadata indices: */ /* Size of metadata area: */ /* Page sizes, in units of DAS words of the appropriate type: */ /* Default page base addresses: */ /* End Include Section: EK Das Paging Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Data Types */ /* ektype.inc Version 1 27-DEC-1994 (NJB) */ /* Within the EK system, data types of EK column contents are */ /* represented by integer codes. The codes and their meanings */ /* are listed below. */ /* Integer codes are also used within the DAS system to indicate */ /* data types; the EK system makes no assumptions about compatibility */ /* between the codes used here and those used in the DAS system. */ /* Character type: */ /* Double precision type: */ /* Integer type: */ /* `Time' type: */ /* Within the EK system, time values are represented as ephemeris */ /* seconds past J2000 (TDB), and double precision numbers are used */ /* to store these values. However, since time values require special */ /* treatment both on input and output, and since the `TIME' column */ /* has a special role in the EK specification and code, time values */ /* are identified as a type distinct from double precision numbers. */ /* End Include Section: EK Data Types */ /* $ Brief_I/O */ /* Variable I/O Description */ /* -------- --- -------------------------------------------------- */ /* HANDLE I File handle. */ /* TREE I Root of tree. */ /* $ Detailed_Input */ /* HANDLE is a file handle of an EK open for write access. */ /* TREE is the root node number of the tree of interest. */ /* $ Detailed_Output */ /* None. See $Particulars for a description of the effect of this */ /* routine. */ /* $ Parameters */ /* None. */ /* $ Exceptions */ /* 1) If HANDLE is invalid, the error will be diagnosed by routines */ /* called by this routine. The file will not be modified. */ /* 2) If an I/O error occurs while reading the indicated file, the */ /* error will be diagnosed by routines called by this routine. */ /* 3) If the number of keys in the root does not correspond to an */ /* overflow of exactly 1 key, the error SPICE(BUG) is signalled. */ /* $ Files */ /* See the EK Required Reading for a discussion of the EK file */ /* format. */ /* $ Particulars */ /* Insertions into an EK tree start at a leaf node. If the node */ /* overflows, the EK system attempts to shuffle keys at the leaf */ /* level to resolve the overflow. That attempt failing, the system */ /* delegates the problem upward to the next higher level. Overflow */ /* may occur there as well; if it does, the problem gets passed */ /* upward again. If the root overflows, the system makes room by */ /* executing what's called a `1-3' split: the root gets two new */ /* children, and all but one of the keys in the root are moved into */ /* the new children. The former children of the root become */ /* children of the two new children of the root. */ /* After the 1-3 split, the tree is balanced and all invariants */ /* relating to key counts are restored. */ /* The tree grows taller by one level as a result of a 1-3 split; */ /* this is the only circumstance under which the tree grows taller. */ /* Below are the gory details concerning the actions of this routine. */ /* All of the parameters referred to here (in capital letters) are */ /* defined in the include file ektree.inc. */ /* In a 1-3 split: */ /* - The leftmost MNKEYC keys of the root are moved into the */ /* new left child. */ /* - The data values associated with the first MNKEYC keys of the */ /* root are moved along with the keys. */ /* - The left child pointers associated with the first MNKEYC keys */ /* of the root are moved along with the keys. */ /* - The right child pointer of the key at location MNKEYC+1 in */ /* the root is moved to location MYKEYC+1 in the child pointer */ /* array of the left child. */ /* - The rightmost MNKEYC keys of the root are moved into the */ /* new right child. */ /* - The data values associated with the last MNKEYC keys of the */ /* root are moved along with the keys. */ /* - The left child pointers associated with the last MNKEYC keys */ /* of the root are moved along with the keys. */ /* - The right child pointer of the last in the root is moved to */ /* location MYKEYC+1 in the child pointer array of the right */ /* child. */ /* - The left child pointer of the one key left in the root */ /* points to the new left child. */ /* - The right child pointer of the one key left in the root */ /* points to the new right child. */ /* As the above list shows, each of the new children of the root */ /* contains the minimum allowed number of keys that a child node */ /* may have. Thus the size constraints on child nodes are met. */ /* The root must be non-empty unless the tree is empty; this */ /* condition is also met. */ /* $ Examples */ /* See ZZEKTRIN. */ /* $ Restrictions */ /* None. */ /* $ Literature_References */ /* None. */ /* $ Author_and_Institution */ /* N.J. Bachman (JPL) */ /* $ Version */ /* - Beta Version 1.0.0, 26-OCT-1995 (NJB) */ /* -& */ /* Local variables */ /* Use discovery check-in for speed. */ root = *tree; zzekpgri_(handle, &root, rpage); nrkeys = rpage[4]; /* The number of keys in the root must correspond exactly to an */ /* overflow level of 1 key. */ if (nrkeys != 83) { chkin_("ZZEKTR13", (ftnlen)8); setmsg_("Number of keys in root = #; should be #.", (ftnlen)40); errint_("#", &nrkeys, (ftnlen)1); errint_("#", &c__83, (ftnlen)1); sigerr_("SPICE(BUG)", (ftnlen)10); chkout_("ZZEKTR13", (ftnlen)8); return 0; } /* Allocate two new pages; these will become children of the root. */ /* Each one will be assigned MNKEYC keys. */ for (i__ = 1; i__ <= 2; ++i__) { zzekpgal_(handle, &c__3, &child[(i__1 = i__ - 1) < 2 && 0 <= i__1 ? i__1 : s_rnge("child", i__1, "zzektr13_", (ftnlen)221)], & base); } /* Set the key count in the first child. */ cleari_(&c__256, c1page); c1page[0] = 41; /* Copy in the keys, data pointers, and child pointers from the */ /* first MNKEYC locations in the root. Also take the left child */ /* pointer of the middle key. */ movei_(&rpage[5], &c__41, &c1page[1]); movei_(&rpage[172], &c__41, &c1page[128]); movei_(&rpage[88], &c__42, &c1page[64]); /* Set up the key count in the second child. */ cleari_(&c__256, c2page); c2page[0] = 41; /* Copy in the keys, data pointers, and child pointers from the */ /* last MNKEYC locations in the root. Also take the last right */ /* child pointer. */ middle = 42; movei_(&rpage[(i__1 = middle + 5) < 256 && 0 <= i__1 ? i__1 : s_rnge( "rpage", i__1, "zzektr13_", (ftnlen)254)], &c__41, &c2page[1]); movei_(&rpage[(i__1 = middle + 172) < 256 && 0 <= i__1 ? i__1 : s_rnge( "rpage", i__1, "zzektr13_", (ftnlen)255)], &c__41, &c2page[128]); movei_(&rpage[(i__1 = middle + 88) < 256 && 0 <= i__1 ? i__1 : s_rnge( "rpage", i__1, "zzektr13_", (ftnlen)256)], &c__42, &c2page[64]); /* The keys in this second node must be adjusted to account for the */ /* loss of the predecessors assigned to the subtree headed by the */ /* left child, as well as of the middle key. */ delta = rpage[(i__1 = middle + 4) < 256 && 0 <= i__1 ? i__1 : s_rnge( "rpage", i__1, "zzektr13_", (ftnlen)263)]; for (i__ = 1; i__ <= 41; ++i__) { c2page[(i__1 = i__) < 256 && 0 <= i__1 ? i__1 : s_rnge("c2page", i__1, "zzektr13_", (ftnlen)266)] = c2page[(i__2 = i__) < 256 && 0 <= i__2 ? i__2 : s_rnge("c2page", i__2, "zzektr13_", (ftnlen) 266)] - delta; } /* Now the root must be updated. The root now contains just 1 */ /* key; that key should be shifted left to the first key location. */ /* There are two child pointers; these point to the children just */ /* created. The depth of the tree has increased, as well as the */ /* number of nodes in the tree. */ rpage[5] = rpage[(i__1 = middle + 4) < 256 && 0 <= i__1 ? i__1 : s_rnge( "rpage", i__1, "zzektr13_", (ftnlen)276)]; rpage[172] = rpage[(i__1 = middle + 171) < 256 && 0 <= i__1 ? i__1 : s_rnge("rpage", i__1, "zzektr13_", (ftnlen)277)]; rpage[88] = child[0]; rpage[89] = child[1]; rpage[4] = 1; ++rpage[3]; rpage[1] += 2; cleari_(&c__82, &rpage[6]); cleari_(&c__82, &rpage[173]); cleari_(&c__82, &rpage[90]); /* Write out our updates. */ zzekpgwi_(handle, &root, rpage); zzekpgwi_(handle, child, c1page); zzekpgwi_(handle, &child[1], c2page); return 0; } /* zzektr13_ */
/* $Procedure ZZEKTRIT ( EK tree, initialize ) */ /* Subroutine */ int zzektrit_(integer *handle, integer *tree) { integer base, page[256]; extern /* Subroutine */ int zzekpgal_(integer *, integer *, integer *, integer *), zzekpgwi_(integer *, integer *, integer *); integer p; extern /* Subroutine */ int chkin_(char *, ftnlen), cleari_(integer *, integer *), chkout_(char *, ftnlen); extern logical return_(void); /* $ Abstract */ /* Initialize an EK tree, returning the root of the tree. */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* $ Required_Reading */ /* EK */ /* $ Keywords */ /* EK */ /* PRIVATE */ /* $ Declarations */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Das Paging Parameters */ /* ekpage.inc Version 4 25-AUG-1995 (NJB) */ /* The EK DAS paging system makes use of the integer portion */ /* of an EK file's DAS address space to store the few numbers */ /* required to describe the system's state. The allocation */ /* of DAS integer addresses is shown below. */ /* DAS integer array */ /* +--------------------------------------------+ */ /* | EK architecture code | Address = 1 */ /* +--------------------------------------------+ */ /* | Character page size (in DAS words) | */ /* +--------------------------------------------+ */ /* | Character page base address | */ /* +--------------------------------------------+ */ /* | Number of character pages in file | */ /* +--------------------------------------------+ */ /* | Number of character pages on free list | */ /* +--------------------------------------------+ */ /* | Character free list head pointer | Address = 6 */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for d.p. pages | 7--11 */ /* | | */ /* +--------------------------------------------+ */ /* | | Addresses = */ /* | Metadata for integer pages | 12--16 */ /* | | */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | End Address = */ /* | Unused space | integer page */ /* | | end */ /* +--------------------------------------------+ */ /* | | Start Address = */ /* | First integer page | integer page */ /* | | base */ /* +--------------------------------------------+ */ /* . */ /* . */ /* . */ /* +--------------------------------------------+ */ /* | | */ /* | Last integer page | */ /* | | */ /* +--------------------------------------------+ */ /* The following parameters indicate positions of elements in the */ /* paging system metadata array: */ /* Number of metadata items per data type: */ /* Character metadata indices: */ /* Double precision metadata indices: */ /* Integer metadata indices: */ /* Size of metadata area: */ /* Page sizes, in units of DAS words of the appropriate type: */ /* Default page base addresses: */ /* End Include Section: EK Das Paging Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Tree Parameters */ /* ektree.inc Version 3 22-OCT-1995 (NJB) */ /* The parameters in this file define the tree structure */ /* used by the EK system. This structure is a variant of the */ /* B*-tree structure described in Knuth's book, that is */ /* Knuth, Donald E. "The Art of Computer Programming, */ /* Volume 3/Sorting and Searching" 1973, pp 471-479. */ /* The trees used in the EK system differ from generic B*-trees */ /* primarily in the way keys are treated. Rather than storing */ /* unique primary key values in each node, EK trees store integer */ /* counts that represent the ordinal position of each data value, */ /* counting from the lowest indexed element in the subtree whose */ /* root is the node in question. Thus the keys are unique within */ /* a node but not across multiple nodes: in fact the Nth key in */ /* every leaf node is N. The absolute ordinal position of a data */ /* item is defined recursively as the sum of the key of the data item */ /* and the absolute ordinal position of the data item in the parent */ /* node that immediately precedes all elements of the node in */ /* question. This data structure allows EK trees to support lookup */ /* of data items based on their ordinal position in a data set. The */ /* two prime applications of this capability in the EK system are: */ /* 1) Using trees to index the records in a table, allowing */ /* the Nth record to be located efficiently. */ /* 2) Using trees to implement order vectors that can be */ /* maintained when insertions and deletions are done. */ /* Root node */ /* +--------------------------------------------+ */ /* | Tree version code | */ /* +--------------------------------------------+ */ /* | Number of nodes in tree | */ /* +--------------------------------------------+ */ /* | Number of keys in tree | */ /* +--------------------------------------------+ */ /* | Depth of tree | */ /* +--------------------------------------------+ */ /* | Number of keys in root | */ /* +--------------------------------------------+ */ /* | Space for n keys, | */ /* | | */ /* | n = 2 * INT( ( 2*m - 2 )/3 ) | */ /* | | */ /* | where m is the max number of children per | */ /* | node in the child nodes | */ /* +--------------------------------------------+ */ /* | Space for n+1 child pointers, | */ /* | where n is as defined above. | */ /* +--------------------------------------------+ */ /* | Space for n data pointers, | */ /* | where n is as defined above. | */ /* +--------------------------------------------+ */ /* Child node */ /* +--------------------------------------------+ */ /* | Number of keys present in node | */ /* +--------------------------------------------+ */ /* | Space for m-1 keys | */ /* +--------------------------------------------+ */ /* | Space for m child pointers | */ /* +--------------------------------------------+ */ /* | Space for m-1 data pointers | */ /* +--------------------------------------------+ */ /* The following parameters give the maximum number of children */ /* allowed in the root and child nodes. During insertions, the */ /* number of children may overflow by 1. */ /* Maximum number of children allowed in a child node: */ /* Maximum number of keys allowed in a child node: */ /* Minimum number of children allowed in a child node: */ /* Minimum number of keys allowed in a child node: */ /* Maximum number of children allowed in the root node: */ /* Maximum number of keys allowed in the root node: */ /* Minimum number of children allowed in the root node: */ /* The following parameters indicate positions of elements in the */ /* tree node structures shown above. */ /* The following parameters are for the root node only: */ /* Location of version code: */ /* Version code: */ /* Location of node count: */ /* Location of total key count for the tree: */ /* Location of tree depth: */ /* Location of count of keys in root node: */ /* Base address of keys in the root node: */ /* Base address of child pointers in root node: */ /* Base address of data pointers in the root node (allow room for */ /* overflow): */ /* Size of root node: */ /* The following parameters are for child nodes only: */ /* Location of number of keys in node: */ /* Base address of keys in child nodes: */ /* Base address of child pointers in child nodes: */ /* Base address of data pointers in child nodes (allow room */ /* for overflow): */ /* Size of child node: */ /* A number of EK tree routines must declare stacks of fixed */ /* depth; this depth limit imposes a limit on the maximum depth */ /* that an EK tree can have. Because of the large branching */ /* factor of EK trees, the depth limit is of no practical */ /* importance: The number of keys that can be held in an EK */ /* tree of depth N is */ /* N-1 */ /* MXKIDC - 1 */ /* MXKIDR * ------------- */ /* MXKIDC - 1 */ /* This formula yields a capacity of over 1 billion keys for a */ /* tree of depth 6. */ /* End Include Section: EK Tree Parameters */ /* $ Disclaimer */ /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */ /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */ /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */ /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */ /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */ /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */ /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */ /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */ /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */ /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */ /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */ /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */ /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */ /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */ /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */ /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */ /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */ /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */ /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */ /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */ /* Include Section: EK Data Types */ /* ektype.inc Version 1 27-DEC-1994 (NJB) */ /* Within the EK system, data types of EK column contents are */ /* represented by integer codes. The codes and their meanings */ /* are listed below. */ /* Integer codes are also used within the DAS system to indicate */ /* data types; the EK system makes no assumptions about compatibility */ /* between the codes used here and those used in the DAS system. */ /* Character type: */ /* Double precision type: */ /* Integer type: */ /* `Time' type: */ /* Within the EK system, time values are represented as ephemeris */ /* seconds past J2000 (TDB), and double precision numbers are used */ /* to store these values. However, since time values require special */ /* treatment both on input and output, and since the `TIME' column */ /* has a special role in the EK specification and code, time values */ /* are identified as a type distinct from double precision numbers. */ /* End Include Section: EK Data Types */ /* $ Brief_I/O */ /* Variable I/O Description */ /* -------- --- -------------------------------------------------- */ /* HANDLE I File handle. */ /* TREE O Root of tree. */ /* $ Detailed_Input */ /* HANDLE is a file handle of an EK open for write access. */ /* $ Detailed_Output */ /* TREE is the root node number of the tree created by */ /* this routine. The root node number is used by the */ /* EK tree routines to identify the tree. */ /* $ Parameters */ /* None. */ /* $ Exceptions */ /* 1) If HANDLE is invalid, the error will be diagnosed by routines */ /* called by this routine. The file will not be modified. */ /* 2) If an I/O error occurs while reading or writing the indicated */ /* file, the error will be diagnosed by routines called by this */ /* routine. */ /* $ Files */ /* See the EK Required Reading for a discussion of the EK file */ /* format. */ /* $ Particulars */ /* This routine is used to create a new, empty EK tree. The */ /* tree has a root node, but no keys are contained in the root. */ /* The metadata area of the tree is initialized. */ /* $ Examples */ /* See EKBSEG. */ /* $ Restrictions */ /* None. */ /* $ Literature_References */ /* 1) Knuth, Donald E. "The Art of Computer Programming, Volume */ /* 3/Sorting and Searching" 1973, pp 471-479. */ /* EK trees are closely related to the B* trees described by */ /* Knuth. */ /* $ Author_and_Institution */ /* N.J. Bachman (JPL) */ /* $ Version */ /* - Beta Version 1.0.0, 20-OCT-1995 (NJB) */ /* -& */ /* SPICELIB functions */ /* Local variables */ /* Standard SPICE error handling. */ if (return_()) { return 0; } else { chkin_("ZZEKTRIT", (ftnlen)8); } /* Start out by allocating a DAS integer page. We'll write the root */ /* node out to this page. */ zzekpgal_(handle, &c__3, &p, &base); page[0] = 1; page[1] = 1; page[2] = 0; page[4] = 0; page[3] = 1; /* Set all keys to zero; set all child and data pointers to null. */ cleari_(&c__82, &page[5]); cleari_(&c__82, &page[172]); cleari_(&c__83, &page[88]); /* Write out the page. */ zzekpgwi_(handle, &p, page); /* The identifier we return is just the page number of the tree's */ /* root. */ *tree = p; chkout_("ZZEKTRIT", (ftnlen)8); return 0; } /* zzektrit_ */