1 /* gfuds.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__5 = 5;
11 static integer c_n1 = -1;
12 static integer c__3 = 3;
13 static integer c__0 = 0;
14 static logical c_false = FALSE_;
15
16 /* $Procedure GFUDS ( GF, user defined scalar ) */
gfuds_(U_fp udfuns,U_fp udqdec,char * relate,doublereal * refval,doublereal * adjust,doublereal * step,doublereal * cnfine,integer * mw,integer * nw,doublereal * work,doublereal * result,ftnlen relate_len)17 /* Subroutine */ int gfuds_(U_fp udfuns, U_fp udqdec, char *relate,
18 doublereal *refval, doublereal *adjust, doublereal *step, doublereal *
19 cnfine, integer *mw, integer *nw, doublereal *work, doublereal *
20 result, ftnlen relate_len)
21 {
22 /* System generated locals */
23 integer work_dim1, work_offset, i__1;
24
25 /* Local variables */
26 extern /* Subroutine */ int zzgfudlt_();
27 extern /* Subroutine */ int zzgfrelx_(U_fp, U_fp, U_fp, U_fp, U_fp, char *
28 , doublereal *, doublereal *, doublereal *, doublereal *, integer
29 *, integer *, doublereal *, logical *, U_fp, U_fp, U_fp, char *,
30 char *, logical *, L_fp, doublereal *, ftnlen, ftnlen, ftnlen),
31 chkin_(char *, ftnlen);
32 extern integer sized_(doublereal *);
33 extern logical gfbail_();
34 logical ok;
35 extern /* Subroutine */ int scardd_(integer *, doublereal *);
36 extern /* Subroutine */ int gfrefn_(), gfrepf_();
37 extern logical return_(void);
38 extern /* Subroutine */ int gfrepi_(), gfrepu_(), gfstep_();
39 char rptpre[1*2], rptsuf[1*2];
40 extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
41 integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
42 ftnlen), gfsstp_(doublereal *);
43 extern logical odd_(integer *);
44 doublereal tol;
45 extern /* Subroutine */ int zzholdd_(integer *, integer *, logical *,
46 doublereal *);
47
48 /* $ Abstract */
49
50 /* Perform a GF search on a user defined scalar quantity. */
51
52 /* $ Disclaimer */
53
54 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
55 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
56 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
57 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
58 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
59 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
60 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
61 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
62 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
63 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
64
65 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
66 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
67 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
68 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
69 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
70 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
71
72 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
73 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
74 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
75 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
76
77 /* $ Required_Reading */
78
79 /* GF */
80 /* SPK */
81 /* TIME */
82 /* WINDOWS */
83
84 /* $ Keywords */
85
86 /* EVENT */
87 /* EPHEMERIS */
88 /* SEARCH */
89 /* WINDOW */
90
91 /* $ Declarations */
92 /* $ Abstract */
93
94 /* This file contains public, global parameter declarations */
95 /* for the SPICELIB Geometry Finder (GF) subsystem. */
96
97 /* $ Disclaimer */
98
99 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
100 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
101 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
102 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
103 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
104 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
105 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
106 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
107 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
108 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
109
110 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
111 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
112 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
113 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
114 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
115 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
116
117 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
118 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
119 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
120 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
121
122 /* $ Required_Reading */
123
124 /* GF */
125
126 /* $ Keywords */
127
128 /* GEOMETRY */
129 /* ROOT */
130
131 /* $ Restrictions */
132
133 /* None. */
134
135 /* $ Author_and_Institution */
136
137 /* N.J. Bachman (JPL) */
138 /* L.E. Elson (JPL) */
139 /* E.D. Wright (JPL) */
140
141 /* $ Literature_References */
142
143 /* None. */
144
145 /* $ Version */
146
147 /* - SPICELIB Version 2.0.0 29-NOV-2016 (NJB) */
148
149 /* Upgraded to support surfaces represented by DSKs. */
150
151 /* Bug fix: removed declaration of NVRMAX parameter. */
152
153 /* - SPICELIB Version 1.3.0, 01-OCT-2011 (NJB) */
154
155 /* Added NWILUM parameter. */
156
157 /* - SPICELIB Version 1.2.0, 14-SEP-2010 (EDW) */
158
159 /* Added NWPA parameter. */
160
161 /* - SPICELIB Version 1.1.0, 08-SEP-2009 (EDW) */
162
163 /* Added NWRR parameter. */
164 /* Added NWUDS parameter. */
165
166 /* - SPICELIB Version 1.0.0, 21-FEB-2009 (NJB) (LSE) (EDW) */
167
168 /* -& */
169
170 /* Root finding parameters: */
171
172 /* CNVTOL is the default convergence tolerance used by the */
173 /* high-level GF search API routines. This tolerance is */
174 /* used to terminate searches for binary state transitions: */
175 /* when the time at which a transition occurs is bracketed */
176 /* by two times that differ by no more than CNVTOL, the */
177 /* transition time is considered to have been found. */
178
179 /* Units are TDB seconds. */
180
181
182 /* NWMAX is the maximum number of windows allowed for user-defined */
183 /* workspace array. */
184
185 /* DOUBLE PRECISION WORK ( LBCELL : MW, NWMAX ) */
186
187 /* Currently no more than twelve windows are required; the three */
188 /* extra windows are spares. */
189
190 /* Callers of GFEVNT can include this file and use the parameter */
191 /* NWMAX to declare the second dimension of the workspace array */
192 /* if necessary. */
193
194
195 /* Callers of GFIDST should declare their workspace window */
196 /* count using NWDIST. */
197
198
199 /* Callers of GFSEP should declare their workspace window */
200 /* count using NWSEP. */
201
202
203 /* Callers of GFRR should declare their workspace window */
204 /* count using NWRR. */
205
206
207 /* Callers of GFUDS should declare their workspace window */
208 /* count using NWUDS. */
209
210
211 /* Callers of GFPA should declare their workspace window */
212 /* count using NWPA. */
213
214
215 /* Callers of GFILUM should declare their workspace window */
216 /* count using NWILUM. */
217
218
219 /* ADDWIN is a parameter used to expand each interval of the search */
220 /* (confinement) window by a small amount at both ends in order to */
221 /* accommodate searches using equality constraints. The loaded */
222 /* kernel files must accommodate these expanded time intervals. */
223
224
225 /* FRMNLN is a string length for frame names. */
226
227
228 /* FOVTLN -- maximum length for FOV string. */
229
230
231 /* Specify the character strings that are allowed in the */
232 /* specification of field of view shapes. */
233
234
235 /* Character strings that are allowed in the */
236 /* specification of occultation types: */
237
238
239 /* Occultation target shape specifications: */
240
241
242 /* Specify the number of supported occultation types and occultation */
243 /* type string length: */
244
245
246 /* Instrument field-of-view (FOV) parameters */
247
248 /* Maximum number of FOV boundary vectors: */
249
250
251 /* FOV shape parameters: */
252
253 /* circle */
254 /* ellipse */
255 /* polygon */
256 /* rectangle */
257
258
259 /* End of file gf.inc. */
260
261 /* $ Abstract */
262
263 /* SPICE private include file intended solely for the support of */
264 /* SPICE routines. Users should not include this routine in their */
265 /* source code due to the volatile nature of this file. */
266
267 /* This file contains private, global parameter declarations */
268 /* for the SPICELIB Geometry Finder (GF) subsystem. */
269
270 /* $ Disclaimer */
271
272 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
273 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
274 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
275 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
276 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
277 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
278 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
279 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
280 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
281 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
282
283 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
284 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
285 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
286 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
287 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
288 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
289
290 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
291 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
292 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
293 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
294
295 /* $ Required_Reading */
296
297 /* GF */
298
299 /* $ Keywords */
300
301 /* GEOMETRY */
302 /* ROOT */
303
304 /* $ Restrictions */
305
306 /* None. */
307
308 /* $ Author_and_Institution */
309
310 /* N.J. Bachman (JPL) */
311 /* E.D. Wright (JPL) */
312
313 /* $ Literature_References */
314
315 /* None. */
316
317 /* $ Version */
318
319 /* - SPICELIB Version 1.0.0, 17-FEB-2009 (NJB) (EDW) */
320
321 /* -& */
322
323 /* The set of supported coordinate systems */
324
325 /* System Coordinates */
326 /* ---------- ----------- */
327 /* Rectangular X, Y, Z */
328 /* Latitudinal Radius, Longitude, Latitude */
329 /* Spherical Radius, Colatitude, Longitude */
330 /* RA/Dec Range, Right Ascension, Declination */
331 /* Cylindrical Radius, Longitude, Z */
332 /* Geodetic Longitude, Latitude, Altitude */
333 /* Planetographic Longitude, Latitude, Altitude */
334
335 /* Below we declare parameters for naming coordinate systems. */
336 /* User inputs naming coordinate systems must match these */
337 /* when compared using EQSTR. That is, user inputs must */
338 /* match after being left justified, converted to upper case, */
339 /* and having all embedded blanks removed. */
340
341
342 /* Below we declare names for coordinates. Again, user */
343 /* inputs naming coordinates must match these when */
344 /* compared using EQSTR. */
345
346
347 /* Note that the RA parameter value below matches */
348
349 /* 'RIGHT ASCENSION' */
350
351 /* when extra blanks are compressed out of the above value. */
352
353
354 /* Parameters specifying types of vector definitions */
355 /* used for GF coordinate searches: */
356
357 /* All string parameter values are left justified, upper */
358 /* case, with extra blanks compressed out. */
359
360 /* POSDEF indicates the vector is defined by the */
361 /* position of a target relative to an observer. */
362
363
364 /* SOBDEF indicates the vector points from the center */
365 /* of a target body to the sub-observer point on */
366 /* that body, for a given observer and target. */
367
368
369 /* SOBDEF indicates the vector points from the center */
370 /* of a target body to the surface intercept point on */
371 /* that body, for a given observer, ray, and target. */
372
373
374 /* Number of workspace windows used by ZZGFREL: */
375
376
377 /* Number of additional workspace windows used by ZZGFLONG: */
378
379
380 /* Index of "existence window" used by ZZGFCSLV: */
381
382
383 /* Progress report parameters: */
384
385 /* MXBEGM, */
386 /* MXENDM are, respectively, the maximum lengths of the progress */
387 /* report message prefix and suffix. */
388
389 /* Note: the sum of these lengths, plus the length of the */
390 /* "percent complete" substring, should not be long enough */
391 /* to cause wrap-around on any platform's terminal window. */
392
393
394 /* Total progress report message length upper bound: */
395
396
397 /* End of file zzgf.inc. */
398
399 /* $ Abstract */
400
401 /* SPICE private routine intended solely for the support of SPICE */
402 /* routines. Users should not call this routine directly due to the */
403 /* volatile nature of this routine. */
404
405 /* This file contains parameter declarations for the ZZHOLDD */
406 /* routine. */
407
408 /* $ Disclaimer */
409
410 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
411 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
412 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
413 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
414 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
415 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
416 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
417 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
418 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
419 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
420
421 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
422 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
423 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
424 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
425 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
426 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
427
428 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
429 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
430 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
431 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
432
433 /* $ Required_Reading */
434
435 /* None. */
436
437 /* $ Keywords */
438
439 /* None. */
440
441 /* $ Declarations */
442
443 /* None. */
444
445 /* $ Brief_I/O */
446
447 /* None. */
448
449 /* $ Detailed_Input */
450
451 /* None. */
452
453 /* $ Detailed_Output */
454
455 /* None. */
456
457 /* $ Parameters */
458
459 /* GEN general value, primarily for testing. */
460
461 /* GF_REF user defined GF reference value. */
462
463 /* GF_TOL user defined GF convergence tolerance. */
464
465 /* GF_DT user defined GF step for numeric differentiation. */
466
467 /* $ Exceptions */
468
469 /* None. */
470
471 /* $ Files */
472
473 /* None. */
474
475 /* $ Particulars */
476
477 /* None. */
478
479 /* $ Examples */
480
481 /* None. */
482
483 /* $ Restrictions */
484
485 /* None. */
486
487 /* $ Literature_References */
488
489 /* None. */
490
491 /* $ Author_and_Institution */
492
493 /* E.D. Wright (JPL) */
494
495 /* $ Version */
496
497 /* - SPICELIB Version 1.0.0 03-DEC-2013 (EDW) */
498
499 /* -& */
500
501 /* OP codes. The values exist in the integer domain */
502 /* [ -ZZNOP, -1], */
503
504
505 /* Current number of OP codes. */
506
507
508 /* ID codes. The values exist in the integer domain */
509 /* [ 1, NID], */
510
511
512 /* General use, primarily testing. */
513
514
515 /* The user defined GF reference value. */
516
517
518 /* The user defined GF convergence tolerance. */
519
520
521 /* The user defined GF step for numeric differentiation. */
522
523
524 /* Current number of ID codes, dimension of array */
525 /* in ZZHOLDD. Bad things can happen if this parameter */
526 /* does not have the proper value. */
527
528
529 /* End of file zzholdd.inc. */
530
531 /* $ Brief_I/O */
532
533 /* Variable I/O Description */
534 /* -------- --- -------------------------------------------------- */
535 /* LBCELL P SPICE Cell lower bound. */
536 /* CNVTOL P Convergence tolerance. */
537 /* UDFUNS I Name of the routine that computes a scalar */
538 /* quantity corresponding to an ET. */
539 /* UDQDEC I Name of the routine that computes whether the */
540 /* scalar quantity is decreasing. */
541 /* RELATE I Operator that either looks for an extreme value */
542 /* (max, min, local, absolute) or compares the */
543 /* geometric quantity value and a number. */
544 /* REFVAL I Value used as reference for scalar quantity */
545 /* condition. */
546 /* ADJUST I Allowed variation for absolute extremal */
547 /* geometric conditions. */
548 /* STEP I Step size used for locating extrema and roots. */
549 /* CNFINE I SPICE window to which the search is confined. */
550 /* MW I Size of workspace windows. */
551 /* NW I Number of workspace windows. */
552 /* WORK I Array containing workspace windows. */
553 /* RESULT I-O SPICE window containing results. */
554
555 /* $ Detailed_Input */
556
557 /* UDFUNS the routine that returns the value of the scalar */
558 /* quantity of interest at time ET. The calling sequence */
559 /* for UDFUNS is: */
560
561 /* CALL UDFUNS ( ET, VALUE ) */
562
563 /* where: */
564
565 /* ET a double precision value representing */
566 /* ephemeris time, expressed as seconds past */
567 /* J2000 TDB, at which to determine the scalar */
568 /* value. */
569
570 /* VALUE is the value of the scalar quantity */
571 /* at ET. */
572
573 /* UDQDEC the name of the routine that determines if the scalar */
574 /* quantity calculated by UDFUNS is decreasing. */
575 /* The calling sequence of UDQDEC is: */
576
577 /* CALL UDQDEC ( UDFUNS, ET, ISDECR ) */
578
579 /* where: */
580
581 /* UDFUNS the name of the scalar function as */
582 /* defined above. */
583
584 /* ET a double precision value representing */
585 /* ephemeris time, expressed as seconds past */
586 /* J2000 TDB, at which to determine the time */
587 /* derivative of UDFUNS. */
588
589 /* ISDECR a logical return indicating whether */
590 /* or not the scalar value returned by UDFUNS */
591 /* is decreasing. ISDECR returns true if the */
592 /* time derivative of UDFUNS at ET is */
593 /* negative. */
594
595 /* RELATE the scalar string comparison operator indicating */
596 /* the numeric constraint of interest. Values are: */
597
598 /* '>' value of scalar quantity greater than some */
599 /* reference (REFVAL). */
600
601 /* '=' value of scalar quantity equal to some */
602 /* reference (REFVAL). */
603
604 /* '<' value of scalar quantity less than some */
605 /* reference (REFVAL). */
606
607 /* 'ABSMAX' The scalar quantity is at an absolute */
608 /* maximum. */
609
610 /* 'ABSMIN' The scalar quantity is at an absolute */
611 /* minimum. */
612
613 /* 'LOCMAX' The scalar quantity is at a local */
614 /* maximum. */
615
616 /* 'LOCMIN' The scalar quantity is at a local */
617 /* minimum. */
618
619 /* The caller may indicate that the region of interest */
620 /* is the set of time intervals where the quantity is */
621 /* within a specified distance of an absolute extremum. */
622 /* The argument ADJUST (described below) is used to */
623 /* specified this distance. */
624
625 /* Local extrema are considered to exist only in the */
626 /* interiors of the intervals comprising the confinement */
627 /* window: a local extremum cannot exist at a boundary */
628 /* point of the confinement window. */
629
630 /* RELATE is insensitive to case, leading and */
631 /* trailing blanks. */
632
633 /* REFVAL is the reference value used to define an equality or */
634 /* inequality to satisfied by the scalar quantity. */
635 /* The units of REFVAL are those of the scalar quantity. */
636
637 /* ADJUST the amount by which the quantity is allowed to vary */
638 /* from an absolute extremum. */
639
640 /* If the search is for an absolute minimum is performed, */
641 /* the resulting window contains time intervals when the */
642 /* geometric quantity value has values between */
643 /* ABSMIN and ABSMIN + ADJUST. */
644
645 /* If the search is for an absolute maximum, the */
646 /* corresponding range is between ABSMAX - ADJUST and */
647 /* ABSMAX. */
648
649 /* ADJUST is not used for searches for local extrema, */
650 /* equality or inequality conditions and must have value */
651 /* zero for such searches. */
652
653 /* STEP the double precision time step size to use in */
654 /* the search. */
655
656 /* STEP must be short enough to for a search using this */
657 /* step size to locate the time intervals where the */
658 /* scalar quantity function is monotone increasing or */
659 /* decreasing. However, STEP must not be *too* short, */
660 /* or the search will take an unreasonable amount of time. */
661
662 /* The choice of STEP affects the completeness but not */
663 /* the precision of solutions found by this routine; the */
664 /* precision is controlled by the convergence tolerance. */
665 /* See the discussion of the parameter CNVTOL for */
666 /* details. */
667
668 /* STEP has units of TDB seconds. */
669
670 /* CNFINE is a SPICE window that confines the time period over */
671 /* which the specified search is conducted. CNFINE may */
672 /* consist of a single interval or a collection of */
673 /* intervals. */
674
675 /* In some cases the confinement window can be used to */
676 /* greatly reduce the time period that must be searched */
677 /* for the desired solution. See the Particulars section */
678 /* below for further discussion. */
679
680 /* See the Examples section below for a code example */
681 /* that shows how to create a confinement window. */
682
683 /* CNFINE must be initialized by the caller via the */
684 /* SPICELIB routine SSIZED. */
685
686 /* MW is a parameter specifying the length of the SPICE */
687 /* windows in the workspace array WORK (see description */
688 /* below) used by this routine. */
689
690 /* MW should be set to a number at least twice as large */
691 /* as the maximum number of intervals required by any */
692 /* workspace window. In many cases, it's not necessary to */
693 /* compute an accurate estimate of how many intervals are */
694 /* needed; rather, the user can pick a size considerably */
695 /* larger than what's really required. */
696
697 /* However, since excessively large arrays can prevent */
698 /* applications from compiling, linking, or running */
699 /* properly, sometimes MW must be set according to */
700 /* the actual workspace requirement. A rule of thumb */
701 /* for the number of intervals NINTVLS needed is */
702
703 /* NINTVLS = 2*N + ( M / STEP ) */
704
705 /* where */
706
707 /* N is the number of intervals in the confinement */
708 /* window */
709
710 /* M is the measure of the confinement window, in */
711 /* units of seconds */
712
713 /* STEP is the search step size in seconds */
714
715 /* MW should then be set to */
716
717 /* 2 * NINTVLS */
718
719 /* NW is a parameter specifying the number of SPICE windows */
720 /* in the workspace array WORK (see description below) */
721 /* used by this routine. (The reason this dimension is */
722 /* an input argument is that this allows run-time */
723 /* error checking to be performed.) */
724
725 /* NW must be at least as large as the parameter NWUDS. */
726
727 /* WORK is an array used to store workspace windows. This */
728 /* array should be declared by the caller as shown: */
729
730 /* DOUBLE PRECISION WORK ( LBCELL : MW, NW ) */
731
732 /* WORK need not be initialized by the caller. */
733
734 /* RESULT a double precision SPICE window which will contain the */
735 /* search results. RESULT must be declared and initialized */
736 /* with sufficient size to capture the full set of time */
737 /* intervals within the search region on which the */
738 /* specified constraint is satisfied. */
739
740 /* RESULT must be initialized by the caller via the */
741 /* SPICELIB routine SSIZED. */
742
743 /* If RESULT is non-empty on input, its contents */
744 /* will be discarded before GFUDS conducts its search. */
745
746 /* $ Detailed_Output */
747
748 /* WORK the input workspace array, modified by this */
749 /* routine. */
750
751 /* RESULT is a SPICE window containing the time intervals within */
752 /* the confinement window, during which the specified */
753 /* condition on the scalar quantity is met. */
754
755 /* If the search is for local extrema, or for absolute */
756 /* extrema with ADJUST set to zero, then normally each */
757 /* interval of RESULT will be a singleton: the left and */
758 /* right endpoints of each interval will be identical. */
759
760 /* If no times within the confinement window satisfy the */
761 /* search, RESULT will be returned with a cardinality */
762 /* of zero. */
763
764 /* $ Parameters */
765
766 /* LBCELL the integer value defining the lower bound for */
767 /* SPICE Cell arrays (a SPICE window is a kind of cell). */
768
769 /* CNVTOL is the convergence tolerance used for finding */
770 /* endpoints of the intervals comprising the result */
771 /* window. CNVTOL is also used for finding intermediate */
772 /* results; in particular, CNVTOL is used for finding the */
773 /* windows on which the range rate is increasing */
774 /* or decreasing. CNVTOL is used to determine when binary */
775 /* searches for roots should terminate: when a root is */
776 /* bracketed within an interval of length CNVTOL; the */
777 /* root is considered to have been found. */
778
779 /* The accuracy, as opposed to precision, of roots found */
780 /* by this routine depends on the accuracy of the input */
781 /* data. In most cases, the accuracy of solutions will be */
782 /* inferior to their precision. */
783
784 /* See INCLUDE file gf.inc for declarations and descriptions of */
785 /* parameters used throughout the GF system. */
786
787 /* $ Exceptions */
788
789 /* 1) In order for this routine to produce correct results, */
790 /* the step size must be appropriate for the problem at hand. */
791 /* Step sizes that are too large may cause this routine to miss */
792 /* roots; step sizes that are too small may cause this routine */
793 /* to run unacceptably slowly and in some cases, find spurious */
794 /* roots. */
795
796 /* This routine does not diagnose invalid step sizes, except */
797 /* that if the step size is non-positive, the error */
798 /* SPICE(INVALIDSTEP) is signaled. */
799
800 /* 2) Due to numerical errors, in particular, */
801
802 /* - truncation error in time values */
803 /* - finite tolerance value */
804 /* - errors in computed geometric quantities */
805
806 /* it is *normal* for the condition of interest to not always be */
807 /* satisfied near the endpoints of the intervals comprising the */
808 /* RESULT window. One technique to handle such a situation, */
809 /* slightly contract RESULT using the window routine WNCOND. */
810
811 /* 3) If the workspace window size MW is less than 2 or not an even */
812 /* value, the error SPICE(INVALIDDIMENSION) will signal. If the */
813 /* size of the workspace is too small, an error is signaled by a */
814 /* routine in the call tree of this routine. */
815
816 /* 4) If the size of the SPICE window RESULT is less than 2 or */
817 /* not an even value, the error SPICE(INVALIDDIMENSION) will */
818 /* signal. If RESULT has insufficient capacity to contain the */
819 /* number of intervals on which the specified condition */
820 /* is met, the error will be diagnosed by a routine in the call */
821 /* tree of this routine. */
822
823 /* 5) If the window count NW is less than NWUDS, the error */
824 /* SPICE(INVALIDDIMENSION) will be signaled. */
825
826 /* 6) If an error (typically cell overflow) occurs during */
827 /* window arithmetic, the error will be diagnosed by a routine */
828 /* in the call tree of this routine. */
829
830 /* 7) If the relational operator RELATE is not recognized, an */
831 /* error is signaled by a routine in the call tree of this */
832 /* routine. */
833
834 /* 8) If ADJUST is negative, the error SPICE(VALUEOUTOFRANGE) will */
835 /* signal from a routine in the call tree of this routine. */
836
837 /* A non-zero value for ADJUST when RELATE has any value other */
838 /* than "ABSMIN" or "ABSMAX" causes the error SPICE(INVALIDVALUE) */
839 /* to signal from a routine in the call tree of this routine. */
840
841 /* 9) If required ephemerides or other kernel data are not */
842 /* available, an error is signaled by a routine in the call tree */
843 /* of this routine. */
844
845 /* $ Files */
846
847 /* Appropriate kernels must be loaded by the calling program before */
848 /* this routine is called. */
849
850 /* If the scalar function requires access to ephemeris data: */
851
852 /* - SPK data: ephemeris data for any body over the */
853 /* time period defined by the confinement window must be */
854 /* loaded. If aberration corrections are used, the states of */
855 /* target and observer relative to the solar system barycenter */
856 /* must be calculable from the available ephemeris data. */
857 /* Typically ephemeris data are made available by loading one */
858 /* or more SPK files via FURNSH. */
859
860 /* - If non-inertial reference frames are used, then PCK */
861 /* files, frame kernels, C-kernels, and SCLK kernels may be */
862 /* needed. */
863
864 /* In all cases, kernel data are normally loaded once per program */
865 /* run, NOT every time this routine is called. */
866
867 /* $ Particulars */
868
869 /* This routine determines a set of one or more time intervals */
870 /* within the confinement window when the scalar function */
871 /* satisfies a caller-specified constraint. The resulting set of */
872 /* intervals is returned as a SPICE window. */
873
874 /* UDQDEC Default Template */
875 /* ======================= */
876
877 /* The user must supply a routine to determine whether sign of the */
878 /* time derivative of UDFUNS is positive or negative at ET. For */
879 /* cases where UDFUNS is numerically well behaved, the user */
880 /* may find it convenient to use a routine based on the below */
881 /* template. UDDC determines the truth of the expression */
882
883 /* d (UDFUNS) */
884 /* -- < 0 */
885 /* dt */
886
887 /* using the library routine UDDF to numerically calculate the */
888 /* derivative of UDFUNS using a three-point estimation. */
889 /* Please see the Examples section for an example of GFDECR use. */
890
891 /* SUBROUTINE GFDECR ( UDFUNS, ET, ISDECR ) */
892 /* IMPLICIT NONE */
893
894 /* EXTERNAL UDFUNS */
895 /* EXTERNAL UDDF */
896
897 /* DOUBLE PRECISION ET */
898 /* LOGICAL ISDECR */
899
900 /* DOUBLE PRECISION DT */
901
902 /* DT = h, double precision interval size */
903
904 /* CALL UDDC ( UDFUNS, ET, DT, ISDECR ) */
905
906 /* END */
907
908 /* The Search Process */
909 /* ================== */
910
911 /* Regardless of the type of constraint selected by the caller, this */
912 /* routine starts the search for solutions by determining the time */
913 /* periods, within the confinement window, over which the specified */
914 /* scalar function is monotone increasing and monotone */
915 /* decreasing. Each of these time periods is represented by a SPICE */
916 /* window. Having found these windows, all of the quantity */
917 /* function's local extrema within the confinement window are known. */
918 /* Absolute extrema then can be found very easily. */
919
920 /* Within any interval of these "monotone" windows, there will be at */
921 /* most one solution of any equality constraint. Since the boundary */
922 /* of the solution set for any inequality constraint is contained in */
923 /* the union of */
924
925 /* - the set of points where an equality constraint is met */
926 /* - the boundary points of the confinement window */
927
928 /* the solutions of both equality and inequality constraints can be */
929 /* found easily once the monotone windows have been found. */
930
931
932 /* Step Size */
933 /* ========= */
934
935 /* The monotone windows (described above) are found using a two-step */
936 /* search process. Each interval of the confinement window is */
937 /* searched as follows: first, the input step size is used to */
938 /* determine the time separation at which the sign of the rate of */
939 /* change of quantity function will be sampled. Starting at */
940 /* the left endpoint of an interval, samples will be taken at each */
941 /* step. If a change of sign is found, a root has been bracketed; at */
942 /* that point, the time at which the time derivative of the quantity */
943 /* function is zero can be found by a refinement process, for */
944 /* example, using a binary search. */
945
946 /* Note that the optimal choice of step size depends on the lengths */
947 /* of the intervals over which the quantity function is monotone: */
948 /* the step size should be shorter than the shortest of these */
949 /* intervals (within the confinement window). */
950
951 /* The optimal step size is *not* necessarily related to the lengths */
952 /* of the intervals comprising the result window. For example, if */
953 /* the shortest monotone interval has length 10 days, and if the */
954 /* shortest result window interval has length 5 minutes, a step size */
955 /* of 9.9 days is still adequate to find all of the intervals in the */
956 /* result window. In situations like this, the technique of using */
957 /* monotone windows yields a dramatic efficiency improvement over a */
958 /* state-based search that simply tests at each step whether the */
959 /* specified constraint is satisfied. The latter type of search can */
960 /* miss solution intervals if the step size is longer than the */
961 /* shortest solution interval. */
962
963 /* Having some knowledge of the relative geometry of the targets and */
964 /* observer can be a valuable aid in picking a reasonable step size. */
965 /* In general, the user can compensate for lack of such knowledge by */
966 /* picking a very short step size; the cost is increased computation */
967 /* time. */
968
969 /* Note that the step size is not related to the precision with which */
970 /* the endpoints of the intervals of the result window are computed. */
971 /* That precision level is controlled by the convergence tolerance. */
972
973
974 /* Convergence Tolerance */
975 /* ===================== */
976
977 /* Once a root has been bracketed, a refinement process is used to */
978 /* narrow down the time interval within which the root must lie. */
979 /* This refinement process terminates when the location of the root */
980 /* has been determined to within an error margin called the */
981 /* "convergence tolerance." The default convergence tolerance */
982 /* used by this routine is set by the parameter CNVTOL (defined */
983 /* in gf.inc). */
984
985 /* The value of CNVTOL is set to a "tight" value so that the */
986 /* tolerance doesn't become the limiting factor in the accuracy of */
987 /* solutions found by this routine. In general the accuracy of input */
988 /* data will be the limiting factor. */
989
990 /* The user may change the convergence tolerance from the default */
991 /* CNVTOL value by calling the routine GFSTOL, e.g. */
992
993 /* CALL GFSTOL( tolerance value ) */
994
995 /* Call GFSTOL prior to calling this routine. All subsequent */
996 /* searches will use the updated tolerance value. */
997
998 /* Setting the tolerance tighter than CNVTOL is unlikely to be */
999 /* useful, since the results are unlikely to be more accurate. */
1000 /* Making the tolerance looser will speed up searches somewhat, */
1001 /* since a few convergence steps will be omitted. However, in most */
1002 /* cases, the step size is likely to have a much greater effect */
1003 /* on processing time than would the convergence tolerance. */
1004
1005
1006 /* The Confinement Window */
1007 /* ====================== */
1008
1009 /* The simplest use of the confinement window is to specify a time */
1010 /* interval within which a solution is sought. However, the */
1011 /* confinement window can, in some cases, be used to make searches */
1012 /* more efficient. Sometimes it's possible to do an efficient search */
1013 /* to reduce the size of the time period over which a relatively */
1014 /* slow search of interest must be performed. */
1015
1016 /* $ Examples */
1017
1018 /* The numerical results shown for these examples may differ across */
1019 /* platforms. The results depend on the SPICE kernels used as */
1020 /* input, the compiler and supporting libraries, and the machine */
1021 /* specific arithmetic implementation. */
1022
1023 /* Use the meta-kernel shown below to load the required SPICE */
1024 /* kernels. */
1025
1026 /* KPL/MK */
1027
1028 /* File name: standard.tm */
1029
1030 /* This meta-kernel is intended to support operation of SPICE */
1031 /* example programs. The kernels shown here should not be */
1032 /* assumed to contain adequate or correct versions of data */
1033 /* required by SPICE-based user applications. */
1034
1035 /* In order for an application to use this meta-kernel, the */
1036 /* kernels referenced here must be present in the user's */
1037 /* current working directory. */
1038
1039
1040 /* \begindata */
1041
1042 /* KERNELS_TO_LOAD = ( 'de414.bsp', */
1043 /* 'pck00008.tpc', */
1044 /* 'naif0009.tls' ) */
1045
1046 /* \begintext */
1047
1048 /* Conduct a search on the range-rate of the vector from the Sun */
1049 /* to the Moon. Define a function to calculate the value. */
1050
1051 /* Code: */
1052
1053 /* PROGRAM GFUDS_T */
1054 /* IMPLICIT NONE */
1055
1056 /* C */
1057 /* C Include GF parameter declarations: */
1058 /* C */
1059 /* INCLUDE 'gf.inc' */
1060
1061 /* EXTERNAL GFQ */
1062 /* EXTERNAL GFDECR */
1063
1064 /* C */
1065 /* C SPICELIB functions */
1066 /* C */
1067 /* DOUBLE PRECISION SPD */
1068 /* DOUBLE PRECISION DVNORM */
1069 /* INTEGER WNCARD */
1070
1071 /* C */
1072 /* C Local parameters */
1073 /* C */
1074 /* INTEGER LBCELL */
1075 /* PARAMETER ( LBCELL = -5 ) */
1076
1077 /* C */
1078 /* C Use the parameter MAXWIN for both the result window size */
1079 /* C and the workspace size. */
1080 /* C */
1081 /* INTEGER MAXWIN */
1082 /* PARAMETER ( MAXWIN = 20000 ) */
1083
1084 /* C */
1085 /* C Length of strings: */
1086 /* C */
1087 /* INTEGER TIMLEN */
1088 /* PARAMETER ( TIMLEN = 26 ) */
1089
1090 /* INTEGER NLOOPS */
1091 /* PARAMETER ( NLOOPS = 7 ) */
1092
1093 /* C */
1094 /* C Local variables */
1095 /* C */
1096 /* CHARACTER*(TIMLEN) TIMSTR */
1097 /* CHARACTER*(TIMLEN) RELATE (NLOOPS) */
1098
1099 /* DOUBLE PRECISION ADJUST */
1100 /* DOUBLE PRECISION CNFINE ( LBCELL : 2 ) */
1101 /* DOUBLE PRECISION DRDT */
1102 /* DOUBLE PRECISION ET0 */
1103 /* DOUBLE PRECISION ET1 */
1104 /* DOUBLE PRECISION FINISH */
1105 /* DOUBLE PRECISION LT */
1106 /* DOUBLE PRECISION POS ( 6 ) */
1107 /* DOUBLE PRECISION REFVAL */
1108 /* DOUBLE PRECISION RESULT ( LBCELL : MAXWIN ) */
1109 /* DOUBLE PRECISION START */
1110 /* DOUBLE PRECISION STEP */
1111 /* DOUBLE PRECISION WORK ( LBCELL : MAXWIN, NWUDS ) */
1112
1113 /* INTEGER I */
1114 /* INTEGER J */
1115
1116
1117 /* DATA RELATE / '=', */
1118 /* . '<', */
1119 /* . '>', */
1120 /* . 'LOCMIN', */
1121 /* . 'ABSMIN', */
1122 /* . 'LOCMAX', */
1123 /* . 'ABSMAX' / */
1124
1125 /* C */
1126 /* C Load kernels. */
1127 /* C */
1128 /* CALL FURNSH ( 'standard.tm' ) */
1129
1130 /* C */
1131 /* C Initialize windows. */
1132 /* C */
1133 /* CALL SSIZED ( MAXWIN, RESULT ) */
1134 /* CALL SSIZED ( 2, CNFINE ) */
1135
1136 /* CALL SCARDD ( 0, CNFINE ) */
1137
1138 /* C */
1139 /* C Store the time bounds of our search interval in */
1140 /* C the confinement window. */
1141 /* C */
1142 /* CALL STR2ET ( '2007 JAN 1', ET0 ) */
1143 /* CALL STR2ET ( '2007 APR 1', ET1 ) */
1144
1145 /* CALL WNINSD ( ET0, ET1, CNFINE ) */
1146
1147 /* C */
1148 /* C Search using a step size of 1 day (in units of seconds). */
1149 /* C The reference value is .3365 km/s - a range rate value known */
1150 /* C to exist during the confinement window. We're not using the */
1151 /* C adjustment feature, so we set ADJUST to zero. */
1152 /* C */
1153 /* STEP = SPD() */
1154 /* REFVAL = .3365D0 */
1155 /* ADJUST = 0.D0 */
1156
1157 /* DO J=1, NLOOPS */
1158
1159 /* WRITE(*,*) 'Relation condition: ', RELATE(J) */
1160
1161 /* C */
1162 /* C Perform the search. The SPICE window RESULT contains */
1163 /* C the set of times when the condition is met. */
1164 /* C */
1165 /* CALL GFUDS ( GFQ, GFDECR, */
1166 /* . RELATE(J), REFVAL, ADJUST, STEP, CNFINE, */
1167 /* . MAXWIN, NWUDS, WORK, RESULT ) */
1168
1169
1170 /* C */
1171 /* C Display the results. */
1172 /* C */
1173 /* IF ( WNCARD(RESULT) .EQ. 0 ) THEN */
1174
1175 /* WRITE (*, '(A)') 'Result window is empty.' */
1176
1177 /* ELSE */
1178
1179 /* DO I = 1, WNCARD(RESULT) */
1180 /* C */
1181 /* C Fetch the endpoints of the Ith interval */
1182 /* C of the result window. */
1183 /* C */
1184 /* CALL WNFETD ( RESULT, I, START, FINISH ) */
1185
1186 /* CALL SPKEZR ( 'MOON', START, 'J2000', 'NONE', */
1187 /* . 'SUN', POS, LT ) */
1188 /* DRDT = DVNORM(POS) */
1189
1190 /* CALL TIMOUT ( START, 'YYYY-MON-DD HR:MN:SC.###', */
1191 /* . TIMSTR ) */
1192
1193 /* WRITE (*, '(A,F16.9)' ) 'Start time, drdt = '// */
1194 /* . TIMSTR, DRDT */
1195
1196 /* CALL SPKEZR ( 'MOON', FINISH, 'J2000', 'NONE', */
1197 /* . 'SUN', POS, LT ) */
1198 /* DRDT = DVNORM(POS) */
1199
1200 /* CALL TIMOUT ( FINISH, 'YYYY-MON-DD HR:MN:SC.###', */
1201 /* . TIMSTR ) */
1202
1203 /* WRITE (*, '(A,F16.9)' ) 'Stop time, drdt = '// */
1204 /* . TIMSTR, DRDT */
1205 /* END DO */
1206
1207 /* END IF */
1208
1209 /* WRITE(*,*) ' ' */
1210
1211 /* END DO */
1212
1213 /* END */
1214
1215
1216
1217 /* C-Procedure GFQ */
1218
1219 /* SUBROUTINE GFQ ( ET, VALUE ) */
1220 /* IMPLICIT NONE */
1221
1222 /* C- Abstract */
1223 /* C */
1224 /* C User defined geometric quantity function. In this case, */
1225 /* C the range from the sun to the Moon at TDB time ET. */
1226 /* C */
1227
1228 /* DOUBLE PRECISION ET */
1229 /* DOUBLE PRECISION VALUE */
1230
1231 /* C */
1232 /* C Local variables. */
1233 /* C */
1234 /* INTEGER TARG */
1235 /* INTEGER OBS */
1236
1237 /* CHARACTER*(12) REF */
1238 /* CHARACTER*(12) ABCORR */
1239
1240 /* DOUBLE PRECISION STATE ( 6 ) */
1241 /* DOUBLE PRECISION LT */
1242 /* DOUBLE PRECISION DVNORM */
1243
1244 /* C */
1245 /* C Initialization. Retrieve the vector from the Sun to */
1246 /* C the Moon in the J2000 frame, without aberration */
1247 /* C correction. */
1248 /* C */
1249 /* TARG = 301 */
1250 /* REF = 'J2000' */
1251 /* ABCORR = 'NONE' */
1252 /* OBS = 10 */
1253
1254 /* CALL SPKEZ ( TARG, ET, REF, ABCORR, OBS, STATE, LT ) */
1255
1256 /* C */
1257 /* C Calculate the scalar range rate corresponding the */
1258 /* C STATE vector. */
1259 /* C */
1260 /* VALUE = DVNORM( STATE ) */
1261
1262 /* END */
1263
1264
1265
1266
1267 /* C-Procedure GFDECR */
1268
1269 /* SUBROUTINE GFDECR ( UDFUNS, ET, ISDECR ) */
1270 /* IMPLICIT NONE */
1271
1272 /* C- Abstract */
1273 /* C */
1274 /* C User defined function to detect if the function derivative */
1275 /* C is negative (the function is decreasing) at TDB time ET. */
1276 /* C */
1277
1278 /* EXTERNAL UDFUNS */
1279 /* EXTERNAL UDDF */
1280
1281 /* DOUBLE PRECISION ET */
1282 /* LOGICAL ISDECR */
1283
1284 /* DOUBLE PRECISION DT */
1285
1286 /* DT = 1.D0 */
1287
1288 /* C */
1289 /* C Determine if GFQ is decreasing at ET. */
1290 /* C */
1291 /* C UDDC - the default GF function to determine if */
1292 /* C the derivative of the user defined */
1293 /* C function is negative at ET. */
1294 /* C */
1295 /* C UDFUNS - the user defined scalar quantity function. */
1296 /* C */
1297 /* CALL UDDC ( UDFUNS, ET, DT, ISDECR ) */
1298
1299 /* END */
1300
1301 /* The program outputs: */
1302
1303 /* Relation condition: = */
1304 /* Start time, drdt = 2007-JAN-02 00:35:19.574 0.336500000 */
1305 /* Stop time, drdt = 2007-JAN-02 00:35:19.574 0.336500000 */
1306 /* Start time, drdt = 2007-JAN-19 22:04:54.899 0.336500000 */
1307 /* Stop time, drdt = 2007-JAN-19 22:04:54.899 0.336500000 */
1308 /* Start time, drdt = 2007-FEB-01 23:30:13.428 0.336500000 */
1309 /* Stop time, drdt = 2007-FEB-01 23:30:13.428 0.336500000 */
1310 /* Start time, drdt = 2007-FEB-17 11:10:46.540 0.336500000 */
1311 /* Stop time, drdt = 2007-FEB-17 11:10:46.540 0.336500000 */
1312 /* Start time, drdt = 2007-MAR-04 15:50:19.929 0.336500000 */
1313 /* Stop time, drdt = 2007-MAR-04 15:50:19.929 0.336500000 */
1314 /* Start time, drdt = 2007-MAR-18 09:59:05.959 0.336500000 */
1315 /* Stop time, drdt = 2007-MAR-18 09:59:05.959 0.336500000 */
1316
1317 /* Relation condition: < */
1318 /* Start time, drdt = 2007-JAN-02 00:35:19.574 0.336500000 */
1319 /* Stop time, drdt = 2007-JAN-19 22:04:54.899 0.336500000 */
1320 /* Start time, drdt = 2007-FEB-01 23:30:13.428 0.336500000 */
1321 /* Stop time, drdt = 2007-FEB-17 11:10:46.540 0.336500000 */
1322 /* Start time, drdt = 2007-MAR-04 15:50:19.929 0.336500000 */
1323 /* Stop time, drdt = 2007-MAR-18 09:59:05.959 0.336500000 */
1324
1325 /* Relation condition: > */
1326 /* Start time, drdt = 2007-JAN-01 00:00:00.000 0.515522367 */
1327 /* Stop time, drdt = 2007-JAN-02 00:35:19.574 0.336500000 */
1328 /* Start time, drdt = 2007-JAN-19 22:04:54.899 0.336500000 */
1329 /* Stop time, drdt = 2007-FEB-01 23:30:13.428 0.336500000 */
1330 /* Start time, drdt = 2007-FEB-17 11:10:46.540 0.336500000 */
1331 /* Stop time, drdt = 2007-MAR-04 15:50:19.929 0.336500000 */
1332 /* Start time, drdt = 2007-MAR-18 09:59:05.959 0.336500000 */
1333 /* Stop time, drdt = 2007-APR-01 00:00:00.000 0.793546222 */
1334
1335 /* Relation condition: LOCMIN */
1336 /* Start time, drdt = 2007-JAN-11 07:03:58.988 -0.803382743 */
1337 /* Stop time, drdt = 2007-JAN-11 07:03:58.988 -0.803382743 */
1338 /* Start time, drdt = 2007-FEB-10 06:26:15.439 -0.575837623 */
1339 /* Stop time, drdt = 2007-FEB-10 06:26:15.439 -0.575837623 */
1340 /* Start time, drdt = 2007-MAR-12 03:28:36.404 -0.441800446 */
1341 /* Stop time, drdt = 2007-MAR-12 03:28:36.404 -0.441800446 */
1342
1343 /* Relation condition: ABSMIN */
1344 /* Start time, drdt = 2007-JAN-11 07:03:58.988 -0.803382743 */
1345 /* Stop time, drdt = 2007-JAN-11 07:03:58.988 -0.803382743 */
1346
1347 /* Relation condition: LOCMAX */
1348 /* Start time, drdt = 2007-JAN-26 02:27:33.766 1.154648992 */
1349 /* Stop time, drdt = 2007-JAN-26 02:27:33.766 1.154648992 */
1350 /* Start time, drdt = 2007-FEB-24 09:35:07.816 1.347132236 */
1351 /* Stop time, drdt = 2007-FEB-24 09:35:07.816 1.347132236 */
1352 /* Start time, drdt = 2007-MAR-25 17:26:56.150 1.428141707 */
1353 /* Stop time, drdt = 2007-MAR-25 17:26:56.150 1.428141707 */
1354
1355 /* Relation condition: ABSMAX */
1356 /* Start time, drdt = 2007-MAR-25 17:26:56.150 1.428141707 */
1357 /* Stop time, drdt = 2007-MAR-25 17:26:56.150 1.428141707 */
1358
1359 /* $ Restrictions */
1360
1361 /* 1) Any kernel files required by this routine must be loaded */
1362 /* (normally via the SPICELIB routine FURNSH) before this routine */
1363 /* is called. */
1364
1365 /* $ Literature_References */
1366
1367 /* None. */
1368
1369 /* $ Author_and_Institution */
1370
1371 /* N.J. Bachman (JPL) */
1372 /* E.D. Wright (JPL) */
1373
1374 /* $ Version */
1375
1376 /* - SPICELIB Version 1.1.0, 15-JUL-2014 (EDW) */
1377
1378 /* Correction to description of UDQDEC to show UDFUNS as */
1379 /* an argument. */
1380
1381 /* Edit to comments to correct search description. */
1382
1383 /* Implemented use of ZZHOLDD to allow user to alter convergence */
1384 /* tolerance. */
1385
1386 /* Removed the STEP > 0 error check. The GFSSTP call includes */
1387 /* the check. */
1388
1389 /* Removed ZZGFREF call. That call now occurs in ZZGFRELX. Update */
1390 /* to ZZGFRELX argument list to reflect this change in */
1391 /* functionality. */
1392
1393 /* Added RETURN() check. */
1394
1395 /* - SPICELIB Version 1.0.0 16-FEB-2010 (EDW) */
1396
1397 /* -& */
1398 /* $ Index_Entries */
1399
1400 /* GF user defined scalar function search */
1401
1402 /* -& */
1403
1404 /* SPICELIB functions. */
1405
1406
1407 /* Local variables. */
1408
1409
1410 /* Dummy variables. */
1411
1412
1413 /* Standard SPICE error handling. */
1414
1415 /* Parameter adjustments */
1416 work_dim1 = *mw + 6;
1417 work_offset = work_dim1 - 5;
1418
1419 /* Function Body */
1420 if (return_()) {
1421 return 0;
1422 }
1423 chkin_("GFUDS", (ftnlen)5);
1424
1425 /* Confirm minimum number of windows. */
1426
1427 if (*nw < 5) {
1428 setmsg_("Workspace window count was #; count must be at least #.", (
1429 ftnlen)55);
1430 errint_("#", nw, (ftnlen)1);
1431 errint_("#", &c__5, (ftnlen)1);
1432 sigerr_("SPICE(INVALIDDIMENSION)", (ftnlen)23);
1433 chkout_("GFUDS", (ftnlen)5);
1434 return 0;
1435 }
1436
1437 /* Confirm minimum window sizes. */
1438
1439 if (*mw < 2 || odd_(mw)) {
1440 setmsg_("Workspace window size was #; size must be at least 2 and an"
1441 " even value.", (ftnlen)71);
1442 errint_("#", mw, (ftnlen)1);
1443 sigerr_("SPICE(INVALIDDIMENSION)", (ftnlen)23);
1444 chkout_("GFUDS", (ftnlen)5);
1445 return 0;
1446 }
1447
1448 /* Check the result window size. */
1449
1450 i__1 = sized_(result);
1451 if (sized_(result) < 2 || odd_(&i__1)) {
1452 setmsg_("Result window size was #; size must be at least 2 and an ev"
1453 "en value.", (ftnlen)68);
1454 i__1 = sized_(result);
1455 errint_("#", &i__1, (ftnlen)1);
1456 sigerr_("SPICE(INVALIDDIMENSION)", (ftnlen)23);
1457 chkout_("GFUDS", (ftnlen)5);
1458 return 0;
1459 }
1460
1461 /* Set the step size. */
1462
1463 gfsstp_(step);
1464
1465 /* Retrieve the convergence tolerance, if set. */
1466
1467 zzholdd_(&c_n1, &c__3, &ok, &tol);
1468
1469 /* Use the default value CNVTOL if no stored tolerance value. */
1470
1471 if (! ok) {
1472 tol = 1e-6;
1473 }
1474
1475 /* Initialize the RESULT window to empty. */
1476
1477 scardd_(&c__0, result);
1478
1479 /* Call ZZGFRELX to do the event detection work. */
1480
1481 zzgfrelx_((U_fp)gfstep_, (U_fp)gfrefn_, (U_fp)udqdec, (U_fp)zzgfudlt_, (
1482 U_fp)udfuns, relate, refval, &tol, adjust, cnfine, mw, nw, work, &
1483 c_false, (U_fp)gfrepi_, (U_fp)gfrepu_, (U_fp)gfrepf_, rptpre,
1484 rptsuf, &c_false, (L_fp)gfbail_, result, relate_len, (ftnlen)1, (
1485 ftnlen)1);
1486 chkout_("GFUDS", (ftnlen)5);
1487 return 0;
1488 } /* gfuds_ */
1489
1490