void spksfs_c ( SpiceInt body,
SpiceInt * handle,
SpiceDouble descr ,
SpiceChar * ident,
SpiceBoolean * found )
Search through loaded SPK files to find the highest-priority segment
applicable to the body and time specified.
Variable I/O Description
-------- --- --------------------------------------------------
body I Body ID.
et I Ephemeris time.
idlen I Length of output segment ID string.
handle O Handle of file containing the applicable segment.
descr O Descriptor of the applicable segment.
ident O Identifier of the applicable segment.
found O Indicates whether or not a segment was found.
SIDLEN P Maximum length of segment ID.
body is the NAIF integer code of an ephemeris object,
typically a solar system body.
et is a time, in seconds past the epoch J2000 TDB.
idlen is the allowed length of the output string. This length
must large enough to hold the output segment ID plus the
null terminator. SPK segment identifiers may contain up
to SIDLEN characters, excluding the null terminator.
handle is the handle of the SPK file containing a located
descr is the descriptor of a located SPK segment. `descr'
has length 5.
ident is the SPK segment identifier of a located SPK segment.
found indicates whether a requested segment was found or not.
The other output arguments are valid only if `found'
is set to SPICETRUE.
SIDLEN is the maximum number of characters in an SPK segment
identifier, excluding the null terminator.
SIDLEN is set to 40.
1) If an attempt is made to call spksfs_c when there aren't any
SPK files loaded, the error SPICE(NOLOADEDFILES) is signaled.
2) With the exception of Fortran READ errors, any errors
that occur while this routine attempts to extract segment
descriptors from loaded SPK files will be diagnosed and signaled
by routines in the call tree of this routine.
Note however that I/O errors occurring during reads of DAF
double precision records are NOT treated as SPICE errors
and are not signaled.
All SPK files loaded by furnsh_c or spklef_c are potential search
targets for spksfs_c.
This routine finds the highest-priority segment, in any loaded
SPK file, such that the segment provides data for the specified
body and epoch.
1) Find a segment for the Pluto barycenter, with coverage for
a specified epoch, in a JPL planetary SPK file.
This example uses the following meta-kernel:
This meta-kernel is intended to support operation of SPICE
example programs. The kernels shown here should not be
assumed to contain adequate or correct versions of data
required by SPICE-based user applications.
In order for an application to use this meta-kernel, the
kernels referenced here must be present in the user's
current working directory.
The names and contents of the kernels referenced
by this meta-kernel are as follows:
File name Contents
de421.bsp Planetary ephemeris
KERNELS_TO_LOAD = ( 'de421.bsp'
End of meta-kernel
Example code starts here.
#define ND 2
#define NI 6
#define DSCSIZ 5
#define SIDLEN1 41
SpiceChar segid [ SIDLEN1 ];
SpiceChar * reqtim;
SpiceDouble dc [ ND ];
SpiceDouble descr [ DSCSIZ ];
SpiceInt ic [ NI ];
Load a meta-kernel that specifies a planetary SPK file
and leapseconds kernel. The contents of this meta-kernel
are displayed above.
furnsh_c ( "spksfs.tm" );
Get the NAIF ID code for the Pluto system barycenter.
This is a built-in ID code, so something's seriously
wrong if we can't find the code.
bodn2c_c ( "PLUTO BARYCENTER", &idcode, &found );
if ( !found )
sigerr_c( "SPICE(BUG)" );
Pick a request time; convert to seconds past J2000 TDB.
reqtim = "2011 FEB 18 UTC";
str2et_c ( reqtim, &et );
Find a loaded segment for the specified body and time.
spksfs_c ( idcode, et, SIDLEN1, &handle, descr, segid, &found );
if ( !found )
printf ( "No descriptor was found for ID %d at "
Display the DAF file handle.
printf ( "\n"
"DAF handle: %d\n"
Display the segment ID.
Unpack the descriptor. Display the contents.
dafus_c ( descr, ND, NI, dc, ic );
printf ( "Segment found.\n"
" Segment ID: %s\n"
" Body ID code: %d\n"
" Center ID code: %d\n"
" Frame ID code: %d\n"
" SPK data type: %d\n"
" Start time (TDB): %24.17e\n"
" Stop time (TDB): %24.17e\n",
return ( 0 );
When executed on a PC/Linux/gcc platform, this program
produced the following output:
DAF handle: 1
Segment ID: DE-0421LE-0421
Body ID code: 9
Center ID code: 0
Frame ID code: 1
SPK data type: 2
Start time (TDB): -3.16919520000000000e+09
Stop time (TDB): 1.69685280000000000e+09
1) If a Fortran I/O error occurs while this routine searches a
loaded SPK file, the internal state of SPK segment and file
selection routines, which are all entry points in the f2c'd
version for the Fortran routine SPKBSR, may be corrupted.
SPK Required Reading.
N.J. Bachman (JPL)
R.E. Thurman (JPL)
-CSPICE Version 1.0.1, 12-JUL-2016 (EDW)
Edit to example program to use "%d" with explicit casts
to int for printing SpiceInts with printf.
-CSPICE Version 1.0.0, 05-OCT-2012 (NJB) (RET)
select spk file and segment