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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| 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 |
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