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

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 21, 2022
1 parent 55f499f commit 3776de2
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 118 deletions.
37 changes: 37 additions & 0 deletions src/base/base_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,41 @@ subroutine reset_storage(self)
return
end subroutine reset_storage



subroutine util_exit(code)
!! author: David A. Minton
!!
!! Print termination message and exit program
!!
!! Adapted from David E. Kaufmann's Swifter routine: util_exit.f90
!! Adapted from Hal Levison's Swift routine util_exit.f
implicit none
! Arguments
integer(I4B), intent(in) :: code
! Internals
character(*), parameter :: BAR = '("------------------------------------------------")'
character(*), parameter :: SUCCESS_MSG = '(/, "Normal termination of Swiftest (version ", f3.1, ")")'
character(*), parameter :: FAIL_MSG = '(/, "Terminating Swiftest (version ", f3.1, ") due to error!!")'
character(*), parameter :: USAGE_MSG = '("Usage: swiftest [bs|helio|ra15|rmvs|symba|tu4|whm] <paramfile> [standard|compact|progress|NONE]")'
character(*), parameter :: HELP_MSG = USAGE_MSG

select case(code)
case(SUCCESS)
write(*, SUCCESS_MSG) VERSION_NUMBER
write(*, BAR)
case(USAGE)
write(*, USAGE_MSG)
case(HELP)
write(*, HELP_MSG)
case default
write(*, FAIL_MSG) VERSION_NUMBER
write(*, BAR)
error stop
end select

stop

end subroutine util_exit

end module base
2 changes: 1 addition & 1 deletion src/collision/collision_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module subroutine collision_netcdf_io_initialize_output(self, param)

667 continue
write(*,*) "Error creating fragmentation output file. " // trim(adjustl(errmsg))
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end subroutine collision_netcdf_io_initialize_output


Expand Down
9 changes: 7 additions & 2 deletions src/collision/collision_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,13 @@ module function collision_resolve_merge(system, param, t) result(status)
integer(I4B) :: status !! Status flag assigned to this outcome
end function collision_resolve_merge



module subroutine collision_resolve_mergeaddsub(system, param, t, status)
class(base_nbody_system), intent(inout) :: system !! Swiftest nbody system object
class(base_parameters), intent(inout) :: param !! Current run configuration parameters with Swiftest additions
real(DP), intent(in) :: t !! Time of collision
integer(I4B), intent(in) :: status !! Status flag to assign to adds
end subroutine collision_resolve_mergeaddsub


module subroutine collision_resolve_plpl(self, system, param, t, dt, irec)
implicit none
Expand Down
4 changes: 2 additions & 2 deletions src/collision/collision_resolve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ module subroutine collision_resolve_make_impactors_pl(pl, idx)
end subroutine collision_resolve_make_impactors_pl


subroutine collision_resolve_mergeaddsub(system, param, t, status)
module subroutine collision_resolve_mergeaddsub(system, param, t, status)
!! author: David A. Minton
!!
!! Fills the pl_discards and pl_adds with removed and added bodies
Expand Down Expand Up @@ -638,7 +638,7 @@ subroutine collision_resolve_list(plpl_collision , system, param, t)
plpl_collision%status(i) = collision_resolve_merge(system, param, t)
case default
write(*,*) "Error in swiftest_collision, unrecognized collision regime"
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end select
call collision_history%take_snapshot(param,system, t, "after")
call impactors%reset()
Expand Down
2 changes: 1 addition & 1 deletion src/collision/collision_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ module subroutine collision_util_get_energy_momentum(self, system, param, lbefo
if (.not.allocated(tmpsys)) then
write(*,*) "Error in collision_util_get_energy_momentum. " // &
" This must be called with lbefore=.true. at least once before calling it with lbefore=.false."
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end if
select type(tmpsys)
class is (swiftest_nbody_system)
Expand Down
2 changes: 1 addition & 1 deletion src/encounter/encounter_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ module subroutine encounter_netcdf_io_initialize_output(self, param)

667 continue
write(*,*) "Error creating encounter output file. " // trim(adjustl(errmsg))
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end subroutine encounter_netcdf_io_initialize_output


Expand Down
2 changes: 1 addition & 1 deletion src/netcdf_io/netcdf_io_implementations.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module subroutine netcdf_io_check(status, call_identifier)
if(status /= nf90_noerr) then
if (present(call_identifier)) write(*,*) "NetCDF error in ",trim(call_identifier)
write(*,*) trim(nf90_strerror(status))
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end if

return
Expand Down
8 changes: 4 additions & 4 deletions src/rmvs/rmvs_step.f90
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ subroutine rmvs_interp_out(cb, pl, dt)
write(*, *) xtmp(:,i)
write(*, *) vtmp(:,i)
write(*, *) " STOPPING "
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end if
end do
end if
Expand All @@ -139,7 +139,7 @@ subroutine rmvs_interp_out(cb, pl, dt)
write(*, *) xtmp(:,i)
write(*, *) vtmp(:,i)
write(*, *) " STOPPING "
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end if
end do
end if
Expand Down Expand Up @@ -284,7 +284,7 @@ subroutine rmvs_interp_in(cb, pl, system, param, dt, outer_index)
write(*, *) xtmp(:,i)
write(*, *) vtmp(:,i)
write(*, *) " STOPPING "
call swiftest_util_exit(failure)
call util_exit(failure)
end if
end do
end if
Expand All @@ -308,7 +308,7 @@ subroutine rmvs_interp_in(cb, pl, system, param, dt, outer_index)
write(*, *) xtmp(:,i)
write(*, *) vtmp(:,i)
write(*, *) " STOPPING "
call swiftest_util_exit(failure)
call util_exit(failure)
end if
end do
end if
Expand Down
12 changes: 6 additions & 6 deletions src/rmvs/rmvs_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module subroutine rmvs_util_append_pl(self, source, lsource_mask)
end associate
class default
write(*,*) "Invalid object passed to the append method. Source must be of class rmvs_pl or its descendents!"
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end select

return
Expand Down Expand Up @@ -68,7 +68,7 @@ module subroutine rmvs_util_append_tp(self, source, lsource_mask)
end associate
class default
write(*,*) "Invalid object passed to the append method. Source must be of class rmvs_tp or its descendents!"
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end select

return
Expand Down Expand Up @@ -174,7 +174,7 @@ module subroutine rmvs_util_fill_pl(self, inserts, lfill_list)
call whm_util_fill_pl(keeps, inserts, lfill_list)
class default
write(*,*) "Invalid object passed to the fill method. Source must be of class rmvs_pl or its descendents!"
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end select
end associate

Expand Down Expand Up @@ -275,7 +275,7 @@ module subroutine rmvs_util_fill_tp(self, inserts, lfill_list)
call swiftest_util_fill_tp(keeps, inserts, lfill_list) ! Note: whm_tp does not have its own fill method, so we skip back to the base class
class default
write(*,*) "Invalid object passed to the fill method. Source must be of class rmvs_tp or its descendents!"
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end select
end associate

Expand Down Expand Up @@ -482,7 +482,7 @@ module subroutine rmvs_util_spill_pl(self, discards, lspill_list, ldestructive)
call whm_util_spill_pl(keeps, discards, lspill_list, ldestructive)
class default
write(*,*) "Invalid object passed to the spill method. Source must be of class rmvs_pl or its descendents!"
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end select
end associate

Expand Down Expand Up @@ -513,7 +513,7 @@ module subroutine rmvs_util_spill_tp(self, discards, lspill_list, ldestructive)
call swiftest_util_spill_tp(keeps, discards, lspill_list, ldestructive)
class default
write(*,*) "Invalid object passed to the spill method. Source must be of class rmvs_tp or its descendents!"
call swiftest_util_exit(FAILURE)
call util_exit(FAILURE)
end select
end associate

Expand Down
2 changes: 1 addition & 1 deletion src/swiftest/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ program swiftest_driver
end associate
end associate

call swiftest_util_exit(SUCCESS)
call util_exit(SUCCESS)
end program swiftest_driver
Loading

0 comments on commit 3776de2

Please sign in to comment.