Create primary (top level) sub communicators
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(supercell_type), | intent(inout) | :: | self |
subroutine sc_make_subcom_1(self)
use mp, only: comm_type, split, free_comm, mp_undefined, sum_allreduce_sub
implicit none
class(supercell_type), intent(inout) :: self
integer :: ic, colour
type(comm_type) :: tmp
!/First make a subcommunicator involving any procs
!which can see this supercell
colour = 0
if(self%is_local) colour = 1
!Here we check if the new subcom has same number of members as
!parent, if so we can carry on using the parent instead
call sum_allreduce_sub(colour, self%parent_sub%id)
if (colour == self%parent_sub%nproc) then
self%sc_sub_all=self%parent_sub
else
colour = mp_undefined
if(self%is_local) colour = 1
call split(colour,tmp,self%parent_sub%id)
!Note we only store the subcom for those procs which will use it
!this ensures an error will occur if we try to use the subcom in
!the wrong place
if(self%is_local)then
self%sc_sub_all=tmp
else
!If we can't see any of this object then
!return
return
endif
endif
!Now make the supercell sub communicators
do ic=1,self%ncell
!Set parent subcom
self%cells(ic)%parent_sub=self%sc_sub_all
enddo
end subroutine sc_make_subcom_1