MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
ErrorUtil.f90
Go to the documentation of this file.
2  use kindmodule, only: i4b
3  implicit none
4 
5  procedure(pstop_iface), pointer :: pstop_alternative => null()
6 
7  interface
8  subroutine pstop_iface(status)
9  import i4b
10  integer(I4B) :: status
11  end subroutine
12  end interface
13 
14 contains
15 
16  !> @brief Stop the program, optionally specifying an error status code.
17  !!
18  !! If a non-zero status is specified, the program is terminated with the
19  !! error status code. If no status is specified or status=0, the program
20  !! stops with code 0. A message may be provided to print before exiting,
21  !! useful e.g. for "contact developer" messages upon programming errors.
22  !<
23  subroutine pstop(status, message)
24  integer(I4B), intent(in), optional :: status !< optional error code to return (default=0)
25  character(len=*), intent(in), optional :: message !< optional message to print before stopping
26 
27  if (associated(pstop_alternative)) then
28  if (present(message)) print *, message
29  if (present(status)) then
30  call pstop_alternative(status)
31  else
32  call pstop_alternative(0)
33  end if
34  end if
35 
36  if (present(message)) print *, message
37  if (present(status)) then
38  if (status == 0) stop
39  call exit(status)
40  else
41  stop
42  end if
43  end subroutine pstop
44 
45 end module errorutilmodule
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
Definition: ErrorUtil.f90:24
procedure(pstop_iface), pointer pstop_alternative
Definition: ErrorUtil.f90:5
This module defines variable data types.
Definition: kind.f90:8