remap_layer_to_density Subroutine

public subroutine remap_layer_to_density(state_handle, z_out, layer_buf, output_buf, is_extensive)

Conservative layer→DENSITY-space remap (DIAG_VGRID_DENSITY). z_out(:) = monotone-increasing target potential DENSITIES (kg/m³). Per column: layer potential density via device EOS at the diag reference pressure, invert the profile to target-interface depths (invert_density_targets), then remap. Lightest target → surface. is_extensive=.false. ⇒ INTENSIVE (weighted average); .true. ⇒ EXTENSIVE (column integral redistributed across bins, Σ preserved). Public only for the unit-test suite.

Arguments

Type IntentOptional Attributes Name
class(*), intent(in) :: state_handle
real(kind=wp), intent(in) :: z_out(:)
real(kind=wp), intent(in) :: layer_buf(:,:,:)
real(kind=wp), intent(inout) :: output_buf(:,:,:)
logical, intent(in) :: is_extensive

Calls

proc~~remap_layer_to_density~~CallsGraph proc~remap_layer_to_density remap_layer_to_density proc~fill_zero_impl fill_zero_impl proc~remap_layer_to_density->proc~fill_zero_impl proc~remap_layer_to_density_impl remap_layer_to_density_impl proc~remap_layer_to_density->proc~remap_layer_to_density_impl tracers tracers proc~remap_layer_to_density->tracers local local proc~remap_layer_to_density_impl->local proc~eos_density_point eos_density_point proc~remap_layer_to_density_impl->proc~eos_density_point proc~invert_density_targets invert_density_targets proc~remap_layer_to_density_impl->proc~invert_density_targets proc~remap_column remap_column proc~remap_layer_to_density_impl->proc~remap_column rdb_vl_conc rdb_vl_conc proc~remap_layer_to_density_impl->rdb_vl_conc rdb_vl_is_live rdb_vl_is_live proc~remap_layer_to_density_impl->rdb_vl_is_live proc~roquet_spv_value roquet_spv_value proc~eos_density_point->proc~roquet_spv_value 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 rdb_roq_spv_p rdb_roq_spv_p proc~roquet_spv_value->rdb_roq_spv_p rdb_roq_ts_coeffs rdb_roq_ts_coeffs proc~roquet_spv_value->rdb_roq_ts_coeffs

Variables

Type Visibility Attributes Name Initial
integer, private :: is_
integer, private :: it
real(kind=wp), private :: pref

Source Code

   subroutine remap_layer_to_density(state_handle, z_out, layer_buf, output_buf, is_extensive)
      !! Conservative layer→DENSITY-space remap (`DIAG_VGRID_DENSITY`).
      !! `z_out(:)` = monotone-increasing target potential DENSITIES (kg/m³).
      !! Per column: layer potential density via device EOS at the diag
      !! reference pressure, invert the profile to target-interface depths
      !! (`invert_density_targets`), then remap.  Lightest target → surface.
      !! `is_extensive=.false.` ⇒ INTENSIVE (weighted average); `.true.` ⇒
      !! EXTENSIVE (column integral redistributed across bins, Σ preserved).
      !! Public only for the unit-test suite.
      class(*), intent(in) :: state_handle
      real(wp), intent(in) :: z_out(:)
      real(wp), intent(in) :: layer_buf(:, :, :)
      real(wp), intent(inout) :: output_buf(:, :, :)
      logical, intent(in) :: is_extensive
      integer :: it, is_
      real(wp) :: pref
      select type (state => state_handle)
      class is (ocean_state_t)
         it = state%multilayer%idx_temperature
         is_ = state%multilayer%idx_salinity
         pref = state%vcoord%rho_ref_pressure
         if (it <= 0 .or. is_ <= 0) then
            call fill_zero_impl(output_buf)
            return
         end if
         call remap_layer_to_density_impl(state%multilayer%h_layer, &
                                          state%multilayer%tracers(it)%hTr, &
                                          state%multilayer%tracers(is_)%hTr, &
                                          state%eos, pref, z_out, &
                                          layer_buf, output_buf, is_extensive, &
                                          diag_remap_method)
      end select
   end subroutine remap_layer_to_density