From e6b176d44c0c4868479f648204bb498411e99b05 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Mon, 25 Oct 2021 13:18:41 -0400 Subject: [PATCH] Fixed quicksort algorithms to properly use pre-sorted index arrays --- src/util/util_sort.f90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/util/util_sort.f90 b/src/util/util_sort.f90 index a3ad9a15c..84371b773 100644 --- a/src/util/util_sort.f90 +++ b/src/util/util_sort.f90 @@ -93,7 +93,8 @@ module pure subroutine util_sort_index_dp(arr, ind) allocate(ind(n)) ind = [(i, i=1, n)] end if - allocate(tmparr, source=arr) + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) call qsort_DP(tmparr, ind) return @@ -221,7 +222,8 @@ module pure subroutine util_sort_index_i4b(arr, ind) allocate(ind(n)) ind = [(i, i=1, n)] end if - allocate(tmparr, source=arr) + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) call qsort_I4B(tmparr, ind) return @@ -348,7 +350,8 @@ module pure subroutine util_sort_index_sp(arr, ind) allocate(ind(n)) ind = [(i, i=1, n)] end if - allocate(tmparr, source=arr) + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) call qsort_SP(tmparr, ind) return