1 /* pck03b.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__3 = 3;
11 static integer c__1 = 1;
12
13 /* $Procedure PCK03B ( PCK, begin a type 3 segment ) */
pck03b_(integer * handle,char * segid,integer * body,char * frame,doublereal * first,doublereal * last,integer * chbdeg,ftnlen segid_len,ftnlen frame_len)14 /* Subroutine */ int pck03b_(integer *handle, char *segid, integer *body,
15 char *frame, doublereal *first, doublereal *last, integer *chbdeg,
16 ftnlen segid_len, ftnlen frame_len)
17 {
18 extern /* Subroutine */ int chkin_(char *, ftnlen);
19 doublereal descr[5];
20 extern logical failed_(void);
21 doublereal dcoeff;
22 integer ncoeff;
23 extern /* Subroutine */ int pckpds_(integer *, char *, integer *,
24 doublereal *, doublereal *, doublereal *, ftnlen), sigerr_(char *,
25 ftnlen), chkout_(char *, ftnlen), sgbwfs_(integer *, doublereal *
26 , char *, integer *, doublereal *, integer *, integer *, ftnlen),
27 setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen);
28 extern logical return_(void);
29 integer pktsiz;
30
31 /* $ Abstract */
32
33 /* Begin a type 03 PCK segment in the binary PCK file associated with */
34 /* HANDLE. See also PCK03A and PCK03E. */
35
36 /* $ Disclaimer */
37
38 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
39 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
40 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
41 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
42 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
43 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
44 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
45 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
46 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
47 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
48
49 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
50 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
51 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
52 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
53 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
54 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
55
56 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
57 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
58 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
59 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
60
61 /* $ Required_Reading */
62
63 /* PCK */
64
65 /* $ Keywords */
66
67 /* PCK */
68
69 /* $ Declarations */
70
71 /* $ Abstract */
72
73 /* Parameter declarations for the generic segments subroutines. */
74
75 /* $ Disclaimer */
76
77 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
78 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
79 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
80 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
81 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
82 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
83 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
84 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
85 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
86 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
87
88 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
89 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
90 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
91 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
92 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
93 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
94
95 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
96 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
97 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
98 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
99
100 /* $ Required_Reading */
101
102 /* DAF Required Reading */
103
104 /* $ Keywords */
105
106 /* GENERIC SEGMENTS */
107
108 /* $ Particulars */
109
110 /* This include file contains the parameters used by the generic */
111 /* segments subroutines, SGxxxx. A generic segment is a */
112 /* generalization of a DAF array which places a particular structure */
113 /* on the data contained in the array, as described below. */
114
115 /* This file defines the mnemonics that are used for the index types */
116 /* allowed in generic segments as well as mnemonics for the meta data */
117 /* items which are used to describe a generic segment. */
118
119 /* A DAF generic segment contains several logical data partitions: */
120
121 /* 1) A partition for constant values to be associated with each */
122 /* data packet in the segment. */
123
124 /* 2) A partition for the data packets. */
125
126 /* 3) A partition for reference values. */
127
128 /* 4) A partition for a packet directory, if the segment contains */
129 /* variable sized packets. */
130
131 /* 5) A partition for a reference value directory. */
132
133 /* 6) A reserved partition that is not currently used. This */
134 /* partition is only for the use of the NAIF group at the Jet */
135 /* Propulsion Laboratory (JPL). */
136
137 /* 7) A partition for the meta data which describes the locations */
138 /* and sizes of other partitions as well as providing some */
139 /* additional descriptive information about the generic */
140 /* segment. */
141
142 /* +============================+ */
143 /* | Constants | */
144 /* +============================+ */
145 /* | Packet 1 | */
146 /* |----------------------------| */
147 /* | Packet 2 | */
148 /* |----------------------------| */
149 /* | . | */
150 /* | . | */
151 /* | . | */
152 /* |----------------------------| */
153 /* | Packet N | */
154 /* +============================+ */
155 /* | Reference Values | */
156 /* +============================+ */
157 /* | Packet Directory | */
158 /* +============================+ */
159 /* | Reference Directory | */
160 /* +============================+ */
161 /* | Reserved Area | */
162 /* +============================+ */
163 /* | Segment Meta Data | */
164 /* +----------------------------+ */
165
166 /* Only the placement of the meta data at the end of a generic */
167 /* segment is required. The other data partitions may occur in any */
168 /* order in the generic segment because the meta data will contain */
169 /* pointers to their appropriate locations within the generic */
170 /* segment. */
171
172 /* The meta data for a generic segment should only be obtained */
173 /* through use of the subroutine SGMETA. The meta data should not be */
174 /* written through any mechanism other than the ending of a generic */
175 /* segment begun by SGBWFS or SGBWVS using SGWES. */
176
177 /* $ Restrictions */
178
179 /* 1) If new reference index types are added, the new type(s) should */
180 /* be defined to be the consecutive integer(s) after the last */
181 /* defined reference index type used. In this way a value for */
182 /* the maximum allowed index type may be maintained. This value */
183 /* must also be updated if new reference index types are added. */
184
185 /* 2) If new meta data items are needed, mnemonics for them must be */
186 /* added to the end of the current list of mnemonics and before */
187 /* the NMETA mnemonic. In this way compatibility with files having */
188 /* a different, but smaller, number of meta data items may be */
189 /* maintained. See the description and example below. */
190
191 /* $ Author_and_Institution */
192
193 /* N.J. Bachman (JPL) */
194 /* K.R. Gehringer (JPL) */
195 /* W.L. Taber (JPL) */
196 /* F.S. Turner (JPL) */
197
198 /* $ Literature_References */
199
200 /* Generic Segments Required Reading. */
201 /* DAF Required Reading. */
202
203 /* $ Version */
204
205 /* - SPICELIB Version 1.1.1, 28-JAN-2004 (NJB) */
206
207 /* Header update: equations for comptutations of packet indices */
208 /* for the cases of index types 0 and 1 were corrected. */
209
210 /* - SPICELIB Version 1.1.0, 25-09-98 (FST) */
211
212 /* Added parameter MNMETA, the minimum number of meta data items */
213 /* that must be present in a generic DAF segment. */
214
215 /* - SPICELIB Version 1.0.0, 04-03-95 (KRG) (WLT) */
216
217 /* -& */
218
219 /* Mnemonics for the type of reference value index. */
220
221 /* Two forms of indexing are provided: */
222
223 /* 1) An implicit form of indexing based on using two values, a */
224 /* starting value, which will have an index of 1, and a step */
225 /* size between reference values, which are used to compute an */
226 /* index and a reference value associated with a specified key */
227 /* value. See the descriptions of the implicit types below for */
228 /* the particular formula used in each case. */
229
230 /* 2) An explicit form of indexing based on a reference value for */
231 /* each data packet. */
232
233
234 /* Reference Index Type 0 */
235 /* ---------------------- */
236
237 /* Implied index. The index and reference value of a data packet */
238 /* associated with a specified key value are computed from the two */
239 /* generic segment reference values using the formula below. The two */
240 /* generic segment reference values, REF(1) and REF(2), represent, */
241 /* respectively, a starting value and a step size between reference */
242 /* values. The index of the data packet associated with a key value */
243 /* of VALUE is given by: */
244
245 /* / VALUE - REF(1) \ */
246 /* INDEX = 1 + INT | -------------------- | */
247 /* \ REF(2) / */
248
249 /* and the reference value associated with VALUE is given by: */
250
251 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
252
253
254 /* Reference Index Type 1 */
255 /* ---------------------- */
256
257 /* Implied index. The index and reference value of a data packet */
258 /* associated with a specified key value are computed from the two */
259 /* generic segment reference values using the formula below. The two */
260 /* generic segment reference values, REF(1) and REF(2), represent, */
261 /* respectively, a starting value and a step size between reference */
262 /* values. The index of the data packet associated with a key value */
263 /* of VALUE is given by: */
264
265 /* / VALUE - REF(1) \ */
266 /* INDEX = 1 + INT | 0.5 + -------------------- | */
267 /* \ REF(2) / */
268
269
270 /* and the reference value associated with VALUE is given by: */
271
272 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
273
274 /* We get the larger index in the event that VALUE is halfway between */
275 /* X(I) and X(I+1), where X(I) = BUFFER(1) + DBLE (I-1) * REFDAT(2). */
276
277
278 /* Reference Index Type 2 */
279 /* ---------------------- */
280
281 /* Explicit index. In this case the number of packets must equal the */
282 /* number of reference values. The index of the packet associated */
283 /* with a key value of VALUE is the index of the last reference item */
284 /* that is strictly less than VALUE. The reference values must be in */
285 /* ascending order, REF(I) < REF(I+1). */
286
287
288 /* Reference Index Type 3 */
289 /* ---------------------- */
290
291 /* Explicit index. In this case the number of packets must equal the */
292 /* number of reference values. The index of the packet associated */
293 /* with a key value of VALUE is the index of the last reference item */
294 /* that is less than or equal to VALUE. The reference values must be */
295 /* in ascending order, REF(I) < REF(I+1). */
296
297
298 /* Reference Index Type 4 */
299 /* ---------------------- */
300
301 /* Explicit index. In this case the number of packets must equal the */
302 /* number of reference values. The index of the packet associated */
303 /* with a key value of VALUE is the index of the reference item */
304 /* that is closest to the value of VALUE. In the event of a "tie" */
305 /* the larger index is selected. The reference values must be in */
306 /* ascending order, REF(I) < REF(I+1). */
307
308
309 /* These parameters define the valid range for the index types. An */
310 /* index type code, MYTYPE, for a generic segment must satisfy the */
311 /* relation MNIDXT <= MYTYPE <= MXIDXT. */
312
313
314 /* The following meta data items will appear in all generic segments. */
315 /* Other meta data items may be added if a need arises. */
316
317 /* 1) CONBAS Base Address of the constants in a generic segment. */
318
319 /* 2) NCON Number of constants in a generic segment. */
320
321 /* 3) RDRBAS Base Address of the reference directory for a */
322 /* generic segment. */
323
324 /* 4) NRDR Number of items in the reference directory of a */
325 /* generic segment. */
326
327 /* 5) RDRTYP Type of the reference directory 0, 1, 2 ... for a */
328 /* generic segment. */
329
330 /* 6) REFBAS Base Address of the reference items for a generic */
331 /* segment. */
332
333 /* 7) NREF Number of reference items in a generic segment. */
334
335 /* 8) PDRBAS Base Address of the Packet Directory for a generic */
336 /* segment. */
337
338 /* 9) NPDR Number of items in the Packet Directory of a generic */
339 /* segment. */
340
341 /* 10) PDRTYP Type of the packet directory 0, 1, ... for a generic */
342 /* segment. */
343
344 /* 11) PKTBAS Base Address of the Packets for a generic segment. */
345
346 /* 12) NPKT Number of Packets in a generic segment. */
347
348 /* 13) RSVBAS Base Address of the Reserved Area in a generic */
349 /* segment. */
350
351 /* 14) NRSV Number of items in the reserved area of a generic */
352 /* segment. */
353
354 /* 15) PKTSZ Size of the packets for a segment with fixed width */
355 /* data packets or the size of the largest packet for a */
356 /* segment with variable width data packets. */
357
358 /* 16) PKTOFF Offset of the packet data from the start of a packet */
359 /* record. Each data packet is placed into a packet */
360 /* record which may have some bookkeeping information */
361 /* prepended to the data for use by the generic */
362 /* segments software. */
363
364 /* 17) NMETA Number of meta data items in a generic segment. */
365
366 /* Meta Data Item 1 */
367 /* ----------------- */
368
369
370 /* Meta Data Item 2 */
371 /* ----------------- */
372
373
374 /* Meta Data Item 3 */
375 /* ----------------- */
376
377
378 /* Meta Data Item 4 */
379 /* ----------------- */
380
381
382 /* Meta Data Item 5 */
383 /* ----------------- */
384
385
386 /* Meta Data Item 6 */
387 /* ----------------- */
388
389
390 /* Meta Data Item 7 */
391 /* ----------------- */
392
393
394 /* Meta Data Item 8 */
395 /* ----------------- */
396
397
398 /* Meta Data Item 9 */
399 /* ----------------- */
400
401
402 /* Meta Data Item 10 */
403 /* ----------------- */
404
405
406 /* Meta Data Item 11 */
407 /* ----------------- */
408
409
410 /* Meta Data Item 12 */
411 /* ----------------- */
412
413
414 /* Meta Data Item 13 */
415 /* ----------------- */
416
417
418 /* Meta Data Item 14 */
419 /* ----------------- */
420
421
422 /* Meta Data Item 15 */
423 /* ----------------- */
424
425
426 /* Meta Data Item 16 */
427 /* ----------------- */
428
429
430 /* If new meta data items are to be added to this list, they should */
431 /* be added above this comment block as described below. */
432
433 /* INTEGER NEW1 */
434 /* PARAMETER ( NEW1 = PKTOFF + 1 ) */
435
436 /* INTEGER NEW2 */
437 /* PARAMETER ( NEW2 = NEW1 + 1 ) */
438
439 /* INTEGER NEWEST */
440 /* PARAMETER ( NEWEST = NEW2 + 1 ) */
441
442 /* and then the value of NMETA must be changed as well to be: */
443
444 /* INTEGER NMETA */
445 /* PARAMETER ( NMETA = NEWEST + 1 ) */
446
447 /* Meta Data Item 17 */
448 /* ----------------- */
449
450
451 /* Maximum number of meta data items. This is always set equal to */
452 /* NMETA. */
453
454
455 /* Minimum number of meta data items that must be present in a DAF */
456 /* generic segment. This number is to remain fixed even if more */
457 /* meta data items are added for compatibility with old DAF files. */
458
459 /* $ Brief_I/O */
460
461 /* VARIABLE I/O DESCRIPTION */
462 /* -------- --- -------------------------------------------------- */
463 /* HANDLE I The handle of a DAF file open for writing. */
464 /* SEGID I The string to use for segment identifier. */
465 /* BODY I The NAIF ID code for the body of the segment. */
466 /* FRAME I The inertial frame for this segment. */
467 /* FIRST I The first epoch for which the segment is valid. */
468 /* LAST I The last epoch for which the segment is valid. */
469 /* CHBDEG I The degree of the Chebyshev Polynomial used. */
470
471 /* $ Detailed_Input */
472
473 /* HANDLE is the file handle of a PCK file that has been */
474 /* opened for writing. */
475
476 /* SEGID is the segment identifier. A PCK segment identifier */
477 /* may contain up to 40 printing characters. It may also be */
478 /* blank. */
479
480 /* BODY is the SPICE ID code for the body whose orientation */
481 /* information is to be stored in the PCK segment being */
482 /* created. */
483
484 /* FRAME is the inertial reference frame to which the orientation */
485 /* data for BODY is relative. */
486
487 /* FIRST are the bounds on the ephemeris times, expressed as */
488 /* LAST seconds past J2000, for which the states can be used */
489 /* to interpolate a state for BODY. */
490
491 /* CHBDEG is the degree of the Chebyshev Polynomial used for */
492 /* each set of Chebyshev coefficients that are to be stored */
493 /* in the segment. */
494
495 /* $ Detailed_Output */
496
497 /* None. The data are stored in the PCK segment in the DAF */
498 /* attached to HANDLE. */
499
500 /* See the $ Particulars section for details about the */
501 /* structure of a type 03 PCK segment. */
502
503 /* $ Parameters */
504
505 /* This subroutine makes use of parameters defined in the file */
506 /* 'sgparam.inc'. */
507
508 /* $ Exceptions */
509
510 /* 1) If the degree of the Chebyshev Polynomial to be used for this */
511 /* segment is negative, the error SPICE(INVALIDARGUMENT) will */
512 /* be signalled. */
513
514 /* 2) Errors in the structure or content of the inputs other than the */
515 /* degree of the Chebyshev Polynomial are diagnosed by routines */
516 /* called by this one. */
517
518 /* 3) File access errors are diagnosed by routines in the call tree */
519 /* of this routine. */
520
521 /* $ Files */
522
523 /* None. */
524
525 /* $ Particulars */
526
527 /* This routine begins a type 03 segment in the binary PCK file that */
528 /* is associated with HANDLE. The file must have been opened with */
529 /* write access. */
530
531 /* This routine is one of a set of three routines for creating and */
532 /* adding data to type 03 PCK segments. These routines are: */
533
534 /* PCK03B: Begin a type 03 PCK segment. This routine must be */
535 /* called before any data may be added to a type 03 */
536 /* segment. */
537
538 /* PCK03A: Add data to a type 03 PCK segment. This routine may be */
539 /* called any number of times after a call to PCK03B to */
540 /* add type 03 records to the PCK segment that was */
541 /* started. */
542
543 /* PCK03E: End a type 03 PCK segment. This routine is called to */
544 /* make the type 03 segment a permanent addition to the */
545 /* PCK file. Once this routine is called, no further type */
546 /* 03 records may be added to the segment. A new segment */
547 /* must be started. */
548
549 /* A type 03 PCK segment consists of coefficient sets for fixed order */
550 /* Chebyshev polynomials over consecutive time intervals, where the */
551 /* time intervals need not all be of the same length. The Chebyshev */
552 /* polynomials represent the orientation of a body specified relative */
553 /* to an inertial frame by the angles RA, DEC, W and body fixed */
554 /* angular rates for each axis of the body fixed coordinate system */
555 /* defined by RA, DEC, and W. All of the angles and the angular rates */
556 /* of the axes are given in degrees. */
557
558 /* The orientation data supplied to the type 03 PCK writer is packed */
559 /* into an array as a sequence of logical records, */
560
561 /* ----------------------------------------------------- */
562 /* | Record 1 | Record 2 | ... | Record N-1 | Record N | */
563 /* ----------------------------------------------------- */
564
565 /* with each record has the following format. */
566
567 /* ------------------------------------------------ */
568 /* | The midpoint of the approximation interval | */
569 /* ------------------------------------------------ */
570 /* | The radius of the approximation interval | */
571 /* ------------------------------------------------ */
572 /* | CHBDEG+1 coefficients for RA | */
573 /* ------------------------------------------------ */
574 /* | CHBDEG+1 coefficients for DEC | */
575 /* ------------------------------------------------ */
576 /* | CHBDEG+1 coefficients for W | */
577 /* ------------------------------------------------ */
578 /* | CHBDEG+1 coefficients for the X-axis rate | */
579 /* ------------------------------------------------ */
580 /* | CHBDEG+1 coefficients for the Y-axis rate | */
581 /* ------------------------------------------------ */
582 /* | CHBDEG+1 coefficients for the Z-axis rate | */
583 /* ------------------------------------------------ */
584
585 /* $ Examples */
586
587 /* Assume we have the following for each of the examples that */
588 /* follow. */
589
590 /* HANDLE is the handle of a PCK file opened with write */
591 /* access. */
592
593 /* SEGID is a character string of no more than 40 characters */
594 /* which provides a pedigree for the data in the PCK */
595 /* segment. */
596
597 /* BODY is the SPICE ID code for the body whose orientation */
598 /* data is to be placed into the file. */
599
600 /* REFFRM is the name of the SPICE inertial reference frame */
601 /* the orientation data is relative to. */
602
603 /* FIRST is the starting epoch, in seconds past J2000, for */
604 /* the orientation data to be placed into the segment. */
605
606 /* LAST is the ending epoch, in seconds past J2000, for */
607 /* the orientation data to be placed into the segment. */
608
609 /* Example 1: */
610
611 /* For this example, we also assume that: */
612
613 /* N is the number of type 03 records that we want to */
614 /* put into a segment in PCK file. */
615
616 /* RECRDS contains N type 03 records packaged for the PCK */
617 /* file. */
618
619 /* ETSTRT contains the initial epochs for each of the */
620 /* records contained in RECRDS, where */
621
622 /* ETSTRT(I) < ETSTRT(I+1), I = 1, N-1 */
623
624 /* ETSTRT(1) <= FIRST, ETSTRT(N) < LAST */
625
626 /* ETSTRT(I+1), I = 1, N-1, is the ending epoch for */
627 /* record I as well as the initial epoch for record */
628 /* I+1. */
629
630 /* Then the following code fragment demonstrates how to create a */
631 /* type 03 PCK segment if all of the data for the segment is */
632 /* available at one time. */
633
634 /* C */
635 /* C Begin the segment. */
636 /* C */
637 /* CALL PCK03B ( HANDLE, SEGID, BODY, REFFRM, */
638 /* . FIRST, LAST, CHBDEG ) */
639 /* C */
640 /* C Add the data to the segment all at once. */
641 /* C */
642 /* CALL PCK03A ( HANDLE, N, RECRDS, ETSTRT ) */
643 /* C */
644 /* C End the segment, making the segment a permanent addition */
645 /* C to the PCK file. */
646 /* C */
647 /* CALL PCK03E ( HANDLE ) */
648
649 /* Example 2: */
650
651 /* In this example we want to add type O3 PCK records, as */
652 /* described above in the $ Particulars section, to the segment */
653 /* being written as they are generated. The ability to write the */
654 /* records in this way is useful if computer memory is limited. It */
655 /* may also be convenient from a programming perspective to write */
656 /* the records one at a time. */
657
658 /* For this example, assume that we want to generate N type 03 PCK */
659 /* records, one for each of N time intervals, writing them all to */
660 /* the same segment in a PCK file. Let */
661
662 /* N be the number of type 03 records that we want to */
663 /* generate and put into a segment in an PCK file. */
664
665 /* RECORD be an array with enough room to hold a single type */
666 /* 03 record, i.e. RECORD should have dimension at */
667 /* least 6 * (CHBDEG + 1 ) + 2. */
668
669 /* START be an array of N times that are the beginning */
670 /* epochs for each of the intervals of interest. The */
671 /* times should be in increasing order and the start */
672 /* time for the first interval should equal the */
673 /* starting time for the segment. */
674
675 /* START(I) < START(I+1), I = 1, N-1 */
676
677 /* START(1) = FIRST */
678
679 /* STOP be an array of N times that are the ending epochs */
680 /* for each of the intervals of interest. The times */
681 /* should be in increasing order and the stop time for */
682 /* interval I should equal the start time for interval */
683 /* I+1, i.e., we want to have continuous coverage in */
684 /* time across all of the records. Also, the stop time */
685 /* for the last interval should equal the ending time */
686 /* for the segment. */
687
688 /* STOP(I) < STOP(I+1), I = 1, N-1 */
689
690 /* STOP(I) = START(I+1), I = 1, N-1 */
691
692 /* STOP(N) = LAST */
693
694 /* GENREC( TIME1, TIME2, RECORD ) */
695
696 /* be a subroutine that generates a type 03 PCK record */
697 /* for a time interval specified by TIME1 and TIME2. */
698
699 /* Then the following code fragment demonstrates how to create a */
700 /* type 03 PCK segment if all of the data for the segment is not */
701 /* available at one time. */
702
703 /* C */
704 /* C Begin the segment. */
705 /* C */
706 /* CALL PCK03B ( HANDLE, SEGID, BODY, REFFRM, */
707 /* . FIRST, LAST, CHBDEG ) */
708
709 /* C */
710 /* C Generate the records and write them to the segment in the */
711 /* C PCK file one at at time. */
712 /* C */
713 /* DO I = 1, N */
714
715 /* CALL GENREC ( START(I), STOP(I), RECORD ) */
716 /* CALL PCK03A ( HANDLE, 1, RECORD, START(I) ) */
717
718 /* END DO */
719
720 /* C */
721 /* C End the segment, making the segment a permanent addition */
722 /* C to the PCK file. */
723 /* C */
724 /* CALL PCK03E ( HANDLE ) */
725
726 /* $ Restrictions */
727
728 /* The binary PCK file must be open with write access. */
729
730 /* Only one segment may be written to a particular PCK file at a */
731 /* time. All of the data for the segment must be written and the */
732 /* segment must be ended before another segment may be started in */
733 /* the file. */
734
735 /* $ Literature_References */
736
737 /* None. */
738
739 /* $ Author_and_Institution */
740
741 /* K.R. Gehringer (JPL) */
742 /* E.D. Wright (JPL) */
743 /* B.V. Semenov (JPL) */
744
745 /* $ Version */
746
747 /* - SPICELIB Version 1.0.1, 10-FEB-2014 (EDW) (BVS) */
748
749 /* Minor edits to Procedure; clean trailing whitespace. */
750 /* Corrected order of header sections to conform to NAIF */
751 /* standard. */
752
753 /* Removed comments from the Declarations section. */
754
755 /* - SPICELIB Version 1.0.0, 06-MAR-1995 (KRG) */
756
757 /* -& */
758 /* $ Index_Entries */
759
760 /* begin writing a type_03 pck segment */
761
762 /* -& */
763
764 /* Spicelib functions */
765
766
767 /* Local Parameters */
768
769 /* DAF ND and NI values for PCK files. */
770
771
772 /* Length of an PCK descriptor. */
773
774
775 /* Number of Euler angles. */
776
777
778 /* The type of this segment. */
779
780
781 /* The number of constants. */
782
783
784 /* Local variables */
785
786
787 /* Standard SPICELIB error handling. */
788
789 if (return_()) {
790 return 0;
791 } else {
792 chkin_("PCK03B", (ftnlen)6);
793 }
794
795 /* First, check the degree of the polynomial to be sure that it is */
796 /* not negative. */
797
798 if (*chbdeg < 0) {
799 setmsg_("The degree of the Chebyshev Polynomial was negative, #. The"
800 " degree of the polynomial must be greater than or equal to z"
801 "ero.", (ftnlen)123);
802 errint_("#", chbdeg, (ftnlen)1);
803 sigerr_("SPICE(INVALIDARGUMENT)", (ftnlen)22);
804 chkout_("PCK03B", (ftnlen)6);
805 return 0;
806 }
807
808 /* Create a descriptor for the segment we are about to write. */
809
810 pckpds_(body, frame, &c__3, first, last, descr, frame_len);
811 if (failed_()) {
812 chkout_("PCK03B", (ftnlen)6);
813 return 0;
814 }
815
816 /* We've got a valid descriptor, so compute a few things and begin */
817 /* the segment. */
818
819 ncoeff = *chbdeg + 1;
820 pktsiz = ncoeff * 6 + 2;
821 dcoeff = (doublereal) ncoeff;
822
823 /* For this data type, we want to use an explicit reference value */
824 /* index where the reference epochs are in increasing order. We also */
825 /* want to have as the index for a particular request epoch the index */
826 /* of the greatest reference epoch less than or equal to the request */
827 /* epoch. These characteristics are prescribed by the mnemonic EXPLE. */
828 /* See the include file 'sgparam.inc' for more details. */
829
830 sgbwfs_(handle, descr, segid, &c__1, &dcoeff, &pktsiz, &c__3, segid_len);
831 chkout_("PCK03B", (ftnlen)6);
832 return 0;
833 } /* pck03b_ */
834
835