tem_treeIDinTotal Function

public function tem_treeIDinTotal(tID, levelDesc, eType) result(elemPos)

Returns the absolute position in the total list of a given treeID opposed to PosOfId, where the relative position in one of the separate lists is returned. Herefore, total list has to be created beforehand.

Arguments

Type IntentOptional Attributes Name
integer(kind=long_k), intent(in) :: tID

the element you are looking for

type(tem_levelDesc_type), intent(in) :: levelDesc

the descriptor you use for searching

integer, intent(in), optional :: eType

element type

Return Value integer

return position of tID in levelDesc%total list


Source Code

  function tem_treeIDinTotal( tID, levelDesc, eType ) result( elemPos )
    ! -------------------------------------------------------------------- !
    !> the element you are looking for
    integer(kind=long_k), intent(in) :: tID
    !> the descriptor you use for searching
    type(tem_levelDesc_type), intent(in) :: levelDesc
    !> element type
    integer, intent(in), optional :: eType
    !> return position of tID in levelDesc%total list
    integer :: elemPos
    ! -------------------------------------------------------------------- !
    integer :: eType_loc
    ! -------------------------------------------------------------------- !

    if( present( eType )) then
      eType_loc = eType
    else
      eType_loc = tem_eTypeOfID( tID, levelDesc%elem )
    end if

    elemPos = 0
    if( eType_loc > 0 ) then
      elemPos = tem_PositionInSorted( me    = levelDesc%total,                 &
        &                             lower = levelDesc%offset(1, eType_loc)+1,&
        &                             upper = levelDesc%offset(2, eType_loc),  &
        &                             val   = tID )
    end if
    elemPos = max( elemPos, 0 )

  end function tem_treeIDinTotal