Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
dafcls

Table of contents
Procedure
Abstract
Required_Reading
Keywords
Declarations
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version

Procedure

     DAFCLS ( DAF, close )

     ENTRY DAFCLS ( HANDLE )

Abstract

     Close the DAF associated with a given handle.

Required_Reading

     DAF

Keywords

     DAF
     FILES

Declarations

    INTEGER               HANDLE

Brief_I/O

     VARIABLE  I/O  DESCRIPTION
     --------  ---  --------------------------------------------------
     HANDLE     I   Handle of DAF to be closed.

Detailed_Input

     HANDLE   is the file handle of a previously opened DAF file.

Detailed_Output

     None.

Parameters

     None.

Exceptions

     1)  If the specified handle does not belong to a DAF
         that is currently open, nothing happens.

     2)  If this routine is used to close a HANDLE not associated
         with a DAF, an error is signaled by a routine in the call tree
         of this routine.

Files

     None.

Particulars

     Because DAFAH and its entry points must keep track of what
     files are open at any given time, it is important that DAF
     files be closed only with DAFCLS, to prevent the remaining
     DAF routines from failing, sometimes mysteriously.

     Note that when a file is opened more than once for read access,
     DAFOPR returns the same handle each time it is re-opened.
     Each time the file is closed, DAFCLS checks to see if any other
     claims on the file are still active before physically closing
     the file.

Examples

     The 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, the arrays in a file are
        examined in order to determine whether the file contains
        any arrays whose names begin with the word TEST.
        The complete names for these arrays are printed to
        the screen. The file is closed at the end of the search.

           CALL DAFOPR ( FNAME, HANDLE )
           CALL DAFBFS ( HANDLE )
           CALL DAFFNA ( FOUND  )

           DO WHILE ( FOUND )
              CALL DAFGN ( NAME )

              IF ( NAME(1:5) .EQ. 'TEST ' ) THEN
                 WRITE (*,*) NAME
              END IF

              CALL DAFFNA ( FOUND )
           END DO

           CALL DAFCLS ( HANDLE )

        Note that if the file has been opened already by a DAF routine
        at some other place in the calling program, it remains open.
        This makes it possible to examine files that have been opened
        for use by other modules without interfering with the operation
        of those routines.


     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 DAFCLS_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).

Restrictions

     None.

Literature_References

     None.

Author_and_Institution

     N.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)

Version

    SPICELIB 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 2.0.3, 29-SEP-1993 (KRG)

        Removed references to specific DAF file open routines in the
        $Detailed_Input section of the header. This was done in order
        to minimize documentation changes if these open routines ever
        change.

    SPICELIB Version 2.0.2, 25-FEB-1993 (JML)

        A minor error in the $Particulars section of the header was
        corrected. It formerly stated that a file could be open more
        than once for read or write access instead of just read access.

    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.

        Upgraded to support file handle checking routines
        DAFHOF and DAFSIH. DAFCLS now initializes the file
        handle list if necessary, and removes from the list
        the handles of files it closes.

    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