1+ ! > @brief State and error handling module for linear algebra routines.
2+ ! >
3+ ! > This module defines the `la_state` type, which is used for error handling in
4+ ! > linear algebra computations. It provides state tracking, formatted error messages,
5+ ! > and a mechanism for comparing state values.
16module la_state_type
27 use la_constants,only:ilp,lk
38 use iso_fortran_env,only:real32,real64,real128,int8,int16,int32,int64,stderr = > error_unit
@@ -19,36 +24,36 @@ module la_state_type
1924 integer (ilp),parameter :: MSG_LENGTH = 512_ilp
2025 integer (ilp),parameter :: NAME_LENGTH = 32_ilp
2126
22- ! > \class ` la_state` defines a state return type for a
23- ! > linear algebra routine. State contains a status flag, a comment, and a
24- ! > procedure specifier that can be used to mark where the error happened
25- type, public :: la_state
26-
27- ! > The current exit state
28- integer (ilp) :: state = LINALG_SUCCESS
29-
30- ! > Message associated to the current state
31- character (len = MSG_LENGTH) :: message = repeat ( ' ' ,MSG_LENGTH)
32-
33- ! > Location of the state change
34- character (len = NAME_LENGTH) :: where_at = repeat ( ' ' ,NAME_LENGTH)
35-
36- contains
37-
38- ! > Cleanup
39- procedure :: destroy = > state_destroy
40-
41- ! > Error handling
42- procedure :: handle = > linalg_error_handling
43-
44- ! > Print error message
45- procedure :: print = > state_print
46- procedure :: print_msg = > state_message
47-
48- ! > State properties
49- procedure :: ok = > state_is_ok
50- procedure :: error = > state_is_error
51-
27+ ! > \class la_state
28+ ! > \brief Defines a state return type for a linear algebra routine.
29+ ! >
30+ ! > This type encapsulates a status flag, an optional error message, and the procedure
31+ ! > name where the error originated.
32+ type, public :: la_state
33+ ! > The current exit state.
34+ integer (ilp) :: state = LINALG_SUCCESS
35+
36+ ! > Message associated with the current state.
37+ character (len = MSG_LENGTH) :: message = repeat ( ' ' , MSG_LENGTH)
38+
39+ ! > Location where the state change occurred.
40+ character (len = NAME_LENGTH) :: where_at = repeat ( ' ' , NAME_LENGTH)
41+ contains
42+ ! > Destroy the state object.
43+ procedure :: destroy = > state_destroy
44+
45+ ! > Handle errors based on the state value.
46+ procedure :: handle = > linalg_error_handling
47+
48+ ! > Print the error message associated with the state.
49+ procedure :: print = > state_print
50+ procedure :: print_msg = > state_message
51+
52+ ! > Check if the state indicates success.
53+ procedure :: ok = > state_is_ok
54+
55+ ! > Check if the state indicates an error.
56+ procedure :: error = > state_is_error
5257 end type la_state
5358
5459 ! > Comparison operators
0 commit comments