1 /* spke03.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 /* $Procedure SPKE03 ( S/P Kernel, evaluate, type 3 ) */
spke03_(doublereal * et,doublereal * record,doublereal * state)9 /* Subroutine */ int spke03_(doublereal *et, doublereal *record, doublereal *
10 state)
11 {
12 /* System generated locals */
13 integer i__1;
14
15 /* Builtin functions */
16 integer s_rnge(char *, integer, char *, integer);
17
18 /* Local variables */
19 integer degp, ncof, i__;
20 extern /* Subroutine */ int chkin_(char *, ftnlen), errdp_(char *,
21 doublereal *, ftnlen), chbval_(doublereal *, integer *,
22 doublereal *, doublereal *, doublereal *);
23 integer cofloc;
24 extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
25 ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
26 ftnlen);
27 extern logical return_(void);
28
29 /* $ Abstract */
30
31 /* Evaluate a single SPK data record from a segment of type 3 */
32 /* (Chebyshev Polynomials, position and velocity). */
33
34 /* $ Disclaimer */
35
36 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
37 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
38 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
39 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
40 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
41 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
42 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
43 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
44 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
45 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
46
47 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
48 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
49 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
50 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
51 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
52 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
53
54 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
55 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
56 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
57 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
58
59 /* $ Required_Reading */
60
61 /* SPK */
62
63 /* $ Keywords */
64
65 /* EPHEMERIS */
66
67 /* $ Declarations */
68 /* $ Brief_I/O */
69
70 /* Variable I/O Description */
71 /* -------- --- -------------------------------------------------- */
72 /* ET I Evaluation epoch. */
73 /* RECORD I Data record. */
74 /* STATE O State (position and velocity). */
75
76 /* $ Detailed_Input */
77
78 /* ET is the epoch at which a state vector or Euler angle */
79 /* state is to be computed. The epoch is represented as */
80 /* seconds past J2000 TDB. */
81
82 /* RECORD is a data record which, when evaluated at epoch ET, */
83 /* will yield three function components and their */
84 /* derivatives with respect to time. The record */
85 /* structure for SPK type 3 data is: */
86
87 /* +--------------------------------------+ */
88 /* | record size (excluding this element) | */
89 /* +--------------------------------------+ */
90 /* | Coverage interval midpoint | */
91 /* +--------------------------------------+ */
92 /* | Coverage interval radius | */
93 /* +--------------------------------------+ */
94 /* | Coeffs for X position component | */
95 /* +--------------------------------------+ */
96 /* | Coeffs for Y position component | */
97 /* +--------------------------------------+ */
98 /* | Coeffs for Z position component | */
99 /* +--------------------------------------+ */
100 /* | Coeffs for X velocity component | */
101 /* +--------------------------------------+ */
102 /* | Coeffs for Y velocity component | */
103 /* +--------------------------------------+ */
104 /* | Coeffs for Z velocity component | */
105 /* +--------------------------------------+ */
106
107 /* In the above record */
108
109 /* - Times are expressed as seconds past J2000 TDB. */
110 /* - Position components have units of km. */
111 /* - Velocity components have units of km/s. */
112
113 /* RECORD must be declared by the caller with size large */
114 /* enough to accommodate the largest record that can be */
115 /* returned by this routine. See the INCLUDE file */
116 /* spkrec.inc for the correct record length. */
117
118 /* $ Detailed_Output */
119
120 /* STATE is the state. In order, X, Y, Z, X', Y', and Z'. */
121 /* Units are km and km/sec. */
122
123 /* $ Parameters */
124
125 /* None. */
126
127 /* $ Exceptions */
128
129 /* 1) If the input record contains an invalid coefficient count, */
130 /* the error SPICE(INVALIDCOUNT) will be signaled. */
131
132 /* 2) If the input record contains invalid domain transformation */
133 /* parameters, the error will be diagnosed by a routine in the */
134 /* call tree of this routine. */
135
136 /* $ Files */
137
138 /* None. */
139
140 /* $ Particulars */
141
142 /* The exact format and structure of type 3 (Chebyshev polynomials, */
143 /* position and velocity) segments are described in the SPK */
144 /* Required Reading file. */
145
146 /* A type 3 segment contains six sets of Chebyshev coefficients, */
147 /* one set each for the position coordinates X, Y, and Z, and one */
148 /* set each for the velocity coordinates X', Y', and Z'. SPKE03 */
149 /* calls the routine CHBVAL to evaluate each polynomial, and arrive */
150 /* at the complete state. */
151
152 /* $ Examples */
153
154 /* The SPKEnn routines are almost always used in conjunction with */
155 /* the corresponding SPKRnn routines, which read the records from */
156 /* SPK files. */
157
158 /* The data returned by the SPKRnn routine is in its rawest form, */
159 /* taken directly from the segment. As such, it will be meaningless */
160 /* to a user unless he/she understands the structure of the data type */
161 /* completely. Given that understanding, however, the SPKRnn */
162 /* routines might be used to examine raw segment data before */
163 /* evaluating it with the SPKEnn routines. */
164
165
166 /* C */
167 /* C Get a segment applicable to a specified body and epoch. */
168 /* C */
169 /* CALL SPKSFS ( BODY, ET, HANDLE, DESCR, IDENT, FOUND ) */
170
171 /* C */
172 /* C Look at parts of the descriptor. */
173 /* C */
174 /* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
175 /* CENTER = ICD( 2 ) */
176 /* REF = ICD( 3 ) */
177 /* TYPE = ICD( 4 ) */
178
179 /* IF ( TYPE .EQ. 3 ) THEN */
180
181 /* CALL SPKR03 ( HANDLE, DESCR, ET, RECORD ) */
182 /* . */
183 /* . Look at the RECORD data. */
184 /* . */
185 /* CALL SPKE03 ( ET, RECORD, STATE ) */
186 /* . */
187 /* . Check out the evaluated state. */
188 /* . */
189 /* END IF */
190
191 /* $ Restrictions */
192
193 /* None. */
194
195 /* $ Literature_References */
196
197 /* NAIF Document 168.0, "S- and P- Kernel (SPK) Specification and */
198 /* User's Guide" */
199
200 /* $ Author_and_Institution */
201
202 /* R.E. Thurman (JPL) */
203
204 /* $ Version */
205
206 /* - SPICELIB Version 2.0.0, 31-DEC-2013 (NJB) */
207
208 /* Added error checks for invalid coefficient counts */
209 /* and invalid interval radius. Changed error handling */
210 /* style to "discovery." Enhanced header documentation. */
211
212 /* - SPICELIB Version 1.0.3, 10-MAR-1992 (WLT) */
213
214 /* Comment section for permuted index source lines was added */
215 /* following the header. */
216
217 /* - SPICELIB Version 1.0.2, 23-AUG-1991 (HAN) */
218
219 /* SPK03 was removed from the Required_Reading section of the */
220 /* header. The information in the SPK03 Required Reading file */
221 /* is now part of the SPK Required Reading file. */
222
223 /* - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */
224
225 /* Literature references added to the header. */
226
227 /* - SPICELIB Version 1.0.0, 31-JAN-1990 (RET) */
228
229 /* -& */
230 /* $ Index_Entries */
231
232 /* evaluate type_3 spk segment */
233
234 /* -& */
235
236 /* SPICELIB functions */
237
238
239 /* Local variables */
240
241
242 /* Use discovery check-in. */
243
244 if (return_()) {
245 return 0;
246 }
247
248 /* The first number in the record is the record size. Following it */
249 /* are two numbers that will be used later, then the six sets of */
250 /* coefficients. The number of coefficients for each quantity can */
251 /* be determined from the record size, since there are the same */
252 /* number of coefficients for each quantity. */
253
254 ncof = ((integer) record[0] - 2) / 6;
255 if (ncof < 1) {
256 chkin_("SPKE03", (ftnlen)6);
257 setmsg_("The input record's coefficient count NCOF should be positiv"
258 "e but was #.", (ftnlen)71);
259 errint_("#", &ncof, (ftnlen)1);
260 sigerr_("SPICE(INVALIDCOUNT)", (ftnlen)19);
261 chkout_("SPKE03", (ftnlen)6);
262 return 0;
263 }
264
265 /* Check the radius of the domain interval. */
266
267 if (record[2] <= 0.) {
268 chkin_("SPKE03", (ftnlen)6);
269 setmsg_("Interval radius must be positive but was #.", (ftnlen)43);
270 errdp_("#", &record[2], (ftnlen)1);
271 sigerr_("SPICE(INVALIDRADIUS)", (ftnlen)20);
272 chkout_("SPKE03", (ftnlen)6);
273 return 0;
274 }
275
276 /* The degree of each polynomial is one less than the number of */
277 /* coefficients. */
278
279 degp = ncof - 1;
280
281 /* Call CHBVAL once for each quantity to evaluate the position */
282 /* and velocity values. */
283
284 for (i__ = 1; i__ <= 6; ++i__) {
285
286 /* The coefficients for each variable are located contiguously, */
287 /* following the first three words in the record. */
288
289 cofloc = ncof * (i__ - 1) + 4;
290
291 /* CHBVAL needs as input the coefficients, the degree of the */
292 /* polynomial, the epoch, and also two variable transformation */
293 /* parameters, which are located, in our case, in the second and */
294 /* third slots of the record. */
295
296 chbval_(&record[cofloc - 1], °p, &record[1], et, &state[(i__1 =
297 i__ - 1) < 6 && 0 <= i__1 ? i__1 : s_rnge("state", i__1,
298 "spke03_", (ftnlen)297)]);
299 }
300 return 0;
301 } /* spke03_ */
302
303