subroutine test_cartesian_to_spherical_Z(this)
class (ESMF_TestMethod), intent(inout) :: this
type (LatLonGridFactory) :: factory
real, allocatable :: u(:,:)
real, allocatable :: v(:,:)
real, allocatable :: xyz(:,:,:,:)
real, allocatable :: longitudes(:)
real, allocatable :: latitudes(:)
integer, parameter :: IM=12, JM=6
type (ESMF_Grid) :: grid
integer :: status
_UNUSED_DUMMY(this)
factory = LatLonGridFactory(im_world=IM, jm_world=JM, lm=1, nx=1, ny=1, pole='PE', dateline='GC')
grid = factory%make_grid()
allocate(u(IM,JM))
allocate(v(IM,JM))
allocate(xyz(3,1,IM,JM))
XYZ(1,1,:,:) = 0
XYZ(2,1,:,:) = 0
XYZ(3,1,:,:) = 1
call factory%cartesian_to_spherical(xyz, u, v, basis='north-south',rc=status)
@assertEqual(0, status)
! Note: longitudes return as REAL64.
longitudes = real(factory%get_longitudes())
latitudes = real(factory%get_latitudes())
do j = 1, JM
@assertEqual(0., u(:,j), 10*epsilon(1.))
@assertEqual(cos(latitudes(j)), v(:,j), 10*epsilon(1.))
end do
end subroutine test_cartesian_to_spherical_Z