PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/src/cknr04.c

https://github.com/mattbornski/spice
C | 433 lines | 33 code | 123 blank | 277 comment | 4 complexity | 7c450626f41f43dab8ec561eddd58915 MD5 | raw file
  1. /* cknr04.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__2 = 2;
  8. static integer c__6 = 6;
  9. static integer c__12 = 12;
  10. /* $Procedure CKNR04 ( C-kernel, number of records, data type 4 ) */
  11. /* Subroutine */ int cknr04_(integer *handle, doublereal *descr, integer *
  12. nrec)
  13. {
  14. extern /* Subroutine */ int chkin_(char *, ftnlen), dafus_(doublereal *,
  15. integer *, integer *, doublereal *, integer *), sgmeta_(integer *,
  16. doublereal *, integer *, integer *), sigerr_(char *, ftnlen),
  17. chkout_(char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *,
  18. integer *, ftnlen);
  19. extern logical return_(void);
  20. doublereal dcd[2];
  21. integer icd[6];
  22. /* $ Abstract */
  23. /* Given the handle of a CK file and the descriptor of a type 4 */
  24. /* segment in that file, return the number of pointing instances */
  25. /* in that segment. */
  26. /* $ Disclaimer */
  27. /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
  28. /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
  29. /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
  30. /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
  31. /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
  32. /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
  33. /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
  34. /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
  35. /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
  36. /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
  37. /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
  38. /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
  39. /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
  40. /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
  41. /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
  42. /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
  43. /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
  44. /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
  45. /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
  46. /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
  47. /* $ Required_Reading */
  48. /* CK.REQ */
  49. /* DAF.REQ */
  50. /* GS.REQ */
  51. /* $ Keywords */
  52. /* POINTING */
  53. /* $ Declarations */
  54. /* $ Abstract */
  55. /* Declarations of the CK data type specific and general CK low */
  56. /* level routine parameters. */
  57. /* $ Disclaimer */
  58. /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
  59. /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
  60. /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
  61. /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
  62. /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
  63. /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
  64. /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
  65. /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
  66. /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
  67. /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
  68. /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
  69. /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
  70. /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
  71. /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
  72. /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
  73. /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
  74. /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
  75. /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
  76. /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
  77. /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
  78. /* $ Required_Reading */
  79. /* CK.REQ */
  80. /* $ Keywords */
  81. /* CK */
  82. /* $ Restrictions */
  83. /* 1) If new CK types are added, the size of the record passed */
  84. /* between CKRxx and CKExx must be registered as separate */
  85. /* parameter. If this size will be greater than current value */
  86. /* of the CKMRSZ parameter (which specifies the maximum record */
  87. /* size for the record buffer used inside CKPFS) then it should */
  88. /* be assigned to CKMRSZ as a new value. */
  89. /* $ Author_and_Institution */
  90. /* N.J. Bachman (JPL) */
  91. /* B.V. Semenov (JPL) */
  92. /* $ Literature_References */
  93. /* CK Required Reading. */
  94. /* $ Version */
  95. /* - SPICELIB Version 2.0.0, 19-AUG-2002 (NJB) */
  96. /* Updated to support CK type 5. */
  97. /* - SPICELIB Version 1.0.0, 05-APR-1999 (BVS) */
  98. /* -& */
  99. /* Number of quaternion components and number of quaternion and */
  100. /* angular rate components together. */
  101. /* CK Type 1 parameters: */
  102. /* CK1DTP CK data type 1 ID; */
  103. /* CK1RSZ maximum size of a record passed between CKR01 */
  104. /* and CKE01. */
  105. /* CK Type 2 parameters: */
  106. /* CK2DTP CK data type 2 ID; */
  107. /* CK2RSZ maximum size of a record passed between CKR02 */
  108. /* and CKE02. */
  109. /* CK Type 3 parameters: */
  110. /* CK3DTP CK data type 3 ID; */
  111. /* CK3RSZ maximum size of a record passed between CKR03 */
  112. /* and CKE03. */
  113. /* CK Type 4 parameters: */
  114. /* CK4DTP CK data type 4 ID; */
  115. /* CK4PCD parameter defining integer to DP packing schema that */
  116. /* is applied when seven number integer array containing */
  117. /* polynomial degrees for quaternion and angular rate */
  118. /* components packed into a single DP number stored in */
  119. /* actual CK records in a file; the value of must not be */
  120. /* changed or compatibility with existing type 4 CK files */
  121. /* will be lost. */
  122. /* CK4MXD maximum Chebychev polynomial degree allowed in type 4 */
  123. /* records; the value of this parameter must never exceed */
  124. /* value of the CK4PCD; */
  125. /* CK4SFT number of additional DPs, which are not polynomial */
  126. /* coefficients, located at the beginning of a type 4 */
  127. /* CK record that passed between routines CKR04 and CKE04; */
  128. /* CK4RSZ maximum size of type 4 CK record passed between CKR04 */
  129. /* and CKE04; CK4RSZ is computed as follows: */
  130. /* CK4RSZ = ( CK4MXD + 1 ) * QAVSIZ + CK4SFT */
  131. /* CK Type 5 parameters: */
  132. /* CK5DTP CK data type 5 ID; */
  133. /* CK5MXD maximum polynomial degree allowed in type 5 */
  134. /* records. */
  135. /* CK5MET number of additional DPs, which are not polynomial */
  136. /* coefficients, located at the beginning of a type 5 */
  137. /* CK record that passed between routines CKR05 and CKE05; */
  138. /* CK5MXP maximum packet size for any subtype. Subtype 2 */
  139. /* has the greatest packet size, since these packets */
  140. /* contain a quaternion, its derivative, an angular */
  141. /* velocity vector, and its derivative. See ck05.inc */
  142. /* for a description of the subtypes. */
  143. /* CK5RSZ maximum size of type 5 CK record passed between CKR05 */
  144. /* and CKE05; CK5RSZ is computed as follows: */
  145. /* CK5RSZ = ( CK5MXD + 1 ) * CK5MXP + CK5MET */
  146. /* Maximum record size that can be handled by CKPFS. This value */
  147. /* must be set to the maximum of all CKxRSZ parameters (currently */
  148. /* CK4RSZ.) */
  149. /* $ Brief_I/O */
  150. /* Variable I/O Description */
  151. /* -------- --- -------------------------------------------------- */
  152. /* HANDLE I The handle of the file containing the segment. */
  153. /* DESCR I The descriptor of the type 4 segment. */
  154. /* NREC O The number of pointing records in the segment. */
  155. /* $ Detailed_Input */
  156. /* HANDLE is the handle of the binary CK file containing the */
  157. /* segment. The file should have been opened for read */
  158. /* or write access, either by CKLPF, DAFOPR, or DAFOPW. */
  159. /* DESCR The packed descriptor of a data type 4 segment. */
  160. /* $ Detailed_Output */
  161. /* NREC The number of pointing records in the type 4 */
  162. /* segment. */
  163. /* $ Parameters */
  164. /* See 'ckparam.inc'. */
  165. /* $ Files */
  166. /* The file specified by HANDLE should be open for read or */
  167. /* write access. */
  168. /* $ Exceptions */
  169. /* 1) If the segment indicated by DESCR is not a type 4 segment, */
  170. /* the error 'SPICE(CKWRONGDATATYPE)' is signalled. */
  171. /* 2) If the specified handle does not belong to any DAF file that */
  172. /* is currently known to be open, an error is diagnosed by a */
  173. /* routine that this routine calls. */
  174. /* 3) If DESCR is not a valid descriptor of a segment in the CK */
  175. /* file specified by HANDLE, the results of this routine are */
  176. /* unpredictable. */
  177. /* $ Particulars */
  178. /* For a complete description of the internal structure of a type 4 */
  179. /* segment, see the CK required reading. */
  180. /* This routine returns the number of pointing records contained */
  181. /* in the specified segment. It is normally used in conjunction */
  182. /* with CKGR04 which returns the Ith pointing record in the */
  183. /* segment. */
  184. /* $ Examples */
  185. /* Suppose that DATA.BC is a CK file that contains segments of */
  186. /* data type 4. Then the following code fragment extracts the */
  187. /* data packets contained in the segment. */
  188. /* C */
  189. /* C CK parameters include file. */
  190. /* C */
  191. /* INCLUDE 'ckparam.inc' */
  192. /* C */
  193. /* C Declarations. */
  194. /* C */
  195. /* DOUBLE PRECISION DCD ( 2 ) */
  196. /* DOUBLE PRECISION DESCR ( 5 ) */
  197. /* DOUBLE PRECISION PKTDAT ( CK4RSZ ) */
  198. /* INTEGER AVFLAG */
  199. /* INTEGER HANDLE */
  200. /* INTEGER I */
  201. /* INTEGER ICD ( 6 ) */
  202. /* INTEGER K */
  203. /* INTEGER LASTAD */
  204. /* INTEGER NCOEF ( QAVSIZ ) */
  205. /* INTEGER NREC */
  206. /* LOGICAL FOUND */
  207. /* C */
  208. /* C First load the file. (The file may also be opened by using */
  209. /* C CKLPF.) */
  210. /* C */
  211. /* CALL DAFOPR ( 'DATA.BC', HANDLE ) */
  212. /* C */
  213. /* C Begin forward search. Find the first array. */
  214. /* C */
  215. /* CALL DAFBFS ( HANDLE ) */
  216. /* CALL DAFFNA ( FOUND ) */
  217. /* C */
  218. /* C Get segment descriptor. */
  219. /* C */
  220. /* CALL DAFGS ( DESCR ) */
  221. /* C */
  222. /* C Unpack the segment descriptor into its double precision */
  223. /* C and integer components. */
  224. /* C */
  225. /* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
  226. /* IF ( ICD( 3 ) .EQ. 4 ) THEN */
  227. /* C */
  228. /* C How many records does this segment contain? */
  229. /* C */
  230. /* CALL CKNR04 ( HANDLE, DESCR, NREC ) */
  231. /* DO I = 1, NREC */
  232. /* C */
  233. /* C Get the data records stored in the segment. */
  234. /* C */
  235. /* CALL CKGR04 ( HANDLE, DESCR, I, PKTDAT ) */
  236. /* C */
  237. /* C Print data packet contents. Print coverage interval */
  238. /* C midpoint & radii first. */
  239. /* C */
  240. /* WRITE (2,*) PKTDAT (1) */
  241. /* WRITE (2,*) PKTDAT (2) */
  242. /* C */
  243. /* C Decode numbers of coefficients. */
  244. /* C */
  245. /* CALL ZZCK4D2I ( PKTDAT(3), QAVSIZ, CK4PCD, NCOEF ) */
  246. /* C */
  247. /* C Print number of coefficients for Q0, Q1, Q2 and Q3. */
  248. /* C */
  249. /* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 1 ), NCOEF( 2 ) */
  250. /* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 3 ), NCOEF( 4 ) */
  251. /* C */
  252. /* C Print number coefficients for AV1, AV2 and AV3. */
  253. /* C */
  254. /* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 5 ), NCOEF( 6 ) */
  255. /* WRITE (2,FMT='(I2,6X,I2)') NCOEF( 7 ) */
  256. /* C */
  257. /* C Print Cheby coefficients. */
  258. /* C */
  259. /* LASTAD = 0 */
  260. /* DO K = 1, QAVSIZ */
  261. /* LASTAD = LASTAD + NCOEF( K ) */
  262. /* END DO */
  263. /* DO K = 4, LASTAD + 4 */
  264. /* WRITE (2,*) PKTDAT (K) */
  265. /* END DO */
  266. /* END DO */
  267. /* END IF */
  268. /* $ Restrictions */
  269. /* 1) The binary CK file containing the segment whose descriptor */
  270. /* was passed to this routine must be opened for read or write */
  271. /* access by either CKLPF, DAFOPR, or DAFOPW. */
  272. /* $ Literature_References */
  273. /* None. */
  274. /* $ Author_and_Institution */
  275. /* Y.K. Zaiko (JPL) */
  276. /* B.V. Semenov (JPL) */
  277. /* $ Version */
  278. /* - SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS) */
  279. /* -& */
  280. /* $ Index_Entries */
  281. /* number of CK type_4 records */
  282. /* -& */
  283. /* SPICELIB functions */
  284. /* Local parameters */
  285. /* Local variables */
  286. /* Standard SPICE error handling. */
  287. if (return_()) {
  288. return 0;
  289. } else {
  290. chkin_("CKNR04", (ftnlen)6);
  291. }
  292. /* Check whether our segment is of the type 4 by unpacking */
  293. /* descriptor and checking value of its third integer component. */
  294. dafus_(descr, &c__2, &c__6, dcd, icd);
  295. if (icd[2] != 4) {
  296. setmsg_("Data type of the segment should be 4: Passed descriptor sho"
  297. "ws type = #.", (ftnlen)71);
  298. errint_("#", &icd[2], (ftnlen)1);
  299. sigerr_("SPICE(CKWRONGDATATYPE)", (ftnlen)22);
  300. chkout_("CKNR04", (ftnlen)6);
  301. return 0;
  302. }
  303. /* The number of records (packets) can be obtained by a call to */
  304. /* SGMETA. This number is a meta item 12 (see sgparam.inc for */
  305. /* details.) */
  306. sgmeta_(handle, descr, &c__12, nrec);
  307. /* All done. */
  308. chkout_("CKNR04", (ftnlen)6);
  309. return 0;
  310. } /* cknr04_ */