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.
| Type | Intent | Optional | 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 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | is_ | ||||
| integer, | private | :: | it | ||||
| real(kind=wp), | private | :: | pref |
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