dafbbs |
Table of contents
ProcedureDAFBBS ( DAF, begin backward search ) ENTRY DAFBBS ( HANDLE ) AbstractBegin a backward search for arrays in a DAF. Required_ReadingDAF KeywordsFILES DeclarationsINTEGER HANDLE Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- HANDLE I Handle of DAF to be searched. Detailed_InputHANDLE is the handle of a DAF on which a backward search is to be conducted. Detailed_OutputNone. ParametersNone. Exceptions1) If the input handle is invalid, an error is signaled by a routine in the call tree of this routine. 2) If the last summary record of the DAF file cannot be read, the error SPICE(RECORDNOTFOUND) is signaled. FilesSee argument HANDLE. ParticularsSee DAFFA. Examples1) See DAFFA. 2) Create a simple routine to output the double precision and integer values stored in an SPK's segment's descriptors. This program opens a DAF for read, performs a backward search for the DAF arrays, prints the segment descriptor for each array found, then closes the DAF. Use the SPK kernel below as input DAF file for the program. de421.bsp Example code begins here. PROGRAM DAFBBS_EX1 IMPLICIT NONE C C Define the summary parameters appropriate C for an SPK file. C INTEGER MAXSUM PARAMETER ( MAXSUM = 125 ) INTEGER ND PARAMETER ( ND = 2 ) INTEGER NI PARAMETER ( NI = 6 ) C C Local variables C CHARACTER*(32) KERNEL DOUBLE PRECISION DC ( ND ) DOUBLE PRECISION SUM( MAXSUM ) INTEGER HANDLE INTEGER IC( NI ) LOGICAL FOUND C C Open a DAF for read. Return a HANDLE referring to the C file. C KERNEL = 'de421.bsp' CALL DAFOPR ( KERNEL, HANDLE ) C C Begin a backward search on the file. C CALL DAFBBS ( HANDLE ) C C Search until a DAF array is found. C CALL DAFFPA ( FOUND ) C C Loop while the search finds subsequent DAF arrays. C DO WHILE ( FOUND ) CALL DAFGS ( SUM ) CALL DAFUS ( SUM, ND, NI, DC, IC ) WRITE(*,*) 'Doubles:', DC(1:ND) WRITE(*, FMT='(A,6I9)' ) 'Integers:', IC(1:NI) C C Check for another segment. C CALL DAFFPA ( FOUND ) END DO C C Safely close the DAF. C CALL DAFCLS ( HANDLE ) END When this program was executed on a Mac/Intel/gfortran/64-bit platform, the output was: Doubles: -3169195200.0000000 1696852800.0000000 Integers: 499 4 1 2 2098633 2098644 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 299 2 1 2 2098621 2098632 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 199 1 1 2 2098609 2098620 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 399 3 1 2 1521325 2098608 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 301 3 1 2 944041 1521324 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 10 0 1 2 820837 944040 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 9 0 1 2 785633 820836 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 8 0 1 2 750429 785632 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 7 0 1 2 715225 750428 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 6 0 1 2 674741 715224 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 5 0 1 2 628977 674740 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 4 0 1 2 567373 628976 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 3 0 1 2 423049 567372 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 2 0 1 2 310405 423048 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 1 0 1 2 641 310404 Note, the final entries in the integer arrays record the segment start/end indexes. The output indicates the search proceeded from the end of the file (high value index) towards the beginning (low value index). Restrictions1) Calls that do or may change DAF addresses of DAF summaries, names, or data of a given DAF file should not be made during a search of that file initiated by either DAFBFS or DAFBBS. No such changes should be made between the start of a search and calls to any entry point that reads or writes to the summary of the "current array" found by that search, or that returns a "found" flag indicating whether the current array exists. Changing the size of the comment area while a search is in progress can invalidate record numbers stored in local data structures of this routine. This can cause corrupted array summaries and names to be returned upon read access and file corruption to occur upon write access. Adding arrays (aka "segments") while either a forward or backward search is in progress can cause the search to miss the new segments. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) H.A. Neilan (JPL) W.L. Taber (JPL) I.M. Underwood (JPL) E.D. Wright (JPL) VersionSPICELIB Version 2.1.1, 26-OCT-2021 (JDR) (NJB) Edited the header to comply with NAIF standard. Added undeclared variables to code example. Updated $Restrictions section. SPICELIB Version 2.1.0, 10-OCT-2012 (EDW) Added a functional code example to the $Examples section. Added check on value of "found" boolean returned from DAFGSR calls. Failure to check this value can cause an infinite loop during segment searches on damaged SPKs. Eliminated unneeded $Revisions section. Removed the obsolete Reference citation to "NAIF Document 167.0." SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) Comment section for permuted index source lines was added following the header. SPICELIB Version 2.0.0, 04-SEP-1991 (NJB) (WLT) Updated to support simultaneous searches of multiple DAFs. This routine now makes the DAF designated by HANDLE the current DAF---the one at the head of the active list. All saved state variables used by this routine are now part of the state table, or its associated set of pointers. Also, the $Exceptions section was filled out. SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) Literature references added to the header. SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) |
Fri Dec 31 18:36:07 2021