1 /* gfsntc.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_n1 = -1;
11 static integer c__3 = 3;
12 static integer c__0 = 0;
13 static integer c__10 = 10;
14 static logical c_false = FALSE_;
15 
16 /* $Procedure GFSNTC (GF, surface intercept vector coordinate search) */
gfsntc_(char * target,char * fixref,char * method,char * abcorr,char * obsrvr,char * dref,doublereal * dvec,char * crdsys,char * coord,char * relate,doublereal * refval,doublereal * adjust,doublereal * step,doublereal * cnfine,integer * mw,integer * nw,doublereal * work,doublereal * result,ftnlen target_len,ftnlen fixref_len,ftnlen method_len,ftnlen abcorr_len,ftnlen obsrvr_len,ftnlen dref_len,ftnlen crdsys_len,ftnlen coord_len,ftnlen relate_len)17 /* Subroutine */ int gfsntc_(char *target, char *fixref, char *method, char *
18 	abcorr, char *obsrvr, char *dref, doublereal *dvec, char *crdsys,
19 	char *coord, char *relate, doublereal *refval, doublereal *adjust,
20 	doublereal *step, doublereal *cnfine, integer *mw, integer *nw,
21 	doublereal *work, doublereal *result, ftnlen target_len, ftnlen
22 	fixref_len, ftnlen method_len, ftnlen abcorr_len, ftnlen obsrvr_len,
23 	ftnlen dref_len, ftnlen crdsys_len, ftnlen coord_len, ftnlen
24 	relate_len)
25 {
26     /* System generated locals */
27     integer work_dim1, work_offset, i__1;
28 
29     /* Builtin functions */
30     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
31 
32     /* Local variables */
33     extern logical even_(integer *);
34     extern /* Subroutine */ int chkin_(char *, ftnlen);
35     extern integer sized_(doublereal *);
36     extern logical gfbail_();
37     logical ok;
38     extern /* Subroutine */ int scardd_(integer *, doublereal *);
39     extern logical return_(void);
40     extern /* Subroutine */ int gfrefn_(), gfrepi_(), gfrepu_(), gfrepf_(),
41 	    gfstep_();
42     char qcpars[80*10], qpnams[80*10];
43     doublereal qdpars[10];
44     integer qipars[10];
45     logical qlpars[10];
46     extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
47 	    integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
48 	    ftnlen), gfsstp_(doublereal *), gfevnt_(U_fp, U_fp, char *,
49 	    integer *, char *, char *, doublereal *, integer *, logical *,
50 	    char *, doublereal *, doublereal *, doublereal *, doublereal *,
51 	    logical *, U_fp, U_fp, U_fp, integer *, integer *, doublereal *,
52 	    logical *, L_fp, doublereal *, ftnlen, ftnlen, ftnlen, ftnlen);
53     doublereal tol;
54     extern /* Subroutine */ int zzholdd_(integer *, integer *, logical *,
55 	    doublereal *);
56 
57 /* $ Abstract */
58 
59 /*     Determine time intervals for which a coordinate of an */
60 /*     surface intercept position vector satisfies a numerical */
61 /*     constraint. */
62 
63 /* $ Disclaimer */
64 
65 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
66 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
67 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
68 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
69 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
70 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
71 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
72 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
73 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
74 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
75 
76 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
77 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
78 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
79 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
80 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
81 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
82 
83 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
84 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
85 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
86 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
87 
88 /* $ Required_Reading */
89 
90 /*     GF */
91 /*     SPK */
92 /*     CK */
93 /*     TIME */
94 /*     WINDOWS */
95 
96 /* $ Keywords */
97 
98 /*     COORDINATE */
99 /*     GEOMETRY */
100 /*     SEARCH */
101 /*     EVENT */
102 
103 /* $ Declarations */
104 /* $ Abstract */
105 
106 /*     This file contains public, global parameter declarations */
107 /*     for the SPICELIB Geometry Finder (GF) subsystem. */
108 
109 /* $ Disclaimer */
110 
111 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
112 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
113 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
114 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
115 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
116 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
117 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
118 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
119 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
120 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
121 
122 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
123 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
124 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
125 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
126 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
127 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
128 
129 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
130 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
131 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
132 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
133 
134 /* $ Required_Reading */
135 
136 /*     GF */
137 
138 /* $ Keywords */
139 
140 /*     GEOMETRY */
141 /*     ROOT */
142 
143 /* $ Restrictions */
144 
145 /*     None. */
146 
147 /* $ Author_and_Institution */
148 
149 /*     N.J. Bachman      (JPL) */
150 /*     L.E. Elson        (JPL) */
151 /*     E.D. Wright       (JPL) */
152 
153 /* $ Literature_References */
154 
155 /*     None. */
156 
157 /* $ Version */
158 
159 /* -    SPICELIB Version 2.0.0  29-NOV-2016 (NJB) */
160 
161 /*        Upgraded to support surfaces represented by DSKs. */
162 
163 /*        Bug fix: removed declaration of NVRMAX parameter. */
164 
165 /* -    SPICELIB Version 1.3.0, 01-OCT-2011 (NJB) */
166 
167 /*       Added NWILUM parameter. */
168 
169 /* -    SPICELIB Version 1.2.0, 14-SEP-2010 (EDW) */
170 
171 /*       Added NWPA parameter. */
172 
173 /* -    SPICELIB Version 1.1.0, 08-SEP-2009 (EDW) */
174 
175 /*       Added NWRR parameter. */
176 /*       Added NWUDS parameter. */
177 
178 /* -    SPICELIB Version 1.0.0, 21-FEB-2009 (NJB) (LSE) (EDW) */
179 
180 /* -& */
181 
182 /*     Root finding parameters: */
183 
184 /*     CNVTOL is the default convergence tolerance used by the */
185 /*     high-level GF search API routines. This tolerance is */
186 /*     used to terminate searches for binary state transitions: */
187 /*     when the time at which a transition occurs is bracketed */
188 /*     by two times that differ by no more than CNVTOL, the */
189 /*     transition time is considered to have been found. */
190 
191 /*     Units are TDB seconds. */
192 
193 
194 /*     NWMAX is the maximum number of windows allowed for user-defined */
195 /*     workspace array. */
196 
197 /*        DOUBLE PRECISION      WORK   ( LBCELL : MW, NWMAX ) */
198 
199 /*     Currently no more than twelve windows are required; the three */
200 /*     extra windows are spares. */
201 
202 /*     Callers of GFEVNT can include this file and use the parameter */
203 /*     NWMAX to declare the second dimension of the workspace array */
204 /*     if necessary. */
205 
206 
207 /*     Callers of GFIDST should declare their workspace window */
208 /*     count using NWDIST. */
209 
210 
211 /*     Callers of GFSEP should declare their workspace window */
212 /*     count using NWSEP. */
213 
214 
215 /*     Callers of GFRR should declare their workspace window */
216 /*     count using NWRR. */
217 
218 
219 /*     Callers of GFUDS should declare their workspace window */
220 /*     count using NWUDS. */
221 
222 
223 /*     Callers of GFPA should declare their workspace window */
224 /*     count using NWPA. */
225 
226 
227 /*     Callers of GFILUM should declare their workspace window */
228 /*     count using NWILUM. */
229 
230 
231 /*     ADDWIN is a parameter used to expand each interval of the search */
232 /*     (confinement) window by a small amount at both ends in order to */
233 /*     accommodate searches using equality constraints. The loaded */
234 /*     kernel files must accommodate these expanded time intervals. */
235 
236 
237 /*     FRMNLN is a string length for frame names. */
238 
239 
240 /*     FOVTLN -- maximum length for FOV string. */
241 
242 
243 /*     Specify the character strings that are allowed in the */
244 /*     specification of field of view shapes. */
245 
246 
247 /*     Character strings that are allowed in the */
248 /*     specification of occultation types: */
249 
250 
251 /*     Occultation target shape specifications: */
252 
253 
254 /*     Specify the number of supported occultation types and occultation */
255 /*     type string length: */
256 
257 
258 /*     Instrument field-of-view (FOV) parameters */
259 
260 /*     Maximum number of FOV boundary vectors: */
261 
262 
263 /*     FOV shape parameters: */
264 
265 /*        circle */
266 /*        ellipse */
267 /*        polygon */
268 /*        rectangle */
269 
270 
271 /*     End of file gf.inc. */
272 
273 /* $ Abstract */
274 
275 /*     SPICE private include file intended solely for the support of */
276 /*     SPICE routines. Users should not include this routine in their */
277 /*     source code due to the volatile nature of this file. */
278 
279 /*     This file contains private, global parameter declarations */
280 /*     for the SPICELIB Geometry Finder (GF) subsystem. */
281 
282 /* $ Disclaimer */
283 
284 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
285 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
286 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
287 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
288 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
289 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
290 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
291 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
292 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
293 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
294 
295 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
296 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
297 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
298 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
299 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
300 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
301 
302 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
303 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
304 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
305 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
306 
307 /* $ Required_Reading */
308 
309 /*     GF */
310 
311 /* $ Keywords */
312 
313 /*     GEOMETRY */
314 /*     ROOT */
315 
316 /* $ Restrictions */
317 
318 /*     None. */
319 
320 /* $ Author_and_Institution */
321 
322 /*     N.J. Bachman      (JPL) */
323 /*     E.D. Wright       (JPL) */
324 
325 /* $ Literature_References */
326 
327 /*     None. */
328 
329 /* $ Version */
330 
331 /* -    SPICELIB Version 1.0.0, 17-FEB-2009 (NJB) (EDW) */
332 
333 /* -& */
334 
335 /*     The set of supported coordinate systems */
336 
337 /*        System          Coordinates */
338 /*        ----------      ----------- */
339 /*        Rectangular     X, Y, Z */
340 /*        Latitudinal     Radius, Longitude, Latitude */
341 /*        Spherical       Radius, Colatitude, Longitude */
342 /*        RA/Dec          Range, Right Ascension, Declination */
343 /*        Cylindrical     Radius, Longitude, Z */
344 /*        Geodetic        Longitude, Latitude, Altitude */
345 /*        Planetographic  Longitude, Latitude, Altitude */
346 
347 /*     Below we declare parameters for naming coordinate systems. */
348 /*     User inputs naming coordinate systems must match these */
349 /*     when compared using EQSTR. That is, user inputs must */
350 /*     match after being left justified, converted to upper case, */
351 /*     and having all embedded blanks removed. */
352 
353 
354 /*     Below we declare names for coordinates. Again, user */
355 /*     inputs naming coordinates must match these when */
356 /*     compared using EQSTR. */
357 
358 
359 /*     Note that the RA parameter value below matches */
360 
361 /*        'RIGHT ASCENSION' */
362 
363 /*     when extra blanks are compressed out of the above value. */
364 
365 
366 /*     Parameters specifying types of vector definitions */
367 /*     used for GF coordinate searches: */
368 
369 /*     All string parameter values are left justified, upper */
370 /*     case, with extra blanks compressed out. */
371 
372 /*     POSDEF indicates the vector is defined by the */
373 /*     position of a target relative to an observer. */
374 
375 
376 /*     SOBDEF indicates the vector points from the center */
377 /*     of a target body to the sub-observer point on */
378 /*     that body, for a given observer and target. */
379 
380 
381 /*     SOBDEF indicates the vector points from the center */
382 /*     of a target body to the surface intercept point on */
383 /*     that body, for a given observer, ray, and target. */
384 
385 
386 /*     Number of workspace windows used by ZZGFREL: */
387 
388 
389 /*     Number of additional workspace windows used by ZZGFLONG: */
390 
391 
392 /*     Index of "existence window" used by ZZGFCSLV: */
393 
394 
395 /*     Progress report parameters: */
396 
397 /*     MXBEGM, */
398 /*     MXENDM    are, respectively, the maximum lengths of the progress */
399 /*               report message prefix and suffix. */
400 
401 /*     Note: the sum of these lengths, plus the length of the */
402 /*     "percent complete" substring, should not be long enough */
403 /*     to cause wrap-around on any platform's terminal window. */
404 
405 
406 /*     Total progress report message length upper bound: */
407 
408 
409 /*     End of file zzgf.inc. */
410 
411 /* $ Abstract */
412 
413 /*     SPICE private routine intended solely for the support of SPICE */
414 /*     routines. Users should not call this routine directly due to the */
415 /*     volatile nature of this routine. */
416 
417 /*     This file contains parameter declarations for the ZZHOLDD */
418 /*     routine. */
419 
420 /* $ Disclaimer */
421 
422 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
423 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
424 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
425 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
426 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
427 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
428 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
429 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
430 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
431 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
432 
433 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
434 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
435 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
436 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
437 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
438 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
439 
440 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
441 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
442 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
443 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
444 
445 /* $ Required_Reading */
446 
447 /*     None. */
448 
449 /* $ Keywords */
450 
451 /*     None. */
452 
453 /* $ Declarations */
454 
455 /*     None. */
456 
457 /* $ Brief_I/O */
458 
459 /*     None. */
460 
461 /* $ Detailed_Input */
462 
463 /*     None. */
464 
465 /* $ Detailed_Output */
466 
467 /*     None. */
468 
469 /* $ Parameters */
470 
471 /*     GEN       general value, primarily for testing. */
472 
473 /*     GF_REF    user defined GF reference value. */
474 
475 /*     GF_TOL    user defined GF convergence tolerance. */
476 
477 /*     GF_DT     user defined GF step for numeric differentiation. */
478 
479 /* $ Exceptions */
480 
481 /*     None. */
482 
483 /* $ Files */
484 
485 /*     None. */
486 
487 /* $ Particulars */
488 
489 /*     None. */
490 
491 /* $ Examples */
492 
493 /*     None. */
494 
495 /* $ Restrictions */
496 
497 /*     None. */
498 
499 /* $ Literature_References */
500 
501 /*     None. */
502 
503 /* $ Author_and_Institution */
504 
505 /*     E.D. Wright    (JPL) */
506 
507 /* $ Version */
508 
509 /* -    SPICELIB Version 1.0.0  03-DEC-2013 (EDW) */
510 
511 /* -& */
512 
513 /*     OP codes. The values exist in the integer domain */
514 /*     [ -ZZNOP, -1], */
515 
516 
517 /*     Current number of OP codes. */
518 
519 
520 /*     ID codes. The values exist in the integer domain */
521 /*     [ 1, NID], */
522 
523 
524 /*     General use, primarily testing. */
525 
526 
527 /*     The user defined GF reference value. */
528 
529 
530 /*     The user defined GF convergence tolerance. */
531 
532 
533 /*     The user defined GF step for numeric differentiation. */
534 
535 
536 /*     Current number of ID codes, dimension of array */
537 /*     in ZZHOLDD. Bad things can happen if this parameter */
538 /*     does not have the proper value. */
539 
540 
541 /*     End of file zzholdd.inc. */
542 
543 /* $ Brief_I/O */
544 
545 /*     Variable  I/O  Description */
546 /*     --------  ---  -------------------------------------------------- */
547 /*     LBCELL     P   SPICE Cell lower bound. */
548 /*     CNVTOL     P   Convergence tolerance. */
549 /*     ZZGET      P   ZZHOLDD retrieves a stored DP value. */
550 /*     GF_TOL     P   ZZHOLDD acts on the GF subsystem tolerance. */
551 /*     TARGET     I   Name of the target body. */
552 /*     FIXREF     I   Body fixed frame associated with TARGET . */
553 /*     METHOD     I   Name of method type for surface intercept */
554 /*                    calculation. */
555 /*     ABCORR     I   Aberration correction flag. */
556 /*     OBSRVR     I   Name of the observing body. */
557 /*     DREF       I   Reference frame of direction vector DVEC. */
558 /*     DVEC       I   Pointing direction vector from OBSRVR. */
559 /*     CRDSYS     I   Name of the coordinate system containing COORD. */
560 /*     COORD      I   Name of the coordinate of interest. */
561 /*     RELATE     I   Relational operator. */
562 /*     REFVAL     I   Reference value. */
563 /*     ADJUST     I   Adjustment value for absolute extrema searches. */
564 /*     STEP       I   Step size used for locating extrema and roots. */
565 /*     CNFINE     I   SPICE window to which the search is confined. */
566 /*     MW         I   Workspace window size. */
567 /*     NW         I   The number of workspace windows needed for the */
568 /*                    search. */
569 /*     WORK      I-O   Array of workspace windows */
570 /*     RESULT    I-O   SPICE window containing results. */
571 
572 /* $ Detailed_Input */
573 
574 /*     TARGET   the string name of a target body.  Optionally, you may */
575 /*              supply the integer ID code for the object as an */
576 /*              integer string.  For example both 'MOON' and '301' */
577 /*              are legitimate strings that indicate the moon is the */
578 /*              target body. */
579 
580 /*              On calling GFSNTC, the kernel pool must contain the radii */
581 /*              data corresponding to TARGET. */
582 
583 /*     FIXREF   the string name of the body-fixed, body-centered */
584 /*              reference frame associated with the target body TARGET. */
585 
586 /*              The SPICE frame subsystem must recognize the 'fixref' */
587 /*              name. */
588 
589 /*     METHOD   the string name of the method to use for the surface */
590 /*              intercept calculation. The accepted values for METHOD: */
591 
592 /*                 'Ellipsoid'        The intercept computation uses */
593 /*                                    a triaxial ellipsoid to model */
594 /*                                    the surface of the target body. */
595 /*                                    The ellipsoid's radii must be */
596 /*                                    available in the kernel pool. */
597 
598 /*              The METHOD string lacks sensitivity to case, embedded, */
599 /*              leading and trailing blanks. */
600 
601 /*     ABCORR   the string description of the aberration corrections to */
602 /*              apply to the state evaluations to account for one-way */
603 /*              light time and stellar aberration. */
604 
605 /*              Any aberration correction accepted by the SPICE */
606 /*              routine SPKEZR is accepted here. See the header */
607 /*              of SPKEZR for a detailed description of the */
608 /*              aberration correction options. For convenience, */
609 /*              the options are listed below: */
610 
611 /*                 'NONE'     Apply no correction. Returns the "true" */
612 /*                            geometric state. */
613 
614 /*                 'LT'       "Reception" case:  correct for */
615 /*                            one-way light time using a Newtonian */
616 /*                            formulation. */
617 
618 /*                 'LT+S'     "Reception" case:  correct for */
619 /*                            one-way light time and stellar */
620 /*                            aberration using a Newtonian */
621 /*                            formulation. */
622 
623 /*                 'CN'       "Reception" case:  converged */
624 /*                            Newtonian light time correction. */
625 
626 /*                'CN+S'     "Reception" case:  converged */
627 /*                            Newtonian light time and stellar */
628 /*                            aberration corrections. */
629 
630 /*                 'XLT'      "Transmission" case:  correct for */
631 /*                            one-way light time using a Newtonian */
632 /*                            formulation. */
633 
634 /*                 'XLT+S'    "Transmission" case:  correct for */
635 /*                            one-way light time and stellar */
636 /*                            aberration using a Newtonian */
637 /*                            formulation. */
638 
639 /*                 'XCN'      "Transmission" case:  converged */
640 /*                            Newtonian light time correction. */
641 
642 /*                 'XCN+S'    "Transmission" case:  converged */
643 /*                            Newtonian light time and stellar */
644 /*                            aberration corrections. */
645 
646 /*              The ABCORR string lacks sensitivity to case, leading */
647 /*              and trailing blanks. */
648 
649 /*              *Note* */
650 
651 /*              When using a reference frame defined as a dynamic frame, */
652 /*              the user should realize defining an aberration correction */
653 /*              for the search different from that in the frames */
654 /*              definition will affect the search results. */
655 
656 /*              In general, use the same aberration correction for */
657 /*              intercept point searches as used in the definition of a */
658 /*              dynamic frame (if applicable). */
659 
660 /*     OBSRVR   the string name of an observing body.  Optionally, you */
661 /*              may supply the ID code of the object as an integer */
662 /*              string. For example, both 'EARTH' and '399' are */
663 /*              legitimate strings to indicate the observer as Earth. */
664 
665 /*     DREF     the string name of the reference frame corresponding to */
666 /*              DVEC. */
667 
668 /*              The DREF string lacks sensitivity to case, leading */
669 /*              and trailing blanks. */
670 
671 /*     DVEC     the pointing or boresight vector from the observer. The */
672 /*              intercept of this vector and TARGET is the event of */
673 /*              interest. */
674 
675 /*     CRDSYS   the string name of the coordinate system for which the */
676 /*              coordinate of interest is a member */
677 
678 /*     COORD    the string name of the coordinate of interest in CRDSYS */
679 
680 /*              The supported coordinate systems and coordinate names: */
681 
682 /*          Coordinate System (CRDSYS)   Coordinates (COORD)  Range */
683 
684 /*          'RECTANGULAR'              'X' */
685 /*                                     'Y' */
686 /*                                     'Z' */
687 
688 /*          'LATITUDINAL'              'RADIUS' */
689 /*                                     'LONGITUDE'        (-Pi,Pi] */
690 /*                                     'LATITUDE'         [-Pi/2,Pi/2] */
691 
692 /*          'RA/DEC'                   'RANGE' */
693 /*                                     'RIGHT ASCENSION'  [0,2Pi) */
694 /*                                     'DECLINATION'      [-Pi/2,Pi/2] */
695 
696 /*          'SPHERICAL'                'RADIUS' */
697 /*                                     'COLATITUDE'       [0,Pi] */
698 /*                                     'LONGITUDE'        (-Pi,Pi] */
699 
700 /*          'CYLINDRICAL'              'RADIUS' */
701 /*                                     'LONGITUDE'        [0,2Pi) */
702 /*                                     'Z' */
703 
704 /*          'GEODETIC'                 'LONGITUDE'        (-Pi,Pi] */
705 /*                                     'LATITUDE'         [-Pi/2,Pi/2] */
706 /*                                     'ALTITUDE' */
707 
708 /*          'PLANETOGRAPHIC'           'LONGITUDE'        [0,2Pi) */
709 /*                                     'LATITUDE'         [-Pi/2,Pi/2] */
710 /*                                     'ALTITUDE' */
711 
712 /*                 The ALTITUDE coordinates have a constant value */
713 /*                 of zero +/- roundoff for ellipsoid targets. */
714 
715 /*                 Limit searches for coordinate events in the GEODETIC */
716 /*                 and PLANETOGRAPHIC coordinate systems to TARGET bodies */
717 /*                 with axial symmetry in the equatorial plane, i.e. */
718 /*                 equality of the body X and Y radii (oblate or prolate */
719 /*                 spheroids). */
720 
721 /*     RELATE   the string or character describing the relational */
722 /*              operator used to define a constraint on the selected */
723 /*              coordinate of the surface intercept vector. The result */
724 /*              window found by this routine indicates the time intervals */
725 /*              where the constraint is satisfied. Supported values of */
726 /*              RELATE and corresponding meanings are shown below: */
727 
728 /*                 '>'       The coordinate value is greater than the */
729 /*                           reference value REFVAL. */
730 
731 /*                 '='       The coordinate value is equal to the */
732 /*                           reference value REFVAL. */
733 
734 /*                 '<'       The coordinate value is less than the */
735 /*                           reference value REFVAL. */
736 
737 /*                 'ABSMAX'  The coordinate value is at an absolute */
738 /*                           maximum. */
739 
740 /*                 'ABSMIN'  The coordinate value is at an absolute */
741 /*                           minimum. */
742 
743 /*                 'LOCMAX'  The coordinate value is at a local */
744 /*                           maximum. */
745 
746 /*                 'LOCMIN'  The coordinate value is at a local */
747 /*                           minimum. */
748 
749 /*              The caller may indicate that the region of interest */
750 /*              is the set of time intervals where the quantity is */
751 /*              within a specified measure of an absolute extremum. */
752 /*              The argument ADJUST (described below) is used to */
753 /*              specify this measure. */
754 
755 /*              Local extrema are considered to exist only in the */
756 /*              interiors of the intervals comprising the confinement */
757 /*              window:  a local extremum cannot exist at a boundary */
758 /*              point of the confinement window. */
759 
760 /*              The RELATE string lacks sensitivity to case, leading */
761 /*              and trailing blanks. */
762 
763 /*     REFVAL   the double precision reference value used together with */
764 /*              the argument RELATE to define an equality or inequality */
765 /*              to satisfy by the selected coordinate of the surface */
766 /*              intercept vector. See the discussion of RELATE above for */
767 /*              further information. */
768 
769 /*               The units of REFVAL correspond to the type as defined */
770 /*               by COORD, radians for angular measures, kilometers for */
771 /*               distance measures. */
772 
773 /*     ADJUST   a double precision value used to modify searches for */
774 /*              absolute extrema: when RELATE is set to ABSMAX or ABSMIN */
775 /*              and ADJUST is set to a positive value, GFSNTC finds times */
776 /*              when the intercept vector coordinate is within ADJUST */
777 /*              radians/kilometers of the specified extreme value. */
778 
779 /*              For RELATE set to ABSMAX, the RESULT window contains */
780 /*              time intervals when the intercept vector coordinate has */
781 /*              values between ABSMAX - ADJUST and ABSMAX. */
782 
783 /*              For RELATE set to ABSMIN, the RESULT window contains */
784 /*              time intervals when the intercept vector coordinate has */
785 /*              values between ABSMIN and ABSMIN + ADJUST. */
786 
787 /*              ADJUST is not used for searches for local extrema, */
788 /*              equality or inequality conditions. */
789 
790 /*     STEP     the double precision time step size to use in the search. */
791 
792 /*              Selection of the time step for surface intercept geometry */
793 /*              requires consideration of the mechanics of a surface */
794 /*              intercept event. In most cases, two distinct searches */
795 /*              will be needed, one to determine the windows when the */
796 /*              boresight vector intercepts the surface and then the */
797 /*              search based on the user defined constraints within those */
798 /*              windows. The boresight of nadir pointing instrument may */
799 /*              continually intercept a body, but an instrument scanning */
800 /*              across a disc will have configurations when the */
801 /*              boresight does not intercept the body. */
802 
803 /*              The step size must be smaller than the shortest interval */
804 /*              within the confinement window over which the intercept */
805 /*              exists and also smaller than the shortest interval over */
806 /*              which the intercept does not exist. */
807 
808 /*              For coordinates other than LONGITUDE and RIGHT ASCENSION, */
809 /*              the step size must be shorter than the shortest interval, */
810 /*              within the confinement window, over which the coordinate */
811 /*              is monotone increasing or decreasing. */
812 
813 /*              For LONGITUDE and RIGHT ASCENSION, the step size must */
814 /*              be shorter than the shortest interval, within the */
815 /*              confinement window, over which either the sin or cosine */
816 /*              of the coordinate is monotone increasing or decreasing. */
817 
818 /*              The choice of STEP affects the completeness but not */
819 /*              the precision of solutions found by this routine; the */
820 /*              precision is controlled by the convergence tolerance. */
821 /*              See the discussion of the parameter CNVTOL for */
822 /*              details. */
823 
824 /*              STEP has units of TDB seconds. */
825 
826 /*     CNFINE   a double precision SPICE window that confines the time */
827 /*              period over which the specified search is conducted. */
828 /*              CNFINE may consist of a single interval or a collection */
829 /*              of intervals. */
830 
831 /*              In some cases the confinement window can be used to */
832 /*              greatly reduce the time period that must be searched */
833 /*              for the desired solution. See the Particulars section */
834 /*              below for further discussion. */
835 
836 /*              See the Examples section below for a code example */
837 /*              that shows how to create a confinement window. */
838 
839 /*              CNFINE must be initialized by the caller using the */
840 /*              SPICELIB routine SSIZED. */
841 
842 /*     MW       is a parameter specifying the length of the SPICE */
843 /*              windows in the workspace array WORK (see description */
844 /*              below) used by this routine. */
845 
846 /*              MW should be set to a number at least twice as large */
847 /*              as the maximum number of intervals required by any */
848 /*              workspace window. In many cases, it's not necessary to */
849 /*              compute an accurate estimate of how many intervals are */
850 /*              needed; rather, the user can pick a size considerably */
851 /*              larger than what's really required. */
852 
853 /*              However, since excessively large arrays can prevent */
854 /*              applications from compiling, linking, or running */
855 /*              properly, sometimes MW must be set according to */
856 /*              the actual workspace requirement. A rule of thumb */
857 /*              for the number of intervals NINTVLS needed is */
858 
859 /*                  NINTVLS  =  2*N  +  ( M / STEP ) */
860 
861 /*              where */
862 
863 /*                  N     is the number of intervals in the confinement */
864 /*                        window */
865 
866 /*                  M     is the measure of the confinement window, in */
867 /*                        units of seconds */
868 
869 /*                  STEP  is the search step size in seconds */
870 
871 /*              MW should then be set to */
872 
873 /*                  2 * NINTVLS */
874 
875 /*     NW       is a parameter specifying the number of SPICE windows */
876 /*              in the workspace array WORK (see description below) */
877 /*              used by this routine. NW should be set to the */
878 /*              parameter NWMAX; this parameter is declared in the */
879 /*              include file gf.inc. (The reason this dimension is */
880 /*              an input argument is that this allows run-time */
881 /*              error checking to be performed.) */
882 
883 /*     WORK     is an array used to store workspace windows. This */
884 /*              array should be declared by the caller as shown: */
885 
886 /*                 INCLUDE 'gf.inc' */
887 /*                    ... */
888 
889 /*                 DOUBLE PRECISION    WORK ( LBCELL : MW, NWMAX ) */
890 
891 /*              where MW is a constant declared by the caller and */
892 /*              NWMAX is a constant defined in the SPICELIB INCLUDE */
893 /*              file gf.inc. See the discussion of MW above. */
894 
895 /*              WORK need not be initialized by the caller. */
896 
897 /*     RESULT   a double precision SPICE window which will contain the */
898 /*              search results. RESULT must be initialized using */
899 /*              a call to SSIZED. RESULT must be declared and initialized */
900 /*              with sufficient size to capture the full set of time */
901 /*              intervals within the search region on which the specified */
902 /*              constraint is satisfied. */
903 
904 /*              If RESULT is non-empty on input, its contents */
905 /*              will be discarded before GFSNTC conducts its */
906 /*              search. */
907 
908 /* $ Detailed_Output */
909 
910 /*     WORK     the input workspace array, modified by this */
911 /*              routine. */
912 
913 /*     RESULT   the SPICE window of intervals, contained within the */
914 /*              confinement window CNFINE, on which the specified */
915 /*              constraint is satisfied. */
916 
917 /*              If the search is for local extrema, or for absolute */
918 /*              extrema with ADJUST set to zero, then normally each */
919 /*              interval of RESULT will be a singleton: the left and */
920 /*              right endpoints of each interval will be identical. */
921 
922 /*              If no times within the confinement window satisfy the */
923 /*              constraint, RESULT will be returned with a */
924 /*              cardinality of zero. */
925 
926 /* $ Parameters */
927 
928 /*     LBCELL   the integer value defining the lower bound for */
929 /*              SPICE Cell arrays (a SPICE window is a kind of cell). */
930 
931 /*     CNVTOL   is the convergence tolerance used for finding */
932 /*              endpoints of the intervals comprising the result */
933 /*              window. CNVTOL is also used for finding intermediate */
934 /*              results; in particular, CNVTOL is used for finding the */
935 /*              windows on which the specified coordinate is increasing */
936 /*              or decreasing. CNVTOL is used to determine when binary */
937 /*              searches for roots should terminate: when a root is */
938 /*              bracketed within an interval of length CNVTOL; the */
939 /*              root is considered to have been found. */
940 
941 /*              The accuracy, as opposed to precision, of roots found */
942 /*              by this routine depends on the accuracy of the input */
943 /*              data. In most cases, the accuracy of solutions will be */
944 /*              inferior to their precision. */
945 
946 /*     See INCLUDE file gf.inc for declarations and descriptions of */
947 /*     parameters used throughout the GF system. */
948 
949 /* $ Exceptions */
950 
951 /*     1)  In order for this routine to produce correct results, */
952 /*         the step size must be appropriate for the problem at hand. */
953 /*         Step sizes that are too large may cause this routine to miss */
954 /*         roots; step sizes that are too small may cause this routine */
955 /*         to run unacceptably slowly and in some cases, find spurious */
956 /*         roots. */
957 
958 /*         This routine does not diagnose invalid step sizes, except */
959 /*         that if the step size is non-positive, an error is signaled */
960 /*         by a routine in the call tree of this routine. */
961 
962 /*     2)  Due to numerical errors, in particular, */
963 
964 /*            - truncation error in time values */
965 /*            - finite tolerance value */
966 /*            - errors in computed geometric quantities */
967 
968 /*         it is *normal* for the condition of interest to not always be */
969 /*         satisfied near the endpoints of the intervals comprising the */
970 /*         RESULT window. One technique to handle such a situation, */
971 /*         slightly contract RESULT using the window routine WNCOND. */
972 
973 /*     3)  If the window size MW is less than 2 or not an even value, */
974 /*         the error SPICE(INVALIDDIMENSION) will signal. */
975 
976 /*     4)  If the window size of RESULT is less than 2, the error */
977 /*         SPICE(INVALIDDIMENSION) will signal. */
978 
979 /*     5)  If an error (typically cell overflow) occurs during */
980 /*         window arithmetic, the error will be diagnosed by a routine */
981 /*         in the call tree of this routine. */
982 
983 /*     6)  If the relational operator RELATE is not recognized, an */
984 /*         error is signaled by a routine in the call tree of this */
985 /*         routine. */
986 
987 /*     7)  If the size of the workspace is too small, an error is */
988 /*         signaled by a routine in the call tree of this routine. */
989 
990 /*     8)  If ADJUST is negative, an error is signaled by a routine in */
991 /*         the call tree of this routine. */
992 
993 /*     9)  If either of the input body names do not map to NAIF ID */
994 /*         codes, an error is signaled by a routine in the call tree of */
995 /*         this routine. */
996 
997 /*     10) If required ephemerides or other kernel data are not */
998 /*         available, an error is signaled by a routine in the call tree */
999 /*         of this routine. */
1000 
1001 /*     11) If a body has unequal equatorial radii, a search for */
1002 /*         coordinate events in the GEODETIC or PLANETOGRAPHIC coordinate */
1003 /*         systems will cause the SPICE(NOTSUPPORTED) error to signal. */
1004 
1005 /* $ Files */
1006 
1007 /*     Appropriate SPK and PCK kernels must be loaded by the calling */
1008 /*     program before this routine is called. */
1009 
1010 /*     The following data are required: */
1011 
1012 /*        - SPK data: the calling application must load ephemeris data */
1013 /*          for the targets, observer, and any intermediate objects in */
1014 /*          a chain connecting the targets and observer that cover the */
1015 /*          time period specified by the window CNFINE. If aberration */
1016 /*          corrections are used, the states of target and observer */
1017 /*          relative to the solar system barycenter must be calculable */
1018 /*          from the available ephemeris data. Typically ephemeris data */
1019 /*          are made available by loading one or more SPK files using */
1020 /*          FURNSH. */
1021 
1022 /*        - If non-inertial reference frames are used, then PCK */
1023 /*          files, frame kernels, C-kernels, and SCLK kernels may be */
1024 /*          needed. */
1025 
1026 /*     Such kernel data are normally loaded once per program run, NOT */
1027 /*     every time this routine is called. */
1028 
1029 /* $ Particulars */
1030 
1031 /*     This routine provides a simpler, but less flexible interface */
1032 /*     than does the routine GFEVNT for conducting searches for */
1033 /*     surface intercept vector coordinate value events. */
1034 /*     Applications that require support for progress reporting, */
1035 /*     interrupt handling, non-default step or refinement functions, or */
1036 /*     non-default convergence tolerance should call GFEVNT rather than */
1037 /*     this routine. */
1038 
1039 /*     This routine determines a set of one or more time intervals */
1040 /*     within the confinement window when the selected coordinate of */
1041 /*     the surface intercept position vector satisfies a caller-specified */
1042 /*     constraint. The resulting set of intervals is returned as a SPICE */
1043 /*     window. */
1044 
1045 /*     Below we discuss in greater detail aspects of this routine's */
1046 /*     solution process that are relevant to correct and efficient */
1047 /*     use of this routine in user applications. */
1048 
1049 
1050 /*     The Search Process */
1051 /*     ================== */
1052 
1053 /*     Regardless of the type of constraint selected by the caller, this */
1054 /*     routine starts the search for solutions by determining the time */
1055 /*     periods, within the confinement window, over which the specified */
1056 /*     coordinate function is monotone increasing and monotone */
1057 /*     decreasing. Each of these time periods is represented by a SPICE */
1058 /*     window. Having found these windows, all of the coordinate */
1059 /*     function's local extrema within the confinement window are known. */
1060 /*     Absolute extrema then can be found very easily. */
1061 
1062 /*     Within any interval of these "monotone" windows, there will be at */
1063 /*     most one solution of any equality constraint. Since the boundary */
1064 /*     of the solution set for any inequality constraint is contained in */
1065 /*     the union of */
1066 
1067 /*        - the set of points where an equality constraint is met */
1068 /*        - the boundary points of the confinement window */
1069 
1070 /*     the solutions of both equality and inequality constraints can be */
1071 /*     found easily once the monotone windows have been found. */
1072 
1073 
1074 /*     Step Size */
1075 /*     ========= */
1076 
1077 /*     The monotone windows (described above) are found using a two-step */
1078 /*     search process. Each interval of the confinement window is */
1079 /*     searched as follows: first, the input step size is used to */
1080 /*     determine the time separation at which the sign of the rate of */
1081 /*     change of coordinate will be sampled. Starting at */
1082 /*     the left endpoint of an interval, samples will be taken at each */
1083 /*     step. If a change of sign is found, a root has been bracketed; at */
1084 /*     that point, the time at which the time derivative of the */
1085 /*     coordinate is zero can be found by a refinement process, for */
1086 /*     example, using a binary search. */
1087 
1088 /*     Note that the optimal choice of step size depends on the lengths */
1089 /*     of the intervals over which the coordinate function is monotone: */
1090 /*     the step size should be shorter than the shortest of these */
1091 /*     intervals (within the confinement window). */
1092 
1093 /*     The optimal step size is *not* necessarily related to the lengths */
1094 /*     of the intervals comprising the result window. For example, if */
1095 /*     the shortest monotone interval has length 10 days, and if the */
1096 /*     shortest result window interval has length 5 minutes, a step size */
1097 /*     of 9.9 days is still adequate to find all of the intervals in the */
1098 /*     result window. In situations like this, the technique of using */
1099 /*     monotone windows yields a dramatic efficiency improvement over a */
1100 /*     state-based search that simply tests at each step whether the */
1101 /*     specified constraint is satisfied. The latter type of search can */
1102 /*     miss solution intervals if the step size is longer than the */
1103 /*     shortest solution interval. */
1104 
1105 /*     Having some knowledge of the relative geometry of the target and */
1106 /*     observer can be a valuable aid in picking a reasonable step size. */
1107 /*     In general, the user can compensate for lack of such knowledge by */
1108 /*     picking a very short step size; the cost is increased computation */
1109 /*     time. */
1110 
1111 /*     Note that the step size is not related to the precision with which */
1112 /*     the endpoints of the intervals of the result window are computed. */
1113 /*     That precision level is controlled by the convergence tolerance. */
1114 
1115 
1116 /*     Convergence Tolerance */
1117 /*     ===================== */
1118 
1119 /*     Once a root has been bracketed, a refinement process is used to */
1120 /*     narrow down the time interval within which the root must lie. */
1121 /*     This refinement process terminates when the location of the root */
1122 /*     has been determined to within an error margin called the */
1123 /*     "convergence tolerance." The default convergence tolerance */
1124 /*     used by this routine is set by the parameter CNVTOL (defined */
1125 /*     in gf.inc). */
1126 
1127 /*     The value of CNVTOL is set to a "tight" value so that the */
1128 /*     tolerance doesn't become the limiting factor in the accuracy of */
1129 /*     solutions found by this routine. In general the accuracy of input */
1130 /*     data will be the limiting factor. */
1131 
1132 /*     The user may change the convergence tolerance from the default */
1133 /*     CNVTOL value by calling the routine GFSTOL, e.g. */
1134 
1135 /*        CALL GFSTOL( tolerance value ) */
1136 
1137 /*     Call GFSTOL prior to calling this routine. All subsequent */
1138 /*     searches will use the updated tolerance value. */
1139 
1140 /*     Setting the tolerance tighter than CNVTOL is unlikely to be */
1141 /*     useful, since the results are unlikely to be more accurate. */
1142 /*     Making the tolerance looser will speed up searches somewhat, */
1143 /*     since a few convergence steps will be omitted. However, in most */
1144 /*     cases, the step size is likely to have a much greater effect */
1145 /*     on processing time than would the convergence tolerance. */
1146 
1147 
1148 /*     The Confinement Window */
1149 /*     ====================== */
1150 
1151 /*     The simplest use of the confinement window is to specify a time */
1152 /*     interval within which a solution is sought. However, the */
1153 /*     confinement window can, in some cases, be used to make searches */
1154 /*     more efficient. Sometimes it's possible to do an efficient search */
1155 /*     to reduce the size of the time period over which a relatively */
1156 /*     slow search of interest must be performed. */
1157 
1158 /*     Practical use of the coordinate search capability would likely */
1159 /*     consist of searches over multiple coordinate constraints to find */
1160 /*     time intervals that satisfies the constraints. An */
1161 /*     effective technique to accomplish such a search is */
1162 /*     to use the result window from one search as the confinement window */
1163 /*     of the next. */
1164 
1165 /*     Longitude and Right Ascension */
1166 /*     ============================= */
1167 
1168 /*     The cyclic nature of the longitude and right ascension coordinates */
1169 /*     produces branch cuts at +/- 180 degrees longitude and 0-360 */
1170 /*     longitude. Round-off error may cause solutions near these branches */
1171 /*     to cross the branch. Use of the SPICE routine WNCOND will contract */
1172 /*     solution windows by some epsilon, reducing the measure of the */
1173 /*     windows and eliminating the branch crossing. A one millisecond */
1174 /*     contraction will in most cases eliminate numerical round-off */
1175 /*     caused branch crossings. */
1176 
1177 /* $ Examples */
1178 
1179 /*     The numerical results shown for these examples may differ across */
1180 /*     platforms. The results depend on the SPICE kernels used as */
1181 /*     input, the compiler and supporting libraries, and the machine */
1182 /*     specific arithmetic implementation. */
1183 
1184 /*     The examples shown below require a "standard" set of SPICE */
1185 /*     kernels. We list these kernels in a meta kernel named */
1186 /*     'standard.tm'. */
1187 
1188 /*        KPL/MK */
1189 
1190 /*           This meta-kernel is intended to support operation of SPICE */
1191 /*           example programs. The kernels shown here should not be */
1192 /*           assumed to contain adequate or correct versions of data */
1193 /*           required by SPICE-based user applications. */
1194 
1195 /*           In order for an application to use this meta-kernel, the */
1196 /*           kernels referenced here must be present in the user's */
1197 /*           current working directory. */
1198 
1199 /*           The names and contents of the kernels referenced */
1200 /*           by this meta-kernel are as follows: */
1201 
1202 /*              File name                     Contents */
1203 /*              ---------                     -------- */
1204 /*              de414.bsp                     Planetary ephemeris */
1205 /*              pck00008.tpc                  Planet orientation and */
1206 /*                                            radii */
1207 /*              naif0008.tls                  Leapseconds */
1208 
1209 
1210 /*           \begindata */
1211 
1212 /*           KERNELS_TO_LOAD = ( '/kernels/gen/lsk/naif0008.tls' */
1213 /*                               '/kernels/gen/spk/de414.bsp' */
1214 /*                               '/kernels/gen/pck/pck00008.tpc' */
1215 /*                             ) */
1216 
1217 
1218 /*     The examples shown below require a frames kernel defining a */
1219 /*     a dynamic frame, Sun-Earth Motion. The frame defined by the */
1220 /*     sun-to-earth direction vector as the X axis. The Y axis in the */
1221 /*     earth orbital plane, and Z completing the right hand system. */
1222 
1223 /*     We name this frames kernel "sem.tf". */
1224 
1225 /*     \begindata */
1226 
1227 /*       FRAME_SEM                     =  10100000 */
1228 /*       FRAME_10100000_NAME           = 'SEM' */
1229 /*       FRAME_10100000_CLASS          =  5 */
1230 /*       FRAME_10100000_CLASS_ID       =  10100000 */
1231 /*       FRAME_10100000_CENTER         =  10 */
1232 /*       FRAME_10100000_RELATIVE       = 'J2000' */
1233 /*       FRAME_10100000_DEF_STYLE      = 'PARAMETERIZED' */
1234 /*       FRAME_10100000_FAMILY         = 'TWO-VECTOR' */
1235 /*       FRAME_10100000_PRI_AXIS       = 'X' */
1236 /*       FRAME_10100000_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION' */
1237 /*       FRAME_10100000_PRI_OBSERVER   = 'SUN' */
1238 /*       FRAME_10100000_PRI_TARGET     = 'EARTH' */
1239 /*       FRAME_10100000_PRI_ABCORR     = 'NONE' */
1240 /*       FRAME_10100000_SEC_AXIS       = 'Y' */
1241 /*       FRAME_10100000_SEC_VECTOR_DEF = 'OBSERVER_TARGET_VELOCITY' */
1242 /*       FRAME_10100000_SEC_OBSERVER   = 'SUN' */
1243 /*       FRAME_10100000_SEC_TARGET     = 'EARTH' */
1244 /*       FRAME_10100000_SEC_ABCORR     = 'NONE' */
1245 /*       FRAME_10100000_SEC_FRAME      = 'J2000' */
1246 
1247 /*     Example(1) */
1248 
1249 /*     Find the time during 2007 for which the latitude of the */
1250 /*     intercept point of the vector pointing from the sun towards */
1251 /*     the earth in the IAU_EARTH frame equals zero i.e. the intercept */
1252 /*     point crosses the equator. */
1253 
1254 /*           PROGRAM GFSNTC_EX1 */
1255 /*           IMPLICIT              NONE */
1256 
1257 /*     C */
1258 /*     C     Include GF parameter declarations: */
1259 /*     C */
1260 /*           INCLUDE               'gf.inc' */
1261 
1262 /*     C */
1263 /*     C     SPICELIB functions */
1264 /*     C */
1265 /*           DOUBLE PRECISION      SPD */
1266 /*           INTEGER               WNCARD */
1267 
1268 /*     C */
1269 /*     C     Local variables and initial parameters. */
1270 /*     C */
1271 /*           INTEGER               LBCELL */
1272 /*           PARAMETER           ( LBCELL = -5 ) */
1273 
1274 /*     C */
1275 /*     C     Create 50 windows. */
1276 /*     C */
1277 /*           INTEGER               MAXWIN */
1278 /*           PARAMETER           ( MAXWIN = 1000 ) */
1279 
1280 /*     C */
1281 /*     C     One window consists of two intervals. */
1282 /*     C */
1283 /*           INTEGER               NINTRVL */
1284 /*           PARAMETER           ( NINTRVL = MAXWIN *2 ) */
1285 
1286 /*           INTEGER               STRLEN */
1287 /*           PARAMETER           ( STRLEN = 64 ) */
1288 
1289 /*           CHARACTER*(STRLEN)    BEGSTR */
1290 /*           CHARACTER*(STRLEN)    ENDSTR */
1291 /*           CHARACTER*(STRLEN)    TARGET */
1292 /*           CHARACTER*(STRLEN)    OBSRVR */
1293 /*           CHARACTER*(STRLEN)    DREF */
1294 /*           CHARACTER*(STRLEN)    ABCORR */
1295 /*           CHARACTER*(STRLEN)    METHOD */
1296 /*           CHARACTER*(STRLEN)    FIXREF */
1297 /*           CHARACTER*(STRLEN)    CRDSYS */
1298 /*           CHARACTER*(STRLEN)    COORD */
1299 /*           CHARACTER*(STRLEN)    RELATE */
1300 
1301 /*           DOUBLE PRECISION      STEP */
1302 /*           DOUBLE PRECISION      DVEC   ( 3 ) */
1303 /*           DOUBLE PRECISION      CNFINE ( LBCELL : NINTRVL ) */
1304 /*           DOUBLE PRECISION      RESULT ( LBCELL : NINTRVL ) */
1305 /*           DOUBLE PRECISION      WORK   ( LBCELL : NINTRVL, NWMAX ) */
1306 
1307 
1308 /*           DOUBLE PRECISION      BEGTIM */
1309 /*           DOUBLE PRECISION      ENDTIM */
1310 /*           DOUBLE PRECISION      BEG */
1311 /*           DOUBLE PRECISION      END */
1312 /*           DOUBLE PRECISION      REFVAL */
1313 /*           DOUBLE PRECISION      ADJUST */
1314 /*           INTEGER               COUNT */
1315 
1316 /*           INTEGER               I */
1317 
1318 
1319 /*     C */
1320 /*     C     The SEM frame defines the X axis as always earth pointing. */
1321 /*     C */
1322 /*     C     Define the earth pointing vector in the SEM frame. */
1323 /*     C */
1324 /*           DATA                  DVEC   / 1.D0, 0.D0, 0.D0 / */
1325 
1326 /*     C */
1327 /*     C     Load kernels. */
1328 /*     C */
1329 /*           CALL FURNSH ('standard.tm') */
1330 /*           CALL FURNSH ('sem.tf') */
1331 
1332 /*     C */
1333 /*     C     Initialize windows RESULT and CNFINE. */
1334 /*     C */
1335 /*           CALL SSIZED ( NINTRVL, RESULT ) */
1336 /*           CALL SSIZED ( 2,      CNFINE ) */
1337 
1338 /*     C */
1339 /*     C     Store the time bounds of our search interval in */
1340 /*     C     the CNFINE confinement window. */
1341 /*     C */
1342 /*           CALL STR2ET ( '2007 JAN 01', BEGTIM ) */
1343 /*           CALL STR2ET ( '2008 JAN 01', ENDTIM ) */
1344 
1345 /*           CALL WNINSD ( BEGTIM, ENDTIM, CNFINE ) */
1346 
1347 /*     C */
1348 /*     C     Search using a step size of 1 day (in units of seconds). */
1349 /*     C */
1350 /*           STEP   = SPD() */
1351 
1352 /*     C */
1353 /*     C     Search for a condition where the latitudinal system */
1354 /*     C     coordinate latitude in the IAU_EARTH frame has value zero. */
1355 /*     C     In this case, the pointing vector, 'DVEC', defines the */
1356 /*     C     vector direction pointing at the earth from the sun. */
1357 /*     C */
1358 /*           ADJUST = 0.D0 */
1359 /*           REFVAL = 0.D0 */
1360 /*           TARGET = 'EARTH' */
1361 /*           OBSRVR = 'SUN' */
1362 /*           DREF   = 'SEM' */
1363 /*           METHOD = 'Ellipsoid' */
1364 /*           FIXREF = 'IAU_EARTH' */
1365 /*           CRDSYS = 'LATITUDINAL' */
1366 /*           COORD  = 'LATITUDE' */
1367 /*           RELATE = '=' */
1368 
1369 /*     C */
1370 /*     C     Use the same aberration correction flag as that in the SEM */
1371 /*     C     frame definition. */
1372 /*     C */
1373 /*           ABCORR = 'NONE' */
1374 
1375 /*           CALL GFSNTC (  TARGET,  FIXREF, */
1376 /*          .               METHOD,  ABCORR, OBSRVR, */
1377 /*          .               DREF,    DVEC, */
1378 /*          .               CRDSYS,  COORD, */
1379 /*          .               RELATE,  REFVAL, */
1380 /*          .               ADJUST,  STEP, CNFINE, */
1381 /*          .               NINTRVL, NWMAX, WORK, RESULT ) */
1382 
1383 /*     C */
1384 /*     C     Check the number of intervals in the result window. */
1385 /*     C */
1386 /*           COUNT = WNCARD(RESULT) */
1387 
1388 /*     C */
1389 /*     C     List the beginning and ending points in each interval */
1390 /*     C     if RESULT contains data. */
1391 /*     C */
1392 /*           IF ( COUNT .EQ. 0 ) THEN */
1393 /*              WRITE (*, '(A)') 'Result window is empty.' */
1394 /*           ELSE */
1395 
1396 /*              DO I = 1, COUNT */
1397 
1398 /*     C */
1399 /*     C           Fetch the endpoints of the Ith interval */
1400 /*     C           of the result window. */
1401 /*     C */
1402 /*                 CALL WNFETD ( RESULT, I, BEG, END  ) */
1403 
1404 /*                 CALL TIMOUT ( BEG, */
1405 /*          .                'YYYY-MON-DD HR:MN:SC.###### ' */
1406 /*          .      //        '(TDB) ::TDB ::RND',  BEGSTR ) */
1407 /*                 CALL TIMOUT ( END, */
1408 /*          .                'YYYY-MON-DD HR:MN:SC.###### ' */
1409 /*          .      //        '(TDB) ::TDB ::RND',  ENDSTR ) */
1410 
1411 /*                 WRITE (*,*) 'Interval ',  I */
1412 /*                 WRITE (*,*) 'Beginning TDB ', BEGSTR */
1413 /*                 WRITE (*,*) 'Ending TDB    ', ENDSTR */
1414 
1415 /*              END DO */
1416 
1417 /*           END IF */
1418 
1419 /*           END */
1420 
1421 /*      The program outputs: */
1422 
1423 /*         Interval  1 */
1424 /*         Beginning TDB 2007-MAR-21 00:01:25.495120 (TDB) */
1425 /*         Ending TDB    2007-MAR-21 00:01:25.495120 (TDB) */
1426 
1427 /*         Interval  2 */
1428 /*         Beginning TDB 2007-SEP-23 09:46:39.574123 (TDB) */
1429 /*         Ending TDB    2007-SEP-23 09:46:39.574123 (TDB) */
1430 
1431 /*      Example(2) */
1432 
1433 /*      Find the time during 2007 for which the intercept point on the */
1434 /*      earth of the sun-to-earth vector as described in Example 1 in */
1435 /*      the IAU_EARTH frame lies within a geodetic latitude-longitude */
1436 /*      "box" defined as */
1437 
1438 /*         16 degrees <= latitude  <= 17 degrees */
1439 /*         85 degrees <= longitude <= 86 degrees */
1440 
1441 /*      This problem requires four searches, each search on one of the */
1442 /*      box restrictions. The user needs also realize the temporal */
1443 /*      behavior of latitude greatly differs from that of the longitude. */
1444 /*      The intercept latitude varies between approximately 23.44 degrees */
1445 /*      and -23.44 degrees during the year. The intercept longitude */
1446 /*      varies between -180 degrees and 180 degrees in one day. */
1447 
1448 /*           PROGRAM GFSNTC_EX2 */
1449 /*           IMPLICIT              NONE */
1450 
1451 /*     C */
1452 /*     C     Include GF parameter declarations: */
1453 /*     C */
1454 /*           INCLUDE               'gf.inc' */
1455 
1456 /*     C */
1457 /*     C     SPICELIB functions */
1458 /*     C */
1459 /*           DOUBLE PRECISION      SPD */
1460 /*           DOUBLE PRECISION      RPD */
1461 /*           INTEGER               WNCARD */
1462 
1463 /*     C */
1464 /*     C     Local variables and initial parameters. */
1465 /*     C */
1466 /*           INTEGER               LBCELL */
1467 /*           PARAMETER           ( LBCELL = -5 ) */
1468 
1469 /*     C */
1470 /*     C     Create 50 windows. */
1471 /*     C */
1472 /*           INTEGER               MAXWIN */
1473 /*           PARAMETER           ( MAXWIN = 1000 ) */
1474 
1475 /*     C */
1476 /*     C     One window consists of two intervals. */
1477 /*     C */
1478 /*           INTEGER               NINTRVL */
1479 /*           PARAMETER           ( NINTRVL = MAXWIN *2 ) */
1480 
1481 /*           INTEGER               STRLEN */
1482 /*           PARAMETER           ( STRLEN = 64 ) */
1483 
1484 /*           CHARACTER*(STRLEN)    BEGSTR */
1485 /*           CHARACTER*(STRLEN)    ENDSTR */
1486 /*           CHARACTER*(STRLEN)    TARGET */
1487 /*           CHARACTER*(STRLEN)    OBSRVR */
1488 /*           CHARACTER*(STRLEN)    DREF */
1489 /*           CHARACTER*(STRLEN)    ABCORR */
1490 /*           CHARACTER*(STRLEN)    METHOD */
1491 /*           CHARACTER*(STRLEN)    FIXREF */
1492 /*           CHARACTER*(STRLEN)    CRDSYS */
1493 /*           CHARACTER*(STRLEN)    COORD */
1494 /*           CHARACTER*(STRLEN)    RELATE */
1495 
1496 /*           DOUBLE PRECISION      STEP */
1497 /*           DOUBLE PRECISION      DVEC    ( 3 ) */
1498 /*           DOUBLE PRECISION      CNFINE  ( LBCELL : NINTRVL ) */
1499 /*           DOUBLE PRECISION      RESULT1 ( LBCELL : NINTRVL ) */
1500 /*           DOUBLE PRECISION      RESULT2 ( LBCELL : NINTRVL ) */
1501 /*           DOUBLE PRECISION      RESULT3 ( LBCELL : NINTRVL ) */
1502 /*           DOUBLE PRECISION      RESULT4 ( LBCELL : NINTRVL ) */
1503 /*           DOUBLE PRECISION      WORK    ( LBCELL : NINTRVL, NWMAX ) */
1504 
1505 
1506 /*           DOUBLE PRECISION      BEGTIM */
1507 /*           DOUBLE PRECISION      ENDTIM */
1508 /*           DOUBLE PRECISION      BEG */
1509 /*           DOUBLE PRECISION      END */
1510 /*           DOUBLE PRECISION      REFVAL */
1511 /*           DOUBLE PRECISION      ADJUST */
1512 
1513 /*           INTEGER               COUNT */
1514 /*           INTEGER               I */
1515 
1516 
1517 /*     C */
1518 /*     C     The SEM frame defines the X axis as always earth pointing. */
1519 /*     C */
1520 /*     C     Define the earth pointing vector in the SEM frame. */
1521 /*     C */
1522 /*           DATA                  DVEC   / 1.D0, 0.D0, 0.D0 / */
1523 
1524 /*     C */
1525 /*     C     Load kernels. */
1526 /*     C */
1527 /*           CALL FURNSH ('standard.tm') */
1528 /*           CALL FURNSH ('sem.tf') */
1529 
1530 /*     C */
1531 /*     C     Initialize windows RESULT and CNFINE. */
1532 /*     C */
1533 /*           CALL SSIZED ( NINTRVL, RESULT1 ) */
1534 /*           CALL SSIZED ( NINTRVL, RESULT2 ) */
1535 /*           CALL SSIZED ( NINTRVL, RESULT3 ) */
1536 /*           CALL SSIZED ( NINTRVL, RESULT4 ) */
1537 /*           CALL SSIZED ( 2,      CNFINE ) */
1538 
1539 /*     C */
1540 /*     C     Store the time bounds of our search interval in */
1541 /*     C     the CNFINE confinement window. */
1542 /*     C */
1543 /*           CALL STR2ET ( '2007 JAN 01', BEGTIM ) */
1544 /*           CALL STR2ET ( '2008 JAN 01', ENDTIM ) */
1545 
1546 /*           CALL WNINSD ( BEGTIM, ENDTIM, CNFINE ) */
1547 
1548 /*     C */
1549 /*     C     The latitude varies relatively slowly, ~46 degrees during */
1550 /*     C     the year. The extrema occur approximately every six months. */
1551 /*     C     Search using a step size less than half that value */
1552 /*     C     (180 days). For this example use ninety days (in units */
1553 /*     C     of seconds). */
1554 /*     C */
1555 /*           STEP   = SPD()*90.D0 */
1556 
1557 /*     C */
1558 /*     C     Perform four searches to determine the times when the */
1559 /*     C     latitude-longitude box restriction conditions apply. In */
1560 /*     C     this case, the pointing vector, 'DVEC', defines the vector */
1561 /*     C     direction pointing at the earth from the sun. */
1562 /*     C */
1563 /*     C     Use geodetic coordinates. */
1564 /*     C */
1565 /*           ADJUST = 0.D0 */
1566 /*           TARGET = 'EARTH' */
1567 /*           OBSRVR = 'SUN' */
1568 /*           DREF   = 'SEM' */
1569 /*           METHOD = 'Ellipsoid' */
1570 /*           FIXREF = 'IAU_EARTH' */
1571 /*           CRDSYS = 'GEODETIC' */
1572 
1573 
1574 /*     C */
1575 /*     C     Use the same aberration correction flag as that in the SEM */
1576 /*     C     frame definition. */
1577 /*     C */
1578 /*           ABCORR = 'NONE' */
1579 
1580 /*     C */
1581 /*     C     Perform the searches such that the result window of a search */
1582 /*     C     serves as the confinement window of the subsequent search. */
1583 /*     C */
1584 
1585 /*     C */
1586 /*     C     Since the latitude coordinate varies slowly and is well */
1587 /*     C     behaved over the time of the confinement window, search */
1588 /*     C     first for the windows satisfying the latitude requirements, */
1589 /*     C     then use that result as confinement for the longitude */
1590 /*     C     search. */
1591 /*     C */
1592 /*           COORD  = 'LATITUDE' */
1593 /*           REFVAL = 16.D0 * RPD() */
1594 /*           RELATE = '>' */
1595 
1596 /*           CALL GFSNTC (  TARGET,  FIXREF, */
1597 /*          .               METHOD,  ABCORR, OBSRVR, */
1598 /*          .               DREF,    DVEC, */
1599 /*          .               CRDSYS,  COORD, */
1600 /*          .               RELATE,  REFVAL, */
1601 /*          .               ADJUST,  CNFINE, STEP, */
1602 /*          .               NINTRVL, NWMAX, WORK, RESULT1 ) */
1603 
1604 /*           REFVAL = 17.D0 * RPD() */
1605 /*           RELATE = '<' */
1606 
1607 /*           CALL GFSNTC (  TARGET,  FIXREF, */
1608 /*          .               METHOD,  ABCORR, OBSRVR, */
1609 /*          .               DREF,    DVEC, */
1610 /*          .               CRDSYS,  COORD, */
1611 /*          .               RELATE,  REFVAL, */
1612 /*          .               ADJUST,  RESULT1, STEP, */
1613 /*          .               NINTRVL, NWMAX, WORK, RESULT2 ) */
1614 
1615 
1616 /*     C */
1617 /*     C     Now the longitude search. */
1618 /*     C */
1619 /*           COORD  = 'LONGITUDE' */
1620 
1621 /*     C */
1622 /*     C     Reset the stepsize to something appropriate for the 360 */
1623 /*     C     degrees in 24 hours domain. The longitude shows near */
1624 /*     C     linear behavior so use a stepsize less than half the period */
1625 /*     C     of twelve hours. Ten hours will suffice in this case. */
1626 /*     C */
1627 /*           STEP   = SPD() * (10.D0/24.D0) */
1628 
1629 /*           REFVAL = 85.D0 * RPD() */
1630 /*           RELATE = '>' */
1631 
1632 /*           CALL GFSNTC (  TARGET,  FIXREF, */
1633 /*          .               METHOD,  ABCORR, OBSRVR, */
1634 /*          .               DREF,    DVEC, */
1635 /*          .               CRDSYS,  COORD, */
1636 /*          .               RELATE,  REFVAL, */
1637 /*          .               ADJUST,  RESULT2, STEP, */
1638 /*          .               NINTRVL, NWMAX, WORK, RESULT3 ) */
1639 
1640 /*     C */
1641 /*     C     Contract the endpoints of each window to account */
1642 /*     C     for possible round-off error at the -180/180 degree branch. */
1643 /*     C */
1644 /*     C     A contraction value of a millisecond should eliminate */
1645 /*     C     any round-off caused branch crossing. */
1646 /*     C */
1647 /*           CALL WNCOND ( 1D-3, 1D-3, RESULT3 ) */
1648 
1649 /*           REFVAL = 86.D0 * RPD() */
1650 /*           RELATE = '<' */
1651 
1652 /*           CALL GFSNTC (  TARGET,  FIXREF, */
1653 /*          .               METHOD,  ABCORR, OBSRVR, */
1654 /*          .               DREF,    DVEC, */
1655 /*          .               CRDSYS,  COORD, */
1656 /*          .               RELATE,  REFVAL, */
1657 /*          .               ADJUST,  RESULT3, STEP, */
1658 /*          .               NINTRVL, NWMAX, WORK, RESULT4 ) */
1659 
1660 /*     C */
1661 /*     C     Check the number of intervals in the result window. */
1662 /*     C */
1663 /*           COUNT = WNCARD(RESULT4) */
1664 
1665 /*     C */
1666 /*     C     List the beginning and ending points in each interval */
1667 /*     C     if RESULT contains data. */
1668 /*     C */
1669 /*           IF ( COUNT .EQ. 0 ) THEN */
1670 /*              WRITE(*, '(A)') 'Result window is empty.' */
1671 /*           ELSE */
1672 
1673 /*              DO I = 1, COUNT */
1674 
1675 /*     C */
1676 /*     C           Fetch the endpoints of the Ith interval */
1677 /*     C           of the result window. */
1678 /*     C */
1679 /*                 CALL WNFETD ( RESULT4, I, BEG, END  ) */
1680 
1681 /*                 CALL TIMOUT ( BEG, */
1682 /*          .                'YYYY-MON-DD HR:MN:SC.###### ' */
1683 /*          .      //        '(TDB) ::TDB ::RND',  BEGSTR ) */
1684 /*                 CALL TIMOUT ( END, */
1685 /*          .                'YYYY-MON-DD HR:MN:SC.###### ' */
1686 /*          .      //        '(TDB) ::TDB ::RND',  ENDSTR ) */
1687 
1688 /*                 WRITE(*,*) 'Interval ',  I */
1689 /*                 WRITE(*,*) 'Beginning TDB ', BEGSTR */
1690 /*                 WRITE(*,*) 'Ending TDB    ', ENDSTR */
1691 /*                 WRITE(*,*) ' ' */
1692 
1693 /*              END DO */
1694 
1695 /*           END IF */
1696 
1697 /*           END */
1698 
1699 /*      The program outputs: */
1700 
1701 /*        Interval  1 */
1702 /*        Beginning TDB 2007-MAY-05 06:14:04.637735 (TDB) */
1703 /*        Ending TDB    2007-MAY-05 06:18:03.621908 (TDB) */
1704 
1705 /*        Interval  2 */
1706 /*        Beginning TDB 2007-MAY-06 06:13:59.583484 (TDB) */
1707 /*        Ending TDB    2007-MAY-06 06:17:58.569239 (TDB) */
1708 
1709 /*        Interval  3 */
1710 /*        Beginning TDB 2007-MAY-07 06:13:55.102940 (TDB) */
1711 /*        Ending TDB    2007-MAY-07 06:17:54.090299 (TDB) */
1712 
1713 /*        Interval  4 */
1714 /*        Beginning TDB 2007-AUG-06 06:23:17.282927 (TDB) */
1715 /*        Ending TDB    2007-AUG-06 06:27:16.264009 (TDB) */
1716 
1717 /*        Interval  5 */
1718 /*        Beginning TDB 2007-AUG-07 06:23:10.545441 (TDB) */
1719 /*        Ending TDB    2007-AUG-07 06:27:09.524926 (TDB) */
1720 
1721 /*        Interval  6 */
1722 /*        Beginning TDB 2007-AUG-08 06:23:03.233996 (TDB) */
1723 /*        Ending TDB    2007-AUG-08 06:27:02.211889 (TDB) */
1724 
1725 /*        Interval  7 */
1726 /*        Beginning TDB 2007-AUG-09 06:22:55.351256 (TDB) */
1727 /*        Ending TDB    2007-AUG-09 06:26:54.327566 (TDB) */
1728 
1729 /* $ Restrictions */
1730 
1731 /*     1) The kernel files to be used by this routine must be loaded */
1732 /*        (normally using the SPICELIB routine FURNSH) before this */
1733 /*        routine is called. */
1734 
1735 /*     2) This routine has the side effect of re-initializing the */
1736 /*        coordinate quantity utility package.  Callers may */
1737 /*        need to re-initialize the package after calling this routine. */
1738 
1739 /* $ Literature_References */
1740 
1741 /*     None. */
1742 
1743 /* $ Author_and_Institution */
1744 
1745 /*     N.J. Bachman   (JPL) */
1746 /*     E.D. Wright    (JPL) */
1747 
1748 /* $ Version */
1749 
1750 /* -    SPICELIB Version 1.1.0, 05-SEP-2012 (EDW) */
1751 
1752 /*        Edit to comments to correct search description. */
1753 
1754 /*        Implemented use of ZZHOLDD to allow user to alter convergence */
1755 /*        tolerance. */
1756 
1757 /*        Removed the STEP > 0 error check. The GFSSTP call includes */
1758 /*        the check. */
1759 
1760 /* -    SPICELIB Version 1.0.1, 16-FEB-2010 (NJB) (EDW) */
1761 
1762 /*        Edits to and corrections of argument descriptions and */
1763 /*        header. */
1764 
1765 /* -    SPICELIB Version 1.0.0, 17-FEB-2009 (NJB) (EDW) */
1766 
1767 /* -& */
1768 /* $ Index_Entries */
1769 
1770 /*     GF surface intercept coordinate search */
1771 
1772 /* -& */
1773 
1774 /*     SPICELIB functions */
1775 
1776 
1777 /*     Routines to set step size, refine transition times */
1778 /*     and report work. */
1779 
1780 
1781 /*     Local parameters */
1782 
1783 
1784 /*     Local variables */
1785 
1786 
1787 /*     Quantity definition parameter arrays: */
1788 
1789 
1790 /*     Standard SPICE error handling. */
1791 
1792     /* Parameter adjustments */
1793     work_dim1 = *mw + 6;
1794     work_offset = work_dim1 - 5;
1795 
1796     /* Function Body */
1797     if (return_()) {
1798 	return 0;
1799     }
1800 
1801 /*     Check into the error subsystem. */
1802 
1803     chkin_("GFSNTC", (ftnlen)6);
1804 
1805 /*     Confirm minimum window sizes. */
1806 
1807     if (*mw < 2 || ! even_(mw)) {
1808 	setmsg_("Workspace window size was #; size must be at least 2 and an"
1809 		" even value.", (ftnlen)71);
1810 	errint_("#", mw, (ftnlen)1);
1811 	sigerr_("SPICE(INVALIDDIMENSION)", (ftnlen)23);
1812 	chkout_("GFSNTC", (ftnlen)6);
1813 	return 0;
1814     }
1815     if (sized_(result) < 2) {
1816 	setmsg_("Result window size was #; size must be at least 2.", (ftnlen)
1817 		50);
1818 	i__1 = sized_(result);
1819 	errint_("#", &i__1, (ftnlen)1);
1820 	sigerr_("SPICE(INVALIDDIMENSION)", (ftnlen)23);
1821 	chkout_("GFSNTC", (ftnlen)6);
1822 	return 0;
1823     }
1824 
1825 /*     Set up a call to GFEVNT specific to the surface intercept */
1826 /*     coordinate search. */
1827 
1828     s_copy(qpnams, "TARGET", (ftnlen)80, (ftnlen)6);
1829     s_copy(qcpars, target, (ftnlen)80, target_len);
1830     s_copy(qpnams + 80, "OBSERVER", (ftnlen)80, (ftnlen)8);
1831     s_copy(qcpars + 80, obsrvr, (ftnlen)80, obsrvr_len);
1832     s_copy(qpnams + 160, "ABCORR", (ftnlen)80, (ftnlen)6);
1833     s_copy(qcpars + 160, abcorr, (ftnlen)80, abcorr_len);
1834     s_copy(qpnams + 240, "COORDINATE SYSTEM", (ftnlen)80, (ftnlen)17);
1835     s_copy(qcpars + 240, crdsys, (ftnlen)80, crdsys_len);
1836     s_copy(qpnams + 320, "COORDINATE", (ftnlen)80, (ftnlen)10);
1837     s_copy(qcpars + 320, coord, (ftnlen)80, coord_len);
1838     s_copy(qpnams + 400, "REFERENCE FRAME", (ftnlen)80, (ftnlen)15);
1839     s_copy(qcpars + 400, fixref, (ftnlen)80, fixref_len);
1840     s_copy(qpnams + 480, "VECTOR DEFINITION", (ftnlen)80, (ftnlen)17);
1841     s_copy(qcpars + 480, "SURFACE INTERCEPT POINT", (ftnlen)80, (ftnlen)23);
1842     s_copy(qpnams + 560, "METHOD", (ftnlen)80, (ftnlen)6);
1843     s_copy(qcpars + 560, method, (ftnlen)80, method_len);
1844     s_copy(qpnams + 640, "DREF", (ftnlen)80, (ftnlen)4);
1845     s_copy(qcpars + 640, dref, (ftnlen)80, dref_len);
1846     s_copy(qpnams + 720, "DVEC", (ftnlen)80, (ftnlen)4);
1847     qdpars[0] = dvec[0];
1848     qdpars[1] = dvec[1];
1849     qdpars[2] = dvec[2];
1850 
1851 /*     Set the step size. */
1852 
1853     gfsstp_(step);
1854 
1855 /*     Retrieve the convergence tolerance, if set. */
1856 
1857     zzholdd_(&c_n1, &c__3, &ok, &tol);
1858 
1859 /*     Use the default value CNVTOL if no stored tolerance value. */
1860 
1861     if (! ok) {
1862 	tol = 1e-6;
1863     }
1864 
1865 /*     Initialize the RESULT window to empty. */
1866 
1867     scardd_(&c__0, result);
1868 
1869 /*     Look for solutions. */
1870 
1871 /*     Progress report and interrupt options are set to .FALSE. */
1872 
1873     gfevnt_((U_fp)gfstep_, (U_fp)gfrefn_, "COORDINATE", &c__10, qpnams,
1874 	    qcpars, qdpars, qipars, qlpars, relate, refval, &tol, adjust,
1875 	    cnfine, &c_false, (U_fp)gfrepi_, (U_fp)gfrepu_, (U_fp)gfrepf_, mw,
1876 	     nw, work, &c_false, (L_fp)gfbail_, result, (ftnlen)10, (ftnlen)
1877 	    80, (ftnlen)80, relate_len);
1878     chkout_("GFSNTC", (ftnlen)6);
1879     return 0;
1880 } /* gfsntc_ */
1881 
1882