diff --git a/src/base/base_module.f90 b/src/base/base_module.f90 index c2b91e6bf..01c111661 100644 --- a/src/base/base_module.f90 +++ b/src/base/base_module.f90 @@ -1054,6 +1054,7 @@ subroutine base_util_spill_arr_char_string(keeps, discards, lspill_list, ldestru nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then @@ -1096,6 +1097,7 @@ subroutine base_util_spill_arr_DP(keeps, discards, lspill_list, ldestructive) nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then @@ -1138,6 +1140,7 @@ subroutine base_util_spill_arr_DPvec(keeps, discards, lspill_list, ldestructive) nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(NDIM, nspill)) else if (size(discards, dim=2) /= nspill) then @@ -1184,6 +1187,7 @@ subroutine base_util_spill_arr_I4B(keeps, discards, lspill_list, ldestructive) nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then @@ -1226,6 +1230,7 @@ subroutine base_util_spill_arr_I8B(keeps, discards, lspill_list, ldestructive) nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then @@ -1268,6 +1273,7 @@ subroutine base_util_spill_arr_logical(keeps, discards, lspill_list, ldestructiv nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index 31b1dc3dd..be98690c3 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -2426,7 +2426,6 @@ module subroutine swiftest_util_setup_body(self, n, param) allocate(self%vb(NDIM, n)) allocate(self%ah(NDIM, n)) allocate(self%ir3h(n)) - allocate(self%aobl(NDIM, n)) allocate(self%isperi(n)) allocate(self%peri(n)) allocate(self%atp(n)) @@ -2465,11 +2464,14 @@ module subroutine swiftest_util_setup_body(self, n, param) self%vb(:,:) = 0.0_DP self%ah(:,:) = 0.0_DP self%ir3h(:) = 0.0_DP - self%aobl(:,:) = 0.0_DP self%isperi(:) = 1 self%peri(:) = 0.0_DP self%atp(:) = 0.0_DP + if (param%loblatecb) then + allocate(self%aobl(NDIM, n)) + self%aobl(:,:) = 0.0_DP + end if if (param%ltides) then allocate(self%atide(NDIM, n)) self%atide(:,:) = 0.0_DP @@ -2996,6 +2998,7 @@ module subroutine swiftest_util_spill_arr_info(keeps, discards, lspill_list, lde nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then @@ -3043,6 +3046,7 @@ module subroutine swiftest_util_spill_arr_kin(keeps, discards, lspill_list, ldes nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then