chksum_stats_2d Subroutine

public subroutine chksum_stats_2d(arr, nx, ny, stats, i0, i1, j0, j1)

Uses

  • proc~~chksum_stats_2d~~UsesGraph proc~chksum_stats_2d chksum_stats_2d ieee_arithmetic ieee_arithmetic proc~chksum_stats_2d->ieee_arithmetic

2D twin of chksum_stats_3d (BT work fields).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: arr(nx,ny)
integer, intent(in) :: nx
integer, intent(in) :: ny
type(chksum_stats_t), intent(out) :: stats
integer, intent(in), optional :: i0

Optional index window (default: the whole array) — see the 3D twin.

integer, intent(in), optional :: i1

Optional index window (default: the whole array) — see the 3D twin.

integer, intent(in), optional :: j0

Optional index window (default: the whole array) — see the 3D twin.

integer, intent(in), optional :: j1

Optional index window (default: the whole array) — see the 3D twin.


Called by

proc~~chksum_stats_2d~~CalledByGraph proc~chksum_stats_2d chksum_stats_2d proc~rdb_debug_chksum_2d rdb_debug_chksum_2d proc~rdb_debug_chksum_2d->proc~chksum_stats_2d interface~rdb_debug_chksum rdb_debug_chksum interface~rdb_debug_chksum->proc~rdb_debug_chksum_2d proc~chksum_bt chksum_bt proc~chksum_bt->interface~rdb_debug_chksum proc~chksum_state chksum_state proc~chksum_state->interface~rdb_debug_chksum proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~chksum_state proc~run_stage_split run_stage_split proc~ocean_dyn_step_split->proc~run_stage_split proc~run_stage_split->proc~chksum_bt proc~run_stage_split->proc~chksum_state proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step_split

Variables

Type Visibility Attributes Name Initial
integer(kind=int64), private :: bsum
integer, private :: i
integer, private :: ia
integer, private :: ib
integer, private :: j
integer, private :: ja
integer, private :: jb
real(kind=wp), private :: mn
real(kind=wp), private :: mx
integer, private :: nf
real(kind=wp), private :: s

Source Code

   subroutine chksum_stats_2d(arr, nx, ny, stats, i0, i1, j0, j1)
      !! 2D twin of chksum_stats_3d (BT work fields).
      use, intrinsic :: ieee_arithmetic, only: ieee_is_finite
      integer, intent(in) :: nx, ny
      real(wp), intent(in) :: arr(nx, ny)
      type(chksum_stats_t), intent(out) :: stats
      integer, intent(in), optional :: i0, i1, j0, j1
         !! Optional index window (default: the whole array) — see the 3D twin.
      real(wp) :: s, mn, mx
      integer(int64) :: bsum
      integer :: nf, i, j, ia, ib, ja, jb
      ia = 1
      ib = nx
      ja = 1
      jb = ny
      if (present(i0)) ia = i0
      if (present(i1)) ib = i1
      if (present(j0)) ja = j0
      if (present(j1)) jb = j1

      s = 0.0_wp
      mn = huge(1.0_wp)
      mx = -huge(1.0_wp)
      nf = 0
      bsum = 0_int64
      ! GPU-offload risk on transfer/popcnt in a device region — see the
      ! matching note in chksum_stats_3d for the host-fallback recipe.
      !$acc parallel loop collapse(2) reduction(+:s, nf, bsum) &
      !$acc   reduction(min:mn) reduction(max:mx)
      do j = ja, jb
         do i = ia, ib
            s = s + arr(i, j)
            mn = min(mn, arr(i, j))
            mx = max(mx, arr(i, j))
            if (.not. ieee_is_finite(arr(i, j))) nf = nf + 1
            bsum = bsum + int(popcnt(transfer(arr(i, j), 0_int64)), int64)
         end do
      end do
      stats%total = s
      stats%minv = mn
      stats%maxv = mx
      stats%nonfin = nf
      stats%bits = bsum
   end subroutine chksum_stats_2d