ocean_engine_t Derived Type

type, public :: ocean_engine_t

One ocean simulation’s setup products, minus the caller-owned time-loop bookkeeping (t_current/n_steps/status-restart cadence/console_stats stay with the caller — see the module docstring).


Inherits

type~~ocean_engine_t~~InheritsGraph type~ocean_engine_t ocean_engine_t type~decomp_t decomp_t type~ocean_engine_t->type~decomp_t decomp type~hgrid_t hgrid_t type~ocean_engine_t->type~hgrid_t grid type~ice_evp_params_t ice_evp_params_t type~ocean_engine_t->type~ice_evp_params_t evp_params type~ice_ic_params_t ice_ic_params_t type~ocean_engine_t->type~ice_ic_params_t ic_par type~ocean_boundary_data_constant_t ocean_boundary_data_constant_t type~ocean_engine_t->type~ocean_boundary_data_constant_t bc_source type~ocean_geothermal_t ocean_geothermal_t type~ocean_engine_t->type~ocean_geothermal_t geo type~ocean_state_t ocean_state_t type~ocean_engine_t->type~ocean_state_t state type~ocean_boundary_data_source_t ocean_boundary_data_source_t type~ocean_boundary_data_constant_t->type~ocean_boundary_data_source_t type~barotropic_state_t barotropic_state_t type~ocean_state_t->type~barotropic_state_t barotropic type~continuity_t continuity_t type~ocean_state_t->type~continuity_t continuity type~coriolis_adv_t coriolis_adv_t type~ocean_state_t->type~coriolis_adv_t coriolis_adv type~eos_t eos_t type~ocean_state_t->type~eos_t eos type~multilayer_state_t multilayer_state_t type~ocean_state_t->type~multilayer_state_t multilayer type~ocean_bc_state_t ocean_bc_state_t type~ocean_state_t->type~ocean_bc_state_t bc type~ocean_bottom_drag_t ocean_bottom_drag_t type~ocean_state_t->type~ocean_bottom_drag_t bdrag type~ocean_cavity_flux_t ocean_cavity_flux_t type~ocean_state_t->type~ocean_cavity_flux_t cavity_flux type~ocean_data_forcing_t ocean_data_forcing_t type~ocean_state_t->type~ocean_data_forcing_t data_forcing type~ocean_data_input_t ocean_data_input_t type~ocean_state_t->type~ocean_data_input_t data_input type~ocean_diag_t ocean_diag_t type~ocean_state_t->type~ocean_diag_t diag type~ocean_dyn_t ocean_dyn_t type~ocean_state_t->type~ocean_dyn_t dyn type~ocean_epbl_t ocean_epbl_t type~ocean_state_t->type~ocean_epbl_t epbl type~ocean_gm_t ocean_gm_t type~ocean_state_t->type~ocean_gm_t gm type~ocean_hdiff_tracer_t ocean_hdiff_tracer_t type~ocean_state_t->type~ocean_hdiff_tracer_t hdiff_tracer type~ocean_horizontal_viscosity_t ocean_horizontal_viscosity_t type~ocean_state_t->type~ocean_horizontal_viscosity_t hvisc type~ocean_kappa_shear_t ocean_kappa_shear_t type~ocean_state_t->type~ocean_kappa_shear_t kshear type~ocean_lateral_mix_t ocean_lateral_mix_t type~ocean_state_t->type~ocean_lateral_mix_t lateral_mix type~ocean_meke_t ocean_meke_t type~ocean_state_t->type~ocean_meke_t meke type~ocean_metrics_t ocean_metrics_t type~ocean_state_t->type~ocean_metrics_t metrics type~ocean_mle_t ocean_mle_t type~ocean_state_t->type~ocean_mle_t mle type~ocean_obc_t ocean_obc_t type~ocean_state_t->type~ocean_obc_t obc type~ocean_p_surf_t ocean_p_surf_t type~ocean_state_t->type~ocean_p_surf_t p_surf type~ocean_pressure_force_t ocean_pressure_force_t type~ocean_state_t->type~ocean_pressure_force_t pressure_force type~ocean_redi_t ocean_redi_t type~ocean_state_t->type~ocean_redi_t redi type~ocean_restart_t ocean_restart_t type~ocean_state_t->type~ocean_restart_t restart type~ocean_sea_ice_t ocean_sea_ice_t type~ocean_state_t->type~ocean_sea_ice_t ice type~ocean_slopes_t ocean_slopes_t type~ocean_state_t->type~ocean_slopes_t slopes type~ocean_sponge_t ocean_sponge_t type~ocean_state_t->type~ocean_sponge_t sponge type~ocean_surface_flux_t ocean_surface_flux_t type~ocean_state_t->type~ocean_surface_flux_t surface_flux type~ocean_surface_stress_t ocean_surface_stress_t type~ocean_state_t->type~ocean_surface_stress_t surface_stress type~ocean_tidal_mixing_t ocean_tidal_mixing_t type~ocean_state_t->type~ocean_tidal_mixing_t vmix_tidal type~ocean_tides_t ocean_tides_t type~ocean_state_t->type~ocean_tides_t tides type~ocean_top_drag_t ocean_top_drag_t type~ocean_state_t->type~ocean_top_drag_t tdrag type~ocean_varmix_t ocean_varmix_t type~ocean_state_t->type~ocean_varmix_t varmix type~ocean_vcoord_t ocean_vcoord_t type~ocean_state_t->type~ocean_vcoord_t vcoord type~ocean_vdiff_t ocean_vdiff_t type~ocean_state_t->type~ocean_vdiff_t vdiff type~ocean_vertical_advection_t ocean_vertical_advection_t type~ocean_state_t->type~ocean_vertical_advection_t vert_advect type~ocean_vmix_t ocean_vmix_t type~ocean_state_t->type~ocean_vmix_t vmix type~ocean_wave_speed_t ocean_wave_speed_t type~ocean_state_t->type~ocean_wave_speed_t wavespeed type~scratch_3d_buffer_t scratch_3d_buffer_t type~continuity_t->type~scratch_3d_buffer_t h_face_left_x, h_face_right_x, h_face_left_y, h_face_right_y, mt_h_new, mt_grounded, pd_theta type~coriolis_adv_t->type~scratch_3d_buffer_t q_corner, ke_centre, pv_flux_x, pv_flux_y, mass_flux_u, mass_flux_v type~tracer_t tracer_t type~multilayer_state_t->type~tracer_t tracers type~ocean_bc_face_tag_t ocean_bc_face_tag_t type~ocean_bc_state_t->type~ocean_bc_face_tag_t west, east, south, north type~ocean_bottom_drag_t->type~scratch_3d_buffer_t du_drag, dv_drag, lambda_side_u, lambda_side_v type~ocean_cavity_const_t ocean_cavity_const_t type~ocean_cavity_flux_t->type~ocean_cavity_const_t const type~ocean_cavity_exchange_t ocean_cavity_exchange_t type~ocean_cavity_flux_t->type~ocean_cavity_exchange_t par type~ocean_cavity_ice_t ocean_cavity_ice_t type~ocean_cavity_flux_t->type~ocean_cavity_ice_t ice type~data_input_field_t data_input_field_t type~ocean_data_input_t->type~data_input_field_t fields type~ocean_diag_t->type~hgrid_t grid type~diag_var_t diag_var_t type~ocean_diag_t->type~diag_var_t vars type~ocean_diag_nc_stream_t ocean_diag_nc_stream_t type~ocean_diag_t->type~ocean_diag_nc_stream_t nc_stream type~barotropic_workstate_t barotropic_workstate_t type~ocean_dyn_t->type~barotropic_workstate_t bt_work type~bt_wide_t bt_wide_t type~ocean_dyn_t->type~bt_wide_t bt_wide type~chksum_probe_t chksum_probe_t type~ocean_dyn_t->type~chksum_probe_t chksum_probe type~ke_probe_t ke_probe_t type~ocean_dyn_t->type~ke_probe_t ke_probe type~ocean_epbl_t->type~eos_t eos type~ocean_epbl_t->type~scratch_3d_buffer_t t0, s0, dpe_t, dpe_s, dcolht_t, dcolht_s, ctke_sw type~ocean_hdiff_tracer_t->type~scratch_3d_buffer_t T_centre, F_x_face, F_y_face type~ocean_horizontal_viscosity_t->type~scratch_3d_buffer_t du_visc, dv_visc, lap_u, lap_v, str_xx, str_xy, ah_t, ah_q type~ocean_kappa_shear_t->type~eos_t eos type~ocean_lateral_mix_t->type~scratch_3d_buffer_t vort_corner type~ocean_pressure_force_t->type~scratch_3d_buffer_t p_edge, z_centre, mont_M, rho_insitu, dpdx_face, dpdy_face, e_face, pa, intz_dpa, intx_pa, inty_pa, intx_dpa, inty_dpa, conc_T, conc_S, recon_T_t, recon_T_b, recon_S_t, recon_S_b type~evp_workspace_t evp_workspace_t type~ocean_sea_ice_t->type~evp_workspace_t evp_ws type~ocean_surface_stress_t->type~scratch_3d_buffer_t du_stress, dv_stress type~ocean_tidal_mixing_t->type~eos_t eos type~ocean_top_drag_t->type~scratch_3d_buffer_t du_drag, dv_drag type~ocean_vdiff_t->type~scratch_3d_buffer_t a_diag_t, b_diag_t, c_diag_t, rhs_t, a_diag_u, b_diag_u, c_diag_u, rhs_u, a_diag_v, b_diag_v, c_diag_v, rhs_v, kv_scalar_buf type~ocean_vertical_advection_t->type~scratch_3d_buffer_t F_face type~ocean_vmix_t->type~eos_t eos type~local_bt_cont_u_type local_BT_cont_u_type type~barotropic_workstate_t->type~local_bt_cont_u_type BTCL_u type~local_bt_cont_v_type local_BT_cont_v_type type~barotropic_workstate_t->type~local_bt_cont_v_type BTCL_v type~bt_wide_t->type~hgrid_t grid_w type~bt_wide_t->type~ocean_metrics_t metrics_w type~diag_mask_t diag_mask_t type~diag_var_t->type~diag_mask_t mask

Inherited by

type~~ocean_engine_t~~InheritedByGraph type~ocean_engine_t ocean_engine_t type~ocean_handle_t ocean_handle_t type~ocean_handle_t->type~ocean_engine_t engine

Components

Type Visibility Attributes Name Initial
type(ocean_boundary_data_constant_t), public :: bc_source

Boundary data source, refreshed once per outer step via engine_step -> bc_source%update(t, state%bc).

real(kind=wp), public :: cfl_vtol = 0.0_wp

Console-stats MaxCFL vanish tolerance; 0 when off. Consumed by the caller’s own ocean_console_stats_report, not by the engine itself.

type(decomp_t), public :: decomp
logical, public :: device_mapped = .false.

True between engine_enter_data and engine_exit_data.

logical, public :: diag_enabled = .false.

Latched cfg%ocean%diag%enabled at setup, so engine_step can gate its state%diag%step call without needing cfg.

type(ice_evp_params_t), public :: evp_params

Sea-ice EVP physical + numerical parameters, built once from &ocean_ice_nml at setup.

type(ocean_geothermal_t), public :: geo
type(hgrid_t), public :: grid
logical, public :: has_staged_topology = .false.

True after a topology injection call; staged_periodic_x/y are only meaningful when this is true.

type(ice_ic_params_t), public :: ic_par

Sea-ice initial-condition parameters, built once from &ocean_ice_ic_nml at setup.

logical, public :: is_setup = .false.

True once engine_setup has completed (host-side only; device mapping is a separate step).

integer, public :: n_inner = 0

Resolved barotropic fast-loop substep count (cfg%ocean%bt%n_inner, possibly auto-derived by configure_ocean_bt_split). engine_step dispatches to the split-RK2 path when n_inner >= 1, else the legacy unsplit ocean_dyn_step — mirrors driver_run_ocean’s own dispatch exactly; engine_setup does not itself require n_inner >= 1 (a caller wanting that guarantee, such as the C ABI, checks it after engine_setup returns).

real(kind=wp), public, allocatable :: staged_bathymetry(:,:)

Interior-sized (nx_phys, ny_phys) bathymetry, RAW in the caller’s own sign convention (staged_bathymetry_convention). Consumed by ocean_state_seed_from_cfg’s injected_b argument, which overrides cfg%ocean%topo%topo_config entirely.

integer, public :: staged_bathymetry_convention = 0

BATHY_CONVENTION_* (rdb_ocean_bathymetry_inject). Only meaningful when staged_bathymetry is allocated — no default (D6.2: sign is the single most dangerous argument here).

real(kind=wp), public, allocatable :: staged_metrics_area(:,:)

In-memory MOM6-style supergrid arrays (metrics_assemble_from_supergrid_arrays’s sg_x/sg_y/sg_dx/ sg_dy/sg_area). When staged_metrics_x is allocated, engine_setup assembles metrics directly from these instead of dispatching on cfg%ocean%grid%grid_config.

real(kind=wp), public, allocatable :: staged_metrics_dx(:,:)
real(kind=wp), public, allocatable :: staged_metrics_dy(:,:)
real(kind=wp), public, allocatable :: staged_metrics_x(:,:)
real(kind=wp), public, allocatable :: staged_metrics_y(:,:)
logical, public :: staged_periodic_x = .false.
logical, public :: staged_periodic_y = .false.

Oceananigans-style “the grid owns periodicity”: applied via ocean_bc_state_set_topology right after configure_ocean_bc, overriding whatever the namelist edge tags derived.

type(ocean_state_t), public :: state
logical, public :: warm_restart = .false.

Latched by engine_setup: the prognostic state came from a checkpoint, ghosts included, so no setup pass may re-derive its halo (see the init-time wrap in engine_setup).


Source Code

   type :: ocean_engine_t
      !! One ocean simulation's setup products, minus the caller-owned
      !! time-loop bookkeeping (t_current/n_steps/status-restart
      !! cadence/console_stats stay with the caller — see the module
      !! docstring).
      type(ocean_state_t) :: state
      type(hgrid_t) :: grid
      type(ocean_geothermal_t) :: geo
      type(ocean_boundary_data_constant_t) :: bc_source
         !! Boundary data source, refreshed once per outer step via
         !! `engine_step` -> `bc_source%update(t, state%bc)`.
      type(decomp_t) :: decomp
      type(ice_evp_params_t) :: evp_params
         !! Sea-ice EVP physical + numerical parameters, built once from
         !! `&ocean_ice_nml` at setup.
      type(ice_ic_params_t) :: ic_par
         !! Sea-ice initial-condition parameters, built once from
         !! `&ocean_ice_ic_nml` at setup.
      real(wp) :: cfl_vtol = 0.0_wp
         !! Console-stats MaxCFL vanish tolerance; 0 when off. Consumed
         !! by the caller's own `ocean_console_stats_report`, not by
         !! the engine itself.
      integer :: n_inner = 0
         !! Resolved barotropic fast-loop substep count
         !! (`cfg%ocean%bt%n_inner`, possibly auto-derived by
         !! `configure_ocean_bt_split`). `engine_step` dispatches to
         !! the split-RK2 path when `n_inner >= 1`, else the legacy
         !! unsplit `ocean_dyn_step` — mirrors `driver_run_ocean`'s own
         !! dispatch exactly; `engine_setup` does not itself require
         !! `n_inner >= 1` (a caller wanting that guarantee, such as
         !! the C ABI, checks it after `engine_setup` returns).
      logical :: diag_enabled = .false.
         !! Latched `cfg%ocean%diag%enabled` at setup, so `engine_step`
         !! can gate its `state%diag%step` call without needing `cfg`.
      logical :: device_mapped = .false.
         !! True between `engine_enter_data` and `engine_exit_data`.
      logical :: warm_restart = .false.
         !! Latched by `engine_setup`: the prognostic state came from a
         !! checkpoint, ghosts included, so no setup pass may re-derive its
         !! halo (see the init-time wrap in `engine_setup`).
      logical :: is_setup = .false.
         !! True once `engine_setup` has completed (host-side only;
         !! device mapping is a separate step).

      ! ---- P2.5: pre-create geometry injection staging ----
      ! Populated (by the C ABI's rdb_ocean_stage_* calls, or directly by
      ! a Fortran caller) BEFORE engine_setup runs, and consumed inside it —
      ! geometry must land before ocean_state_enter_data, exactly like
      ! passive-tracer registration (registry_locked closes at enter_data).
      ! Unset (not `allocated`/`.false.`) ⇒ engine_setup falls through to
      ! its ordinary namelist-driven path, byte-identical to before P2.5.
      real(wp), allocatable :: staged_bathymetry(:, :)
         !! Interior-sized (nx_phys, ny_phys) bathymetry, RAW in the
         !! caller's own sign convention (`staged_bathymetry_convention`).
         !! Consumed by `ocean_state_seed_from_cfg`'s `injected_b` argument,
         !! which overrides `cfg%ocean%topo%topo_config` entirely.
      integer :: staged_bathymetry_convention = 0
         !! `BATHY_CONVENTION_*` (`rdb_ocean_bathymetry_inject`). Only
         !! meaningful when `staged_bathymetry` is allocated — no default
         !! (D6.2: sign is the single most dangerous argument here).
      real(wp), allocatable :: staged_metrics_x(:, :), staged_metrics_y(:, :)
      real(wp), allocatable :: staged_metrics_dx(:, :), staged_metrics_dy(:, :)
      real(wp), allocatable :: staged_metrics_area(:, :)
         !! In-memory MOM6-style supergrid arrays
         !! (`metrics_assemble_from_supergrid_arrays`'s `sg_x/sg_y/sg_dx/
         !! sg_dy/sg_area`). When `staged_metrics_x` is allocated,
         !! `engine_setup` assembles metrics directly from these instead of
         !! dispatching on `cfg%ocean%grid%grid_config`.
      logical :: has_staged_topology = .false.
         !! True after a topology injection call; `staged_periodic_x/y`
         !! are only meaningful when this is true.
      logical :: staged_periodic_x = .false.
      logical :: staged_periodic_y = .false.
         !! Oceananigans-style "the grid owns periodicity": applied via
         !! `ocean_bc_state_set_topology` right after `configure_ocean_bc`,
         !! overriding whatever the namelist edge tags derived.
   end type ocean_engine_t