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 | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(ocean_dyn_t), | intent(inout) | :: | dyn |
Dynamics state; |
||
| 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 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | bh | ||||
| integer, | private | :: | cor_scheme | ||||
| integer, | private | :: | grid_cfg | ||||
| integer, | private | :: | ng_w |
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