Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed allocation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jan 8, 2023
1 parent a237141 commit d710c9a
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/collision/collision_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d710c9a

Please sign in to comment.