This function provides the parent ID of a given tree ID on a given level.
The parent ID on a given level is calculated using the equation \f[ id_{l-1}=\frac{id_{l}-1}{8} \f] in a loop.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | TreeID |
treeID of which the pID is requested |
||
integer, | intent(in) | :: | level |
the level on which the pID is requested |
resulting parent ID
function tem_ParentAtLevel(TreeID, level) result(parentID)
! ---------------------------------------------------------------------------
!> treeID of which the pID is requested
integer(kind=long_k),intent(in) :: TreeID
!> the level on which the pID is requested
integer,intent(in) :: level
!> resulting parent ID
integer(kind=long_k) :: parentID
! ---------------------------------------------------------------------------
integer :: cLevel ! the current level of the tree ID
integer :: iLevel ! level iterator
! ---------------------------------------------------------------------------
parentID = TreeID
cLevel = tem_LevelOf(TreeID)
do iLevel = 1, cLevel-level
! parentID = (parentID - 1) / 8
parentID = ishft( (parentID-1_long_k), -3 )
end do
end function tem_ParentAtLevel