1 /* ckcov.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__2 = 2;
11 static integer c__6 = 6;
12
13 /* $Procedure CKCOV ( CK coverage ) */
ckcov_(char * ck,integer * idcode,logical * needav,char * level,doublereal * tol,char * timsys,doublereal * cover,ftnlen ck_len,ftnlen level_len,ftnlen timsys_len)14 /* Subroutine */ int ckcov_(char *ck, integer *idcode, logical *needav, char *
15 level, doublereal *tol, char *timsys, doublereal *cover, ftnlen
16 ck_len, ftnlen level_len, ftnlen timsys_len)
17 {
18 /* System generated locals */
19 integer i__1;
20 doublereal d__1;
21
22 /* Builtin functions */
23 integer s_cmp(char *, char *, ftnlen, ftnlen), s_rnge(char *, integer,
24 char *, integer);
25
26 /* Local variables */
27 char arch[80];
28 logical avok;
29 extern /* Subroutine */ int sct2e_(integer *, doublereal *, doublereal *);
30 integer i__;
31 extern /* Subroutine */ int dafgs_(doublereal *);
32 integer clkid;
33 extern /* Subroutine */ int chkin_(char *, ftnlen);
34 doublereal descr[5];
35 extern /* Subroutine */ int dafus_(doublereal *, integer *, integer *,
36 doublereal *, integer *), errch_(char *, char *, ftnlen, ftnlen);
37 doublereal dctol[2];
38 logical istdb, found;
39 extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen);
40 integer dtype;
41 extern logical eqstr_(char *, char *, ftnlen, ftnlen);
42 doublereal dc[2];
43 integer ic[6];
44 extern /* Subroutine */ int daffna_(logical *);
45 extern logical failed_(void);
46 extern /* Subroutine */ int dafbfs_(integer *);
47 doublereal et;
48 integer handle, segbeg;
49 extern /* Subroutine */ int dafcls_(integer *), ckmeta_(integer *, char *,
50 integer *, ftnlen);
51 integer segend;
52 extern /* Subroutine */ int getfat_(char *, char *, char *, ftnlen,
53 ftnlen, ftnlen), dafopr_(char *, integer *, ftnlen), sigerr_(char
54 *, ftnlen);
55 logical seglvl;
56 extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
57 ftnlen), wninsd_(doublereal *, doublereal *, doublereal *),
58 errint_(char *, integer *, ftnlen);
59 char kertyp[80];
60 extern logical return_(void);
61 extern /* Subroutine */ int zzckcv01_(integer *, integer *, integer *,
62 integer *, doublereal *, char *, doublereal *, ftnlen), zzckcv02_(
63 integer *, integer *, integer *, integer *, doublereal *, char *,
64 doublereal *, ftnlen), zzckcv03_(integer *, integer *, integer *,
65 integer *, doublereal *, char *, doublereal *, ftnlen), zzckcv04_(
66 integer *, integer *, integer *, integer *, doublereal *, char *,
67 doublereal *, ftnlen), zzckcv05_(integer *, integer *, integer *,
68 integer *, doublereal *, doublereal *, char *, doublereal *,
69 ftnlen), zzckcv06_(integer *, integer *, integer *, integer *,
70 doublereal *, doublereal *, char *, doublereal *, ftnlen);
71
72 /* $ Abstract */
73
74 /* Find the coverage window for a specified object in a specified CK */
75 /* file. */
76
77 /* $ Disclaimer */
78
79 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
80 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
81 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
82 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
83 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
84 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
85 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
86 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
87 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
88 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
89
90 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
91 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
92 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
93 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
94 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
95 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
96
97 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
98 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
99 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
100 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
101
102 /* $ Required_Reading */
103
104 /* CELLS */
105 /* DAF */
106 /* CK */
107 /* TIME */
108 /* WINDOWS */
109
110 /* $ Keywords */
111
112 /* POINTING */
113 /* TIME */
114 /* UTILITY */
115
116 /* $ Declarations */
117 /* $ Brief_I/O */
118
119 /* Variable I/O Description */
120 /* -------- --- -------------------------------------------------- */
121 /* CK I Name of CK file. */
122 /* IDCODE I ID code of object. */
123 /* NEEDAV I Flag indicating whether angular velocity is needed. */
124 /* LEVEL I Coverage level: 'SEGMENT' OR 'INTERVAL'. */
125 /* TOL I Tolerance in ticks. */
126 /* TIMSYS I Time system used to represent coverage. */
127 /* COVER I/O Window giving coverage for IDCODE. */
128
129 /* $ Detailed_Input */
130
131 /* CK is the name of a C-kernel. */
132
133 /* IDCODE is the integer ID code of an object, normally */
134 /* a spacecraft structure or instrument, for which */
135 /* pointing data are expected to exist in the */
136 /* specified CK file. */
137
138 /* NEEDAV is a logical variable indicating whether only */
139 /* segments having angular velocity are to be */
140 /* considered when determining coverage. When */
141 /* NEEDAV is .TRUE., segments without angular */
142 /* velocity don't contribute to the coverage */
143 /* window; when NEEDAV is .FALSE., all segments for */
144 /* IDCODE may contribute to the coverage window. */
145
146
147 /* LEVEL is the level (granularity) at which the coverage */
148 /* is examined. Allowed values and corresponding */
149 /* meanings are: */
150
151 /* 'SEGMENT' The output coverage window */
152 /* contains intervals defined by the */
153 /* start and stop times of segments */
154 /* for the object designated by */
155 /* IDCODE. */
156
157 /* 'INTERVAL' The output coverage window */
158 /* contains interpolation intervals */
159 /* of segments for the object */
160 /* designated by IDCODE. For type 1 */
161 /* segments, which don't have */
162 /* interpolation intervals, each */
163 /* epoch associated with a pointing */
164 /* instance is treated as a singleton */
165 /* interval; these intervals are */
166 /* added to the coverage window. */
167
168 /* All interpolation intervals are */
169 /* considered to lie within the */
170 /* segment bounds for the purpose of */
171 /* this summary: if an interpolation */
172 /* interval extends beyond the */
173 /* segment coverage interval, only */
174 /* its intersection with the segment */
175 /* coverage interval is considered to */
176 /* contribute to the total coverage. */
177
178
179 /* TOL is a tolerance value expressed in ticks of the */
180 /* spacecraft clock associated with IDCODE. Before */
181 /* each interval is inserted into the coverage */
182 /* window, the interval is intersected with the */
183 /* segment coverage interval, then if the */
184 /* intersection is non-empty, it is expanded by TOL: */
185 /* the left endpoint of the intersection interval is */
186 /* reduced by TOL and the right endpoint is increased */
187 /* by TOL. Adjusted interval endpoints, when */
188 /* expressed as encoded SCLK, never are less than */
189 /* zero ticks. Any intervals that overlap as a */
190 /* result of the expansion are merged. */
191
192 /* The coverage window returned when TOL > 0 */
193 /* indicates the coverage provided by the file to the */
194 /* CK readers CKGPAV and CKGP when that value of TOL */
195 /* is passed to them as an input. */
196
197
198 /* TIMSYS is a string indicating the time system used */
199 /* in the output coverage window. TIMSYS may */
200 /* have the values: */
201
202 /* 'SCLK' Elements of COVER are expressed in */
203 /* encoded SCLK ("ticks"), where the */
204 /* clock is associated with the object */
205 /* designated by IDCODE. */
206
207 /* 'TDB' Elements of COVER are expressed as */
208 /* seconds past J2000 TDB. */
209
210
211 /* COVER is an initialized SPICELIB window data structure. */
212 /* COVER optionally may contain coverage data on */
213 /* input; on output, the data already present in */
214 /* COVER will be combined with coverage found for the */
215 /* object designated by IDCODE in the file CK. */
216
217 /* If COVER contains no data on input, its size and */
218 /* cardinality still must be initialized. */
219
220 /* $ Detailed_Output */
221
222 /* COVER is a SPICELIB window data structure which */
223 /* represents the merged coverage for IDCODE. When */
224 /* the coverage level is 'INTERVAL', this is the set */
225 /* of time intervals for which data for IDCODE are */
226 /* present in the file CK, merged with the set of */
227 /* time intervals present in COVER on input. The */
228 /* merged coverage is represented as the union of one */
229 /* or more disjoint time intervals. The window COVER */
230 /* contains the pairs of endpoints of these */
231 /* intervals. */
232
233 /* When the coverage level is 'SEGMENT', COVER is */
234 /* computed in a manner similar to that described */
235 /* above, but the coverage intervals used in the */
236 /* computation are those of segments rather than */
237 /* interpolation intervals within segments. */
238
239 /* When TOL is > 0, the intervals comprising the */
240 /* coverage window for IDCODE are expanded by TOL and */
241 /* any intervals overlapping as a result are merged. */
242 /* The resulting window is returned in COVER. The */
243 /* expanded window in no case extends beyond the */
244 /* segment bounds in either direction by more than */
245 /* TOL. */
246
247 /* The interval endpoints contained in COVER are */
248 /* encoded spacecraft clock times if TIMSYS is */
249 /* 'SCLK'; otherwise the times are converted from */
250 /* encoded spacecraft clock to seconds past J2000 */
251 /* TDB. */
252
253 /* See the Examples section below for a complete */
254 /* example program showing how to retrieve the */
255 /* endpoints from COVER. */
256
257 /* $ Parameters */
258
259 /* None. */
260
261 /* $ Exceptions */
262
263 /* 1) If the input file has transfer format, the error */
264 /* SPICE(INVALIDFORMAT) is signaled. */
265
266 /* 2) If the input file is not a transfer file but has architecture */
267 /* other than DAF, the error SPICE(BADARCHTYPE) is signaled. */
268
269 /* 3) If the input file is a binary DAF file of type other than */
270 /* CK, the error SPICE(BADFILETYPE) is signaled. */
271
272 /* 4) If the CK file cannot be opened or read, the error will */
273 /* be diagnosed by routines called by this routine. The output */
274 /* window will not be modified. */
275
276 /* 5) If the size of the output WINDOW argument COVER is */
277 /* insufficient to contain the actual number of intervals in the */
278 /* coverage window for IDCODE, the error will be diagnosed by */
279 /* routines called by this routine. */
280
281 /* 6) If TOL is negative, the error SPICE(VALUEOUTOFRANGE) is */
282 /* signaled. */
283
284 /* 7) If LEVEL is not recognized, the error SPICE(INVALIDOPTION) */
285 /* is signaled. */
286
287 /* 8) If TIMSYS is not recognized, the error SPICE(NOTSUPPORTED) */
288 /* is signaled. */
289
290 /* 9) If a time conversion error occurs, the error will be */
291 /* diagnosed by a routine in the call tree of this routine. */
292
293 /* 10) If the output time system is TDB, the CK subsystem must be */
294 /* able to map IDCODE to the ID code of the associated */
295 /* spacecraft clock. If this mapping cannot be performed, the */
296 /* error will be diagnosed by a routine in the call tree of this */
297 /* routine. */
298
299 /* $ Files */
300
301 /* This routine reads a C-kernel. */
302
303 /* If the output time system is 'TDB', then a leapseconds kernel */
304 /* and an SCLK kernel for the spacecraft clock associated with */
305 /* IDCODE must be loaded before this routine is called. */
306
307 /* If the ID code of the clock associated with IDCODE is not */
308 /* equal to */
309
310 /* IDCODE / 1000 */
311
312 /* then the kernel variable */
313
314 /* CK_<IDCODE>_SCLK */
315
316 /* must be present in the kernel pool to identify the clock */
317 /* associated with IDCODE. This variable must contain the ID code */
318 /* to be used for conversion between SCLK and TDB. Normally this */
319 /* variable is provided in a text kernel loaded via FURNSH. */
320
321 /* $ Particulars */
322
323 /* This routine provides an API via which applications can determine */
324 /* the coverage a specified CK file provides for a specified */
325 /* object. */
326
327 /* $ Examples */
328
329 /* 1) Display the interval-level coverage for each object in a */
330 /* specified CK file. Use tolerance of zero ticks. Do not */
331 /* request angular velocity. Express the results in the TDB time */
332 /* system. */
333
334 /* Find the set of objects in the file. Loop over the contents */
335 /* of the ID code set: find the coverage for each item in the */
336 /* set and display the coverage. */
337
338
339 /* PROGRAM CKCVR */
340 /* IMPLICIT NONE */
341
342 /* C */
343 /* C SPICELIB functions */
344 /* C */
345 /* INTEGER WNCARD */
346 /* INTEGER CARDI */
347 /* C */
348 /* C Local parameters */
349 /* C */
350 /* C */
351 /* C Declare the coverage window. Make enough room */
352 /* C for MAXIV intervals. */
353 /* C */
354 /* INTEGER FILSIZ */
355 /* PARAMETER ( FILSIZ = 255 ) */
356
357 /* INTEGER LBCELL */
358 /* PARAMETER ( LBCELL = -5 ) */
359
360 /* INTEGER MAXIV */
361 /* PARAMETER ( MAXIV = 100000 ) */
362
363 /* INTEGER WINSIZ */
364 /* PARAMETER ( WINSIZ = 2 * MAXIV ) */
365
366 /* INTEGER TIMLEN */
367 /* PARAMETER ( TIMLEN = 50 ) */
368
369 /* INTEGER MAXOBJ */
370 /* PARAMETER ( MAXOBJ = 1000 ) */
371
372 /* C */
373 /* C Local variables */
374 /* C */
375 /* CHARACTER*(FILSIZ) CK */
376 /* CHARACTER*(FILSIZ) LSK */
377 /* CHARACTER*(FILSIZ) SCLK */
378 /* CHARACTER*(TIMLEN) TIMSTR */
379
380 /* DOUBLE PRECISION B */
381 /* DOUBLE PRECISION COVER ( LBCELL : WINSIZ ) */
382 /* DOUBLE PRECISION E */
383
384 /* INTEGER I */
385 /* INTEGER IDS ( LBCELL : MAXOBJ ) */
386 /* INTEGER J */
387 /* INTEGER NIV */
388
389 /* C */
390 /* C Load a leapseconds kernel and SCLK kernel for output */
391 /* C time conversion. Note that we assume a single spacecraft */
392 /* C clock is associated with all of the objects in the CK. */
393 /* C */
394 /* CALL PROMPT ( 'Name of leapseconds kernel > ', LSK ) */
395 /* CALL FURNSH ( LSK ) */
396
397 /* CALL PROMPT ( 'Name of SCLK kernel > ', SCLK ) */
398 /* CALL FURNSH ( SCLK ) */
399
400 /* C */
401 /* C Get name of CK file. */
402 /* C */
403 /* CALL PROMPT ( 'Name of CK file > ', CK ) */
404
405 /* C */
406 /* C Initialize the set IDS. */
407 /* C */
408 /* CALL SSIZEI ( MAXOBJ, IDS ) */
409
410 /* C */
411 /* C Initialize the window COVER. */
412 /* C */
413 /* CALL SSIZED ( WINSIZ, COVER ) */
414
415 /* C */
416 /* C Find the set of objects in the CK file. */
417 /* C */
418 /* CALL CKOBJ ( CK, IDS ) */
419
420 /* C */
421 /* C We want to display the coverage for each object. Loop */
422 /* C over the contents of the ID code set, find the coverage */
423 /* C for each item in the set, and display the coverage. */
424 /* C */
425 /* DO I = 1, CARDI( IDS ) */
426 /* C */
427 /* C Find the coverage window for the current */
428 /* C object. Empty the coverage window each time */
429 /* C so we don't include data for the previous object. */
430 /* C */
431 /* CALL SCARDD ( 0, COVER ) */
432 /* CALL CKCOV ( CK, IDS(I), .FALSE., */
433 /* . 'INTERVAL', 0.D0, 'TDB', COVER ) */
434
435 /* C */
436 /* C Get the number of intervals in the coverage */
437 /* C window. */
438 /* C */
439 /* NIV = WNCARD( COVER ) */
440
441 /* C */
442 /* C Display a simple banner. */
443 /* C */
444 /* WRITE (*,*) '========================================' */
445 /* WRITE (*,*) 'Coverage for object ', IDS(I) */
446
447 /* C */
448 /* C Convert the coverage interval start and stop */
449 /* C times to TDB calendar strings. */
450 /* C */
451 /* DO J = 1, NIV */
452 /* C */
453 /* C Get the endpoints of the Jth interval. */
454 /* C */
455 /* CALL WNFETD ( COVER, J, B, E ) */
456 /* C */
457 /* C Convert the endpoints to TDB calendar */
458 /* C format time strings and display them. */
459 /* C */
460 /* CALL TIMOUT ( B, */
461 /* . 'YYYY MON DD HR:MN:SC.###### ' // */
462 /* . '(TDB) ::TDB', */
463 /* . TIMSTR ) */
464 /* WRITE (*,*) ' ' */
465 /* WRITE (*,*) 'Interval: ', J */
466 /* WRITE (*,*) 'Start: ', TIMSTR */
467
468 /* CALL TIMOUT ( E, */
469 /* . 'YYYY MON DD HR:MN:SC.###### ' // */
470 /* . '(TDB) ::TDB', */
471 /* . TIMSTR ) */
472 /* WRITE (*,*) 'Stop: ', TIMSTR */
473 /* WRITE (*,*) ' ' */
474
475 /* END DO */
476
477 /* WRITE (*,*) '========================================' */
478
479 /* END DO */
480
481 /* END */
482
483
484 /* 2) Find the segment-level coverage for the object designated by */
485 /* IDCODE provided by the set of CK files loaded via a */
486 /* metakernel. (The metakernel must also specify leapseconds and */
487 /* SCLK kernels.) Use tolerance of zero ticks. Do not request */
488 /* angular velocity. Express the results in the TDB time system. */
489
490 /* PROGRAM CKMET */
491 /* IMPLICIT NONE */
492 /* C */
493 /* C SPICELIB functions */
494 /* C */
495 /* INTEGER WNCARD */
496
497 /* C */
498 /* C Local parameters */
499 /* C */
500 /* INTEGER LBCELL */
501 /* PARAMETER ( LBCELL = -5 ) */
502
503 /* INTEGER FILSIZ */
504 /* PARAMETER ( FILSIZ = 255 ) */
505
506 /* INTEGER LNSIZE */
507 /* PARAMETER ( LNSIZE = 80 ) */
508
509 /* INTEGER MAXCOV */
510 /* PARAMETER ( MAXCOV = 100000 ) */
511
512 /* INTEGER TIMLEN */
513 /* PARAMETER ( TIMLEN = 50 ) */
514
515 /* C */
516 /* C Local variables */
517 /* C */
518 /* CHARACTER*(FILSIZ) FILE */
519 /* CHARACTER*(LNSIZE) IDCH */
520 /* CHARACTER*(FILSIZ) META */
521 /* CHARACTER*(FILSIZ) SOURCE */
522 /* CHARACTER*(TIMLEN) TIMSTR */
523 /* CHARACTER*(LNSIZE) TYPE */
524
525 /* DOUBLE PRECISION B */
526 /* DOUBLE PRECISION COVER ( LBCELL : 2*MAXCOV ) */
527 /* DOUBLE PRECISION E */
528
529 /* INTEGER COUNT */
530 /* INTEGER HANDLE */
531 /* INTEGER I */
532 /* INTEGER IDCODE */
533 /* INTEGER NIV */
534
535 /* LOGICAL FOUND */
536
537 /* C */
538 /* C Prompt for the metakernel name; load the metakernel. */
539 /* C The metakernel lists the CK files whose coverage */
540 /* C for IDCODE we'd like to determine. The metakernel */
541 /* C must also specify a leapseconds kernel and an SCLK */
542 /* C kernel for the clock associated with IDCODE. */
543 /* C */
544 /* CALL PROMPT ( 'Enter name of metakernel > ', META ) */
545
546 /* CALL FURNSH ( META ) */
547
548 /* C */
549 /* C Get the ID code of interest. */
550 /* C */
551 /* CALL PROMPT ( 'Enter ID code > ', IDCH ) */
552
553 /* CALL PRSINT ( IDCH, IDCODE ) */
554
555 /* C */
556 /* C Initialize the coverage window. */
557 /* C */
558 /* CALL SSIZED ( MAXCOV, COVER ) */
559
560 /* C */
561 /* C Find out how many kernels are loaded. Loop over the */
562 /* C kernels: for each loaded CK file, add its coverage */
563 /* C for IDCODE, if any, to the coverage window. */
564 /* C */
565 /* CALL KTOTAL ( 'CK', COUNT ) */
566
567 /* DO I = 1, COUNT */
568
569 /* CALL KDATA ( I, 'CK', FILE, TYPE, */
570 /* . SOURCE, HANDLE, FOUND ) */
571
572 /* CALL CKCOV ( FILE, IDCODE, .FALSE., */
573 /* . 'SEGMENT', 0.0, 'TDB', COVER ) */
574
575 /* END DO */
576
577 /* C */
578 /* C Display results. */
579 /* C */
580 /* C Get the number of intervals in the coverage */
581 /* C window. */
582 /* C */
583 /* NIV = WNCARD( COVER ) */
584
585 /* C */
586 /* C Display a simple banner. */
587 /* C */
588 /* WRITE (*,*) ' ' */
589 /* WRITE (*,*) 'Coverage for object ', IDCODE */
590
591 /* C */
592 /* C Convert the coverage interval start and stop */
593 /* C times to TDB calendar strings. */
594 /* C */
595 /* DO I = 1, NIV */
596 /* C */
597 /* C Get the endpoints of the Ith interval. */
598 /* C */
599 /* CALL WNFETD ( COVER, I, B, E ) */
600 /* C */
601 /* C Convert the endpoints to TDB calendar */
602 /* C format time strings and display them. */
603 /* C */
604 /* CALL TIMOUT ( B, */
605 /* . 'YYYY MON DD HR:MN:SC.###### ' // */
606 /* . '(TDB) ::TDB', */
607 /* . TIMSTR ) */
608 /* WRITE (*,*) ' ' */
609 /* WRITE (*,*) 'Interval: ', I */
610 /* WRITE (*,*) 'Start: ', TIMSTR */
611
612 /* CALL TIMOUT ( E, */
613 /* . 'YYYY MON DD HR:MN:SC.###### ' // */
614 /* . '(TDB) ::TDB', */
615 /* . TIMSTR ) */
616 /* WRITE (*,*) 'Stop: ', TIMSTR */
617 /* WRITE (*,*) ' ' */
618
619 /* END DO */
620
621 /* END */
622
623
624 /* $ Restrictions */
625
626 /* 1) When this routine is used to accumulate coverage for IDCODE */
627 /* provided by multiple CK files, the inputs NEEDAV, LEVEL, TOL, */
628 /* and TIMSYS must have the same values for all files in order */
629 /* for the result to be meaningful. */
630
631 /* $ Literature_References */
632
633 /* None. */
634
635 /* $ Author_and_Institution */
636
637 /* N.J. Bachman (JPL) */
638 /* B.V. Semenov (JPL) */
639
640 /* $ Version */
641
642 /* - SPICELIB Version 2.0.0, 05-JAN-2014 (NJB) (BVS) */
643
644 /* Updated index entries. */
645
646 /* Last update was 05-JAN-2014 (NJB) (BVS) */
647
648 /* Updated to support type 6. */
649
650 /* - SPICELIB Version 1.0.1, 30-NOV-2007 (NJB) */
651
652 /* Corrected bug in first program in header Examples section: */
653 /* program now empties the coverage window prior to collecting */
654 /* data for the current object. Updated examples to use WNCARD */
655 /* rather than CARDD. */
656
657 /* - SPICELIB Version 1.0.0, 07-JAN-2005 (NJB) */
658
659 /* -& */
660 /* $ Index_Entries */
661
662 /* get coverage window for ck_object */
663 /* get coverage start and stop time for ck_object */
664 /* get coverage start and stop time for ck frame */
665 /* get coverage start and stop time for ck instrument */
666
667 /* -& */
668
669 /* SPICELIB functions */
670
671
672 /* Local parameters */
673
674
675 /* Local variables */
676
677
678 /* Standard SPICE error handling. */
679
680 if (return_()) {
681 return 0;
682 }
683 chkin_("CKCOV", (ftnlen)5);
684
685 /* Check tolerance value. */
686
687 if (*tol < 0.) {
688 setmsg_("Tolerance must be non-negative; actual value was #.", (
689 ftnlen)51);
690 errdp_("#", tol, (ftnlen)1);
691 sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
692 chkout_("CKCOV", (ftnlen)5);
693 return 0;
694 }
695
696 /* Use a logical flag to indicate whether this is a segment-level */
697 /* coverage description. */
698
699 seglvl = eqstr_(level, "SEGMENT", level_len, (ftnlen)7);
700
701 /* Check coverage level keyword. */
702
703 if (! (seglvl || eqstr_(level, "INTERVAL", level_len, (ftnlen)8))) {
704 setmsg_("Allowed values of LEVEL are # and #; actual value was #.", (
705 ftnlen)56);
706 errch_("#", "SEGMENT", (ftnlen)1, (ftnlen)7);
707 errch_("#", "INTERVAL", (ftnlen)1, (ftnlen)8);
708 errch_("#", level, (ftnlen)1, level_len);
709 sigerr_("SPICE(INVALIDOPTION)", (ftnlen)20);
710 chkout_("CKCOV", (ftnlen)5);
711 return 0;
712 }
713
714 /* See whether GETFAT thinks we've got a CK file. */
715
716 getfat_(ck, arch, kertyp, ck_len, (ftnlen)80, (ftnlen)80);
717 if (s_cmp(arch, "XFR", (ftnlen)80, (ftnlen)3) == 0) {
718 setmsg_("Input file # has architecture #. The file must be a binary "
719 "CK file to be readable by this routine. If the input file i"
720 "s an CK file in transfer format, run TOBIN on the file to co"
721 "nvert it to binary format.", (ftnlen)205);
722 errch_("#", ck, (ftnlen)1, ck_len);
723 errch_("#", arch, (ftnlen)1, (ftnlen)80);
724 sigerr_("SPICE(INVALIDFORMAT)", (ftnlen)20);
725 chkout_("CKCOV", (ftnlen)5);
726 return 0;
727 } else if (s_cmp(arch, "DAF", (ftnlen)80, (ftnlen)3) != 0) {
728 setmsg_("Input file # has architecture #. The file must be a binary "
729 "CK file to be readable by this routine. Binary CK files hav"
730 "e DAF architecture. If you expected the file to be a binary"
731 " CK file, the problem may be due to the file being an old no"
732 "n-native file lacking binary file format information. It's a"
733 "lso possible the file has been corrupted.", (ftnlen)340);
734 errch_("#", ck, (ftnlen)1, ck_len);
735 errch_("#", arch, (ftnlen)1, (ftnlen)80);
736 sigerr_("SPICE(INVALIDARCHTYPE)", (ftnlen)22);
737 chkout_("CKCOV", (ftnlen)5);
738 return 0;
739 } else if (s_cmp(kertyp, "CK", (ftnlen)80, (ftnlen)2) != 0) {
740 setmsg_("Input file # has file type #. The file must be a binary CK "
741 "file to be readable by this routine. If you expected the fil"
742 "e to be a binary CK file, the problem may be due to the file"
743 " being an old non-native file lacking binary file format inf"
744 "ormation. It's also possible the file has been corrupted.", (
745 ftnlen)296);
746 errch_("#", ck, (ftnlen)1, ck_len);
747 errch_("#", kertyp, (ftnlen)1, (ftnlen)80);
748 sigerr_("SPICE(INVALIDFILETYPE)", (ftnlen)22);
749 chkout_("CKCOV", (ftnlen)5);
750 return 0;
751 }
752
753 /* Set a logical flag indicating whether the time system is SCLK. */
754
755 istdb = eqstr_(timsys, "TDB", timsys_len, (ftnlen)3);
756
757 /* Check time system. */
758
759 if (! istdb) {
760 if (! eqstr_(timsys, "SCLK", timsys_len, (ftnlen)4)) {
761 setmsg_("Time system spec TIMSYS was #; allowed values are SCLK "
762 "and TDB.", (ftnlen)63);
763 errch_("#", timsys, (ftnlen)1, timsys_len);
764 sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
765 chkout_("CKCOV", (ftnlen)5);
766 return 0;
767 }
768 }
769
770 /* If the output time system is TDB, find the clock ID associated */
771 /* with IDCODE. */
772
773 if (istdb) {
774 ckmeta_(idcode, "SCLK", &clkid, (ftnlen)4);
775 if (failed_()) {
776 chkout_("CKCOV", (ftnlen)5);
777 return 0;
778 }
779 }
780
781 /* Open the file for reading. */
782
783 dafopr_(ck, &handle, ck_len);
784 if (failed_()) {
785 chkout_("CKCOV", (ftnlen)5);
786 return 0;
787 }
788
789 /* We will examine each segment descriptor in the file, and */
790 /* we'll update our coverage bounds according to the data found */
791 /* in these descriptors. */
792
793 /* If TOL > 0, we'll apply TOL after we've found the coverage */
794 /* for the zero-tolerance case. */
795
796 /* If the time system is TDB, we'll convert the times to TDB */
797 /* at the end of this routine. */
798
799 /* Start a forward search. */
800
801 dafbfs_(&handle);
802
803 /* Find the next DAF array. */
804
805 daffna_(&found);
806 while(found) {
807
808 /* Note: we check FAILED() at the bottom of this loop; this */
809 /* routine returns if FAILED() returns .TRUE. at that point. */
810
811 /* Fetch and unpack the segment descriptor. */
812
813 dafgs_(descr);
814 dafus_(descr, &c__2, &c__6, dc, ic);
815
816 /* Let AVOK indicate whether the segment satisfies the */
817 /* angular velocity restriction. */
818
819 avok = ic[3] == 1 || ! (*needav);
820 if (ic[0] == *idcode && avok) {
821
822 /* This segment is for the body of interest. If angular */
823 /* velocity is needed, this segment has it. */
824
825 if (seglvl) {
826
827 /* This is a segment-level summary. */
828
829 /* Insert the coverage bounds into the coverage window. */
830 /* Adjust the interval using the tolerance. */
831
832 /* Computing MAX */
833 d__1 = dc[0] - *tol;
834 dctol[0] = max(d__1,0.);
835 dctol[1] = dc[1] + *tol;
836
837 /* Convert the time to TDB if necessary. */
838
839 if (istdb) {
840
841 /* Convert the time bounds to TDB before inserting */
842 /* into the window. */
843
844 for (i__ = 1; i__ <= 2; ++i__) {
845 sct2e_(&clkid, &dctol[(i__1 = i__ - 1) < 2 && 0 <=
846 i__1 ? i__1 : s_rnge("dctol", i__1, "ckcov_",
847 (ftnlen)880)], &et);
848 dctol[(i__1 = i__ - 1) < 2 && 0 <= i__1 ? i__1 :
849 s_rnge("dctol", i__1, "ckcov_", (ftnlen)881)]
850 = et;
851 }
852 }
853 if (dctol[0] <= dctol[1]) {
854 wninsd_(dctol, &dctol[1], cover);
855 }
856 } else {
857
858 /* We're looking for an interval-level coverage window. */
859 /* This information must be retrieved in a */
860 /* data-type-dependent fashion. The coverage routines */
861 /* we'll call will, if necessary, adjust intervals by TOL */
862 /* and convert interval times to TDB. */
863
864 dtype = ic[2];
865 segbeg = ic[4];
866 segend = ic[5];
867 if (dtype == 1) {
868 zzckcv01_(&handle, &segbeg, &segend, &clkid, tol, timsys,
869 cover, timsys_len);
870 } else if (dtype == 2) {
871 zzckcv02_(&handle, &segbeg, &segend, &clkid, tol, timsys,
872 cover, timsys_len);
873 } else if (dtype == 3) {
874 zzckcv03_(&handle, &segbeg, &segend, &clkid, tol, timsys,
875 cover, timsys_len);
876 } else if (dtype == 4) {
877 zzckcv04_(&handle, &segbeg, &segend, &clkid, tol, timsys,
878 cover, timsys_len);
879 } else if (dtype == 5) {
880 zzckcv05_(&handle, &segbeg, &segend, &clkid, dc, tol,
881 timsys, cover, timsys_len);
882 } else if (dtype == 6) {
883 zzckcv06_(&handle, &segbeg, &segend, &clkid, dc, tol,
884 timsys, cover, timsys_len);
885 } else {
886 setmsg_("Supported CK data types are 1, 2, 3, 4, 5. Dat"
887 "a type of segment: #. This problem may indicate "
888 "that you need to update your SPICE Toolkit.", (
889 ftnlen)138);
890 errint_("#", &dtype, (ftnlen)1);
891 sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
892 chkout_("CKCOV", (ftnlen)5);
893 return 0;
894 }
895 }
896 }
897 daffna_(&found);
898 if (failed_()) {
899 chkout_("CKCOV", (ftnlen)5);
900 return 0;
901 }
902 }
903
904 /* COVER now represents the coverage of the entire file at the */
905 /* granularity indicated by LEVEL, combined with the coverage */
906 /* contained in COVER on input. */
907
908 /* Release the file. */
909
910 dafcls_(&handle);
911 chkout_("CKCOV", (ftnlen)5);
912 return 0;
913 } /* ckcov_ */
914
915