spice_id_to_old_id Function

private pure function spice_id_to_old_id(spice_id) result(old_id)

Convert the NAIF SPICE ID code to the old one used by the JPL ephemeris. Returns 0 if the body was not found.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: spice_id

the ID code used by SPICE

Return Value integer

the ID code used by this module (old JPL ephemeris code)


Called by

proc~~spice_id_to_old_id~~CalledByGraph proc~spice_id_to_old_id jpl_ephemeris_module::spice_id_to_old_id proc~get_rv_from_jpl_ephemeris jpl_ephemeris_module::jpl_ephemeris%get_rv_from_jpl_ephemeris proc~get_rv_from_jpl_ephemeris->proc~spice_id_to_old_id

Source Code

    pure function spice_id_to_old_id(spice_id) result(old_id)

    implicit none

    integer,intent(in) :: spice_id !! the ID code used by SPICE
    integer            :: old_id   !! the ID code used by this module (old JPL ephemeris code)

    integer :: i !! counter

    !>
    !  The index of this array is the old ID code. The value is the new code.
    !  See: [NAIF Integer ID codes](http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/req/naif_ids.html)
    integer,parameter,dimension(13) :: new_ids = &
        [   199,&  ! mercury
            299,&  ! venus
            399,&  ! earth
            499,&  ! mars
            599,&  ! jupiter
            699,&  ! saturn
            799,&  ! uranus
            899,&  ! neptune
            999,&  ! pluto
            301,&  ! moon
            10, &  ! sun
            0,  &  ! solar-system barycenter
            3   ]  ! earth-moon barycenter

    !just a simple search of the list:
    ! [small enough that bisection search probably not worth it]
    do i=1,size(new_ids)
        if (new_ids(i)==spice_id) then
            old_id = i
            return
        end if
    end do

    !not found:
    old_id = 0

    end function spice_id_to_old_id