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

Commit

Permalink
Improved messaging by writing to log file instead of terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jan 6, 2023
1 parent 7f133cd commit a543463
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 35 deletions.
1 change: 1 addition & 0 deletions examples/Chambers2013/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*
!.gitignore
!init_cond.py
!aescattermovie.py
2 changes: 1 addition & 1 deletion src/collision/collision_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ module subroutine collision_check_pltp(self, nbody_system, param, t, dt, irec, l
write(message, *) "Particle " // trim(adjustl(tp%info(j)%name)) // " (" // trim(adjustl(idstrj)) // ")" &
// " collided with massive body " // trim(adjustl(pl%info(i)%name)) // " (" // trim(adjustl(idstri)) // ")" &
// " at t = " // trim(adjustl(timestr))
!call swiftest_io_log_one_message(COLLISION_LOG_OUT, message)
call swiftest_io_log_one_message(COLLISION_LOG_OUT, message)
end if
end do

Expand Down
2 changes: 1 addition & 1 deletion src/collision/collision_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module subroutine collision_generate_bounce(self, nbody_system, param, t)
case (COLLRESOLVE_REGIME_MERGE, COLLRESOLVE_REGIME_GRAZE_AND_MERGE)
call self%merge(nbody_system, param, t) ! Use the default collision model, which is merge
case default
write(*,*) "Error in swiftest_collision, unrecognized collision regime"
call swiftest_io_log_one_message(COLLISION_LOG_OUT,"Error in swiftest_collision, unrecognized collision regime")
call util_exit(FAILURE)
end select
end associate
Expand Down
2 changes: 1 addition & 1 deletion src/collision/collision_regime.f90
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ subroutine collision_regime_LS12_SI(Mcb, m1, m2, rad1, rad2, rh1, rh2, vb1, vb2,
regime = COLLRESOLVE_REGIME_SUPERCATASTROPHIC ! supercatastrophic
Qloss = (c_star + 1.0_DP) * U_binding ! Qr - Qr_supercat
else
write(*,*) "Error no regime found in symba_regime"
call swiftest_io_log_one_message(COLLISION_LOG_OUT,"Error no regime found in symba_regime")
end if
end if

Expand Down
5 changes: 2 additions & 3 deletions src/collision/collision_resolve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,8 @@ module subroutine collision_resolve_plpl(self, nbody_system, param, t, dt, irec)

if (.not.lplpl_collision) exit
if (loop == MAXCASCADE) then
write(*,*)
write(*,*) "An runaway collisional cascade has been detected in collision_resolve_plpl."
write(*,*) "Consider reducing the step size or changing the parameters in the collisional model to reduce the number of fragments."
call swiftest_io_log_one_message(COLLISION_LOG_OUT,"An runaway collisional cascade has been detected in collision_resolve_plpl.")
call swiftest_io_log_one_message(COLLISION_LOG_OUT,"Consider reducing the step size or changing the parameters in the collisional model to reduce the number of fragments.")
call util_exit(FAILURE)
end if
end associate
Expand Down
6 changes: 5 additions & 1 deletion src/helio/helio_drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module subroutine helio_drift_body(self, nbody_system, param, dt)
integer(I4B) :: i !! Loop counter
integer(I4B), dimension(:),allocatable :: iflag !! Vectorized error code flag
real(DP), dimension(:), allocatable :: mu
character(len=STRMAX) message

if (self%nbody == 0) return

Expand All @@ -40,7 +41,10 @@ module subroutine helio_drift_body(self, nbody_system, param, dt)
if (any(iflag(1:n) /= 0)) then
where(iflag(1:n) /= 0) self%status(1:n) = DISCARDED_DRIFTERR
do i = 1, n
if (iflag(i) /= 0) write(*, *) " Body ", self%id(i), " lost due to error in Danby drift"
if (iflag(i) /= 0) then
write(message, *) " Body ", self%id(i), " lost due to error in Danby drift"
call swiftest_io_log_one_message(COLLISION_LOG_OUT,message)
end if
end do
end if
end associate
Expand Down
5 changes: 3 additions & 2 deletions src/rmvs/rmvs_discard.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module subroutine rmvs_discard_tp(self, nbody_system, param)
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: i
character(len=STRMAX) :: timestr, idstri, idstrj
character(len=STRMAX) :: timestr, idstri, idstrj, message

if (self%nbody == 0) return

Expand All @@ -38,9 +38,10 @@ module subroutine rmvs_discard_tp(self, nbody_system, param)
write(idstri, *) tp%id(i)
write(idstrj, *) pl%id(iplperP)
write(timestr, *) t
write(*, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstri)) &
write(message, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstri)) &
// ") q with respect to massive body " // trim(adjustl(pl%info(iplperP)%name)) &
// " (" // trim(adjustl(idstrj)) // ") is too small at t = " // trim(adjustl(timestr))
call swiftest_io_log_one_message(COLLISION_LOG_OUT,message)
tp%ldiscard(i) = .true.
tp%lmask(i) = .false.
call tp%info(i)%set_value(status="DISCARDED_PLQ", discard_time=t, discard_rh=tp%rh(:,i), &
Expand Down
35 changes: 20 additions & 15 deletions src/rmvs/rmvs_step.f90
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ subroutine rmvs_interp_out(cb, pl, dt)
real(DP), dimension(:,:), allocatable :: xtmp, vtmp
real(DP), dimension(:), allocatable :: GMcb, dto
integer(I4B), dimension(:), allocatable :: iflag
character(len=STRMAX) :: message

dntenc = real(NTENC, kind=DP)
associate (npl => pl%nbody)
Expand All @@ -112,11 +113,12 @@ subroutine rmvs_interp_out(cb, pl, dt)
if (any(iflag(1:npl) /= 0)) then
do i = 1, npl
if (iflag(i) /= 0) then
write(*, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!"
write(*, *) GMcb(i), dto(i)
write(*, *) xtmp(:,i)
write(*, *) vtmp(:,i)
write(*, *) " STOPPING "
write(message, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!",new_line('a'), &
GMcb(i), dto(i),new_line('a'), &
xtmp(:,i),new_line('a'), &
vtmp(:,i),new_line('a'), &
" STOPPING "
call swiftest_io_log_one_message(COLLISION_LOG_OUT,message)
call util_exit(FAILURE)
end if
end do
Expand All @@ -134,11 +136,12 @@ subroutine rmvs_interp_out(cb, pl, dt)
if (any(iflag(1:npl) /= 0)) then
do i = 1, npl
if (iflag(i) /= 0) then
write(*, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!"
write(*, *) GMcb(i), -dto(i)
write(*, *) xtmp(:,i)
write(*, *) vtmp(:,i)
write(*, *) " STOPPING "
write(message, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!",new_line('a'), &
GMcb(i), -dto(i), new_line('a'), &
xtmp(:,i), new_line('a'), &
vtmp(:,i), new_line('a'), &
" STOPPING "
call swiftest_io_log_one_message(COLLISION_LOG_OUT,message)
call util_exit(FAILURE)
end if
end do
Expand Down Expand Up @@ -237,6 +240,7 @@ subroutine rmvs_interp_in(cb, pl, nbody_system, param, dt, outer_index)
real(DP), dimension(:,:), allocatable :: xtmp, vtmp, rh_original, ah_original
real(DP), dimension(:), allocatable :: GMcb, dti
integer(I4B), dimension(:), allocatable :: iflag
character(len=STRMAX) :: message

associate (npl => nbody_system%pl%nbody)
dntphenc = real(NTPHENC, kind=DP)
Expand Down Expand Up @@ -279,11 +283,12 @@ subroutine rmvs_interp_in(cb, pl, nbody_system, param, dt, outer_index)
if (any(iflag(1:npl) /= 0)) then
do i = 1, npl
if (iflag(i) /=0) then
write(*, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!"
write(*, *) GMcb(i), dti(i)
write(*, *) xtmp(:,i)
write(*, *) vtmp(:,i)
write(*, *) " STOPPING "
write(message, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!", new_line('a'), &
GMcb(i), dti(i), new_line('a'), &
xtmp(:,i), new_line('a'), &
vtmp(:,i), new_line('a'), &
" STOPPING "
call swiftest_io_log_one_message(COLLISION_LOG_OUT, message)
call util_exit(failure)
end if
end do
Expand Down
6 changes: 4 additions & 2 deletions src/swiftest/swiftest_discard.f90
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ subroutine swiftest_discard_peri_tp(tp, nbody_system, param)
integer(I4B) :: i, j, ih
real(DP) :: r2
real(DP), dimension(NDIM) :: dx
character(len=STRMAX) :: idstr, timestr
character(len=STRMAX) :: idstr, timestr, message

associate(cb => nbody_system%cb, ntp => tp%nbody, pl => nbody_system%pl, npl => nbody_system%pl%nbody, t => nbody_system%t)
call tp%get_peri(nbody_system, param)
Expand All @@ -220,8 +220,10 @@ subroutine swiftest_discard_peri_tp(tp, nbody_system, param)
tp%status(i) = DISCARDED_PERI
write(idstr, *) tp%id(i)
write(timestr, *) nbody_system%t
write(*, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // &
write(message, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // &
" perihelion distance too small at t = " // trim(adjustl(timestr))

call swiftest_io_log_one_message(COLLISION_LOG_OUT, message)
tp%ldiscard(i) = .true.
call tp%info(i)%set_value(status="DISCARDED_PERI", discard_time=nbody_system%t, discard_rh=tp%rh(:,i), &
discard_vh=tp%vh(:,i), discard_body_id=pl%id(j))
Expand Down
6 changes: 5 additions & 1 deletion src/swiftest/swiftest_drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module subroutine swiftest_drift_body(self, nbody_system, param, dt)
! Internals
integer(I4B) :: i
integer(I4B), dimension(:), allocatable :: iflag
character(len=STRMAX) :: message

associate(n => self%nbody)
allocate(iflag(n))
Expand All @@ -42,7 +43,10 @@ module subroutine swiftest_drift_body(self, nbody_system, param, dt)
if (any(iflag(1:n) /= 0)) then
where(iflag(1:n) /= 0) self%status(1:n) = DISCARDED_DRIFTERR
do i = 1, n
if (iflag(i) /= 0) write(*, *) " Body ", self%id(i), " lost due to error in Danby drift"
if (iflag(i) /= 0) then
write(message, *) " Body ", self%id(i), " lost due to error in Danby drift"
call swiftest_io_log_one_message(COLLISION_LOG_OUT, message)
end if
end do
end if
end associate
Expand Down
1 change: 0 additions & 1 deletion src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,6 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i
! Calculate the G for the nbody_system units
param%GU = GC / (param%DU2M**3 / (param%MU2KG * param%TU2S**2))


! 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")
Expand Down
5 changes: 3 additions & 2 deletions src/symba/symba_discard.f90
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ subroutine symba_discard_peri_pl(pl, nbody_system, param)
logical, save :: lfirst = .true.
logical :: lfirst_orig
integer(I4B) :: i
character(len=STRMAX) :: timestr, idstr
character(len=STRMAX) :: timestr, idstr, message


lfirst_orig = pl%lfirst
Expand All @@ -320,8 +320,9 @@ subroutine symba_discard_peri_pl(pl, nbody_system, param)
pl%status(i) = DISCARDED_PERI
write(timestr, *) nbody_system%t
write(idstr, *) pl%id(i)
write(*, *) trim(adjustl(pl%info(i)%name)) // " (" // trim(adjustl(idstr)) // &
write(message, *) trim(adjustl(pl%info(i)%name)) // " (" // trim(adjustl(idstr)) // &
") perihelion distance too small at t = " // trim(adjustl(timestr))
call swiftest_io_log_one_message(COLLISION_LOG_OUT, message)
call pl%info(i)%set_value(status="DISCARDED_PERI", discard_time=nbody_system%t, &
discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), discard_body_id=nbody_system%cb%id)
end if
Expand Down
12 changes: 7 additions & 5 deletions src/whm/whm_drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module subroutine whm_drift_pl(self, nbody_system, param, dt)
! Internals
integer(I4B) :: i
integer(I4B), dimension(:), allocatable :: iflag
character(len=STRMAX) :: message

if (self%nbody == 0) return

Expand All @@ -41,11 +42,12 @@ module subroutine whm_drift_pl(self, nbody_system, param, dt)
end where
do i = 1, npl
if (iflag(i) /= 0) then
write(*, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!!!"
WRITE(*, *) pl%muj(i), dt
WRITE(*, *) pl%xj(:,i)
WRITE(*, *) pl%vj(:,i)
WRITE(*, *) " STOPPING "
write(message, *) " Planet ", pl%id(i), " is lost!!!!!!!!!!!!",new_line('A'), &
pl%muj(i), dt, new_line('A'), &
pl%xj(:,i),new_line('A'), &
pl%vj(:,i),new_line('A'), &
" STOPPING "
call swiftest_io_log_one_message(COLLISION_LOG_OUT, message)
end if
end do
call util_exit(FAILURE)
Expand Down

0 comments on commit a543463

Please sign in to comment.