Speeding up SPICE

Spices_in_an_Indian_marketThe SPICE Toolkit software is an excellent package of very well-written and well-documented routines for a variety of astrodynamics applications.  It is produced by NASA’s Navigation and Ancillary Information Facility (NAIF).  Versions are available for Fortran 77, C, IDL, and Matlab.

To speed up the execution of SPICE-based programs, there are a few things you can do:

  • For the Fortran SPICELIB, recompile it with optimization enabled (say, -O2). The default library released by NAIF is not compiled with optimization.
  • Turn off the SPICE traceback system (call TRCOFF()). If you are using a compiler that has a built-in stack trace routine (for example TRACEBACKQQ in the Intel compiler), just include a call to it in the SPICE BYEBYE.F routine.  That will give you a stack trace for any fatal errors.
  • Converting a non-native binary PCK to native form will also speed up data access somewhat.
  • Calls to ephemeris routines where the target and observer bodies are input as strings will be slightly slower than the ones where the inputs are the NAIF ID codes (which are integers).  For example, for the geometric state (position and velocity) of one body relative to another, use SPKGEO instead of SPKEZR.  Also, if all you require is position and not velocity, use SPKGPS instead of SPKGEO, since it will be a bit faster.

Also note that for applications only requiring the ephemerides of the solar system major bodies, there is an older code from JPL (PLEPH) which is simpler and faster than SPICE, but uses a different format for the ephemeris files.

Tagged with: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*