multilayer_scan_vanished_content Subroutine

private pure subroutine multilayer_scan_vanished_content(this, nx, ny, n_bad, worst)

Pure I1′ TRIPWIRE scan — counts the vanished cells that do NOT hold their donor’s concentration (rdb_vl_holds_live_conc: |hTr − h·c_live| > 1e-12·|h·c_live|, i.e. hTr ≠ 0 in a column with no live layer) and reports the largest offending |hTr − h·c_live|, without touching anything. Two device reductions per tracer, two scalars out; no H←D copy on the healthy path.

The impure half (log + error stop) lives with the caller, in rdb_ocean_dyn, because this type is below the logger in the dependency order and because a pure scan is what a unit test can assert against without provoking an abort.

Type Bound

multilayer_state_t

Arguments

Type IntentOptional Attributes Name
class(multilayer_state_t), intent(in) :: this
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(out) :: n_bad

Number of (i,j,k,tracer) cells violating I1′.

real(kind=wp), intent(out) :: worst

Largest |hTr − h·c_live| found in a vanished layer (0 when clean).


Calls

proc~~multilayer_scan_vanished_content~~CallsGraph proc~multilayer_scan_vanished_content multilayer_state_t%multilayer_scan_vanished_content proc~scan_vanished_one_impl scan_vanished_one_impl proc~multilayer_scan_vanished_content->proc~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~~multilayer_scan_vanished_content~~CalledByGraph proc~multilayer_scan_vanished_content multilayer_state_t%multilayer_scan_vanished_content 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 proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
integer, private :: n_t
integer, private :: t
real(kind=wp), private :: w_t

Source Code

   pure subroutine multilayer_scan_vanished_content(this, nx, ny, n_bad, worst)
      !! Pure I1′ TRIPWIRE scan — counts the vanished cells that do NOT hold
      !! their donor's concentration (`rdb_vl_holds_live_conc`: `|hTr −
      !! h·c_live| > 1e-12·|h·c_live|`, i.e. `hTr ≠ 0` in a column with no
      !! live layer) and reports the largest offending `|hTr − h·c_live|`,
      !! without touching anything.  Two device reductions per tracer, two
      !! scalars out; no H←D copy on the healthy path.
      !!
      !! The impure half (log + `error stop`) lives with the caller, in
      !! `rdb_ocean_dyn`, because this type is below the logger in the
      !! dependency order and because a `pure` scan is what a unit test can
      !! assert against without provoking an abort.
      class(multilayer_state_t), intent(in) :: this
      integer, intent(in) :: nx, ny
      integer, intent(out) :: n_bad
         !! Number of `(i,j,k,tracer)` cells violating I1′.
      real(wp), intent(out) :: worst
         !! Largest `|hTr − h·c_live|` found in a vanished layer (0 when clean).
      integer :: t, n_t
      real(wp) :: w_t

      n_bad = 0
      worst = 0.0_wp
      if (.not. allocated(this%h_layer)) return
      if (.not. allocated(this%tracers)) return
      do t = 1, size(this%tracers)
         if (.not. allocated(this%tracers(t)%hTr)) cycle
         call scan_vanished_one_impl(nx, ny, this%nz_ml, this%h_layer, &
                                     this%tracers(t)%hTr, n_t, w_t)
         n_bad = n_bad + n_t
         worst = max(worst, w_t)
      end do
   end subroutine multilayer_scan_vanished_content