Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Changed whole array operations from (:) to (1:self%nbody) in order to…
Browse files Browse the repository at this point in the history
… only apply operations on valid array elements
  • Loading branch information
daminton committed Aug 18, 2021
1 parent 5fb1e63 commit 55f745d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/util/util_set.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module subroutine util_set_mu_pl(self, cb)
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object

if (self%nbody > 0) self%mu(:) = cb%Gmass + self%Gmass(:)
if (self%nbody > 0) self%mu(1:self%nbody) = cb%Gmass + self%Gmass(1:self%nbody)

return
end subroutine util_set_mu_pl
Expand All @@ -92,7 +92,8 @@ module subroutine util_set_mu_tp(self, cb)
class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object

if (self%nbody > 0) self%mu(:) = cb%Gmass
if (self%nbody == 0) return
self%mu(1:self%nbody) = cb%Gmass

return
end subroutine util_set_mu_tp
Expand All @@ -107,10 +108,10 @@ module subroutine util_set_rhill(self,cb)
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object

if (self%nbody > 0) then
call self%xv2el(cb)
self%rhill(:) = self%a(:) * (self%Gmass(:) / cb%Gmass / 3)**THIRD
end if
if (self%nbody == 0) return

call self%xv2el(cb)
self%rhill(1:self%nbody) = self%a(1:self%nbody) * (self%Gmass(1:self%nbody) / cb%Gmass / 3)**THIRD

return
end subroutine util_set_rhill
Expand All @@ -127,10 +128,10 @@ module subroutine util_set_rhill_approximate(self,cb)
! Internals
real(DP), dimension(:), allocatable :: rh

if (self%nbody > 0) then
rh(:) = .mag. self%xh(:,:)
self%rhill(:) = rh(:) * (self%Gmass(:) / cb%Gmass / 3)**THIRD
end if
if (self%nbody == 0) return

rh(1:self%nbody) = .mag. self%xh(:,1:self%nbody)
self%rhill(1:self%nbody) = rh(1:self%nbody) * (self%Gmass(1:self%nbody) / cb%Gmass / 3)**THIRD

return
end subroutine util_set_rhill_approximate
Expand Down

0 comments on commit 55f745d

Please sign in to comment.