ke_probe_sample Subroutine

public subroutine ke_probe_sample(grid, ms, probe, label, stage, step)

Sample the three-region layer KE and print the attribution row. Call AFTER the segment being attributed; the printed dKE is “this sample minus the previous one” — i.e. the segment’s energy contribution. Drains all device queues first so the async velocity-apply chain (queue 1) has landed.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(multilayer_state_t), intent(in) :: ms
type(ke_probe_t), intent(inout) :: probe
character(len=*), intent(in) :: label

Segment tag, e.g. “coriolis_adv”, “bt_correction”.

integer, intent(in) :: stage
integer, intent(in) :: step

Calls

proc~~ke_probe_sample~~CallsGraph proc~ke_probe_sample ke_probe_sample proc~ke_probe_active ke_probe_active proc~ke_probe_sample->proc~ke_probe_active proc~ke_regions_impl ke_regions_impl proc~ke_probe_sample->proc~ke_regions_impl reduce reduce proc~ke_regions_impl->reduce

Called by

proc~~ke_probe_sample~~CalledByGraph proc~ke_probe_sample ke_probe_sample proc~run_stage_split run_stage_split proc~run_stage_split->proc~ke_probe_sample proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_stage_split 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
real(kind=wp), private :: d_east
real(kind=wp), private :: d_full
real(kind=wp), private :: d_rim
real(kind=wp), private :: ke_east
real(kind=wp), private :: ke_full
real(kind=wp), private :: ke_rim

Source Code

   subroutine ke_probe_sample(grid, ms, probe, label, stage, step)
      !! Sample the three-region layer KE and print the attribution row.
      !! Call AFTER the segment being attributed; the printed dKE is
      !! "this sample minus the previous one" — i.e. the segment's
      !! energy contribution.  Drains all device queues first so the
      !! async velocity-apply chain (queue 1) has landed.
      type(hgrid_t), intent(in) :: grid
      type(multilayer_state_t), intent(in) :: ms
      type(ke_probe_t), intent(inout) :: probe
      character(len=*), intent(in) :: label
         !! Segment tag, e.g. "coriolis_adv", "bt_correction".
      integer, intent(in) :: stage, step

      real(wp) :: ke_full, ke_rim, ke_east
      real(wp) :: d_full, d_rim, d_east

      if (.not. ke_probe_active(probe, step)) return

      !$acc wait
      call ke_regions_impl(ms%h_layer, ms%u_face_x_layer, ms%v_face_y_layer, &
                           grid%nx_total, grid%ny_total, ms%nz_ml, &
                           grid%nghost, grid%nx_phys, grid%ny_phys, &
                           probe%rim_band, probe%east_band, &
                           ke_full, ke_rim, ke_east)

      if (probe%have_prev) then
         d_full = ke_full - probe%prev_full
         d_rim = ke_rim - probe%prev_rim
         d_east = ke_east - probe%prev_east
      else
         d_full = ke_full
         d_rim = ke_rim
         d_east = ke_east
      end if

      if (.not. probe%header_done) then
         write (*, "(a)") "# KE_ATTR columns: step stage segment "// &
            "dKE_full KE_full dKE_rim KE_rim dKE_east KE_east   [m3/s2]"
         write (*, "(a)") "# dKE = energy injected (+) / removed (-) by the segment just run"
         probe%header_done = .true.
      end if
      write (*, "(a,1x,i6,1x,a,i1,1x,a16,6(1x,es13.5))") &
         "KE_ATTR", step, "s", stage, adjustl(label), &
         d_full, ke_full, d_rim, ke_rim, d_east, ke_east

      probe%prev_full = ke_full
      probe%prev_rim = ke_rim
      probe%prev_east = ke_east
      probe%have_prev = .true.
   end subroutine ke_probe_sample