From 704ce2d93fb07235b5d0b747e33895fbc815b6e3 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 11 May 2023 11:06:26 -0400 Subject: [PATCH] Added intermediate local allocatable array to the coarray_collect methods --- src/coarray/coarray_collect.f90 | 16 ++++++++++++---- src/swiftest/swiftest_coarray.f90 | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/coarray/coarray_collect.f90 b/src/coarray/coarray_collect.f90 index 566113a07..0c27e110d 100644 --- a/src/coarray/coarray_collect.f90 +++ b/src/coarray/coarray_collect.f90 @@ -25,6 +25,7 @@ module subroutine coarray_component_collect_DP_arr1D(var,dest_img) integer(I4B) :: i,img, ti, di, istart, iend, nmax integer(I4B), allocatable :: n[:] logical, allocatable :: isalloc[:] + real(DP), dimension(:), allocatable :: vari1 allocate(isalloc[*]) allocate(n[*]) @@ -55,7 +56,8 @@ module subroutine coarray_component_collect_DP_arr1D(var,dest_img) if (this_image() == di) then do img = 1, num_images() if (img /= di) then - call util_append(var, tmp(1:n[img])[img]) + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) n = n + n[img] end if end do @@ -85,6 +87,7 @@ module subroutine coarray_component_collect_DP_arr2D(var,dest_img) integer(I4B) :: i, img, ti, di, ntot, istart, iend, nmax integer(I4B), allocatable :: n1[:], n2[:] logical, allocatable :: isalloc[:] + real(DP), dimension(:,:), allocatable :: vari1 allocate(n1[*]) allocate(n2[*]) @@ -117,7 +120,8 @@ module subroutine coarray_component_collect_DP_arr2D(var,dest_img) if (this_image() == di) then do img = 1, num_images() if (img /= di) then - call util_append(var, tmp(:,:)[img]) + allocate(vari1,source=tmp(:,1:n2[img])[img]) + call util_append(var, vari1) n2 = n2 + n2[img] end if end do @@ -219,6 +223,7 @@ module subroutine coarray_component_collect_I4B_arr1D(var,dest_img) integer(I4B) :: i,img, ti, di, istart, iend, nmax integer(I4B), allocatable :: n[:] logical, allocatable :: isalloc[:] + integer(I4B), dimension(:), allocatable :: vari1 allocate(isalloc[*]) allocate(n[*]) @@ -247,7 +252,8 @@ module subroutine coarray_component_collect_I4B_arr1D(var,dest_img) if (this_image() == di) then do img = 1, num_images() if (img /= di) then - call util_append(var, tmp(1:n[img])[img]) + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) n = n + n[img] end if end do @@ -277,6 +283,7 @@ module subroutine coarray_component_collect_lgt_arr1D(var,dest_img) integer(I4B) :: i,img, ti, di, ntot, istart, iend, nmax integer(I4B), allocatable :: n[:] logical, allocatable :: isalloc[:] + logical, dimension(:), allocatable :: vari1 allocate(isalloc[*]) allocate(n[*]) @@ -305,7 +312,8 @@ module subroutine coarray_component_collect_lgt_arr1D(var,dest_img) if (this_image() == di) then do img = 1, num_images() if (img /= di) then - call util_append(var, tmp(1:n[img])[img]) + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) n = n + n[img] end if end do diff --git a/src/swiftest/swiftest_coarray.f90 b/src/swiftest/swiftest_coarray.f90 index e35d3d838..e97488a0f 100644 --- a/src/swiftest/swiftest_coarray.f90 +++ b/src/swiftest/swiftest_coarray.f90 @@ -510,6 +510,7 @@ module subroutine swiftest_coarray_component_collect_info_arr1D(var,dest_img) integer(I4B) :: i,img, ti, di, ntot, istart, iend, nmax integer(I4B), allocatable :: n[:] logical, allocatable :: isalloc[:] + type(swiftest_particle_info), dimension(:), allocatable :: vari1 allocate(isalloc[*]) allocate(n[*]) @@ -538,7 +539,8 @@ module subroutine swiftest_coarray_component_collect_info_arr1D(var,dest_img) if (this_image() == di) then do img = 1, num_images() if (img /= di) then - call util_append(var, tmp(1:n[img])[img]) + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) n = n + n[img] end if end do