Recursive routine to find all actual (eligible) leave nodes in the local partition for a given treeID.
HK: when doing this for the complete domain it would probably better just compute the ID on the finest level along with the information on the level of each leaf, in order to speed up things a little. This way comparison would be just a simple integer comparison.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | Path |
Path to the leaf to find in the array of Elements |
||
integer, | intent(in) | :: | eligible_child(:) |
Candidate childs, which might be considered as neighbors |
||
type(tem_longList), | pointer | :: | ElemList |
linked list of resulting elements building the neighbor |
||
type(tem_path_type), | intent(in) | :: | pathlist(nElems) |
array of paths |
||
integer, | intent(in) | :: | nElems |
number of elements in list |
||
logical, | intent(inout), | optional | :: | otherLevel |
entry is on another level |
recursive subroutine tem_findPath( Path, eligible_child, ElemList, &
& Pathlist, nElems, otherLevel )
! -------------------------------------------------------------------- !
!> Path to the leaf to find in the array of Elements
type(tem_path_type), intent(in) :: Path
!> Candidate childs, which might be considered as neighbors
integer, intent(in) :: 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 paths
type(tem_path_type), intent(in) :: pathlist(nElems)
!> entry is on another level
logical,optional,intent(inout) :: otherLevel
! -------------------------------------------------------------------- !
integer(kind=long_k) :: pos
integer :: i
integer(kind=long_k) :: off
type(tem_path_type) :: childPath
! -------------------------------------------------------------------- !
! binary search of the Path in the array of actual present elements
! Return pos < 0 if
pos = tem_PosOfPath(Path, Pathlist)
! 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 GhostFromFiner, look for childs
if( present( otherLevel ) ) otherLevel = .true.
off = Path%Node(1)*8
do i=1,size(eligible_child)
childPath = tem_pathOf(off + eligible_child(i))
call tem_findPath( childPath, eligible_child, ElemList, &
& Pathlist, nElems, otherLevel)
end do
else ! pos == 0
end if
end subroutine tem_findPath