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

Commit

Permalink
Improved coarray outpt handling and preventing runs getting stuck on …
Browse files Browse the repository at this point in the history
…sync
  • Loading branch information
daminton committed Jun 4, 2023
1 parent 650296b commit da21136
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 15 additions & 4 deletions src/swiftest/swiftest_coarray.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,33 @@ module subroutine swiftest_coarray_balance_system(nbody_system, param)
! Internals
integer(I4B), codimension[*], save :: ntp
integer(I4B) :: img,ntp_min, ntp_max
character(len=NAMELEN) :: min_str, max_str, diff_str, ni_str

ntp = nbody_system%tp%nbody
sync all
write(param%display_unit,*) "Checking whether test particles need to be reblanced."
ntp_min = huge(1)
ntp_max = 0
do img = 1, num_images()
if (ntp[img] < ntp_min) ntp_min = ntp[img]
if (ntp[img] > ntp_max) ntp_max = ntp[img]
end do
write(min_str,*) ntp_min
write(max_str,*) ntp_max
write(diff_str,*) ntp_max - ntp_min
write(ni_str,*) num_images()
write(param%display_unit,*) "ntp_min : " // trim(adjustl(min_str))
write(param%display_unit,*) "ntp_max : " // trim(adjustl(max_str))
write(param%display_unit,*) "difference: " // trim(adjustl(diff_str))
if (ntp_max - ntp_min >= num_images()) then
write(param%display_unit,*) trim(adjustl(diff_str)) // ">=" // trim(adjustl(ni_str)) // ": Rebalancing"
call nbody_system%coarray_collect(param)
call nbody_system%coarray_distribute(param)
write(param%display_unit,*) "Rebalancing complete"
else
write(param%display_unit,*) trim(adjustl(diff_str)) // "<" // trim(adjustl(ni_str)) // ": No rebalancing needed"
end if

call flush(param%display_unit)
return
end subroutine swiftest_coarray_balance_system

Expand Down Expand Up @@ -700,15 +713,13 @@ module subroutine swiftest_coarray_distribute_system(nbody_system, param)

write(image_num_char,*) this_image()
write(ntp_num_char,*) nbody_system%tp%nbody
if (this_image() /= 1) sync images(this_image() - 1)
write(param%display_unit,*) "Image " // trim(adjustl(image_num_char)) // " ntp: " // trim(adjustl(ntp_num_char))
if (param%log_output) flush(param%display_unit)
if (this_image() < num_images()) sync images(this_image() + 1)

deallocate(ntp, lspill_list, tmp, cotp)

return
end subroutine swiftest_coarray_distribute_system


end submodule s_swiftest_coarray
end submodule s_swiftest_coarray
6 changes: 3 additions & 3 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ module subroutine swiftest_io_dump_storage(self, param)
associate(nc => self%nc)
#ifdef COARRAY
sync all
if (param%lcoarray .and. (this_image() /= 1)) sync images(this_image() - 1)
write(param%display_unit,*) "File output started"
call iotimer%start()
critical
#endif
call nc%open(param)
do i = 1, self%iframe
Expand All @@ -433,10 +433,10 @@ module subroutine swiftest_io_dump_storage(self, param)
end do
call nc%close()
#ifdef COARRAY
if (param%lcoarray .and. (this_image() < num_images())) sync images(this_image() + 1)
end critical
call iotimer%stop()
call iotimer%report(message="File output :", unit=param%display_unit)
sync all
call iotimer%report(message="File output :", unit=param%display_unit)
#endif
end associate

Expand Down

0 comments on commit da21136

Please sign in to comment.