compute_total_h Function

private function compute_total_h(h_layer, areaT, nghost) result(total)

Σ h_layer(i,j,k)·areaT(i,j) over PHYSICAL cells (ghosts excluded). Explicit OpenACC reduction — the sum() intrinsic on a present-mapped array silently runs host-side under NVHPC non-managed mode and returns the stale host shadow.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: h_layer(:,:,:)
real(kind=wp), intent(in) :: areaT(:,:)
integer, intent(in) :: nghost

Return Value real(kind=wp)


Called by

proc~~compute_total_h~~CalledByGraph proc~compute_total_h compute_total_h proc~ocean_console_stats_report ocean_console_stats_report proc~ocean_console_stats_report->proc~compute_total_h proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~ocean_console_stats_report proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: acc
integer, private :: i
integer, private :: i_hi
integer, private :: i_lo
integer, private :: j
integer, private :: j_hi
integer, private :: j_lo
integer, private :: k
integer, private :: nx
integer, private :: ny
integer, private :: nz

Source Code

   function compute_total_h(h_layer, areaT, nghost) result(total)
      !! `Σ h_layer(i,j,k)·areaT(i,j)` over PHYSICAL cells (ghosts
      !! excluded). Explicit OpenACC reduction — the `sum()` intrinsic on
      !! a present-mapped array silently runs host-side under NVHPC
      !! non-managed mode and returns the stale host shadow.
      real(wp), intent(in) :: h_layer(:, :, :)
      real(wp), intent(in) :: areaT(:, :)
      integer, intent(in) :: nghost
      real(wp) :: total
      real(wp) :: acc
      integer :: i, j, k, nx, ny, nz, i_lo, i_hi, j_lo, j_hi
      nx = min(size(h_layer, 1), size(areaT, 1))
      ny = min(size(h_layer, 2), size(areaT, 2))
      nz = size(h_layer, 3)
      i_lo = nghost + 1
      i_hi = nx - nghost
      j_lo = nghost + 1
      j_hi = ny - nghost
      acc = 0.0_wp
      !$acc parallel loop collapse(3) reduction(+:acc) present(h_layer, areaT)
      do k = 1, nz
         do j = j_lo, j_hi
            do i = i_lo, i_hi
               acc = acc + h_layer(i, j, k)*areaT(i, j)
            end do
         end do
      end do
      total = acc
   end function compute_total_h