1 /* ckw04b.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__0 = 0;
13 static integer c__3 = 3;
14
15 /* $Procedure CKW04B ( CK type 04: Begin a segment ) */
ckw04b_(integer * handle,doublereal * begtim,integer * inst,char * ref,logical * avflag,char * segid,ftnlen ref_len,ftnlen segid_len)16 /* Subroutine */ int ckw04b_(integer *handle, doublereal *begtim, integer *
17 inst, char *ref, logical *avflag, char *segid, ftnlen ref_len, ftnlen
18 segid_len)
19 {
20 /* System generated locals */
21 integer i__1;
22
23 /* Local variables */
24 integer i__;
25 extern /* Subroutine */ int chkin_(char *, ftnlen), dafps_(integer *,
26 integer *, doublereal *, integer *, doublereal *);
27 doublereal descr[5];
28 extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
29 integer value;
30 doublereal dcoeff;
31 integer refcod;
32 extern /* Subroutine */ int namfrm_(char *, integer *, ftnlen);
33 extern integer lastnb_(char *, ftnlen);
34 extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
35 ftnlen), setmsg_(char *, ftnlen), sgbwvs_(integer *, doublereal *,
36 char *, integer *, doublereal *, integer *, ftnlen);
37 extern logical return_(void);
38 doublereal dcd[2];
39 integer icd[6];
40
41 /* $ Abstract */
42
43 /* Begin a type CK04 segment in the DAF file associated with */
44 /* HANDLE. See also CKW04A and CKW04E. */
45
46 /* $ Disclaimer */
47
48 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
49 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
50 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
51 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
52 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
53 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
54 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
55 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
56 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
57 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
58
59 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
60 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
61 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
62 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
63 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
64 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
65
66 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
67 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
68 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
69 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
70
71 /* $ Required_Reading */
72
73 /* CK */
74 /* DAF */
75
76 /* $ Keywords */
77
78 /* POINTING */
79
80 /* $ Declarations */
81
82 /* $ Abstract */
83
84 /* Parameter declarations for the generic segments subroutines. */
85
86 /* $ Disclaimer */
87
88 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
89 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
90 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
91 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
92 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
93 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
94 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
95 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
96 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
97 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
98
99 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
100 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
101 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
102 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
103 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
104 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
105
106 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
107 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
108 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
109 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
110
111 /* $ Required_Reading */
112
113 /* DAF Required Reading */
114
115 /* $ Keywords */
116
117 /* GENERIC SEGMENTS */
118
119 /* $ Particulars */
120
121 /* This include file contains the parameters used by the generic */
122 /* segments subroutines, SGxxxx. A generic segment is a */
123 /* generalization of a DAF array which places a particular structure */
124 /* on the data contained in the array, as described below. */
125
126 /* This file defines the mnemonics that are used for the index types */
127 /* allowed in generic segments as well as mnemonics for the meta data */
128 /* items which are used to describe a generic segment. */
129
130 /* A DAF generic segment contains several logical data partitions: */
131
132 /* 1) A partition for constant values to be associated with each */
133 /* data packet in the segment. */
134
135 /* 2) A partition for the data packets. */
136
137 /* 3) A partition for reference values. */
138
139 /* 4) A partition for a packet directory, if the segment contains */
140 /* variable sized packets. */
141
142 /* 5) A partition for a reference value directory. */
143
144 /* 6) A reserved partition that is not currently used. This */
145 /* partition is only for the use of the NAIF group at the Jet */
146 /* Propulsion Laboratory (JPL). */
147
148 /* 7) A partition for the meta data which describes the locations */
149 /* and sizes of other partitions as well as providing some */
150 /* additional descriptive information about the generic */
151 /* segment. */
152
153 /* +============================+ */
154 /* | Constants | */
155 /* +============================+ */
156 /* | Packet 1 | */
157 /* |----------------------------| */
158 /* | Packet 2 | */
159 /* |----------------------------| */
160 /* | . | */
161 /* | . | */
162 /* | . | */
163 /* |----------------------------| */
164 /* | Packet N | */
165 /* +============================+ */
166 /* | Reference Values | */
167 /* +============================+ */
168 /* | Packet Directory | */
169 /* +============================+ */
170 /* | Reference Directory | */
171 /* +============================+ */
172 /* | Reserved Area | */
173 /* +============================+ */
174 /* | Segment Meta Data | */
175 /* +----------------------------+ */
176
177 /* Only the placement of the meta data at the end of a generic */
178 /* segment is required. The other data partitions may occur in any */
179 /* order in the generic segment because the meta data will contain */
180 /* pointers to their appropriate locations within the generic */
181 /* segment. */
182
183 /* The meta data for a generic segment should only be obtained */
184 /* through use of the subroutine SGMETA. The meta data should not be */
185 /* written through any mechanism other than the ending of a generic */
186 /* segment begun by SGBWFS or SGBWVS using SGWES. */
187
188 /* $ Restrictions */
189
190 /* 1) If new reference index types are added, the new type(s) should */
191 /* be defined to be the consecutive integer(s) after the last */
192 /* defined reference index type used. In this way a value for */
193 /* the maximum allowed index type may be maintained. This value */
194 /* must also be updated if new reference index types are added. */
195
196 /* 2) If new meta data items are needed, mnemonics for them must be */
197 /* added to the end of the current list of mnemonics and before */
198 /* the NMETA mnemonic. In this way compatibility with files having */
199 /* a different, but smaller, number of meta data items may be */
200 /* maintained. See the description and example below. */
201
202 /* $ Author_and_Institution */
203
204 /* N.J. Bachman (JPL) */
205 /* K.R. Gehringer (JPL) */
206 /* W.L. Taber (JPL) */
207 /* F.S. Turner (JPL) */
208
209 /* $ Literature_References */
210
211 /* Generic Segments Required Reading. */
212 /* DAF Required Reading. */
213
214 /* $ Version */
215
216 /* - SPICELIB Version 1.1.1, 28-JAN-2004 (NJB) */
217
218 /* Header update: equations for comptutations of packet indices */
219 /* for the cases of index types 0 and 1 were corrected. */
220
221 /* - SPICELIB Version 1.1.0, 25-09-98 (FST) */
222
223 /* Added parameter MNMETA, the minimum number of meta data items */
224 /* that must be present in a generic DAF segment. */
225
226 /* - SPICELIB Version 1.0.0, 04-03-95 (KRG) (WLT) */
227
228 /* -& */
229
230 /* Mnemonics for the type of reference value index. */
231
232 /* Two forms of indexing are provided: */
233
234 /* 1) An implicit form of indexing based on using two values, a */
235 /* starting value, which will have an index of 1, and a step */
236 /* size between reference values, which are used to compute an */
237 /* index and a reference value associated with a specified key */
238 /* value. See the descriptions of the implicit types below for */
239 /* the particular formula used in each case. */
240
241 /* 2) An explicit form of indexing based on a reference value for */
242 /* each data packet. */
243
244
245 /* Reference Index Type 0 */
246 /* ---------------------- */
247
248 /* Implied index. The index and reference value of a data packet */
249 /* associated with a specified key value are computed from the two */
250 /* generic segment reference values using the formula below. The two */
251 /* generic segment reference values, REF(1) and REF(2), represent, */
252 /* respectively, a starting value and a step size between reference */
253 /* values. The index of the data packet associated with a key value */
254 /* of VALUE is given by: */
255
256 /* / VALUE - REF(1) \ */
257 /* INDEX = 1 + INT | -------------------- | */
258 /* \ REF(2) / */
259
260 /* and the reference value associated with VALUE is given by: */
261
262 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
263
264
265 /* Reference Index Type 1 */
266 /* ---------------------- */
267
268 /* Implied index. The index and reference value of a data packet */
269 /* associated with a specified key value are computed from the two */
270 /* generic segment reference values using the formula below. The two */
271 /* generic segment reference values, REF(1) and REF(2), represent, */
272 /* respectively, a starting value and a step size between reference */
273 /* values. The index of the data packet associated with a key value */
274 /* of VALUE is given by: */
275
276 /* / VALUE - REF(1) \ */
277 /* INDEX = 1 + INT | 0.5 + -------------------- | */
278 /* \ REF(2) / */
279
280
281 /* and the reference value associated with VALUE is given by: */
282
283 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
284
285 /* We get the larger index in the event that VALUE is halfway between */
286 /* X(I) and X(I+1), where X(I) = BUFFER(1) + DBLE (I-1) * REFDAT(2). */
287
288
289 /* Reference Index Type 2 */
290 /* ---------------------- */
291
292 /* Explicit index. In this case the number of packets must equal the */
293 /* number of reference values. The index of the packet associated */
294 /* with a key value of VALUE is the index of the last reference item */
295 /* that is strictly less than VALUE. The reference values must be in */
296 /* ascending order, REF(I) < REF(I+1). */
297
298
299 /* Reference Index Type 3 */
300 /* ---------------------- */
301
302 /* Explicit index. In this case the number of packets must equal the */
303 /* number of reference values. The index of the packet associated */
304 /* with a key value of VALUE is the index of the last reference item */
305 /* that is less than or equal to VALUE. The reference values must be */
306 /* in ascending order, REF(I) < REF(I+1). */
307
308
309 /* Reference Index Type 4 */
310 /* ---------------------- */
311
312 /* Explicit index. In this case the number of packets must equal the */
313 /* number of reference values. The index of the packet associated */
314 /* with a key value of VALUE is the index of the reference item */
315 /* that is closest to the value of VALUE. In the event of a "tie" */
316 /* the larger index is selected. The reference values must be in */
317 /* ascending order, REF(I) < REF(I+1). */
318
319
320 /* These parameters define the valid range for the index types. An */
321 /* index type code, MYTYPE, for a generic segment must satisfy the */
322 /* relation MNIDXT <= MYTYPE <= MXIDXT. */
323
324
325 /* The following meta data items will appear in all generic segments. */
326 /* Other meta data items may be added if a need arises. */
327
328 /* 1) CONBAS Base Address of the constants in a generic segment. */
329
330 /* 2) NCON Number of constants in a generic segment. */
331
332 /* 3) RDRBAS Base Address of the reference directory for a */
333 /* generic segment. */
334
335 /* 4) NRDR Number of items in the reference directory of a */
336 /* generic segment. */
337
338 /* 5) RDRTYP Type of the reference directory 0, 1, 2 ... for a */
339 /* generic segment. */
340
341 /* 6) REFBAS Base Address of the reference items for a generic */
342 /* segment. */
343
344 /* 7) NREF Number of reference items in a generic segment. */
345
346 /* 8) PDRBAS Base Address of the Packet Directory for a generic */
347 /* segment. */
348
349 /* 9) NPDR Number of items in the Packet Directory of a generic */
350 /* segment. */
351
352 /* 10) PDRTYP Type of the packet directory 0, 1, ... for a generic */
353 /* segment. */
354
355 /* 11) PKTBAS Base Address of the Packets for a generic segment. */
356
357 /* 12) NPKT Number of Packets in a generic segment. */
358
359 /* 13) RSVBAS Base Address of the Reserved Area in a generic */
360 /* segment. */
361
362 /* 14) NRSV Number of items in the reserved area of a generic */
363 /* segment. */
364
365 /* 15) PKTSZ Size of the packets for a segment with fixed width */
366 /* data packets or the size of the largest packet for a */
367 /* segment with variable width data packets. */
368
369 /* 16) PKTOFF Offset of the packet data from the start of a packet */
370 /* record. Each data packet is placed into a packet */
371 /* record which may have some bookkeeping information */
372 /* prepended to the data for use by the generic */
373 /* segments software. */
374
375 /* 17) NMETA Number of meta data items in a generic segment. */
376
377 /* Meta Data Item 1 */
378 /* ----------------- */
379
380
381 /* Meta Data Item 2 */
382 /* ----------------- */
383
384
385 /* Meta Data Item 3 */
386 /* ----------------- */
387
388
389 /* Meta Data Item 4 */
390 /* ----------------- */
391
392
393 /* Meta Data Item 5 */
394 /* ----------------- */
395
396
397 /* Meta Data Item 6 */
398 /* ----------------- */
399
400
401 /* Meta Data Item 7 */
402 /* ----------------- */
403
404
405 /* Meta Data Item 8 */
406 /* ----------------- */
407
408
409 /* Meta Data Item 9 */
410 /* ----------------- */
411
412
413 /* Meta Data Item 10 */
414 /* ----------------- */
415
416
417 /* Meta Data Item 11 */
418 /* ----------------- */
419
420
421 /* Meta Data Item 12 */
422 /* ----------------- */
423
424
425 /* Meta Data Item 13 */
426 /* ----------------- */
427
428
429 /* Meta Data Item 14 */
430 /* ----------------- */
431
432
433 /* Meta Data Item 15 */
434 /* ----------------- */
435
436
437 /* Meta Data Item 16 */
438 /* ----------------- */
439
440
441 /* If new meta data items are to be added to this list, they should */
442 /* be added above this comment block as described below. */
443
444 /* INTEGER NEW1 */
445 /* PARAMETER ( NEW1 = PKTOFF + 1 ) */
446
447 /* INTEGER NEW2 */
448 /* PARAMETER ( NEW2 = NEW1 + 1 ) */
449
450 /* INTEGER NEWEST */
451 /* PARAMETER ( NEWEST = NEW2 + 1 ) */
452
453 /* and then the value of NMETA must be changed as well to be: */
454
455 /* INTEGER NMETA */
456 /* PARAMETER ( NMETA = NEWEST + 1 ) */
457
458 /* Meta Data Item 17 */
459 /* ----------------- */
460
461
462 /* Maximum number of meta data items. This is always set equal to */
463 /* NMETA. */
464
465
466 /* Minimum number of meta data items that must be present in a DAF */
467 /* generic segment. This number is to remain fixed even if more */
468 /* meta data items are added for compatibility with old DAF files. */
469
470 /* $ Abstract */
471
472 /* Declarations of the CK data type specific and general CK low */
473 /* level routine parameters. */
474
475 /* $ Disclaimer */
476
477 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
478 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
479 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
480 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
481 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
482 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
483 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
484 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
485 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
486 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
487
488 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
489 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
490 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
491 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
492 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
493 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
494
495 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
496 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
497 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
498 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
499
500 /* $ Required_Reading */
501
502 /* CK.REQ */
503
504 /* $ Keywords */
505
506 /* CK */
507
508 /* $ Restrictions */
509
510 /* 1) If new CK types are added, the size of the record passed */
511 /* between CKRxx and CKExx must be registered as separate */
512 /* parameter. If this size will be greater than current value */
513 /* of the CKMRSZ parameter (which specifies the maximum record */
514 /* size for the record buffer used inside CKPFS) then it should */
515 /* be assigned to CKMRSZ as a new value. */
516
517 /* $ Author_and_Institution */
518
519 /* N.J. Bachman (JPL) */
520 /* B.V. Semenov (JPL) */
521
522 /* $ Literature_References */
523
524 /* CK Required Reading. */
525
526 /* $ Version */
527
528 /* - SPICELIB Version 3.0.0, 27-JAN-2014 (NJB) */
529
530 /* Updated to support CK type 6. Maximum degree for */
531 /* type 5 was updated to be consistent with the */
532 /* maximum degree for type 6. */
533
534 /* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
535
536 /* Updated to support CK type 5. */
537
538 /* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
539
540 /* -& */
541
542 /* Number of quaternion components and number of quaternion and */
543 /* angular rate components together. */
544
545
546 /* CK Type 1 parameters: */
547
548 /* CK1DTP CK data type 1 ID; */
549
550 /* CK1RSZ maximum size of a record passed between CKR01 */
551 /* and CKE01. */
552
553
554 /* CK Type 2 parameters: */
555
556 /* CK2DTP CK data type 2 ID; */
557
558 /* CK2RSZ maximum size of a record passed between CKR02 */
559 /* and CKE02. */
560
561
562 /* CK Type 3 parameters: */
563
564 /* CK3DTP CK data type 3 ID; */
565
566 /* CK3RSZ maximum size of a record passed between CKR03 */
567 /* and CKE03. */
568
569
570 /* CK Type 4 parameters: */
571
572 /* CK4DTP CK data type 4 ID; */
573
574 /* CK4PCD parameter defining integer to DP packing schema that */
575 /* is applied when seven number integer array containing */
576 /* polynomial degrees for quaternion and angular rate */
577 /* components packed into a single DP number stored in */
578 /* actual CK records in a file; the value of must not be */
579 /* changed or compatibility with existing type 4 CK files */
580 /* will be lost. */
581
582 /* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
583 /* records; the value of this parameter must never exceed */
584 /* value of the CK4PCD; */
585
586 /* CK4SFT number of additional DPs, which are not polynomial */
587 /* coefficients, located at the beginning of a type 4 */
588 /* CK record that passed between routines CKR04 and CKE04; */
589
590 /* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
591 /* and CKE04; CK4RSZ is computed as follows: */
592
593 /* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
594
595
596 /* CK Type 5 parameters: */
597
598
599 /* CK5DTP CK data type 5 ID; */
600
601 /* CK5MXD maximum polynomial degree allowed in type 5 */
602 /* records. */
603
604 /* CK5MET number of additional DPs, which are not polynomial */
605 /* coefficients, located at the beginning of a type 5 */
606 /* CK record that passed between routines CKR05 and CKE05; */
607
608 /* CK5MXP maximum packet size for any subtype. Subtype 2 */
609 /* has the greatest packet size, since these packets */
610 /* contain a quaternion, its derivative, an angular */
611 /* velocity vector, and its derivative. See ck05.inc */
612 /* for a description of the subtypes. */
613
614 /* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
615 /* and CKE05; CK5RSZ is computed as follows: */
616
617 /* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
618
619
620 /* CK Type 6 parameters: */
621
622
623 /* CK6DTP CK data type 6 ID; */
624
625 /* CK6MXD maximum polynomial degree allowed in type 6 */
626 /* records. */
627
628 /* CK6MET number of additional DPs, which are not polynomial */
629 /* coefficients, located at the beginning of a type 6 */
630 /* CK record that passed between routines CKR06 and CKE06; */
631
632 /* CK6MXP maximum packet size for any subtype. Subtype 2 */
633 /* has the greatest packet size, since these packets */
634 /* contain a quaternion, its derivative, an angular */
635 /* velocity vector, and its derivative. See ck06.inc */
636 /* for a description of the subtypes. */
637
638 /* CK6RSZ maximum size of type 6 CK record passed between CKR06 */
639 /* and CKE06; CK6RSZ is computed as follows: */
640
641 /* CK6RSZ = CK6MET + ( CK6MXD + 1 ) * ( CK6PS3 + 1 ) */
642
643 /* where CK6PS3 is equal to the parameter CK06PS3 defined */
644 /* in ck06.inc. Note that the subtype having the largest */
645 /* packet size (subtype 2) does not give rise to the */
646 /* largest record size, because that type is Hermite and */
647 /* requires half the window size used by subtype 3 for a */
648 /* given polynomial degree. */
649
650
651 /* The parameter CK6PS3 must be in sync with C06PS3 defined in */
652 /* ck06.inc. */
653
654
655
656 /* Maximum record size that can be handled by CKPFS. This value */
657 /* must be set to the maximum of all CKxRSZ parameters (currently */
658 /* CK5RSZ.) */
659
660 /* $ Brief_I/O */
661
662 /* VARIABLE I/O DESCRIPTION */
663 /* -------- --- -------------------------------------------------- */
664 /* HANDLE I The handle of an DAF file open for writing. */
665 /* SEGID I The string to use for segment identifier. */
666 /* INST I The NAIF ID code for the SC or instrument. */
667 /* AVFLAG I The angular rates flag. */
668 /* REF I The reference frame for this segment. */
669 /* BEGTIM I The segment coverage start encoded SCLK time */
670
671 /* $ Detailed_Input */
672
673 /* HANDLE is the file handle of a CK file that has been */
674 /* opened for writing. */
675
676 /* SEGID is the segment identifier. CK segment identifier */
677 /* may contain up to 40 printing ASCII characters. */
678
679 /* INST is the SPICE ID for the SC structure or instrument */
680 /* whose orientation are to be recorded in a CK file. */
681
682 /* AVFLAG angular rates flag indicates whether segment will */
683 /* contain angular rate information. */
684
685 /* REF is the name of a reference frame that pointing is */
686 /* given with respect to, for example 'J2000'. */
687
688 /* BEGTIM is the encoded SCLK time for the start of the segment */
689 /* coverage. */
690
691 /* $ Detailed_Output */
692
693 /* None. The input data is used to create the segment summary */
694 /* for the segment being started in the DAF file */
695 /* associated with HANDLE. */
696
697 /* See the $ Particulars section for details about the */
698 /* structure of a type 4 CK segment. */
699
700 /* $ Parameters */
701
702 /* This subroutine makes use of parameters defined in the files */
703 /* 'sgparam.inc' and 'ckparam.inc'. */
704
705 /* $ Exceptions */
706
707 /* 1) File access errors are diagnosed by routines in the call tree */
708 /* of this routine. */
709
710 /* 2) If numeric ID for given reference frame cannot be resolved */
711 /* from it's name SPICE(INVALIDREFFRAME) is signalled. */
712
713 /* 2) If SEGID is more than 40 characters long, the error */
714 /* SPICE(SEGIDTOOLONG) is signalled. */
715
716 /* 3) If SEGID contains any nonprintable characters, the error */
717 /* SPICE(NONPRINTABLECHARS) is signalled. */
718
719 /* $ Files */
720
721 /* See HANDLE in the $ Detailed_Input section. */
722
723 /* $ Particulars */
724
725 /* This routine begins writing a type 4 CK segment to the open DAF */
726 /* file that is associated with HANDLE. The file must have been */
727 /* opened with write access. */
728
729 /* This routine is one of a set of three routines for creating and */
730 /* adding data to type 4 CK segments. These routines are: */
731
732 /* CKW04B: Begin a type 4 CK segment. This routine must be */
733 /* called before any data may be added to a type 4 */
734 /* segment. */
735
736 /* CKW04A: Add data to a type 4 CK segment. This routine may be */
737 /* called any number of times after a call to CKW04B to */
738 /* add type 4 records to the CK segment that was */
739 /* started. */
740
741 /* CKW04E: End a type 4 CK segment. This routine is called to */
742 /* make the type 4 segment a permanent addition to the */
743 /* DAF file. Once this routine is called, no further type */
744 /* 4 records may be added to the segment. A new segment */
745 /* must be started. */
746
747 /* A type 4 CK segment consists of coefficient sets for variable */
748 /* order Chebyshev polynomials over consecutive time intervals of */
749 /* a variable length. The gaps between intervals are allowed. */
750 /* The Chebyshev polynomials represent individual quaternion */
751 /* components q0, q1, q2 and q3 and individual angular velocities */
752 /* AV1, AV2 and AV3 if they are included with the data. */
753
754 /* The pointing data supplied to the type 4 CK writer (CKW04A) */
755 /* is packed into an array as a sequence of records, */
756
757 /* ---------------------------------------------------- */
758 /* | Record 1 | Record 2 | .. | Record N-1 | Record N | */
759 /* ---------------------------------------------------- */
760
761 /* with each record in data packets has the following format. */
762
763 /* ---------------------------------------------------- */
764 /* | The midpoint of the approximation interval | */
765 /* ---------------------------------------------------- */
766 /* | The radius of the approximation interval | */
767 /* ---------------------------------------------------- */
768 /* | Number of coefficients for q0 | */
769 /* ---------------------------------------------------- */
770 /* | Number of coefficients for q1 | */
771 /* ---------------------------------------------------- */
772 /* | Number of coefficients for q2 | */
773 /* ---------------------------------------------------- */
774 /* | Number of coefficients for q3 | */
775 /* ---------------------------------------------------- */
776 /* | Number of coefficients for AV1 | */
777 /* ---------------------------------------------------- */
778 /* | Number of coefficients for AV2 | */
779 /* ---------------------------------------------------- */
780 /* | Number of coefficients for AV3 | */
781 /* ---------------------------------------------------- */
782 /* | q0 Cheby coefficients | */
783 /* ---------------------------------------------------- */
784 /* | q1 Cheby coefficients | */
785 /* ---------------------------------------------------- */
786 /* | q2 Cheby coefficients | */
787 /* ---------------------------------------------------- */
788 /* | q3 Cheby coefficients | */
789 /* ---------------------------------------------------- */
790 /* | AV1 Cheby coefficients (optional) | */
791 /* ---------------------------------------------------- */
792 /* | AV2 Cheby coefficients (optional) | */
793 /* ---------------------------------------------------- */
794 /* | AV3 Cheby coefficients (optional) | */
795 /* ---------------------------------------------------- */
796
797 /* $ Examples */
798
799 /* Assume that we have: */
800
801 /* HANDLE is the handle of an CK file opened with write */
802 /* access. */
803
804 /* SEGID is a character string of no more than 40 characters */
805 /* which provides a pedigree for the data in the CK */
806 /* segment we will create. */
807
808 /* INST is the SPICE ID code for the instrument whose */
809 /* pointing data is to be placed into the file. */
810
811 /* AVFLAG angular rates flag. */
812
813 /* REFFRM is the name of the SPICE reference frame for the */
814 /* pointing data. */
815
816 /* BEGTIM is the starting encoded SCLK time for which the */
817 /* segment is valid. */
818
819 /* ENDTIM is the ending encoded SCLK time for which the segment */
820 /* is valid. */
821
822 /* N is the number of type 4 records that we want to */
823 /* put into a segment in an CK file. */
824
825 /* NPKTS is integer array which contains the lengths of */
826 /* variable size data packets */
827
828 /* RECRDS contains N type 4 records packaged for the CK */
829 /* file. */
830
831 /* SCSTRT contains the initial encoded SC time for each of */
832 /* the records contained in RECRDS, where */
833
834 /* SCSTRT(I) < SCSTRT(I+1), I = 1, N-1 */
835
836 /* SCSTRT(1) <= FIRST, SCSTRT(N) < LAST */
837
838 /* Then the following code fragment demonstrates how to create */
839 /* a type 4 CK segment if all of the data for the segment is */
840 /* available at one time. */
841
842 /* C */
843 /* C Begin the segment. */
844 /* C */
845 /* CALL CKW04B ( HANDLE, BEGTIM, INST, REF, AVFLAG, SEGID ) */
846 /* C */
847 /* C Add the data to the segment all at once. */
848 /* C */
849 /* CALL CKW04A ( HANDLE, N, NPKTS, RECRDS, SCSTRT ) */
850 /* C */
851 /* C End the segment, making the segment a permanent */
852 /* C addition to the CK file. */
853 /* C */
854 /* CALL CKW04E ( HANDLE, ENDTIM ) */
855
856 /* $ Restrictions */
857
858 /* 1) The file containing the segment should be opened for read */
859 /* or write access either by CKOPN or DAFOPW. */
860
861 /* $ Literature_References */
862
863 /* None. */
864
865 /* $ Author_and_Institution */
866
867 /* Y.K. Zaiko (JPL) */
868 /* B.V. Semenov (JPL) */
869
870 /* $ Version */
871
872 /* - SPICELIB Version 1.0.1, 18-APR-2014 (BVS) */
873
874 /* Minor header edits. */
875
876 /* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
877
878 /* -& */
879 /* $ Index_Entries */
880
881 /* begin writing a type_4 CK segment */
882
883 /* -& */
884
885 /* Spicelib functions */
886
887
888 /* Local Parameters */
889
890
891 /* DAF ND and NI values for CK files and length of a DAF descriptor. */
892
893
894 /* The number of generic segment constants in a type 4 CK segment. */
895
896
897 /* The integer codes of the first and last printable ASCII */
898 /* characters. */
899
900
901 /* The maximum number of characters allowed in a CK segment */
902 /* identifier. */
903
904
905 /* Local variables */
906
907
908 /* Standard SPICELIB error handling. */
909
910 if (return_()) {
911 return 0;
912 } else {
913 chkin_("CKW04B", (ftnlen)6);
914 }
915
916 /* Create a descriptor for the segment we are about to write. First */
917 /* assign start and stop times. */
918
919 dcd[0] = *begtim;
920 dcd[1] = 0.;
921
922 /* Second, resolve reference frame ID code from its name and */
923 /* assign it to the corresponding descriptor component. Signal */
924 /* an error if frame is not recognized. */
925
926 namfrm_(ref, &refcod, ref_len);
927 if (refcod == 0) {
928 setmsg_("The reference frame # is not supported.", (ftnlen)39);
929 errch_("#", ref, (ftnlen)1, ref_len);
930 sigerr_("SPICE(INVALIDREFFRAME)", (ftnlen)22);
931 chkout_("CKW04B", (ftnlen)6);
932 return 0;
933 }
934 icd[1] = refcod;
935
936 /* Third, assign values to the rest of the integer components of */
937 /* the segment descriptor. */
938
939 icd[0] = *inst;
940 icd[2] = 4;
941 if (*avflag) {
942 icd[3] = 1;
943 } else {
944 icd[3] = 0;
945 }
946
947 /* Now pack the segment descriptor. */
948
949 dafps_(&c__2, &c__6, dcd, icd, descr);
950
951 /* Check that all characters in the SEGID are printable. */
952
953 i__1 = lastnb_(segid, segid_len);
954 for (i__ = 1; i__ <= i__1; ++i__) {
955 value = *(unsigned char *)&segid[i__ - 1];
956 if (value < 32 || value > 126) {
957 setmsg_("The segment identifier contains nonprintable characters",
958 (ftnlen)55);
959 sigerr_("SPICE(NONPRINTABLECHARS)", (ftnlen)24);
960 chkout_("CKW04B", (ftnlen)6);
961 return 0;
962 }
963 }
964
965 /* Also check if the segment identifier is too long. */
966
967 if (lastnb_(segid, segid_len) > 40) {
968 setmsg_("Segment identifier contains more than 40 characters.", (
969 ftnlen)52);
970 sigerr_("SPICE(SEGIDTOOLONG)", (ftnlen)19);
971 chkout_("CKW04B", (ftnlen)6);
972 return 0;
973 }
974
975 /* We've got a valid descriptor and identifier and can begin */
976 /* the segment. For this data type, we want to use an explicit */
977 /* reference value index where the reference epochs are in */
978 /* increasing order. We also want the index returned for a */
979 /* particular request epoch to be the index of the greatest */
980 /* reference epoch less than or equal to the request epoch. These */
981 /* characteristics are prescribed by the mnemonic EXPLE. See the */
982 /* include file 'sgparam.inc' for more details. */
983
984 sgbwvs_(handle, descr, segid, &c__0, &dcoeff, &c__3, segid_len);
985
986 /* No need to check FAILED() here, since all we do after this */
987 /* point is checking out. */
988
989 chkout_("CKW04B", (ftnlen)6);
990 return 0;
991 } /* ckw04b_ */
992
993