configure_ocean_foxkemper Subroutine

private subroutine configure_ocean_foxkemper(cfg, ocean_state, compute_rank, ierr)

Copy the &ocean_foxkemper_nml knobs onto the MLE slot (B5). Validates: B5 reads epbl%mld, so EPBL must be enabled; and the resolution_taper hook is a hard error until B2 lands.

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(in) :: cfg
type(ocean_state_t), intent(inout) :: ocean_state
integer, intent(in) :: compute_rank
integer, intent(out), optional :: ierr

Non-zero on a Fox-Kemper MLE configuration conflict when present; absent behaves as today (error stop).


Calls

proc~~configure_ocean_foxkemper~~CallsGraph proc~configure_ocean_foxkemper configure_ocean_foxkemper info info proc~configure_ocean_foxkemper->info proc~fail fail proc~configure_ocean_foxkemper->proc~fail to_string to_string proc~configure_ocean_foxkemper->to_string error error proc~fail->error proc~error_ring_push error_ring_push proc~fail->proc~error_ring_push

Called by

proc~~configure_ocean_foxkemper~~CalledByGraph proc~configure_ocean_foxkemper configure_ocean_foxkemper proc~configure_ocean_lateral configure_ocean_lateral proc~configure_ocean_lateral->proc~configure_ocean_foxkemper 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

Source Code

   subroutine configure_ocean_foxkemper(cfg, ocean_state, compute_rank, ierr)
      !! Copy the `&ocean_foxkemper_nml` knobs onto the MLE slot (B5).
      !! Validates: B5 reads `epbl%mld`, so EPBL must be enabled; and the
      !! `resolution_taper` hook is a hard error until B2 lands.
      type(config_t), intent(in) :: cfg
      type(ocean_state_t), intent(inout) :: ocean_state
      integer, intent(in) :: compute_rank
      integer, intent(out), optional :: ierr
         !! Non-zero on a Fox-Kemper MLE configuration conflict when
         !! present; absent behaves as today (`error stop`).

      associate (mle => ocean_state%mle, fcfg => cfg%ocean%foxkemper)
         mle%enable = fcfg%enable
         if (.not. fcfg%enable) then
            if (present(ierr)) ierr = OCEAN_STATUS_OK
            return
         end if

         mle%ce = fcfg%ce
         mle%f_floor = fcfg%f_floor
         mle%mld_decay_time = fcfg%mld_decay_time
         mle%tail_dh = fcfg%tail_dh
         mle%use_mom_mixrate = fcfg%use_mom_mixrate
         mle%resolution_taper = fcfg%resolution_taper
         mle%use_bodner = fcfg%use_bodner
         mle%cr = fcfg%cr
         mle%bodner_mstar = fcfg%bodner_mstar
         mle%bodner_nstar = fcfg%bodner_nstar
         mle%min_wstar2 = fcfg%min_wstar2

         ! B5 takes the mixed-layer depth from epbl%mld — EPBL is the
         ! enabler and must be on.
         if (.not. ocean_state%epbl%enable) then
            call fail("ocean_foxkemper_nml: enable=.true. requires "// &
                      "ocean_epbl_nml enable=.true. (B5 reads epbl%mld)", ierr, OCEAN_STATUS_ERR_SETUP)
            return
         end if
         ! resolution_taper is a B2 hook; the res_fn is not available yet.
         if (mle%resolution_taper) then
            call fail("ocean_foxkemper_nml: resolution_taper=.true. "// &
                      "requires the B2 resolution function (not yet "// &
                      "available) — leave it .false. until B2 lands", ierr, OCEAN_STATUS_ERR_SETUP)
            return
         end if
         if (mle%tail_dh /= 0.0_wp) then
            call fail("ocean_foxkemper_nml: tail_dh /= 0 (mu cubic "// &
                      "tail) is deferred; use the exact mu (tail_dh=0)", ierr, OCEAN_STATUS_ERR_SETUP)
            return
         end if

         if (compute_rank == 0) then
            if (fcfg%use_bodner) then
               call logger%info("Fox-Kemper MLE:   restratification enabled  "// &
                                "Bodner-2023 frontogenesis arrest  Cr="//to_string(fcfg%cr))
            else
               call logger%info("Fox-Kemper MLE:   restratification enabled  Ce="// &
                                to_string(fcfg%ce)//"  timescale="// &
                                merge("FK11-mixrate", "bare Ce/|f| ", fcfg%use_mom_mixrate))
            end if
         end if
      end associate
      if (present(ierr)) ierr = OCEAN_STATUS_OK
   end subroutine configure_ocean_foxkemper