Subsections

1 MCTWorld

1.1 Module m_MCTWorld - MCTWorld Class (Source File: m_MCTWorld.F90)

MCTWorld is a datatype which acts as a component model registry. All models communicating through MCT must participate in initialization of MCTWorld. The single instance of MCTWorld, ThisMCTWorld stores the component id and local and global processor rank of each component. This module contains methods for creating and destroying ThisMCTWorld as well as inquiry functions.


INTERFACE:

 
  module m_MCTWorld
USES:
       use m_List, only : List   ! Support for List components.
 
       implicit none
 
       private   ! except
PUBLIC TYPES:
 
       public :: MCTWorld        ! The MCTWorld  class data structure
 
     type MCTWorld
       integer :: MCT_comm                          ! MCT communicator
       integer :: ncomps	                           ! Total number of components
       integer :: mygrank                           ! Rank of this processor in 
                                                    ! global communicator.
       integer,dimension(:),pointer :: nprocspid	   ! Number of processes 
                                                    ! each component is on (e.g. rank of its
 						   ! local communicator.
       integer,dimension(:,:),pointer :: idGprocid  ! Translate between local component rank
                                                    ! rank in global communicator.
 						   ! idGprocid(modelid,localrank)=globalrank
     end type MCTWorld
PUBLIC DATA MEMBERS:
 
     type(MCTWorld) :: ThisMCTWorld   !  declare the MCTWorld
PUBLIC MEMBER FUNCTIONS:
       public :: initialized          ! Determine if MCT is initialized
       public :: init                 ! Create a MCTWorld
       public :: clean                ! Destroy a MCTWorld
       public :: NumComponents        ! Number of Components in the MCTWorld
       public :: ComponentNumProcs    ! Number of processes owned by a given
                                      ! component
       public :: ComponentToWorldRank ! Given the rank of a process on a 
                                      ! component, return its rank on the 
                                      ! world communicator
       public :: ComponentRootRank    ! Return the rank on the world 
                                      ! communicator of the root process of 
                                      ! a component
       public :: ThisMCTWorld         ! Instantiation of the MCTWorld
 
    
 
     interface initialized ; module procedure &
       initialized_
     end interface
     interface init ; module procedure &
       initd_, &
       initm_, &
       initr_
     end interface
     interface clean ; module procedure clean_ ; end interface
     interface NumComponents ; module procedure &
        NumComponents_ 
     end interface
     interface ComponentNumProcs ; module procedure &
        ComponentNumProcs_ 
     end interface
     interface ComponentToWorldRank ; module procedure &
        ComponentToWorldRank_ 
     end interface
     interface ComponentRootRank ; module procedure &
        ComponentRootRank_ 
     end interface
REVISION HISTORY:
   19Jan01 - R. Jacob <jacob@mcs.anl.gov> - initial prototype
   05Feb01 - J. Larson <larson@mcs.anl.gov> - added query and
             local-to-global mapping services NumComponents, 
             ComponentNumProcs, ComponentToWorldRank, and ComponentRootRank
   08Feb01 - R. Jacob <jacob@mcs.anl.gov> - add mylrank and mygrank
             to datatype
   20Apr01 - R. Jacob <jacob@mcs.anl.gov> - remove allids from
             MCTWorld datatype.  Not needed because component
             ids are always from 1 to number-of-components.
   07Jun01 - R. Jacob <jacob@mcs.anl.gov> - remove myid, mynprocs
             and mylrank from MCTWorld datatype because they are not 
             clearly defined in PCM mode.  Add MCT_comm for future use.
   03Aug01 - E. Ong <eong@mcs.anl.gov> - explicity specify starting
             address in mpi_irecv
   27Nov01 - E. Ong <eong@mcs.anl.gov> - added R. Jacob's version of initd_
             to support PCM mode. 
   15Feb02 - R. Jacob - elminate use of MP_COMM_WORLD.  Use
             argument globalcomm instead.  Create MCT_comm from
             globalcomm

1.1.1 initialized_ - determine if MCTWorld is initialized

This routine may be used to determine whether MCTWorld::init has been called. If not, the user must call init before performing any other MCT library calls.


INTERFACE:

 
  logical function initialized_()
USES:
INPUT PARAMETERS:
REVISION HISTORY:
   01June07 - R. Loy <rloy@mcs.anl.gov> - initial version

1.1.2 initm_ - initialize MCTWorld

Do a distributed init of MCTWorld for the case where a set of processors contains more then one model and the models may not span the set of processors. ncomps is the total number of components in the entire coupled system. globalcomm encompasses all the models (typically this can be MPI_COMM_WORLD). mycomms is an array of MPI communicators, each sized for the appropriate model and myids is a corresponding array of integers containing the model ids for the models on this particular set of processors.

This routine is called once for the models covered by the set of processors.


INTERFACE:

 
  subroutine initm_(ncomps,globalcomm,mycomms,myids)
USES:
       use m_mpif90
       use m_die
       use m_stdio
 
       implicit none
INPUT PARAMETERS:
 
       integer, intent(in)	       :: ncomps          ! number of components
       integer, intent(in)	       :: globalcomm      ! global communicator
       integer, dimension(:),pointer    :: mycomms         ! my communicators
       integer, dimension(:),pointer    :: myids           ! component ids
REVISION HISTORY:
   20Sep07 - T. Craig migrated code from initd routine
   20Sep07 - T. Craig - made mycomms an array

1.1.3 initd_ - initialize MCTWorld

Do a distributed init of MCTWorld using the total number of components ncomps and either a unique integer component id myid or, if more than one model is placed on a processor, an array of integer ids specifying the models myids. Also required is the local communicator mycomm and global communicator globalcomm which encompasses all the models (typically this can be MPI_COMM_WORLD). This routine must be called once by each component (using myid) or component group (using myids).


INTERFACE:

 
  subroutine initd_(ncomps,globalcomm,mycomm,myid,myids)
USES:
       use m_mpif90
       use m_die
       use m_stdio
 
       implicit none
INPUT PARAMETERS:
 
       integer, intent(in)	       :: ncomps          ! number of components
       integer, intent(in)	       :: globalcomm      ! global communicator
       integer, intent(in)	       :: mycomm          ! my communicator
       integer, intent(in),optional     :: myid            ! my component id
       integer, dimension(:),pointer,optional  :: myids    ! component ids
REVISION HISTORY:
   19Jan01 - R. Jacob <jacob@mcs.anl.gov> - initial prototype
   07Feb01 - R. Jacob <jacob@mcs.anl.gov> - non fatal error
             if init is called a second time.
   08Feb01 - R. Jacob <jacob@mcs.anl.gov> - initialize the new
             mygrank and mylrank
   20Apr01 - R. Jacob <jacob@mcs.anl.gov> - remove allids from
             MCTWorld datatype.  Not needed because component
             ids are always from 1 to number-of-components.
   22Jun01 - R. Jacob <jacob@mcs.anl.gov> - move Bcast and init
             of MCTWorld to initr_
   20Sep07 - T. Craig migrated code to new initm routine

1.1.4 initr_ - initialize MCTWorld from global root

Initialize MCTWorld using information valid only on the global root. This is called by initm_ but could also be called by the user for very complex model-processor geometries.


INTERFACE:

 
  subroutine initr_(ncomps,globalcomm,rnprocspid,ridGprocid)
USES:
       use m_mpif90
       use m_die
       use m_stdio
 
       implicit none
INPUT PARAMETERS:
 
       integer, intent(in)                :: ncomps     ! total number of components
       integer, intent(in)                :: globalcomm ! the global communicator
       integer, dimension(:),intent(in)   :: rnprocspid ! number of processors for each component
       integer, dimension(:,:),intent(in) :: ridGprocid ! an array of size (1:ncomps) x (0:Gsize-1) 
 						       ! which maps local ranks to global ranks
                                                        ! it's actually 1:Gsize here
REVISION HISTORY:
   22Jun01 - R. Jacob <jacob@mcs.anl.gov> - initial prototype

1.1.5 clean_ - Destroy a MCTWorld

This routine deallocates the arrays of ThisMCTWorld It also zeros out the integer components.


INTERFACE:

 
     subroutine clean_()
USES:
       use m_die
 
       implicit none
REVISION HISTORY:
   19Jan01 - R. Jacob <jacob@mcs.anl.gov> - initial prototype
   08Feb01 - R. Jacob <jacob@mcs.anl.gov> - clean the new
             mygrank and mylrank
   20Apr01 - R. Jacob <jacob@mcs.anl.gov> - remove allids from
             MCTWorld datatype.  Not needed because component
             ids are always from 1 to number-of-components.
   07Jun01 - R. Jacob <jacob@mcs.anl.gov> - remove myid,mynprocs
             and mylrank.

1.1.6 NumComponents_ - Determine number of components in World.

The function NumComponents_ takes an input MCTWorld argument World, and returns the number of component models present.


INTERFACE:

 
  integer function NumComponents_(World)
USES:
       use m_die
       use m_stdio
 
       implicit none
INPUT PARAMETERS:
 
       type(MCTWorld), intent(in)      :: World
REVISION HISTORY:
   05Feb01 - J. Larson <larson@mcs.anl.gov> - initial version

1.1.7 ComponentNumProcs_ - Number of processes a component owns.

The function ComponentNumProcs_ takes an input MCTWorld argument World, and a component ID comp_id, and returns the number of processes owned by that component.


INTERFACE:

 
  integer function ComponentNumProcs_(World, comp_id)
USES:
       use m_die
       use m_stdio
 
       implicit none
INPUT PARAMETERS:
       type(MCTWorld), intent(in)      :: World
       integer,        intent(in)      :: comp_id
REVISION HISTORY:
   05Feb01 - J. Larson <larson@mcs.anl.gov> - initial version
   07Jun01 - R. Jacob <jacob@mcs.anl.gov> - modify to use
             nprocspid and comp_id instead of World%mynprocs\end{verbatim}
 
%/////////////////////////////////////////////////////////////
 
\mbox{}\hrulefill\ 
 

  \subsubsection{ComponentToWorldRank\_ - Determine rank on COMM\_WORLD.}


  
   The function {\tt ComponentToWorldRank\_} takes an input component ID 
   {\tt comp\_id} and input rank on that component communicator 
   {\tt comp\_rank}, and returns the rank of that process on the world 
   communicator of {\tt MCTWorld}.  
  
\bigskip{\sf INTERFACE:}
\begin{verbatim} 
  integer function ComponentToWorldRank_(comp_rank, comp_id, World)
USES:
       use m_die
       use m_stdio
 
       implicit none
INPUT PARAMETERS:
       integer, intent(in)	     :: comp_rank ! process rank on the communicator
                                                   ! associated with comp_id
       integer, intent(in)	     :: comp_id   ! component id
       type(MCTWorld), intent(in)     :: World     ! World
REVISION HISTORY:
         05Feb01 - J. Larson <larson@mcs.anl.gov> - initial version
         14Jul02 - E. Ong <eong@mcs.anl.gov> - made argument checking required

1.1.8 ComponentRootRank_ - Rank of component root on COMM_WORLD.

The function ComponentRootRank_ takes an input component ID comp_id and input MCTWorld variable World, and returns the global rank of the root of this component.


INTERFACE:

 
  integer function ComponentRootRank_(comp_id, World)
USES:
       use m_die
       use m_stdio
 
       implicit none
INPUT PARAMETERS:
       integer, intent(in)	     :: comp_id   ! component id
       type(MCTWorld), intent(in)     :: World     ! World
REVISION HISTORY:
         05Feb01 - J. Larson <larson@mcs.anl.gov> - initial version
         14Jul02 - E. Ong <eong@mcs.anl.gov> - made argument checking required


jacob@mcs.anl.gov