1 /* gfrefn.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 /* $Procedure GFREFN ( GF, default refinement estimator) */
gfrefn_(doublereal * t1,doublereal * t2,logical * s1,logical * s2,doublereal * t)9 /* Subroutine */ int gfrefn_(doublereal *t1, doublereal *t2, logical *s1,
10 	logical *s2, doublereal *t)
11 {
12     doublereal x;
13     extern doublereal brcktd_(doublereal *, doublereal *, doublereal *);
14 
15 /* $ Abstract */
16 
17 /*     For those times when we can't do better, we use a bisection */
18 /*     method to find the next estimate of state change. */
19 
20 /* $ Disclaimer */
21 
22 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
23 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
24 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
25 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
26 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
27 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
28 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
29 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
30 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
31 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
32 
33 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
34 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
35 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
36 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
37 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
38 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
39 
40 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
41 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
42 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
43 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
44 
45 /* $ Required_Reading */
46 
47 /*     None. */
48 
49 /* $ Keywords */
50 
51 /*     SEARCH */
52 /*     UTILITY */
53 
54 /* $ Declarations */
55 /* $ Brief_I/O */
56 
57 /*     VARIABLE  I/O  DESCRIPTION */
58 /*     --------  ---  -------------------------------------------------- */
59 /*     T1         I   One of two values bracketing a state change. */
60 /*     T2         I   The other value that brackets a state change. */
61 /*     S1         I   State at T1. */
62 /*     S2         I   State at T2. */
63 /*     T          O   New value at which to check for transition. */
64 
65 /* $ Detailed_Input */
66 
67 /*     T1         One of two abscissa values (usually times) */
68 /*                bracketing a state change. */
69 
70 /*     T2         The other abscissa value that brackets a state change. */
71 
72 /*     S1         System state at T1. This argument is provided */
73 /*                for forward compatibility; it's not currently used. */
74 
75 /*     S2         System state at T2. This argument is provided */
76 /*                for forward compatibility; it's not currently used. */
77 
78 /* $ Detailed_Output */
79 
80 /*     T          the midpoint of T1 and T2. */
81 
82 /* $ Parameters */
83 
84 /*     None. */
85 
86 /* $ Exceptions */
87 
88 /*     Error free */
89 
90 /* $ Files */
91 
92 /*     None. */
93 
94 /* $ Particulars */
95 
96 /*   "Refinement" means reducing the size of a bracketing interval on the */
97 /*   real line in which a solution is known to lie. In the GF setting, */
98 /*   the solution is the time of a state transition of a binary function. */
99 
100 /*   This routine supports solving for locations of bracketed state */
101 /*   transitions by the bisection method. This is the default refinement */
102 /*   method used by the GF system. */
103 
104 /*   The argument list of this routine is compatible with the GF system's */
105 /*   general root finding routine. Refinement routines created by users */
106 /*   must have the same argument list in order to be used by the GF */
107 /*   mid-level APIs such as GFOCCE and GFFOVE. */
108 
109 /* $ Examples */
110 
111 /*   The following code fragment from an example program in the header of */
112 /*   GFOCCE shows the routine passed as the 12th argument. */
113 
114 /*      C */
115 /*      C     Define as EXTERNAL the routines to pass to GFOCCE. */
116 /*      C */
117 /*            EXTERNAL              GFSTEP */
118 /*            EXTERNAL              GFREFN */
119 /*            EXTERNAL              GFREPI */
120 /*            EXTERNAL              GFREPU */
121 /*            EXTERNAL              GFREPF */
122 /*            EXTERNAL              GFBAIL */
123 
124 /*               ... initialize for the search ... */
125 
126 /*            CALL GFOCCE ( 'ANY', */
127 /*           .              'MOON',   'ellipsoid',  'IAU_MOON', */
128 /*           .              'SUN',    'ellipsoid',  'IAU_SUN', */
129 /*           .              'LT',     'EARTH',       CNVTOL, */
130 /*           .               GFSTEP,   GFREFN,       RPT, */
131 /*           .               GFREPI,   GFREPU,       GFREPF, */
132 /*           .               BAIL,     GFBAIL,       CNFINE,  RESULT ) */
133 
134 /* $ Restrictions */
135 
136 /*      No errors are returned by this routine. */
137 
138 /* $ Literature_References */
139 
140 /*     None. */
141 
142 /* $ Author_and_Institution */
143 
144 /*     W.L. Taber     (JPL) */
145 /*     I.M. Underwood (JPL) */
146 /*     L.S. Elson     (JPL) */
147 
148 /* $ Version */
149 
150 /*   SPICELIB Version 1.0.0, 03-MAR-2009 (NJB) (EDW) */
151 
152 /* -& */
153 /* $ Index_Entries */
154 
155 /*     GF standard step refinement */
156 
157 /* -& */
158 
159 /*     SPICELIB functions */
160 
161 
162 /*     Local variables. */
163 
164     x = *t1 * .5 + *t2 * .5;
165     *t = brcktd_(&x, t1, t2);
166     return 0;
167 } /* gfrefn_ */
168 
169