1 /* ckgr06.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
13 /* $Procedure CKGR06 ( C-kernel, get record, type 06 ) */
ckgr06_(integer * handle,doublereal * descr,integer * msno,integer * recno,doublereal * record)14 /* Subroutine */ int ckgr06_(integer *handle, doublereal *descr, integer *
15 msno, integer *recno, doublereal *record)
16 {
17 /* Initialized data */
18
19 static integer pktszs[4] = { 8,4,14,7 };
20
21 /* System generated locals */
22 integer i__1, i__2;
23
24 /* Builtin functions */
25 integer i_dnnt(doublereal *), s_rnge(char *, integer, char *, integer);
26
27 /* Local variables */
28 integer nrec;
29 doublereal rate;
30 integer baddr, eaddr;
31 extern /* Subroutine */ int chkin_(char *, ftnlen);
32 integer minib, minie;
33 extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
34 doublereal *, integer *), dafgda_(integer *, integer *, integer *,
35 doublereal *);
36 doublereal dc[2];
37 integer ic[6];
38 extern logical failed_(void);
39 doublereal dpdata[1];
40 integer epcbas, epaddr, bufbas;
41 doublereal buffer[4];
42 integer nepdir, ptrbas;
43 extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
44 ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
45 ftnlen);
46 integer nintvl;
47 extern logical return_(void);
48 integer pktsiz, subtyp;
49
50 /* $ Abstract */
51
52 /* Given the handle and descriptor of a type 6 segment in a CK file, */
53 /* return a specified pointing record from that segment. */
54
55 /* $ Disclaimer */
56
57 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
58 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
59 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
60 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
61 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
62 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
63 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
64 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
65 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
66 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
67
68 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
69 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
70 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
71 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
72 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
73 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
74
75 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
76 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
77 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
78 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
79
80 /* $ Required_Reading */
81
82 /* CK */
83 /* DAF */
84
85 /* $ Keywords */
86
87 /* POINTING */
88
89 /* $ Declarations */
90 /* $ Abstract */
91
92 /* Declare parameters specific to CK type 06. */
93
94 /* $ Disclaimer */
95
96 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
97 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
98 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
99 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
100 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
101 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
102 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
103 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
104 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
105 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
106
107 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
108 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
109 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
110 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
111 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
112 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
113
114 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
115 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
116 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
117 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
118
119 /* $ Required_Reading */
120
121 /* CK */
122
123 /* $ Keywords */
124
125 /* CK */
126
127 /* $ Restrictions */
128
129 /* None. */
130
131 /* $ Author_and_Institution */
132
133 /* N.J. Bachman (JPL) */
134 /* B.V. Semenov (JPL) */
135
136 /* $ Literature_References */
137
138 /* None. */
139
140 /* $ Version */
141
142 /* - SPICELIB Version 1.0.0, 10-MAR-2014 (NJB) (BVS) */
143
144 /* -& */
145
146 /* Maximum polynomial degree supported by the current */
147 /* implementation of this CK type. */
148
149
150 /* Integer code indicating `true': */
151
152
153 /* Integer code indicating `false': */
154
155
156 /* CK type 6 subtype codes: */
157
158
159 /* Subtype 0: Hermite interpolation, 8-element packets. Quaternion */
160 /* and quaternion derivatives only, no angular velocity */
161 /* vector provided. Quaternion elements are listed */
162 /* first, followed by derivatives. Angular velocity is */
163 /* derived from the quaternions and quaternion */
164 /* derivatives. */
165
166
167 /* Subtype 1: Lagrange interpolation, 4-element packets. Quaternion */
168 /* only. Angular velocity is derived by differentiating */
169 /* the interpolating polynomials. */
170
171
172 /* Subtype 2: Hermite interpolation, 14-element packets. */
173 /* Quaternion and angular angular velocity vector, as */
174 /* well as derivatives of each, are provided. The */
175 /* quaternion comes first, then quaternion derivatives, */
176 /* then angular velocity and its derivatives. */
177
178
179 /* Subtype 3: Lagrange interpolation, 7-element packets. Quaternion */
180 /* and angular velocity vector provided. The quaternion */
181 /* comes first. */
182
183
184 /* Number of subtypes: */
185
186
187 /* Packet sizes associated with the various subtypes: */
188
189
190 /* Maximum packet size for type 6: */
191
192
193 /* Minimum packet size for type 6: */
194
195
196 /* The CKPFS record size declared in ckparam.inc must be at least as */
197 /* large as the maximum possible size of a CK type 6 record. */
198
199 /* The largest possible CK type 6 record has subtype 3 (note that */
200 /* records of subtype 2 have half as many epochs as those of subtype */
201 /* 3, for a given polynomial degree). A subtype 3 record contains */
202
203 /* - The evaluation epoch */
204 /* - The subtype and packet count */
205 /* - MAXDEG+1 packets of size C06PS3 */
206 /* - MAXDEG+1 time tags */
207
208
209 /* End of file ck06.inc. */
210
211 /* $ Brief_I/O */
212
213 /* Variable I/O Description */
214 /* -------- --- -------------------------------------------------- */
215 /* HANDLE I The handle of the file containing the segment. */
216 /* DESCR I The segment descriptor. */
217 /* MSNO I Index of the mini-segment containing the record. */
218 /* RECNO I Index of the pointing record to be returned. */
219 /* RECORD O The pointing record. */
220
221 /* $ Detailed_Input */
222
223 /* HANDLE is the handle of the binary CK file containing the */
224 /* segment. Normally the CK file should be open for read */
225 /* access. See the Files section below for details. */
226
227 /* DESCR is the DAF descriptor of the type 6 segment. */
228
229 /* RECNO is the number of the discrete pointing instance to be */
230 /* returned from the specified type 6 segment. */
231
232 /* $ Detailed_Output */
233
234 /* RECORD is the pointing record indexed by RECNO in the */
235 /* segment. The contents are as follows: */
236
237 /* RECORD( 1 ) = CLKOUT */
238
239 /* CLKOUT is the encoded spacecraft clock time associated */
240 /* with the returned pointing values. */
241
242 /* RECORD( 2 ) = SUBTYP */
243
244 /* SUBTYP is the CK type 6 subtype code. This code */
245 /* identifies the structure and meaning of the rest */
246 /* of the record. However, all subtypes have a */
247 /* quaternion stored in elements 4-7. */
248
249 /* RECORD( 3 ) = RATE */
250
251 /* RATE is the nominal SCLK rate expressed in units of */
252 /* seconds per tick. This rate is required to convert */
253 /* quaternion or angular velocity derivatives from units */
254 /* of radians/tick to radians/s. */
255
256 /* RECORD( 4 ) = q0 */
257 /* RECORD( 5 ) = q1 */
258 /* RECORD( 6 ) = q2 */
259 /* RECORD( 7 ) = q3 */
260
261 /* Subtype 1 ends here; there are no angular velocity */
262 /* data. Angular velocity is derived by differentiating */
263 /* Lagrange interpolating polynomials. */
264
265 /* RECORD( 8 ) = ] */
266 /* RECORD( 9 ) = ] --- For subtypes 0 and 2, these */
267 /* RECORD( 10 ) = ] elements contain a quaternion */
268 /* RECORD( 11 ) = ] derivative. For subtype 3, */
269 /* elements 8-10 contain an */
270 /* angular velocity vector; */
271 /* element 11 is unassigned. */
272
273 /* All subtypes except subtype */
274 /* 2 stop here. */
275
276 /* RECORD( 12 ) = ] */
277 /* RECORD( 13 ) = ] --- For subtype 2, these */
278 /* RECORD( 14 ) = ] elements contain an angular */
279 /* velocity vector. */
280
281
282 /* RECORD( 15 ) = ] */
283 /* RECORD( 16 ) = ] --- For subtype 2, these */
284 /* RECORD( 17 ) = ] elements contain the */
285 /* derivative of an angular */
286 /* velocity vector. */
287
288 /* The quantities q0 - q3 are the components of the */
289 /* quaternion that represents the C-matrix that transforms */
290 /* vectors from the inertial reference frame of the */
291 /* segment to the instrument frame at time CLKOUT. */
292
293 /* Quaternion derivatives, angular velocity, or the */
294 /* derivative of angular velocity are valid only if */
295 /* these are supported by the segment subtype and */
296 /* if the segment descriptor indicates that angular */
297 /* velocity is present. */
298
299 /* The components of the angular velocity vector are */
300 /* specified relative to the inertial reference frame of */
301 /* the segment. */
302
303 /* Units of angular velocity and of quaternion */
304 /* derivatives are radians/second and 1/second */
305 /* respectively. */
306
307 /* $ Parameters */
308
309 /* None. */
310
311 /* $ Exceptions */
312
313 /* 1) If the segment is not of data type 6, the error */
314 /* SPICE(CKWRONGDATATYPE) is signaled. */
315
316 /* 2) If MSNO is less than one or greater than the number of */
317 /* mini-segments in the specified segment, the error */
318 /* SPICE(INDEXOUTOFRANGE) is signaled. */
319
320 /* 3) If RECNO is less than one or greater than the number of */
321 /* records in the specified segment, the error */
322 /* SPICE(CKNONEXISTREC) is signaled. */
323
324 /* 4) If the specified handle does not belong to any DAF file that */
325 /* is currently known to be open, an error is diagnosed by a */
326 /* routine in the call tree of this routine. */
327
328 /* 5) If DESCR is not a valid descriptor of a valid segment in the */
329 /* CK file specified by HANDLE, the results of this routine are */
330 /* unpredictable. */
331
332 /* 6) If the segment subtype is not recognized, the error */
333 /* SPICE(NOTSUPPORTED) is signaled. */
334
335 /* $ Files */
336
337 /* The CK file specified by HANDLE may be open for read or write */
338 /* access. Normally, the file should have been opened for read */
339 /* access. If the file is open for write access, the calling */
340 /* application must ensure integrity of the CK segment being read. */
341 /* If the structure of the segment is invalid---for example, if the */
342 /* segment has been partially written---this routine will either */
343 /* return invalid results, or it will cause a system-level runtime */
344 /* error. */
345
346 /* $ Particulars */
347
348 /* Note that the mini-segment interpolation window size is not */
349 /* returned in the pointing record; this parameter is not required */
350 /* in order to interpret the record. Call CKMP06 to obtain the */
351 /* window size. */
352
353 /* For a complete description of the internal structure of a type 6 */
354 /* segment, see the CK Required Reading. */
355
356 /* This routine is normally used in conjunction with CKNM06 and */
357 /* CKGM06 to obtain time tags and packet data from a specified type */
358 /* 6 CK segment. */
359
360 /* $ Examples */
361
362 /* The numerical results shown for this example may differ across */
363 /* platforms. The results depend on the SPICE kernels used as */
364 /* input, the compiler and supporting libraries, and the machine */
365 /* specific arithmetic implementation. */
366
367
368 /* 1) The following program dumps records from a CK file that */
369 /* contains only type 6 segments. */
370
371 /* Example code begins here. */
372
373
374 /* PROGRAM GREX1 */
375 /* IMPLICIT NONE */
376 /* C */
377 /* C Dump all records from a CK that */
378 /* C contains only segments of type 6. */
379 /* C */
380
381 /* INCLUDE 'ck06.inc' */
382 /* C */
383 /* C Local parameters */
384 /* C */
385 /* INTEGER ND */
386 /* PARAMETER ( ND = 2 ) */
387
388 /* INTEGER NI */
389 /* PARAMETER ( NI = 6 ) */
390
391 /* INTEGER DSCSIZ */
392 /* PARAMETER ( DSCSIZ = 5 ) */
393
394 /* INTEGER FILSIZ */
395 /* PARAMETER ( FILSIZ = 255 ) */
396
397 /* C */
398 /* C RECSIZ is the size of the largest pointing */
399 /* C record, which corresponds to subtype 2. */
400 /* C */
401 /* INTEGER RECSIZ */
402 /* PARAMETER ( RECSIZ = C06PS2 + 3 ) */
403
404 /* C */
405 /* C Local variables */
406 /* C */
407 /* CHARACTER*(FILSIZ) CK */
408
409 /* DOUBLE PRECISION DC ( ND ) */
410 /* DOUBLE PRECISION DESCR ( DSCSIZ ) */
411 /* DOUBLE PRECISION IVLBDS ( 2 ) */
412 /* DOUBLE PRECISION LSTEPC */
413 /* DOUBLE PRECISION RATE */
414 /* DOUBLE PRECISION RECORD ( RECSIZ ) */
415
416 /* INTEGER DTYPE */
417 /* INTEGER HANDLE */
418 /* INTEGER IC ( NI ) */
419 /* INTEGER RECNO */
420 /* INTEGER MSNO */
421 /* INTEGER NMINI */
422 /* INTEGER NREC */
423 /* INTEGER SEGNO */
424 /* INTEGER SUBTYP */
425 /* INTEGER WINSIZ */
426
427 /* LOGICAL FOUND */
428
429
430 /* CALL PROMPT ( 'Enter name of CK to dump > ', CK ) */
431
432 /* CALL DAFOPR ( CK, HANDLE ) */
433 /* C */
434 /* C Dump data from each CK segment. */
435 /* C */
436 /* SEGNO = 0 */
437
438 /* CALL DAFBFS ( HANDLE ) */
439 /* CALL DAFFNA ( FOUND ) */
440
441 /* DO WHILE ( FOUND ) */
442
443 /* SEGNO = SEGNO + 1 */
444
445 /* WRITE (*,*) ' ' */
446 /* WRITE (*,*) ' ' */
447 /* WRITE (*,*) 'Segment number: ', SEGNO */
448
449 /* C */
450 /* C Fetch and unpack the descriptor of the */
451 /* C current segment; check the data type. */
452 /* C */
453 /* CALL DAFGS ( DESCR ) */
454 /* CALL DAFUS ( DESCR, ND, NI, DC, IC ) */
455
456 /* DTYPE = IC(3) */
457
458 /* IF ( DTYPE .NE. 6 ) THEN */
459
460 /* CALL SETMSG ( 'Data type must be 6 but was #.' ) */
461 /* CALL ERRINT ( '#', DTYPE ) */
462 /* CALL SIGERR ( 'SPICE(NOTSUPPORTED)' ) */
463
464 /* END IF */
465 /* C */
466 /* C Get the mini-segment count for this */
467 /* C segment. */
468 /* C */
469 /* CALL CKNM06 ( HANDLE, DESCR, NMINI ) */
470 /* C */
471 /* C Dump data from each mini-segment. */
472 /* C */
473 /* DO MSNO = 1, NMINI */
474 /* C */
475 /* C Get the mini-segment's record count */
476 /* C and time bounds. */
477 /* C */
478 /* CALL CKMP06 ( HANDLE, DESCR, MSNO, RATE, SUBTYP, */
479 /* . WINSIZ, NREC, IVLBDS, LSTEPC ) */
480
481 /* WRITE (*,*) ' ' */
482 /* WRITE (*,*) ' Mini-segment number: ', MSNO */
483 /* WRITE (*,*) ' Rate: ', RATE */
484 /* WRITE (*,*) ' Subtype: ', SUBTYP */
485 /* WRITE (*,*) ' Window size: ', WINSIZ */
486 /* WRITE (*,*) ' Interval start: ', IVLBDS(1) */
487 /* WRITE (*,*) ' Interval stop: ', IVLBDS(2) */
488 /* WRITE (*,*) ' Last epoch: ', LSTEPC */
489 /* WRITE (*,*) ' ' */
490
491 /* DO RECNO = 1, NREC */
492
493 /* CALL CKGR06 ( HANDLE, DESCR, */
494 /* . MSNO, RECNO, RECORD ) */
495
496 /* WRITE (*,*) ' Record number: ', RECNO */
497 /* WRITE (*,*) ' SCLKDP: ', RECORD(1) */
498 /* WRITE (*,*) ' Clock rate: ', RECORD(3) */
499
500 /* IF ( SUBTYP .EQ. C06TP0 ) THEN */
501
502 /* WRITE (*,*) ' Q(0): ', RECORD(4) */
503 /* WRITE (*,*) ' Q(1): ', RECORD(5) */
504 /* WRITE (*,*) ' Q(2): ', RECORD(6) */
505 /* WRITE (*,*) ' Q(3): ', RECORD(7) */
506 /* WRITE (*,*) ' d Q(0)/dt: ', RECORD(8) */
507 /* WRITE (*,*) ' d Q(1)/dt: ', RECORD(9) */
508 /* WRITE (*,*) ' d Q(2)/dt: ', RECORD(10) */
509 /* WRITE (*,*) ' d Q(3)/dt: ', RECORD(11) */
510
511 /* ELSE IF ( SUBTYP .EQ. C06TP1 ) THEN */
512
513 /* WRITE (*,*) ' Q(0): ', RECORD(4) */
514 /* WRITE (*,*) ' Q(1): ', RECORD(5) */
515 /* WRITE (*,*) ' Q(2): ', RECORD(6) */
516 /* WRITE (*,*) ' Q(3): ', RECORD(7) */
517
518 /* ELSE IF ( SUBTYP .EQ. C06TP2 ) THEN */
519
520 /* WRITE (*,*) ' Q(0): ', RECORD(4) */
521 /* WRITE (*,*) ' Q(1): ', RECORD(5) */
522 /* WRITE (*,*) ' Q(2): ', RECORD(6) */
523 /* WRITE (*,*) ' Q(3): ', RECORD(7) */
524 /* WRITE (*,*) ' d Q(0)/dt: ', RECORD(8) */
525 /* WRITE (*,*) ' d Q(1)/dt: ', RECORD(9) */
526 /* WRITE (*,*) ' d Q(2)/dt: ', RECORD(10) */
527 /* WRITE (*,*) ' d Q(3)/dt: ', RECORD(11) */
528 /* WRITE (*,*) ' AV(1): ', RECORD(12) */
529 /* WRITE (*,*) ' AV(2): ', RECORD(13) */
530 /* WRITE (*,*) ' AV(3): ', RECORD(14) */
531 /* WRITE (*,*) ' d AV(1)/dt: ', RECORD(15) */
532 /* WRITE (*,*) ' d AV(2)/dt: ', RECORD(16) */
533 /* WRITE (*,*) ' d AV(3)/dt: ', RECORD(17) */
534
535 /* ELSE IF ( SUBTYP .EQ. C06TP3 ) THEN */
536
537 /* WRITE (*,*) ' Q(0): ', RECORD(4) */
538 /* WRITE (*,*) ' Q(1): ', RECORD(5) */
539 /* WRITE (*,*) ' Q(2): ', RECORD(6) */
540 /* WRITE (*,*) ' Q(3): ', RECORD(7) */
541 /* WRITE (*,*) ' AV(1): ', RECORD(8) */
542 /* WRITE (*,*) ' AV(2): ', RECORD(9) */
543 /* WRITE (*,*) ' AV(3): ', RECORD(10) */
544
545 /* ELSE */
546 /* CALL SETMSG ( 'Subtype # is not ' */
547 /* . // 'recognized.' ) */
548 /* CALL ERRINT ( '#', SUBTYP ) */
549 /* CALL SIGERR ( 'SPICE(NOTSUPPORTED)' ) */
550 /* END IF */
551
552 /* WRITE (*,*) ' ' */
553
554 /* END DO */
555
556 /* END DO */
557
558 /* CALL DAFFNA ( FOUND ) */
559
560 /* END DO */
561
562 /* END */
563
564
565 /* An initial portion of the output created by this program, when */
566 /* the program was executed on a PC/Linux/gfortran platform, for */
567 /* a sample CK containing type 6 segments, is shown below: */
568
569
570 /* Segment number: 1 */
571
572 /* Mini-segment number: 1 */
573 /* Rate: 1.52587890625000000E-005 */
574 /* Subtype: 1 */
575 /* Window size: 10 */
576 /* Interval start: 11288914762710.869 */
577 /* Interval stop: 11290384616127.203 */
578 /* Last epoch: 11290384616127.203 */
579
580 /* Record number: 1 */
581 /* SCLKDP: 11288914762710.869 */
582 /* Clock rate: 1.52587890625000000E-005 */
583 /* Q(0): 0.46164827229286126 */
584 /* Q(1): -0.70575355403199758 */
585 /* Q(2): -0.29319084125475281 */
586 /* Q(3): -0.45036865373250068 */
587
588 /* Record number: 2 */
589 /* SCLKDP: 11288998883607.230 */
590 /* Clock rate: 1.52587890625000000E-005 */
591 /* Q(0): 0.46162099825988423 */
592 /* Q(1): -0.70570932104748119 */
593 /* Q(2): -0.29323821047130305 */
594 /* Q(3): -0.45043507864268195 */
595
596 /* Record number: 3 */
597 /* SCLKDP: 11289077342579.063 */
598 /* Clock rate: 1.52587890625000000E-005 */
599 /* Q(0): 0.46159435700379842 */
600 /* Q(1): -0.70566850733850173 */
601 /* Q(2): -0.29328062251407311 */
602 /* Q(3): -0.45049870564815003 */
603
604
605 /* $ Restrictions */
606
607 /* None. */
608
609 /* $ Literature_References */
610
611 /* None. */
612
613 /* $ Author_and_Institution */
614
615 /* N.J. Bachman (JPL) */
616 /* J.M. Lynch (JPL) */
617 /* B.V. Semenov (JPL) */
618
619 /* $ Version */
620
621 /* - SPICELIB Version 1.0.0, 14-MAR-2014 (NJB) (JML) (BVS) */
622
623 /* -& */
624 /* $ Index_Entries */
625
626 /* get ck type_6 record */
627
628 /* -& */
629
630 /* SPICELIB functions */
631
632
633 /* Local parameters */
634
635 /* ND is the number of double precision components in an */
636 /* unpacked C-kernel descriptor. */
637
638 /* NI is the number of integer components in an unpacked */
639 /* C-kernel descriptor. */
640
641 /* DTYPE is the data type of the segment that this routine */
642 /* operates on. */
643
644
645 /* Mini-segment control area size: */
646
647
648 /* Local variables */
649
650
651 /* Saved variables */
652
653
654 /* Initial values */
655
656
657 /* Standard SPICE error handling. */
658
659 if (return_()) {
660 return 0;
661 }
662 chkin_("CKGR06", (ftnlen)6);
663
664 /* The number of discrete pointing instances contained in a data */
665 /* type 6 segment is stored in the last double precision word of the */
666 /* segment. Since the address of the last word is stored in the */
667 /* sixth integer component of the segment descriptor, it is a */
668 /* trivial matter to extract the count. */
669
670 /* The unpacked descriptor contains the following information */
671 /* about the segment: */
672
673 /* DC(1) Initial encoded SCLK */
674 /* DC(2) Final encoded SCLK */
675
676 /* IC(1) CK frame class ID (aka "instrument") */
677 /* IC(2) Inertial reference frame */
678 /* IC(3) Data type */
679 /* IC(4) Angular velocity flag */
680 /* IC(5) Initial address of segment data */
681 /* IC(6) Final address of segment data */
682
683
684 dafus_(descr, &c__2, &c__6, dc, ic);
685
686 /* If this segment is not of data type 6, then signal an error. */
687
688 if (ic[2] != 6) {
689 setmsg_("Data type of the segment should be 6: Passed descriptor sho"
690 "ws type = #.", (ftnlen)71);
691 errint_("#", &ic[2], (ftnlen)1);
692 sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
693 chkout_("CKGR06", (ftnlen)6);
694 return 0;
695 }
696
697 /* Check the mini-segment index. */
698
699 /* The number of mini-segments is the final word in the segment. */
700
701 baddr = ic[4];
702 eaddr = ic[5];
703 dafgda_(handle, &eaddr, &eaddr, dpdata);
704 if (failed_()) {
705 chkout_("CKGR06", (ftnlen)6);
706 return 0;
707 }
708 nintvl = i_dnnt(dpdata);
709 if (*msno < 1 || *msno > nintvl) {
710 setmsg_("Mini-segment index must be in range 1:# but was #.", (ftnlen)
711 50);
712 errint_("#", &nintvl, (ftnlen)1);
713 errint_("#", msno, (ftnlen)1);
714 sigerr_("SPICE(INDEXOUTOFRANGE)", (ftnlen)22);
715 chkout_("CKGR06", (ftnlen)6);
716 return 0;
717 }
718
719 /* Set the base address of the mini-segment pointers. There */
720 /* are NINTVL+1 pointers, and these precede the control area. */
721
722 ptrbas = eaddr - 2 - (nintvl + 1);
723
724 /* Compute the mini-segment pointers as absolute */
725 /* DAF addresses. The stored value is a relative address. */
726
727 bufbas = ptrbas + *msno - 1;
728 i__1 = bufbas + 1;
729 i__2 = bufbas + 2;
730 dafgda_(handle, &i__1, &i__2, buffer);
731 if (failed_()) {
732 chkout_("CKGR06", (ftnlen)6);
733 return 0;
734 }
735 minib = baddr - 1 + i_dnnt(buffer);
736 minie = baddr - 1 + i_dnnt(&buffer[1]) - 1;
737
738 /* Fetch the control area of the mini-segment. */
739
740 bufbas = minie - 4;
741 i__1 = bufbas + 1;
742 i__2 = bufbas + 4;
743 dafgda_(handle, &i__1, &i__2, buffer);
744 if (failed_()) {
745 chkout_("CKGR06", (ftnlen)6);
746 return 0;
747 }
748
749 /* Fetch the SCLK rate (seconds per tick), mini-segment */
750 /* subtype, and record count. */
751
752 rate = buffer[0];
753 subtyp = i_dnnt(&buffer[1]);
754 nrec = i_dnnt(&buffer[3]);
755
756 /* Compute the packet size for this mini-segment. This will */
757 /* be used a bit later. We'll also check the subtype. */
758
759 if (subtyp < 0 || subtyp > 3) {
760 setmsg_("Unexpected CK type 6 subtype # found in mini-segment #.", (
761 ftnlen)55);
762 errint_("#", &subtyp, (ftnlen)1);
763 errint_("#", msno, (ftnlen)1);
764 sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
765 chkout_("CKGR06", (ftnlen)6);
766 return 0;
767 }
768 pktsiz = pktszs[(i__1 = subtyp) < 4 && 0 <= i__1 ? i__1 : s_rnge("pktszs",
769 i__1, "ckgr06_", (ftnlen)686)];
770
771 /* Check the record index. */
772
773 if (*recno < 1 || *recno > nrec) {
774 setmsg_("Record index must be in range 1:# but was #.", (ftnlen)44);
775 errint_("#", &nrec, (ftnlen)1);
776 errint_("#", recno, (ftnlen)1);
777 sigerr_("SPICE(CKNONEXISTREC)", (ftnlen)20);
778 chkout_("CKGR06", (ftnlen)6);
779 return 0;
780 }
781
782 /* The epochs of the mini-segment precede the */
783 /* mini-segment's control area and the epoch directories. */
784
785 nepdir = (nrec - 1) / 100;
786 epcbas = minie - 4 - nepdir - nrec;
787
788 /* Fetch the mini-segment's epoch at index RECNO into */
789 /* element 1 of the output record. */
790
791 epaddr = epcbas + *recno;
792 dafgda_(handle, &epaddr, &epaddr, record);
793
794 /* Transfer the subtype and rate to the output record. */
795
796 record[1] = (doublereal) subtyp;
797 record[2] = rate;
798
799 /* Locate the data packet at index RECNO. */
800
801 bufbas = minib - 1 + (*recno - 1) * pktsiz;
802 i__1 = bufbas + 1;
803 i__2 = bufbas + pktsiz;
804 dafgda_(handle, &i__1, &i__2, &record[3]);
805
806 /* The record is complete if DAFGDA did its job. We don't */
807 /* check FAILED here since we're about to return. */
808
809 chkout_("CKGR06", (ftnlen)6);
810 return 0;
811 } /* ckgr06_ */
812
813