2D twin of chksum_stats_3d (BT work fields).
| Type | Intent | Optional | 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. |
| 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 |
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