A routine to split a subcommunicator into sub-groups based on each procs specific colour "col" and ranked by key. The sub communicator's handle is passed back in new_comm
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | col |
Processors colour |
||
integer, | intent(in) | :: | key |
Processors key, used to determine rank |
||
type(comm_type), | intent(out) | :: | new_comm |
The new sub communicator's handle |
||
integer, | intent(in) | :: | sub |
Subcommunicator to split |
subroutine split_key_to_commtype_sub (col,key,new_comm,sub)
implicit none
integer, intent(in) :: col !< Processors colour
integer, intent(in) :: key !< Processors key, used to determine rank
type(comm_type), intent(out) :: new_comm !< The new sub communicator's handle
integer, intent(in) :: sub !< Subcommunicator to split
# ifdef MPI
integer :: ierror
# endif
integer :: comm_id, nproc
# ifdef MPI
!$OMP MASTER
call time_message(.false., time_mp_other, ' MPI Overheads')
!$OMP END MASTER
!Split the comm group
call mpi_comm_split(sub,col,key,comm_id,ierror)
!$OMP MASTER
call time_message(.false., time_mp_other, ' MPI Overheads')
!$OMP END MASTER
!If the resulting communicator is the null communicator then
!just return the default type with the appropriate id.
if(comm_id == mp_comm_null) then
new_comm%id = comm_id
return
end if
# else
UNUSED_DUMMY(col); UNUSED_DUMMY(key); UNUSED_DUMMY(sub)
comm_id = mp_comm_null
# endif
new_comm%id=comm_id
call nproc_comm(comm_id,nproc)
new_comm%nproc=nproc
call rank_comm(comm_id,nproc)
new_comm%iproc=nproc
new_comm%proc0=new_comm%iproc.eq.0
end subroutine split_key_to_commtype_sub