dafopr |
Table of contents
ProcedureDAFOPR ( DAF, open for read ) ENTRY DAFOPR ( FNAME, HANDLE ) AbstractOpen a DAF for subsequent read requests. Required_ReadingDAF KeywordsDAF FILES DeclarationsCHARACTER*(*) FNAME INTEGER HANDLE Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- FNAME I Name of DAF to be opened. HANDLE O Handle assigned to DAF. Detailed_InputFNAME is the file name of a DAF to be opened for read access. Detailed_OutputHANDLE is the file handle associated with the file. This handle is used to identify the file in subsequent calls to other DAF routines. ParametersNone. Exceptions1) If the specified file has already been opened for read access, the handle already associated with the file is returned. 2) If the specified file has already been opened for write access, an error is signaled by a routine in the call tree of this routine. 3) If the specified file has already been opened by a non-DAF routine, an error is signaled by a routine in the call tree of this routine. 4) If the specified file cannot be opened without exceeding the maximum number of files, the error SPICE(DAFFTFULL) is signaled. 5) If the attempt to read the file's file record fails, the error SPICE(FILEREADFAILED) is signaled. 6) If the specified file is not a DAF file, an error is signaled by a routine in the call tree of this routine. 7) If no logical units are available, an error is signaled by a routine in the call tree of this routine. 8) If the file does not exist, an error is signaled by a routine in the call tree of this routine. 9) If an I/O error occurs in the process of opening the file, the error is signaled by a routine in the call tree of this routine. 10) If the file name is blank or otherwise inappropriate, an error is signaled by a routine in the call tree of this routine. 11) If the file was transferred improperly via FTP, an error is signaled by a routine in the call tree of this routine. 12) If the file utilizes a binary file format that is not currently supported on this platform, an error is signaled by a routine in the call tree of this routine. FilesSee argument FNAME. ParticularsMost DAFs require only read access. If you do not need to change the contents of a file, you should open it with DAFOPR. ExamplesThe numerical results shown for these examples may differ across platforms. The results depend on the SPICE kernels used as input, the compiler and supporting libraries, and the machine specific arithmetic implementation. 1) In the following code fragment, DAFOPR is used to open a file, which is then searched for DAFs containing data for a particular object. CALL DAFOPR ( FNAME, HANDLE ) CALL DAFBFS ( HANDLE ) CALL DAFFNA ( FOUND ) DO WHILE ( FOUND ) CALL DAFGS ( SUM ) CALL DAFUS ( SUM, ND, NI, DC, IC ) IF ( IC(1) .EQ. TARGET_OBJECT ) THEN . . END IF CALL DAFFNA ( FOUND ) END DO 2) Use a simple routine to output the double precision and integer values stored in an SPK's segments descriptors. This function opens a DAF for read, performs a forwards search for the DAF arrays, prints segments description 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 DAFOPR_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 forward search on the file. C CALL DAFBFS ( HANDLE ) C C Search until a DAF array is found. C CALL DAFFNA ( 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 DAFFNA ( 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: 1 0 1 2 641 310404 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 2 0 1 2 310405 423048 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 3 0 1 2 423049 567372 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 4 0 1 2 567373 628976 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 5 0 1 2 628977 674740 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 6 0 1 2 674741 715224 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 7 0 1 2 715225 750428 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 8 0 1 2 750429 785632 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 9 0 1 2 785633 820836 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 10 0 1 2 820837 944040 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 301 3 1 2 944041 1521324 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 399 3 1 2 1521325 2098608 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 199 1 1 2 2098609 2098620 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 299 2 1 2 2098621 2098632 Doubles: -3169195200.0000000 1696852800.0000000 Integers: 499 4 1 2 2098633 2098644 Note, the final entries in the integer array contain the segment start/end indexes. The output indicates the search proceeded from the start of the file (low value index) towards the end (high value index). Restrictions1) Files opened using this routine must be closed with DAFCLS. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) K.R. Gehringer (JPL) J.M. Lynch (JPL) H.A. Neilan (JPL) W.L. Taber (JPL) F.S. Turner (JPL) I.M. Underwood (JPL) E.D. Wright (JPL) VersionSPICELIB Version 8.1.2, 25-NOV-2021 (JDR) Edited the header to comply with NAIF standard. Updated code example with IMPLICIT NONE, and declarations of SUM variable and MAXSUM parameter. Corrected minor typos in header. SPICELIB Version 8.1.1, 10-OCT-2012 (EDW) Added a functional code example to the $Examples section. Removed the unneeded $Revisions section. Removed the obsolete Reference citation to "NAIF Document 167.0." Corrected ordering of header section. SPICELIB Version 8.1.0, 02-APR-2002 (FST) This routine was updated to accommodate changes to the handle manager interface. See DAFAH's Revision section for details. SPICELIB Version 8.0.0, 13-NOV-2001 (FST) This routine was updated to utilize the new handle manager software to manage binary file formats and consolidated I/O code. SPICELIB Version 7.0.4, 08-OCT-1999 (WLT) The environment lines were expanded so that the supported environments are now explicitly given. New environments are WIN-NT SPICELIB Version 7.0.3, 16-SEP-1999 (NJB) CSPICE environments were added. Some typos were corrected. SPICELIB Version 7.0.2, 28-JUL-1999 (WLT) The environment lines were expanded so that the supported environments are now explicitly given. New environments are PC-DIGITAL, SGI-O32 and SGI-N32. SPICELIB Version 7.0.1, 17-MAR-1999 (WLT) The environment lines were expanded so that the supported environments are now explicitly given. Previously, environments such as SUN-SUNOS and SUN-SOLARIS were implied by the environment label SUN. SPICELIB Version 5.0.0, 03-MAR-1999 (FST) This entry point now attempts to locate and validate the FTP validation string contained in the file record. See the $Revisions section under DAFAH for a discussion of the impact of the changes made for this version. SPICELIB Version 4.0.0, 27-SEP-1993 (KRG) This routine was modified to use a subroutine to obtain the architecture of the file rather than using hard coded values for comparison with the file ID word. This was done in order to isolate the code which checks to determine a file architecture and to make the identification of file types easier through a change to the file ID word. In particular, the changes to this routine support the change of the file ID word from 'NAIF/DAF' or 'NAIF/NIP' to 'DAF/xxxx' where 'xxxx' represents a four character mnemonic code for the type of data in the file. Removed the error SPICE(DAFNOIDWORD) as it was no longer relevant. Added the error SPICE(NOTADAFFILE) if this routine is called with a file that does not contain an ID word identifying the file as a DAF file. Changed the long error message when the error SPICE(NOTADAFFILE) is signaled to suggest that a common error is attempting to load a text version of the desired file rather than the binary version. SPICELIB Version 3.0.0, 25-FEB-1993 (JML) The INQUIRE statement that checks if the file is already open now also checks that the file exists. A new variable LUN is used for the logical unit number returned by GETLUN. The IF-THEN statements were reorganized to improve readability. A long error message is now set when the DAF id word is not recognized. Also, the file is closed when this error is signaled. IOSTAT is checked after the file record is read. The file name is checked to see if it is blank. The file name string that is passed to the FORTRAN OPEN and INQUIRE statements has been chopped at the last non-blank character. 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, 03-SEP-1991 (NJB) (WLT) This routine was updated so that it now keeps current the set of DAF handles returned by DAFHOF. Some error messages were changed so that they specify names of relevant DAFs. 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:08 2021