domain_decomposition_2d Module

Neighbour ranks are supplied by the caller (from MPI_Cart_shift) so this stays pure and unit-testable with synthetic coordinates.



Derived Types

type, public ::  decomp_2d_t

Components

Type Visibility Attributes Name Initial
integer, public :: coord_x = -1
integer, public :: coord_y = -1
integer, public :: dim_x = -1
integer, public :: dim_y = -1
integer, public :: nx_global = -1
integer, public :: ny_global = -1
integer, public :: nx_local = -1
integer, public :: ny_local = -1
integer, public :: ix_first_global = -1
integer, public :: ix_last_global = -1
integer, public :: iy_first_global = -1
integer, public :: iy_last_global = -1
integer, public :: halo_width = -1
integer, public :: x_lo_neighbour = -1
integer, public :: x_hi_neighbour = -1
integer, public :: y_lo_neighbour = -1
integer, public :: y_hi_neighbour = -1
logical, public :: periodic_x = .false.
logical, public :: periodic_y = .false.

Functions

public pure function decompose_2d(coords, dims, nx_global, ny_global, halo_width, periodic_x, periodic_y, x_lo, x_hi, y_lo, y_hi) result(d)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: coords(2)
integer, intent(in) :: dims(2)
integer, intent(in) :: nx_global
integer, intent(in) :: ny_global
integer, intent(in) :: halo_width
logical, intent(in) :: periodic_x
logical, intent(in) :: periodic_y
integer, intent(in) :: x_lo
integer, intent(in) :: x_hi
integer, intent(in) :: y_lo
integer, intent(in) :: y_hi

Return Value type(decomp_2d_t)

public pure function is_decomp_2d_feasible(d) result(ok)

Arguments

Type IntentOptional Attributes Name
type(decomp_2d_t), intent(in) :: d

Return Value logical


Subroutines

private pure subroutine axis_split(coord, dim, n_global, n_local, i_first, i_last)

Split one Cartesian axis (n_global cells across dim process slots) for the slot at coord. Delegates to the shared 1D slab-partition helpers so the per-axis block layout matches the 1D decompose() exactly (single source of truth: domain_decomposition%rank_local_count/rank_first_global).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: coord
integer, intent(in) :: dim
integer, intent(in) :: n_global
integer, intent(out) :: n_local
integer, intent(out) :: i_first
integer, intent(out) :: i_last

public subroutine validate_decomp_2d(d)

Abort with a clear message if either local tile dimension is too small to hold the halo cells the chosen reconstruction scheme requires. Mirrors the 1D validate_decomp; called from the 2D driver right after the decomposition is built (an over-fine MPI process grid, e.g. a thin axis from MPI_Dims_create, would otherwise silently over-read halos).

Arguments

Type IntentOptional Attributes Name
type(decomp_2d_t), intent(in) :: d