latlon2xyz Subroutine

private subroutine latlon2xyz(p, e)

Arguments

Type IntentOptional Attributes Name
real(kind=ESMF_KIND_R8), intent(in) :: p(2)
real(kind=ESMF_KIND_R8), intent(out) :: e(3)

Source Code

 subroutine latlon2xyz(p, e)
!
! Routine to map (lon, lat) to (x,y,z)
!
 real(ESMF_KIND_R8), intent(in) :: p(2)
 real(ESMF_KIND_R8), intent(out):: e(3)

 integer n
 real(ESMF_KIND_R8) :: q(2)
 real(ESMF_KIND_R8) :: e1, e2, e3

    do n=1,2
       q(n) = p(n)
    enddo

    e1 = cos(q(2)) * cos(q(1))
    e2 = cos(q(2)) * sin(q(1))
    e3 = sin(q(2))
!-----------------------------------
! Truncate to the desired precision:
!-----------------------------------
    e(1) = e1
    e(2) = e2
    e(3) = e3

 end subroutine latlon2xyz