Table of contents
CSPICE_UNLOAD unloads a SPICE kernel file (of any type)
from IDL.
Given:
file the name of a file to unload.
help, file
STRING = Scalar
This file should be one loaded through the interface
cspice_furnsh. If the file is not on the list of loaded kernels
no action is taken.
Note that if `file' is a meta-text kernel, all of
the files loaded as a result of loading the meta-text
kernel will be unloaded.
the call:
cspice_unload, file
removes the file and all associated data from the kernel sub-system. If
`file' is a meta-text kernel, the sub-system unloads all files listed in
the kernel. See -Particulars for important information on this routine's
handling of variables NOT set through cspice_furnsh.
None.
Any numerical results shown for these examples may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Load a meta-kernel with a PCK, an LSK and an SPK, and
separately, a text kernel and a binary PCK. Loop over the
loaded kernels, outputting file information for each of
them.
Then unload the text kernels, check that they have been
unloaded, and finally unload the meta-kernel.
Use the meta-kernel shown below to load the required SPICE
kernels.
KPL/MK
File name: unload_ex1.tm
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
pck00009.tpc Planet orientation and
radii
naif0012.tls Leapseconds
\begindata
KERNELS_TO_LOAD = ( 'de421.bsp',
'naif0012.tls',
'pck00009.tpc' )
\begintext
End of meta-kernel
Use the PCK kernel below as the binary PCK required for the
example.
earth_latest_high_prec.bpc
Use the FK kernel below as the text kernel required for the
example.
RSSD0002.TF
Example code begins here.
PRO unload_ex1
;;
;; Load several kernel files.
;;
cspice_furnsh, 'unload_ex1.tm'
cspice_furnsh, 'RSSD0002.TF'
cspice_furnsh, 'earth_latest_high_prec.bpc'
;;
;; Count the number of loaded kernel files.
;;
cspice_ktotal, 'ALL', count
print, format='(A,I2)', 'The total number of kernels after' + $
' final cspice_furnsh: ', count
print, ''
;;
;; Unload the text kernels.
;;
cspice_ktotal, 'TEXT', count
print, ''
print, format='(A,I2,A)', 'Unloading', count, ' text kernels...'
print, ''
while ( count gt 0 ) do begin
cspice_kdata, 0, 'TEXT', file, filtyp, srcfil, handle, found
;;
;; If the kernel is found in the pool, unload it.
;;
if ( found ) then begin
cspice_unload, file
;;
;; Check if the file has been unloaded.
;;
cspice_kinfo, file, filtyp, srcfil, handle, found
if ( found ) then begin
print, FORMAT='(A,$)', ' Error'
endif else begin
print, FORMAT='(A,$)', ' Success'
endelse
print, ' unloading ', file
;;
;; Something is not working. Inform NAIF.
;;
endif else begin
print, ' ERROR: No kernel found but cspice_ktotal returns ', $
count
endelse
;;
;; Check if we have more text kernels to unload from
;; the kernel pool. Note that unloading a text kernel
;; or meta-kernel implies that the kernel pool is
;; cleared, and any kernel[s - 1] that were not to be
;; unloaded are re-loaded. Therefore the `count' value
;; changes, and the indexing of the files within the
;; kernel pool too.
;;
cspice_ktotal, 'TEXT', count
endwhile
cspice_ktotal, 'ALL', count
print, ' '
print, format='(A,I2)', 'The total number of kernels after' + $
' cspice_unload calls: ', count
;;
;; Clear the KEEPER system, retrieve the number of loaded
;; after the clear.
;;
cspice_unload, 'unload_ex1.tm'
cspice_ktotal, 'ALL', count
print, ' '
print, format='(A,I2)', 'The total number of kernels after' + $
' final cspice_unload: ', count
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
The total number of kernels after final cspice_furnsh: 6
Unloading 3 text kernels...
Success unloading naif0012.tls
Success unloading pck00009.tpc
Success unloading RSSD0002.TF
The total number of kernels after cspice_unload calls: 3
The total number of kernels after final cspice_unload: 1
2) Redo the previous example, using the cspice_unload capability
of unloading kernels by listing them in an array of strings.
Use the meta-kernel and kernels of Example 1.
Example code begins here.
PRO unload_ex2
;;
;; Load several kernel files.
;;
cspice_furnsh, 'unload_ex1.tm'
cspice_furnsh, 'RSSD0002.TF'
cspice_furnsh, 'earth_latest_high_prec.bpc'
;;
;; Count the number of loaded kernel files.
;;
cspice_ktotal, 'ALL', count
print, format='(A,I2)', 'The total number of kernels after' + $
' final cspice_furnsh: ', count
print, ''
;;
;; Unload the text kernels.
;;
cspice_ktotal, 'TEXT', count
print, ''
print, format='(A,I2,A)', 'Unloading', count, ' text kernels...'
print, ''
;;
;; Create an empty array of strings, to hold the
;; names of the kernels to unload.
;;
kernels = STRARR(count)
for i = 0, count-1 do begin
cspice_kdata, i, 'TEXT', file, filtyp, srcfil, handle, found
;;
;; If the kernel is found in the pool, add it to the array.
;;
if ( found ) then begin
kernels[i] = file
print, ' ', file, ' will be unloaded.'
;;
;; Something is not working. Inform NAIF.
;;
endif else begin
print, ' ERROR: No kernel found with index ', i
endelse
endfor
;;
;; Unload the kernels present in the `kernels' variable, and
;; retrieve the number of remaining loaded kernels.
;;
cspice_unload, kernels
cspice_ktotal, 'ALL', count
print, ' '
print, format='(A,I2)', 'The total number of kernels after' + $
' cspice_unload calls: ', count
;;
;; Clear the KEEPER system, retrieve the number of loaded
;; after the clear.
;;
cspice_unload, 'unload_ex1.tm'
cspice_ktotal, 'ALL', count
print, ' '
print, format='(A,I2)', 'The total number of kernels after' + $
' final cspice_unload: ', count
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
The total number of kernels after final cspice_furnsh: 6
Unloading 3 text kernels...
naif0012.tls will be unloaded.
pck00009.tpc will be unloaded.
RSSD0002.TF will be unloaded.
The total number of kernels after cspice_unload calls: 3
The total number of kernels after final cspice_unload: 1
The call
cspice_unload, file
has the effect of "erasing" the last previous call:
cspice_furnsh, file
This interface allows you to unload binary and text kernels.
Moreover, if you used a meta-text kernel to set up your
working environment, you can unload all of the kernels loaded
through the meta-kernel by unloading the meta-kernel.
Unloading Text Kernels or Meta-Kernels
--------------------------------------
Part of the action of unloading text (or meta-text kernels) is
clearing the kernel pool and re-loading any kernels that were not in
the specified set of kernels to unload. Since loading of text
kernels is not a very fast process, unloading text kernels takes
considerably longer than unloading binary kernels. Moreover, since
the kernel pool is cleared, any kernel pool variables you have set
from your program by using one of the interfaces cspice_pcpool,
cspice_pdpool, cspice_pipool, or cspice_lmpool will be removed from the
kernel pool. For this reason, if you plan to use this feature in your
program, together with one of the routines specified above, you will need
to take special precautions to make sure kernel pool variables required
by your program do not inadvertently disappear.
1) If the specified kernel is not on the list of loaded kernels
no action is taken.
2) If the input argument `file' is undefined, an error is
signaled by the IDL error handling system.
3) If the input argument `file' is not of the expected type, or
it does not have the expected dimensions and size, an error is
signaled by the Icy interface.
None.
1) See the note regarding the unloading of Text and meta-text
Kernels.
ICY.REQ
KERNEL.REQ
PCK.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.1.1, 17-JUN-2021 (JDR)
Edited the header to comply with NAIF standard.
Extended "file" argument description and replaced the note in -I/O
with a reference to -Particulars section. Created complete code example
from existing code fragments.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added argument's type and size information in the -I/O section.
-Icy Version 1.1.0, 07-JUN-2007 (EDW)
Example section showed a cspice_furnsh call instead of the
cspice_unload.
Added capability to process vector 'file' input.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
Unload a SPICE kernel
|