diff --git a/src/encounter/encounter_check.f90 b/src/encounter/encounter_check.f90 index 360c01113..a669855ca 100644 --- a/src/encounter/encounter_check.f90 +++ b/src/encounter/encounter_check.f90 @@ -924,7 +924,7 @@ module pure subroutine encounter_check_sort_aabb_1D(self, n, extent_arr) call util_sort(extent_arr, self%ind) - do concurrent(k = 1_I8B:2_I8B*n) + do concurrent(k = 1_I8B:2_I8B * n) i = self%ind(k) if (i <= n) then self%ibeg(i) = k @@ -1072,7 +1072,7 @@ module subroutine encounter_check_sweep_aabb_single_list(self, n, x, v, renc, dt logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical array indicating which pairs are approaching ! Internals integer(I4B) :: ii, i - integer(I8B) :: k + integer(I8B) :: k, itmp logical, dimension(n) :: loverlap logical, dimension(n) :: lencounteri integer(I4B), dimension(:), allocatable :: ext_ind_true @@ -1129,6 +1129,13 @@ module subroutine encounter_check_sweep_aabb_single_list(self, n, x, v, renc, dt call encounter_check_collapse_ragged_list(lenc, n, nenc, index1, index2, lvdotr) + ! By convention, we always assume that index1 < index2, and so we must swap any that are out of order + do concurrent(k = 1_I8B:nenc, index1(k) > index2(k)) + itmp = index1(k) + index1(k) = index2(k) + index2(k) = itmp + end do + call encounter_check_remove_duplicates(n, nenc, index1, index2, lvdotr) return