From 4502dab5cecdc104b09c45d9b0761dc989d90deb Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 12 Nov 2021 15:25:00 -0500 Subject: [PATCH] Changed the types of npl/nplm to be 8-byte integers in order to handle situations in which nplpl/nplplm are higher than the maximum 4-byte integer value --- src/symba/symba_util.f90 | 10 +++++----- src/util/util_flatten.f90 | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/symba/symba_util.f90 b/src/symba/symba_util.f90 index d38106705..5a985faea 100644 --- a/src/symba/symba_util.f90 +++ b/src/symba/symba_util.f90 @@ -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) @@ -411,8 +411,8 @@ 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) @@ -420,7 +420,7 @@ module subroutine symba_util_flatten_eucl_plpl(self, param) 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 diff --git a/src/util/util_flatten.f90 b/src/util/util_flatten.f90 index b124d031d..1f6f60fe6 100644 --- a/src/util/util_flatten.f90 +++ b/src/util/util_flatten.f90 @@ -75,12 +75,12 @@ 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) @@ -88,7 +88,7 @@ module subroutine util_flatten_eucl_plpl(self, param) 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