bt_wide_t Derived Type

type, public :: bt_wide_t

Wide-halo shadow state for the barotropic fast loop.


Inherits

type~~bt_wide_t~~InheritsGraph type~bt_wide_t bt_wide_t type~hgrid_t hgrid_t type~bt_wide_t->type~hgrid_t grid_w type~ocean_metrics_t ocean_metrics_t type~bt_wide_t->type~ocean_metrics_t metrics_w

Inherited by

type~~bt_wide_t~~InheritedByGraph type~bt_wide_t bt_wide_t type~ocean_dyn_t ocean_dyn_t type~ocean_dyn_t->type~bt_wide_t bt_wide type~ocean_state_t ocean_state_t type~ocean_state_t->type~ocean_dyn_t dyn type~ocean_engine_t ocean_engine_t type~ocean_engine_t->type~ocean_state_t state type~ocean_handle_t ocean_handle_t type~ocean_handle_t->type~ocean_state_t state type~ocean_handle_t->type~ocean_engine_t engine

Components

Type Visibility Attributes Name Initial
integer, public :: bt_halo = 0

Requested wide-halo width (cells; even, > 0).

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

Coriolis at wide-grid C-grid corners (nx_w+1, ny_w+1).

type(hgrid_t), public :: grid_w

Wide hgrid_t: nghost = ng_wide.

logical, public :: is_init = .false.

True after init, before destroy.

type(ocean_metrics_t), public :: metrics_w

Metrics built on grid_w via the same formula generator.

integer, public :: ng_wide = 0

Effective ghost width: nghost + bt_halo.

integer, public :: num_cycles = 0

Substeps between grouped wide exchanges: bt_halo / 2.

real(kind=wp), public, allocatable :: w_H_ref(:,:)
real(kind=wp), public, allocatable :: w_eta(:,:)
real(kind=wp), public, allocatable :: w_eta_end(:,:)
real(kind=wp), public, allocatable :: w_eta_new(:,:)
real(kind=wp), public, allocatable :: w_eta_sum(:,:)
real(kind=wp), public, allocatable :: w_force_u(:,:)
real(kind=wp), public, allocatable :: w_force_v(:,:)
real(kind=wp), public, allocatable :: w_ke(:,:)
real(kind=wp), public, allocatable :: w_rem_u(:,:)
real(kind=wp), public, allocatable :: w_rem_v(:,:)
real(kind=wp), public, allocatable :: w_ubt(:,:)
real(kind=wp), public, allocatable :: w_ubt_end(:,:)
real(kind=wp), public, allocatable :: w_ubt_prev(:,:)
real(kind=wp), public, allocatable :: w_ubt_sum(:,:)
real(kind=wp), public, allocatable :: w_uhbt(:,:)
real(kind=wp), public, allocatable :: w_uhbt_sum(:,:)
real(kind=wp), public, allocatable :: w_vbt(:,:)
real(kind=wp), public, allocatable :: w_vbt_end(:,:)
real(kind=wp), public, allocatable :: w_vbt_prev(:,:)
real(kind=wp), public, allocatable :: w_vbt_sum(:,:)
real(kind=wp), public, allocatable :: w_vhbt(:,:)
real(kind=wp), public, allocatable :: w_vhbt_sum(:,:)
real(kind=wp), public, allocatable :: w_zeta(:,:)

Type-Bound Procedures

procedure, public, non_overridable :: bytes => bt_wide_bytes

  • private pure function bt_wide_bytes(this) result(nbytes)

    Counted allocatable footprint of the wide-halo BT shadow state (0 when unallocated, i.e. whenever &ocean_bt_nml bt_halo = 0).

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(in) :: this

    Return Value integer(kind=int64)

procedure, public, non_overridable :: copy_in => bt_wide_copy_in

  • private subroutine bt_wide_copy_in(this, grid, bt_eta, bt_H_ref, bt_ubt, bt_vbt, bt_ubt_prev, bt_vbt_prev, bt_rem_u, bt_rem_v, force_u, force_v)

    Offset-copy normal-width input arrays into the wide shadow arrays. Dispatches to the non-polymorphic _impl body to avoid the class-box GPU descriptor issue (same pattern as enter/exit_data).

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(inout) :: this
    type(hgrid_t), intent(in) :: grid
    real(kind=wp), intent(in) :: bt_eta(grid%nx_total,grid%ny_total)
    real(kind=wp), intent(in) :: bt_H_ref(grid%nx_total,grid%ny_total)
    real(kind=wp), intent(in) :: bt_ubt(grid%nx_total+1,grid%ny_total)
    real(kind=wp), intent(in) :: bt_vbt(grid%nx_total,grid%ny_total+1)
    real(kind=wp), intent(in) :: bt_ubt_prev(grid%nx_total+1,grid%ny_total)
    real(kind=wp), intent(in) :: bt_vbt_prev(grid%nx_total,grid%ny_total+1)
    real(kind=wp), intent(in) :: bt_rem_u(grid%nx_total+1,grid%ny_total)
    real(kind=wp), intent(in) :: bt_rem_v(grid%nx_total,grid%ny_total+1)
    real(kind=wp), intent(in) :: force_u(grid%nx_total+1,grid%ny_total)
    real(kind=wp), intent(in) :: force_v(grid%nx_total,grid%ny_total+1)

procedure, public, non_overridable :: copy_out => bt_wide_copy_out

  • private subroutine bt_wide_copy_out(this, grid, bt_eta, bt_ubt, bt_vbt, bt_uhbt, bt_vhbt, bt_eta_end, bt_ubt_end, bt_vbt_end)

    Offset-copy wide output arrays back to the normal-width arrays. Dispatches to the non-polymorphic _impl body.

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(in) :: this
    type(hgrid_t), intent(in) :: grid
    real(kind=wp), intent(out) :: bt_eta(grid%nx_total,grid%ny_total)
    real(kind=wp), intent(out) :: bt_ubt(grid%nx_total+1,grid%ny_total)
    real(kind=wp), intent(out) :: bt_vbt(grid%nx_total,grid%ny_total+1)
    real(kind=wp), intent(out) :: bt_uhbt(grid%nx_total+1,grid%ny_total)
    real(kind=wp), intent(out) :: bt_vhbt(grid%nx_total,grid%ny_total+1)
    real(kind=wp), intent(out) :: bt_eta_end(grid%nx_total,grid%ny_total)
    real(kind=wp), intent(out) :: bt_ubt_end(grid%nx_total+1,grid%ny_total)
    real(kind=wp), intent(out) :: bt_vbt_end(grid%nx_total,grid%ny_total+1)

procedure, public, non_overridable :: destroy => bt_wide_destroy

  • private subroutine bt_wide_destroy(this)

    Deallocate all wide state.

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(inout) :: this

procedure, public, non_overridable :: enter_data => bt_wide_enter_data

  • private subroutine bt_wide_enter_data(this)

    Attach all wide arrays (and wide metrics leaf arrays) to the GPU present table. The containing ocean_dyn_t is already mapped by the caller; this routine attaches the components.

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(inout) :: this

procedure, public, non_overridable :: entry_exchange => bt_wide_entry_exchange

  • private subroutine bt_wide_entry_exchange(this)

    One wide grouped exchange (eta+ubt+vbt) + wide singles for the other 7 input arrays (H_ref, ubt_prev, rem_u, force_u, vbt_prev, rem_v, force_v). Fills the entire wide ghost band before the fast loop. Counter effect: +1 bt_group, +1 centre_2d, +3 face_x_2d, +3 face_y_2d. Dispatches to the non-polymorphic _impl body.

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(inout) :: this

procedure, public, non_overridable :: exit_data => bt_wide_exit_data

  • private subroutine bt_wide_exit_data(this)

    Detach all wide arrays from the GPU present table.

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(inout) :: this

procedure, public, non_overridable :: init => bt_wide_init

  • private subroutine bt_wide_init(this, grid, dx, dy, lon_west, lat_south, rad_earth, grid_config, f_0, beta, y_ref, coriolis_scheme, omega)

    Allocate the wide shadow state. Builds grid_w (same nx_phys/ny_phys as grid, nghost = grid%nghost + bt_halo), fills wide metrics via the same formula generator, fills wide f_corner. grid_config must be GRID_CONFIG_CARTESIAN or GRID_CONFIG_SPHERICAL; supergrid/tripolar are excluded at configure time.

    Arguments

    Type IntentOptional Attributes Name
    class(bt_wide_t), intent(inout) :: this
    type(hgrid_t), intent(in) :: grid

    Normal-width grid descriptor 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

    South-west corner (used only for spherical; ignored for Cartesian).

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

    South-west corner (used only for spherical; ignored for Cartesian).

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

    Earth radius (m; used only for spherical; ignored for Cartesian).

    integer, intent(in) :: grid_config

    GRID_CONFIG_CARTESIAN or GRID_CONFIG_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.

    integer, intent(in) :: coriolis_scheme

    CORIOLIS_SCHEME_BETA_PLANE or CORIOLIS_SCHEME_PLANETARY.

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

    Planetary rotation rate for the planetary scheme. Absent => 0.

Source Code

   type :: bt_wide_t
      !! Wide-halo shadow state for the barotropic fast loop.
      logical :: is_init = .false.
         !! True after `init`, before `destroy`.
      integer :: bt_halo = 0
         !! Requested wide-halo width (cells; even, > 0).
      integer :: ng_wide = 0
         !! Effective ghost width: `nghost + bt_halo`.
      integer :: num_cycles = 0
         !! Substeps between grouped wide exchanges: `bt_halo / 2`.

      ! Wide grid and metrics.  Same `nx_phys/ny_phys` as the normal grid;
      ! only `nghost` differs (`ng_wide`).
      type(hgrid_t) :: grid_w
         !! Wide hgrid_t: nghost = ng_wide.
      type(ocean_metrics_t) :: metrics_w
         !! Metrics built on `grid_w` via the same formula generator.

      ! Wide Coriolis corners — filled by `metrics_fill_coriolis`.
      real(wp), allocatable :: f_corner_w(:, :)
         !! Coriolis at wide-grid C-grid corners (nx_w+1, ny_w+1).

      ! Wide shadow copies of the 22 fast-loop 2D arrays.
      ! Naming convention: w_<field> mirrors <field> on the wide grid.
      ! Centres (nx_w, ny_w):
      real(wp), allocatable :: w_eta(:, :)
      real(wp), allocatable :: w_H_ref(:, :)
      real(wp), allocatable :: w_eta_new(:, :)
      real(wp), allocatable :: w_ke(:, :)
      real(wp), allocatable :: w_eta_sum(:, :)
      real(wp), allocatable :: w_eta_end(:, :)
      ! East-face u (nx_w+1, ny_w):
      real(wp), allocatable :: w_ubt(:, :)
      real(wp), allocatable :: w_ubt_prev(:, :)
      real(wp), allocatable :: w_rem_u(:, :)
      real(wp), allocatable :: w_ubt_sum(:, :)
      real(wp), allocatable :: w_uhbt_sum(:, :)
      real(wp), allocatable :: w_uhbt(:, :)
      real(wp), allocatable :: w_ubt_end(:, :)
      ! North-face v (nx_w, ny_w+1):
      real(wp), allocatable :: w_vbt(:, :)
      real(wp), allocatable :: w_vbt_prev(:, :)
      real(wp), allocatable :: w_rem_v(:, :)
      real(wp), allocatable :: w_vbt_sum(:, :)
      real(wp), allocatable :: w_vhbt_sum(:, :)
      real(wp), allocatable :: w_vhbt(:, :)
      real(wp), allocatable :: w_vbt_end(:, :)
      ! Corner zeta (nx_w+1, ny_w+1):
      real(wp), allocatable :: w_zeta(:, :)
      ! Wide force arrays (copied in from the normal-width slow tendencies):
      real(wp), allocatable :: w_force_u(:, :)
      real(wp), allocatable :: w_force_v(:, :)

   contains
      procedure, non_overridable :: init => bt_wide_init
      procedure, non_overridable :: enter_data => bt_wide_enter_data
      procedure, non_overridable :: exit_data => bt_wide_exit_data
      procedure, non_overridable :: copy_in => bt_wide_copy_in
      procedure, non_overridable :: entry_exchange => bt_wide_entry_exchange
      procedure, non_overridable :: copy_out => bt_wide_copy_out
      procedure, non_overridable :: destroy => bt_wide_destroy
      procedure, non_overridable :: bytes => bt_wide_bytes
   end type bt_wide_t