1 /* spkr10.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__1 = 1;
11 static integer c__8 = 8;
12 static integer c__7 = 7;
13 static integer c__14 = 14;
14
15 /* $Procedure SPKR10 ( SPK, read record from SPK type 10 segment ) */
spkr10_(integer * handle,doublereal * descr,doublereal * et,doublereal * record)16 /* Subroutine */ int spkr10_(integer *handle, doublereal *descr, doublereal *
17 et, doublereal *record)
18 {
19 /* System generated locals */
20 integer i__1;
21
22 /* Local variables */
23 static integer ends[2], indx, from, i__;
24 extern /* Subroutine */ int chkin_(char *, ftnlen), moved_(doublereal *,
25 integer *, doublereal *);
26 static logical found;
27 static doublereal value;
28 static integer to, nepoch, getelm;
29 extern /* Subroutine */ int sgfcon_(integer *, doublereal *, integer *,
30 integer *, doublereal *), sgmeta_(integer *, doublereal *,
31 integer *, integer *), chkout_(char *, ftnlen), sgfpkt_(integer *,
32 doublereal *, integer *, integer *, doublereal *, integer *),
33 sgfrvi_(integer *, doublereal *, doublereal *, doublereal *,
34 integer *, logical *);
35 static integer putelm;
36 extern logical return_(void);
37 static integer set1, set2;
38
39 /* $ Abstract */
40
41 /* Read a single SPK data record from a segment of type 10 */
42 /* (NORAD two line element sets). */
43
44 /* $ Disclaimer */
45
46 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
47 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
48 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
49 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
50 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
51 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
52 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
53 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
54 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
55 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
56
57 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
58 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
59 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
60 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
61 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
62 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
63
64 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
65 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
66 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
67 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
68
69 /* $ Required_Reading */
70
71 /* SPK */
72
73 /* $ Keywords */
74
75 /* EPHEMERIS */
76
77 /* $ Declarations */
78
79 /* $ Abstract */
80
81 /* Parameter declarations for the generic segments subroutines. */
82
83 /* $ Disclaimer */
84
85 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
86 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
87 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
88 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
89 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
90 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
91 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
92 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
93 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
94 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
95
96 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
97 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
98 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
99 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
100 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
101 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
102
103 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
104 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
105 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
106 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
107
108 /* $ Required_Reading */
109
110 /* DAF Required Reading */
111
112 /* $ Keywords */
113
114 /* GENERIC SEGMENTS */
115
116 /* $ Particulars */
117
118 /* This include file contains the parameters used by the generic */
119 /* segments subroutines, SGxxxx. A generic segment is a */
120 /* generalization of a DAF array which places a particular structure */
121 /* on the data contained in the array, as described below. */
122
123 /* This file defines the mnemonics that are used for the index types */
124 /* allowed in generic segments as well as mnemonics for the meta data */
125 /* items which are used to describe a generic segment. */
126
127 /* A DAF generic segment contains several logical data partitions: */
128
129 /* 1) A partition for constant values to be associated with each */
130 /* data packet in the segment. */
131
132 /* 2) A partition for the data packets. */
133
134 /* 3) A partition for reference values. */
135
136 /* 4) A partition for a packet directory, if the segment contains */
137 /* variable sized packets. */
138
139 /* 5) A partition for a reference value directory. */
140
141 /* 6) A reserved partition that is not currently used. This */
142 /* partition is only for the use of the NAIF group at the Jet */
143 /* Propulsion Laboratory (JPL). */
144
145 /* 7) A partition for the meta data which describes the locations */
146 /* and sizes of other partitions as well as providing some */
147 /* additional descriptive information about the generic */
148 /* segment. */
149
150 /* +============================+ */
151 /* | Constants | */
152 /* +============================+ */
153 /* | Packet 1 | */
154 /* |----------------------------| */
155 /* | Packet 2 | */
156 /* |----------------------------| */
157 /* | . | */
158 /* | . | */
159 /* | . | */
160 /* |----------------------------| */
161 /* | Packet N | */
162 /* +============================+ */
163 /* | Reference Values | */
164 /* +============================+ */
165 /* | Packet Directory | */
166 /* +============================+ */
167 /* | Reference Directory | */
168 /* +============================+ */
169 /* | Reserved Area | */
170 /* +============================+ */
171 /* | Segment Meta Data | */
172 /* +----------------------------+ */
173
174 /* Only the placement of the meta data at the end of a generic */
175 /* segment is required. The other data partitions may occur in any */
176 /* order in the generic segment because the meta data will contain */
177 /* pointers to their appropriate locations within the generic */
178 /* segment. */
179
180 /* The meta data for a generic segment should only be obtained */
181 /* through use of the subroutine SGMETA. The meta data should not be */
182 /* written through any mechanism other than the ending of a generic */
183 /* segment begun by SGBWFS or SGBWVS using SGWES. */
184
185 /* $ Restrictions */
186
187 /* 1) If new reference index types are added, the new type(s) should */
188 /* be defined to be the consecutive integer(s) after the last */
189 /* defined reference index type used. In this way a value for */
190 /* the maximum allowed index type may be maintained. This value */
191 /* must also be updated if new reference index types are added. */
192
193 /* 2) If new meta data items are needed, mnemonics for them must be */
194 /* added to the end of the current list of mnemonics and before */
195 /* the NMETA mnemonic. In this way compatibility with files having */
196 /* a different, but smaller, number of meta data items may be */
197 /* maintained. See the description and example below. */
198
199 /* $ Author_and_Institution */
200
201 /* N.J. Bachman (JPL) */
202 /* K.R. Gehringer (JPL) */
203 /* W.L. Taber (JPL) */
204 /* F.S. Turner (JPL) */
205
206 /* $ Literature_References */
207
208 /* Generic Segments Required Reading. */
209 /* DAF Required Reading. */
210
211 /* $ Version */
212
213 /* - SPICELIB Version 1.1.1, 28-JAN-2004 (NJB) */
214
215 /* Header update: equations for comptutations of packet indices */
216 /* for the cases of index types 0 and 1 were corrected. */
217
218 /* - SPICELIB Version 1.1.0, 25-09-98 (FST) */
219
220 /* Added parameter MNMETA, the minimum number of meta data items */
221 /* that must be present in a generic DAF segment. */
222
223 /* - SPICELIB Version 1.0.0, 04-03-95 (KRG) (WLT) */
224
225 /* -& */
226
227 /* Mnemonics for the type of reference value index. */
228
229 /* Two forms of indexing are provided: */
230
231 /* 1) An implicit form of indexing based on using two values, a */
232 /* starting value, which will have an index of 1, and a step */
233 /* size between reference values, which are used to compute an */
234 /* index and a reference value associated with a specified key */
235 /* value. See the descriptions of the implicit types below for */
236 /* the particular formula used in each case. */
237
238 /* 2) An explicit form of indexing based on a reference value for */
239 /* each data packet. */
240
241
242 /* Reference Index Type 0 */
243 /* ---------------------- */
244
245 /* Implied index. The index and reference value of a data packet */
246 /* associated with a specified key value are computed from the two */
247 /* generic segment reference values using the formula below. The two */
248 /* generic segment reference values, REF(1) and REF(2), represent, */
249 /* respectively, a starting value and a step size between reference */
250 /* values. The index of the data packet associated with a key value */
251 /* of VALUE is given by: */
252
253 /* / VALUE - REF(1) \ */
254 /* INDEX = 1 + INT | -------------------- | */
255 /* \ REF(2) / */
256
257 /* and the reference value associated with VALUE is given by: */
258
259 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
260
261
262 /* Reference Index Type 1 */
263 /* ---------------------- */
264
265 /* Implied index. The index and reference value of a data packet */
266 /* associated with a specified key value are computed from the two */
267 /* generic segment reference values using the formula below. The two */
268 /* generic segment reference values, REF(1) and REF(2), represent, */
269 /* respectively, a starting value and a step size between reference */
270 /* values. The index of the data packet associated with a key value */
271 /* of VALUE is given by: */
272
273 /* / VALUE - REF(1) \ */
274 /* INDEX = 1 + INT | 0.5 + -------------------- | */
275 /* \ REF(2) / */
276
277
278 /* and the reference value associated with VALUE is given by: */
279
280 /* REFVAL = REF(1) + DBLE (INDEX-1) * REF(2) */
281
282 /* We get the larger index in the event that VALUE is halfway between */
283 /* X(I) and X(I+1), where X(I) = BUFFER(1) + DBLE (I-1) * REFDAT(2). */
284
285
286 /* Reference Index Type 2 */
287 /* ---------------------- */
288
289 /* Explicit index. In this case the number of packets must equal the */
290 /* number of reference values. The index of the packet associated */
291 /* with a key value of VALUE is the index of the last reference item */
292 /* that is strictly less than VALUE. The reference values must be in */
293 /* ascending order, REF(I) < REF(I+1). */
294
295
296 /* Reference Index Type 3 */
297 /* ---------------------- */
298
299 /* Explicit index. In this case the number of packets must equal the */
300 /* number of reference values. The index of the packet associated */
301 /* with a key value of VALUE is the index of the last reference item */
302 /* that is less than or equal to VALUE. The reference values must be */
303 /* in ascending order, REF(I) < REF(I+1). */
304
305
306 /* Reference Index Type 4 */
307 /* ---------------------- */
308
309 /* Explicit index. In this case the number of packets must equal the */
310 /* number of reference values. The index of the packet associated */
311 /* with a key value of VALUE is the index of the reference item */
312 /* that is closest to the value of VALUE. In the event of a "tie" */
313 /* the larger index is selected. The reference values must be in */
314 /* ascending order, REF(I) < REF(I+1). */
315
316
317 /* These parameters define the valid range for the index types. An */
318 /* index type code, MYTYPE, for a generic segment must satisfy the */
319 /* relation MNIDXT <= MYTYPE <= MXIDXT. */
320
321
322 /* The following meta data items will appear in all generic segments. */
323 /* Other meta data items may be added if a need arises. */
324
325 /* 1) CONBAS Base Address of the constants in a generic segment. */
326
327 /* 2) NCON Number of constants in a generic segment. */
328
329 /* 3) RDRBAS Base Address of the reference directory for a */
330 /* generic segment. */
331
332 /* 4) NRDR Number of items in the reference directory of a */
333 /* generic segment. */
334
335 /* 5) RDRTYP Type of the reference directory 0, 1, 2 ... for a */
336 /* generic segment. */
337
338 /* 6) REFBAS Base Address of the reference items for a generic */
339 /* segment. */
340
341 /* 7) NREF Number of reference items in a generic segment. */
342
343 /* 8) PDRBAS Base Address of the Packet Directory for a generic */
344 /* segment. */
345
346 /* 9) NPDR Number of items in the Packet Directory of a generic */
347 /* segment. */
348
349 /* 10) PDRTYP Type of the packet directory 0, 1, ... for a generic */
350 /* segment. */
351
352 /* 11) PKTBAS Base Address of the Packets for a generic segment. */
353
354 /* 12) NPKT Number of Packets in a generic segment. */
355
356 /* 13) RSVBAS Base Address of the Reserved Area in a generic */
357 /* segment. */
358
359 /* 14) NRSV Number of items in the reserved area of a generic */
360 /* segment. */
361
362 /* 15) PKTSZ Size of the packets for a segment with fixed width */
363 /* data packets or the size of the largest packet for a */
364 /* segment with variable width data packets. */
365
366 /* 16) PKTOFF Offset of the packet data from the start of a packet */
367 /* record. Each data packet is placed into a packet */
368 /* record which may have some bookkeeping information */
369 /* prepended to the data for use by the generic */
370 /* segments software. */
371
372 /* 17) NMETA Number of meta data items in a generic segment. */
373
374 /* Meta Data Item 1 */
375 /* ----------------- */
376
377
378 /* Meta Data Item 2 */
379 /* ----------------- */
380
381
382 /* Meta Data Item 3 */
383 /* ----------------- */
384
385
386 /* Meta Data Item 4 */
387 /* ----------------- */
388
389
390 /* Meta Data Item 5 */
391 /* ----------------- */
392
393
394 /* Meta Data Item 6 */
395 /* ----------------- */
396
397
398 /* Meta Data Item 7 */
399 /* ----------------- */
400
401
402 /* Meta Data Item 8 */
403 /* ----------------- */
404
405
406 /* Meta Data Item 9 */
407 /* ----------------- */
408
409
410 /* Meta Data Item 10 */
411 /* ----------------- */
412
413
414 /* Meta Data Item 11 */
415 /* ----------------- */
416
417
418 /* Meta Data Item 12 */
419 /* ----------------- */
420
421
422 /* Meta Data Item 13 */
423 /* ----------------- */
424
425
426 /* Meta Data Item 14 */
427 /* ----------------- */
428
429
430 /* Meta Data Item 15 */
431 /* ----------------- */
432
433
434 /* Meta Data Item 16 */
435 /* ----------------- */
436
437
438 /* If new meta data items are to be added to this list, they should */
439 /* be added above this comment block as described below. */
440
441 /* INTEGER NEW1 */
442 /* PARAMETER ( NEW1 = PKTOFF + 1 ) */
443
444 /* INTEGER NEW2 */
445 /* PARAMETER ( NEW2 = NEW1 + 1 ) */
446
447 /* INTEGER NEWEST */
448 /* PARAMETER ( NEWEST = NEW2 + 1 ) */
449
450 /* and then the value of NMETA must be changed as well to be: */
451
452 /* INTEGER NMETA */
453 /* PARAMETER ( NMETA = NEWEST + 1 ) */
454
455 /* Meta Data Item 17 */
456 /* ----------------- */
457
458
459 /* Maximum number of meta data items. This is always set equal to */
460 /* NMETA. */
461
462
463 /* Minimum number of meta data items that must be present in a DAF */
464 /* generic segment. This number is to remain fixed even if more */
465 /* meta data items are added for compatibility with old DAF files. */
466
467 /* $ Brief_I/O */
468
469 /* Variable I/O Description */
470 /* -------- --- -------------------------------------------------- */
471 /* HANDLE I File handle. */
472 /* DESCR I Segment descriptor. */
473 /* ET I Target epoch. */
474 /* RECORD O Data record. */
475
476 /* $ Detailed_Input */
477
478 /* HANDLE, */
479 /* DESCR are the file handle and segment descriptor for */
480 /* a SPK segment of type 10. */
481
482 /* ET is a target epoch, for which a data record from */
483 /* a specific segment is required. */
484
485 /* $ Detailed_Output */
486
487 /* RECORD is the record from the specified segment which, */
488 /* when evaluated at epoch ET, will give the state */
489 /* (position and velocity) of some body, relative */
490 /* to some center, in some inertial reference frame. */
491
492 /* $ Parameters */
493
494 /* None. */
495
496 /* $ Exceptions */
497
498 /* 1) It is assumed that the descriptor and handle supplied are */
499 /* for a properly constructed type 10 segment. No checks are */
500 /* performed to ensure this. */
501
502 /* 2) All errors are diagnosed by routines in the call tree */
503 /* of this routine. */
504
505 /* $ Files */
506
507 /* See argument HANDLE. */
508
509 /* $ Particulars */
510
511 /* See the SPK Required Reading file for a description of the */
512 /* structure of a data type 10 segment. */
513
514 /* $ Examples */
515
516 /* The data returned by the SPKRnn routine is in its rawest form, */
517 /* taken directly from the segment. As such, it will be meaningless */
518 /* to a user unless he/she understands the structure of the data type */
519 /* completely. Given that understanding, however, the SPKRxx */
520 /* routines might be used to "dump" and check segment data for a */
521 /* particular epoch. */
522
523
524 /* C */
525 /* C Get a segment applicable to a specified body and epoch. */
526 /* C */
527 /* CALL SPKSFS ( BODY, ET, HANDLE, DESCR, IDENT, FOUND ) */
528
529 /* C */
530 /* C Look at parts of the descriptor. */
531 /* C */
532 /* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
533 /* CENTER = ICD( 2 ) */
534 /* REF = ICD( 3 ) */
535 /* TYPE = ICD( 4 ) */
536
537 /* IF ( TYPE .EQ. 1 ) THEN */
538 /* CALL SPKR10 ( HANDLE, DESCR, ET, RECORD ) */
539 /* . */
540 /* . Look at the RECORD data. */
541 /* . */
542 /* END IF */
543
544 /* $ Restrictions */
545
546 /* None. */
547
548 /* $ Literature_References */
549
550 /* NAIF Document 168.0, "S- and P- Kernel (SPK) Specification and */
551 /* User's Guide" */
552
553 /* $ Author_and_Institution */
554
555 /* W.L. Taber (JPL) */
556
557 /* $ Version */
558
559 /* - SPICELIB Version 1.1.0, 09-MAR-2009 (EDW) */
560
561 /* Remove declaration of unused varaible DOINT. */
562
563 /* - SPICELIB Version 1.0.0, 05-JAN-1994 (WLT) */
564
565 /* -& */
566 /* $ Index_Entries */
567
568 /* read record from type_10 spk segment */
569
570 /* -& */
571
572 /* SPICELIB functions */
573
574
575 /* Local variables */
576
577
578 /* We have 2 nutation/obliquity terms and their rates giving us */
579 /* four angle components for each packet. */
580
581
582 /* BEGEL1 is the location in the record where the first */
583 /* two-line element set will begin. */
584
585
586 /* BEGEL2 is the location in the record where the second */
587 /* two-line element set will begin. */
588
589
590 /* ENSET1 and ENSET2 are the locations in the record where the */
591 /* last element of set 1 and set 2 will be located. */
592
593
594 /* Standard SPICE error handling. */
595
596 if (return_()) {
597 return 0;
598 }
599 chkin_("SPKR10", (ftnlen)6);
600
601 /* Fetch the constants and store them in the first part of */
602 /* the output RECORD. */
603
604 sgfcon_(handle, descr, &c__1, &c__8, record);
605
606 /* Locate the time in the file closest to the input ET. */
607
608 sgfrvi_(handle, descr, et, &value, &indx, &found);
609
610 /* Determine which pair of element sets to choose so that */
611 /* they will bracket ET. */
612
613 if (*et <= value) {
614 /* Computing MAX */
615 i__1 = indx - 1;
616 from = max(i__1,1);
617 to = indx;
618 } else {
619 sgmeta_(handle, descr, &c__7, &nepoch);
620 from = indx;
621 /* Computing MIN */
622 i__1 = indx + 1;
623 to = min(i__1,nepoch);
624 }
625
626 /* Fetch the element sets */
627
628 sgfpkt_(handle, descr, &from, &to, &record[8], ends);
629
630 /* If the size of the packets is not 14, this is an old style */
631 /* two-line element set without nutation information. We simply */
632 /* set all of the angles to zero. */
633
634 if (ends[0] == 10) {
635
636 /* First shift the elements to their proper locations in RECORD */
637 /* so there will be room to fill in the zeros. */
638
639 putelm = 32;
640 getelm = 28;
641 while(getelm > 18) {
642 record[putelm - 1] = record[getelm - 1];
643 --putelm;
644 --getelm;
645 }
646 set1 = 19;
647 set2 = 33;
648 for (i__ = 1; i__ <= 4; ++i__) {
649 record[set1 - 1] = 0.;
650 record[set2 - 1] = 0.;
651 ++set1;
652 ++set2;
653 }
654 }
655
656 /* If we only got one element set, ET was either before the */
657 /* first one in the segment or after the last one in the */
658 /* segment. We simply copy the one fetched a second time so */
659 /* that the record is properly constructed. */
660
661 if (from == to) {
662 moved_(&record[8], &c__14, &record[22]);
663 }
664 chkout_("SPKR10", (ftnlen)6);
665 return 0;
666 } /* spkr10_ */
667
668