1 /* getelm.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 GETELM ( Get the components from two-line elements) */
getelm_(integer * frstyr,char * lines,doublereal * epoch,doublereal * elems,ftnlen lines_len)9 /* Subroutine */ int getelm_(integer *frstyr, char *lines, doublereal *epoch,
10 	doublereal *elems, ftnlen lines_len)
11 {
12     extern /* Subroutine */ int zzgetelm_(integer *, char *, doublereal *,
13 	    doublereal *, logical *, char *, ftnlen, ftnlen), chkin_(char *,
14 	    ftnlen), errch_(char *, char *, ftnlen, ftnlen);
15     char error[256];
16     logical ok;
17     extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
18 	    ftnlen), setmsg_(char *, ftnlen);
19     extern logical return_(void);
20 
21 /* $ Abstract */
22 
23 /*    Given a the "lines" of a two-line element set, parse the */
24 /*    lines and return the elements in units suitable for use */
25 /*    in SPICE software. */
26 
27 /* $ Disclaimer */
28 
29 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
30 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
31 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
32 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
33 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
34 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
35 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
36 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
37 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
38 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
39 
40 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
41 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
42 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
43 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
44 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
45 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
46 
47 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
48 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
49 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
50 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
51 
52 /* $ Required_Reading */
53 
54 /*     None. */
55 
56 /* $ Keywords */
57 
58 /*     PARSING */
59 
60 /* $ Declarations */
61 /* $ Brief_I/O */
62 
63 /*     VARIABLE  I/O  DESCRIPTION */
64 /*     --------  ---  -------------------------------------------------- */
65 /*     FRSTYR     I   year of earliest representable two-line elements */
66 /*     LINES      I   a pair of "lines" containing two-line elements */
67 /*     EPOCH      O   The epoch of the elements in seconds past J2000 */
68 /*     ELEMS      O   The elements converted to SPICE units. */
69 
70 /* $ Detailed_Input */
71 
72 /*     FRSTYR    is the first year possible for two line elements. */
73 /*               Since two line elements allow only two digits for */
74 /*               the year, some conventions must be followed concerning */
75 /*               which century the two digits refer to .  FRSTYR */
76 /*               is the year of the earliest representable elements. */
77 /*               The two-digit year is mapped to the year in */
78 /*               the interval from FRSTYR to FRSTYR + 99 that */
79 /*               has the same last two digits as the two digit */
80 /*               year in the element set.  For example if FRSTYR */
81 /*               is set to 1960  then the two digit years are mapped */
82 /*               as shown in the table below: */
83 
84 /*               Two-line         Maps to */
85 /*               element year */
86 /*                  00            2000 */
87 /*                  01            2001 */
88 /*                  02            2002 */
89 /*                   .              . */
90 /*                   .              . */
91 /*                   .              . */
92 /*                  58            2058 */
93 /*                  59            2059 */
94 /*                 -------------------- */
95 /*                  60            1960 */
96 /*                  61            1961 */
97 /*                  62            1962 */
98 /*                   .              . */
99 /*                   .              . */
100 /*                   .              . */
101 /*                  99            1999 */
102 
103 /*                Note that if Space Command should decide to represent */
104 /*                years in 21st century as 100 + the last two digits */
105 /*                of the year (for example: 2015 is represented as 115) */
106 /*                instead of simply dropping the first two digits of */
107 /*                the year, this routine will correctly map the year */
108 /*                as long as you set FRSTYR to some value between 1900 */
109 /*                and 1999. */
110 
111 /*     LINES      is a pair of lines of text that comprise a Space */
112 /*                command ``two-line element'' set.  These text lines */
113 /*                should be the same as they are presented in the */
114 /*                two-line element files available from Space Command */
115 /*                (formerly NORAD). Below is an example of a two-line */
116 /*                set for TOPEX. */
117 
118 /*  TOPEX */
119 /*  1 22076U 92052A   97173.53461370 -.00000038  00000-0  10000-3 0   594 */
120 /*  2 22076  66.0378 163.4372 0008359 278.7732  81.2337 12.80930736227550 */
121 
122 
123 /* $ Detailed_Output */
124 
125 /*     EPOCH      is the epoch of the two line elements supplied via */
126 /*                the input array LINES.  Epoch is returned in TDB */
127 /*                seconds past J2000. */
128 
129 /*     ELEMS      is an array containing the elements from the two line */
130 /*                set supplied via the array LINES.  The elements are */
131 /*                in units suitable for use by the SPICE routine */
132 /*                EV2LIN. */
133 
134 /*                Also note that the elements XNDD6O and BSTAR */
135 /*                incorporate the exponential factor present in the */
136 /*                input two line elements in LINES.  (See particulars */
137 /*                below. */
138 
139 /*                    ELEMS (  1 ) = XNDT2O in radians/minute**2 */
140 /*                    ELEMS (  2 ) = XNDD6O in radians/minute**3 */
141 /*                    ELEMS (  3 ) = BSTAR */
142 /*                    ELEMS (  4 ) = XINCL  in radians */
143 /*                    ELEMS (  5 ) = XNODEO in radians */
144 /*                    ELEMS (  6 ) = EO */
145 /*                    ELEMS (  7 ) = OMEGAO in radians */
146 /*                    ELEMS (  8 ) = XMO    in radians */
147 /*                    ELEMS (  9 ) = XNO    in radians/minute */
148 /*                    ELEMS ( 10 ) = EPOCH of the elements in seconds */
149 /*                                   past ephemeris epoch J2000. */
150 
151 /* $ Parameters */
152 
153 /*     None. */
154 
155 /* $ Files */
156 
157 /*     You must have loaded a SPICE leapseconds kernel into the */
158 /*     kernel pool prior to caling this routine. */
159 
160 /* $ Exceptions */
161 
162 /*     1) If an error occurs while trying to parse the two-line element */
163 /*        set, the error 'SPICE(BADTLE)' signals. */
164 
165 /* $ Particulars */
166 
167 /*     This routine passes a Space Command Two-line element set */
168 /*     to the parsing routine ZZGETELM.  Input elements have the */
169 /*     form: */
170 
171 /*  1 22076U 92052A   97173.53461370 -.00000038  00000-0  10000-3 0   594 */
172 /*  2 22076  66.0378 163.4372 0008359 278.7732  81.2337 12.80930736227550 */
173 /*  ^ */
174 /*  123456789012345678901234567890123456789012345678901234567890123456789 */
175 /*           1         2         3         4         5         6 */
176 
177 /* $ Examples */
178 
179 /*     Suppose you have a set of two-line elements and an array */
180 /*     containing the related geophysical constants necessary */
181 /*     to evaluate a state.  The example below shows how you */
182 /*     can use this routine together with the routine EV2LIN to */
183 /*     propagate a state to an epoch of interest. */
184 
185 
186 /*        The parameters below will make it easier to make assignments */
187 /*        to the array GEOPHS required by EV2LIN. */
188 
189 /*        J2  --- location of J2 */
190 /*        J3  --- location of J3 */
191 /*        J4  --- location if J4 */
192 /*        KE  --- location of KE = sqrt(GM) in eart-radii**1.5/MIN */
193 /*        QO  --- location of upper bound of atmospheric model in KM */
194 /*        SO  --- location of lower bound of atmospheric model in KM */
195 /*        ER  --- location of earth equatorial radius in KM. */
196 /*        AE  --- location of distance units/earth radius */
197 
198 /*        PARAMETER           ( J2 = 1 ) */
199 /*        PARAMETER           ( J3 = 2 ) */
200 /*        PARAMETER           ( J4 = 3 ) */
201 /*        PARAMETER           ( KE = 4 ) */
202 /*        PARAMETER           ( QO = 5 ) */
203 /*        PARAMETER           ( SO = 6 ) */
204 /*        PARAMETER           ( ER = 7 ) */
205 /*        PARAMETER           ( AE = 8 ) */
206 
207 
208 /*        We set the lower bound for the years to be the beginning */
209 /*        of the space age. */
210 
211 /*        FRSTYR = 1957 */
212 
213 /*        Read in the next two lines from the text file that contains */
214 /*        the two-line elements.  We assume that file has been opened */
215 /*        properly and that we have set the ``file pointer'' to the */
216 /*        correct location for reading the next set of elements. */
217 
218 /*        READ  (UNIT,FMT='(A)' ) LINE(1) */
219 /*        READ  (UNIT,FMT='(A)' ) LINE(2) */
220 
221 /*        CALL GETELM ( FRSTYR, LINE, EPOCH, ELEMS ) */
222 
223 /*        Set up the geophysical quantities.  At last check these */
224 /*        were the values used by Space Command. */
225 
226 /*        GEOPHS( J2 ) =    1.082616D-3 */
227 /*        GEOPHS( J3 ) =   -2.53881D-6 */
228 /*        GEOPHS( J4 ) =   -1.65597D-6 */
229 /*        GEOPHS( KE ) =    7.43669161D-2 */
230 /*        GEOPHS( QO ) =  120.0D0 */
231 /*        GEOPHS( SO ) =   78.0D0 */
232 /*        GEOPHS( ER ) = 6378.135D0 */
233 /*        GEOPHS( AE ) =    1.0D0 */
234 
235 /*        Now propagate the state using EV2LIN to the epoch of */
236 /*        interest. */
237 
238 /*        CALL EV2LIN ( ET, GEOPHS, ELEMS, STATE ) */
239 
240 
241 /* $ Restrictions */
242 
243 /*    Please refer to the header of ZZGETELM. */
244 
245 /* $ Author_and_Institution */
246 
247 /*     W.L. Taber      (JPL) */
248 
249 /* $ Literature_References */
250 
251 /*     None. */
252 
253 /* $ Version */
254 
255 /* -    SPICELIB Version 3.0.0, 30-MAR-2004 (EDW) */
256 
257 /*        Routine now passes inputs to ZZGETELM then reponds to */
258 /*        any error condition. */
259 
260 /* -    SPICELIB Version 2.0.0, 03-MAR-2000 (WLT) */
261 
262 /*        The routine was modified to check that all of the terms */
263 /*        in the two-line element set are parsed correctly. */
264 
265 /* -    SPICELIB Version 1.0.0, 26-JUN-1997 (WLT) */
266 
267 
268 /* -& */
269 /* $ Index_Entries */
270 
271 /*     Parse two-line elements */
272 
273 /* -& */
274 
275 /*     Spicelib functions */
276 
277 
278 /*     Local. */
279 
280 
281 /*     Standard SPICE error handling. */
282 
283     if (return_()) {
284 	return 0;
285     }
286     chkin_("GETELM", (ftnlen)6);
287 
288 /*     Pass the input to the parse routine... */
289 
290     zzgetelm_(frstyr, lines, epoch, elems, &ok, error, lines_len, (ftnlen)256)
291 	    ;
292 
293 /*     ...check for an error parsing the TLE pair. Signal an */
294 /*     error if OK equals .FALSE. */
295 
296     if (! ok) {
297 	setmsg_("Error in TLE set. #", (ftnlen)19);
298 	errch_("#", error, (ftnlen)1, (ftnlen)256);
299 	sigerr_("SPICE(BADTLE)", (ftnlen)13);
300 	chkout_("GETELM", (ftnlen)6);
301 	return 0;
302     }
303     chkout_("GETELM", (ftnlen)6);
304     return 0;
305 } /* getelm_ */
306 
307