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

Commit

Permalink
Changed the types of npl/nplm to be 8-byte integers in order to handl…
Browse files Browse the repository at this point in the history
…e situations in which nplpl/nplplm are higher than the maximum 4-byte integer value
  • Loading branch information
daminton committed Nov 12, 2021
1 parent 145d5e5 commit 4502dab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/symba/symba_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ module subroutine symba_util_flatten_eucl_plpl(self, param)
class(symba_pl), intent(inout) :: self !! SyMBA massive body object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I8B) :: k
integer(I4B) :: i, j, npl, nplm, err
integer(I8B) :: k, npl, nplm
integer(I4B) :: i, j, err

associate(pl => self, nplpl => self%nplpl, nplplm => self%nplplm)
npl = int(self%nbody, kind=I8B)
Expand All @@ -411,16 +411,16 @@ module subroutine symba_util_flatten_eucl_plpl(self, param)
end select
nplm = count(.not. pl%lmtiny(1:npl))
pl%nplm = int(nplm, kind=I4B)
nplpl = (npl * (npl - 1) / 2) ! number of entries in a strict lower triangle, npl x npl, minus first column
nplplm = nplm * npl - nplm * (nplm + 1) / 2 ! number of entries in a strict lower triangle, npl x npl, minus first column including only mutually interacting bodies
nplpl = (npl * (npl - 1_I8B)) / 2_I8B ! number of entries in a strict lower triangle, npl x npl, minus first column
nplplm = nplm * npl - nplm * (nplm + 1_I8B) / 2_I8B ! number of entries in a strict lower triangle, npl x npl, minus first column including only mutually interacting bodies
if (param%lflatten_interactions) then
if (allocated(self%k_plpl)) deallocate(self%k_plpl) ! Reset the index array if it's been set previously
allocate(self%k_plpl(2, nplpl), stat=err)
if (err /= 0) then ! An error occurred trying to allocate this big array. This probably means it's too big to fit in memory, and so we will force the run back into triangular mode
param%lflatten_interactions = .false.
else
do concurrent (i=1:npl, j=1:npl, j>i)
call util_flatten_eucl_ij_to_k(npl, i, j, k)
call util_flatten_eucl_ij_to_k(self%nbody, i, j, k)
self%k_plpl(1, k) = i
self%k_plpl(2, k) = j
end do
Expand Down
8 changes: 4 additions & 4 deletions src/util/util_flatten.f90
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ module subroutine util_flatten_eucl_plpl(self, param)
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: i, j, npl, err
integer(I8B) :: k
integer(I4B) :: i, j, err
integer(I8B) :: k, npl

npl = int(self%nbody, kind=I8B)
associate(nplpl => self%nplpl)
nplpl = (npl * (npl - 1) / 2) ! number of entries in a strict lower triangle, npl x npl
nplpl = npl * (npl - 1_I8B) / 2_I8B ! number of entries in a strict lower triangle, npl x npl
if (param%lflatten_interactions) then
if (allocated(self%k_plpl)) deallocate(self%k_plpl) ! Reset the index array if it's been set previously
allocate(self%k_plpl(2, nplpl), stat=err)
if (err /=0) then ! An error occurred trying to allocate this big array. This probably means it's too big to fit in memory, and so we will force the run back into triangular mode
param%lflatten_interactions = .false.
else
do concurrent (i=1:npl, j=1:npl, j>i)
call util_flatten_eucl_ij_to_k(npl, i, j, k)
call util_flatten_eucl_ij_to_k(self%nbody, i, j, k)
self%k_plpl(1, k) = i
self%k_plpl(2, k) = j
end do
Expand Down

0 comments on commit 4502dab

Please sign in to comment.