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

Commit

Permalink
Browse files Browse the repository at this point in the history
Attempt to vectorize encounter check inner loop
  • Loading branch information
daminton committed Apr 13, 2021
1 parent e1be90e commit f3e821d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/rmvs/rmvs_encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,25 @@ module function rmvs_encounter_check_tp(self, cb, pl, dt, rts) result(lencounter
real(DP), dimension(pl%nbody) :: r2crit
logical :: lflag

associate(tp => self, ntp => self%nbody, npl => pl%nbody, rhill => pl%rhill, &
xht => self%xh, vht => self%vh, xbeg => self%xbeg, vbeg => self%vbeg)
associate(tp => self, ntp => self%nbody, npl => pl%nbody, rhill => pl%rhill, xht => self%xh, vht => self%vh, &
xbeg => self%xbeg, vbeg => self%vbeg, status => tp%status, plencP => tp%plencP, nenc => pl%nenc)
r2crit(:) = (rts * rhill(:))**2
tp%plencP(:) = 0
plencP(:) = 0
do j = 1, npl
!$omp simd private(xr,vr,r2,v2,vdotr,lflag)
do i = 1, ntp
if ((tp%status(i) /= ACTIVE).or.(tp%plencP(i) /=0)) cycle
if ((status(i) /= ACTIVE).or.(plencP(i) /= 0)) cycle
xr(:) = xht(:, i) - xbeg(:, j)
vr(:) = vht(:, i) - vbeg(:, j)
r2 = dot_product(xr(:), xr(:))
v2 = dot_product(vr(:), vr(:))
vdotr = dot_product(vr(:), xr(:))
lflag = rmvs_chk_ind(r2, v2, vdotr, dt, r2crit(j))
if (lflag) tp%plencP(i) = j
if (lflag) plencP(i) = j
end do
pl%nenc(j) = count(tp%plencP(:) == j)
nenc(j) = count(plencP(:) == j)
end do
lencounter = any(pl%nenc(:) > 0)
lencounter = any(nenc(:) > 0)
end associate
return
end function rmvs_encounter_check_tp
Expand Down

0 comments on commit f3e821d

Please sign in to comment.