scan_vanished_one_impl Subroutine

private pure subroutine scan_vanished_one_impl(nx, ny, nz, h_layer, hTr, n_bad, worst)

Flat-impl of the I1′ scan for ONE tracer. Per column: find the topmost live layer, then walk DOWN carrying the nearest live layer above — the donor map rdb_vl_merge_content / rdb_vl_column_conc use — and test each filler against its donor’s hTr/h.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
real(kind=wp), intent(in) :: h_layer(nx,ny,nz)
real(kind=wp), intent(in) :: hTr(nx,ny,nz)
integer, intent(out) :: n_bad
real(kind=wp), intent(out) :: worst

Calls

proc~~scan_vanished_one_impl~~CallsGraph proc~scan_vanished_one_impl scan_vanished_one_impl rdb_vl_holds_live_conc rdb_vl_holds_live_conc proc~scan_vanished_one_impl->rdb_vl_holds_live_conc rdb_vl_is_live rdb_vl_is_live proc~scan_vanished_one_impl->rdb_vl_is_live

Called by

proc~~scan_vanished_one_impl~~CalledByGraph proc~scan_vanished_one_impl scan_vanished_one_impl proc~multilayer_scan_vanished_content multilayer_state_t%multilayer_scan_vanished_content proc~multilayer_scan_vanished_content->proc~scan_vanished_one_impl proc~check_vanished_invariant_or_die check_vanished_invariant_or_die proc~check_vanished_invariant_or_die->proc~multilayer_scan_vanished_content proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~check_vanished_invariant_or_die proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step_split proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: c_live
integer, private :: i
integer, private :: j
integer, private :: k
integer, private :: k_don
integer, private :: k_top

Source Code

   pure subroutine scan_vanished_one_impl(nx, ny, nz, h_layer, hTr, n_bad, worst)
      !! Flat-impl of the I1′ scan for ONE tracer.  Per column: find the
      !! topmost live layer, then walk DOWN carrying the nearest live layer
      !! above — the donor map `rdb_vl_merge_content` / `rdb_vl_column_conc`
      !! use — and test each filler against its donor's `hTr/h`.
      integer, intent(in) :: nx, ny, nz
      real(wp), intent(in) :: h_layer(nx, ny, nz)
      real(wp), intent(in) :: hTr(nx, ny, nz)
      integer, intent(out) :: n_bad
      real(wp), intent(out) :: worst
      integer :: i, j, k, k_top, k_don
      real(wp) :: c_live

      n_bad = 0
      worst = 0.0_wp
      ! No explicit data clause: nvfortran emits `implicit copyin(...) [if not
      ! already present]`, which is a no-op for the production state (mapped by
      ! `enter_data`) and still correct for a host-only unit test.  `present(...)`
      ! here would make the test abort with a present-table lookup failure.
      !$acc parallel loop collapse(2) private(k, k_top, k_don, c_live) &
      !$acc   reduction(+:n_bad) reduction(max:worst)
      do j = 1, ny
         do i = 1, nx
            k_top = 0
            !$acc loop seq
            do k = nz, 1, -1
               if (rdb_vl_is_live(h_layer(i, j, k))) then
                  k_top = k
                  exit
               end if
            end do
            k_don = k_top
            !$acc loop seq
            do k = nz, 1, -1
               if (rdb_vl_is_live(h_layer(i, j, k))) then
                  k_don = k
               else
                  c_live = 0.0_wp
                  if (k_don > 0) c_live = hTr(i, j, k_don)/h_layer(i, j, k_don)
                  if (.not. rdb_vl_holds_live_conc(hTr(i, j, k), h_layer(i, j, k), c_live)) then
                     n_bad = n_bad + 1
                     worst = max(worst, abs(hTr(i, j, k) - h_layer(i, j, k)*c_live))
                  end if
               end if
            end do
         end do
      end do
   end subroutine scan_vanished_one_impl