initialize_globals Subroutine

private subroutine initialize_globals(me, et0, dt, etf)

initialize the earth and sun ephemeris.

Type Bound

jpl_ephemeris_splined

Arguments

Type IntentOptional Attributes Name
class(jpl_ephemeris_splined), intent(inout) :: me
real(kind=wp), intent(in) :: et0

initial ephemeris time [sec]

real(kind=wp), intent(in) :: dt

ephemeris time step [sec]

real(kind=wp), intent(in) :: etf

final ephemeris time [sec]


Calls

proc~~initialize_globals~~CallsGraph proc~initialize_globals jpl_ephemeris_splined%initialize_globals proc~destroy_jpl_ephemeris_splined jpl_ephemeris_splined%destroy_jpl_ephemeris_splined proc~initialize_globals->proc~destroy_jpl_ephemeris_splined proc~populate_body_eph body_eph%populate_body_eph proc~initialize_globals->proc~populate_body_eph proc~spline_body_eph body_eph%spline_body_eph proc~initialize_globals->proc~spline_body_eph proc~destroy_body_eph_interface body_eph_interface%destroy_body_eph_interface proc~destroy_jpl_ephemeris_splined->proc~destroy_body_eph_interface get_rv get_rv proc~populate_body_eph->get_rv db1ink db1ink proc~spline_body_eph->db1ink proc~destroy_body_eph body_eph%destroy_body_eph proc~destroy_body_eph_interface->proc~destroy_body_eph

Called by

proc~~initialize_globals~~CalledByGraph proc~initialize_globals jpl_ephemeris_splined%initialize_globals proc~initialize_splinded_ephemeris jpl_ephemeris_splined%initialize_splinded_ephemeris proc~initialize_splinded_ephemeris->proc~initialize_globals

Source Code

    subroutine initialize_globals(me, et0, dt, etf)

        !! initialize the earth and sun ephemeris.

        class(jpl_ephemeris_splined),intent(inout) :: me
        real(wp),intent(in) :: et0 !! initial ephemeris time [sec]
        real(wp),intent(in) :: dt  !! ephemeris time step [sec]
        real(wp),intent(in) :: etf !! final ephemeris time [sec]

        integer :: i !! counter
        real(wp) :: et !! ephemeris time
        integer :: nx !! number of points
        real(wp),dimension(:),allocatable :: et_vec
        integer :: iflag

        ! write(*,*) 'initialize_globals...'
        ! write(*,*) '  et0 = ', et0
        ! write(*,*) '  dt  = ', dt
        ! write(*,*) '  etf = ', etf

        call me%destroy()
        call earth_eph%destroy()
        call sun_eph%destroy()
        call ssb_eph%destroy()
        call jupiter_eph%destroy()

        ! first, count the number of points and allocate the arrays:
        nx = 0
        et = et0
        do
            if (et>etf) exit
            nx = nx + 1
            et = et + dt
        end do
        call earth_eph%allocate(nx, kx)
        call sun_eph%allocate(nx, kx)
        call ssb_eph%allocate(nx, kx)
        call jupiter_eph%allocate(nx, kx)
        allocate(et_vec(nx))

        ! function calls from et0 to etf:
        i = 0 ! index in the arrays
        et = et0
        do
            if (et>etf) exit
            i = i + 1
            et = et + dt
            et_vec(i) = et
            call earth_eph%populate  (me%jpl_ephemeris,et,body_earth,  body_moon,i)
            call sun_eph%populate    (me%jpl_ephemeris,et,body_sun,    body_moon,i)
            call ssb_eph%populate    (me%jpl_ephemeris,et,body_ssb,    body_moon,i)
            call jupiter_eph%populate(me%jpl_ephemeris,et,body_jupiter,body_moon,i)
        end do

        ! create the splines (one for each coordinate):
        do i = 1, 6
            call earth_eph%spline(et_vec,i)
            call sun_eph%spline  (et_vec,i)
            call ssb_eph%spline  (et_vec,i)
            call jupiter_eph%spline(et_vec,i)
        end do
        deallocate(earth_eph%f) ! don't need these anymore
        deallocate(sun_eph%f)
        deallocate(ssb_eph%f)
        deallocate(jupiter_eph%f)

    end subroutine initialize_globals