The GlobalMap is a datatype used to store descriptors of a one-dimensional domain decomposition for a vector on an MPI communicator. It is defined with three assumptions:
Both the segment displacement and length data are stored in arrays
whose indices run from zero to , where
is the number of MPI
processes on the communicator on which the GlobalMap is defined.
This is done so this information corresponds directly to the MPI process
ID's on whihc the segments reside.
This module contains the definition of the GlobalMap datatype, all-processor and an on-root creation methods (both of which can be used to create a GlobalMap on the local communicator), a creation method to create/propagate a GlobalMap native to a remote communicator, a destruction method, and a variety of query methods.
INTERFACE:
module m_GlobalMap !USES No external modules are used in the declaration section of this module. implicit none private ! exceptPUBLIC TYPES:
public :: GlobalMap ! The class data structure Type GlobalMap integer :: comp_id ! Component ID number integer :: gsize ! the Global size integer :: lsize ! my local size integer,dimension(:),pointer :: counts ! all local sizes integer,dimension(:),pointer :: displs ! PE ordered locations End Type GlobalMapPUBLIC MEMBER FUNCTIONS:
public :: gsize public :: lsize public :: init public :: init_remote public :: clean public :: rank public :: bounds public :: comp_id interface gsize; module procedure gsize_; end interface interface lsize; module procedure lsize_; end interface interface init ; module procedure & initd_, & ! initialize from all PEs initr_ ! initialize from the root end interface interface init_remote; module procedure init_remote_; end interface interface clean; module procedure clean_; end interface interface rank ; module procedure rank_ ; end interface interface bounds; module procedure bounds_; end interface interface comp_id ; module procedure comp_id_ ; end interfaceSEE ALSO:
The MCT module m_MCTWorld for more information regarding component ID numbers.REVISION HISTORY:
21Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code 9Nov00 - J.W. Larson <[email protected]> - added init_remote interface. 26Jan01 - J.W. Larson <[email protected]> - added storage for component ID number GlobalMap%comp_id, and associated method comp_id_()
This routine creates the GlobalMap GMap from distributed data spread across the MPI communicatior associated with the input INTEGER handle comm. The INTEGER input argument comp_id is used to define the MCT component ID for GMap. The input INTEGER argument ln is the number of elements in the local vector segment.
INTERFACE:
subroutine initd_(GMap, comp_id, ln, comm)USES:
use m_mpif90 use m_die implicit noneINPUT PARAMETERS:
integer, intent(in) :: comp_id ! Component ID integer, intent(in) :: ln ! the local size integer, intent(in) :: comm ! f90 MPI communicator ! handleOUTPUT PARAMETERS:
type(GlobalMap), intent(out) :: GMapSEE ALSO:
The MCT module m_MCTWorld for more information regarding component ID numbers.REVISION HISTORY:
21Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This routine creates the GlobalMap GMap, and propagates it to all processes on the communicator associated with the MPI INTEGER handle comm. The input INTEGER arguments comp_id (the MCT component ID number) and lns(:) need only be valid on the process whose rank is equal to root on comm. The array lns(:) should have length equal to the number of processes on comm, and contains the length of each local segment.
INTERFACE:
subroutine initr_(GMap, comp_id, lns, root, comm)USES:
use m_mpif90 use m_die use m_stdio implicit noneINPUT PARAMETERS:
integer, intent(in) :: comp_id ! component ID number integer, dimension(:), intent(in) :: lns ! segment lengths integer, intent(in) :: root ! root process ID integer, intent(in) :: comm ! communicator IDOUTPUT PARAMETERS:
type(GlobalMap), intent(out) :: GMapSEE ALSO:
The MCT module m_MCTWorld for more information regarding component ID numbers.REVISION HISTORY:
29May98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This routine creates and propagates across the local communicator a GlobalMap associated with a remote component. The controlling process in this operation has MPI process ID defined by the input INTEGER argument my_root, and its MPI communinicator is defined by the input INTEGER argument my_comm. The input INTEGER argument remote_npes is the number of MPI processes on the remote component's communicator (which need be valid only on the process my_root). The input the INTEGER array remote_lns(:), and the INTEGER argument remote_comp_id need only be valid on the process whose rank on the communicator my_comm is my_root. The argument remote_lns(:) defines the vector segment length on each process of the remote component's communicator, and the argument remote_comp_id defines the remote component's ID number in the MCT component registry MCTWorld.
INTERFACE:
subroutine init_remote_(GMap, remote_lns, remote_npes, my_root, & my_comm, remote_comp_id)USES:
use m_mpif90 use m_die use m_stdio implicit noneINPUT PARAMETERS:
integer, dimension(:), intent(in) :: remote_lns integer, intent(in) :: remote_npes integer, intent(in) :: my_root integer, intent(in) :: my_comm integer, intent(in) :: remote_comp_idOUTPUT PARAMETERS:
type(GlobalMap), intent(out) :: GMapSEE ALSO:
The MCT module m_MCTWorld for more information regarding component ID numbers.REVISION HISTORY:
8Nov00 - J.W. Larson <[email protected]> - initial prototype 26Jan01 - J.W. Larson <[email protected]> - slight change--remote communicator is replaced by remote component ID number in argument remote_comp_id.
This routine deallocates all allocated memory associated with the input/output GlobalMap argument GMap, and sets to zero all of its statically defined components. The success (failure) of this operation is signified by the zero (non-zero) value of the optional output INTEGER argument stat.
INTERFACE:
subroutine clean_(GMap, stat)USES:
use m_die implicit noneINPUT/OUTPUT PARAMETERS:
type(GlobalMap), intent(inout) :: GMapOUTPUT PARAMETERS:
integer, optional, intent(out) :: statREVISION HISTORY:
21Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code 26Jan01 - J. Larson <[email protected]> incorporated comp_id. 1Mar02 - E.T. Ong <[email protected]> removed the die to prevent crashes and added stat argument.
This INTEGER function returns the length of the local vector segment as defined by the input GlobalMap argument GMap.
INTERFACE:
integer function lsize_(GMap)USES:
implicit noneINPUT PARAMETERS:
type(GlobalMap), intent(in) :: GMapREVISION HISTORY:
21Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This INTEGER function returns the global length of a vector that is decomposed according to the input GlobalMap argument GMap.
INTERFACE:
integer function gsize_(GMap)USES:
implicit noneINPUT PARAMETERS:
type(GlobalMap), intent(in) :: GMapREVISION HISTORY:
21Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This routine uses the input GlobalMap argument GMap to determine the process ID (on the communicator on which GMap was defined) of the vector element with global index i_g. This process ID is returned in the output INTEGER argument rank.
INTERFACE:
subroutine rank_(GMap, i_g, rank)USES:
implicit noneINPUT PARAMETERS:
type(GlobalMap), intent(in) :: GMap integer, intent(in) :: i_gOUTPUT PARAMETERS:
integer, intent(out) :: rankREVISION HISTORY:
5May98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
This routine takes as input a process ID (defined by the input INTEGER argument pe_no), examines the input GlobalMap argument GMap, and returns the global indices for the first and last elements of the segment owned by this process in the output INTEGER arguments lbnd and ubnd, respectively.
INTERFACE:
subroutine bounds_(GMap, pe_no, lbnd, ubnd)USES:
implicit noneINPUT PARAMETERS:
type(GlobalMap), intent(in) :: GMap integer, intent(in) :: pe_noOUTPUT PARAMETERS:
integer, intent(out) :: lbnd integer, intent(out) :: ubndREVISION HISTORY:
30Jan01 - J. Larson <[email protected]> - initial code
This INTEGER query function returns the MCT component ID number stored in the input GlobalMap argument GMap.
INTERFACE:
integer function comp_id_(GMap)USES:
implicit noneINPUT PARAMETERS:
type(GlobalMap), intent(in) :: GMapSEE ALSO:
The MCT module m_MCTWorld for more information regarding component ID numbers.REVISION HISTORY:
25Jan02 - J. Larson <[email protected]> - initial version