diff --git a/src/helio/helio_kick.f90 b/src/helio/helio_kick.f90 index 1c2fff23e..b1949ac2f 100644 --- a/src/helio/helio_kick.f90 +++ b/src/helio/helio_kick.f90 @@ -17,7 +17,6 @@ module subroutine helio_kick_getacch_pl(self, system, param, t, lbeg) logical, optional, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step associate(cb => system%cb, pl => self, npl => self%nbody) - pl%ah(:,:) = 0.0_DP call pl%accel_int() if (param%loblatecb) then cb%aoblbeg = cb%aobl @@ -52,7 +51,6 @@ module subroutine helio_kick_getacch_tp(self, system, param, t, lbeg) logical, optional, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step associate(tp => self, cb => system%cb, pl => system%pl, npl => system%pl%nbody) - tp%ah(:,:) = 0.0_DP if (present(lbeg)) system%lbeg = lbeg if (system%lbeg) then call tp%accel_int(pl%Gmass(:), pl%xbeg(:,:), npl) @@ -87,6 +85,7 @@ module subroutine helio_kick_vb_pl(self, system, param, t, dt, mask, lbeg) associate(pl => self, npl => self%nbody) if (npl ==0) return + pl%ah(:,:) = 0.0_DP call pl%accel(system, param, t) if (lbeg) then call pl%set_beg_end(xbeg = pl%xh) @@ -123,6 +122,7 @@ module subroutine helio_kick_vb_tp(self, system, param, t, dt, mask, lbeg) associate(tp => self, ntp => self%nbody) if (ntp ==0) return + tp%ah(:,:) = 0.0_DP call tp%accel(system, param, t, lbeg) do concurrent(i = 1:ntp, mask(i)) tp%vb(:, i) = tp%vb(:, i) + tp%ah(:, i) * dt diff --git a/src/symba/symba_kick.f90 b/src/symba/symba_kick.f90 index 0586b2a5f..85d3bb8f3 100644 --- a/src/symba/symba_kick.f90 +++ b/src/symba/symba_kick.f90 @@ -12,16 +12,16 @@ module subroutine symba_kick_pltpenc(self, system, dt, irec, sgn) !! Adapted from Hal Levison's Swift routine symba5_kick.f implicit none ! Arguments - class(symba_pltpenc), intent(in) :: self !! SyMBA pl-tp encounter list object + class(symba_pltpenc), intent(in) :: self !! SyMBA pl-tp encounter list object class(symba_nbody_system), intent(inout) :: system !! SyMBA nbody system object - real(DP), intent(in) :: dt !! step size - integer(I4B), intent(in) :: irec !! Current recursion level - integer(I4B), intent(in) :: sgn !! sign to be applied to acceleration + real(DP), intent(in) :: dt !! step size + integer(I4B), intent(in) :: irec !! Current recursion level + integer(I4B), intent(in) :: sgn !! sign to be applied to acceleration ! Internals - integer(I4B) :: i, irm1, irecl - real(DP) :: r, rr, ri, ris, rim1, r2, ir3, fac, faci, facj + integer(I4B) :: i, irm1, irecl + real(DP) :: r, rr, ri, ris, rim1, r2, ir3, fac, faci, facj real(DP), dimension(NDIM) :: dx - logical :: isplpl, lgoodlevel + logical :: isplpl, lgoodlevel select type(self) class is (symba_plplenc) diff --git a/src/whm/whm_kick.f90 b/src/whm/whm_kick.f90 index 5a0e19fd5..c5a60452a 100644 --- a/src/whm/whm_kick.f90 +++ b/src/whm/whm_kick.f90 @@ -25,7 +25,7 @@ module subroutine whm_kick_getacch_pl(self, system, param, t, lbeg) ah0(:) = whm_kick_getacch_ah0(pl%Gmass(2:npl), pl%xh(:,2:npl), npl-1) do i = 1, npl - pl%ah(:, i) = ah0(:) + pl%ah(:, i) = pl%ah(:, i) + ah0(:) end do call whm_kick_getacch_ah1(cb, pl) @@ -75,13 +75,13 @@ module subroutine whm_kick_getacch_tp(self, system, param, t, lbeg) if (system%lbeg) then ah0(:) = whm_kick_getacch_ah0(pl%Gmass(:), pl%xbeg(:,:), npl) do i = 1, ntp - tp%ah(:, i) = ah0(:) + tp%ah(:, i) = tp%ah(:, i) + ah0(:) end do call tp%accel_int(pl%Gmass(:), pl%xbeg(:,:), npl) else ah0(:) = whm_kick_getacch_ah0(pl%Gmass(:), pl%xend(:,:), npl) do i = 1, ntp - tp%ah(:, i) = ah0(:) + tp%ah(:, i) = tp%ah(:, i) + ah0(:) end do call tp%accel_int(pl%Gmass(:), pl%xend(:,:), npl) end if @@ -200,16 +200,18 @@ module subroutine whm_kick_vh_pl(self, system, param, t, dt, mask, lbeg) associate(pl => self, npl => self%nbody, cb => system%cb) if (npl == 0) return - if (pl%lfirst) then - call pl%h2j(cb) - call pl%accel(system, param, t) - pl%lfirst = .false. - end if if (lbeg) then + if (pl%lfirst) then + call pl%h2j(cb) + pl%ah(:,:) = 0.0_DP + call pl%accel(system, param, t) + pl%lfirst = .false. + end if call pl%set_beg_end(xbeg = pl%xh) else - call pl%set_beg_end(xend = pl%xh) + pl%ah(:,:) = 0.0_DP call pl%accel(system, param, t) + call pl%set_beg_end(xend = pl%xh) end if do concurrent(i = 1:npl, mask(i)) pl%vh(:, i) = pl%vh(:, i) + pl%ah(:, i) * dt @@ -241,10 +243,14 @@ module subroutine whm_kick_vh_tp(self, system, param, t, dt, mask, lbeg) associate(tp => self, ntp => self%nbody) if (ntp == 0) return if (tp%lfirst) then + tp%ah(:,:) = 0.0_DP call tp%accel(system, param, t, lbeg=.true.) tp%lfirst = .false. end if - if (.not.lbeg) call tp%accel(system, param, t, lbeg) + if (.not.lbeg) then + tp%ah(:,:) = 0.0_DP + call tp%accel(system, param, t, lbeg) + end if do concurrent(i = 1:ntp, mask(i)) tp%vh(:, i) = tp%vh(:, i) + tp%ah(:, i) * dt end do diff --git a/src/whm/whm_step.f90 b/src/whm/whm_step.f90 index ae8722ad9..ebcb94e27 100644 --- a/src/whm/whm_step.f90 +++ b/src/whm/whm_step.f90 @@ -54,7 +54,6 @@ module subroutine whm_step_pl(self, system, param, t, dt) if (param%lgr) call pl%gr_pos_kick(param, dth) call pl%j2h(cb) call pl%kick(system, param, t + dt, dth, mask=(pl%status(:) == ACTIVE), lbeg=.false.) - call pl%set_beg_end(xend = pl%xh) end associate return end subroutine whm_step_pl