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

Commit

Permalink
Consolidated loops in the potential energy calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Sep 14, 2021
1 parent f44e695 commit 4bfcd59
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/util/util_get_energy_momentum.f90
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,13 @@ subroutine util_get_energy_potential(npl, nplpl, k_plpl, lmask, GMcb, Gmass, mas
pecb(i) = -GMcb * mass(i) / norm2(xb(:,i))
end do

! Do the potential energy between pairs of massive bodies
do concurrent (k = 1:nplpl)
!$omp parallel do default(private) schedule(static)&
!$omp shared(nplpl, k_plpl, xb, mass, Gmass, pepl, lstatpl, lmask)
do k = 1, nplpl
i = k_plpl(1,k)
j = k_plpl(2,k)
lstatpl(k) = (lmask(i) .and. lmask(j))
end do

!$omp parallel do default(private) schedule(static)&
!$omp shared(nplpl, k_plpl, xb, mass, Gmass, pepl, lstatpl)
do k = 1, nplpl
if (lstatpl(k)) then
i = k_plpl(1,k)
j = k_plpl(2,k)
pepl(k) = -(Gmass(i) * mass(j)) / norm2(xb(:, i) - xb(:, j))
else
pepl(k) = 0.0_DP
Expand Down

0 comments on commit 4bfcd59

Please sign in to comment.