diag_density_levels_ok Function

public pure 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).

Arguments

Type IntentOptional 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(:)

Return Value logical


Called by

proc~~diag_density_levels_ok~~CalledByGraph proc~diag_density_levels_ok diag_density_levels_ok proc~validate_config validate_config proc~validate_config->proc~diag_density_levels_ok proc~build_pending_handle build_pending_handle proc~build_pending_handle->proc~validate_config proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~build_pending_handle proc~rdb_ocean_create_pending rdb_ocean_create_pending proc~rdb_ocean_create_pending->proc~build_pending_handle

Variables

Type Visibility Attributes Name Initial
logical, private :: density_requested
integer, private :: k

Source Code

   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