1 /* zzekstyp.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure      ZZEKSTYP ( EK, determine segment type ) */
zzekstyp_(integer * ncols,integer * cdscrs)9 integer zzekstyp_(integer *ncols, integer *cdscrs)
10 {
11     /* System generated locals */
12     integer ret_val, i__1;
13 
14     /* Local variables */
15     integer i__;
16     extern /* Subroutine */ int chkin_(char *, ftnlen);
17     logical fixed;
18     extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
19 	    ftnlen), setmsg_(char *, ftnlen);
20     extern logical return_(void);
21     logical var;
22 
23 /* $ Abstract */
24 
25 /*     Determine the type of segment required to support a specified */
26 /*     set of columns. */
27 
28 /* $ Disclaimer */
29 
30 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
31 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
32 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
33 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
34 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
35 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
36 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
37 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
38 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
39 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
40 
41 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
42 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
43 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
44 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
45 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
46 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
47 
48 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
49 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
50 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
51 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
52 
53 /* $ Required_Reading */
54 
55 /*     EK */
56 
57 /* $ Keywords */
58 
59 /*     EK */
60 
61 /* $ Declarations */
62 /* $ Disclaimer */
63 
64 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
65 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
66 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
67 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
68 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
69 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
70 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
71 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
72 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
73 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
74 
75 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
76 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
77 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
78 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
79 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
80 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
81 
82 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
83 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
84 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
85 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
86 
87 
88 /*     Include Section:  EK Column Descriptor Parameters */
89 
90 /*        ekcoldsc.inc Version 6    23-AUG-1995 (NJB) */
91 
92 
93 /*     Note:  The column descriptor size parameter CDSCSZ  is */
94 /*     declared separately in the include section CDSIZE$INC.FOR. */
95 
96 /*     Offset of column descriptors, relative to start of segment */
97 /*     integer address range.  This number, when added to the last */
98 /*     integer address preceding the segment, yields the DAS integer */
99 /*     base address of the first column descriptor.  Currently, this */
100 /*     offset is exactly the size of a segment descriptor.  The */
101 /*     parameter SDSCSZ, which defines the size of a segment descriptor, */
102 /*     is declared in the include file eksegdsc.inc. */
103 
104 
105 /*     Size of column descriptor */
106 
107 
108 /*     Indices of various pieces of column descriptors: */
109 
110 
111 /*     CLSIDX is the index of the column's class code.  (We use the */
112 /*     word `class' to distinguish this item from the column's data */
113 /*     type.) */
114 
115 
116 /*     TYPIDX is the index of the column's data type code (CHR, INT, DP, */
117 /*     or TIME).  The type is actually implied by the class, but it */
118 /*     will frequently be convenient to look up the type directly. */
119 
120 
121 
122 /*     LENIDX is the index of the column's string length value, if the */
123 /*     column has character type.  A value of IFALSE in this element of */
124 /*     the descriptor indicates that the strings have variable length. */
125 
126 
127 /*     SIZIDX is the index of the column's element size value.  This */
128 /*     descriptor element is meaningful for columns with fixed-size */
129 /*     entries.  For variable-sized columns, this value is IFALSE. */
130 
131 
132 /*     NAMIDX is the index of the base address of the column's name. */
133 
134 
135 /*     IXTIDX is the data type of the column's index.  IXTIDX */
136 /*     contains a type value only if the column is indexed. For columns */
137 /*     that are not indexed, the location IXTIDX contains the boolean */
138 /*     value IFALSE. */
139 
140 
141 /*     IXPIDX is a pointer to the column's index.  IXTPDX contains a */
142 /*     meaningful value only if the column is indexed.  The */
143 /*     interpretation of the pointer depends on the data type of the */
144 /*     index. */
145 
146 
147 /*     NFLIDX is the index of a flag indicating whether nulls are */
148 /*     permitted in the column.  The value at location NFLIDX is */
149 /*     ITRUE if nulls are permitted and IFALSE otherwise. */
150 
151 
152 /*     ORDIDX is the index of the column's ordinal position in the */
153 /*     list of columns belonging to the column's parent segment. */
154 
155 
156 /*     METIDX is the index of the column's integer metadata pointer. */
157 /*     This pointer is a DAS integer address. */
158 
159 
160 /*     The last position in the column descriptor is reserved.  No */
161 /*     parameter is defined to point to this location. */
162 
163 
164 /*     End Include Section:  EK Column Descriptor Parameters */
165 
166 /* $ Disclaimer */
167 
168 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
169 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
170 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
171 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
172 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
173 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
174 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
175 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
176 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
177 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
178 
179 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
180 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
181 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
182 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
183 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
184 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
185 
186 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
187 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
188 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
189 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
190 
191 
192 /*     Include Section:  EK General Limit Parameters */
193 
194 /*        ekglimit.inc  Version 1    21-MAY-1995 (NJB) */
195 
196 
197 /*     This file contains general limits for the EK system. */
198 
199 /*     MXCLSG is the maximum number of columns allowed in a segment. */
200 /*     This limit applies to logical tables as well, since all segments */
201 /*     in a logical table must have the same column definitions. */
202 
203 
204 /*     End Include Section:  EK General Limit Parameters */
205 
206 /* $ Brief_I/O */
207 
208 /*     Variable  I/O  Description */
209 /*     --------  ---  -------------------------------------------------- */
210 /*     NCOLS      I   Number of columns in the segment. */
211 /*     CDSCRS     I   Descriptors of columns. */
212 
213 /*     The function returns the type of segment that is compatible with */
214 /*     the input column descriptors. */
215 
216 /* $ Detailed_Input */
217 
218 
219 /*     NCOLS          is the number of columns in a new segment. */
220 
221 /*     CDSCRS         is an array of column descriptors:  the Ith */
222 /*                    descriptor applies to the Ith column in the */
223 /*                    segment. */
224 
225 /* $ Detailed_Output */
226 
227 /*     The function returns the type of segment that is compatible with */
228 /*     the input column descriptors. */
229 
230 /* $ Parameters */
231 
232 /*     None. */
233 
234 /* $ Exceptions */
235 
236 /*     1)  If NCOLS is non-positive or greater than the maximum allowed */
237 /*         number MXCLSG, the error SPICE(INVALIDCOUNT) is signalled. */
238 
239 /*     2)  If the input column descriptors do not contain compatible */
240 /*         attributes, the error SPICE(BADATTRIBUTES) will be signalled. */
241 
242 /* $ Files */
243 
244 /*     See the EK Required Reading for a discussion of the EK file */
245 /*     format. */
246 
247 /* $ Particulars */
248 
249 /*     This routine determines the appropriate segment type to contain */
250 /*     a specified set of columns.  Currently, there are two segment */
251 /*     types.  The first type accommodates column classes 1 through 6; */
252 /*     the second type accommodates column classes 7 through 9.  The */
253 /*     latter set of column classes are `fixed_count' classes:  a column */
254 /*     in one of these classes may not have entries added or deleted */
255 /*     after the column is created.  Fixed and variable count columns */
256 /*     may not coexist in the same segment. */
257 
258 /* $ Examples */
259 
260 /*     See EKBSEG. */
261 
262 /* $ Restrictions */
263 
264 /*     None. */
265 
266 /* $ Literature_References */
267 
268 /*     None. */
269 
270 /* $ Author_and_Institution */
271 
272 /*     N.J. Bachman   (JPL) */
273 
274 /* $ Version */
275 
276 /* -    Beta Version 1.0.0, 06-NOV-1995 (NJB) */
277 
278 /* -& */
279 
280 /*     SPICELIB functions */
281 
282 
283 /*     Local variables */
284 
285 
286 /*     Standard SPICE error handling. */
287 
288     if (return_()) {
289 	ret_val = 0;
290 	return ret_val;
291     } else {
292 	chkin_("ZZEKSTYP", (ftnlen)8);
293     }
294 
295 /*     FIXED and VAR indicate whether we've seen any fixed or variable */
296 /*     column classes so far. */
297 
298     fixed = FALSE_;
299     var = FALSE_;
300     i__1 = *ncols;
301     for (i__ = 1; i__ <= i__1; ++i__) {
302 	if (cdscrs[i__ * 11 - 11] >= 1 && cdscrs[i__ * 11 - 11] <= 6) {
303 	    var = TRUE_;
304 	} else if (cdscrs[i__ * 11 - 11] >= 7 && cdscrs[i__ * 11 - 11] <= 9) {
305 	    fixed = TRUE_;
306 	}
307     }
308     if (var && ! fixed) {
309 	ret_val = 1;
310     } else if (fixed && ! var) {
311 	ret_val = 2;
312     } else {
313 	ret_val = 0;
314 	setmsg_("Column set contains a mixture of variable and fixed-count c"
315 		"olumns.  Segments must contain all variable or all fixed cou"
316 		"nt columns.", (ftnlen)130);
317 	sigerr_("SPICE(BADATTRIBUTES)", (ftnlen)20);
318 	chkout_("ZZEKSTYP", (ftnlen)8);
319 	return ret_val;
320     }
321     chkout_("ZZEKSTYP", (ftnlen)8);
322     return ret_val;
323 } /* zzekstyp_ */
324 
325