comm_t Derived Type

type, public :: comm_t

MPI communicator wrapper type for legacy MPI

Provides object-oriented interface to MPI communicators with type-bound procedures for common operations. Uses integer handles for compatibility with legacy MPI implementations.


Components

Type Visibility Attributes Name Initial
logical, private :: is_valid = .false.

Validity flag

integer, private :: m_comm = MPI_COMM_NULL

Internal MPI communicator (integer handle)

integer(kind=int32), private :: m_rank = -1_int32

Cached rank in this communicator

integer(kind=int32), private :: m_size = -1_int32

Cached size of this communicator


Type-Bound Procedures

procedure, public :: barrier => comm_barrier

Synchronization barrier

  • private subroutine comm_barrier(this)

    Arguments

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

procedure, public :: discard_leader => comm_discard_leader

Create communicator without leader

  • private function comm_discard_leader(this) result(new_comm)

    Arguments

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

    Return Value type(comm_t)

procedure, public :: discard_to => comm_discard_to

Create communicator with first N ranks

  • private function comm_discard_to(this, num_ranks) result(new_comm)

    Arguments

    Type IntentOptional Attributes Name
    class(comm_t), intent(in) :: this
    integer, intent(in) :: num_ranks

    Return Value type(comm_t)

procedure, public :: duplicate => comm_duplicate

Duplicate communicator

  • private function comm_duplicate(this) result(new_comm)

    Arguments

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

    Return Value type(comm_t)

procedure, public :: finalize => comm_finalize

Free communicator resources

  • private subroutine comm_finalize(this)

    Arguments

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

procedure, public :: get => comm_get

Get underlying MPI communicator handle

  • private function comm_get(this) result(mpi_comm_out)

    Arguments

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

    Return Value integer

procedure, public :: is_null => comm_is_null

Check if communicator is null

  • private pure function comm_is_null(this) result(is_null)

    Arguments

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

    Return Value logical

procedure, public :: leader => comm_leader

Check if this rank is leader (rank 0)

  • private pure function comm_leader(this) result(is_leader)

    Arguments

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

    Return Value logical

procedure, public :: rank => comm_rank

Get rank in communicator

  • private pure function comm_rank(this) result(rank)

    Arguments

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

    Return Value integer

procedure, public :: size => m_size_func

Get size of communicator

  • private pure function m_size_func(this) result(size)

    Arguments

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

    Return Value integer

procedure, public :: split => comm_split_shared

Split into shared memory communicators

  • private function comm_split_shared(this) result(new_comm)

    Arguments

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

    Return Value type(comm_t)

procedure, public :: split_by => comm_split_by_color

Split communicator by color

  • private function comm_split_by_color(this, color) result(new_comm)

    Arguments

    Type IntentOptional Attributes Name
    class(comm_t), intent(in) :: this
    integer, intent(in) :: color

    Return Value type(comm_t)

Source Code

   type :: comm_t
   !! MPI communicator wrapper type for legacy MPI
   !!
   !! Provides object-oriented interface to MPI communicators with
   !! type-bound procedures for common operations. Uses integer handles
   !! for compatibility with legacy MPI implementations.
      private
      integer :: m_comm = MPI_COMM_NULL !! Internal MPI communicator (integer handle)
      integer(int32) :: m_rank = -1_int32 !! Cached rank in this communicator
      integer(int32) :: m_size = -1_int32 !! Cached size of this communicator
      logical :: is_valid = .false. !! Validity flag
   contains
      procedure :: rank => comm_rank !! Get rank in communicator
      procedure :: size => m_size_func !! Get size of communicator
      procedure :: leader => comm_leader !! Check if this rank is leader (rank 0)
      procedure :: is_null => comm_is_null !! Check if communicator is null
      procedure :: get => comm_get !! Get underlying MPI communicator handle

      procedure :: barrier => comm_barrier !! Synchronization barrier

      procedure :: split => comm_split_shared !! Split into shared memory communicators
      procedure :: split_by => comm_split_by_color !! Split communicator by color
      procedure :: discard_leader => comm_discard_leader !! Create communicator without leader
      procedure :: discard_to => comm_discard_to !! Create communicator with first N ranks
      procedure :: duplicate => comm_duplicate !! Duplicate communicator

      procedure :: finalize => comm_finalize !! Free communicator resources
   end type comm_t