subroutine dyn_mpas_compute_unit_vector(self)
! Module(s) from MPAS.
use mpas_derived_types, only: mpas_pool_type
use mpas_vector_operations, only: mpas_initialize_vectors
class(mpas_dynamical_core_type), intent(in) :: self
character(*), parameter :: subname = 'dyn_mpas_subdriver::dyn_mpas_compute_unit_vector'
integer :: i
integer, pointer :: ncells
real(rkind), pointer :: latcell(:), loncell(:)
real(rkind), pointer :: east(:, :), north(:, :)
type(mpas_pool_type), pointer :: mpas_pool
call self % debug_print(log_level_debug, subname // ' entered')
nullify(ncells)
nullify(latcell, loncell)
nullify(east, north)
nullify(mpas_pool)
! Input.
call self % get_variable_pointer(ncells, 'dim', 'nCells')
call self % get_variable_pointer(latcell, 'mesh', 'latCell')
call self % get_variable_pointer(loncell, 'mesh', 'lonCell')
! Output.
call self % get_variable_pointer(east, 'mesh', 'east')
call self % get_variable_pointer(north, 'mesh', 'north')
call self % debug_print(log_level_info, 'Computing unit vectors')
do i = 1, ncells
east(1, i) = -sin(loncell(i))
east(2, i) = cos(loncell(i))
east(3, i) = 0.0_rkind
! `r3_normalize` has been inlined below.
east(1:3, i) = east(1:3, i) / sqrt(sum(east(1:3, i) * east(1:3, i)))
north(1, i) = -cos(loncell(i)) * sin(latcell(i))
north(2, i) = -sin(loncell(i)) * sin(latcell(i))
north(3, i) = cos(latcell(i))
! `r3_normalize` has been inlined below.
north(1:3, i) = north(1:3, i) / sqrt(sum(north(1:3, i) * north(1:3, i)))
end do
nullify(ncells)
nullify(latcell, loncell)
nullify(east, north)
call self % get_pool_pointer(mpas_pool, 'mesh')
call mpas_initialize_vectors(mpas_pool)
nullify(mpas_pool)
call self % debug_print(log_level_debug, subname // ' completed')
end subroutine dyn_mpas_compute_unit_vector