From 1d41b686d03ae1bb3a2e305245f0dc50df9c58b6 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Wed, 6 Oct 2021 14:50:34 -0400 Subject: [PATCH] Fixed bug that was causing a segfault when n decreased. Moved the allocation of the temporary index array out of the if statement --- src/util/util_index_array.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/util_index_array.f90 b/src/util/util_index_array.f90 index d6b214267..a72ac1b17 100644 --- a/src/util/util_index_array.f90 +++ b/src/util/util_index_array.f90 @@ -22,8 +22,8 @@ module subroutine util_index_array(ind_arr, n) nold = 0 end if + allocate(itmp(n)) if (n >= nold) then - allocate(itmp(n)) if (nold > 0) itmp(1:nold) = ind_arr(1:nold) itmp(nold+1:n) = [(i, i = nold + 1, n)] call move_alloc(itmp, ind_arr)