From 1a3ae148c3c036c7d5379516227b4dcef0dc1aa9 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sun, 15 Jan 2023 08:54:44 -0500 Subject: [PATCH] Fixed bug that happens when there are no plm-plm encounters but there are plm-plt encounters (massive-semi interacting only) --- src/encounter/encounter_check.f90 | 6 +++--- src/swiftest/swiftest_util.f90 | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/encounter/encounter_check.f90 b/src/encounter/encounter_check.f90 index 52b6dfea0..46b712910 100644 --- a/src/encounter/encounter_check.f90 +++ b/src/encounter/encounter_check.f90 @@ -152,15 +152,15 @@ module subroutine encounter_check_all_plplm(param, nplm, nplt, rplm, vplm, rplt, if (plmplt_nenc > 0) then ! Consolidate the two lists allocate(itmp(nenc+plmplt_nenc)) - itmp(1:nenc) = index1(1:nenc) + if (nenc > 0) itmp(1:nenc) = index1(1:nenc) itmp(nenc+1:nenc+plmplt_nenc) = plmplt_index1(1:plmplt_nenc) call move_alloc(itmp, index1) allocate(itmp(nenc+plmplt_nenc)) - itmp(1:nenc) = index2(1:nenc) + if (nenc > 0) itmp(1:nenc) = index2(1:nenc) itmp(nenc+1:nenc+plmplt_nenc) = plmplt_index2(1:plmplt_nenc) + nplm ! Be sure to shift these indices back to their natural range call move_alloc(itmp, index2) allocate(ltmp(nenc+plmplt_nenc)) - ltmp(1:nenc) = lvdotr(1:nenc) + if (nenc > 0) ltmp(1:nenc) = lvdotr(1:nenc) ltmp(nenc+1:nenc+plmplt_nenc) = plmplt_lvdotr(1:plmplt_nenc) call move_alloc(ltmp, lvdotr) nenc = nenc + plmplt_nenc diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index ecd3708ed..c1efe888f 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -1869,21 +1869,21 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) call plplenc_old%copy(nbody_system%plpl_encounter) end if - ! ! Re-build the encounter list - ! ! Be sure to get the level info if this is a SyMBA nbody_system - ! select type(nbody_system) - ! class is (symba_nbody_system) - ! select type(pl) - ! class is (symba_pl) - ! select type(tp) - ! class is (symba_tp) - ! lencounter = pl%encounter_check(param, nbody_system, param%dt, nbody_system%irec) - ! if (tp%nbody > 0) then - ! lencounter = tp%encounter_check(param, nbody_system, param%dt, nbody_system%irec) - ! end if - ! end select - ! end select - ! end select + ! Re-build the encounter list + ! Be sure to get the level info if this is a SyMBA nbody_system + select type(nbody_system) + class is (symba_nbody_system) + select type(pl) + class is (symba_pl) + select type(tp) + class is (symba_tp) + lencounter = pl%encounter_check(param, nbody_system, param%dt, nbody_system%irec) + if (tp%nbody > 0) then + lencounter = tp%encounter_check(param, nbody_system, param%dt, nbody_system%irec) + end if + end select + end select + end select ! Re-index the encounter list as the index values may have changed if (nenc_old > 0) then