diff --git a/src/modules/symba_classes.f90 b/src/modules/symba_classes.f90 index e95c28a73..e059bb33b 100644 --- a/src/modules/symba_classes.f90 +++ b/src/modules/symba_classes.f90 @@ -32,6 +32,7 @@ module symba_classes logical :: lfragmentation = .false. !! Do fragmentation modeling instead of simple merger. character(STRMAX) :: encounter_save = "NONE" !! Indicate if and how encounter data should be saved character(STRMAX) :: fragmentation_save = "NONE" !! Indicate if and how fragmentation data should be saved + logical :: lencounter_save = .false. !! Turns on encounter saving contains procedure :: reader => symba_io_param_reader procedure :: writer => symba_io_param_writer @@ -221,6 +222,8 @@ module symba_classes procedure :: dealloc => symba_util_dealloc_system !! Deallocates all allocatable arrays procedure :: resize_storage => symba_util_resize_storage !! Resizes the encounter history storage object so that it contains enough spaces for the number of snapshots needed procedure :: snapshot => symba_util_take_encounter_snapshot !! Take a minimal snapshot of the system through an encounter + procedure :: start_encounter => symba_io_start_encounter !! Initializes the new encounter and/or fragmentation save file(s) + procedure :: stop_encounter => symba_io_stop_encounter !! Saves the encounter and/or fragmentation data to file(s) final :: symba_util_final_system !! Finalizes the SyMBA nbody system object - deallocates all allocatables end type symba_nbody_system @@ -455,6 +458,20 @@ module subroutine symba_io_param_writer(self, unit, iotype, v_list, iostat, ioms character(len=*), intent(inout) :: iomsg !! Message to pass if iostat /= 0 end subroutine symba_io_param_writer + module subroutine symba_io_start_encounter(self, param, t) + implicit none + class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object + class(symba_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! Current simulation time + end subroutine symba_io_start_encounter + + module subroutine symba_io_stop_encounter(self, param, t) + implicit none + class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object + class(symba_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! Current simulation time + end subroutine symba_io_stop_encounter + module subroutine symba_io_write_discard(self, param) use swiftest_classes, only : swiftest_parameters implicit none @@ -563,8 +580,8 @@ recursive module subroutine symba_step_recur_system(self, param, t, ireci) implicit none class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t - integer(I4B), intent(in) :: ireci !! input recursion level + real(DP), intent(in) :: t !! Current simulation time + integer(I4B), intent(in) :: ireci !! input recursion level end subroutine symba_step_recur_system module subroutine symba_step_reset_system(self, param) diff --git a/src/symba/symba_io.f90 b/src/symba/symba_io.f90 index 59553a11b..641ab7d54 100644 --- a/src/symba/symba_io.f90 +++ b/src/symba/symba_io.f90 @@ -301,6 +301,8 @@ module subroutine symba_io_param_reader(self, unit, iotype, v_list, iostat, ioms iostat = -1 return end if + param%lencounter_save = (param%encounter_save /= "TRAJECTORY") .or. (param%encounter_save /= "CLOSEST") .or. & + (param%fragmentation_save /= "TRAJECTORY") .or. (param%fragmentation_save /= "CLOSEST") ! Call the base method (which also prints the contents to screen) call io_param_reader(param, unit, iotype, v_list, iostat, iomsg) diff --git a/src/symba/symba_step.f90 b/src/symba/symba_step.f90 index f8dca7ff7..7b26f80af 100644 --- a/src/symba/symba_step.f90 +++ b/src/symba/symba_step.f90 @@ -37,10 +37,9 @@ module subroutine symba_step_system(self, param, t, dt) call self%reset(param) lencounter = pl%encounter_check(param, self, dt, 0) .or. tp%encounter_check(param, self, dt, 0) if (lencounter) then - call self%snapshot(param, t) + if (param%lencounter_save) call self%start_encounter(param, t) call self%interp(param, t, dt) - call self%snapshot(param, t+dt) - call self%encounter_history%dump(param) + if (param%lencounter_save) call self%stop_encounter(param, t+dt) else self%irec = -1 call helio_step_system(self, param, t, dt)