1 /* 2 3 -Procedure zzadqdec_c ( Private - GF, user defined boolean adapter ) 4 5 -Abstract 6 7 Provide an f2c-style interface allowing f2c'd Fortran 8 code to call a CSPICE-style GF routine that determines 9 the value of a user defined boolean function. 10 11 -Disclaimer 12 13 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 14 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 15 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 16 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 17 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 18 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 19 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 20 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 21 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 22 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 23 24 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 25 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 26 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 27 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 28 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 29 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 30 31 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 32 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 33 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 34 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 35 36 -Required_Reading 37 38 None. 39 40 -Keywords 41 42 SEARCH 43 UTILITY 44 45 */ 46 47 #include "SpiceUsr.h" 48 #include "SpiceZfc.h" 49 #include "SpiceZst.h" 50 #include "SpiceZad.h" 51 zzadqdec_c(U_fp udfunc,doublereal * et,logical * xbool)52 int zzadqdec_c ( U_fp udfunc, 53 doublereal * et, 54 logical * xbool ) 55 56 /* 57 58 -Brief_I/O 59 60 VARIABLE I/O DESCRIPTION 61 -------- --- -------------------------------------------------- 62 udfunc I Name of scalar function of interest. 63 et I Epoch of interest in TDB seconds. 64 xbool O Boolean value at `et'. 65 66 -Detailed_Input 67 68 udfunc the name of the external routine that returns the 69 value of the scalar quantity of interest at time `et'. 70 71 et a double precision value representing 72 ephemeris time, expressed as seconds past 73 J2000 TDB, at which to evaluate "udfunb." 74 75 -Detailed_Output 76 77 xbool the value of the boolean quantity function at `et'. 78 79 -Parameters 80 81 None. 82 83 -Exceptions 84 85 1) A run-time error will result if this routine is called before 86 a valid pointer to a CSPICE-style function has been stored via 87 a call to zzadqdec_c. 88 89 The argument list of the stored function must match that of 90 udqdec (refer to gfuds_c.c). 91 92 -Files 93 94 None. 95 96 -Particulars 97 98 This routine is meant to be passed to f2c'd Fortran GF code that 99 requires a derivative sign test function as an argument. 100 101 This routine calls the CSPICE-style derivative test function 102 passed to a CSPICE wrapper for use by an intermediate-level GF 103 function. A pointer to this function must be stored via a call 104 to zzadsave_c before this routine is called. 105 106 -Examples 107 108 None. 109 110 -Restrictions 111 112 1) This function is intended only for internal use by GF routines. 113 114 -Literature_References 115 116 None. 117 118 -Author_and_Institution 119 120 N.J. Bachman (JPL) 121 L.S. Elson (JPL) 122 W.L. Taber (JPL) 123 I.M. Underwood (JPL) 124 E.D. Wright (JPL) 125 126 -Version 127 128 -CSPICE Version 2.0.0, 23-OCT-2013 (EDW) 129 130 131 -CSPICE Version 1.0.0, 21-DEC-2008 (EDW) 132 133 -Index_Entries 134 135 adapter for gf user defined boolean quantity 136 137 -& 138 */ 139 140 { /* Begin zzadqdec_c */ 141 142 /* 143 Local variables 144 */ 145 void ( * fPtr ) ( void ( * ) ( SpiceDouble, 146 SpiceDouble *), 147 SpiceDouble, 148 SpiceBoolean * ); 149 150 void ( * fPtr2) ( SpiceDouble, 151 SpiceDouble * ); 152 153 SpiceBoolean bool_loc; 154 155 /* 156 Participate in error tracing. 157 */ 158 159 if ( return_c() ) 160 { 161 return ( 0 ); 162 } 163 chkin_c ( "zzadqdec_c" ); 164 165 /* 166 Retrieve the stored pointer for the passed-in function; cast 167 the pointer from (void *) to that of a function whose argument 168 list matches that of "udqdec." 169 */ 170 fPtr = ( void (*) ( void ( * ) ( SpiceDouble, SpiceDouble *), 171 SpiceDouble, 172 SpiceBoolean*) ) zzadget_c ( UDQDEC ); 173 174 /* 175 Retrieve the stored pointer for the user defined scalar function. The 176 'udfunc' pointer passed to zzadqdec_c as an argument corresponds to 177 the adapter for the scalar function, but the function pointer 178 argument in 'fPtr' requires the non-adapter pointer. Ignore 'udfunc'. 179 */ 180 fPtr2= ( void (*) (SpiceDouble, SpiceDouble*) ) zzadget_c ( UDFUNC ); 181 182 /* 183 Call the stored function. 184 */ 185 (*fPtr) ( fPtr2, (SpiceDouble)(*et), (SpiceBoolean *) &bool_loc ); 186 187 /* 188 Cast the "SpiceBoolean" to "logical" to prevent any future size mismatches 189 or compiler warnings. 190 */ 191 *xbool = (logical) bool_loc; 192 193 chkout_c ( "zzadqdec_c" ); 194 195 return ( 0 ); 196 197 } /* End zzadqdec_c */ 198