configure_ocean_wavespeed Subroutine

private subroutine configure_ocean_wavespeed(cfg, ocean_state, grid, ierr)

Copy the &ocean_wavespeed_nml knobs onto the wave-speed slot (B1). Diagnostic, no mutual exclusion: cg1/Rd read rho_layer directly. Fills f_centre + the static beta_centre = |grad f| field via fill_coriolis_centre + build_static — the SAME metrics_fill_coriolis path VarMix/MEKE use (planetary on spherical/tripolar, beta-plane bit-identical elsewhere) — rather than the legacy hard-coded beta-plane set_f_centre. Copies rho0 from the EOS slot for the Boussinesq gprime. Must run AFTER configure_ocean_metrics (metrics filled + finalized).

Arguments

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

Non-zero on a wave-speed configuration conflict when present; absent behaves as today (error stop).


Calls

proc~~configure_ocean_wavespeed~~CallsGraph proc~configure_ocean_wavespeed configure_ocean_wavespeed proc~fail fail proc~configure_ocean_wavespeed->proc~fail proc~fill_coriolis_centre fill_coriolis_centre proc~configure_ocean_wavespeed->proc~fill_coriolis_centre proc~ocean_wave_speed_build_static ocean_wave_speed_t%ocean_wave_speed_build_static proc~configure_ocean_wavespeed->proc~ocean_wave_speed_build_static error error proc~fail->error proc~error_ring_push error_ring_push proc~fail->proc~error_ring_push proc~metrics_fill_coriolis metrics_fill_coriolis proc~fill_coriolis_centre->proc~metrics_fill_coriolis proc~parse_coriolis_scheme parse_coriolis_scheme proc~fill_coriolis_centre->proc~parse_coriolis_scheme

Called by

proc~~configure_ocean_wavespeed~~CalledByGraph proc~configure_ocean_wavespeed configure_ocean_wavespeed proc~configure_ocean_lateral configure_ocean_lateral proc~configure_ocean_lateral->proc~configure_ocean_wavespeed 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, allocatable :: f_centre(:,:)

Source Code

   subroutine configure_ocean_wavespeed(cfg, ocean_state, grid, ierr)
      !! Copy the `&ocean_wavespeed_nml` knobs onto the wave-speed slot
      !! (B1).  Diagnostic, no mutual exclusion: cg1/Rd read `rho_layer`
      !! directly.  Fills `f_centre` + the static `beta_centre = |grad
      !! f|` field via `fill_coriolis_centre` + `build_static` — the
      !! SAME `metrics_fill_coriolis` path VarMix/MEKE use (planetary on
      !! spherical/tripolar, beta-plane bit-identical elsewhere) —
      !! rather than the legacy hard-coded beta-plane `set_f_centre`.
      !! Copies rho0 from the EOS slot for the Boussinesq `gprime`.  Must
      !! run AFTER `configure_ocean_metrics` (metrics filled + finalized).
      type(config_t), intent(in) :: cfg
      type(ocean_state_t), intent(inout) :: ocean_state
      type(hgrid_t), intent(in) :: grid
      integer, intent(out), optional :: ierr
         !! Non-zero on a wave-speed configuration conflict when present;
         !! absent behaves as today (`error stop`).
      real(wp), allocatable :: f_centre(:, :)

      associate (ws => ocean_state%wavespeed, wcfg => cfg%ocean%wavespeed)
         ws%enable = wcfg%enable
         if (.not. wcfg%enable) then
            if (present(ierr)) ierr = OCEAN_STATUS_OK
            return
         end if

         ! Fail loud at configure: the column kernel indexes fixed-size
         ! NZ_STACK_MAX column arrays; wavespeed_compute never ran before
         ! this PR so nz > NZ_STACK_MAX never overran it.  It can now.
         if (cfg%nz_layers > NZ_STACK_MAX) then
            call fail("ocean_wavespeed_nml: nz_layers exceeds "// &
                      "NZ_STACK_MAX (raise NZ_STACK_MAX in rdb_constants)", ierr, OCEAN_STATUS_ERR_SETUP)
            return
         end if

         ws%mono_n2_depth = wcfg%mono_n2
         ws%use_ebt = wcfg%use_ebt
         ws%n_wavespeed = wcfg%n_wavespeed
         ws%rho0 = ocean_state%eos%rho0

         ! |f| at centres + the static |grad f| field for Rd.
         allocate (f_centre(grid%nx_total, grid%ny_total))
         call fill_coriolis_centre(cfg, ocean_state%metrics, grid, f_centre)
         call ws%build_static(grid, ocean_state%metrics, f_centre)
         deallocate (f_centre)

         if (wcfg%n_wavespeed < 1) then
            call fail("ocean_wavespeed_nml: n_wavespeed must be >= 1", ierr, OCEAN_STATUS_ERR_SETUP)
            return
         end if
      end associate
      if (present(ierr)) ierr = OCEAN_STATUS_OK
   end subroutine configure_ocean_wavespeed