1 /* cknr04.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* Table of constant values */
9 
10 static integer c__2 = 2;
11 static integer c__6 = 6;
12 static integer c__12 = 12;
13 
14 /* $Procedure      CKNR04 ( C-kernel, number of records, data type 4 ) */
cknr04_(integer * handle,doublereal * descr,integer * nrec)15 /* Subroutine */ int cknr04_(integer *handle, doublereal *descr, integer *
16 	nrec)
17 {
18     extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
19 	    integer *, integer *, doublereal *, integer *), sgmeta_(integer *,
20 	     doublereal *, integer *, integer *), sigerr_(char *, ftnlen),
21 	    chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
22 	    integer *, ftnlen);
23     extern logical return_(void);
24     doublereal dcd[2];
25     integer icd[6];
26 
27 /* $ Abstract */
28 
29 /*     Given the handle of a CK file and the descriptor of a type 4 */
30 /*     segment in that file, return the number of pointing instances */
31 /*     in that segment. */
32 
33 /* $ Disclaimer */
34 
35 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
36 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
37 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
38 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
39 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
40 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
41 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
42 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
43 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
44 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
45 
46 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
47 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
48 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
49 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
50 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
51 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
52 
53 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
54 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
55 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
56 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
57 
58 /* $ Required_Reading */
59 
60 /*     CK */
61 /*     DAF */
62 
63 /* $ Keywords */
64 
65 /*     POINTING */
66 
67 /* $ Declarations */
68 /* $ Abstract */
69 
70 /*     Declarations of the CK data type specific and general CK low */
71 /*     level routine parameters. */
72 
73 /* $ Disclaimer */
74 
75 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
76 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
77 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
78 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
79 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
80 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
81 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
82 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
83 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
84 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
85 
86 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
87 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
88 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
89 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
90 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
91 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
92 
93 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
94 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
95 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
96 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
97 
98 /* $ Required_Reading */
99 
100 /*     CK.REQ */
101 
102 /* $ Keywords */
103 
104 /*     CK */
105 
106 /* $ Restrictions */
107 
108 /*     1) If new CK types are added, the size of the record passed */
109 /*        between CKRxx and CKExx must be registered as separate */
110 /*        parameter. If this size will be greater than current value */
111 /*        of the CKMRSZ parameter (which specifies the maximum record */
112 /*        size for the record buffer used inside CKPFS) then it should */
113 /*        be assigned to CKMRSZ as a new value. */
114 
115 /* $ Author_and_Institution */
116 
117 /*     N.J. Bachman      (JPL) */
118 /*     B.V. Semenov      (JPL) */
119 
120 /* $ Literature_References */
121 
122 /*     CK Required Reading. */
123 
124 /* $ Version */
125 
126 /* -    SPICELIB Version 3.0.0, 27-JAN-2014 (NJB) */
127 
128 /*        Updated to support CK type 6. Maximum degree for */
129 /*        type 5 was updated to be consistent with the */
130 /*        maximum degree for type 6. */
131 
132 /* -    SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
133 
134 /*        Updated to support CK type 5. */
135 
136 /* -    SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
137 
138 /* -& */
139 
140 /*     Number of quaternion components and number of quaternion and */
141 /*     angular rate components together. */
142 
143 
144 /*     CK Type 1 parameters: */
145 
146 /*     CK1DTP   CK data type 1 ID; */
147 
148 /*     CK1RSZ   maximum size of a record passed between CKR01 */
149 /*              and CKE01. */
150 
151 
152 /*     CK Type 2 parameters: */
153 
154 /*     CK2DTP   CK data type 2 ID; */
155 
156 /*     CK2RSZ   maximum size of a record passed between CKR02 */
157 /*              and CKE02. */
158 
159 
160 /*     CK Type 3 parameters: */
161 
162 /*     CK3DTP   CK data type 3 ID; */
163 
164 /*     CK3RSZ   maximum size of a record passed between CKR03 */
165 /*              and CKE03. */
166 
167 
168 /*     CK Type 4 parameters: */
169 
170 /*     CK4DTP   CK data type 4 ID; */
171 
172 /*     CK4PCD   parameter defining integer to DP packing schema that */
173 /*              is applied when seven number integer array containing */
174 /*              polynomial degrees for quaternion and angular rate */
175 /*              components packed into a single DP number stored in */
176 /*              actual CK records in a file; the value of must not be */
177 /*              changed or compatibility with existing type 4 CK files */
178 /*              will be lost. */
179 
180 /*     CK4MXD   maximum Chebychev polynomial degree allowed in type 4 */
181 /*              records; the value of this parameter must never exceed */
182 /*              value of the CK4PCD; */
183 
184 /*     CK4SFT   number of additional DPs, which are not polynomial */
185 /*              coefficients, located at the beginning of a type 4 */
186 /*              CK record that passed between routines CKR04 and CKE04; */
187 
188 /*     CK4RSZ   maximum size of type 4 CK record passed between CKR04 */
189 /*              and CKE04; CK4RSZ is computed as follows: */
190 
191 /*                 CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
192 
193 
194 /*     CK Type 5 parameters: */
195 
196 
197 /*     CK5DTP   CK data type 5 ID; */
198 
199 /*     CK5MXD   maximum polynomial degree allowed in type 5 */
200 /*              records. */
201 
202 /*     CK5MET   number of additional DPs, which are not polynomial */
203 /*              coefficients, located at the beginning of a type 5 */
204 /*              CK record that passed between routines CKR05 and CKE05; */
205 
206 /*     CK5MXP   maximum packet size for any subtype.  Subtype 2 */
207 /*              has the greatest packet size, since these packets */
208 /*              contain a quaternion, its derivative, an angular */
209 /*              velocity vector, and its derivative.  See ck05.inc */
210 /*              for a description of the subtypes. */
211 
212 /*     CK5RSZ   maximum size of type 5 CK record passed between CKR05 */
213 /*              and CKE05; CK5RSZ is computed as follows: */
214 
215 /*                 CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
216 
217 
218 /*     CK Type 6 parameters: */
219 
220 
221 /*     CK6DTP   CK data type 6 ID; */
222 
223 /*     CK6MXD   maximum polynomial degree allowed in type 6 */
224 /*              records. */
225 
226 /*     CK6MET   number of additional DPs, which are not polynomial */
227 /*              coefficients, located at the beginning of a type 6 */
228 /*              CK record that passed between routines CKR06 and CKE06; */
229 
230 /*     CK6MXP   maximum packet size for any subtype.  Subtype 2 */
231 /*              has the greatest packet size, since these packets */
232 /*              contain a quaternion, its derivative, an angular */
233 /*              velocity vector, and its derivative.  See ck06.inc */
234 /*              for a description of the subtypes. */
235 
236 /*     CK6RSZ   maximum size of type 6 CK record passed between CKR06 */
237 /*              and CKE06; CK6RSZ is computed as follows: */
238 
239 /*                 CK6RSZ = CK6MET + ( CK6MXD + 1 ) * ( CK6PS3 + 1 ) */
240 
241 /*              where CK6PS3 is equal to the parameter CK06PS3 defined */
242 /*              in ck06.inc. Note that the subtype having the largest */
243 /*              packet size (subtype 2) does not give rise to the */
244 /*              largest record size, because that type is Hermite and */
245 /*              requires half the window size used by subtype 3 for a */
246 /*              given polynomial degree. */
247 
248 
249 /*     The parameter CK6PS3 must be in sync with C06PS3 defined in */
250 /*     ck06.inc. */
251 
252 
253 
254 /*     Maximum record size that can be handled by CKPFS. This value */
255 /*     must be set to the maximum of all CKxRSZ parameters (currently */
256 /*     CK5RSZ.) */
257 
258 /* $ Brief_I/O */
259 
260 /*     Variable  I/O  Description */
261 /*     --------  ---  -------------------------------------------------- */
262 /*     HANDLE     I   The handle of the file containing the segment. */
263 /*     DESCR      I   The descriptor of the type 4 segment. */
264 /*     NREC       O   The number of pointing records in the segment. */
265 
266 /* $ Detailed_Input */
267 
268 /*     HANDLE     is the handle of the binary CK file containing the */
269 /*                segment. The file should have been opened for read */
270 /*                or write access, either by CKLPF, DAFOPR, or DAFOPW. */
271 
272 /*     DESCR      The packed descriptor of a data type 4 segment. */
273 
274 /* $ Detailed_Output */
275 
276 /*     NREC       The number of pointing records in the type 4 */
277 /*                segment. */
278 
279 /* $ Parameters */
280 
281 /*     See 'ckparam.inc'. */
282 
283 /* $ Exceptions */
284 
285 /*     1)  If the segment indicated by DESCR is not a type 4 segment, */
286 /*         the error 'SPICE(CKWRONGDATATYPE)' is signalled. */
287 
288 /*     2)  If the specified handle does not belong to any DAF file that */
289 /*         is currently known to be open, an error is diagnosed by a */
290 /*         routine that this routine calls. */
291 
292 /*     3)  If DESCR is not a valid descriptor of a segment in the CK */
293 /*         file specified by HANDLE, the results of this routine are */
294 /*         unpredictable. */
295 
296 /* $ Files */
297 
298 /*     The file specified by HANDLE should be open for read or */
299 /*     write access. */
300 
301 /* $ Particulars */
302 
303 /*     For a complete description of the internal structure of a type 4 */
304 /*     segment, see the CK required reading. */
305 
306 /*     This routine returns the number of pointing records contained */
307 /*     in the specified segment. It is normally used in conjunction */
308 /*     with CKGR04 which returns the Ith pointing record in the */
309 /*     segment. */
310 
311 /* $ Examples */
312 
313 /*     Suppose that DATA.BC is a CK file that contains segments of */
314 /*     data type 4. Then the following code fragment extracts the */
315 /*     data packets contained in the segment. */
316 
317 /*     C */
318 /*     C     CK parameters include file. */
319 /*     C */
320 /*           INCLUDE               'ckparam.inc' */
321 /*     C */
322 /*     C     Declarations. */
323 /*     C */
324 /*           DOUBLE PRECISION      DCD    ( 2 ) */
325 /*           DOUBLE PRECISION      DESCR  ( 5 ) */
326 /*           DOUBLE PRECISION      PKTDAT ( CK4RSZ ) */
327 
328 /*           INTEGER               AVFLAG */
329 /*           INTEGER               HANDLE */
330 /*           INTEGER               I */
331 /*           INTEGER               ICD    ( 6 ) */
332 /*           INTEGER               K */
333 /*           INTEGER               LASTAD */
334 /*           INTEGER               NCOEF  ( QAVSIZ ) */
335 /*           INTEGER               NREC */
336 
337 /*           LOGICAL               FOUND */
338 /*     C */
339 /*     C     First load the file. (The file may also be opened by using */
340 /*     C     CKLPF.) */
341 /*     C */
342 /*           CALL DAFOPR ( 'DATA.BC', HANDLE ) */
343 /*     C */
344 /*     C     Begin forward search. Find the first array. */
345 /*     C */
346 /*           CALL DAFBFS ( HANDLE ) */
347 /*           CALL DAFFNA ( FOUND  ) */
348 /*     C */
349 /*     C     Get segment descriptor. */
350 /*     C */
351 /*           CALL DAFGS ( DESCR ) */
352 /*     C */
353 /*     C     Unpack the segment descriptor into its double precision */
354 /*     C     and integer components. */
355 /*     C */
356 /*           CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
357 
358 /*           IF ( ICD( 3 ) .EQ. 4 ) THEN */
359 /*     C */
360 /*     C        How many records does this segment contain? */
361 /*     C */
362 /*              CALL CKNR04 ( HANDLE, DESCR, NREC ) */
363 
364 /*              DO I = 1, NREC */
365 /*     C */
366 /*     C           Get the data records stored in the segment. */
367 /*     C */
368 /*                 CALL CKGR04 ( HANDLE, DESCR, I, PKTDAT ) */
369 /*     C */
370 /*     C           Print data packet contents. Print coverage interval */
371 /*     C           midpoint & radii first. */
372 /*     C */
373 /*                 WRITE (2,*) PKTDAT (1) */
374 /*                 WRITE (2,*) PKTDAT (2) */
375 /*     C */
376 /*     C           Decode numbers of coefficients. */
377 /*     C */
378 /*                 CALL ZZCK4D2I ( PKTDAT(3), QAVSIZ, CK4PCD, NCOEF ) */
379 /*     C */
380 /*     C           Print number of coefficients for Q0, Q1, Q2 and Q3. */
381 /*     C */
382 /*                 WRITE (2,FMT='(I2,6X,I2)') NCOEF( 1 ), NCOEF( 2 ) */
383 /*                 WRITE (2,FMT='(I2,6X,I2)') NCOEF( 3 ), NCOEF( 4 ) */
384 /*     C */
385 /*     C           Print number coefficients for AV1, AV2 and AV3. */
386 /*     C */
387 /*                 WRITE (2,FMT='(I2,6X,I2)') NCOEF( 5 ), NCOEF( 6 ) */
388 /*                 WRITE (2,FMT='(I2,6X,I2)') NCOEF( 7 ) */
389 /*     C */
390 /*     C           Print Cheby coefficients. */
391 /*     C */
392 /*                 LASTAD = 0 */
393 
394 /*                 DO K = 1, QAVSIZ */
395 /*                    LASTAD = LASTAD + NCOEF( K ) */
396 /*                 END DO */
397 
398 /*                 DO K = 4, LASTAD + 4 */
399 /*                    WRITE (2,*) PKTDAT (K) */
400 /*                 END DO */
401 
402 /*              END DO */
403 
404 /*           END IF */
405 
406 /* $ Restrictions */
407 
408 /*     1) The binary CK file containing the segment whose descriptor */
409 /*        was passed to this routine must be opened for read or write */
410 /*        access by either CKLPF, DAFOPR, or DAFOPW. */
411 
412 /* $ Literature_References */
413 
414 /*     None. */
415 
416 /* $ Author_and_Institution */
417 
418 /*     Y.K. Zaiko     (JPL) */
419 /*     B.V. Semenov   (JPL) */
420 
421 /* $ Version */
422 
423 /* -    SPICELIB Version 1.0.1, 18-APR-2014 (BVS) */
424 
425 /*        Minor header edits. */
426 
427 /* -    SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
428 
429 /* -& */
430 /* $ Index_Entries */
431 
432 /*     number of CK type_4 records */
433 
434 /* -& */
435 
436 /*     SPICELIB functions */
437 
438 
439 /*     Local parameters */
440 
441 
442 /*     Local variables */
443 
444 
445 /*     Standard SPICE error handling. */
446 
447     if (return_()) {
448 	return 0;
449     } else {
450 	chkin_("CKNR04", (ftnlen)6);
451     }
452 
453 /*     Check whether our segment is of the type 4 by unpacking */
454 /*     descriptor and checking value of its third integer component. */
455 
456     dafus_(descr, &c__2, &c__6, dcd, icd);
457     if (icd[2] != 4) {
458 	setmsg_("Data type of the segment should be 4: Passed descriptor sho"
459 		"ws type = #.", (ftnlen)71);
460 	errint_("#", &icd[2], (ftnlen)1);
461 	sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
462 	chkout_("CKNR04", (ftnlen)6);
463 	return 0;
464     }
465 
466 /*     The number of records (packets) can be obtained by a call to */
467 /*     SGMETA. This number is a meta item 12 (see sgparam.inc for */
468 /*     details.) */
469 
470     sgmeta_(handle, descr, &c__12, nrec);
471 
472 /*     All done. */
473 
474     chkout_("CKNR04", (ftnlen)6);
475     return 0;
476 } /* cknr04_ */
477 
478