/src/bodvrd.c

https://github.com/mattbornski/spice · C · 368 lines · 74 code · 101 blank · 193 comment · 7 complexity · 66bf5c403adb1d60a37c5767be739f30 MD5 · raw file

  1. /* bodvrd.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. #include "f2c.h"
  6. /* Table of constant values */
  7. static integer c__0 = 0;
  8. static integer c__1 = 1;
  9. /* $Procedure BODVRD ( Return d.p. values from the kernel pool ) */
  10. /* Subroutine */ int bodvrd_(char *bodynm, char *item, integer *maxn, integer
  11. *dim, doublereal *values, ftnlen bodynm_len, ftnlen item_len)
  12. {
  13. /* Builtin functions */
  14. /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
  15. /* Local variables */
  16. char code[16], type__[1];
  17. extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
  18. ftnlen, ftnlen);
  19. logical found;
  20. extern /* Subroutine */ int bods2c_(char *, integer *, logical *, ftnlen);
  21. integer bodyid;
  22. char varnam[32];
  23. extern /* Subroutine */ int gdpool_(char *, integer *, integer *, integer
  24. *, doublereal *, logical *, ftnlen), sigerr_(char *, ftnlen),
  25. chkout_(char *, ftnlen), dtpool_(char *, logical *, integer *,
  26. char *, ftnlen, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
  27. integer *, ftnlen), suffix_(char *, integer *, char *, ftnlen,
  28. ftnlen);
  29. extern logical return_(void);
  30. extern /* Subroutine */ int intstr_(integer *, char *, ftnlen);
  31. /* $ Abstract */
  32. /* Fetch from the kernel pool the double precision values */
  33. /* of an item associated with a body. */
  34. /* $ Disclaimer */
  35. /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
  36. /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
  37. /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
  38. /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
  39. /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
  40. /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
  41. /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
  42. /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
  43. /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
  44. /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
  45. /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
  46. /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
  47. /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
  48. /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
  49. /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
  50. /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
  51. /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
  52. /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
  53. /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
  54. /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
  55. /* $ Required_Reading */
  56. /* KERNEL */
  57. /* NAIF_IDS */
  58. /* $ Keywords */
  59. /* CONSTANTS */
  60. /* $ Declarations */
  61. /* $ Brief_I/O */
  62. /* VARIABLE I/O DESCRIPTION */
  63. /* -------- --- -------------------------------------------------- */
  64. /* BODYNM I Body name. */
  65. /* ITEM I Item for which values are desired. ('RADII', */
  66. /* 'NUT_PREC_ANGLES', etc. ) */
  67. /* MAXN I Maximum number of values that may be returned. */
  68. /* DIM O Number of values returned. */
  69. /* VALUES O Values. */
  70. /* $ Detailed_Input */
  71. /* BODYNM is the name of the body for which ITEM is requested. */
  72. /* BODYNM is case-insensitive, and leading and trailing */
  73. /* blanks in BODYNM are not significant. Optionally, you */
  74. /* may supply the integer ID code for the object as an */
  75. /* integer string. For example both 'MOON' and '301' are */
  76. /* legitimate strings that indicate the moon is the body */
  77. /* of interest. */
  78. /* ITEM is the item to be returned. Together, the NAIF ID */
  79. /* code of the body and the item name combine to form a */
  80. /* kernel variable name, e.g., */
  81. /* 'BODY599_RADII' */
  82. /* 'BODY401_POLE_RA' */
  83. /* The values associated with the kernel variable having */
  84. /* the name constructed as shown are sought. Below */
  85. /* we'll take the shortcut of calling this kernel variable */
  86. /* the "requested kernel variable." */
  87. /* Note that ITEM *is* case-sensitive. This attribute */
  88. /* is inherited from the case-sensitivity of kernel */
  89. /* variable names. */
  90. /* MAXN is the maximum number of values that may be returned. */
  91. /* The output array VALUES must be declared with size at */
  92. /* least MAXN. It's an error to supply an output array */
  93. /* that is too small to hold all of the values associated */
  94. /* with the requested kernel variable. */
  95. /* $ Detailed_Output */
  96. /* DIM is the number of values returned; this is always the */
  97. /* number of values associated with the requested kernel */
  98. /* variable unless an error has been signaled. */
  99. /* VALUES is the array of values associated with the requested */
  100. /* kernel variable. If VALUES is too small to hold all */
  101. /* of the values associated with the kernel variable, the */
  102. /* returned values of DIM and VALUES are undefined. */
  103. /* $ Parameters */
  104. /* None. */
  105. /* $ Exceptions */
  106. /* 1) If the input body name cannot be translated to an ID code, */
  107. /* and if the name is not a string representation of an integer */
  108. /* (for example, '399'), the error SPICE(NOTRANSLATION) is */
  109. /* signaled. */
  110. /* 2) If the requested kernel variable is not found in the kernel */
  111. /* pool, the error SPICE(KERNELVARNOTFOUND) is signaled. */
  112. /* 3) If the requested kernel variable is found but the associated */
  113. /* values aren't numeric, the error SPICE(TYPEMISMATCH) is */
  114. /* signaled. */
  115. /* 4) The output array VALUES must be declared with sufficient size */
  116. /* to contain all of the values associated with the requested */
  117. /* kernel variable. If the dimension of */
  118. /* VALUES indicated by MAXN is too small to contain the */
  119. /* requested values, the error SPICE(ARRAYTOOSMALL) is signaled. */
  120. /* 5) If the input dimension MAXN indicates there is more room */
  121. /* in VALUES than there really is---for example, if MAXN is */
  122. /* 10 but values is declared with dimension 5---and the dimension */
  123. /* of the requested kernel variable is larger than the actual */
  124. /* dimension of VALUES, then this routine may overwrite */
  125. /* memory. The results are unpredictable. */
  126. /* $ Files */
  127. /* None. */
  128. /* $ Particulars */
  129. /* This routine simplifies looking up PCK kernel variables by */
  130. /* constructing names of requested kernel variables and by */
  131. /* performing error checking. */
  132. /* This routine is intended for use in cases where the maximum */
  133. /* number of values that may be returned is known at compile */
  134. /* time. The caller fetches all of the values associated with */
  135. /* the specified kernel variable via a single call to this */
  136. /* routine. If the number of values to be fetched cannot be */
  137. /* known until run time, the lower-level routine GDPOOL (an */
  138. /* entry point of POOL) should be used instead. GDPOOL supports */
  139. /* fetching arbitrary amounts of data in multiple "chunks." */
  140. /* This routine is intended for use in cases where the requested */
  141. /* kernel variable is expected to be present in the kernel pool. If */
  142. /* the variable is not found or has the wrong data type, this */
  143. /* routine signals an error. In cases where it is appropriate to */
  144. /* indicate absence of an expected kernel variable by returning a */
  145. /* boolean "found flag" with the value .FALSE., again the routine */
  146. /* GDPOOL should be used. */
  147. /* $ Examples */
  148. /* 1) When the kernel variable */
  149. /* BODY399_RADII */
  150. /* is present in the kernel pool---normally because a PCK */
  151. /* defining this variable has been loaded---the call */
  152. /* CALL BODVRD ( 'EARTH', 'RADII', 3, DIM, VALUES ) */
  153. /* returns the dimension and values associated with the variable */
  154. /* 'BODY399_RADII', for example, */
  155. /* DIM = 3 */
  156. /* VALUES(1) = 6378.140 */
  157. /* VALUES(2) = 6378.140 */
  158. /* VALUES(3) = 6356.755 */
  159. /* 2) The call */
  160. /* CALL BODVRD ( 'earth', 'RADII', 3, DIM, VALUES ) */
  161. /* will produce the same results shown in example (1), */
  162. /* since the case of the input argument BODYNM is */
  163. /* not significant. */
  164. /* 3) The call */
  165. /* CALL BODVRD ( '399', 'RADII', 3, DIM, VALUES ) */
  166. /* will produce the same results shown in example (1), */
  167. /* since strings containing integer codes are accepted */
  168. /* by this routine. */
  169. /* 4) The call */
  170. /* CALL BODVRD ( 'EARTH', 'radii', 3, DIM, VALUES ) */
  171. /* usually will cause a SPICE(KERNELVARNOTFOUND) error to be */
  172. /* signaled, because this call will attempt to look up the */
  173. /* values associated with a kernel variable of the name */
  174. /* 'BODY399_radii' */
  175. /* Since kernel variable names are case sensitive, this */
  176. /* name is not considered to match the name */
  177. /* 'BODY399_RADII' */
  178. /* which normally would be present after a text PCK */
  179. /* containing data for all planets and satellites has */
  180. /* been loaded. */
  181. /* $ Restrictions */
  182. /* None. */
  183. /* $ Literature_References */
  184. /* None. */
  185. /* $ Author_and_Institution */
  186. /* N.J. Bachman (JPL) */
  187. /* B.V. Semenov (JPL) */
  188. /* W.L. Taber (JPL) */
  189. /* I.M. Underwood (JPL) */
  190. /* $ Version */
  191. /* - SPICELIB Version 1.1.0, 22-JUL-2004 (NJB) */
  192. /* Updated to use BODS2C. */
  193. /* - SPICELIB Version 1.0.0, 23-FEB-2004 (NJB) (BVS) (WLT) (IMU) */
  194. /* -& */
  195. /* $ Index_Entries */
  196. /* fetch constants for a body from the kernel pool */
  197. /* physical constants for a body */
  198. /* -& */
  199. /* $ Revisions */
  200. /* - SPICELIB Version 1.1.0, 22-JUL-2004 (NJB) */
  201. /* Updated to use BODS2C. This simplifies the name-to-ID */
  202. /* mapping code. */
  203. /* -& */
  204. /* SPICELIB functions */
  205. /* Local parameters */
  206. /* Local variables */
  207. /* Standard SPICE error handling. */
  208. if (return_()) {
  209. return 0;
  210. } else {
  211. chkin_("BODVRD", (ftnlen)6);
  212. }
  213. /* Translate the input name to an ID code. */
  214. bods2c_(bodynm, &bodyid, &found, bodynm_len);
  215. if (! found) {
  216. setmsg_("The body name # could not be translated to a NAIF ID code. "
  217. " The cause of this problem may be that you need an updated v"
  218. "ersion of the SPICE Toolkit.", (ftnlen)147);
  219. errch_("#", bodynm, (ftnlen)1, bodynm_len);
  220. sigerr_("SPICE(NOTRANSLATION)", (ftnlen)20);
  221. chkout_("BODVRD", (ftnlen)6);
  222. return 0;
  223. }
  224. /* Construct the variable name from BODY and ITEM. */
  225. s_copy(varnam, "BODY", (ftnlen)32, (ftnlen)4);
  226. intstr_(&bodyid, code, (ftnlen)16);
  227. suffix_(code, &c__0, varnam, (ftnlen)16, (ftnlen)32);
  228. suffix_("_", &c__0, varnam, (ftnlen)1, (ftnlen)32);
  229. suffix_(item, &c__0, varnam, item_len, (ftnlen)32);
  230. /* Make sure the item is present in the kernel pool. */
  231. dtpool_(varnam, &found, dim, type__, (ftnlen)32, (ftnlen)1);
  232. if (! found) {
  233. setmsg_("The variable # could not be found in the kernel pool.", (
  234. ftnlen)53);
  235. errch_("#", varnam, (ftnlen)1, (ftnlen)32);
  236. sigerr_("SPICE(KERNELVARNOTFOUND)", (ftnlen)24);
  237. chkout_("BODVRD", (ftnlen)6);
  238. return 0;
  239. }
  240. /* Make sure the item's data type is numeric. */
  241. if (*(unsigned char *)type__ != 'N') {
  242. setmsg_("The data associated with variable # are not of numeric type."
  243. , (ftnlen)60);
  244. errch_("#", varnam, (ftnlen)1, (ftnlen)32);
  245. sigerr_("SPICE(TYPEMISMATCH)", (ftnlen)19);
  246. chkout_("BODVRD", (ftnlen)6);
  247. return 0;
  248. }
  249. /* Make sure there's enough room in the array VALUES to hold */
  250. /* the requested data. */
  251. if (*maxn < *dim) {
  252. setmsg_("The data array associated with variable # has dimension #, "
  253. "which is larger than the available space # in the output arr"
  254. "ay.", (ftnlen)122);
  255. errch_("#", varnam, (ftnlen)1, (ftnlen)32);
  256. errint_("#", dim, (ftnlen)1);
  257. errint_("#", maxn, (ftnlen)1);
  258. sigerr_("SPICE(ARRAYTOOSMALL)", (ftnlen)20);
  259. chkout_("BODVRD", (ftnlen)6);
  260. return 0;
  261. }
  262. /* Grab the values. We know at this point they're present in */
  263. /* the kernel pool, so we don't check the FOUND flag. */
  264. gdpool_(varnam, &c__1, maxn, dim, values, &found, (ftnlen)32);
  265. chkout_("BODVRD", (ftnlen)6);
  266. return 0;
  267. } /* bodvrd_ */