FUTILS
Some basic Fortran Utilities
Loading...
Searching...
No Matches
error_handling_m Module Reference

Data Types

type  error_handling_t

Functions/Subroutines

pure subroutine error_handling_abort_routine (line, file, msg)
 Causes an ERROR STOP, printing an error message, as well as the file name and line number where the error occurred.
pure subroutine error_handling_assert_array_routine (condition, condition_str, line, file)
pure subroutine error_handling_assert_routine (condition, condition_str, line, file)
 Causes an ERROR STOP, printing an error message, as well as the file name and line number where the error occurred.

Variables

type(error_handling_t), parameter, public error_handling = error_handling_t()

Function/Subroutine Documentation

◆ error_handling_abort_routine()

pure subroutine error_handling_m::error_handling_abort_routine ( integer, intent(in) line,
character(len=*), intent(in) file,
character(len=*), intent(in) msg )
private

Causes an ERROR STOP, printing an error message, as well as the file name and line number where the error occurred.

The abort routine should be kept for situations where the assert routine is not appropriate.

Parameters
[in]line(integer) : Line number where the error occurred
[in]file(character) : Name of file where error occurred
[in]msg(character) : Error message

Definition at line 72 of file error_handling.f90.

73 implicit none
74
75 !-=-= INPUT/OUTPUT
76 integer, intent(in) :: line !< (integer) : Line number where the error occurred
77 character(len=*), intent(in) :: file !< (character) : Name of file where error occurred
78 character(len=*), intent(in) :: msg !< (character) : Error message
79 type(string_t) :: file_s, line_s, msg_s
80 character*12, parameter :: newline = new_line('a')//repeat(' ',11)
81 integer :: n, i
82
83 file_s = trim(adjustl(file))
84 line_s = line
85
86 n = len_trim(file) + 7
87
88 msg_s = repeat('-',n)
89 msg_s = msg_s//newline//'FILE: '//file_s
90 msg_s = msg_s//newline//'LINE: '//line_s
91 msg_s = msg_s//newline//'MSG:: '//trim(adjustl(msg))
92 msg_s = msg_s//newline//repeat('-',n)
93
94 error stop msg_s%s
95

Referenced by error_handling_assert_array_routine(), and error_handling_assert_routine().

Here is the caller graph for this function:

◆ error_handling_assert_array_routine()

pure subroutine error_handling_m::error_handling_assert_array_routine ( logical, dimension(:), intent(in) condition,
character(len=*), intent(in) condition_str,
integer, intent(in) line,
character(len=*), intent(in) file )
private
Parameters
[in]condition(logical(:)) : Array of logical conditions to assert
[in]condition_str(character) : The conditions as a string
[in]line(integer) : Line number where the assertion is made
[in]file(character) : Name of file where the assertion is made

Definition at line 98 of file error_handling.f90.

99 implicit none
100
101 !-=-= INPUT/OUTPUT
102 logical, dimension(:), intent(in) :: condition !< (logical(:)) : Array of logical conditions to assert
103 character(len=*), intent(in) :: condition_str !< (character) : The conditions as a string
104 integer, intent(in) :: line !< (integer) : Line number where the assertion is made
105 character(len=*), intent(in) :: file !< (character) : Name of file where the assertion is made
106
107 if(.not.all(condition)) call error_handling_abort_routine(line,file,"ASSERTION FAILED: "//trim(adjustl(condition_str)))
108

References error_handling_abort_routine().

Referenced by error_handling_m::error_handling_t::assert_routine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ error_handling_assert_routine()

pure subroutine error_handling_m::error_handling_assert_routine ( logical, intent(in) condition,
character(len=*), intent(in) condition_str,
integer, intent(in) line,
character(len=*), intent(in) file )
private

Causes an ERROR STOP, printing an error message, as well as the file name and line number where the error occurred.

The assert routine should be used for internal validity checks only. It is a safety mechanism to ensure that program bugs are found and fixed, with the idea that the code developer uses the file name and line number to inspect the source location where the assertion failure occurred and determine the cause. If you want to ERROR STOP as a result of invalid/improper input parameters, use the abort routine, with a useful error message.

Parameters
[in]condition(logical) : Logical condition to assert
[in]condition_str(character) : The condition as a string
[in]line(integer) : Line number where the assertion is made
[in]file(character) : Name of file where the assertion is made

Definition at line 124 of file error_handling.f90.

125 implicit none
126
127 !-=-= INPUT/OUTPUT
128 logical, intent(in) :: condition !< (logical) : Logical condition to assert
129 character(len=*), intent(in) :: condition_str !< (character) : The condition as a string
130 integer, intent(in) :: line !< (integer) : Line number where the assertion is made
131 character(len=*), intent(in) :: file !< (character) : Name of file where the assertion is made
132
133 if(.not.condition) call error_handling_abort_routine(line,file,"ASSERTION FAILED: "//trim(adjustl(condition_str)))
134

References error_handling_abort_routine().

Referenced by error_handling_m::error_handling_t::assert_routine().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ error_handling

type(error_handling_t), parameter, public error_handling_m::error_handling = error_handling_t()

Definition at line 61 of file error_handling.f90.

61 type(error_handling_t), parameter :: error_handling = error_handling_t()

Referenced by enum_generator_m::assignment(=)::assign_enumerator(), enum_generator_m::is_equal(), and enum_generator_m::not_equal().