Gather the information on a property from the bit fields of all elements
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_property_type), | intent(out) | :: | Property |
Property to gather |
||
type(tem_prophead_type), | intent(in) | :: | Header |
Header for this property |
||
integer(kind=long_k), | intent(in) | :: | BitField(:) |
The BitField for the properties of all local elements |
||
integer, | intent(in) | :: | comm |
Communicator to act on |
subroutine gather_property(Property, Header, BitField, comm)
! ---------------------------------------------------------------------- !
!> Property to gather
type(tem_property_type), intent(out) :: Property
!> Header for this property
type(tem_prophead_type), intent(in) :: Header
!> The BitField for the properties of all local elements
integer(kind=long_k), intent(in) :: BitField(:)
!> Communicator to act on
integer, intent(in) :: comm
! ---------------------------------------------------------------------- !
integer :: nElems
integer :: iElem, PropElem
integer(kind=long_k) :: myElems
integer :: iError
! ---------------------------------------------------------------------- !
nElems = size(BitField)
! First count the number of local elements with the given property.
Property%nElems = count(btest(BitField, Header%BitPos))
myElems = Property%nElems
Property%Offset = 0
! Calculate offset on each process, by summing the number of elements
! on all lower ranks.
call MPI_Exscan( myElems, Property%Offset, 1, MPI_INTEGER8, MPI_SUM, &
& comm, iError)
! Allocate an array to store the link from the list of elements with this
! property to the list of all elements.
! (Property%ElemID -> tree%treeID)
allocate(Property%ElemID(Property%nElems))
PropElem = 0
do iElem=1,nElems
! Run over all elements.
if (btest(BitField(iElem), Header%BitPos)) then
! If the element has the property, increase the counter for elements
! with this property and store this position for later lookups.
PropElem = PropElem + 1
Property%ElemID(PropElem) = iElem
end if
end do
end subroutine gather_property