cable_error_handler_mod Module

This module provides error handling functionality that can be used throughout the CABLE codebase.

Error handling behaviour is controlled internally by either the global error handler instance (error_handler_global) or the fallback error handler instance (error_handler_fallback). The global error handler instance can be set via cable_error_handler_set to provide custom error handling behaviour, while the fallback error handler instance provides a default implementation of the error handling behaviour. The global error handler is polymorphic which allows for customising the error handling behaviour dynamically at runtime. To do this we can create a new type that extends cable_error_handler_base_t with the new error handling behaviour and set the global error handler to an instance of the extended type.



Variables

Type Visibility Attributes Name Initial
type(cable_error_handler_base_t), private, target :: error_handler_fallback = cable_error_handler_base_t()
class(cable_error_handler_base_t), private, allocatable, target :: error_handler_global

Subroutines

public subroutine cable_error_handler_set(new_error_handler)

Set the global error handler instance.

Arguments

Type IntentOptional Attributes Name
class(cable_error_handler_base_t), intent(in) :: new_error_handler

New error handler instance to set as the global error handler.

public subroutine cable_error_handler_free()

Free the global error handler instance.

Arguments

None

public subroutine cable_abort(message, file, line, error_code)

Abort CABLE with an error message.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: message

Error message to display

character(len=*), intent(in) :: file

Source file where the error occurred

integer, intent(in) :: line

Line number where the error occurred

integer, intent(in), optional :: error_code

Optional error code