diff --git a/src/swiftest/swiftest_io.f90 b/src/swiftest/swiftest_io.f90 index b22e892dd..9eb3bed2c 100644 --- a/src/swiftest/swiftest_io.f90 +++ b/src/swiftest/swiftest_io.f90 @@ -3190,9 +3190,9 @@ module subroutine swiftest_io_initialize_output_file_system(self, nc, param) character(len=2*STRMAX) :: errmsg logical :: fileExists - associate (pl => self%pl, tp => self%tp, npl => self%pl%nbody, ntp => self%tp%nbody) + associate (pl => self%pl, tp => self%tp, npl => self%pl%nbody, ntp => self%tp%nbody, lfirst => self%lfirst_io) nc%file_name = param%outfile - if (self%lfirst) then + if (lfirst) then inquire(file=param%outfile, exist=fileExists) #ifdef COARRAY if (this_image() /= 1) param%out_stat = 'APPEND' @@ -3215,7 +3215,7 @@ module subroutine swiftest_io_initialize_output_file_system(self, nc, param) call nc%initialize(param) end select - self%lfirst = .false. + lfirst = .false. end if end associate diff --git a/src/swiftest/swiftest_module.f90 b/src/swiftest/swiftest_module.f90 index 27cbbbddf..7437c49bc 100644 --- a/src/swiftest/swiftest_module.f90 +++ b/src/swiftest/swiftest_module.f90 @@ -395,7 +395,8 @@ module swiftest logical :: lbeg !! True if this is the beginning of a step. This is used so that test particle steps can be calculated !! separately from massive bodies. Massive body variables are saved at half steps, and passed to !! the test particles - logical :: lfirst = .true. !! Flag to indicate that this is a new run + logical :: lfirst_io = .true. !! Flag to indicate that this is the first time to write to a file + logical :: lfirst_peri = .true. !! Flag to indicate that this is the first pericenter passage contains !> Each integrator will have its own version of the step procedure(abstract_step_system), deferred :: step diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index 7dc5761fc..6659bf69e 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -2368,7 +2368,8 @@ module subroutine swiftest_util_setup_construct_system(nbody_system, param) write(*,*) 'Unkown integrator',param%integrator call base_util_exit(FAILURE,param%display_unit) end select - nbody_system%lfirst = .true. + nbody_system%lfirst_io = .true. + nbody_system%lfirst_peri = .true. allocate(swiftest_particle_info :: nbody_system%cb%info) diff --git a/src/symba/symba_discard.f90 b/src/symba/symba_discard.f90 index 37fc34698..e6b08601e 100644 --- a/src/symba/symba_discard.f90 +++ b/src/symba/symba_discard.f90 @@ -302,17 +302,16 @@ subroutine symba_discard_peri_pl(pl, nbody_system, param) class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters ! Internals - logical, save :: lfirst = .true. logical :: lfirst_orig integer(I4B) :: i character(len=STRMAX) :: timestr, idstr, message lfirst_orig = pl%lfirst - pl%lfirst = lfirst - if (lfirst) then + pl%lfirst = nbody_system%lfirst_peri + if (nbody_system%lfirst_peri) then call pl%get_peri(nbody_system, param) - lfirst = .false. + nbody_system%lfirst_peri = .false. else call pl%get_peri(nbody_system, param) do i = 1, pl%nbody diff --git a/src/whm/whm_step.f90 b/src/whm/whm_step.f90 index e4ea4262d..02812b428 100644 --- a/src/whm/whm_step.f90 +++ b/src/whm/whm_step.f90 @@ -42,7 +42,6 @@ module subroutine whm_step_pl(self, nbody_system, param, t, dt) !! !! Adapted from Hal Levison's Swift routine step_kdk_pl.f !! Adapted from David E. Kaufmann's Swifter routine whm_step_pl.f90 - !logical, save :: lfirst = .true. implicit none ! Arguments class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure