From 24ad0d628b40f25c65f1542ade4208d2037da1f5 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sat, 28 Aug 2021 13:24:30 -0400 Subject: [PATCH] Fixed array indexing problem when re-indexing the pl-pl encounter lists after a rearray operation. --- src/symba/symba_util.f90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/symba/symba_util.f90 b/src/symba/symba_util.f90 index b8428dd99..51af8159d 100644 --- a/src/symba/symba_util.f90 +++ b/src/symba/symba_util.f90 @@ -418,7 +418,7 @@ module subroutine symba_util_rearray_pl(self, system, param) class(symba_parameters), intent(in) :: param !! Current run configuration parameters ! Internals class(symba_pl), allocatable :: tmp !! The discarded body list. - integer(I4B) :: i, j, k, npl + integer(I4B) :: i, j, k, npl, nencmin logical, dimension(:), allocatable :: lmask class(symba_plplenc), allocatable :: plplenc_old logical :: lencounter @@ -500,8 +500,10 @@ module subroutine symba_util_rearray_pl(self, system, param) call move_alloc(levelm_orig_pl, pl%levelm) call move_alloc(nplenc_orig_pl, pl%nplenc) + ! Re-index the encounter list as the index values may have changed associate(idnew1 => system%plplenc_list%id1, idnew2 => system%plplenc_list%id2, idold1 => plplenc_old%id1, idold2 => plplenc_old%id2) - do k = 1, system%plplenc_list%nenc + nencmin = min(system%plplenc_list%nenc, plplenc_old%nenc) + do k = 1, nencmin if ((idnew1(k) == idold1(k)) .and. (idnew2(k) == idold2(k))) then ! This is an encounter we already know about, so save the old information system%plplenc_list%lvdotr(k) = plplenc_old%lvdotr(k)