diff --git a/src/encounter/encounter_io.f90 b/src/encounter/encounter_io.f90 index 86a0c60ad..7c3730df2 100644 --- a/src/encounter/encounter_io.f90 +++ b/src/encounter/encounter_io.f90 @@ -23,13 +23,17 @@ module subroutine encounter_io_dump(self, param) ! Internals integer(I4B) :: i - do i = 1, self%nframes if (allocated(self%frame(i)%item)) then select type(snapshot => self%frame(i)%item) class is (encounter_snapshot) param%ioutput = self%tslot(i) call snapshot%write_frame(self%nc,param) + select type(snapshot) ! Be sure to call the base class method to get the regular encounter data sved + class is (fraggle_encounter_snapshot) + call snapshot%encounter_snapshot%write_frame(self%nc,param) + end select + end select else exit diff --git a/src/modules/fraggle_classes.f90 b/src/modules/fraggle_classes.f90 index a45ceb873..581eb1a65 100644 --- a/src/modules/fraggle_classes.f90 +++ b/src/modules/fraggle_classes.f90 @@ -123,8 +123,9 @@ module fraggle_classes end type fraggle_storage type, extends(encounter_snapshot) :: fraggle_encounter_snapshot - class(fraggle_colliders), allocatable :: colliders !! Colliders object at this snapshot - class(fraggle_fragments), allocatable :: fragments !! Fragments object at this snapshot + logical :: lcollision !! Indicates that this snapshot contains at least one collision + class(fraggle_colliders), allocatable :: colliders !! Colliders object at this snapshot + class(fraggle_fragments), allocatable :: fragments !! Fragments object at this snapshot contains procedure :: write_frame => fraggle_io_encounter_write_frame !! Writes a frame of encounter data to file final :: fraggle_util_final_snapshot diff --git a/src/symba/symba_step.f90 b/src/symba/symba_step.f90 index cf2b819e7..9e8f643bd 100644 --- a/src/symba/symba_step.f90 +++ b/src/symba/symba_step.f90 @@ -296,6 +296,7 @@ module subroutine symba_step_reset_system(self, param) call pl%set_renc(0) call system%plplenc_list%setup(nenc_old) ! This resizes the pl-pl encounter list to be the same size as it was the last step, to decrease the number of potential resize operations that have to be one inside the step system%plplenc_list%nenc = 0 ! Sets the true number of encounters back to 0 after resizing + system%plplenc_list%lcollision = .false. end if nenc_old = system%pltpenc_list%nenc @@ -308,6 +309,7 @@ module subroutine symba_step_reset_system(self, param) tp%ldiscard(1:ntp) = .false. call system%pltpenc_list%setup(nenc_old)! This resizes the pl-tp encounter list to be the same size as it was the last step, to decrease the number of potential resize operations that have to be one inside the step system%pltpenc_list%nenc = 0 ! Sets the true number of encounters back to 0 after resizing + system%pltpenc_list%lcollision = .false. end if call system%pl_adds%setup(0, param) diff --git a/src/symba/symba_util.f90 b/src/symba/symba_util.f90 index 0e090601e..ffd077f0e 100644 --- a/src/symba/symba_util.f90 +++ b/src/symba/symba_util.f90 @@ -1296,11 +1296,16 @@ module subroutine symba_util_take_encounter_snapshot(self, param, t) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: t !! current time ! Arguments - type(fraggle_encounter_snapshot) :: snapshot + class(encounter_snapshot), allocatable :: snapshot integer(I4B) :: i, npl_snap, ntp_snap associate(npl => self%pl%nbody, ntp => self%tp%nbody) + if (self%plplenc_list%lcollision) then + allocate(fraggle_encounter_snapshot :: snapshot) + else + allocate(encounter_snapshot :: snapshot) + end if snapshot%t = t snapshot%iloop = param%iloop @@ -1380,10 +1385,11 @@ module subroutine symba_util_take_encounter_snapshot(self, param, t) end select end select - if (self%plplenc_list%lcollision) then + select type(snapshot) + class is (fraggle_encounter_snapshot) allocate(snapshot%colliders, source=self%colliders) allocate(snapshot%fragments, source=self%fragments) - end if + end select ! Save the snapshot call symba_util_save_storage(self,snapshot,t)