Recursive routine to find all actual (eligible) leave nodes in the local partition for a given treeID. Alternatively use tem_findPath, which uses precomputed paths in the tree and should speed up the search (at the expense of storing the paths beforehand).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k) | :: | TreeID |
TreeID to find in the array of Elements |
|||
integer | :: | eligible_child(:) |
Candidate childs, which might be considered as neighbors |
|||
type(tem_longList), | pointer | :: | ElemList |
linked list of resulting elements building the neighbor |
||
integer(kind=long_k), | intent(in) | :: | treeIDlist(nElems) |
array of treeIDs |
||
integer, | intent(in) | :: | nElems |
number of elements in list |
||
integer(kind=long_k), | intent(in) | :: | Part_First(:) |
parts first entry |
||
integer(kind=long_k), | intent(in) | :: | Part_Last(:) |
parts last entry |
||
logical, | intent(inout), | optional | :: | otherLevel |
entry is on another level |
recursive subroutine tem_findElement( TreeID, eligible_child, ElemList, & & treeIDlist, nElems, Part_First, & & Part_Last, otherLevel ) ! -------------------------------------------------------------------- ! !> TreeID to find in the array of Elements integer(kind=long_k) :: TreeID !> Candidate childs, which might be considered as neighbors integer :: eligible_child(:) !> linked list of resulting elements building the neighbor type(tem_longList), pointer :: ElemList !> number of elements in list integer, intent(in) :: nElems !> array of treeIDs integer(kind=long_k), intent(in) :: treeIDlist(nElems) !> parts first entry integer(kind=long_k), intent(in) :: Part_First(:) !> parts last entry integer(kind=long_k), intent(in) :: Part_Last(:) !> entry is on another level logical,optional,intent(inout) :: otherLevel ! -------------------------------------------------------------------- ! integer(kind=long_k) :: pos integer :: i integer(kind=long_k) :: childID, off ! -------------------------------------------------------------------- ! ! binary search of the ID in the array of actual present elements ! Return pos < 0 if pos = tem_PosOfId(TreeID, treeIDlist) ! If the neighbor is on a level higher than myself, it should be ! delivered by binary search if (pos > 0 ) then ! Element actually exists, append it to the list call append(ElemList, pos) else if (pos < 0) then ! Element is a virtual neighbor, look for childs if( present( otherLevel ) ) otherLevel = .true. off = TreeID*8 do i=1,size(eligible_child) childID = off + eligible_child(i) call tem_findElement( childID, eligible_child, ElemList, & & treeIDlist, nElems, Part_First, Part_Last ) end do end if end if end subroutine tem_findElement