mpi_cart_2d Module

cart_setup_2d calls MPI_Dims_create to auto-factor n_ranks() into a 2D grid, creates the Cartesian communicator (with optional periodicity), queries this rank's coords, and derives the axis-neighbour ranks via MPI_Cart_shift before delegating the actual tile sizing to decompose_2d.

Boundary ranks at non-periodic edges receive MPI_PROC_NULL from MPI_Cart_shift, which propagates into decomp_2d_t%x_lo_neighbour etc. halo_exchange_2d (Task 3) relies on MPI standard ยง6.6: Isend/Irecv to MPI_PROC_NULL are silent no-ops, so no special-casing is needed there.

The Cartesian communicator handle is stored in the module-level save variable g_cart and exposed via cart_comm_2d() for use by the halo exchange and any other collective that needs it.

Legacy-MPI note: MPI_Cart_create, MPI_Cart_coords, MPI_Cart_shift, and MPI_Dims_create are not used in the 1D path, so they are not imported in mpi_runtime.F90. We import them directly here. On Windows/MS-MPI (CFD_SOLVER_LEGACY_MPI) the mpi module provides the same symbols with bare-integer handles; the mpi_f08 path uses derived-type handles.



Variables

Type Visibility Attributes Name Initial
integer, private, save :: g_cart = MPI_COMM_NULL
type(MPI_Comm), private, save :: g_cart = MPI_COMM_NULL
logical, private, save :: g_cart_setup = .false.

Functions

public function cart_is_setup() result(yes)

True once cart_setup_2d / setup_decomp_2d has created the Cartesian comm.

Read more…

Arguments

None

Return Value logical

public function cart_comm_2d() result(c)

Return the Cartesian communicator handle.

Read more…

Arguments

None

Return Value integer

public function cart_rank_2d() result(r)

This rank's index within the Cartesian communicator.

Read more…

Arguments

None

Return Value integer


Subroutines

public subroutine cart_setup_2d(nx_global, ny_global, halo_width, periodic_x, periodic_y, d)

Create the Cartesian communicator (dims auto-chosen by MPI_Dims_create) and return this rank's per-rank decomposition.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx_global

Total interior cells in x.

integer, intent(in) :: ny_global

Total interior cells in x. Total interior cells in y.

integer, intent(in) :: halo_width

Total interior cells in x. Total interior cells in y. Ghost-cell layer width (scheme-derived).

logical, intent(in) :: periodic_x

Wrap in x?

logical, intent(in) :: periodic_y

Wrap in x? Wrap in y?

type(decomp_2d_t), intent(out) :: d

Output: per-rank decomposition including local extents

public subroutine setup_decomp_2d(state)

Build the MPI Cartesian decomposition and store it on the state (MPI runs).

Read more…

Arguments

Type IntentOptional Attributes Name
type(solver_state_2d_t), intent(inout) :: state