geocentric_radius Function

public pure function geocentric_radius(a, b, lat) result(r)

The distance from the center of a celestial body (e.g., the Earth) to a point on the spheroid surface at a specified geodetic latitude.

Reference

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a

equatorial radius (km)

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

polar radius of point (km)

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

geodetic latitude of point (rad)

Return Value real(kind=wp)

distance from center of body to point (km)


Source Code

    pure function geocentric_radius(a,b,lat) result(r)

    implicit none

    real(wp),intent(in) :: a    !! equatorial radius (km)
    real(wp),intent(in) :: b    !! polar radius of point (km)
    real(wp),intent(in) :: lat  !! geodetic latitude of point (rad)
    real(wp)            :: r    !! distance from center of body to point (km)

    !local variables:
    real(wp) :: num,den,cl2,sl2,a2,b2

    if (a==zero .and. b==zero) then
        r = zero
    else
        cl2 = cos(lat)**2
        sl2 = sin(lat)**2
        a2  = a*a
        b2  = b*b
        num = cl2 * a2**2 + sl2 * b2**2
        den = cl2 * a2    + sl2 * b2
        r   = sqrt(num/den)
    end if

    end function geocentric_radius