HaloKeySort Subroutine

public subroutine HaloKeySort(keys, elems, sides, flips, ranks, n)

Heap sort of the halo side list by ascending 64-bit key, permuting the companion arrays alongside the keys. O(n log n), in place; the relative order of equal keys is irrelevant because global side ids are unique.

Arguments

TypeIntentOptionalAttributesName
integer(kind=int64), intent(inout) :: keys(1:n)
integer, intent(inout) :: elems(1:n)
integer, intent(inout) :: sides(1:n)
integer, intent(inout) :: flips(1:n)
integer, intent(inout) :: ranks(1:n)
integer, intent(in) :: n

Calls

proc~~halokeysort~~CallsGraph proc~halokeysort HaloKeySort proc~halosiftdown HaloSiftDown proc~halokeysort->proc~halosiftdown proc~haloswap HaloSwap proc~halokeysort->proc~haloswap proc~halosiftdown->proc~haloswap

Called by

proc~~halokeysort~~CalledByGraph proc~halokeysort HaloKeySort proc~buildhaloexchange_domaindecomposition BuildHaloExchange_DomainDecomposition proc~buildhaloexchange_domaindecomposition->proc~halokeysort

Contents

Source Code


Source Code

  subroutine HaloKeySort(keys,elems,sides,flips,ranks,n)
  !! Heap sort of the halo side list by ascending 64-bit key, permuting the
  !! companion arrays alongside the keys. O(n log n), in place; the relative
  !! order of equal keys is irrelevant because global side ids are unique.
    implicit none
    integer,intent(in) :: n
    integer(int64),intent(inout) :: keys(1:n)
    integer,intent(inout) :: elems(1:n),sides(1:n),flips(1:n),ranks(1:n)
    ! Local
    integer :: i,last

    do i = n/2,1,-1
      call HaloSiftDown(keys,elems,sides,flips,ranks,i,n)
    enddo
    do last = n,2,-1
      call HaloSwap(keys,elems,sides,flips,ranks,1,last)
      call HaloSiftDown(keys,elems,sides,flips,ranks,1,last-1)
    enddo

  endsubroutine HaloKeySort