Print the error trace and stop the program Use for unrecoverable errors
Usage: if (err%has_error()) call err%fatal() if (err%has_error()) call err%fatal(exit_code=2) ! custom status
exit_code is the process exit status, default 1. A non-default
status needs F2018 variable stop codes; compilers without them can
be built with -DPIC_NO_VARIABLE_STOP_CODE, which always exits 1.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(error_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in), | optional | :: | unit | ||
| integer(kind=default_int), | intent(in), | optional | :: | exit_code |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | status |
subroutine error_fatal(self, unit, exit_code) !! Print the error trace and stop the program !! Use for unrecoverable errors !! !! Usage: !! if (err%has_error()) call err%fatal() !! if (err%has_error()) call err%fatal(exit_code=2) ! custom status !! !! `exit_code` is the process exit status, default 1. A non-default !! status needs F2018 variable stop codes; compilers without them can !! be built with -DPIC_NO_VARIABLE_STOP_CODE, which always exits 1. class(error_t), intent(in) :: self integer(default_int), intent(in), optional :: unit integer(default_int), intent(in), optional :: exit_code #ifndef PIC_NO_VARIABLE_STOP_CODE integer(default_int) :: status #endif #ifndef PIC_NO_VARIABLE_STOP_CODE status = 1 if (present(exit_code)) status = exit_code #endif if (.not. self%has_error()) return call self%print_trace(unit) #ifdef PIC_NO_VARIABLE_STOP_CODE error stop 1 #else ! int() puts the stop code in the compiler's default integer kind, ! which is what the standard requires even in an int64 PIC build error stop int(status) #endif end subroutine error_fatal