From 346ff32f252414e04e08ead40f237b0b5d943f52 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 24 Mar 2023 15:33:43 -0400 Subject: [PATCH] Rearranged objects to put id into the swiftest_body type out of the base --- src/base/base_module.f90 | 23 ----------------------- src/collision/collision_module.f90 | 4 +++- src/collision/collision_util.f90 | 2 ++ src/swiftest/swiftest_module.f90 | 4 +++- src/swiftest/swiftest_util.f90 | 5 ++--- 5 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/base/base_module.f90 b/src/base/base_module.f90 index 0a9429dbc..042c53909 100644 --- a/src/base/base_module.f90 +++ b/src/base/base_module.f90 @@ -206,14 +206,6 @@ end subroutine abstract_util_dealloc_object end interface - type, abstract, extends(base_object) :: base_multibody - integer(I4B) :: nbody = 0 !! Number of bodies - integer(I4B), dimension(:), allocatable :: id !! Identifier - contains - procedure :: dealloc => base_util_dealloc_multibody - end type base_multibody - - !> Class definition for the kinship relationships used in bookkeeping multiple collisions bodies in a single time step. type, abstract :: base_kinship end type base_kinship @@ -240,21 +232,6 @@ subroutine base_util_copy_store(self, source) end subroutine base_util_copy_store - subroutine base_util_dealloc_multibody(self) - !! author: David A. Minton - !! - !! Finalize the multibody body object - deallocates all allocatables - implicit none - ! Argument - class(base_multibody), intent(inout) :: self - - self%nbody = 0 - if (allocated(self%id)) deallocate(self%id) - - return - end subroutine base_util_dealloc_multibody - - subroutine base_util_dealloc_param(self) !! author: David A. Minton !! diff --git a/src/collision/collision_module.f90 b/src/collision/collision_module.f90 index 042c67af7..86b3ff76c 100644 --- a/src/collision/collision_module.f90 +++ b/src/collision/collision_module.f90 @@ -97,8 +97,10 @@ module collision !> Class definition for the variables that describe a collection of fragments in barycentric coordinates - type, extends(base_multibody) :: collision_fragments + type, extends(base_object) :: collision_fragments + integer(I4B) :: nbody = 0 !! Number of bodies real(DP) :: mtot !! Total mass of fragments + integer(I4B), dimension(:), allocatable :: id !! Identifier class(base_particle_info), dimension(:), allocatable :: info !! Particle metadata information integer(I4B), dimension(:), allocatable :: status !! An integrator-specific status indicator real(DP), dimension(:,:), allocatable :: rh !! Heliocentric position diff --git a/src/collision/collision_util.f90 b/src/collision/collision_util.f90 index 19a688c8a..9eeb1746f 100644 --- a/src/collision/collision_util.f90 +++ b/src/collision/collision_util.f90 @@ -299,6 +299,8 @@ module subroutine collision_util_dealloc_fragments(self) ! Arguments class(collision_fragments), intent(inout) :: self + self%nbody = 0 + if (allocated(self%id)) deallocate(self%id) if (allocated(self%info)) deallocate(self%info) if (allocated(self%status)) deallocate(self%status) if (allocated(self%rh)) deallocate(self%rh) diff --git a/src/swiftest/swiftest_module.f90 b/src/swiftest/swiftest_module.f90 index 4ac6cb3c3..b4b43b526 100644 --- a/src/swiftest/swiftest_module.f90 +++ b/src/swiftest/swiftest_module.f90 @@ -92,9 +92,11 @@ module swiftest !> An abstract class for a generic collection of Swiftest bodies - type, abstract, extends(base_multibody) :: swiftest_body + type, abstract, extends(base_object) :: swiftest_body !! Superclass that defines the generic elements of a Swiftest particle logical :: lfirst = .true. !! Run the current step as a first + integer(I4B) :: nbody = 0 !! Number of bodies + integer(I4B), dimension(:), allocatable :: id !! Identifier type(swiftest_particle_info), dimension(:), allocatable :: info !! Particle metadata information logical, dimension(:), allocatable :: lmask !! Logical mask used to select a subset of bodies when performing certain operations (drift, kick, accel, etc.) integer(I4B), dimension(:), allocatable :: status !! An integrator-specific status indicator diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index fcf130f83..18b6d22df 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -727,7 +727,8 @@ module subroutine swiftest_util_dealloc_body(self) class(swiftest_body), intent(inout) :: self self%lfirst = .true. - + self%nbody = 0 + if (allocated(self%id)) deallocate(self%id) if (allocated(self%info)) deallocate(self%info) if (allocated(self%status)) deallocate(self%status) if (allocated(self%lmask)) deallocate(self%lmask) @@ -754,8 +755,6 @@ module subroutine swiftest_util_dealloc_body(self) if (allocated(self%omega)) deallocate(self%omega) if (allocated(self%capm)) deallocate(self%capm) - call base_util_dealloc_multibody(self) - return end subroutine swiftest_util_dealloc_body