error_handler_t Derived Type

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

  • interface

    private module subroutine error_handler_set_error_mode(this, err_mode)

    Set the error mode of the type instance

    Arguments

    Type IntentOptional Attributes Name
    class(error_handler_t), intent(inout) :: this

    Instance of the type

    integer, intent(in) :: err_mode

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

procedure, public :: handle_error => error_handler_handle_error

  • interface

    private module subroutine error_handler_handle_error(this, message, status_code, line_number, file_name, additional_info)

    Handle the given error by printing out messages and terminating the program if status_code is an error code.

    Arguments

    Type IntentOptional Attributes Name
    class(error_handler_t), intent(inout) :: this

    Instance of the type

    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

procedure, public :: handle_error_netcdf => error_handler_handle_error_netcdf

  • interface

    private module subroutine error_handler_handle_error_netcdf(this, istatus, line_number, file_name)

    Handle the given NetCDF error by calling handle_error with special preprocessing taylored to NetCDF errors.

    Arguments

    Type IntentOptional Attributes Name
    class(error_handler_t), intent(inout) :: this

    Instance of the type

    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