1 /* sce2c.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      SCE2C ( ET to continuous SCLK ticks ) */
sce2c_(integer * sc,doublereal * et,doublereal * sclkdp)9 /* Subroutine */ int sce2c_(integer *sc, doublereal *et, doublereal *sclkdp)
10 {
11     /* System generated locals */
12     integer i__1;
13 
14     /* Local variables */
15     extern /* Subroutine */ int scec01_(integer *, doublereal *, doublereal *)
16 	    , chkin_(char *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
17 	     ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer *,
18 	    ftnlen);
19     extern integer sctype_(integer *);
20     extern logical return_(void);
21 
22 /* $ Abstract */
23 
24 /*     Convert ephemeris seconds past J2000 (ET) to continuous encoded */
25 /*     spacecraft clock (`ticks').  Non-integral tick values may be */
26 /*     returned. */
27 
28 /* $ Disclaimer */
29 
30 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
31 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
32 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
33 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
34 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
35 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
36 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
37 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
38 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
39 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
40 
41 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
42 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
43 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
44 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
45 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
46 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
47 
48 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
49 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
50 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
51 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
52 
53 /* $ Required_Reading */
54 
55 /*     SCLK */
56 /*     TIME */
57 
58 /* $ Keywords */
59 
60 /*     CONVERSION */
61 /*     TIME */
62 
63 /* $ Declarations */
64 /* $ Brief_I/O */
65 
66 /*     Variable  I/O  Description */
67 /*     --------  ---  -------------------------------------------------- */
68 /*     SC         I   NAIF spacecraft ID code. */
69 /*     ET         I   Ephemeris time, seconds past J2000. */
70 /*     SCLKDP     O   SCLK, encoded as ticks since spacecraft clock */
71 /*                    start.  SCLKDP need not be integral. */
72 
73 /* $ Detailed_Input */
74 
75 /*     SC             is a NAIF integer code for a spacecraft whose */
76 /*                    encoded SCLK value at the epoch specified by ET is */
77 /*                    desired. */
78 
79 /*     ET             is an epoch, specified as ephemeris seconds past */
80 /*                    J2000. */
81 
82 /* $ Detailed_Output */
83 
84 /*     SCLKDP         is an encoded spacecraft clock value.  SCLKDP is */
85 /*                    an encoded representation of the total number */
86 /*                    of spacecraft clock ticks measured from the time */
87 /*                    the spacecraft clock started to the epoch ET: */
88 /*                    partition information IS reflected in the encoded */
89 /*                    value. */
90 
91 /*                    SCLKDP may be non-integral:  SCLKDP is NOT */
92 /*                    rounded to the nearest whole tick. */
93 
94 /* $ Parameters */
95 
96 /*     None. */
97 
98 /* $ Exceptions */
99 
100 /*     1)  This routine assumes that that an SCLK kernel appropriate */
101 /*         to the spacecraft clock identified by the input argument SC */
102 /*         has been loaded.  If an SCLK kernel has not been loaded, */
103 /*         does not contain all of the required data, or contains */
104 /*         invalid data, error diagnoses will be performed by routines */
105 /*         called by this routine.  The output argument SCLKDP will not */
106 /*         be modified. */
107 
108 /*     2)  When using SCLK kernels that map SCLK to a time system other */
109 /*         than ET (also called barycentric dynamical time---`TDB'), it */
110 /*         is necessary to have a leapseconds kernel loaded at the time */
111 /*         this routine is called.  If a leapseconds kernel is required */
112 /*         for conversion between SCLK and ET but is not loaded, the */
113 /*         error will be diagnosed by routines called by this routine. */
114 /*         The output argument SCLKDP will not be modified. */
115 
116 /*         The time system that an SCLK kernel maps SCLK to is indicated */
117 /*         by the variable SCLK_TIME_SYSTEM_nn in the kernel, where nn */
118 /*         is the negative of the NAIF integer code for the spacecraft. */
119 /*         The time system used in a kernel is TDB if and only if the */
120 /*         variable is assigned the value 1. */
121 
122 /*     3)  If the clock type for the spacecraft clock identified by */
123 /*         SC is not supported by this routine, the error */
124 /*         SPICE(NOTSUPPORTED) is signalled.  The output argument SCLKDP */
125 /*         will not be modified. */
126 
127 /*     4)  If the input ET value is not representable as an encoded */
128 /*         spacecraft clock value for the spacecraft clock identified by */
129 /*         SC, the error will be diagnosed by routines called by this */
130 /*         routine.  The output argument SCLKDP will not be modified. */
131 
132 /* $ Files */
133 
134 /*     None. */
135 
136 /* $ Particulars */
137 
138 /*     This routine outputs continuous encoded SCLK values; unlike the */
139 /*     routine SCE2T, the values output by this routine need not be */
140 /*     integral. */
141 
142 /*     This routine supports use of non-integral encoded clock values in */
143 /*     C-kernels:  non-integral clock values may be stored as pointing */
144 /*     time tags when a C-kernel is created, and they may be supplied */
145 /*     as request times to the C-kernel readers. */
146 
147 /*     The advantage of encoded SCLK, as opposed to character string */
148 /*     representations of SCLK, is that encoded SCLK values are easy to */
149 /*     perform arithmetic operations on.  Also, working with encoded SCLK */
150 /*     reduces the overhead of repeated conversion of  character strings */
151 /*     to integers or double precision numbers. */
152 
153 /*     To convert ET to a string representation of an SCLK value, use */
154 /*     the SPICELIB routine SCE2S. */
155 
156 /*     See the SCLK Required Reading for a list of the entire set of */
157 /*     SCLK conversion routines. */
158 
159 /* $ Examples */
160 
161 /*     1)  Convert ET directly to an encoded SCLK value; use both of */
162 /*         these time values to look up both C-kernel (pointing) and */
163 /*         SPK (position and velocity) data for an epoch specified by an */
164 /*         ephemeris time. */
165 
166 /*            During program initialization, load the leapseconds and */
167 /*            SCLK kernels.  We will pretend that these files are named */
168 /*            "LEAPSECONDS.KER" and "GLLSCLK.KER".  To use this code */
169 /*            fragment, you must substitute the actual names of these */
170 /*            kernel files for the names used here. */
171 
172 /*               C */
173 /*               C     Load leapseconds and SCLK kernels: */
174 /*               C */
175 /*                     CALL FURNSH ( 'LEAPSECONDS.KER' ) */
176 /*                     CALL FURNSH ( 'GLLSCLK.KER'     ) */
177 
178 /*            The mission is Galileo, which has spacecraft ID -77. */
179 /*            Let ET be the epoch, specified in ephemeris seconds */
180 /*            past J2000, at which both position and pointing data */
181 /*            are desired. */
182 
183 /*            Find the continuous encoded SCLK value corresponding to ET. */
184 
185 /*                     CALL SCE2C  ( -77,  ET,  SCLKDP ) */
186 
187 /*            Now you're ready to call both CKGP, which expects the input */
188 /*            epoch to be specified by an encoded SCLK string, and */
189 /*            SPKEZ, which expects the epoch to be specified as an */
190 /*            ephemeris time. */
191 
192 /*               C */
193 /*               C     Find scan platform pointing CMAT and s/c--target */
194 /*               C     vector (first 3 components of STATE) at epoch. */
195 /*               C     We assume that CK and SPK kernels have been loaded */
196 /*               C     already, via CKLPF and SPKLEF respectively. */
197 /*               C */
198 /*                     CALL CKGP  ( SCANPL, */
199 /*                    .             SCLKDP, */
200 /*                    .             TOL, */
201 /*                    .             REFSYS, */
202 /*                    .             CMAT, */
203 /*                    .             CLKOUT, */
204 /*                    .             FOUND   ) */
205 
206 /*                     CALL SPKEZ ( TARGET, */
207 /*                    .             ET, */
208 /*                    .             REFSYS, */
209 /*                    .             CORR, */
210 /*                    .             -77, */
211 /*                    .             STATE, */
212 /*                    .             LT      ) */
213 
214 
215 /*     2)  Convert UTC to a continuous encoded Voyager 2 SCLK value. */
216 
217 /*            Again, your initialization code must load the leapseconds */
218 /*            and SCLK kernels. */
219 
220 /*               C */
221 /*               C     Load leapseconds and SCLK kernels: */
222 /*               C */
223 /*                     CALL FURNSH ( 'LEAPSECONDS.KER' ) */
224 /*                     CALL FURNSH ( 'VGR2SCLK.KER'    ) */
225 
226 
227 /*            To find the encoded Voyager 2 SCLK value SCLKDP */
228 /*            corresponding to a UTC time, you can use the code fragment */
229 
230 /*                     CALL UTC2ET ( UTC,  ET          ) */
231 /*                     CALL SCE2C  ( -32,  ET,  SCLKDP ) */
232 
233 /* $ Restrictions */
234 
235 /*     1)  An SCLK kernel appropriate to the spacecraft clock identified */
236 /*         by SC must be loaded at the time this routine is called. */
237 
238 /*     2)  If the SCLK kernel used with this routine does not map SCLK */
239 /*         directly to barycentric dynamical time, a leapseconds kernel */
240 /*         must be loaded at the time this routine is called. */
241 
242 /* $ Literature_References */
243 
244 /*     [1]  CK Required Reading */
245 
246 /*     [2]  SPK Required Reading */
247 
248 /* $ Author_and_Institution */
249 
250 /*     N.J. Bachman   (JPL) */
251 
252 /* $ Version */
253 
254 /* -    SPICELIB Version 1.0.1, 22-AUG-2006 (EDW) */
255 
256 /*        Replaced references to LDPOOL with references */
257 /*        to FURNSH. */
258 
259 /* -    SPICELIB Version 1.0.0, 09-MAR-1999 (NJB) */
260 
261 /* -& */
262 /* $ Index_Entries */
263 
264 /*     ephemeris time to continuous spacecraft_clock ticks */
265 
266 /* -& */
267 
268 /*     SPICELIB functions */
269 
270 
271 /*     Standard SPICE error handling. */
272 
273     if (return_()) {
274 	return 0;
275     } else {
276 	chkin_("SCE2C", (ftnlen)5);
277     }
278 
279 /*     Just hand off the conversion to the appropriate routine. */
280 
281     if (sctype_(sc) == 1) {
282 	scec01_(sc, et, sclkdp);
283     } else {
284 	setmsg_("Clock type # is not supported.", (ftnlen)30);
285 	i__1 = sctype_(sc);
286 	errint_("#", &i__1, (ftnlen)1);
287 	sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
288 	chkout_("SCE2C", (ftnlen)5);
289 	return 0;
290     }
291     chkout_("SCE2C", (ftnlen)5);
292     return 0;
293 } /* sce2c_ */
294 
295