From feabec73212c85cb41ad2ef20923460ee95af98b Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sun, 5 Feb 2023 19:27:29 -0500 Subject: [PATCH] Fixed potential issue wehre append subroutines might fail if the appended array has 0 size. --- src/swiftest/swiftest_util.f90 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index 05f9383ee..74a795856 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -31,6 +31,8 @@ module subroutine swiftest_util_append_arr_char_string(arr, source, nold, nsrc, if (.not. allocated(source)) return nnew = count(lsource_mask(1:nsrc)) + if (nnew == 0) return + if (.not.allocated(arr)) then allocate(arr(nold+nnew)) else @@ -59,6 +61,8 @@ module subroutine swiftest_util_append_arr_DP(arr, source, nold, nsrc, lsource_m if (.not. allocated(source)) return nnew = count(lsource_mask(1:nsrc)) + if (nnew == 0) return + if (.not.allocated(arr)) then allocate(arr(nold+nnew)) else @@ -87,6 +91,8 @@ module subroutine swiftest_util_append_arr_DPvec(arr, source, nold, nsrc, lsourc if (.not. allocated(source)) return nnew = count(lsource_mask(1:nsrc)) + if (nnew == 0) return + if (.not.allocated(arr)) then allocate(arr(NDIM,nold+nnew)) else @@ -117,6 +123,8 @@ module subroutine swiftest_util_append_arr_I4B(arr, source, nold, nsrc, lsource_ if (.not. allocated(source)) return nnew = count(lsource_mask(1:nsrc)) + if (nnew == 0) return + if (.not.allocated(arr)) then allocate(arr(nold+nnew)) else @@ -146,6 +154,8 @@ module subroutine swiftest_util_append_arr_info(arr, source, nold, nsrc, lsource if (.not. allocated(source)) return nnew = count(lsource_mask(1:nsrc)) + if (nnew == 0) return + if (.not.allocated(arr)) then allocate(arr(nold+nnew)) else @@ -178,6 +188,8 @@ module subroutine swiftest_util_append_arr_kin(arr, source, nold, nsrc, lsource_ if (.not. allocated(source)) return nnew = count(lsource_mask(1:nsrc)) + if (nnew == 0) return + if (.not.allocated(arr)) then allocate(arr(nold+nnew)) else @@ -206,6 +218,8 @@ module subroutine swiftest_util_append_arr_logical(arr, source, nold, nsrc, lsou if (.not. allocated(source)) return nnew = count(lsource_mask(1:nsrc)) + if (nnew == 0) return + if (.not.allocated(arr)) then allocate(arr(nold+nnew)) else