1 /* scpars.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__1 = 1;
11 static integer c__9999 = 9999;
12
13 /* $Procedure SCPARS ( Parse a spacecraft clock string ) */
scpars_(integer * sc,char * sclkch,logical * error,char * msg,doublereal * sclkdp,ftnlen sclkch_len,ftnlen msg_len)14 /* Subroutine */ int scpars_(integer *sc, char *sclkch, logical *error, char *
15 msg, doublereal *sclkdp, ftnlen sclkch_len, ftnlen msg_len)
16 {
17 /* System generated locals */
18 integer i__1, i__2, i__3, i__4, i__5;
19 doublereal d__1;
20
21 /* Builtin functions */
22 /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
23 integer s_cmp(char *, char *, ftnlen, ftnlen);
24 double d_nint(doublereal *);
25 integer s_rnge(char *, integer, char *, integer);
26
27 /* Local variables */
28 extern integer cpos_(char *, char *, integer *, ftnlen, ftnlen);
29 integer part, i__;
30 extern /* Subroutine */ int chkin_(char *, ftnlen), repmc_(char *, char *,
31 char *, char *, ftnlen, ftnlen, ftnlen, ftnlen), scps01_(integer
32 *, char *, logical *, char *, doublereal *, ftnlen, ftnlen),
33 repmi_(char *, char *, integer *, char *, ftnlen, ftnlen, ftnlen);
34 doublereal ticks;
35 integer dtype, pnter;
36 char psmsg[255];
37 logical pserr;
38 doublereal pstop[9999];
39 extern logical failed_(void);
40 extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
41 ftnlen), scpart_(integer *, integer *, doublereal *, doublereal *)
42 , nparsi_(char *, integer *, char *, integer *, ftnlen, ftnlen),
43 setmsg_(char *, ftnlen), errint_(char *, integer *, ftnlen);
44 extern integer sctype_(integer *);
45 integer nparts;
46 doublereal pstart[9999];
47 extern logical return_(void);
48 char strerr[255];
49 doublereal ptotls[9999];
50 integer pos;
51
52 /* $ Abstract */
53
54 /* Parse a character representation of spacecraft clock time and */
55 /* encode it as a double precision number. */
56
57 /* $ Disclaimer */
58
59 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
60 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
61 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
62 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
63 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
64 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
65 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
66 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
67 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
68 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
69
70 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
71 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
72 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
73 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
74 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
75 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
76
77 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
78 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
79 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
80 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
81
82 /* $ Required_Reading */
83
84 /* SCLK */
85
86 /* $ Keywords */
87
88 /* CONVERSION */
89 /* TIME */
90
91 /* $ Declarations */
92 /* $ Abstract */
93
94 /* Include file sclk.inc */
95
96 /* SPICE private file intended solely for the support of SPICE */
97 /* routines. Users should not include this file directly due */
98 /* to the volatile nature of this file */
99
100 /* The parameters below define sizes and limits used by */
101 /* the SCLK system. */
102
103 /* $ Disclaimer */
104
105 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
106 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
107 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
108 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
109 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
110 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
111 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
112 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
113 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
114 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
115
116 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
117 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
118 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
119 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
120 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
121 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
122
123 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
124 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
125 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
126 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
127
128 /* $ Parameters */
129
130 /* See the declaration section below. */
131
132 /* $ Author_and_Institution */
133
134 /* N.J. Bachman (JPL) */
135
136 /* $ Literature_References */
137
138 /* None. */
139
140 /* $ Version */
141
142 /* - SPICELIB Version 2.0.0, 24-MAY-2010 (NJB) */
143
144 /* Increased value of maximum coefficient record count */
145 /* parameter MXCOEF from 10K to 50K. */
146
147 /* - SPICELIB Version 1.0.0, 11-FEB-2008 (NJB) */
148
149 /* -& */
150
151 /* Number of supported SCLK field delimiters: */
152
153
154 /* Supported SCLK string field delimiters: */
155
156
157 /* Maximum number of partitions: */
158
159
160 /* Partition string length. */
161
162 /* Since the maximum number of partitions is given by MXPART is */
163 /* 9999, PRTSTR needs at most 4 characters for the partition number */
164 /* and one character for the slash. */
165
166
167 /* Maximum number of coefficient records: */
168
169
170 /* Maximum number of fields in an SCLK string: */
171
172
173 /* Length of strings used to represent D.P. */
174 /* numbers: */
175
176
177 /* Maximum number of supported parallel time systems: */
178
179
180 /* End of include file sclk.inc */
181
182 /* $ Brief_I/O */
183
184 /* Variable I/O Description */
185 /* -------- --- -------------------------------------------------- */
186 /* SC I NAIF spacecraft identification code. */
187 /* SCLKCH I Character representation of a spacecraft clock. */
188 /* ERROR O Flag to indicate if string parsed correctly. */
189 /* MSG O Error message if string did not parse. */
190 /* SCLKDP O Encoded representation of the clock count. */
191 /* MXPART P Maximum number of spacecraft clock partitions. */
192
193 /* $ Detailed_Input */
194
195 /* SC is the standard NAIF ID of the spacecraft whose clock's */
196 /* time is being encoded. */
197
198 /* SCLKCH is the character representation of some spacecraft's */
199 /* clock count. */
200
201 /* SCLKCH will have the following general format: */
202
203 /* 'pp/sclk_string', or just */
204 /* 'sclk_string' */
205
206 /* 'pp' is an integer greater than or equal to one */
207 /* and is called the partition number. */
208
209 /* Each mission is divided into some number of partitions. */
210 /* A new partition starts when the spacecraft clock */
211 /* resets, either to zero, or to some other */
212 /* value. Thus, the first partition for any mission */
213 /* starts with launch, and ends with the first clock */
214 /* reset. The second partition starts immediately when */
215 /* the first stopped, and so on. */
216
217 /* In order to be completely unambiguous about a */
218 /* particular time, you need to specify a partition number */
219 /* along with the standard clock string. */
220
221 /* Information about when partitions occur for different */
222 /* missions is contained in a spacecraft clock kernel */
223 /* file, which needs to be loaded into the kernel pool, */
224 /* using the routines CLPOOL and FURNSH. */
225
226 /* The routine SCPART is used to read the partition */
227 /* start and stop times, in encoded units of SCLK (called */
228 /* "ticks" -- see SCLKDP below) from the kernel file. */
229
230 /* If the partition number is included, it must be */
231 /* separated from the rest of the string by a '/'. */
232 /* Any number of spaces may separate the partition number, */
233 /* the '/', and the rest of the clock string. */
234
235
236 /* If the partition number is omitted, a default partition */
237 /* will be assumed. The default partition is the lowest- */
238 /* numbered partition that contains the given clock time. */
239 /* If the clock time does not fall in any of the */
240 /* partition boundaries then an error is signaled. */
241
242
243 /* 'sclk_string' is a spacecraft specific clock string. */
244 /* Using Galileo as an example, the full format is */
245
246 /* wwwwwwww:xx:y:z */
247
248 /* where z is a mod-8 counter (values 0-7) which */
249 /* increments approximately once every 8 1/3 ms., y is a */
250 /* mod-10 counter (values 0-9) which increments once */
251 /* every time z turns over, i.e., approximately once every */
252 /* 66 2/3 ms., xx is a mod-91 (values 0-90) counter */
253 /* which increments once every time y turns over, i.e., */
254 /* once every 2/3 seconds. wwwwwwww is the Real-Time Image */
255 /* Count (RIM), which increments once every time xx turns */
256 /* over, i.e., once every 60 2/3 seconds. The roll-over */
257 /* expression for the RIM is 16777215, which corresponds */
258 /* to approximately 32 years. */
259
260 /* wwwwwwww, xx, y, and z are referred to interchangeably */
261 /* as the fields or components of the spacecraft clock. */
262 /* SCLK components may be separated by any of these */
263 /* five characters: ' ' ':' ',' '-' '.' */
264 /* Any number of spaces can separate the components and */
265 /* the delimiters. The presence of the RIM component */
266 /* is required. Successive components may be omitted, and */
267 /* in such cases are assumed to represent zero values. */
268
269 /* Values for the individual components may exceed the */
270 /* maximum expected values. For instance, '0:0:0:9' is */
271 /* an acceptable Galileo clock string, and will convert */
272 /* to the same number of ticks as '0:0:1:1'. */
273
274 /* Consecutive delimiters containing no intervening digits */
275 /* are treated as if they delimit zero components. */
276
277 /* Trailing zeros should always be included to match the */
278 /* length of the counter. For example, a Galileo clock */
279 /* count of '25684.90' should not be represented as */
280 /* '25684.9'. */
281
282 /* Some spacecraft clock components have offset, or */
283 /* starting, values different from zero. For example, */
284 /* with an offset value of 1, a mod 20 counter would */
285 /* cycle from 1 to 20 instead of from 0 to 19. */
286
287 /* See the SCLK required reading for a detailed */
288 /* description of the Voyager and Mars Observer clock */
289 /* formats. */
290
291
292 /* $ Detailed_Output */
293
294 /* ERROR is true if an error occurred parsing the input clock */
295 /* string and converting it to ticks. */
296
297 /* MSG is the message generated if an error occurred parsing */
298 /* the input clock string. */
299
300 /* SCLKDP is the double precision encoding of SCLKCH. */
301
302 /* The encoding is such that order and proximity will be */
303 /* preserved. That is, if t1, t2, and t3 are spacecraft */
304 /* clock times, and t1*, t2*, and t3* are their encodings, */
305 /* then if */
306
307 /* t1 < t2 < t3, and */
308
309 /* t2 is closer to t1 than to t3, you will have the result */
310 /* that */
311
312 /* t1* < t2* < t3*, and */
313
314 /* t2* is closer to t1* than to t3*. */
315
316 /* The units of encoded SCLK are "ticks since the start of */
317 /* the mission", where a "tick" is defined to be the */
318 /* shortest time increment expressible by a particular */
319 /* spacecraft's clock. */
320
321 /* Each clock string without partition number represents */
322 /* a certain number of ticks, but you need to include */
323 /* partition information to determine the relative */
324 /* position of that time in relation to the start of the */
325 /* mission. */
326
327 /* Since the end time of one partition is coincident */
328 /* with the begin time of the next, there are two */
329 /* different representations for this instant, and they */
330 /* will both yield the same encoding. */
331
332 /* For example, if partition 1 has an end time of t1, and */
333 /* partition 2 has a begin time of t2, then if we did */
334
335 /* CALL SCENCD ( '1/t1', SC, X ) and */
336 /* CALL SCENCD ( '2/t2', SC, Y ), then */
337
338 /* X = Y. */
339
340 /* The individual routines TIKSnn, where nn is the */
341 /* clock type code, contain more detailed information */
342 /* on the conversion process. */
343
344 /* $ Parameters */
345
346 /* MXPART is the maximum number of spacecraft clock partitions */
347 /* expected in the kernel file for any one spacecraft. */
348 /* See the INCLUDE file sclk.inc for this parameter's */
349 /* value. */
350
351 /* $ Exceptions */
352
353 /* This routine uses both the normal SPICELIB error handling and */
354 /* an ERROR flag and message. Errors that deal with kernel pool */
355 /* data that is missing or invalid are treated in the usual way. */
356 /* Errors that arise solely from parsing the input clock string */
357 /* do not signal SPICELIB errors, but instead use the ERROR flag */
358 /* and MSG string. */
359
360 /* In the case of any SPICELIB error occuring, ERROR is initialized */
361 /* to .TRUE. and MSG to "SPICELIB error detected.". */
362
363
364 /* 1) If the number of partitions in the kernel file for spacecraft */
365 /* SC excceds the parameter MXPART, the error */
366 /* 'SPICE(TOOMANYPARTS)' is signaled. */
367
368 /* 2) If the data type of the clock for the specified spacecraft is */
369 /* of a data type not recognized by this routine, the error */
370 /* 'SPICE(NOTSUPPORTED)' is signaled. */
371
372
373 /* If a partition number is included in the SCLK string, the */
374 /* following errors may occur: */
375
376 /* 3) The partition number cannot be parsed as an integer. */
377
378 /* 4) The partition number is not in the range of the number of */
379 /* partitions found in the kernel pool. */
380
381 /* 5) The clock count does not fall in the boundaries of the */
382 /* specified partition. */
383
384
385 /* If a partition number is not included in the SCLK string, the */
386 /* following exception may occur. */
387
388 /* 6) The clock count does not fall in the boundaries of any */
389 /* partition found in the kernel pool. */
390
391 /* The actual parsing of the remainder of the clock string is */
392 /* performed by data type specific routines. The error handling */
393 /* in those routines works in a similar manner to this one. */
394
395 /* $ Files */
396
397 /* A kernel file containing spacecraft clock partition information */
398 /* for the desired spaceraft must be loaded, using the routines */
399 /* CLPOOL and FURNSH, before calling this routine. */
400
401 /* $ Particulars */
402
403 /* In general, it is difficult to compare spacecraft clock counts */
404 /* numerically since there are too many clock components for a */
405 /* single comparison. This routine provides a method of assigning a */
406 /* single double precision number to a spacecraft's clock count, */
407 /* given one of its character representations. */
408
409 /* The routine SCDECD performs the inverse operation to SCENCD, */
410 /* converting an encoded double precision number to character format. */
411
412 /* To convert the string to ticks since the start of the mission, */
413 /* SCENCD */
414
415 /* 1) Converts the non-partition portion of the string to */
416 /* ticks, using the routine SCTIKS. */
417
418 /* 2) Determines the partition number for the clock time, */
419 /* either by getting it directly from the input string, or */
420 /* determining the default partition if none was specified. */
421
422 /* 3) Includes partition start and stop times, which are also */
423 /* measured in ticks, to compute the number of ticks */
424 /* since the beginning of the mission of the clock time. */
425
426 /* $ Examples */
427
428 /* Double precision encodings of spacecraft clock counts are used to */
429 /* tag pointing data in the C-kernel. */
430
431 /* In the following example, pointing for a sequence of images from */
432 /* the Voyager 2 narrow angle camera is requested from the C-kernel */
433 /* using an array of character spacecraft clock counts as input. */
434 /* The clock counts attached to the output are then decoded to */
435 /* character and compared with the input strings. */
436
437 /* CHARACTER*(25) SCLKIN ( 4 ) */
438 /* CHARACTER*(25) SCLKOUT */
439 /* CHARACTER*(25) CLKTOL */
440
441 /* DOUBLE PRECISION TIMEIN */
442 /* DOUBLE PRECISION TIMOUT */
443 /* DOUBLE PRECISION CMAT ( 3, 3 ) */
444
445 /* INTEGER NPICS */
446 /* INTEGER SC */
447
448 /* DATA NPICS / 4 / */
449
450 /* DATA SCLKIN / '2 / 20538:39:768', */
451 /* . '2 / 20543:21:768', */
452 /* . '2 / 20550:37', */
453 /* . '2 / 20561:59' / */
454
455 /* DATA CLKTOL / ' 0:01:000' / */
456
457 /* C */
458 /* C The instrument we want pointing for is the Voyager 2 */
459 /* C narrow angle camera. The reference frame we want is */
460 /* C J2000. The spacecraft is Voyager 2. */
461 /* C */
462 /* INST = -32001 */
463 /* REF = 'J2000' */
464 /* SC = -32 */
465
466 /* C */
467 /* C Load the appropriate files. We need */
468 /* C */
469 /* C 1) CK file containing pointing data. */
470 /* C 2) Spacecraft clock kernel file, for SCENCD and SCDECD. */
471 /* C */
472 /* CALL CKLPF ( 'VGR2NA.CK' ) */
473 /* CALL CLPOOL */
474 /* CALL FURNSH ( 'SCLK.KER' ) */
475
476 /* C */
477 /* C Convert the tolerance string to ticks. */
478 /* C */
479 /* CALL SCTIKS ( SC, CLKTOL, TOL ) */
480
481 /* DO I = 1, NPICS */
482
483 /* CALL SCENCD ( SC, SCLKIN( I ), TIMEIN ) */
484
485 /* CALL CKGP ( INST, TIMEIN, TOL, REF, CMAT, TIMOUT, */
486 /* . FOUND ) */
487
488 /* CALL SCDECD ( SC, TIMOUT, SCLKOUT ) */
489
490 /* WRITE (*,*) */
491 /* WRITE (*,*) 'Input s/c clock count: ', SCLKIN( I ) */
492 /* WRITE (*,*) 'Output s/c clock count: ', SCLKOUT */
493 /* WRITE (*,*) 'Output C-Matrix: ', CMAT */
494 /* WRITE (*,*) */
495
496 /* END DO */
497
498 /* The output from such a program might look like: */
499
500
501 /* Input s/c clock count: 2 / 20538:39:768 */
502 /* Output s/c clock count: 2/20538:39:768 */
503 /* Output C-Matrix: 'first C-matrix' */
504
505 /* Input s/c clock count: 2 / 20543:21:768 */
506 /* Output s/c clock count: 2/20543:22:768 */
507 /* Output C-Matrix: 'second C-matrix' */
508
509 /* Input s/c clock count: 2 / 20550:37 */
510 /* Output s/c clock count: 2/20550:36:768 */
511 /* Output C-Matrix: 'third C-matrix' */
512
513 /* Input s/c clock count: 2 / 20561:59 */
514 /* Output s/c clock count: 2/20561:58:768 */
515 /* Output C-Matrix: 'fourth C-matrix' */
516
517 /* $ Restrictions */
518
519 /* None. */
520
521 /* $ Literature_References */
522
523 /* None. */
524
525 /* $ Author_and_Institution */
526
527 /* N.J. Bachman (JPL) */
528 /* J.M. Lynch (JPL) */
529 /* R.E. Thurman (JPL) */
530
531 /* $ Version */
532
533 /* - SPICELIB Version 1.2.0, 05-FEB-2008 (NJB) */
534
535 /* The values of parameter MXPART and is now */
536 /* provided by the INCLUDE file sclk.inc. */
537
538 /* - SPICELIB Version 1.1.1, 22-AUG-2006 (EDW) */
539
540 /* Replaced references to LDPOOL with references */
541 /* to FURNSH. */
542
543 /* - SPICELIB Version 1.1.0, 18-JUN-1999 (WLT) */
544
545 /* Make CHKIN and CHKOUT arguments consistent. */
546
547 /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
548
549 /* Comment section for permuted index source lines was added */
550 /* following the header. */
551
552 /* - SPICELIB Version 1.0.0, 03-SEP-1990 (JML) (RET) */
553
554 /* -& */
555 /* $ Index_Entries */
556
557 /* encode spacecraft_clock */
558
559 /* -& */
560
561 /* SPICELIB functions */
562
563
564 /* Local variables */
565
566
567 /* Standard SPICE error handling. */
568
569 if (return_()) {
570 return 0;
571 } else {
572 chkin_("SCPARS", (ftnlen)6);
573 }
574
575 /* This routine handles errors in two different ways. */
576
577 /* 1) Errors relating to parsing the input clock string */
578 /* will not use the normal SPICELIB error handling. */
579 /* Instead they will use the ERROR and MSG arguments */
580 /* to this routine. */
581
582 /* 2) Errors relating to missing or invalid data in the */
583 /* kernel pool will use the normal SPICELIB error */
584 /* handling. */
585
586 /* In the event that a SPICE error occurs somewhere, ERROR */
587 /* and MSG will be initialized to the following values: */
588
589 *error = TRUE_;
590 s_copy(msg, "SPICELIB error detected.", msg_len, (ftnlen)24);
591
592 /* First check if the string is blank. */
593
594 if (s_cmp(sclkch, " ", sclkch_len, (ftnlen)1) == 0) {
595 *error = TRUE_;
596 s_copy(msg, "Input spacecraft clock string is blank.", msg_len, (
597 ftnlen)39);
598 chkout_("SCPARS", (ftnlen)6);
599 return 0;
600 }
601
602 /* Convert the non-partition clock string to a tick value. */
603 /* This conversion depends on the data type of the clock. */
604
605 pos = cpos_(sclkch, "/", &c__1, sclkch_len, (ftnlen)1);
606 dtype = sctype_(sc);
607 if (failed_()) {
608 chkout_("SCPARS", (ftnlen)6);
609 return 0;
610 }
611 if (dtype == 1) {
612 i__1 = pos;
613 scps01_(sc, sclkch + i__1, &pserr, psmsg, &ticks, sclkch_len - i__1, (
614 ftnlen)255);
615 } else {
616 setmsg_("Clock type # is not supported.", (ftnlen)30);
617 errint_("#", &dtype, (ftnlen)1);
618 sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
619 chkout_("SCPARS", (ftnlen)6);
620 return 0;
621 }
622
623 /* Check if the SCPSxx routine encoutered a problem. */
624
625 if (pserr) {
626 *error = TRUE_;
627 s_copy(msg, psmsg, msg_len, (ftnlen)255);
628 chkout_("SCPARS", (ftnlen)6);
629 return 0;
630 }
631
632 /* Find the partition that this clock time falls in. */
633
634
635 /* Read the partition start and stop times (in ticks) for this */
636 /* mission. Error if there are too many of them. */
637
638 scpart_(sc, &nparts, pstart, pstop);
639 if (failed_()) {
640 chkout_("SCPARS", (ftnlen)6);
641 return 0;
642 }
643 if (nparts > 9999) {
644 setmsg_("The number of partitions, #, for spacecraft # exceeds the v"
645 "alue for parameter MXPART, #.", (ftnlen)88);
646 errint_("#", &nparts, (ftnlen)1);
647 errint_("#", sc, (ftnlen)1);
648 errint_("#", &c__9999, (ftnlen)1);
649 sigerr_("SPICE(TOOMANYPARTS)", (ftnlen)19);
650 chkout_("SCPARS", (ftnlen)6);
651 return 0;
652 }
653
654 /* For each partition, compute the total number of ticks in that */
655 /* partition plus all preceding partitions. */
656
657 d__1 = pstop[0] - pstart[0];
658 ptotls[0] = d_nint(&d__1);
659 i__1 = nparts;
660 for (i__ = 2; i__ <= i__1; ++i__) {
661 d__1 = ptotls[(i__3 = i__ - 2) < 9999 && 0 <= i__3 ? i__3 : s_rnge(
662 "ptotls", i__3, "scpars_", (ftnlen)588)] + pstop[(i__4 = i__
663 - 1) < 9999 && 0 <= i__4 ? i__4 : s_rnge("pstop", i__4, "scp"
664 "ars_", (ftnlen)588)] - pstart[(i__5 = i__ - 1) < 9999 && 0 <=
665 i__5 ? i__5 : s_rnge("pstart", i__5, "scpars_", (ftnlen)588)];
666 ptotls[(i__2 = i__ - 1) < 9999 && 0 <= i__2 ? i__2 : s_rnge("ptotls",
667 i__2, "scpars_", (ftnlen)588)] = d_nint(&d__1);
668 }
669
670 /* Determine the partition number for the input clock string: */
671
672 /* If it was included in the string make sure it's valid for */
673 /* this mission. */
674
675 /* Error if */
676
677 /* 1) The partition number can't be parsed. */
678
679 /* 2) The partition number is not in the range 1 to the number */
680 /* of partitions. */
681
682 /* 3) The clock count does not fall in the boundaries of the */
683 /* specified partition. */
684
685 /* If it wasn't included, determine the default partition for */
686 /* this clock count. */
687
688 /* Error if */
689
690 /* 1) The clock count does not fall in the boundaries of any */
691 /* of the partitions. */
692
693
694 if (pos == 1) {
695
696 /* The slash character is first character in the string which */
697 /* means that the partition number is not there. */
698
699 s_copy(msg, "Unable to parse the partition number from SCLK string #."
700 , msg_len, (ftnlen)56);
701 repmc_(msg, "#", sclkch, msg, msg_len, (ftnlen)1, sclkch_len, msg_len)
702 ;
703 chkout_("SCPARS", (ftnlen)6);
704 return 0;
705 } else if (pos > 1) {
706
707 /* Try to parse the partition number. */
708
709 part = 0;
710 nparsi_(sclkch, &part, strerr, &pnter, pos - 1, (ftnlen)255);
711
712 /* Make sure that the number parsed is correct. */
713
714 if (s_cmp(strerr, " ", (ftnlen)255, (ftnlen)1) != 0) {
715
716 /* Was not able to parse a number. */
717
718 s_copy(msg, "Unable to parse the partition number from SCLK stri"
719 "ng #.", msg_len, (ftnlen)56);
720 repmc_(msg, "#", sclkch, msg, msg_len, (ftnlen)1, sclkch_len,
721 msg_len);
722 chkout_("SCPARS", (ftnlen)6);
723 return 0;
724 } else if (part <= 0 || part > nparts) {
725
726 /* The parsed number does not fall in the range of valid */
727 /* numbers. */
728
729 s_copy(msg, "Partition number # taken from SCLK string # is not "
730 "in acceptable range 1 to #.", msg_len, (ftnlen)78);
731 repmi_(msg, "#", &part, msg, msg_len, (ftnlen)1, msg_len);
732 repmc_(msg, "#", sclkch, msg, msg_len, (ftnlen)1, sclkch_len,
733 msg_len);
734 repmi_(msg, "#", &nparts, msg, msg_len, (ftnlen)1, msg_len);
735 chkout_("SCPARS", (ftnlen)6);
736 return 0;
737 } else if (ticks < pstart[(i__1 = part - 1) < 9999 && 0 <= i__1 ?
738 i__1 : s_rnge("pstart", i__1, "scpars_", (ftnlen)673)] ||
739 ticks > pstop[(i__2 = part - 1) < 9999 && 0 <= i__2 ? i__2 :
740 s_rnge("pstop", i__2, "scpars_", (ftnlen)673)]) {
741
742 /* The TICKS value does not fall in the range of valid */
743 /* values for the partition number parsed from the input */
744 /* clock string. */
745
746 s_copy(msg, "SCLK count from # does not fall in the boundaries o"
747 "f partition number #.", msg_len, (ftnlen)72);
748 i__1 = pos;
749 repmc_(msg, "#", sclkch + i__1, msg, msg_len, (ftnlen)1,
750 sclkch_len - i__1, msg_len);
751 repmi_(msg, "#", &part, msg, msg_len, (ftnlen)1, msg_len);
752 chkout_("SCPARS", (ftnlen)6);
753 return 0;
754 }
755 } else {
756
757 /* The partition number was not included in the string. */
758 /* Determine the partition from the TICKS value that the */
759 /* clock string converted to. */
760
761 part = 1;
762 while(part <= nparts && (ticks < pstart[(i__1 = part - 1) < 9999 && 0
763 <= i__1 ? i__1 : s_rnge("pstart", i__1, "scpars_", (ftnlen)
764 702)] || ticks > pstop[(i__2 = part - 1) < 9999 && 0 <= i__2 ?
765 i__2 : s_rnge("pstop", i__2, "scpars_", (ftnlen)702)])) {
766 ++part;
767 }
768 if (part > nparts) {
769 s_copy(msg, "SCLK count # does not fall in the boundaries of any"
770 " of the partitions for spacecraft #.", msg_len, (ftnlen)
771 87);
772 i__1 = pos;
773 repmc_(msg, "#", sclkch + i__1, msg, msg_len, (ftnlen)1,
774 sclkch_len - i__1, msg_len);
775 repmi_(msg, "#", sc, msg, msg_len, (ftnlen)1, msg_len);
776 chkout_("SCPARS", (ftnlen)6);
777 return 0;
778 }
779 }
780
781 /* Now we have a valid partition number, and the number of ticks for */
782 /* the clock string. To convert to ticks since the start of the */
783 /* mission, add in the total number of ticks in preceding partitions */
784 /* and subtract off the starting ticks value for this partition. */
785
786 if (part > 1) {
787 *sclkdp = ticks - pstart[(i__1 = part - 1) < 9999 && 0 <= i__1 ? i__1
788 : s_rnge("pstart", i__1, "scpars_", (ftnlen)733)] + ptotls[(
789 i__2 = part - 2) < 9999 && 0 <= i__2 ? i__2 : s_rnge("ptotls",
790 i__2, "scpars_", (ftnlen)733)];
791 } else {
792 *sclkdp = ticks - pstart[(i__1 = part - 1) < 9999 && 0 <= i__1 ? i__1
793 : s_rnge("pstart", i__1, "scpars_", (ftnlen)735)];
794 }
795 *error = FALSE_;
796 s_copy(msg, " ", msg_len, (ftnlen)1);
797 chkout_("SCPARS", (ftnlen)6);
798 return 0;
799 } /* scpars_ */
800
801