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

Commit

Permalink
Fixed potential issue wehre append subroutines might fail if the appe…
Browse files Browse the repository at this point in the history
…nded array has 0 size.
  • Loading branch information
daminton committed Feb 6, 2023
1 parent cb756a4 commit feabec7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/swiftest/swiftest_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit feabec7

Please sign in to comment.