stdlib_error#
See also the specification page: stdlib_error.
stdlib_error (module)#
Provides support for catching and handling errors (Specification: stdlib_error) Version: experimental
A fixed-storage state variable for error handling of linear algebra routines
Version: experimental
Interfaces for comparison operators of error states with integer flags
Variables
- STDLIB_SUCCESSinteger(kind=ilp), parameter, Default = 0_ilp
Base state return types for
- STDLIB_VALUE_ERRORinteger(kind=ilp), parameter, Default = -1_ilp
- STDLIB_LINALG_ERRORinteger(kind=ilp), parameter, Default = -2_ilp
- STDLIB_INTERNAL_ERRORinteger(kind=ilp), parameter, Default = -3_ilp
- STDLIB_IO_ERRORinteger(kind=ilp), parameter, Default = -4_ilp
- STDLIB_FS_ERRORinteger(kind=ilp), parameter, Default = -5_ilp
Types
state_type (type)#
-
state_type (type) state_type defines a general state return type for a stdlib routine. State contains a status flag, a comment, and a procedure specifier that can be used to mark where the error happened
- Attributes:
- stateinteger(kind=ilp), Default = STDLIB_SUCCESS
The current exit state
- messagecharacter(len=MSG_LENGTH), Default = repeat(’ ‘, MSG_LENGTH)
Message associated to the current state
- where_atcharacter(len=NAME_LENGTH), Default = repeat(’ ‘, NAME_LENGTH)
Location of the state change
- Procedures:
Interfaces
error_stop (interface)#
-
module subroutine error_stop(msg, code) Provides a call to error stop and allows the user to specify a code and message (see also stdlib_error)
- Arguments:
- msgcharacter(len=*), intent(in)
- codeinteger, intent(in), optional
operator(==) (interface)#
-
operator(==) (interface) Comparison operators
- Procedures:
operator(/=) (interface)#
-
operator(/=) (interface) - Procedures:
operator(<) (interface)#
-
operator(<) (interface) - Procedures:
operator(<=) (interface)#
-
operator(<=) (interface) - Procedures:
operator(>) (interface)#
-
operator(>) (interface) - Procedures:
operator(>=) (interface)#
-
operator(>=) (interface) - Procedures:
Procedures
state_message (function)#
-
pure function state_message(this) -> msg Return a formatted message
- Arguments:
- thisclass(state_type), intent(in)
- Returns:
- msgcharacter(len=:), allocatable
state_print (function)#
-
pure function state_print(this) -> msg Produce a nice error string
- Arguments:
- thisclass(state_type), intent(in)
- Returns:
- msgcharacter(len=:), allocatable
state_is_ok (function)#
-
elemental function state_is_ok(this) -> state_is_ok Check if the current state is successful
- Arguments:
- thisclass(state_type), intent(in)
- Returns:
- state_is_oklogical(kind=lk)
state_is_error (function)#
-
elemental function state_is_error(this) -> state_is_error Check if the current state is an error state
- Arguments:
- thisclass(state_type), intent(in)
- Returns:
- state_is_errorlogical(kind=lk)
state_eq_flag (function)#
-
elemental function state_eq_flag(err, flag) -> state_eq_flag Compare an error state with an integer flag
- Arguments:
- errclass(state_type), intent(in)
- flaginteger, intent(in)
- Returns:
- state_eq_flaglogical(kind=lk)
flag_eq_state (function)#
-
elemental function flag_eq_state(flag, err) -> flag_eq_state Compare an integer flag with the error state
- Arguments:
- flaginteger, intent(in)
- errclass(state_type), intent(in)
- Returns:
- flag_eq_statelogical(kind=lk)
state_neq_flag (function)#
-
elemental function state_neq_flag(err, flag) -> state_neq_flag Compare the error state with an integer flag
- Arguments:
- errclass(state_type), intent(in)
- flaginteger, intent(in)
- Returns:
- state_neq_flaglogical(kind=lk)
flag_neq_state (function)#
-
elemental function flag_neq_state(flag, err) -> flag_neq_state Compare an integer flag with the error state
- Arguments:
- flaginteger, intent(in)
- errclass(state_type), intent(in)
- Returns:
- flag_neq_statelogical(kind=lk)
state_lt_flag (function)#
-
elemental function state_lt_flag(err, flag) -> state_lt_flag Compare the error state with an integer flag
- Arguments:
- errclass(state_type), intent(in)
- flaginteger, intent(in)
- Returns:
- state_lt_flaglogical(kind=lk)
state_le_flag (function)#
-
elemental function state_le_flag(err, flag) -> state_le_flag Compare the error state with an integer flag
- Arguments:
- errclass(state_type), intent(in)
- flaginteger, intent(in)
- Returns:
- state_le_flaglogical(kind=lk)
flag_lt_state (function)#
-
elemental function flag_lt_state(flag, err) -> flag_lt_state Compare an integer flag with the error state
- Arguments:
- flaginteger, intent(in)
- errclass(state_type), intent(in)
- Returns:
- flag_lt_statelogical(kind=lk)
flag_le_state (function)#
-
elemental function flag_le_state(flag, err) -> flag_le_state Compare an integer flag with the error state
- Arguments:
- flaginteger, intent(in)
- errclass(state_type), intent(in)
- Returns:
- flag_le_statelogical(kind=lk)
state_gt_flag (function)#
-
elemental function state_gt_flag(err, flag) -> state_gt_flag Compare the error state with an integer flag
- Arguments:
- errclass(state_type), intent(in)
- flaginteger, intent(in)
- Returns:
- state_gt_flaglogical(kind=lk)
state_ge_flag (function)#
-
elemental function state_ge_flag(err, flag) -> state_ge_flag Compare the error state with an integer flag
- Arguments:
- errclass(state_type), intent(in)
- flaginteger, intent(in)
- Returns:
- state_ge_flaglogical(kind=lk)
flag_gt_state (function)#
-
elemental function flag_gt_state(flag, err) -> flag_gt_state Compare an integer flag with the error state
- Arguments:
- flaginteger, intent(in)
- errclass(state_type), intent(in)
- Returns:
- flag_gt_statelogical(kind=lk)
flag_ge_state (function)#
-
elemental function flag_ge_state(flag, err) -> flag_ge_state Compare an integer flag with the error state
- Arguments:
- flaginteger, intent(in)
- errclass(state_type), intent(in)
- Returns:
- flag_ge_statelogical(kind=lk)
check (subroutine)#
-
subroutine check(condition, msg, code, warn) Checks the value of a logical condition (Specification: stdlib_error)
- Arguments:
- conditionlogical, intent(in)
- msgcharacter(len=*), intent(in), optional
- codeinteger, intent(in), optional
- warnlogical, intent(in), optional
Behavior
If
condition == .false.and:No other arguments are provided, it stops the program with the default message and exit code
1;msgis provided, it prints the value ofmsg;codeis provided, it stops the program with the given exit code;warnis provided and.true., it doesn’t stop the program and prints the message.
Examples
If
a /= 5, the following stops the program with exit code1and printsCheck failed.:call check(a == 5)
To print
a == 5 failed., use:call check(a == 5, msg='a == 5 failed.')
To emit the message without stopping the program, use:
call check(a == 5, msg='a == 5 failed.', warn=.true.)
To stop the program with exit code
77, use:call check(a == 5, msg='a == 5 failed.', code=77)
state_destroy (subroutine)#
-
elemental subroutine state_destroy(this) Cleanup the object
- Arguments:
- thisclass(state_type), intent(inout)
error_handling (subroutine)#
-
pure subroutine error_handling(ierr, ierr_out) Flow control: on output flag present, return it; otherwise, halt on error
- Arguments:
- ierrclass(state_type), intent(in)
- ierr_outclass(state_type), intent(inout), optional
state_update_location (subroutine)#
-
pure subroutine state_update_location(this, where_at) Update the location of the error message
- Arguments:
- thisclass(state_type), intent(inout)
- where_atcharacter(len=*), intent(in), optional
state_parse_at_location (subroutine)#
-
pure subroutine state_parse_at_location(new_state, where_at, flag, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) Parse a generic list of arguments provided to the error constructor
Set error flag
Set chain Add location
- Arguments:
- new_stateclass(state_type), intent(inout)
The current state variable
- where_atcharacter(len=*), intent(in)
Error Location
- flaginteger, intent(in)
Input error flag
- a1class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a2class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a3class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a4class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a5class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a6class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a7class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a8class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a9class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a10class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a11class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a12class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a13class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a14class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a15class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a16class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a17class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a18class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a19class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a20class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
state_parse_arguments (subroutine)#
-
pure subroutine state_parse_arguments(new_state, flag, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) Parse a generic list of arguments provided to the error constructor
Set error flag
Set chain
- Arguments:
- new_stateclass(state_type), intent(inout)
The current state variable
- flaginteger, intent(in)
Input error flag
- a1class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a2class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a3class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a4class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a5class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a6class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a7class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a8class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a9class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a10class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a11class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a12class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a13class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a14class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a15class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a16class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a17class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a18class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a19class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments
- a20class(*), dimension(..), intent(in), optional
Optional rank-agnostic arguments