ocean_apply_conservative_min_thickness Subroutine

public subroutine ocean_apply_conservative_min_thickness(grid, ms, h_new, grounded_mask, h_floor)

Apply the conservative minimum-thickness adjustment in place on ms.

h_new is caller-owned device-resident scratch shaped (nx_total, ny_total, nz_ml) (a scratch_3d_buffer_t%data slot); grounded_mask is (nx_total, ny_total, 1) scratch (ct%mt_grounded). On grounded columns h_new receives the floor-only target thickness; non-grounded columns are never written (their target ≡ h_old).

Order (each step a separate device launch so the h_old reads all complete before h_layer is overwritten): 0. build the 2D grounded mask + global count (ONE coalesced pass); count == 0 ⇒ return — the entire adjustment is a byte-no-op. 1. build the target field h_new on grounded columns, 2. remap every tracer (h_old -> h_new) on grounded columns, 3. remap the face velocities (h_old -> h_new) on active faces, 4. h_layer := h_new on grounded columns.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(multilayer_state_t), intent(inout) :: ms
real(kind=wp), intent(inout) :: h_new(grid%nx_total,grid%ny_total,ms%nz_ml)
real(kind=wp), intent(inout) :: grounded_mask(grid%nx_total,grid%ny_total,1)
real(kind=wp), intent(in) :: h_floor

Minimum layer thickness (m); the isopycnal angstrom_h.


Calls

proc~~ocean_apply_conservative_min_thickness~~CallsGraph proc~ocean_apply_conservative_min_thickness ocean_apply_conservative_min_thickness proc~assign_h_layer assign_h_layer proc~ocean_apply_conservative_min_thickness->proc~assign_h_layer proc~build_grounded_mask build_grounded_mask proc~ocean_apply_conservative_min_thickness->proc~build_grounded_mask proc~build_target_field build_target_field proc~ocean_apply_conservative_min_thickness->proc~build_target_field proc~remap_tracer_grounded remap_tracer_grounded proc~ocean_apply_conservative_min_thickness->proc~remap_tracer_grounded proc~remap_x_face_grounded remap_x_face_grounded proc~ocean_apply_conservative_min_thickness->proc~remap_x_face_grounded proc~remap_y_face_grounded remap_y_face_grounded proc~ocean_apply_conservative_min_thickness->proc~remap_y_face_grounded local local proc~build_grounded_mask->local reduce reduce proc~build_grounded_mask->reduce proc~build_target_field->local proc~min_thickness_target_column min_thickness_target_column proc~build_target_field->proc~min_thickness_target_column proc~remap_tracer_grounded->local proc~remap_column remap_column proc~remap_tracer_grounded->proc~remap_column proc~remap_x_face_grounded->local proc~remap_x_face_grounded->proc~remap_column proc~remap_y_face_grounded->local proc~remap_y_face_grounded->proc~remap_column proc~remap_column_pcm remap_column_pcm proc~remap_column->proc~remap_column_pcm proc~remap_column_plm remap_column_plm proc~remap_column->proc~remap_column_plm proc~remap_column_ppm remap_column_ppm proc~remap_column->proc~remap_column_ppm proc~remap_column_ppm_h4 remap_column_ppm_h4 proc~remap_column->proc~remap_column_ppm_h4 proc~remap_column_pqm remap_column_pqm proc~remap_column->proc~remap_column_pqm proc~boundary_half_jump boundary_half_jump proc~remap_column_plm->proc~boundary_half_jump proc~plm_slope_nonuniform plm_slope_nonuniform proc~remap_column_plm->proc~plm_slope_nonuniform proc~remap_column_ppm->proc~remap_column_plm proc~remap_column_ppm->proc~boundary_half_jump proc~ppm_edge_nonuniform ppm_edge_nonuniform proc~remap_column_ppm->proc~ppm_edge_nonuniform proc~ppm_edge_two_cell ppm_edge_two_cell proc~remap_column_ppm->proc~ppm_edge_two_cell proc~ppm_jump_nonuniform ppm_jump_nonuniform proc~remap_column_ppm->proc~ppm_jump_nonuniform proc~remap_column_ppm_h4->proc~remap_column_plm proc~remap_column_ppm_h4->proc~boundary_half_jump proc~remap_column_pqm->proc~remap_column_ppm proc~remap_column_pqm->proc~boundary_half_jump proc~pqm_end_value_h4 pqm_end_value_h4 proc~remap_column_pqm->proc~pqm_end_value_h4 proc~pqm_solve_diag_dominant pqm_solve_diag_dominant proc~remap_column_pqm->proc~pqm_solve_diag_dominant

Called by

proc~~ocean_apply_conservative_min_thickness~~CalledByGraph proc~ocean_apply_conservative_min_thickness ocean_apply_conservative_min_thickness proc~run_continuity_chain run_continuity_chain proc~run_continuity_chain->proc~ocean_apply_conservative_min_thickness proc~run_stage_split run_stage_split proc~run_stage_split->proc~run_continuity_chain 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

Variables

Type Visibility Attributes Name Initial
integer, private :: n_grounded
integer, private :: nx
integer, private :: ny
integer, private :: nz
integer, private :: t

Source Code

   subroutine ocean_apply_conservative_min_thickness(grid, ms, h_new, grounded_mask, &
                                                     h_floor)
      !! Apply the conservative minimum-thickness adjustment in place on `ms`.
      !!
      !! `h_new` is caller-owned device-resident scratch shaped
      !! `(nx_total, ny_total, nz_ml)` (a `scratch_3d_buffer_t%data` slot);
      !! `grounded_mask` is `(nx_total, ny_total, 1)` scratch (`ct%mt_grounded`).
      !! On grounded columns `h_new` receives the floor-only target thickness;
      !! non-grounded columns are never written (their target ≡ h_old).
      !!
      !! Order (each step a separate device launch so the h_old reads all
      !! complete before h_layer is overwritten):
      !!   0. build the 2D grounded mask + global count (ONE coalesced pass);
      !!      count == 0 ⇒ return — the entire adjustment is a byte-no-op.
      !!   1. build the target field h_new on grounded columns,
      !!   2. remap every tracer   (h_old -> h_new) on grounded columns,
      !!   3. remap the face velocities (h_old -> h_new) on active faces,
      !!   4. h_layer := h_new on grounded columns.
      type(hgrid_t), intent(in) :: grid
      type(multilayer_state_t), intent(inout) :: ms
      real(wp), intent(inout) :: h_new(grid%nx_total, grid%ny_total, ms%nz_ml)
      real(wp), intent(inout) :: grounded_mask(grid%nx_total, grid%ny_total, 1)
      real(wp), intent(in) :: h_floor
         !! Minimum layer thickness (m); the isopycnal `angstrom_h`.

      integer :: nx, ny, nz, t, n_grounded

      nx = grid%nx_total
      ny = grid%ny_total
      nz = ms%nz_ml

      call build_grounded_mask(nx, ny, nz, ms%h_layer, h_floor, grounded_mask, &
                               n_grounded)
      if (n_grounded == 0) return

      call build_target_field(nx, ny, nz, ms%h_layer, h_floor, grounded_mask, h_new)

      if (allocated(ms%tracers)) then
         do t = 1, size(ms%tracers)
            if (.not. allocated(ms%tracers(t)%hTr)) cycle
            call remap_tracer_grounded(nx, ny, nz, ms%h_layer, h_new, grounded_mask, &
                                       ms%tracers(t)%hTr)
         end do
      end if

      call remap_x_face_grounded(nx, ny, nz, ms%h_layer, h_new, grounded_mask, &
                                 ms%u_face_x_layer)
      call remap_y_face_grounded(nx, ny, nz, ms%h_layer, h_new, grounded_mask, &
                                 ms%v_face_y_layer)

      call assign_h_layer(nx, ny, nz, h_new, grounded_mask, ms%h_layer)
   end subroutine ocean_apply_conservative_min_thickness