.true. iff a density-coordinate diagnostic selection (global
vgrid='density', or a per-diagnostic :density/:rho attribute
anywhere in diags) has a usable rho_levels axis: at least one
entry, strictly increasing (invert_density_targets assumes a
monotone light->dense target list), and within the declared
MAX_OCEAN_DIAG_Z_LEVELS array bound. Unlike sigma/z*, density
bins have no auto-fill, so an unset axis must abort rather than
silently size to zero. When density is not requested at all this
is unconditionally .true. (no constraint).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | vgrid | |||
| character(len=*), | intent(in) | :: | diags | |||
| integer, | intent(in) | :: | n_rho_levels | |||
| real(kind=wp), | intent(in) | :: | rho_levels(:) |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | private | :: | density_requested | ||||
| integer, | private | :: | k |
pure logical function diag_density_levels_ok(vgrid, diags, n_rho_levels, rho_levels) result(ok) !! .true. iff a density-coordinate diagnostic selection (global !! `vgrid='density'`, or a per-diagnostic `:density`/`:rho` attribute !! anywhere in `diags`) has a usable `rho_levels` axis: at least one !! entry, strictly increasing (`invert_density_targets` assumes a !! monotone light->dense target list), and within the declared !! `MAX_OCEAN_DIAG_Z_LEVELS` array bound. Unlike sigma/z*, density !! bins have no auto-fill, so an unset axis must abort rather than !! silently size to zero. When density is not requested at all this !! is unconditionally `.true.` (no constraint). character(len=*), intent(in) :: vgrid character(len=*), intent(in) :: diags integer, intent(in) :: n_rho_levels real(wp), intent(in) :: rho_levels(:) logical :: density_requested integer :: k density_requested = (trim(vgrid) == "density") .or. & (index(diags, ":density") > 0) .or. & (index(diags, ":rho") > 0) if (.not. density_requested) then ok = .true. return end if ok = .true. if (n_rho_levels <= 0) then ok = .false. return end if if (n_rho_levels > size(rho_levels)) then ok = .false. return end if do k = 2, n_rho_levels if (rho_levels(k) <= rho_levels(k - 1)) then ok = .false. return end if end do end function diag_density_levels_ok