1 /* zzgfcslv.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__15 = 15;
11 static integer c__7 = 7;
12 static integer c__0 = 0;
13 static integer c__1 = 1;
14 static logical c_false = FALSE_;
15 static doublereal c_b36 = 0.;
16 
17 /* $Procedure ZZGFCSLV ( GF, coordinate solver ) */
zzgfcslv_(char * vecdef,char * method,char * target,char * ref,char * abcorr,char * obsrvr,char * dref,doublereal * dvec,char * crdsys,char * crdnam,char * relate,doublereal * refval,doublereal * tol,doublereal * adjust,U_fp udstep,U_fp udrefn,logical * rpt,S_fp udrepi,U_fp udrepu,S_fp udrepf,logical * bail,L_fp udbail,integer * mw,integer * nw,doublereal * work,doublereal * cnfine,doublereal * result,ftnlen vecdef_len,ftnlen method_len,ftnlen target_len,ftnlen ref_len,ftnlen abcorr_len,ftnlen obsrvr_len,ftnlen dref_len,ftnlen crdsys_len,ftnlen crdnam_len,ftnlen relate_len)18 /* Subroutine */ int zzgfcslv_(char *vecdef, char *method, char *target, char
19 	*ref, char *abcorr, char *obsrvr, char *dref, doublereal *dvec, char *
20 	crdsys, char *crdnam, char *relate, doublereal *refval, doublereal *
21 	tol, doublereal *adjust, U_fp udstep, U_fp udrefn, logical *rpt, S_fp
22 	udrepi, U_fp udrepu, S_fp udrepf, logical *bail, L_fp udbail, integer
23 	*mw, integer *nw, doublereal *work, doublereal *cnfine, doublereal *
24 	result, ftnlen vecdef_len, ftnlen method_len, ftnlen target_len,
25 	ftnlen ref_len, ftnlen abcorr_len, ftnlen obsrvr_len, ftnlen dref_len,
26 	 ftnlen crdsys_len, ftnlen crdnam_len, ftnlen relate_len)
27 {
28     /* Initialized data */
29 
30     static char cnames[6*7] = ">     " "=     " "<     " "ABSMAX" "ABSMIN"
31 	    "LOCMAX" "LOCMIN";
32     static char rptpre[55*3] = "Coordinate pass 1 of #                      "
33 	    "           " "Coordinate pass 2 of #                            "
34 	    "     " "Intercept existence pass 1 of 1                        ";
35     static char rptsuf[13*3] = "done.        " "done.        " "done.        "
36 	    ;
37 
38     /* System generated locals */
39     integer work_dim1, work_dim2, work_offset, i__1, i__2, i__3;
40 
41     /* Builtin functions */
42     integer s_rnge(char *, integer, char *, integer), s_cmp(char *, char *,
43 	    ftnlen, ftnlen);
44 
45     /* Local variables */
46     extern /* Subroutine */ int zzgfcodc_();
47     extern /* Subroutine */ int zzgfcoin_(char *, char *, char *, char *,
48 	    char *, char *, char *, doublereal *, char *, char *, ftnlen,
49 	    ftnlen, ftnlen, ftnlen, ftnlen, ftnlen, ftnlen, ftnlen, ftnlen);
50     extern /* Subroutine */ int zzgfcoex_();
51     extern /* Subroutine */ int zzgflong_(char *, char *, char *, char *,
52 	    char *, char *, char *, doublereal *, char *, char *, char *,
53 	    doublereal *, doublereal *, doublereal *, U_fp, U_fp, logical *,
54 	    S_fp, U_fp, S_fp, logical *, L_fp, integer *, integer *,
55 	    doublereal *, doublereal *, doublereal *, ftnlen, ftnlen, ftnlen,
56 	    ftnlen, ftnlen, ftnlen, ftnlen, ftnlen, ftnlen, ftnlen);
57     extern /* Subroutine */ int zzgfudlt_();
58     extern /* Subroutine */ int zzgfrelx_(U_fp, U_fp, U_fp, U_fp, U_fp, char *
59 	    , doublereal *, doublereal *, doublereal *, doublereal *, integer
60 	    *, integer *, doublereal *, logical *, S_fp, U_fp, S_fp, char *,
61 	    char *, logical *, L_fp, doublereal *, ftnlen, ftnlen, ftnlen);
62     integer i__;
63     extern /* Subroutine */ int chkin_(char *, ftnlen), ucase_(char *, char *,
64 	     ftnlen, ftnlen), errch_(char *, char *, ftnlen, ftnlen);
65     doublereal excon;
66     extern /* Subroutine */ int errdp_(char *, doublereal *, ftnlen), copyd_(
67 	    doublereal *, doublereal *), repmi_(char *, char *, integer *,
68 	    char *, ftnlen, ftnlen, ftnlen);
69     integer npass;
70     doublereal start;
71     extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
72     extern logical failed_(void);
73     extern /* Subroutine */ int zzgfsolvx_(U_fp, U_fp, U_fp, U_fp, logical *,
74 	    L_fp, logical *, doublereal *, doublereal *, doublereal *,
75 	    doublereal *, logical *, U_fp, doublereal *), scardd_(integer *,
76 	    doublereal *);
77     extern integer isrchc_(char *, integer *, char *, ftnlen, ftnlen),
78 	    wncard_(doublereal *);
79     extern logical return_(void);
80     char loccrd[80], locvdf[80], prebuf[55*3];
81     doublereal finish;
82     logical localx, noadjx;
83     extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
84 	    integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
85 	    ftnlen), ssized_(integer *, doublereal *), cmprss_(char *,
86 	    integer *, char *, char *, ftnlen, ftnlen, ftnlen), wnfetd_(
87 	    doublereal *, integer *, doublereal *, doublereal *), wncond_(
88 	    doublereal *, doublereal *, doublereal *);
89     integer loc;
90     extern /* Subroutine */ int udf_();
91     char uop[6];
92     extern /* Subroutine */ int zzgfcog_();
93 
94 /* $ Abstract */
95 
96 /*     Perform a coordinate search. */
97 
98 /* $ Disclaimer */
99 
100 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
101 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
102 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
103 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
104 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
105 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
106 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
107 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
108 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
109 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
110 
111 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
112 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
113 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
114 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
115 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
116 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
117 
118 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
119 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
120 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
121 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
122 
123 /* $ Required_Reading */
124 
125 /*     GF */
126 /*     SPK */
127 /*     TIME */
128 /*     NAIF_IDS */
129 /*     FRAMES */
130 
131 /* $ Keywords */
132 
133 /*     GEOMETRY */
134 /*     PRIVATE */
135 /*     ROOT */
136 
137 /* $ Declarations */
138 /* $ Abstract */
139 
140 /*     This file contains public, global parameter declarations */
141 /*     for the SPICELIB Geometry Finder (GF) subsystem. */
142 
143 /* $ Disclaimer */
144 
145 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
146 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
147 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
148 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
149 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
150 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
151 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
152 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
153 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
154 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
155 
156 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
157 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
158 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
159 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
160 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
161 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
162 
163 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
164 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
165 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
166 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
167 
168 /* $ Required_Reading */
169 
170 /*     GF */
171 
172 /* $ Keywords */
173 
174 /*     GEOMETRY */
175 /*     ROOT */
176 
177 /* $ Restrictions */
178 
179 /*     None. */
180 
181 /* $ Author_and_Institution */
182 
183 /*     N.J. Bachman      (JPL) */
184 /*     L.E. Elson        (JPL) */
185 /*     E.D. Wright       (JPL) */
186 
187 /* $ Literature_References */
188 
189 /*     None. */
190 
191 /* $ Version */
192 
193 /* -    SPICELIB Version 2.0.0  29-NOV-2016 (NJB) */
194 
195 /*        Upgraded to support surfaces represented by DSKs. */
196 
197 /*        Bug fix: removed declaration of NVRMAX parameter. */
198 
199 /* -    SPICELIB Version 1.3.0, 01-OCT-2011 (NJB) */
200 
201 /*       Added NWILUM parameter. */
202 
203 /* -    SPICELIB Version 1.2.0, 14-SEP-2010 (EDW) */
204 
205 /*       Added NWPA parameter. */
206 
207 /* -    SPICELIB Version 1.1.0, 08-SEP-2009 (EDW) */
208 
209 /*       Added NWRR parameter. */
210 /*       Added NWUDS parameter. */
211 
212 /* -    SPICELIB Version 1.0.0, 21-FEB-2009 (NJB) (LSE) (EDW) */
213 
214 /* -& */
215 
216 /*     Root finding parameters: */
217 
218 /*     CNVTOL is the default convergence tolerance used by the */
219 /*     high-level GF search API routines. This tolerance is */
220 /*     used to terminate searches for binary state transitions: */
221 /*     when the time at which a transition occurs is bracketed */
222 /*     by two times that differ by no more than CNVTOL, the */
223 /*     transition time is considered to have been found. */
224 
225 /*     Units are TDB seconds. */
226 
227 
228 /*     NWMAX is the maximum number of windows allowed for user-defined */
229 /*     workspace array. */
230 
231 /*        DOUBLE PRECISION      WORK   ( LBCELL : MW, NWMAX ) */
232 
233 /*     Currently no more than twelve windows are required; the three */
234 /*     extra windows are spares. */
235 
236 /*     Callers of GFEVNT can include this file and use the parameter */
237 /*     NWMAX to declare the second dimension of the workspace array */
238 /*     if necessary. */
239 
240 
241 /*     Callers of GFIDST should declare their workspace window */
242 /*     count using NWDIST. */
243 
244 
245 /*     Callers of GFSEP should declare their workspace window */
246 /*     count using NWSEP. */
247 
248 
249 /*     Callers of GFRR should declare their workspace window */
250 /*     count using NWRR. */
251 
252 
253 /*     Callers of GFUDS should declare their workspace window */
254 /*     count using NWUDS. */
255 
256 
257 /*     Callers of GFPA should declare their workspace window */
258 /*     count using NWPA. */
259 
260 
261 /*     Callers of GFILUM should declare their workspace window */
262 /*     count using NWILUM. */
263 
264 
265 /*     ADDWIN is a parameter used to expand each interval of the search */
266 /*     (confinement) window by a small amount at both ends in order to */
267 /*     accommodate searches using equality constraints. The loaded */
268 /*     kernel files must accommodate these expanded time intervals. */
269 
270 
271 /*     FRMNLN is a string length for frame names. */
272 
273 
274 /*     FOVTLN -- maximum length for FOV string. */
275 
276 
277 /*     Specify the character strings that are allowed in the */
278 /*     specification of field of view shapes. */
279 
280 
281 /*     Character strings that are allowed in the */
282 /*     specification of occultation types: */
283 
284 
285 /*     Occultation target shape specifications: */
286 
287 
288 /*     Specify the number of supported occultation types and occultation */
289 /*     type string length: */
290 
291 
292 /*     Instrument field-of-view (FOV) parameters */
293 
294 /*     Maximum number of FOV boundary vectors: */
295 
296 
297 /*     FOV shape parameters: */
298 
299 /*        circle */
300 /*        ellipse */
301 /*        polygon */
302 /*        rectangle */
303 
304 
305 /*     End of file gf.inc. */
306 
307 /* $ Abstract */
308 
309 /*     SPICE private include file intended solely for the support of */
310 /*     SPICE routines. Users should not include this routine in their */
311 /*     source code due to the volatile nature of this file. */
312 
313 /*     This file contains private, global parameter declarations */
314 /*     for the SPICELIB Geometry Finder (GF) subsystem. */
315 
316 /* $ Disclaimer */
317 
318 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
319 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
320 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
321 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
322 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
323 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
324 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
325 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
326 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
327 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
328 
329 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
330 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
331 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
332 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
333 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
334 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
335 
336 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
337 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
338 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
339 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
340 
341 /* $ Required_Reading */
342 
343 /*     GF */
344 
345 /* $ Keywords */
346 
347 /*     GEOMETRY */
348 /*     ROOT */
349 
350 /* $ Restrictions */
351 
352 /*     None. */
353 
354 /* $ Author_and_Institution */
355 
356 /*     N.J. Bachman      (JPL) */
357 /*     E.D. Wright       (JPL) */
358 
359 /* $ Literature_References */
360 
361 /*     None. */
362 
363 /* $ Version */
364 
365 /* -    SPICELIB Version 1.0.0, 17-FEB-2009 (NJB) (EDW) */
366 
367 /* -& */
368 
369 /*     The set of supported coordinate systems */
370 
371 /*        System          Coordinates */
372 /*        ----------      ----------- */
373 /*        Rectangular     X, Y, Z */
374 /*        Latitudinal     Radius, Longitude, Latitude */
375 /*        Spherical       Radius, Colatitude, Longitude */
376 /*        RA/Dec          Range, Right Ascension, Declination */
377 /*        Cylindrical     Radius, Longitude, Z */
378 /*        Geodetic        Longitude, Latitude, Altitude */
379 /*        Planetographic  Longitude, Latitude, Altitude */
380 
381 /*     Below we declare parameters for naming coordinate systems. */
382 /*     User inputs naming coordinate systems must match these */
383 /*     when compared using EQSTR. That is, user inputs must */
384 /*     match after being left justified, converted to upper case, */
385 /*     and having all embedded blanks removed. */
386 
387 
388 /*     Below we declare names for coordinates. Again, user */
389 /*     inputs naming coordinates must match these when */
390 /*     compared using EQSTR. */
391 
392 
393 /*     Note that the RA parameter value below matches */
394 
395 /*        'RIGHT ASCENSION' */
396 
397 /*     when extra blanks are compressed out of the above value. */
398 
399 
400 /*     Parameters specifying types of vector definitions */
401 /*     used for GF coordinate searches: */
402 
403 /*     All string parameter values are left justified, upper */
404 /*     case, with extra blanks compressed out. */
405 
406 /*     POSDEF indicates the vector is defined by the */
407 /*     position of a target relative to an observer. */
408 
409 
410 /*     SOBDEF indicates the vector points from the center */
411 /*     of a target body to the sub-observer point on */
412 /*     that body, for a given observer and target. */
413 
414 
415 /*     SOBDEF indicates the vector points from the center */
416 /*     of a target body to the surface intercept point on */
417 /*     that body, for a given observer, ray, and target. */
418 
419 
420 /*     Number of workspace windows used by ZZGFREL: */
421 
422 
423 /*     Number of additional workspace windows used by ZZGFLONG: */
424 
425 
426 /*     Index of "existence window" used by ZZGFCSLV: */
427 
428 
429 /*     Progress report parameters: */
430 
431 /*     MXBEGM, */
432 /*     MXENDM    are, respectively, the maximum lengths of the progress */
433 /*               report message prefix and suffix. */
434 
435 /*     Note: the sum of these lengths, plus the length of the */
436 /*     "percent complete" substring, should not be long enough */
437 /*     to cause wrap-around on any platform's terminal window. */
438 
439 
440 /*     Total progress report message length upper bound: */
441 
442 
443 /*     End of file zzgf.inc. */
444 
445 /* $ Brief_I/O */
446 
447 /*     VARIABLE  I/O  DESCRIPTION */
448 /*     --------  ---  -------------------------------------------------- */
449 /*     LBCELL     P   Cell lower bound. */
450 /*     CNTRCT     P   Existence window contraction magnitude. */
451 /*     VECDEF     I   Vector definition. */
452 /*     METHOD     I   Computation method. */
453 /*     TARGET     I   Target name. */
454 /*     REF        I   Reference frame name. */
455 /*     ABCORR     I   Aberration correction. */
456 /*     OBSRVR     I   Observer name. */
457 /*     DREF       I   Ray's direction vector frame. */
458 /*     DVEC       I   Ray's direction vector. */
459 /*     CRDSYS     I   Coordinate system name. */
460 /*     CRDNAM     I   Coordinate name. */
461 /*     RELATE     I   Relational operator. */
462 /*     REFVAL     I   Reference value. */
463 /*     TOL        I   Convergence tolerance. */
464 /*     ADJUST     I   Absolute extremum adjustment value. */
465 /*     UDSTEP     I   Step size routine. */
466 /*     UDREFN     I   Search refinement routine. */
467 /*     RPT        I   Progress report flag. */
468 /*     UDREPI     I   Progress report initialization routine. */
469 /*     UDREPU     I   Progress report update routine. */
470 /*     UDREPF     I   Progress report termination routine. */
471 /*     BAIL       I   Bail-out flag. */
472 /*     UDBAIL     I   Bail-out status function. */
473 /*     MW         I   Workspace window size. */
474 /*     NW         I   Workspace window count. */
475 /*     WORK      I-O  Workspace window array. */
476 /*     CNFINE     I   Confinement window. */
477 /*     RESULT     O   Result window. */
478 
479 /* $ Detailed_Input */
480 
481 
482 /*     VECDEF     Every coordinate computed by this routine is a */
483 /*                function of an underlying vector. VECDEF is a short */
484 /*                string describing the means by which the vector of */
485 /*                interest is defined. Only parameters from the Fortran */
486 /*                INCLUDE file zzgf.inc should be used. Parameter names */
487 /*                and meanings are: */
488 
489 /*                   POSDEF               Vector is position of */
490 /*                                        target relative to observer. */
491 
492 /*                   SOBDEF               Vector is sub-observer */
493 /*                                        point on target body.  Vector */
494 /*                                        points from target body */
495 /*                                        center to sub-observer point. */
496 /*                                        The target must be an extended */
497 /*                                        body modeled as a triaxial */
498 /*                                        ellipsoid. */
499 
500 /*                   SINDEF               Vector is ray-surface intercept */
501 /*                                        point on target body. Vector */
502 /*                                        points from target body */
503 /*                                        center to sub-observer point. */
504 /*                                        The target must be an extended */
505 /*                                        body modeled as a triaxial */
506 /*                                        ellipsoid. */
507 
508 /*                Case, leading and trailing blanks ARE significant */
509 /*                in the string VECDEF. */
510 
511 
512 /*     METHOD     is a string specifying the computational method */
513 /*                applicable to the vector of interest. When VECDEF */
514 /*                is the parameter */
515 
516 /*                   SOBDEF */
517 
518 /*                METHOD should be set to one of the values accepted */
519 /*                by the SPICELIB routine SUBPNT. */
520 
521 /*                When VECDEF is the parameter */
522 
523 /*                   SINDEF */
524 
525 /*                METHOD should be set to one of the values accepted */
526 /*                by the SPICELIB routine SINCPT. */
527 
528 /*                METHOD is ignored if VECDEF is set to */
529 
530 /*                   POSDEF */
531 
532 /*                Case, leading and trailing blanks are not significant */
533 /*                in the string METHOD. */
534 
535 
536 /*     TARGET     is the name of the target object. */
537 
538 
539 /*     REF        is the name of the reference frame relative to which */
540 /*                the vector of interest is specified. The specified */
541 /*                condition applies to the specified coordinate of */
542 /*                of this vector in frame REF. */
543 
544 /*                When geodetic coordinates are used, the reference */
545 /*                ellipsoid is assumed to be that associated with */
546 /*                the central body of the frame designated by REF. */
547 /*                In this case, the central body of the frame must */
548 /*                be an extended body. */
549 
550 /*                Case, leading and trailing blanks are not significant */
551 /*                in the string REF. */
552 
553 
554 /*     ABCORR     indicates the aberration corrections to be applied to */
555 /*                the state of the target body to account for one-way */
556 /*                light time and stellar aberration.  The orientation */
557 /*                of the target body will also be corrected for one-way */
558 /*                light time when light time corrections are requested. */
559 
560 /*                Supported aberration correction options for */
561 /*                observation (case where radiation is received by */
562 /*                observer at ET) are: */
563 
564 /*                  'NONE'          No correction. */
565 /*                  'LT'            Light time only. */
566 /*                  'LT+S'          Light time and stellar aberration. */
567 /*                  'CN'            Converged Newtonian (CN) light time. */
568 /*                  'CN+S'          CN light time and stellar aberration. */
569 
570 /*                Supported aberration correction options for */
571 /*                transmission (case where radiation is emitted from */
572 /*                observer at ET) are: */
573 
574 /*                  'XLT'           Light time only. */
575 /*                  'XLT+S'         Light time and stellar aberration. */
576 /*                  'XCN'           Converged Newtonian (CN) light time. */
577 /*                  'XCN+S'         CN light time and stellar aberration. */
578 
579 /*                For detailed information, see the geometry finder */
580 /*                required reading, gf.req.  Also see the header of */
581 /*                SPKEZR, which contains a detailed discussion of */
582 /*                aberration corrections. */
583 
584 /*                Case, leading and trailing blanks are not significant */
585 /*                in the string ABCORR. */
586 
587 
588 /*     OBSRVR     is the name of the observer. */
589 
590 
591 /*     DREF       is the name of the reference frame relative to which a */
592 /*                ray's direction vector is expressed. This may be any */
593 /*                frame supported by the SPICE system, including */
594 /*                built-in frames (documented in the Frames Required */
595 /*                Reading) and frames defined by a loaded frame kernel */
596 /*                (FK). The string DREF is case-insensitive, and leading */
597 /*                and trailing blanks in DREF are not significant. */
598 
599 /*                When DREF designates a non-inertial frame, the */
600 /*                orientation of the frame is evaluated at an epoch */
601 /*                dependent on the frame's center and, if the center is */
602 /*                not the observer, on the selected aberration */
603 /*                correction. See the description of the direction */
604 /*                vector DVEC for details. */
605 
606 
607 /*     DVEC       Ray direction vector emanating from the observer. The */
608 /*                intercept with the target body's surface of the ray */
609 /*                defined by the observer and DVEC is sought. */
610 
611 /*                DVEC is specified relative to the reference frame */
612 /*                designated by DREF. */
613 
614 /*                Non-inertial reference frames are treated as follows: */
615 /*                if the center of the frame is at the observer's */
616 /*                location, the frame is evaluated at ET. If the frame's */
617 /*                center is located elsewhere, then letting LTCENT be */
618 /*                the one-way light time between the observer and the */
619 /*                central body associated with the frame, the */
620 /*                orientation of the frame is evaluated at ET-LTCENT, */
621 /*                ET+LTCENT, or ET depending on whether the requested */
622 /*                aberration correction is, respectively, for received */
623 /*                radiation, transmitted radiation, or is omitted. */
624 /*                LTCENT is computed using the method indicated by */
625 /*                ABCORR. */
626 
627 
628 /*     CRDSYS     is the name of the coordinate system to which the */
629 /*                coordinate of interest belongs. Allowed values are */
630 /*                those defined in the GF Fortran INCLUDE file */
631 
632 /*                   zzgf.inc. */
633 
634 /*                Note that when geodetic coordinates are used, the */
635 /*                reference ellipsoid is that associated with the */
636 /*                central body of the reference frame designated by REF. */
637 /*                The central body must be an extended body in this */
638 /*                case. */
639 
640 /*                Case, leading and trailing blanks are not significant */
641 /*                in the string CRDSYS. */
642 
643 
644 /*     CRDNAM     is the name of the coordinate of interest:  this is */
645 /*                the coordinate to which the specified condition */
646 /*                applies.  The set of coordinate names is a function of */
647 /*                the coordinate system. Allowed values are those */
648 /*                defined in the GF Fortran INCLUDE file */
649 
650 /*                   zzgf.inc. */
651 
652 /*                Case, leading and trailing blanks are not significant */
653 /*                in the string CRDNAM. */
654 
655 
656 /*     RELATE      is a relational operator used to define a constraint */
657 /*                 on the specified coordinate. The result window found */
658 /*                 by this routine indicates the time intervals where */
659 /*                 the constraint is satisfied. Supported values of */
660 /*                 RELATE and corresponding meanings are shown below: */
661 
662 /*                    '>'      Coordinate is greater than the reference */
663 /*                             value REFVAL. */
664 
665 /*                    '='      Coordinate is equal to the reference */
666 /*                             value REFVAL. */
667 
668 /*                    '<'      Coordinate is less than the reference */
669 /*                             value REFVAL. */
670 
671 
672 /*                   'ABSMAX'  Coordinate is at an absolute maximum. */
673 
674 /*                   'ABSMIN'  Coordinate is at an absolute  minimum. */
675 
676 /*                   'LOCMAX'  Coordinate is at a local maximum. */
677 
678 /*                   'LOCMIN'  Coordinate is at a local minimum. */
679 
680 /*                The caller may indicate that the region of interest */
681 /*                is the set of time intervals where the coordinate is */
682 /*                within a specified tolerance of an absolute extremum. */
683 /*                The argument ADJUST (described below) is used to */
684 /*                specify this tolerance. */
685 
686 /*                Local extrema are considered to exist only in the */
687 /*                interiors of the intervals comprising the confinement */
688 /*                window:  a local extremum cannot exist at a boundary */
689 /*                point of the confinement window. */
690 
691 /*                Case is not significant in the string RELATE. */
692 
693 
694 /*     REFVAL     is the reference value used to define equality or */
695 /*                inequality conditions. */
696 
697 /*                If the coordinate has the dimension "length," then */
698 /*                REFVAL has units of kilometers. */
699 
700 /*                If the coordinate has the dimension "angle," then */
701 /*                REFVAL has units of radians. */
702 
703 /*                When the coordinate of interest is longitude, REFVAL */
704 /*                is interpreted as though it were translated, if */
705 /*                necessary, by an integer multiple of 2*pi to place it */
706 /*                in the standard range for longitude: (-pi, pi]. */
707 /*                Similarly, when the coordinate of interest is right */
708 /*                ascension, REFVAL is interpreted as though it were */
709 /*                translated, if necessary, by an integer multiple of */
710 /*                2*pi into the range [0, 2*pi). */
711 
712 /*                Example:  suppose REFVAL is set to -4.5. Then the */
713 /*                          condition */
714 
715 /*                   longitude equals REFVAL */
716 
717 /*                is interpreted as */
718 
719 /*                   longitude equals -0.5 * pi */
720 
721 /*                so the solution window for this condition may well */
722 /*                be non-empty. */
723 
724 /*                REFVAL is ignored if RELATE is not an equality or */
725 /*                inequality operator. */
726 
727 
728 /*     TOL        is a tolerance value used to determine convergence of */
729 /*                root-finding operations. TOL is measured in TDB */
730 /*                seconds and is greater than zero. */
731 
732 
733 /*     ADJUST     The amount by which the coordinate is allowed to vary */
734 /*                from an absolute extremum. ADJUST is not used for */
735 /*                equality or inequality conditions. ADJUST must not be */
736 /*                negative. */
737 
738 /*                If ADJUST is positive and a search for an absolute */
739 /*                minimum is performed, the resulting schedule contains */
740 /*                time intervals when the specified coordinate has */
741 /*                values between ABSMIN and ABSMIN + ADJUST. */
742 
743 /*                If the search is for an absolute maximum, the */
744 /*                corresponding range is  between ABSMAX - ADJUST and */
745 /*                ABSMAX. */
746 
747 
748 /*     UDSTEP     is a routine that computes a time step used to search */
749 /*                for a transition of the state of the specified */
750 /*                coordinate. In the context of this routine's */
751 /*                algorithm, a "state transition" occurs where the */
752 /*                coordinate's time derivative changes from negative to */
753 /*                non-negative or vice versa. */
754 
755 /*                This routine relies on UDSTEP returning step sizes */
756 /*                small enough so that state transitions within the */
757 /*                confinement window are not overlooked.  There must */
758 /*                never be two roots A and B separated by less than */
759 /*                STEP, where STEP is the minimum step size returned by */
760 /*                UDSTEP for any value of ET in the interval [A, B]. */
761 
762 /*                The calling sequence for UDSTEP is: */
763 
764 /*                   CALL UDSTEP ( ET, STEP ) */
765 
766 /*                where: */
767 
768 /*                   ET      is the input start time from which the */
769 /*                           algorithm is to search forward for a state */
770 /*                           transition. ET is expressed as seconds past */
771 /*                           J2000 TDB. ET is a DOUBLE PRECISION number. */
772 
773 /*                   STEP    is the output step size. STEP indicates */
774 /*                           how far to advance ET so that ET and */
775 /*                           ET+STEP may bracket a state transition and */
776 /*                           definitely do not bracket more than one */
777 /*                           state transition. STEP is a DOUBLE */
778 /*                           PRECISION number. Units are TDB seconds. */
779 
780 /*                If a constant step size is desired, the routine GFSTEP */
781 /*                may be used. GFSTEP returns the step size that was set */
782 /*                via the most recent call to GFSSTP. */
783 
784 
785 /*     UDREFN     is the name of the externally specified routine that */
786 /*                computes a refinement in the times that bracket a */
787 /*                transition point. In other words, once a pair of */
788 /*                times have been detected such that the system is in */
789 /*                different states at each of the two times, UDREFN */
790 /*                selects an intermediate time which should be closer to */
791 /*                the transition state than one of the two known times. */
792 /*                The calling sequence for UDREFN is: */
793 
794 /*                   CALL UDREFN ( T1, T2, S1, S2, T ) */
795 
796 /*                where the inputs are: */
797 
798 /*                   T1    is a time when the system is in state S1. T1 */
799 /*                         is a DOUBLE PRECISION number. */
800 
801 /*                   T2    is a time when the system is in state S2. T2 */
802 /*                         is a DOUBLE PRECISION number and is assumed */
803 /*                         to be larger than T1. */
804 
805 /*                   S1    is the state of the system at time T1. */
806 /*                         S1 is a LOGICAL value. */
807 
808 /*                   S2    is the state of the system at time T2. */
809 /*                         S2 is a LOGICAL value. */
810 
811 /*                UDREFN may use or ignore the S1 and S2 values. */
812 
813 /*                The output is: */
814 
815 /*                   T     is next time to check for a state transition. */
816 /*                         T is a DOUBLE PRECISION number between T1 and */
817 /*                         T2. */
818 
819 /*                If a simple bisection method is desired, the routine */
820 /*                GFREFN may be used. This is the default option. */
821 
822 
823 /*     RPT        is a logical variable which controls whether the */
824 /*                progress reporter is on or off; setting RPT */
825 /*                to .TRUE. enables progress reporting. */
826 
827 
828 /*     UDREPI     is a user-defined subroutine that initializes a */
829 /*                progress report. When progress reporting is */
830 /*                enabled, UDREPI is called at the start of a search */
831 /*                pass (see the implementation of ZZGFREL for details on */
832 /*                search passes).  The calling sequence of UDREPI is */
833 
834 /*                   UDREPI ( CNFINE, RPTPRE, RPTSUF ) */
835 
836 /*                   DOUBLE PRECISION    CNFINE ( LBCELL : * ) */
837 /*                   CHARACTER*(*)       RPTPRE */
838 /*                   CHARACTER*(*)       RPTSUF */
839 
840 /*                where */
841 
842 /*                   CNFINE */
843 
844 /*                is the confinement window passed into ZZGFREL, and */
845 
846 /*                   RPTPRE */
847 /*                   RPTSUF */
848 
849 /*                are prefix and suffix strings used in the progress */
850 /*                report:  these strings are intended to bracket a */
851 /*                representation of the fraction of work done. */
852 
853 /*                SPICELIB provides the default progress reporting */
854 /*                initialization routine GFREPI. If GFREPI is used, then */
855 /*                the progress reporting update and termination routines */
856 /*                GFREPU and GFREPF must be used as well. */
857 
858 
859 /*     UDREPU     is a user-defined subroutine that updates the */
860 /*                progress report for a search pass. The calling */
861 /*                sequence of UDREPU is */
862 
863 /*                   UDREPU (IVBEG, IVEND, ET ) */
864 
865 /*                   DOUBLE PRECISION      ET */
866 /*                   DOUBLE PRECISION      IVBEG */
867 /*                   DOUBLE PRECISION      IVEND */
868 
869 /*                where ET is an epoch belonging to the confinement */
870 /*                window, IVBEG and IVEND are the start and stop times, */
871 /*                respectively of the current confinement window */
872 /*                interval.  The ratio of the measure of the portion */
873 /*                of CNFINE that precedes ET to the measure of CNFINE */
874 /*                would be a logical candidate for the search's */
875 /*                completion percentage; however the method of */
876 /*                measurement is up to the user. */
877 
878 
879 /*     UDREPF     is a user-defined subroutine that finalizes a */
880 /*                progress report. UDREPF has no arguments. */
881 
882 
883 /*     BAIL       is a logical flag indicating whether or not interrupt */
884 /*                signal handling is enabled. Setting BAIL to .TRUE. */
885 /*                enables interrupt signal handling: the GF system will */
886 /*                then call UDBAIL to check for interrupt signals. */
887 
888 
889 /*     UDBAIL     is the name of a user defined logical function that */
890 /*                checks to see whether an interrupt signal has been */
891 /*                issued from, e.g. the keyboard. UDBAIL is used only */
892 /*                when BAIL is set to .TRUE. If interrupt handling is */
893 /*                not used, the SPICELIB function GFBAIL should be */
894 /*                passed in as the actual bail-out function argument. */
895 
896 
897 /*     MW         is the cell size of the windows in the workspace array */
898 /*                WORK. */
899 
900 
901 /*     NW         is the number of windows in the workspace array WORK. */
902 /*                NW must be at least as large as the parameter NWMAX. */
903 
904 
905 /*     WORK       is an array used to store workspace windows. This */
906 /*                array has dimensions ( LBCELL : MW, NW). */
907 
908 
909 /*     CNFINE     is a SPICE window that confines the bounds of the */
910 /*                search. */
911 
912 /*                For coordinates defined by ray-target surface */
913 /*                intercepts, the effective confinement window is */
914 /*                obtained by searching for times within CNFINE when the */
915 /*                specified intercept and its derivative with respect to */
916 /*                time are computable. The window resulting from this */
917 /*                search is then contracted by CNTRCT+TOL seconds at */
918 /*                both left and right endpoints; this contracted window */
919 /*                is called the "existence window," since the surface */
920 /*                intercept and its time derivative are expected to be */
921 /*                computable on this contracted window. The user must */
922 /*                select CNFINE so that this requirement is met. */
923 
924 
925 /*     RESULT     is an initialized SPICE window. RESULT must be large */
926 /*                enough to hold all of the intervals, within the */
927 /*                confinement window, on which the specified condition */
928 /*                is met. */
929 
930 /*                RESULT must be initialized by the caller via the */
931 /*                SPICELIB routine SSIZED. */
932 
933 
934 /* $ Detailed_Output */
935 
936 /*     WORK       has undefined contents on output. */
937 
938 
939 /*     RESULT     is a SPICELIB window containing the intersection of */
940 /*                the confinement window and the set of time intervals */
941 /*                when the value of the specified coordinate satisfies */
942 /*                constraints specified by RELATE and ADJUST. */
943 
944 /*                For coordinates defined by ray-target surface */
945 /*                intercepts, RESULT is further restricted to the window */
946 /*                over which the intercept and its derivative with */
947 /*                respect to time are computable. See the description of */
948 /*                CNFINE above for details. */
949 
950 /* $ Parameters */
951 
952 /*     LBCELL     is the lower bound for SPICELIB cells. */
953 
954 /*     CNTRCT     is the contraction magnitude used to prepare the */
955 /*                "existence window" for use as a confinement window. */
956 /*                The existence window is applicable only to coordinates */
957 /*                of surface intercepts: it is the result of contracting */
958 /*                the window over which the surface intercept and its */
959 /*                time derivative are computable by CNTRCT+TOL. Units */
960 /*                are TDB seconds. */
961 
962 /* $ Exceptions */
963 
964 /*     1)  If the workspace window count NW is less than NWMAX, the */
965 /*         error SPICE(TOOFEWWINDOWS) is signaled. */
966 
967 /*     2)  If the workspace window size MW is less than 2, the */
968 /*         error SPICE(WINDOWSTOOSMALL) is signaled. */
969 
970 /*     3)  If a workspace window or the result window is too small */
971 /*         to accommodate the required number of intervals, */
972 /*         the error will be diagnosed by routines in the call tree */
973 /*         of this routine. */
974 
975 /*     4)  If either the observer or target names cannot be mapped */
976 /*         to ID codes, the error will be diagnosed by routines in the */
977 /*         call tree of this routine. */
978 
979 /*     5)  If the observer and target have the same ID codes, the */
980 /*         error will be diagnosed by routines in the call tree of this */
981 /*         routine. */
982 
983 /*     6)  If the vector definition VECDEF is not recognized, */
984 /*         the error will be diagnosed by routines in the call tree */
985 /*         of this routine. */
986 
987 /*     7)  If the computation method METHOD is not recognized, */
988 /*         the error will be diagnosed by routines in the call tree */
989 /*         of this routine. */
990 
991 /*     8)  If the aberration correction ABCORR is not recognized, */
992 /*         the error will be diagnosed by routines in the call tree */
993 /*         of this routine. */
994 
995 /*     9)  If the coordinate system name CRDSYS is not recognized, */
996 /*         the error will be diagnosed by routines in the call tree */
997 /*         of this routine. */
998 
999 /*     10) If the coordinate name CRDNAM is not recognized, */
1000 /*         the error will be diagnosed by routines in the call tree */
1001 /*         of this routine. */
1002 
1003 /*     11) If the frame REF is not recognized by the frames subsystem, */
1004 /*         the error will be diagnosed by routines in the call tree */
1005 /*         of this routine. */
1006 
1007 /*     12) If VECDEF calls for a computation involving a target surface */
1008 /*         intercept point and the name and ID code of the frame DREF */
1009 /*         associated with the target body are not available from the */
1010 /*         frame subsystem, the error will be diagnosed by routines in */
1011 /*         the call tree of this routine. */
1012 
1013 /*     13) If VECDEF calls for a computation involving a target surface */
1014 /*         intercept point and the direction vector DVEC is the zero */
1015 /*         vector, the error will be diagnosed by routines in the call */
1016 /*         tree of this routine. */
1017 
1018 /*     14) If VECDEF calls for a computation involving a target surface */
1019 /*         point and the radii defining the reference ellipsoid */
1020 /*         associated with the target body are not available in the */
1021 /*         kernel pool, the error will be diagnosed by routines in the */
1022 /*         call tree of this routine. */
1023 
1024 /*     15) If VECDEF calls for a computation involving a target surface */
1025 /*         point and the frame REF is not centered on the target body, */
1026 /*         the error will be diagnosed by routines in the call tree */
1027 /*         of this routine. */
1028 
1029 /*     16) If geodetic or planetographic coordinates are used and the */
1030 /*         radii defining the reference ellipsoid associated with the */
1031 /*         center of the frame REF are not available in the kernel pool, */
1032 /*         the error will be diagnosed by routines in the call tree of */
1033 /*         this routine. */
1034 
1035 /*     17) If geodetic or planetographic coordinates are used and the */
1036 /*         first equatorial radius of the reference ellipsoid associated */
1037 /*         with the center of the frame REF is zero, the error will be */
1038 /*         diagnosed by routines in the call tree of this routine. */
1039 
1040 /*     18) If geodetic or planetographic coordinates are used and the */
1041 /*         equatorial radii of the reference ellipsoid associated */
1042 /*         with the center of the frame REF are unequal, the error */
1043 /*         SPICE(NOTSUPPORTED) is signaled. */
1044 
1045 /*     19) If geodetic or planetographic coordinates are used and the */
1046 /*         reference ellipsoid associated with the center of the frame */
1047 /*         REF is degenerate (one or more radii are non-positive), */
1048 /*         the error will be diagnosed by routines in the call tree */
1049 /*         of this routine. */
1050 
1051 /*     20) If ADJUST is negative, the error SPICE(VALUEOUTOFRANGE) */
1052 /*         is signaled. */
1053 
1054 /*     21) If TOL is non-positive, the error SPICE(VALUEOUTOFRANGE) */
1055 /*         is signaled. */
1056 
1057 /*     21) If RELATE is not a supported relational operator */
1058 /*         specification, the error SPICE(NOTRECOGNIZED) is signaled. */
1059 
1060 /* $ Files */
1061 
1062 /*     See the discussion in the Files section of the header of the */
1063 /*     umbrella subroutine ZZGFCOU. */
1064 
1065 /* $ Particulars */
1066 
1067 /*     This routine handles coordinate search set-up and execution */
1068 /*     activities for GFEVNT. */
1069 
1070 /*     For a surface intercept coordinate search, this routine finds the */
1071 /*     "existence window," within the input confinement window, for the */
1072 /*     surface intercept and its time derivative. The existence window */
1073 /*     is contracted by CNTRCT seconds; this contracted window is then */
1074 /*     used as the confinement window for the search. */
1075 
1076 /* $ Examples */
1077 
1078 /*     See GFEVNT and ZZGFLONG. */
1079 
1080 /* $ Restrictions */
1081 
1082 /*     1)  The interface and functionality of this set of routines may */
1083 /*         change without notice.  These routines should be called only */
1084 /*         by SPICELIB routines. */
1085 
1086 /*     2)  ZZGFCSLV must be called prior to use of any of the other */
1087 /*         entry points. */
1088 
1089 /*     3)  This routine has the following couplings with other */
1090 /*         SPICE routines: */
1091 
1092 /*            - The set of allowed aberration corrections must */
1093 /*              be kept in sync with the set supported by the */
1094 /*              SPK API routines. */
1095 
1096 /*            - The set of vector definitions must be kept in */
1097 /*              sync with the set supported by GFEVNT. */
1098 
1099 /*            - The set of supported coordinate systems must be kept in */
1100 /*              sync with the set supported by zzgf.inc. */
1101 
1102 
1103 /* $ Literature_References */
1104 
1105 /*     None. */
1106 
1107 /* $ Author_and_Institution */
1108 
1109 /*     N.J. Bachman   (JPL) */
1110 /*     E.D. Wright    (JPL) */
1111 
1112 /* $ Version */
1113 
1114 /* -    SPICELIB Version 1.2.0, 04-APR-2011 (EDW) */
1115 
1116 /*        Replaced use of rooutines ZZGFREL with ZZGFRELX, and */
1117 /*        ZZGFSOLV with ZZGFSOLVX. ZZGFCOIN argument list edited */
1118 /*        to remove the unneeded argument REFVAL. */
1119 
1120 /*        The code changes for ZZGFRELX use should not affect the */
1121 /*        numerical results of GF computations. */
1122 
1123 /* -    SPICELIB Version 1.0.0 06-MAR-2009 (NJB) (EDW) */
1124 
1125 /* -& */
1126 /* $ Index_Entries */
1127 
1128 /*     coordinate search */
1129 
1130 /* -& */
1131 
1132 /*     SPICELIB functions */
1133 
1134 
1135 /*     Local parameters */
1136 
1137 
1138 /*     Number of supported comparison operators: */
1139 
1140 
1141 /*     MAXOP is the maximum string length for comparison operators. */
1142 /*     MAXOP may grow if new comparisons are added. */
1143 
1144 
1145 /*     Local variables */
1146 
1147 
1148 /*     Saved variables */
1149 
1150 
1151 /*     Initial values */
1152 
1153 
1154 /*     Below we initialize the list of comparison operator names. */
1155 
1156     /* Parameter adjustments */
1157     work_dim1 = *mw + 6;
1158     work_dim2 = *nw;
1159     work_offset = work_dim1 - 5;
1160 
1161     /* Function Body */
1162 
1163 /*     Standard SPICE error handling. */
1164 
1165     if (return_()) {
1166 	return 0;
1167     }
1168     chkin_("ZZGFCSLV", (ftnlen)8);
1169 
1170 /*     Check the workspace window count. */
1171 
1172     if (*nw < 15) {
1173 	setmsg_("Workspace window count was # but must be at least #.", (
1174 		ftnlen)52);
1175 	errint_("#", nw, (ftnlen)1);
1176 	errint_("#", &c__15, (ftnlen)1);
1177 	sigerr_("SPICE(TOOFEWWINDOWS)", (ftnlen)20);
1178 	chkout_("ZZGFCSLV", (ftnlen)8);
1179 	return 0;
1180     }
1181 
1182 /*     Check the workspace window size. The minimum size that */
1183 /*     makes any sense is 2. */
1184 
1185     if (*mw < 2) {
1186 	setmsg_("Workspace window size was # but must be at least 2.", (
1187 		ftnlen)51);
1188 	errint_("#", mw, (ftnlen)1);
1189 	sigerr_("SPICE(WINDOWSTOOSMALL)", (ftnlen)22);
1190 	chkout_("ZZGFCSLV", (ftnlen)8);
1191 	return 0;
1192     }
1193 
1194 /*     Make sure ADJUST is non-negative. */
1195 
1196     if (*adjust < 0.) {
1197 	setmsg_("ADJUST was #; must be non-negative.", (ftnlen)35);
1198 	errdp_("#", adjust, (ftnlen)1);
1199 	sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
1200 	chkout_("ZZGFCSLV", (ftnlen)8);
1201 	return 0;
1202     }
1203 
1204 /*     Make sure TOL is positive. */
1205 
1206     if (*tol <= 0.) {
1207 	setmsg_("TOL was #; must be positive.", (ftnlen)28);
1208 	errdp_("#", tol, (ftnlen)1);
1209 	sigerr_("SPICE(VALUEOUTOFRANGE)", (ftnlen)22);
1210 	chkout_("ZZGFCSLV", (ftnlen)8);
1211 	return 0;
1212     }
1213 
1214 /*     Make sure that the requested comparison operation is one we */
1215 /*     recognize. */
1216 
1217     ljust_(relate, uop, relate_len, (ftnlen)6);
1218     ucase_(uop, uop, (ftnlen)6, (ftnlen)6);
1219     loc = isrchc_(uop, &c__7, cnames, (ftnlen)6, (ftnlen)6);
1220     if (loc == 0) {
1221 	setmsg_("The comparison operator, # is not recognized.  Supported op"
1222 		"erators are: >,=,<,ABSMAX,ABSMIN,LOCMAX,LOCMIN.", (ftnlen)106)
1223 		;
1224 	errch_("#", relate, (ftnlen)1, relate_len);
1225 	sigerr_("SPICE(NOTRECOGNIZED)", (ftnlen)20);
1226 	chkout_("ZZGFCSLV", (ftnlen)8);
1227 	return 0;
1228     }
1229 
1230 /*     Initialize the workspace windows. */
1231 
1232     i__1 = *nw;
1233     for (i__ = 1; i__ <= i__1; ++i__) {
1234 	ssized_(mw, &work[(i__2 = i__ * work_dim1 - 5 - work_offset) <
1235 		work_dim1 * work_dim2 && 0 <= i__2 ? i__2 : s_rnge("work",
1236 		i__2, "zzgfcslv_", (ftnlen)969)]);
1237     }
1238 
1239 /*     Initialize the result window. */
1240 
1241     scardd_(&c__0, result);
1242 
1243 /*     Create a left-justified, compressed copy of the */
1244 /*     input vector definition method. */
1245 
1246     ljust_(vecdef, locvdf, vecdef_len, (ftnlen)80);
1247     cmprss_(" ", &c__1, locvdf, locvdf, (ftnlen)1, (ftnlen)80, (ftnlen)80);
1248     ucase_(locvdf, locvdf, (ftnlen)80, (ftnlen)80);
1249 
1250 /*     If the vector definition method is "surface intercept," */
1251 /*     find the "existence window": the window over which */
1252 /*     the intercept and its time derivative are computable. */
1253 
1254     if (s_cmp(locvdf, "SURFACE INTERCEPT POINT", (ftnlen)80, (ftnlen)23) == 0)
1255 	     {
1256 
1257 /*        Initialize the search for the existence window. */
1258 
1259 	zzgfcoin_(vecdef, method, target, ref, abcorr, obsrvr, dref, dvec,
1260 		crdsys, crdnam, vecdef_len, method_len, target_len, ref_len,
1261 		abcorr_len, obsrvr_len, dref_len, crdsys_len, crdnam_len);
1262 	if (failed_()) {
1263 	    chkout_("ZZGFCSLV", (ftnlen)8);
1264 	    return 0;
1265 	}
1266 
1267 /*        This routine presumes that UDSTEP has been initialized, so we */
1268 /*        don't attempt to reset the step. */
1269 
1270 /*        If progress reporting is enabled, initialize the progress */
1271 /*        report for the existence window search. */
1272 
1273 	if (*rpt) {
1274 	    (*udrepi)(cnfine, rptpre + 110, rptsuf + 26, (ftnlen)55, (ftnlen)
1275 		    13);
1276 	}
1277 
1278 /*        ZZGFSOLV will add the result of each search to the workspace */
1279 /*        window */
1280 
1281 /*           WORK(LBCELL,EXWIDX) */
1282 
1283 /*        Initialize this window. */
1284 
1285 	ssized_(mw, &work[(i__1 = work_dim1 * 13 - 5 - work_offset) <
1286 		work_dim1 * work_dim2 && 0 <= i__1 ? i__1 : s_rnge("work",
1287 		i__1, "zzgfcslv_", (ftnlen)1022)]);
1288 
1289 /*        Search each interval of the confinement window. */
1290 
1291 	i__1 = wncard_(cnfine);
1292 	for (i__ = 1; i__ <= i__1; ++i__) {
1293 	    wnfetd_(cnfine, &i__, &start, &finish);
1294 	    zzgfsolvx_((U_fp)udf_, (U_fp)zzgfcoex_, (U_fp)udstep, (U_fp)
1295 		    udrefn, bail, (L_fp)udbail, &c_false, &c_b36, &start, &
1296 		    finish, tol, rpt, (U_fp)udrepu, &work[(i__2 = work_dim1 *
1297 		    13 - 5 - work_offset) < work_dim1 * work_dim2 && 0 <=
1298 		    i__2 ? i__2 : s_rnge("work", i__2, "zzgfcslv_", (ftnlen)
1299 		    1031)]);
1300 	    if (failed_()) {
1301 		chkout_("ZZGFCSLV", (ftnlen)8);
1302 		return 0;
1303 	    }
1304 
1305 /*           If interrupt processing is enabled, check to see */
1306 /*           whether an interrupt has occurred. */
1307 
1308 	    if (*bail) {
1309 		if ((*udbail)()) {
1310 		    chkout_("ZZGFCSLV", (ftnlen)8);
1311 		    return 0;
1312 		}
1313 	    }
1314 	}
1315 
1316 /*        If progress reporting is enabled, terminate the report */
1317 /*        for this pass. */
1318 
1319 	if (*rpt) {
1320 	    (*udrepf)();
1321 	}
1322 
1323 /*        For safety, contract the existence window. Store */
1324 /*        the result in the workspace. */
1325 
1326 	excon = *tol + 1.;
1327 	wncond_(&excon, &excon, &work[(i__1 = work_dim1 * 13 - 5 -
1328 		work_offset) < work_dim1 * work_dim2 && 0 <= i__1 ? i__1 :
1329 		s_rnge("work", i__1, "zzgfcslv_", (ftnlen)1069)]);
1330     } else {
1331 
1332 /*        Simply copy the confinement window to the workspace. */
1333 
1334 	copyd_(cnfine, &work[(i__1 = work_dim1 * 13 - 5 - work_offset) <
1335 		work_dim1 * work_dim2 && 0 <= i__1 ? i__1 : s_rnge("work",
1336 		i__1, "zzgfcslv_", (ftnlen)1075)]);
1337     }
1338 
1339 /*     If progress reporting is enabled, set the report prefix array */
1340 /*     according to the quantity and the relational operator. */
1341 
1342     if (*rpt) {
1343 
1344 /*        We'll use the logical flag LOCALX to indicate a local extremum */
1345 /*        operator and the flag NOADJX to indicate an absolut extremum */
1346 /*        operator with zero adjustment. */
1347 
1348 	localx = s_cmp(uop, "LOCMIN", (ftnlen)6, (ftnlen)6) == 0 || s_cmp(uop,
1349 		 "LOCMAX", (ftnlen)6, (ftnlen)6) == 0;
1350 	noadjx = *adjust == 0. && (s_cmp(uop, "ABSMIN", (ftnlen)6, (ftnlen)6)
1351 		== 0 || s_cmp(uop, "ABSMAX", (ftnlen)6, (ftnlen)6) == 0);
1352 	if (localx || noadjx) {
1353 
1354 /*           These operators correspond to 1-pass searches. */
1355 
1356 	    npass = 1;
1357 	} else {
1358 	    npass = 2;
1359 	}
1360 
1361 /*        Fill in the prefix strings. */
1362 
1363 	i__1 = npass;
1364 	for (i__ = 1; i__ <= i__1; ++i__) {
1365 	    repmi_(rptpre + ((i__2 = i__ - 1) < 3 && 0 <= i__2 ? i__2 :
1366 		    s_rnge("rptpre", i__2, "zzgfcslv_", (ftnlen)1110)) * 55,
1367 		    "#", &npass, prebuf + ((i__3 = i__ - 1) < 3 && 0 <= i__3 ?
1368 		     i__3 : s_rnge("prebuf", i__3, "zzgfcslv_", (ftnlen)1110))
1369 		     * 55, (ftnlen)55, (ftnlen)1, (ftnlen)55);
1370 	}
1371     }
1372 
1373 /*     Create a left-justified, compressed, upper case copy of the */
1374 /*     input coordinate name. */
1375 
1376     ljust_(crdnam, loccrd, crdnam_len, (ftnlen)80);
1377     cmprss_(" ", &c__1, loccrd, loccrd, (ftnlen)1, (ftnlen)80, (ftnlen)80);
1378     ucase_(loccrd, loccrd, (ftnlen)80, (ftnlen)80);
1379 
1380 /*     If the coordinate of interest is longitude or right ascension, we */
1381 /*     have a special case, since the mapping from Cartesian to */
1382 /*     latitudinal coordinates has a branch discontinuity. */
1383 
1384     if (s_cmp(loccrd, "LONGITUDE", (ftnlen)80, (ftnlen)9) == 0 || s_cmp(
1385 	    loccrd, "RIGHT ASCENSION", (ftnlen)80, (ftnlen)15) == 0) {
1386 
1387 /*        The coordinate is longitude or right ascension. */
1388 
1389 	zzgflong_(vecdef, method, target, ref, abcorr, obsrvr, dref, dvec,
1390 		crdsys, crdnam, relate, refval, tol, adjust, (U_fp)udstep, (
1391 		U_fp)udrefn, rpt, (S_fp)udrepi, (U_fp)udrepu, (S_fp)udrepf,
1392 		bail, (L_fp)udbail, mw, nw, work, &work[(i__1 = work_dim1 *
1393 		13 - 5 - work_offset) < work_dim1 * work_dim2 && 0 <= i__1 ?
1394 		i__1 : s_rnge("work", i__1, "zzgfcslv_", (ftnlen)1133)],
1395 		result, vecdef_len, method_len, target_len, ref_len,
1396 		abcorr_len, obsrvr_len, dref_len, crdsys_len, crdnam_len,
1397 		relate_len);
1398     } else {
1399 
1400 /*        This is the normal case. */
1401 
1402 /*        Initialize the coordinate quantity utilities. */
1403 
1404 	zzgfcoin_(vecdef, method, target, ref, abcorr, obsrvr, dref, dvec,
1405 		crdsys, crdnam, vecdef_len, method_len, target_len, ref_len,
1406 		abcorr_len, obsrvr_len, dref_len, crdsys_len, crdnam_len);
1407 
1408 /*        Perform the search. */
1409 
1410 	zzgfrelx_((U_fp)udstep, (U_fp)udrefn, (U_fp)zzgfcodc_, (U_fp)
1411 		zzgfudlt_, (U_fp)zzgfcog_, relate, refval, tol, adjust, &work[
1412 		(i__1 = work_dim1 * 13 - 5 - work_offset) < work_dim1 *
1413 		work_dim2 && 0 <= i__1 ? i__1 : s_rnge("work", i__1, "zzgfcs"
1414 		"lv_", (ftnlen)1154)], mw, nw, work, rpt, (S_fp)udrepi, (U_fp)
1415 		udrepu, (S_fp)udrepf, prebuf, rptsuf, bail, (L_fp)udbail,
1416 		result, relate_len, (ftnlen)55, (ftnlen)13);
1417     }
1418     chkout_("ZZGFCSLV", (ftnlen)8);
1419     return 0;
1420 } /* zzgfcslv_ */
1421 
1422