MpiFx 1.4.0
Public Member Functions | Public Attributes | List of all members
mpifx_comm_module::mpifx_comm Type Reference

MPI communicator with some additional information. More...

Public Member Functions

procedure init (self, commid, error)
 Initializes the MPI environment.
 
procedure split (self, splitkey, rankkey, newcomm, error)
 Creates a new communicator by splitting the old one.
 
procedure split_type (self, splittype, rankkey, newcomm, error)
 Creates a new communicator by splitting the old one given a split type.
 
procedure free (self)
 Frees the communicator. The communicator should not be used after this.
 

Public Attributes

integer id
 Communicator id.
 
integer size
 Nr. of processes (size).
 
integer rank
 Rank of the current process.
 
integer leadrank
 Index of the lead node.
 
logical lead
 True if current process is the lead (rank == 0).
 

Detailed Description

MPI communicator with some additional information.

Member Function/Subroutine Documentation

◆ free()

procedure mpifx_comm_module::mpifx_comm::free ( class(mpifx_comm), intent(inout) self)

Frees the communicator. The communicator should not be used after this.

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

Parameters
selfCommunicator instance.

◆ init()

procedure mpifx_comm_module::mpifx_comm::init ( class(mpifx_comm), intent(out) self,
integer, intent(in), optional commid,
integer, intent(out), optional error )

Initializes the MPI environment.

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.

◆ split()

procedure 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 )

Creates a new communicator 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)

◆ split_type()

procedure 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 )

Creates a new communicator by splitting the old one given a 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)

The documentation for this type was generated from the following file: