tem_find_depProc Subroutine

public subroutine tem_find_depProc(depProc, nDepProcs, tree, elemPath, PathFirst, PathLast)

Find the partitions holding data on a given path

Using a binary search over the processes first and last elements.

Is the element in question a local or remote element? To look up a certain element by its treeID in the distributed list of elements, it is sufficient to know the splitting positions of all chunks. That is, the first and last treeID of each partition. With a binary search over the splitting positions any requested element can then be identified to be either outside the computational domain at all, or inside of one or several known partitions.

Arguments

Type IntentOptional Attributes Name
integer, intent(out) :: depProc

List of partitions

integer, intent(out) :: nDepProcs

Number of partitions

type(treelmesh_type), intent(in) :: tree

tree information

type(tem_path_type), intent(in) :: elemPath

Element to look up

type(tem_path_type), intent(in) :: PathFirst(:)

Left partition bounds

type(tem_path_type), intent(in) :: PathLast(:)

Right partition bounds


Calls

proc~~tem_find_depproc~~CallsGraph proc~tem_find_depproc tem_find_depProc proc~tem_pathcomparison tem_PathComparison proc~tem_find_depproc->proc~tem_pathcomparison proc~tem_find_depproc_globsearch tem_find_depProc_globSearch proc~tem_find_depproc->proc~tem_find_depproc_globsearch proc~tem_find_depproc_globsearch->proc~tem_pathcomparison

Called by

proc~~tem_find_depproc~~CalledByGraph proc~tem_find_depproc tem_find_depProc proc~identify_elements identify_elements proc~identify_elements->proc~tem_find_depproc proc~identify_elements->proc~identify_elements proc~create_allparentneighbors create_allParentNeighbors proc~identify_elements->proc~create_allparentneighbors proc~identify_stencilneigh identify_stencilNeigh proc~identify_elements->proc~identify_stencilneigh proc~build_levelelements build_levelElements proc~build_levelelements->proc~identify_elements proc~identify_additionalneigh identify_additionalNeigh proc~build_levelelements->proc~identify_additionalneigh proc~create_allparentneighbors->proc~identify_elements proc~create_allparentneighbors->proc~identify_stencilneigh proc~identify_additionalneigh->proc~identify_elements proc~identify_stencilneigh->proc~identify_elements proc~tem_find_allelements tem_find_allElements proc~tem_find_allelements->proc~build_levelelements proc~tem_find_allelements->proc~identify_additionalneigh proc~request_remotehalos request_remoteHalos proc~request_remotehalos->proc~create_allparentneighbors proc~request_remotehalos->proc~identify_stencilneigh proc~tem_create_leveldesc tem_create_levelDesc proc~tem_create_leveldesc->proc~tem_find_allelements proc~communicate_elements communicate_elements proc~communicate_elements->proc~request_remotehalos

Contents

Source Code


Source Code

  subroutine tem_find_depProc( depProc, nDepProcs, tree, elemPath, PathFirst, &
    &                          PathLast )
    ! -------------------------------------------------------------------- !
    !> List of partitions
    integer, intent(out) :: depProc
    !> Number of partitions
    integer, intent(out) :: nDepProcs
    !> tree information
    type(treelmesh_type), intent(in) :: tree
    !> Element to look up
    type(tem_path_type), intent(in) :: elemPath
    !> Left partition bounds
    type(tem_path_type), intent(in) :: PathFirst(:)
    !> Right partition bounds
    type(tem_path_type), intent(in) :: PathLast(:)
    ! -------------------------------------------------------------------- !
    integer :: p_lb, p_ub ! process lower and upper bound
    integer :: relFirst, relLast
    integer :: myRank
    ! -------------------------------------------------------------------- !
    myRank = tree%global%myPart

    nDepProcs = 0
    ! First check if this neighbor is in my local tree range
    p_lb = 1
    ! rank starts from indice 0 where as fortran array pathFirst and
    ! pathLast starts from 1
    relFirst = tem_PathComparison(elemPath, PathFirst(myRank+1))
    relLast = tem_PathComparison(elemPath, PathLast(myRank+1))

    if (relFirst < 0) then
      ! The searched element is definitely left of myself
      ! Do only search up to my own range
      p_ub = myRank
    else
      p_ub = int( min( int(tree%global%nParts, kind=long_k), &
        &             tree%global%nElems ) )
      if (relLast > 0) then
        ! The searched element is definitely right of myself
        ! Do only search beyond my own range
        p_lb = myRank+2
      else

        ! The element might be (partly) on my own partition
        if (relLast < 0) then
          ! The element is at least left of my right border
          ! Set the upper bound to include myself
          p_ub = myRank + 1
        end if
        if (relFirst > 0) then
          ! The element is at least right of my left border
          ! Set the lower bound to include myself
          p_lb = myRank + 1
        end if
      end if ! relLast > 0
    end if ! relFirst < 0

    if ((p_lb == p_ub) .and. (p_lb == myRank+1)) then
      ! The element is local, do not go on to other processes
      nDepProcs = 1
      depProc = myRank+1
    else
      ! Possibly NON-LOCAL Element...
      ! Every process COULD hold a part of the current neighbor element
      call tem_find_depProc_globSearch( depProc   = depProc,   &
        &                               nDepProcs = nDepProcs, &
        &                               elemPath  = elemPath,  &
        &                               p_lb      = p_lb,      &
        &                               p_ub      = p_ub,      &
        &                               PathFirst = PathFirst, &
        &                               PathLast  = PathLast   )
    end if ! local or non-local

  end subroutine tem_find_depProc