configure_rho_target Subroutine

private subroutine configure_rho_target(cfg, rho_target, nz_ml)

Populate the isopycnal rho_target(0:nz_ml) interface densities for VCOORD_RHO / VCOORD_HYCOM. rho_target(0) is the surface (lightest) interface, rho_target(nz_ml) the bed (densest).

  • &vcoord_nml rho_target_profile = "uniform" (default) — a uniform light→dense linspace from rho_target_light / rho_target_dense (MOM6 ALE_COORDINATE_CONFIG=UNIFORM);
  • "list" — the nz_ml+1 interface densities of rho_target_list, light first (MOM6 target densities from a list or a file, e.g. HYBRID:file,sigma2,dz).

validate_config has already refused a list of the wrong length or one that is not strictly increasing; a short list reaching here is an error stop. Harmless on other families.

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(in) :: cfg
real(kind=wp), intent(inout) :: rho_target(0:)
integer, intent(in) :: nz_ml

Called by

proc~~configure_rho_target~~CalledByGraph proc~configure_rho_target configure_rho_target proc~configure_ocean_lateral configure_ocean_lateral proc~configure_ocean_lateral->proc~configure_rho_target proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_lateral proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: frac
integer, private :: k

Source Code

   subroutine configure_rho_target(cfg, rho_target, nz_ml)
      !! Populate the isopycnal `rho_target(0:nz_ml)` interface densities
      !! for `VCOORD_RHO` / `VCOORD_HYCOM`.  `rho_target(0)` is the surface
      !! (lightest) interface, `rho_target(nz_ml)` the bed (densest).
      !!
      !!   * `&vcoord_nml rho_target_profile = "uniform"` (default) — a
      !!     uniform light→dense linspace from `rho_target_light` /
      !!     `rho_target_dense` (MOM6 `ALE_COORDINATE_CONFIG=UNIFORM`);
      !!   * `"list"` — the `nz_ml+1` interface densities of
      !!     `rho_target_list`, light first (MOM6 target densities from a
      !!     list or a file, e.g. `HYBRID:file,sigma2,dz`).
      !!
      !! `validate_config` has already refused a list of the wrong length
      !! or one that is not strictly increasing; a short list reaching here
      !! is an `error stop`.  Harmless on other families.
      type(config_t), intent(in) :: cfg
      real(wp), intent(inout) :: rho_target(0:)
      integer, intent(in) :: nz_ml
      integer :: k
      real(wp) :: frac

      if (trim(cfg%rho_target_profile) == "list") then
         ! validate_config refuses a short list; reaching here with one is
         ! a bug, so stop rather than fall back to the linspace.
         if (count(cfg%rho_target_list > 0.0_wp) < nz_ml + 1) then
            error stop "configure_rho_target: rho_target_list shorter than nz_ml+1"
         end if
         do k = 0, nz_ml
            rho_target(k) = cfg%rho_target_list(k + 1)
         end do
         return
      end if
      do k = 0, nz_ml
         if (nz_ml > 0) then
            frac = real(k, wp)/real(nz_ml, wp)
         else
            frac = 0.0_wp
         end if
         rho_target(k) = cfg%rho_target_light &
                         + (cfg%rho_target_dense - cfg%rho_target_light)*frac
      end do
   end subroutine configure_rho_target