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
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I4B), | intent(in) | :: | code | |||
| integer(kind=I4B), | intent(in), | optional | :: | unit |
subroutine base_util_exit(code,unit)
!! 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
integer(I4B), intent(in), optional :: unit
! Internals
character(*), parameter :: BAR = '("-----------------------------------------------------")'
character(*), parameter :: SUCCESS_MSG = '(/, "Normal termination of Swiftest (version ", A, ")")'
character(*), parameter :: FAIL_MSG = '(/, "Terminating Swiftest (version ", A, ") due to error!")'
character(*), parameter :: USAGE_MSG = '("Usage: swiftest <whm|helio|rmvs|symba> <paramfile> ' // &
'[{progress}|classic|quiet]")'
character(*), parameter :: HELP_MSG = USAGE_MSG
integer(I4B) :: iu
if (present(unit)) then
iu = unit
else
iu = OUTPUT_UNIT
end if
#ifdef COARRAY
if ((code /= SUCCESS .and. code /= USAGE .and. code /= HELP) .or. (this_image() == 1)) then
#endif
select case(code)
case(SUCCESS)
write(iu, SUCCESS_MSG) VERSION
write(iu, BAR)
case(USAGE)
write(iu, USAGE_MSG)
case(HELP)
write(iu, HELP_MSG)
case default
write(iu, FAIL_MSG) VERSION
write(iu, BAR)
stop
end select
#ifdef COARRAY
end if
#endif
stop
return
end subroutine base_util_exit