1 /* scps01.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__10 = 10;
11 
12 /* $Procedure       SCPS01 ( Convert type 1 SCLK string to ticks ) */
scps01_(integer * sc,char * clkstr,logical * error,char * msg,doublereal * ticks,ftnlen clkstr_len,ftnlen msg_len)13 /* Subroutine */ int scps01_(integer *sc, char *clkstr, logical *error, char *
14 	msg, doublereal *ticks, ftnlen clkstr_len, ftnlen msg_len)
15 {
16     /* Initialized data */
17 
18     static char namlst[60*3] = "SCLK01_N_FIELDS                             "
19 	    "                " "SCLK01_OFFSETS                               "
20 	    "               " "SCLK01_MODULI                                 "
21 	    "              ";
22 
23     /* System generated locals */
24     integer i__1, i__2, i__3, i__4;
25 
26     /* Builtin functions */
27     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
28     integer s_cmp(char *, char *, ftnlen, ftnlen), s_rnge(char *, integer,
29 	    char *, integer);
30     double d_nint(doublereal *);
31 
32     /* Local variables */
33     static integer pntr, i__, n;
34     extern /* Subroutine */ int scld01_(char *, integer *, integer *, integer
35 	    *, doublereal *, ftnlen), scli01_(char *, integer *, integer *,
36 	    integer *, integer *, ftnlen), chkin_(char *, ftnlen), repmc_(
37 	    char *, char *, char *, char *, ftnlen, ftnlen, ftnlen, ftnlen),
38 	    repmi_(char *, char *, integer *, char *, ftnlen, ftnlen, ftnlen);
39     extern logical failed_(void);
40     static integer nfield;
41     static doublereal cmpval[10], moduli[10], offset[10];
42     extern /* Subroutine */ int chkout_(char *, ftnlen), lparsm_(char *, char
43 	    *, integer *, integer *, char *, ftnlen, ftnlen, ftnlen);
44     static doublereal cmptks[10];
45     extern /* Subroutine */ int nparsd_(char *, doublereal *, char *, integer
46 	    *, ftnlen, ftnlen);
47     extern logical return_(void);
48     static char strerr[240], cmp[30*10];
49 
50 /* $ Abstract */
51 
52 /*     Convert a character representation of a type 1 spacecraft clock */
53 /*     count to ticks. */
54 
55 /* $ Disclaimer */
56 
57 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
58 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
59 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
60 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
61 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
62 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
63 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
64 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
65 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
66 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
67 
68 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
69 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
70 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
71 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
72 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
73 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
74 
75 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
76 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
77 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
78 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
79 
80 /* $ Required_Reading */
81 
82 /*     SCLK */
83 
84 /* $ Keywords */
85 
86 /*     CONVERSION */
87 /*     TIME */
88 
89 /* $ Declarations */
90 /* $ Abstract */
91 
92 /*     Include file sclk.inc */
93 
94 /*     SPICE private file intended solely for the support of SPICE */
95 /*     routines.  Users should not include this file directly due */
96 /*     to the volatile nature of this file */
97 
98 /*     The parameters below define sizes and limits used by */
99 /*     the SCLK system. */
100 
101 /* $ Disclaimer */
102 
103 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
104 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
105 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
106 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
107 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
108 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
109 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
110 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
111 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
112 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
113 
114 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
115 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
116 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
117 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
118 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
119 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
120 
121 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
122 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
123 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
124 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
125 
126 /* $ Parameters */
127 
128 /*     See the declaration section below. */
129 
130 /* $ Author_and_Institution */
131 
132 /*     N.J. Bachman    (JPL) */
133 
134 /* $ Literature_References */
135 
136 /*     None. */
137 
138 /* $ Version */
139 
140 /* -    SPICELIB Version 2.0.0, 24-MAY-2010 (NJB) */
141 
142 /*        Increased value of maximum coefficient record count */
143 /*        parameter MXCOEF from 10K to 50K. */
144 
145 /* -    SPICELIB Version 1.0.0, 11-FEB-2008 (NJB) */
146 
147 /* -& */
148 
149 /*     Number of supported SCLK field delimiters: */
150 
151 
152 /*     Supported SCLK string field delimiters: */
153 
154 
155 /*     Maximum number of partitions: */
156 
157 
158 /*     Partition string length. */
159 
160 /*     Since the maximum number of partitions is given by MXPART is */
161 /*     9999, PRTSTR needs at most 4 characters for the partition number */
162 /*     and one character for the slash. */
163 
164 
165 /*     Maximum number of coefficient records: */
166 
167 
168 /*     Maximum number of fields in an SCLK string: */
169 
170 
171 /*     Length of strings used to represent D.P. */
172 /*     numbers: */
173 
174 
175 /*     Maximum number of supported parallel time systems: */
176 
177 
178 /*     End of include file sclk.inc */
179 
180 /* $ Brief_I/O */
181 
182 /*     Variable  I/O  Description */
183 /*     --------  ---  -------------------------------------------------- */
184 /*     SC         I   NAIF spacecraft ID code. */
185 /*     CLKSTR     I   Character representation of a clock count. */
186 /*     ERROR      O   Parsing error flag. */
187 /*     MSG        O   Output message for parsing error. */
188 /*     TICKS      O   Number of ticks represented by the clock count. */
189 /*     MXNFLD     P   Maximum number of allowed fields in an SCLK string. */
190 /*     DELIMS     P   The accepted delimiters of an SCLK string. */
191 /*     DPLEN      P   Maximum width of a clock field. */
192 
193 /* $ Detailed_Input */
194 
195 /*     SC         is a NAIF spacecraft identification code.  See the */
196 /*                `Examples' section below, and also the NAIF_IDS */
197 /*                required reading file for a complete list of body ID */
198 /*                codes. */
199 
200 
201 /*     CLKSTR     on input is the character representation of a */
202 /*                spacecraft clock count (SCLK), without a partition */
203 /*                number. */
204 
205 /*                Using Galileo as an example, a SCLK string without */
206 /*                a partition number has the form */
207 
208 /*                               wwwwwwww:xx:y:z */
209 
210 /*                where z is a mod-8 counter (values 0-7) which */
211 /*                increments approximately once every 8 1/3 ms., y is a */
212 /*                mod-10 counter (values 0-9) which increments once */
213 /*                every time z turns over, i.e., approximately once every */
214 /*                66 2/3 ms., xx is a mod-91 (values 0-90) counter */
215 /*                which increments once every time y turns over, i.e., */
216 /*                once every 2/3 seconds. wwwwwwww is the Real-Time */
217 /*                Image Count (RIM), which increments once every time */
218 /*                xx turns over, i.e., once every 60 2/3 seconds. The */
219 /*                roll-over expression for the RIM is 16777215, which */
220 /*                corresponds to approximately 32 years. */
221 
222 /*                wwwwwwww, xx, y, and z are referred to interchangeably */
223 /*                as the fields or components of the spacecraft count. */
224 /*                SCLK components may be separated by any of the */
225 /*                single character delimiters in the string DELIMS, with */
226 /*                any number of spaces separating the components and */
227 /*                the delimiters. The presence of the RIM component */
228 /*                is required. Successive components may be omitted, and */
229 /*                in such cases are assumed to represent zero values. */
230 
231 /*                Values for the individual components may exceed the */
232 /*                maximum expected values. For instance, '0:0:0:9' is */
233 /*                an acceptable Galileo clock string, and indicates the */
234 /*                same time interval as '0:0:1:1'. */
235 
236 /*                Consecutive delimiters containing no intervening digits */
237 /*                are treated as if they delimit zero components, except */
238 /*                in the case of blanks.  Consecutive blanks are treated */
239 /*                as a single blank. */
240 
241 /*                Trailing zeros should always be included to match the */
242 /*                length of the counter.  For example, a Galileo clock */
243 /*                count of '25684.90' should not be represented as */
244 /*                '25684.9'. */
245 
246 /*                Some spacecraft clock components have offset, or */
247 /*                starting, values different from zero.  For example, */
248 /*                with an offset value of 1, a mod 20 counter would */
249 /*                cycle from 1 to 20 instead of from 0 to 19. */
250 
251 /*                See the SCLK required reading for a detailed */
252 /*                description of the Galileo, Mars Observer, and Voyager */
253 /*                clock formats. */
254 
255 /*                See the `Examples' section in SCPS01, below. */
256 
257 /* $ Detailed_Output */
258 
259 /*     ERROR      is true if an error occurred parsing the input clock */
260 /*                string and converting it to ticks. */
261 
262 /*     MSG        is the message generated if an error occurred parsing */
263 /*                the input clock string. */
264 
265 /*     TICKS      is the number of "ticks" corresponding to the input */
266 /*                spacecraft clock string CLKSTR.  "Ticks" are the units */
267 /*                in which encoded SCLK strings are represented. */
268 
269 /*                A typical Galileo SCLK string looks like */
270 
271 /*                             'wwwwwwww xx y z', */
272 
273 /*                as described above. Since z is the mod-8 (one tick) */
274 /*                counter, the number of ticks represented by y is 8*y. */
275 /*                And since y is the mod-10 counter, the number of ticks */
276 /*                represented by xx is 10*8*xx. The total number of */
277 /*                ticks represented by the above string is */
278 
279 /*                              wwwwwwww( 7280 ) + */
280 /*                                    xx(   80 ) + */
281 /*                                     y(    8 ) + */
282 /*                                     z */
283 
284 /*                Clock strings for other spacecraft are converted in */
285 /*                a similar manner. */
286 
287 /*                See Examples below. */
288 
289 /* $ Parameters */
290 
291 /*     See the INCLUDE file sclk.inc. */
292 
293 /* $ Exceptions */
294 
295 /*     1)  This routine assumes that that an SCLK kernel appropriate */
296 /*         to the spacecraft clock identified by the input argument SC */
297 /*         has been loaded.  If an SCLK kernel has not been loaded, */
298 /*         does not contain all of the required data, or contains */
299 /*         invalid data, error diagnoses will be performed by routines */
300 /*         called by this routine.  The output argument TICKS will not */
301 /*         be modified. */
302 
303 /*         The variables that must be set by the SCLK kernel are: */
304 
305 /*            -  The number of fields in an (unabridged) SCLK string */
306 /*            -  The output delimiter code */
307 /*            -  The parallel time system code */
308 /*            -  The moduli of the fields of an SCLK string */
309 /*            -  The offsets for each clock field. */
310 /*            -  The SCLK coefficients array */
311 /*            -  The partition start times */
312 /*            -  The partition end times */
313 
314 /*         When using SCLK kernels that map SCLK to a time system other */
315 /*         than ET (also called barycentric dynamical time---`TDB'), it */
316 /*         is necessary to have a leapseconds kernel loaded at the time */
317 /*         this routine is called.  If a leapseconds kernel is required */
318 /*         for conversion between SCLK and ET but is not loaded, the */
319 /*         error will be diagnosed by routines called by this routine. */
320 /*         The output argument TICKS will not be modified. */
321 
322 /*         The time system that an SCLK kernel maps SCLK to is indicated */
323 /*         by the variable SCLK_TIME_SYSTEM_nn in the kernel, where nn */
324 /*         is the negative of the NAIF integer code for the spacecraft. */
325 /*         The time system used in a kernel is TDB if and only if the */
326 /*         variable is assigned the value 1. */
327 
328 
329 /*     2)  If any of the following kernel variables have invalid values, */
330 /*         the error will be diagnosed by routines called by this */
331 /*         routine: */
332 
333 /*            -  The time system code */
334 /*            -  The number of SCLK coefficients */
335 /*            -  The number of partition start times */
336 /*            -  The number of partition end times */
337 /*            -  The number of fields of a SCLK string */
338 /*            -  The number of moduli for a SCLK string */
339 
340 /*         If the number of values for any item read from the kernel */
341 /*         pool exceeds the maximum allowed value, it is may not be */
342 /*         possible to diagnose the error correctly, since overwriting */
343 /*         of memory may occur.  This particular type of error is not */
344 /*         diagnosed by this routine. */
345 
346 
347 /*     3)  The input argument CLKSTR may be invalid for a variety of */
348 /*         reasons: */
349 
350 /*            -- One of the extracted clock components cannot be parsed */
351 /*               as an integer */
352 
353 /*            -- CLKSTR contains too many components */
354 
355 /*            -- the value  of one of the components is less than the */
356 /*               offset value */
357 
358 /*         If any of these conditions is detected, the error */
359 /*         SPICE(INVALIDSCLKSTRING) is signaled.  The output argument */
360 /*         TICKS will not be modified. */
361 
362 /* $ Files */
363 
364 /*     None. */
365 
366 /* $ Particulars */
367 
368 /*     This routine converts a character string representation of a */
369 /*     spacecraft clock count into the number of ticks represented */
370 /*     by the clock count.  An important distinction between this type */
371 /*     of conversion and that carried out by SCENCD is that this routine */
372 /*     treats spacecraft clock times as representations of time */
373 /*     intervals, not absolute times. */
374 
375 /*     This routine does not make use of any partition information. */
376 /*     See SCENCD for details on how to make use of partition numbers. */
377 
378 /* $ Examples */
379 
380 /*     1)  Below are some examples illustrating various inputs and the */
381 /*         resulting outputs for the Galileo spacecraft. */
382 
383 /*         CLKSTR                TICKS */
384 /*         ----------------      -------------------- */
385 /*         '0:0:0:1'             1 */
386 /*         '0:0:1'               8 */
387 /*         '0:1'                 80 */
388 /*         '1'                   7280 */
389 /*         '1 0 0 0'             7280 */
390 /*         '1,0,0,0'             7280 */
391 /*         '1:90'                14480 */
392 /*         '1:9'                 8000 */
393 /*         '1:09'                8000 */
394 /*         '0-0-10'              80   |--  Third component is supposed */
395 /*         '0-1-0'               80   |    to be a mod-10 count. */
396 /*         '0/1/0'               Error: '/' is not an accepted delimiter. */
397 /*         '1: 00 : 0 : 1'       7281 */
398 /*         '1:::1'               7281 */
399 /*         '1.1.1.1.1'           Error: Too many components */
400 /*         '1.1.1.1.'            Error: The last delimiter signals that */
401 /*                                      a fifth component will follow. */
402 
403 
404 /*         The following examples are for the Voyager 2 spacecraft. Note */
405 /*         that the last component of the Voyager clock has an offset */
406 /*         value of 1. */
407 
408 /*         CLKSTR                TICKS */
409 /*         ----------------      -------------------- */
410 /*         '0.0.001'             0 */
411 /*         '0:0:002'             1 */
412 /*         '0:01'                800 */
413 /*         '1'                   48000 */
414 /*         '1.0'                 48000 */
415 /*         '1.0.0'               Error: The 3rd component is never 0. */
416 /*         '0.0:100'             99 */
417 /*         '0-60-1'              48000 */
418 /*         '1-1-1'               48800 */
419 /*         '1-1-2'               48801 */
420 
421 
422 /* $ Restrictions */
423 
424 /*     1)  An SCLK kernel appropriate to the spacecraft clock identified */
425 /*         by SC must be loaded at the time this routine is called. */
426 
427 /*     2)  If the SCLK kernel used with this routine does not map SCLK */
428 /*         directly to barycentric dynamical time, a leapseconds kernel */
429 /*         must be loaded at the time this routine is called. */
430 
431 /* $ Literature_References */
432 
433 /*     None. */
434 
435 /* $ Author_and_Institution */
436 
437 /*     N.J. Bachman (JPL) */
438 /*     J.M. Lynch   (JPL) */
439 /*     R.E. Thurman (JPL) */
440 
441 /* $ Version */
442 
443 /* -    SPICELIB Version 1.1.0, 11-FEB-2008 (NJB) */
444 
445 /*        Global parameters are now declared in the Fortran */
446 /*        INCLUDE file sclk.inc. */
447 
448 /* -    SPICELIB Version 1.0.0, 25-FEB-1993 (JML) */
449 
450 /* -& */
451 /* $ Index_Entries */
452 
453 /*     convert type_1 spacecraft_clock string to ticks */
454 
455 /* -& */
456 
457 /*     SPICELIB functions */
458 
459 
460 /*     Local parameters */
461 
462 
463 /*     Following are parameters for the indices within the */
464 /*     array NAMLST of the kernel variable names. */
465 
466 
467 /*     Local variables */
468 
469 
470 /*     Save everything */
471 
472 
473 /*     Standard SPICE error handling. */
474 
475     if (return_()) {
476 	return 0;
477     } else {
478 	chkin_("SCPS01", (ftnlen)6);
479     }
480 
481 /*     Start off with the error flag and message set for a regular */
482 /*     SPICE error. */
483 
484     *error = TRUE_;
485     s_copy(msg, "SPICELIB error detected.", msg_len, (ftnlen)24);
486 
487 /*     Our first piece of business is to look up all of the data */
488 /*     we require from the kernel pool.  We must form the names */
489 /*     of the items we want using the input S/C ID code.  The items */
490 /*     we need are: */
491 
492 /*        -  The number of fields in an (unabridged) SCLK string */
493 /*        -  The moduli of the fields of an SCLK string */
494 /*        -  The offsets for each clock field. */
495 
496     scli01_(namlst, sc, &c__10, &n, &nfield, (ftnlen)60);
497     scld01_(namlst + 120, sc, &c__10, &n, moduli, (ftnlen)60);
498     scld01_(namlst + 60, sc, &c__10, &n, offset, (ftnlen)60);
499 
500 /*     Don't try to continue if we had a lookup error. */
501 
502     if (failed_()) {
503 	chkout_("SCPS01", (ftnlen)6);
504 	return 0;
505     }
506 
507 /*     If our clock string is blank, we can stop now. */
508 
509     if (s_cmp(clkstr, " ", clkstr_len, (ftnlen)1) == 0) {
510 	s_copy(msg, "Non partition part of the input clock string is blank.",
511 		msg_len, (ftnlen)54);
512 	*error = TRUE_;
513 	chkout_("SCPS01", (ftnlen)6);
514 	return 0;
515     }
516 
517 /*     Determine how many ticks is each field is worth. */
518 
519     cmptks[(i__1 = nfield - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("cmptks",
520 	    i__1, "scps01_", (ftnlen)464)] = 1.;
521     for (i__ = nfield - 1; i__ >= 1; --i__) {
522 	cmptks[(i__1 = i__ - 1) < 10 && 0 <= i__1 ? i__1 : s_rnge("cmptks",
523 		i__1, "scps01_", (ftnlen)467)] = cmptks[(i__2 = i__) < 10 &&
524 		0 <= i__2 ? i__2 : s_rnge("cmptks", i__2, "scps01_", (ftnlen)
525 		467)] * moduli[(i__3 = i__) < 10 && 0 <= i__3 ? i__3 : s_rnge(
526 		"moduli", i__3, "scps01_", (ftnlen)467)];
527     }
528 
529 /*     Parse the clock components from the input string. There should */
530 /*     be at most NFIELD of them, but, in order to check for too long */
531 /*     a clock string, we'll let LPARSM take up to MXNFLD components and */
532 /*     then test for an error. */
533 
534     lparsm_(clkstr, ".:-, ", &c__10, &n, cmp, clkstr_len, (ftnlen)5, (ftnlen)
535 	    30);
536 
537 /*     If the string has too many fields for the specified spacecraft */
538 /*     then signal an error. */
539 
540     if (n > nfield) {
541 	*error = TRUE_;
542 	s_copy(msg, "Input clock string # has # fields; maximum for this spa"
543 		"cecraft clock is #.", msg_len, (ftnlen)74);
544 	repmc_(msg, "#", clkstr, msg, msg_len, (ftnlen)1, clkstr_len, msg_len)
545 		;
546 	repmi_(msg, "#", &n, msg, msg_len, (ftnlen)1, msg_len);
547 	repmi_(msg, "#", &nfield, msg, msg_len, (ftnlen)1, msg_len);
548 	chkout_("SCPS01", (ftnlen)6);
549 	return 0;
550     }
551 
552 /*     Convert each of the components into numbers.  Error if any */
553 /*     of the conversions screw up. */
554 
555     i__1 = n;
556     for (i__ = 1; i__ <= i__1; ++i__) {
557 	if (s_cmp(cmp + ((i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
558 		"cmp", i__2, "scps01_", (ftnlen)504)) * 30, " ", (ftnlen)30, (
559 		ftnlen)1) == 0) {
560 	    cmpval[(i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge("cmpval"
561 		    , i__2, "scps01_", (ftnlen)505)] = offset[(i__3 = i__ - 1)
562 		     < 10 && 0 <= i__3 ? i__3 : s_rnge("offset", i__3, "scps"
563 		    "01_", (ftnlen)505)];
564 	} else {
565 	    nparsd_(cmp + ((i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
566 		    "cmp", i__2, "scps01_", (ftnlen)507)) * 30, &cmpval[(i__3
567 		    = i__ - 1) < 10 && 0 <= i__3 ? i__3 : s_rnge("cmpval",
568 		    i__3, "scps01_", (ftnlen)507)], strerr, &pntr, (ftnlen)30,
569 		     (ftnlen)240);
570 	}
571 	if (s_cmp(strerr, " ", (ftnlen)240, (ftnlen)1) != 0) {
572 	    *error = TRUE_;
573 	    s_copy(msg, "Could not parse SCLK component # from # as a number."
574 		    , msg_len, (ftnlen)52);
575 	    repmc_(msg, "#", cmp + ((i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2
576 		    : s_rnge("cmp", i__2, "scps01_", (ftnlen)517)) * 30, msg,
577 		    msg_len, (ftnlen)1, (ftnlen)30, msg_len);
578 	    repmc_(msg, "#", clkstr, msg, msg_len, (ftnlen)1, clkstr_len,
579 		    msg_len);
580 	    chkout_("SCPS01", (ftnlen)6);
581 	    return 0;
582 	}
583 
584 /*        Subtract off the offset value so that we can do base ten */
585 /*        arithmetic.  Also, if any of the components become negative */
586 /*        as a result of the subtraction, then that component must */
587 /*        have been invalid. */
588 
589 	cmpval[(i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge("cmpval",
590 		i__2, "scps01_", (ftnlen)531)] = cmpval[(i__3 = i__ - 1) < 10
591 		&& 0 <= i__3 ? i__3 : s_rnge("cmpval", i__3, "scps01_", (
592 		ftnlen)531)] - offset[(i__4 = i__ - 1) < 10 && 0 <= i__4 ?
593 		i__4 : s_rnge("offset", i__4, "scps01_", (ftnlen)531)];
594 	if (d_nint(&cmpval[(i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
595 		"cmpval", i__2, "scps01_", (ftnlen)533)]) < 0.) {
596 	    *error = TRUE_;
597 	    s_copy(msg, "Component number #, # in the SCLK string  # is inva"
598 		    "lid.", msg_len, (ftnlen)55);
599 	    repmi_(msg, "#", &i__, msg, msg_len, (ftnlen)1, msg_len);
600 	    repmc_(msg, "#", cmp + ((i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2
601 		    : s_rnge("cmp", i__2, "scps01_", (ftnlen)541)) * 30, msg,
602 		    msg_len, (ftnlen)1, (ftnlen)30, msg_len);
603 	    repmc_(msg, "#", clkstr, msg, msg_len, (ftnlen)1, clkstr_len,
604 		    msg_len);
605 	    chkout_("SCPS01", (ftnlen)6);
606 	    return 0;
607 	}
608     }
609 
610 /*     Convert to ticks by multiplying the value of each component by */
611 /*     the number of ticks each component count represents, and then */
612 /*     add up the results. */
613 
614     *ticks = 0.;
615     i__1 = n;
616     for (i__ = 1; i__ <= i__1; ++i__) {
617 	*ticks += cmpval[(i__2 = i__ - 1) < 10 && 0 <= i__2 ? i__2 : s_rnge(
618 		"cmpval", i__2, "scps01_", (ftnlen)559)] * cmptks[(i__3 = i__
619 		- 1) < 10 && 0 <= i__3 ? i__3 : s_rnge("cmptks", i__3, "scps"
620 		"01_", (ftnlen)559)];
621     }
622     *error = FALSE_;
623     s_copy(msg, " ", msg_len, (ftnlen)1);
624     chkout_("SCPS01", (ftnlen)6);
625     return 0;
626 } /* scps01_ */
627 
628