ocean_dyn_enable_bt_wide Subroutine

public subroutine ocean_dyn_enable_bt_wide(dyn, grid, dx, dy, lon_west, lat_south, rad_earth, grid_config_str, f_0, beta, y_ref, coriolis_scheme_str, omega)

Allocate, initialise, and GPU-attach the wide-halo shadow state from dyn%bt_halo (already set by the caller).

Preconditions: - dyn%init has been called. - dyn%enter_data has been called (bt_work is on the GPU; we add bt_wide to the same GPU context). - dyn%bt_halo > 0.

Odd bt_halo is rounded DOWN to even (with a warning). ng_wide = nghost + bt_halo must be <= min(nx_phys, ny_phys) (fail-loud: the wide halo must fit inside the local domain).

Arguments

Type IntentOptional Attributes Name
type(ocean_dyn_t), intent(inout) :: dyn

Dynamics state; bt_halo must be set before calling.

type(hgrid_t), intent(in) :: grid

Normal-width grid for this subdomain.

real(kind=wp), intent(in) :: dx

Cell spacing (m for Cartesian; deg for spherical).

real(kind=wp), intent(in) :: dy

Cell spacing (m for Cartesian; deg for spherical).

real(kind=wp), intent(in) :: lon_west

Spherical-grid parameters (ignored for Cartesian).

real(kind=wp), intent(in) :: lat_south

Spherical-grid parameters (ignored for Cartesian).

real(kind=wp), intent(in) :: rad_earth

Spherical-grid parameters (ignored for Cartesian).

character(len=*), intent(in) :: grid_config_str

Grid-config string (e.g. “cartesian”, “spherical”).

real(kind=wp), intent(in) :: f_0

Beta-plane Coriolis parameters.

real(kind=wp), intent(in) :: beta

Beta-plane Coriolis parameters.

real(kind=wp), intent(in) :: y_ref

Beta-plane Coriolis parameters.

character(len=*), intent(in) :: coriolis_scheme_str

Coriolis-scheme string (e.g. “beta_plane”).

real(kind=wp), intent(in), optional :: omega

Planetary rotation rate (1/s) for coriolis_scheme = "planetary" (&ocean_grid_nml omega). Absent => 0, which is only right for the beta plane: the wide clone’s planetary f used to be built with omega = 0, i.e. a non-rotating barotropic fast loop.


Calls

proc~~ocean_dyn_enable_bt_wide~~CallsGraph proc~ocean_dyn_enable_bt_wide ocean_dyn_enable_bt_wide proc~bt_wide_enter_data bt_wide_t%bt_wide_enter_data proc~ocean_dyn_enable_bt_wide->proc~bt_wide_enter_data proc~bt_wide_init bt_wide_t%bt_wide_init proc~ocean_dyn_enable_bt_wide->proc~bt_wide_init proc~parse_coriolis_scheme parse_coriolis_scheme proc~ocean_dyn_enable_bt_wide->proc~parse_coriolis_scheme proc~parse_grid_config parse_grid_config proc~ocean_dyn_enable_bt_wide->proc~parse_grid_config to_string to_string proc~ocean_dyn_enable_bt_wide->to_string warning warning proc~ocean_dyn_enable_bt_wide->warning proc~bt_wide_enter_data_impl bt_wide_enter_data_impl proc~bt_wide_enter_data->proc~bt_wide_enter_data_impl f_centre_scratch f_centre_scratch proc~bt_wide_init->f_centre_scratch proc~grid_init hgrid_t%grid_init proc~bt_wide_init->proc~grid_init proc~metrics_fill_cartesian metrics_fill_cartesian proc~bt_wide_init->proc~metrics_fill_cartesian proc~metrics_fill_coriolis metrics_fill_coriolis proc~bt_wide_init->proc~metrics_fill_coriolis proc~metrics_fill_spherical metrics_fill_spherical proc~bt_wide_init->proc~metrics_fill_spherical proc~metrics_finalize metrics_finalize proc~bt_wide_init->proc~metrics_finalize proc~ocean_metrics_enter_data ocean_metrics_t%ocean_metrics_enter_data proc~bt_wide_enter_data_impl->proc~ocean_metrics_enter_data proc~adcroft_recip adcroft_recip proc~metrics_finalize->proc~adcroft_recip proc~ocean_metrics_enter_data_impl ocean_metrics_enter_data_impl proc~ocean_metrics_enter_data->proc~ocean_metrics_enter_data_impl

Called by

proc~~ocean_dyn_enable_bt_wide~~CalledByGraph proc~ocean_dyn_enable_bt_wide ocean_dyn_enable_bt_wide proc~engine_enter_data engine_enter_data proc~engine_enter_data->proc~ocean_dyn_enable_bt_wide proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_enter_data proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_enter_data 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
integer, private :: bh
integer, private :: cor_scheme
integer, private :: grid_cfg
integer, private :: ng_w

Source Code

   subroutine ocean_dyn_enable_bt_wide(dyn, grid, dx, dy, lon_west, lat_south, &
                                       rad_earth, grid_config_str, &
                                       f_0, beta, y_ref, coriolis_scheme_str, omega)
      !! Allocate, initialise, and GPU-attach the wide-halo shadow state
      !! from `dyn%bt_halo` (already set by the caller).
      !!
      !! Preconditions:
      !!   - `dyn%init` has been called.
      !!   - `dyn%enter_data` has been called (bt_work is on the GPU; we add
      !!     bt_wide to the same GPU context).
      !!   - `dyn%bt_halo > 0`.
      !!
      !! Odd bt_halo is rounded DOWN to even (with a warning).
      !! ng_wide = nghost + bt_halo must be <= min(nx_phys, ny_phys)
      !! (fail-loud: the wide halo must fit inside the local domain).
      type(ocean_dyn_t), intent(inout) :: dyn
         !! Dynamics state; `bt_halo` must be set before calling.
      type(hgrid_t), intent(in) :: grid
         !! Normal-width grid for this subdomain.
      real(wp), intent(in) :: dx, dy
         !! Cell spacing (m for Cartesian; deg for spherical).
      real(wp), intent(in) :: lon_west, lat_south, rad_earth
         !! Spherical-grid parameters (ignored for Cartesian).
      character(len=*), intent(in) :: grid_config_str
         !! Grid-config string (e.g. "cartesian", "spherical").
      real(wp), intent(in) :: f_0, beta, y_ref
         !! Beta-plane Coriolis parameters.
      character(len=*), intent(in) :: coriolis_scheme_str
         !! Coriolis-scheme string (e.g. "beta_plane").
      real(wp), intent(in), optional :: omega
         !! Planetary rotation rate (1/s) for `coriolis_scheme = "planetary"`
         !! (`&ocean_grid_nml omega`).  Absent => 0, which is only right for
         !! the beta plane: the wide clone's planetary f used to be built
         !! with omega = 0, i.e. a non-rotating barotropic fast loop.

      integer :: bh, ng_w, grid_cfg, cor_scheme

      bh = dyn%bt_halo
      if (bh <= 0) return

      ! Round odd bt_halo down to even.
      if (mod(bh, 2) /= 0) then
         call logger%warning("ocean_dyn_enable_bt_wide: bt_halo="//to_string(bh)// &
                             " is odd; rounding down to "//to_string(bh - 1))
         bh = bh - 1
         dyn%bt_halo = bh
      end if

      ng_w = grid%nghost + bh
      if (ng_w > min(grid%nx_phys, grid%ny_phys)) then
         error stop "ocean_dyn_enable_bt_wide: bt_halo too large — ng_wide exceeds "// &
            "min(nx_phys,ny_phys); reduce bt_halo or increase the domain"
      end if

      grid_cfg = parse_grid_config(grid_config_str)
      cor_scheme = parse_coriolis_scheme(coriolis_scheme_str)

      allocate (dyn%bt_wide)
      dyn%bt_wide%bt_halo = bh
      if (present(omega)) then
         call dyn%bt_wide%init(grid, dx, dy, lon_west, lat_south, rad_earth, &
                               grid_cfg, f_0, beta, y_ref, cor_scheme, omega=omega)
      else
         call dyn%bt_wide%init(grid, dx, dy, lon_west, lat_south, rad_earth, &
                               grid_cfg, f_0, beta, y_ref, cor_scheme)
      end if
      call dyn%bt_wide%enter_data()
   end subroutine ocean_dyn_enable_bt_wide