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
Added interfaces to eucl submodule
  • Loading branch information
daminton committed Apr 4, 2021
1 parent f1da3e5 commit cbcfe2a
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/eucl/eucl.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
submodule (swiftest_classes) s_eucl
use swiftest
contains
module procedure eucl_dist_index_plpl
module subroutine eucl_dist_index_plpl(self)
!! author: Jacob R. Elliott and David A. Minton
!!
!! Turns i,j indices into k index for use in the Euclidean distance matrix
Expand All @@ -11,36 +11,39 @@
!! Mélodie Angeletti, Jean-Marie Bonny, Jonas Koko. Parallel Euclidean distance matrix computation on big datasets *.
!! 2019. hal-0204751
implicit none

! Arguments
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body objec
! Internals
integer(I4B) :: i, j, k, kp, p

associate(npl => self%nbody, num_comparisons => self%num_comparisons)
associate(npl => self%nbody, num_comparisons => self%num_comparisons, k_eucl => self%k_eucl)
num_comparisons = (npl * (npl - 1) / 2) ! number of entries in a strict lower triangle, nplm x npl, minus first column
if (allocated(self%k_eucl)) deallocate(self%k_eucl) ! Reset the index array if it's been set previously
if (allocated(self%irij3)) deallocate(self%irij3)
allocate(self%k_eucl(2, num_comparisons))
allocate(self%irij3(num_comparisons))
associate(k_eucl => self%k_eucl)
!do concurrent(k = 1:num_comparisons) !shared(num_comparisons, k_eucl, npl) local(kp, i, j, p)
do k = 1, num_comparisons
kp = npl * (npl - 1) / 2 - k
p = floor((sqrt(1._DP + 8 * kp) - 1._DP) / 2._DP)
i = k - (npl - 1) * (npl - 2) / 2 + p * (p + 1) / 2 + 1
j = npl - 1 - p
k_eucl(1, k) = i
k_eucl(2, k) = j
end do
end associate
!do concurrent(k = 1:num_comparisons) !shared(num_comparisons, k_eucl, npl) local(kp, i, j, p)
do k = 1, num_comparisons
kp = npl * (npl - 1) / 2 - k
p = floor((sqrt(1._DP + 8 * kp) - 1._DP) / 2._DP)
i = k - (npl - 1) * (npl - 2) / 2 + p * (p + 1) / 2 + 1
j = npl - 1 - p
k_eucl(1, k) = i
k_eucl(2, k) = j
end do
end associate
return

end procedure eucl_dist_index_plpl
end subroutine eucl_dist_index_plpl

module procedure eucl_irij3_plpl
module subroutine eucl_irij3_plpl(self)
!! author: Jacob R. Elliott and David A. Minton
!!
!! Efficient parallel loop-blocking algrorithm for evaluating the Euclidean distance matrix for planet-planet
implicit none
! Arguments
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
! Internals
integer(I4B) :: k, i, j
real(DP), dimension(NDIM) :: dx
real(DP) :: rji2
Expand All @@ -57,7 +60,6 @@
end associate

return
end procedure eucl_irij3_plpl

end subroutine eucl_irij3_plpl

end submodule s_eucl

0 comments on commit cbcfe2a

Please sign in to comment.