MpiFx 1.4.0
Data Types | Functions/Subroutines
mpifx_comm_module Module Reference

Contains the extended MPI communicator. More...

Data Types

type  mpifx_comm
 MPI communicator with some additional information. More...
 

Functions/Subroutines

subroutine mpifx_comm_init (self, commid, error)
 Initializes a communicator to contain all processes.
 
subroutine mpifx_comm_split (self, splitkey, rankkey, newcomm, error)
 Creates a new communicators by splitting the old one.
 
subroutine mpifx_comm_split_type (self, splittype, rankkey, newcomm, error)
 Creates a new communicator by splitting the old one applying a given split type.
 
subroutine mpifx_comm_free (self)
 Frees the MPI communicator.
 

Detailed Description

Contains the extended MPI communicator.

Function/Subroutine Documentation

◆ mpifx_comm_free()

subroutine mpifx_comm_module::mpifx_comm_free ( class(mpifx_comm), intent(inout) self)
private

Frees the MPI communicator.

After this call, the passed communicator should not be used any more.

Parameters
selfCommunicator instance.

◆ mpifx_comm_init()

subroutine mpifx_comm_module::mpifx_comm_init ( class(mpifx_comm), intent(out) self,
integer, intent(in), optional commid,
integer, intent(out), optional error )

Initializes a communicator to contain all processes.

Parameters
selfInitialized instance on exit.
commidMPI Communicator ID (default: MPI_COMM_WORLD)
errorError flag on return containing the first error occuring during the calls mpi_comm_size and mpi_comm_rank.

◆ mpifx_comm_split()

subroutine mpifx_comm_module::mpifx_comm_split ( class(mpifx_comm), intent(inout) self,
integer, intent(in) splitkey,
integer, intent(in) rankkey,
class(mpifx_comm), intent(out) newcomm,
integer, intent(out), optional error )
private

Creates a new communicators by splitting the old one.

Parameters
selfCommunicator instance.
splitkeyKey for the splitting. Processes invoking the routine with the same value for splitkey will be belong to the same communicator.
rankkeyIs used to determine the rank of the process in its new communicator. Processes calling the routine with a higher value will have a higher rank in the new communicator.
newcommNew communicator for the given process.
errorOptional error code on return.

Example:

program test_split
  use libmpifx_module
  implicit none

  type(mpifx_comm) :: allproc, groupproc
  integer :: groupsize, mygroup

  call mpifx_init()
  call allproc%init()
  groupsize = allproc%size / 2
  mygroup = allproc%rank / groupsize
  call allproc%split(mygroup, allproc%rank, groupproc)
  write(*, "(3(A,1X,I0,1X))") "ID:", allproc%rank, "SUBGROUP", &
      & mygroup, "SUBGROUP ID", groupproc%rank
  call mpifx_finalize()

end program test_split
See also
MPI documentation (MPI_COMM_SPLIT)

◆ mpifx_comm_split_type()

subroutine mpifx_comm_module::mpifx_comm_split_type ( class(mpifx_comm), intent(inout) self,
integer, intent(in) splittype,
integer, intent(in) rankkey,
class(mpifx_comm), intent(out) newcomm,
integer, intent(out), optional error )
private

Creates a new communicator by splitting the old one applying a given split type.

Parameters
selfCommunicator instance.
splittypeDetermines which ranks to be grouped together. In MPI 3.0, this can only be MPI_COMM_TYPE_SHARED grouping all MPI ranks together that can share memory (usually on a node).
rankkeyIs used to determine the rank of the process in its new communicator. Processes calling the routine with a higher value will have a higher rank in the new communicator.
newcommNew communicator for the given process.
errorOptional error code on return.

Example:

program test_split_type
  use libmpifx_module
  implicit none

  type(mpifx_comm) :: allproc, splitproc

  call mpifx_init()
  call allproc%init()
  call allproc%split_type(MPI_COMM_TYPE_SHARED, allproc%rank, splitproc)
  write(*, "(2(A,1X,I0,1X))") "ID:", allproc%rank, "SPLIT ID", splitproc%rank
  call mpifx_finalize()

end program test_split_type
See also
MPI documentation (MPI_COMM_SPLIT_TYPE)