From d710c9a7db81102362c27dd22e463b5836083389 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sun, 8 Jan 2023 17:20:37 -0500 Subject: [PATCH] Fixed allocation bugs --- src/collision/collision_util.f90 | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/collision/collision_util.f90 b/src/collision/collision_util.f90 index d1598c62f..3f90f39c6 100644 --- a/src/collision/collision_util.f90 +++ b/src/collision/collision_util.f90 @@ -366,16 +366,23 @@ module subroutine collision_util_dealloc_basic(self) deallocate(self%fragments) end if - select type(before => self%before) - class is (swiftest_nbody_system) - if (allocated(before%pl)) deallocate(before%pl) - if (allocated(before%tp)) deallocate(before%tp) - end select - select type(after => self%after) - class is (swiftest_nbody_system) - if (allocated(after%pl)) deallocate(after%pl) - if (allocated(after%tp)) deallocate(after%tp) - end select + if (allocated(self%before)) then + select type(before => self%before) + class is (swiftest_nbody_system) + if (allocated(before%pl)) deallocate(before%pl) + if (allocated(before%tp)) deallocate(before%tp) + end select + deallocate(self%before) + end if + + if (allocated(self%after)) then + select type(after => self%after) + class is (swiftest_nbody_system) + if (allocated(after%pl)) deallocate(after%pl) + if (allocated(after%tp)) deallocate(after%tp) + end select + deallocate(self%after) + end if self%L_orbit(:,:) = 0.0_DP self%L_spin(:,:) = 0.0_DP @@ -721,6 +728,7 @@ module subroutine collision_util_snapshot(self, param, nbody_system, t, arg) ! Save the snapshot for posterity call self%save(snapshot) + deallocate(snapshot) case default write(*,*) "collision_util_snapshot requies either 'before' or 'after' passed to 'arg'" end select