1 /* spkr15.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      SPKR15 ( Read SPK record from segment, type 15 ) */
spkr15_(integer * handle,doublereal * descr,doublereal * et,doublereal * record)14 /* Subroutine */ int spkr15_(integer *handle, doublereal *descr, doublereal *
15 	et, doublereal *record)
16 {
17     /* System generated locals */
18     integer i__1;
19 
20     /* Local variables */
21     integer type__, begin;
22     extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
23 	    integer *, integer *, doublereal *, integer *), dafgda_(integer *,
24 	     integer *, integer *, doublereal *);
25     doublereal dc[2];
26     integer ic[6];
27     extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
28 	    ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
29 	    ftnlen);
30     extern logical return_(void);
31     integer end;
32 
33 /* $ Abstract */
34 
35 /*     This routine reads a single spk data record from a segment of */
36 /*     type 15 (Precessing Conic Propagation). */
37 
38 /* $ Disclaimer */
39 
40 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
41 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
42 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
43 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
44 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
45 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
46 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
47 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
48 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
49 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
50 
51 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
52 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
53 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
54 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
55 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
56 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
57 
58 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
59 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
60 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
61 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
62 
63 /* $ Required_Reading */
64 
65 /*     SPK */
66 
67 /* $ Keywords */
68 
69 /*     EPHEMERIS */
70 
71 /* $ Declarations */
72 /* $ Brief_I/O */
73 
74 /*     Variable  I/O  Description */
75 /*     --------  ---  -------------------------------------------------- */
76 /*     HANDLE     I   File handle. */
77 /*     DESCR      I   Segment descriptor. */
78 /*     ET         I   Target epoch. */
79 /*     RECORD     O   Data record. */
80 
81 /* $ Detailed_Input */
82 
83 /*     HANDLE, */
84 /*     DESCR       are the file handle and segment descriptor for */
85 /*                 a SPK segment of type 15. */
86 
87 /*     ET          is a target epoch, for which a data record from */
88 /*                 a specific segment is required. */
89 
90 /* $ Detailed_Output */
91 
92 /*     RECORD      is the record from the specified segment which, */
93 /*                 when evaluated at epoch ET, will give the state */
94 /*                 (position and velocity) of some body, relative */
95 /*                 to some center, in some inertial reference frame. */
96 
97 /* $ Parameters */
98 
99 /*     None. */
100 
101 /* $ Files */
102 
103 /*     See argument HANDLE. */
104 
105 /* $ Exceptions */
106 
107 /*     1) If the segment specified by DESCR is not a type 15 segment */
108 /*        the error 'SPICE(WRONGSPKTYPE)' will be signalled. */
109 
110 /*     2) A type 15 segment should have exactly 16 values.  If this */
111 /*        is not the case the error 'SPICE(MALFORMEDSEGMENT)' is */
112 /*        signalled. */
113 
114 /* $ Particulars */
115 
116 /*     This routine reads all of the data from a type 15 SPK segment. */
117 
118 /*     The structure of the data retrieved in RECORD is: */
119 
120 /*         RECORD(1)             epoch of the orbit elements at periapse */
121 /*                               in ephemeris seconds past J2000. */
122 /*         RECORD(2)-RECORD(4)   unit trajectory pole vector */
123 /*         RECORD(5)-RECORD(7)   unit periapsis vector */
124 /*         RECORD(8)             semi-latus rectum---p in the */
125 /*                               equation: */
126 
127 /*                               r = p/(1 + ECC*COS(Nu)) */
128 
129 /*         RECORD(9)             eccentricity */
130 /*         RECORD(10)            J2 processing flag describing */
131 /*                               what J2 corrections are to be */
132 /*                               applied when the orbit is */
133 /*                               propagated. */
134 
135 /*                                Value       Meaning */
136 /*                                -----  ----------------------------- */
137 /*                                1      Regress line of nodes only. */
138 /*                                2      Precess line of apsides only. */
139 /*                                3      Don't use J2 corrections. */
140 /*                                Other  Regress line of nodes */
141 /*                                       and precess line of apsides. */
142 
143 /*         RECORD(11)-RECORD(13) unit central body pole vector */
144 /*         RECORD(14)            central body GM */
145 /*         RECORD(15)            central body J2 */
146 /*         RECORD(16)            central body radius */
147 
148 /*     Except for J2, units are radians, km, seconds. */
149 
150 
151 /* $ Examples */
152 
153 /*     The data returned by the SPKRnn routine is in its rawest form, */
154 /*     taken directly from the segment.  As such, it will be meaningless */
155 /*     to a user unless he/she understands the structure of the data type */
156 /*     completely.  Given that understanding, however, the SPKRnn */
157 /*     routines might be used to "dump" and check segment data for a */
158 /*     particular epoch. */
159 
160 
161 /*     C */
162 /*     C     Get a segment applicable to a specified body and epoch. */
163 /*     C */
164 /*           CALL SPKSFS ( BODY, ET, HANDLE, DESCR, IDENT, FOUND ) */
165 
166 /*     C */
167 /*     C     Look at parts of the descriptor. */
168 /*     C */
169 /*           CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
170 /*           CENTER = ICD( 2 ) */
171 /*           REF    = ICD( 3 ) */
172 /*           TYPE   = ICD( 4 ) */
173 
174 /*           IF ( TYPE .EQ. 15 ) THEN */
175 /*              CALL SPKR15 ( HANDLE, DESCR, ET, RECORD ) */
176 /*                  . */
177 /*                  .  Look at the RECORD data. */
178 /*                  . */
179 /*           END IF */
180 
181 
182 /* $ Restrictions */
183 
184 /*     None. */
185 
186 /* $ Author_and_Institution */
187 
188 /*      S.   Schlaifer  (JPL) */
189 /*      W.L. Taber      (JPL) */
190 
191 /* $ Literature_References */
192 
193 /*      None. */
194 
195 /* $ Version */
196 
197 /* -    SPICELIB Version 1.1.0, 07-SEP-2001 (EDW) */
198 
199 /*        Replaced DAFRDA call with DAFGDA. */
200 /*        Added IMPLICIT NONE. */
201 
202 /* -    SPICELIB Version 1.0.0, 15-NOV-1994 (WLT) (SS) */
203 
204 /* -& */
205 /* $ Index_Entries */
206 
207 /*     read record from type_15 spk segment */
208 
209 /* -& */
210 
211 /*     SPICELIB Funcions */
212 
213 
214 /*     Local Variables */
215 
216 
217 /*     The differnce between the first and last address of a type 15 */
218 /*     segment should be 15. */
219 
220 
221 /*     Standard Spice Error Handling. */
222 
223     if (return_()) {
224 	return 0;
225     }
226     chkin_("SPKR15", (ftnlen)6);
227 
228 /*     Unpack the segment descriptor. */
229 
230     dafus_(descr, &c__2, &c__6, dc, ic);
231     type__ = ic[3];
232     begin = ic[4];
233     end = ic[5];
234 
235 /*     Make sure that this really is a type 15 data segment. */
236 
237     if (type__ != 15) {
238 	setmsg_("You are attempting to locate type 15 data in a type # data "
239 		"segment.", (ftnlen)67);
240 	errint_("#", &type__, (ftnlen)1);
241 	sigerr_("SPICE(WRONGSPKTYPE)", (ftnlen)19);
242 	chkout_("SPKR15", (ftnlen)6);
243 	return 0;
244     }
245 
246 /*     Since it doesn't cost much we make sure that the segment has */
247 /*     the correct amount of data. */
248 
249     if (end - begin != 15) {
250 	setmsg_("A type 15 segment should contain exactly 16 double precisio"
251 		"n values.  The segment supplied had #.  The segment is badly"
252 		" formed. ", (ftnlen)128);
253 	i__1 = end - begin + 1;
254 	errint_("#", &i__1, (ftnlen)1);
255 	sigerr_("SPICE(MALFORMEDSEGMENT)", (ftnlen)23);
256 	chkout_("SPKR15", (ftnlen)6);
257 	return 0;
258     }
259 
260 /*     Read the data for the record. */
261 
262     dafgda_(handle, &begin, &end, record);
263     chkout_("SPKR15", (ftnlen)6);
264     return 0;
265 } /* spkr15_ */
266 
267