Create the secondary subcommunicators
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fieldmat_type), | intent(inout) | :: | self |
subroutine fm_make_subcom_2(self)
use mp, only: split, free_comm, mp_undefined
implicit none
class(fieldmat_type), intent(inout) :: self
integer :: ik, colour
type(comm_type) :: tmp
logical :: has_head_sc
!Make child subcommunicators
do ik=1,self%naky
!Make individual subcom
call self%kyb(ik)%make_subcom_2
enddo
!Now make the supercell head communicator used for field gathers
!/First work out if this proc is the head of any supercells
has_head_sc=.false.
do ik=1,self%naky
has_head_sc=has_head_sc.or.any(self%kyb(ik)%supercells%is_head)
enddo
!/Now split to make a subcom
colour = mp_undefined
!NOTE: Here we assume that the supercell head will always
!have the data we want *but* currently in ky_get_field we don't
!store anything on the procs for which the supercell is local but
!empty. This should really be changed as whilst empty procs don't
!have any field data to calculate they will still need it when
!advancing g etc.
if(has_head_sc.or.self%fm_sub_all%proc0) colour=1
call split(colour,tmp,self%fm_sub_all%id)
if(colour /= mp_undefined) then
!/Store subcom
self%fm_sub_headsc_p0=tmp
endif
end subroutine fm_make_subcom_2