CP2K 2.5 (Revision 12981)
Classes | Functions | Variables

cp_error_handling Namespace Reference

Module that contains the routines for error handling The idea is that in general routines have an optional parameter that can be used to change the error behaviour. More...

Classes

struct  cp_error_type
 this type represent a structure that can be passed to the functions to change their error behaviour. It should always be initialized with cp_error_init before use More...

Functions

subroutine, public cp_error_init (error, stop_level, print_level, logger, template_error, error_nr, level)
 Initializes the error structure error. The optional arguments initialize the values in the structure. Default values: stop_level=2, logger=null (i.e. default logger)
subroutine, public cp_error_reset (error)
 if the optional parameter error is present resets its level and error_nr to 0 (is tipically called when you want to discard the previous errors stored in error, i.e. not often)
subroutine, public cp_error_set (error, level, error_nr, stop_level, print_level, logger, template_error, info)
 routine to set the various components of the error structure
subroutine, public cp_error_dealloc_ref (err_to_free, error)
 Deallocates the memory allocated by the error.
subroutine, public cp_error_get (error, level, error_nr, stop_level, print_level, logger, info)
 returns the various attributes of the given error
INTEGER, public cp_error_get_level (error)
 gets the error level from the given error
INTEGER, public cp_error_get_print_level (error)
 gets the print level (starting with which errorlevel something gets printed) from the given error if the error is not present returns cp_note_level
INTEGER, public cp_error_get_nr (error)
 gets the error number from the given error
TYPE(cp_logger_type), pointer,
public 
cp_error_get_logger (error)
 gets the logger of the given error. The error argument is optional, so you can get the logger of an optional dummy argument. If the error is not present or its logger is not associated returns the default logger.
INTEGER, public cp_error_get_stop_level (error)
 gets the error level at which the error will stop the programm If the error is not present returns cp_failure_level
subroutine cp_error_common_stop (fromWhere, message)
 a subroutine that call just stop, useful because all the failures fails calling this routine: the right point to set a breakpoint
subroutine, public cp_error_handle_error (error, fromWhere, message, ionode)
 all the error situations at the end should call this routine
subroutine, public cp_error_message (level, fromWhere, message, error)
 writes an error message of level level, subject to control of error (i.e. if errorprintlevel is >= level)
subroutine, public cp_assert (condition, level, error_nr, fromWhere, message, error, failure, info, only_ionode)
 routine that checks an assertion, if it fails set the optional argument failure is given sets it to true. This can be used to do many assertion one fater the other and check at the end if one failed.
subroutine, public cp_error_propagate_error (iError, fromWhere, message, error, failure, failure_level)
 if the internal error iError of a subroutine has an error levele that is at least failure_level(i.e. if there was a serious error in the subroutine) propagates the error to the actual error (i.e. sets error to the same error than iError) and sets failure to true if a failure more severe than warning happened
subroutine, public cp_unimplemented_error (fromWhere, message, error, error_level)
 comodity call to signat that something is not implemented
subroutine, public cp_error_synchronize_error (error, para_env)
 synchronizes the error values between different processors (propagating an eventual failure to each processor)
subroutine, public cp_a_l (condition, level, fromWhere, lineNr, error, failure)
 assert with linenumber (to be used with the assertion macros to keep the line short)
subroutine, public cp_error_check (error, failure)
 if error is present sets failure to true if an error did happen
subroutine, public cp_simple_assert (condition, routineP, line)
 simple assert

Variables

LOGICAL, parameter, private debug_this_module = .FALSE.
CHARACTER(len=*), parameter,
private 
moduleN = 'cp_error_handling'
LOGICAL, parameter, public cp_debug = .FALSE.
INTEGER, parameter, public cp_no_error = 0
INTEGER, parameter, public cp_caller_error = 1
INTEGER, parameter, public cp_wrong_args_error = 100
INTEGER, parameter, public cp_precondition_failed = 200
INTEGER, parameter, public cp_internal_error = -1
INTEGER, parameter, public cp_postcondition_failed = -200
INTEGER, parameter, public cp_invariant_failed = -100
INTEGER, parameter, public cp_assertion_failed = -300
INTEGER, parameter, public cp_unimplemented_error_nr = -1000

Detailed Description

Module that contains the routines for error handling The idea is that in general routines have an optional parameter that can be used to change the error behaviour.

Note:
In general 0 means no error, a negative error code means an internal error (in the routine, postcondition failure), and a positive error an error on the side of the caller (precondition failure). Error numbers in the dange -1000..1000 are reserved for generic error codes. Inspired from the nag nl90 library. Some help on this is also available in the high level dev notes on pao.

The following error levels are defined: 0 - note : CP_NOTE_LEVEL 1 - warning : CP_WARNING_LEVEL 2 - failure : CP_FAILURE_LEVEL 3 - fatal : CP_FATAL_LEVEL You shouldn't use the numbers but the constants defined in cp_log_handling

History
none
Author:
Fawzi Mohamed
Version:
1.2002

Function Documentation

subroutine,public cp_error_handling::cp_a_l ( LOGICAL,intent(in)  condition,
INTEGER,intent(in)  level,
CHARACTER(len=*),intent(in)  fromWhere,
INTEGER,intent(in)  lineNr,
TYPE(cp_error_type),intent(inout),optional  error,
LOGICAL,intent(inout),optional  failure 
)

assert with linenumber (to be used with the assertion macros to keep the line short)

Parameters:
from_
errorvariable to control error logging, stopping,... see module cp_error_handling
History
12.2002 created [fawzi]
Author:
fawzi

Definition at line 732 of file cp_error_handling.f90.

References cp_assert(), and cp_assertion_failed.

Here is the call graph for this function:

subroutine,public cp_error_handling::cp_assert ( LOGICAL,intent(in)  condition,
INTEGER,intent(in)  level,
INTEGER,intent(in)  error_nr,
CHARACTER(len=*),intent(in)  fromWhere,
CHARACTER(len=*),intent(in)  message,
TYPE(cp_error_type),intent(inout),optional  error,
LOGICAL,intent(inout),optional  failure,
CHARACTER(len=*),optional  info,
LOGICAL,intent(in),optional  only_ionode 
)

routine that checks an assertion, if it fails set the optional argument failure is given sets it to true. This can be used to do many assertion one fater the other and check at the end if one failed.

Parameters:
conditionthe condition to check, if true does nothing
levelthe level of the error (cp_note_level, cp_warning_level,
error_nrthe number of the error
fromWherea string that contains the module name and routine name where this test happened
messagethe error message
errorthe error type that controls error reporting (optional)
failureis set to true if the condition is false otherwise it is not changed (optional)
History
none
Author:
Fawzi Mohamed
Version:
1.2002

Definition at line 539 of file cp_error_handling.f90.

References cp_error_dealloc_ref(), cp_error_get_logger(), cp_error_handle_error(), cp_error_init(), debug_this_module, and error.

Referenced by cp_a_l(), cp_error_synchronize_error(), cp_ma_interface::cp_ma_current_thread_run(), cp_ma_interface::cp_ma_get_cuDev(), cp_ma_interface::cp_ma_mempol(), cp_ma_interface::cp_ma_mpi_sched(), cp_ma_interface::cp_ma_print_config(), cp_ma_interface::cp_ma_print_machine(), cp_ma_interface::cp_ma_run_on(), cp_ma_interface::cp_ma_set_neighbors(), cp_ma_interface::cp_ma_thread_run_on(), cp_ma_interface::cp_ma_thread_sched(), cp_ma_interface::cp_ma_verify_place(), and cp_unimplemented_error().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_error_handling::cp_error_check ( TYPE(cp_error_type),intent(in),optional  error,
LOGICAL,intent(inout),optional  failure 
)

if error is present sets failure to true if an error did happen

Parameters:
errorthe error to check for failure
failureset to true if there was an error
History
11.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 755 of file cp_error_handling.f90.

subroutine cp_error_handling::cp_error_common_stop ( CHARACTER(len=*),intent(in)  fromWhere,
CHARACTER(len=*),intent(in)  message 
) [private]

a subroutine that call just stop, useful because all the failures fails calling this routine: the right point to set a breakpoint

Parameters:
fromWhere'module:routine' that called this function
messagean error message
History
none
Author:
Fawzi Mohamed
Version:
2.2002

Definition at line 438 of file cp_error_handling.f90.

References cp_log_handling::cp_logger_get_default_unit_nr(), message_passing::mp_abort(), and termination::print_message().

Referenced by cp_error_dealloc_ref(), cp_error_get_logger(), and cp_error_reset().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_error_handling::cp_error_dealloc_ref ( TYPE(cp_error_type),intent(inout)  err_to_free,
TYPE(cp_error_type),intent(inout),optional  error 
)

Deallocates the memory allocated by the error.

Parameters:
err_to_freethe error that gets deallocated
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
actually the error allocates no memory, and it is better if it stays so even in the future, but I have written this routine to remain consistent with the generic types
History
none
Author:
Fawzi Mohamed
Version:
1.2002

Definition at line 267 of file cp_error_handling.f90.

References cp_error_common_stop(), cp_log_handling::cp_get_default_logger(), and cp_log_handling::cp_logger_release().

Referenced by cp_assert().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_error_handling::cp_error_get ( TYPE(cp_error_type),intent(inout)  error,
INTEGER,intent(out),optional  level,
INTEGER,intent(out),optional  error_nr,
INTEGER,intent(out),optional  stop_level,
INTEGER,intent(out),optional  print_level,
TYPE(cp_logger_type),optional,pointer  logger,
CHARACTER(LEN=*),optional  info 
)

returns the various attributes of the given error

Parameters:
errorvariable to control error logging, stopping,... see module cp_error_handling
History
none
Author:
Fawzi Mohamed
Version:
1.2002

Definition at line 299 of file cp_error_handling.f90.

References cp_error_get_logger().

Here is the call graph for this function:

INTEGER,public cp_error_handling::cp_error_get_level ( TYPE(cp_error_type),intent(in),optional  error)

gets the error level from the given error

Parameters:
errorthe error you take the info from
History
none
Author:
Fawzi Mohamed
Version:
1.2002

Definition at line 325 of file cp_error_handling.f90.

Referenced by cp_error_propagate_error().

Here is the caller graph for this function:

TYPE(cp_logger_type),pointer,public cp_error_handling::cp_error_get_logger ( TYPE(cp_error_type),intent(in),optional  error)

gets the logger of the given error. The error argument is optional, so you can get the logger of an optional dummy argument. If the error is not present or its logger is not associated returns the default logger.

Parameters:
errorthe error you take the info from (optional)
History
none
Author:
Fawzi Mohamed
Version:
1.2002

Definition at line 391 of file cp_error_handling.f90.

References cp_error_common_stop(), and cp_log_handling::cp_get_default_logger().

Referenced by cp_assert(), cp_error_get(), cp_error_handle_error(), cp_error_message(), cp_error_synchronize_error(), cp_ma_interface::cp_ma_current_thread_run(), cp_ma_interface::cp_ma_get_cuDev(), cp_ma_interface::cp_ma_init_lib(), cp_ma_interface::cp_ma_print_config(), cp_ma_interface::cp_ma_print_machine(), cp_ma_interface::cp_ma_print_strategy(), cp_ma_interface::cp_ma_run_on(), cp_ma_interface::cp_ma_thread_run_on(), and cp_ma_interface::cp_ma_verify_place().

Here is the call graph for this function:

Here is the caller graph for this function:

INTEGER,public cp_error_handling::cp_error_get_nr ( TYPE(cp_error_type),intent(in),optional  error)

gets the error number from the given error

Parameters:
errorthe error you take the info from
History
none
Author:
Fawzi Mohamed
Version:
2.2002

Definition at line 367 of file cp_error_handling.f90.

INTEGER,public cp_error_handling::cp_error_get_print_level ( TYPE(cp_error_type),intent(in),optional  error)

gets the print level (starting with which errorlevel something gets printed) from the given error if the error is not present returns cp_note_level

Parameters:
errorthe error you take the info from (optional)
History
none
Author:
Fawzi Mohamed
Version:
.2002

Definition at line 347 of file cp_error_handling.f90.

References cp_log_handling::cp_note_level.

Referenced by cp_error_message(), and cp_error_propagate_error().

Here is the caller graph for this function:

INTEGER,public cp_error_handling::cp_error_get_stop_level ( TYPE(cp_error_type),intent(in),optional  error)

gets the error level at which the error will stop the programm If the error is not present returns cp_failure_level

Parameters:
errorthe error you take the info from (optional)
History
none
Author:
Fawzi Mohamed
Version:
2.2002

Definition at line 414 of file cp_error_handling.f90.

References cp_log_handling::cp_failure_level.

subroutine,public cp_error_handling::cp_error_handle_error ( TYPE(cp_error_type),intent(in)  error,
CHARACTER(len=*),intent(in)  fromWhere,
CHARACTER(len=*),intent(in)  message,
LOGICAL,intent(in)  ionode 
)

all the error situations at the end should call this routine

main function for error logging, most error reporting ends up calling this function, great place to put a breakpoint if you want to catch errors that do not stop the program.

Parameters:
errorthe error you take the info from (optional)
History
none
Author:
Fawzi Mohamed
Version:
2.2002

Definition at line 462 of file cp_error_handling.f90.

References cp_error_get_logger(), cp_error_message(), cp_log_handling::cp_logger_get_default_unit_nr(), debug_this_module, message_passing::mp_abort(), and timings::print_stack().

Referenced by cp_assert().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_error_handling::cp_error_init ( TYPE(cp_error_type),intent(out)  error,
INTEGER,intent(in),optional  stop_level,
INTEGER,intent(in),optional  print_level,
TYPE(cp_logger_type),optional,pointer  logger,
TYPE(cp_error_type),intent(in),optional  template_error,
INTEGER,intent(in),optional  error_nr,
INTEGER,intent(in),optional  level 
)

Initializes the error structure error. The optional arguments initialize the values in the structure. Default values: stop_level=2, logger=null (i.e. default logger)

Parameters:
errorthe error that will be initialized
stop_levelthe stop level of the newly created error (defaults to cp_failure_level)
print_levelthe print level of the newly created error (defaults to cp_note_level)
loggerthe logger where errors are written (defaults to the default logger)
template_erroran error that gives the default values for the previous variables (useful to initialize an internal error)
History
none
Author:
Fawzi Mohamed
Version:
2.2002

Definition at line 148 of file cp_error_handling.f90.

References cp_log_handling::cp_logger_retain().

Referenced by cp_assert().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_error_handling::cp_error_message ( INTEGER,intent(in)  level,
CHARACTER(len=*),intent(in)  fromWhere,
CHARACTER(len=*),intent(in)  message,
TYPE(cp_error_type),intent(in),optional  error 
)

writes an error message of level level, subject to control of error (i.e. if errorprintlevel is >= level)

Parameters:
levelthe level of the error (cp_note_level, cp_warning_level,
fromWherea string that contains the module name and routine name where this test happened
messagethe error message
errorthe error type that controls error reporting (optional)
History
none
Author:
Fawzi Mohamed
Version:
1.2002

Definition at line 506 of file cp_error_handling.f90.

References cp_error_get_logger(), and cp_error_get_print_level().

Referenced by cp_error_handle_error(), and cp_error_propagate_error().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_error_handling::cp_error_propagate_error ( TYPE(cp_error_type),intent(in)  iError,
CHARACTER(len=*)  fromWhere,
CHARACTER(len=*),optional  message,
TYPE(cp_error_type),intent(inout),optional  error,
LOGICAL,intent(inout),optional  failure,
INTEGER,intent(in),optional  failure_level 
)

if the internal error iError of a subroutine has an error levele that is at least failure_level(i.e. if there was a serious error in the subroutine) propagates the error to the actual error (i.e. sets error to the same error than iError) and sets failure to true if a failure more severe than warning happened

Parameters:
iErrorthe error object that comes from the subroutine
errorthe error object in the actual routine
failureif iError has an error it is set to true
failure_levelstarting with which error level propagation happens (defaults to cp_warning_level)
History
none
Author:
Fawzi Mohamed
Version:
1.2002

Definition at line 603 of file cp_error_handling.f90.

References cp_error_get_level(), cp_error_get_print_level(), cp_error_message(), cp_log_handling::cp_warning_level, and debug_this_module.

Here is the call graph for this function:

subroutine,public cp_error_handling::cp_error_reset ( TYPE(cp_error_type),intent(inout),optional  error)

if the optional parameter error is present resets its level and error_nr to 0 (is tipically called when you want to discard the previous errors stored in error, i.e. not often)

Parameters:
errorthe error you want to reset
History
none
Author:
Fawzi Mohamed
Version:
2.2002

Definition at line 196 of file cp_error_handling.f90.

References cp_error_common_stop(), and cp_log_handling::cp_get_default_logger().

Here is the call graph for this function:

subroutine,public cp_error_handling::cp_error_set ( TYPE(cp_error_type),intent(inout)  error,
INTEGER,intent(in),optional  level,
INTEGER,intent(in),optional  error_nr,
INTEGER,intent(in),optional  stop_level,
INTEGER,intent(in),optional  print_level,
TYPE(cp_logger_type),optional,pointer  logger,
TYPE(cp_error_type),intent(in),optional  template_error,
CHARACTER(LEN=*),optional  info 
)

routine to set the various components of the error structure

Parameters:
errorthe error you want to change
template_errorgives the default values of logger, stop_level and print_level (but not of level and error_nr)
History
none
Author:
Fawzi Mohamed
Version:
2.2002

Definition at line 223 of file cp_error_handling.f90.

References cp_log_handling::cp_logger_release(), and cp_log_handling::cp_logger_retain().

Here is the call graph for this function:

subroutine,public cp_error_handling::cp_error_synchronize_error ( TYPE(cp_error_type),intent(inout),optional  error,
TYPE(cp_para_env_type),optional,pointer  para_env 
)

synchronizes the error values between different processors (propagating an eventual failure to each processor)

Parameters:
errorthe error to synchronize
Note:
allow for non uniform presence of the error argument?)
Author:
fawzi

Definition at line 687 of file cp_error_handling.f90.

References cp_assert(), cp_error_get_logger(), and cp_log_handling::cp_failure_level.

Here is the call graph for this function:

subroutine,public cp_error_handling::cp_simple_assert ( LOGICAL,intent(in)  condition,
CHARACTER(len=*),intent(in)  routineP,
INTEGER,intent(in)  line 
)

simple assert

Note:
you should use the CPAssert and similar macros defined in cp_prep_globals.h that call cp_a_l
History
, TCH, created
See also:
cp_a_l

Definition at line 781 of file cp_error_handling.f90.

subroutine,public cp_error_handling::cp_unimplemented_error ( CHARACTER(len=*),intent(in)  fromWhere,
CHARACTER(len=*),intent(in),optional  message,
TYPE(cp_error_type),intent(inout),optional  error,
INTEGER,intent(in),optional  error_level 
)

comodity call to signat that something is not implemented

Parameters:
fromWhereroutine where the error happened
messagethe message to write out (UNIMPLEMENTED is added to it)
error_levelthe error level of this error, defaults to cp_failure_level
errorvariable to control error logging, stopping,... see module cp_error_handling
History
05.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 655 of file cp_error_handling.f90.

References cp_assert(), cp_log_handling::cp_failure_level, and cp_unimplemented_error_nr.

Here is the call graph for this function:


Variable Documentation

Definition at line 90 of file cp_error_handling.f90.

Referenced by cp_a_l().

Definition at line 78 of file cp_error_handling.f90.

LOGICAL,parameter,public cp_error_handling::cp_debug = .FALSE.

Definition at line 72 of file cp_error_handling.f90.

Definition at line 84 of file cp_error_handling.f90.

Definition at line 88 of file cp_error_handling.f90.

Definition at line 76 of file cp_error_handling.f90.

Definition at line 86 of file cp_error_handling.f90.

Definition at line 82 of file cp_error_handling.f90.

Definition at line 80 of file cp_error_handling.f90.

LOGICAL,parameter,private cp_error_handling::debug_this_module = .FALSE.
CHARACTER(len=*),parameter,private cp_error_handling::moduleN = 'cp_error_handling'

Definition at line 47 of file cp_error_handling.f90.