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

Commit

Permalink
Fixed bug that was causing the data.nc file to be closed before we we…
Browse files Browse the repository at this point in the history
…re ready
  • Loading branch information
daminton committed Dec 23, 2022
1 parent 3ccde0b commit 45b1064
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/collision/collision_resolve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ module subroutine collision_resolve_plpl(self, nbody_system, param, t, dt, irec)
real(DP) :: Eorbit_before, Eorbit_after
logical :: lplpl_collision
character(len=STRMAX) :: timestr
class(swiftest_parameters), allocatable :: tmp_param
integer(I4B), dimension(2) :: idx_parent !! Index of the two bodies considered the "parents" of the collision
logical :: lgoodcollision
integer(I4B) :: i, loop, ncollisions
Expand Down Expand Up @@ -533,7 +532,6 @@ module subroutine collision_resolve_plpl(self, nbody_system, param, t, dt, irec)
trim(adjustl(timestr)))
call swiftest_io_log_one_message(COLLISION_LOG_OUT, "***********************************************************" // &
"***********************************************************")
allocate(tmp_param, source=param)

do i = 1, ncollisions
idx_parent(1) = pl%kin(idx1(i))%parent
Expand All @@ -555,15 +553,14 @@ module subroutine collision_resolve_plpl(self, nbody_system, param, t, dt, irec)
if ((nbody_system%pl_adds%nbody == 0) .and. (nbody_system%pl_discards%nbody == 0)) exit

! Save the add/discard information to file
call nbody_system%write_discard(tmp_param)
call nbody_system%write_discard(param)

! Rearrange the arrays: Remove discarded bodies, add any new bodies, resort, and recompute all indices and encounter lists
call pl%rearray(nbody_system, tmp_param)
call pl%rearray(nbody_system, param)

! Destroy the add/discard list so that we don't append the same body multiple times if another collision is detected
call nbody_system%pl_discards%setup(0, param)
call nbody_system%pl_adds%setup(0, param)
deallocate(tmp_param)

! Check whether or not any of the particles that were just added are themselves in a collision state. This will generate a new plpl_collision
call plpl_encounter%collision_check(nbody_system, param, t, dt, irec, lplpl_collision)
Expand Down
6 changes: 3 additions & 3 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module subroutine fraggle_generate_disruption(collider, nbody_system, param, t)
!!
implicit none
! Arguments
class(collision_fraggle), intent(inout) :: collider
class(collision_fraggle), intent(inout) :: collider
class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
Expand Down Expand Up @@ -102,7 +102,7 @@ module subroutine fraggle_generate_hitandrun(collider, nbody_system, param, t)
!!
implicit none
! Arguments
class(collision_fraggle), intent(inout) :: collider !! Fraggle collision system object
class(collision_fraggle), intent(inout) :: collider !! Fraggle collision system object
class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters with SyMBA additions
real(DP), intent(in) :: t !! Time of collision
Expand Down Expand Up @@ -180,7 +180,7 @@ end subroutine fraggle_generate_hitandrun

module subroutine fraggle_generate_system(self, nbody_system, param, t)
implicit none
class(collision_fraggle), intent(inout) :: self !! Fraggle fragment nbody_system object
class(collision_fraggle), intent(inout) :: self !! Fraggle fragment nbody_system object
class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object
class(base_parameters), intent(inout) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! The time of the collision
Expand Down
5 changes: 3 additions & 2 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2049,8 +2049,9 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i
param%GU = GC / (param%DU2M**3 / (param%MU2KG * param%TU2S**2))


! All reporting of collision information in SyMBA (including mergers) is now recorded in the Fraggle logfile
call swiftest_io_log_start(param, COLLISION_LOG_OUT, "Fraggle logfile")
! A minimal log of collision outcomes is stored in the following log file
! More complete data on collisions is stored in the NetCDF output files
call swiftest_io_log_start(param, COLLISION_LOG_OUT, "Collision logfile")

if ((param%encounter_save /= "NONE") .and. &
(param%encounter_save /= "TRAJECTORY") .and. &
Expand Down

0 comments on commit 45b1064

Please sign in to comment.