error_handling_m Module

Contains functionality for error handling


Used by


Enumerations

enum, bind(c)

Enumerators

enumerator:: ERRORS_RETURN = 0
enumerator:: ERRORS_ARE_FATAL = 1

Description

Enumerator defining the error mode


Derived Types

type, public ::  error_info_t

Specifies additional user defined output for an error message that contains more than a simple message. May have a descriptive string and one dimensional integer and real arrays to print out variables.

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: c_info

Additional user defined string message

integer, public, dimension(:), allocatable :: i_info

Additional user defined integer variables

real(kind=FP), public, dimension(:), allocatable :: r_info

Additional user defined real variables

Type-Bound Procedures

procedure, public :: print => print_error_info

type, public ::  error_handler_t

Type that can be used to handle errors for multiple code instances at once. Each calling code may create a singleton instance of this type. There is no initialize routine, the instance should be initialized via the constructor.

Components

Type Visibility Attributes Name Initial
character(len=32), public :: handler_name

Name of the error handler instance

integer, public :: error_mode

Error mode chosen, can be either ERRORS_RETURN or ERRORS_ARE_FATAL

integer, public :: netcdf_error_code

Error code that is associated with NetCDF errors. Used when handling NetCDF errors.

logical, public :: first_time_warning = .true.

Indicates that a warning has already been printed before or not

Type-Bound Procedures

procedure, public :: set_error_mode => error_handler_set_error_mode
procedure, public :: handle_error => error_handler_handle_error
procedure, public :: handle_error_netcdf => error_handler_handle_error_netcdf

Subroutines

public subroutine set_error_mode(err_mode)

Sets the way PARALLAX responds to internal errors. When set to errors return, the error is logged into stderr without program termination, expecting that the error will be handled by the calling routine. When set to errors are fatal, the code will be terminated with error stop.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: err_mode

Error mode: Use ERRORS_RETURN or ERRORS_ARE_FATAL. Other values are ignored and ERRORS_ARE_FATAL is used.

public subroutine handle_error(message, status_code, line_number, file_name, additional_info)

Logs an error to stderr and stops the program. If status_code is PARALLAX_SUCCESS, this subroutine will do nothing.

Read more…

Arguments

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

Error or warning message

integer, intent(in) :: status_code

Error or warning code

integer, intent(in) :: line_number

Line number where error or warning occured, i.e. LINE

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

File name where error or warning occured, i.e. FILE

type(error_info_t), intent(in), optional :: additional_info

Additional information

public subroutine handle_error_netcdf(istatus, line_number, file_name)

Wrapper of handle error for calls of NetCDF functions. Checks for NetCDF errors and prints a standardized error message.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istatus

Status integer returned by the NetCDF function

integer, intent(in) :: line_number

Line number where error or warning occured, i.e. LINE

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

File name where error or warning occured, i.e. FILE