error_handling Module

Error handling module for PROCESS author: P J Knight, CCFE, Culham Science Centre N/A This module provides a centralised method for dealing with errors generated by PROCESS.

All possible informational/error messages are initialised via a call to initialise_error_list. Thereafter, any routine that needs to flag a message should call report_error with the relevant error identifier as the argument. Up to eight integer and eight floating-point diagnostic values may be saved by the user in arrays idiags and fdiags, respectively, for debugging purposes.

The list of messages reported during the course of a run may be displayed by calling routine show_errors.

The error_status variable returns the highest severity level that has been encountered; if a severe error is flagged (level 3) the program is terminated immediately. None



Contents


Variables

TypeVisibility AttributesNameInitial
logical, public :: errors_on
integer, private, parameter:: ERROR_OKAY =0
integer, private, parameter:: ERROR_INFO =1
integer, private, parameter:: ERROR_WARN =2
integer, private, parameter:: ERROR_SEVERE =3
integer, private :: error_id

error_id : identifier for final message encountered

integer, public :: error_status

error_status : overall status flag for a run; on exit:

  • 0 all okay
  • 1 informational messages have been encountered
  • 2 warning (non-fatal) messages have been encountered
  • 3 severe (fatal) errors have occurred

integer, private, parameter:: INT_DEFAULT =-999999
real(kind=dp), private, parameter:: FLT_DEFAULT =real(INT_DEFAULT, kind(1.0D0))
integer, public, dimension(8):: idiags
real(kind=dp), public, dimension(8):: fdiags
type(error_list_item), private, pointer:: error_head
type(error_list_item), private, pointer:: error_tail
type(error), private, allocatable, dimension(:):: error_type

Derived Types

type, private :: error

Components

TypeVisibility AttributesNameInitial
integer, public :: level
character(len=200), public :: message
integer, public, dimension(8):: idiags =INT_DEFAULT
real(kind=dp), public, dimension(8):: fdiags =FLT_DEFAULT

type, private :: error_list_item

Components

TypeVisibility AttributesNameInitial
integer, public :: id
type(error), public :: data
type(error_list_item), public, pointer:: ptr

Subroutines

public subroutine init_error_handling()

Initialise the error_handling module variables

Arguments

None

public subroutine initialise_error_list()

Initialises the informational/error message list author: P J Knight, CCFE, Culham Science Centre None This routine sets all the possible informational/error messages that may be used during the course of a run. Thus, it needs to be called during the initialisation phase.

The error messages are read in from a JSON-format file. None

Arguments

None

public subroutine report_error(error_id)

Adds the latest error message to the list already specified author: P J Knight, CCFE, Culham Science Centre error_id : input integer : identifier (error_type element number) for the relevant error This routine should be called if a informational, warning or error message needs to be flagged. It uses a linked list (see references) to provide an audit trail for any such messages during the program execution.

Up to eight integer and eight floating-point diagnostic values may be saved by the user in arrays idiags and fdiags, respectively, for debugging; these arrays must be assigned with up to eight values each prior to calling this routine.

The error_status variable returns the highest severity level that has been encountered; if a severe error is flagged (level 3) the program is terminated immediately. Introduction to Fortran 90/95, Stephen J, Chapman, pp.467-472, McGraw-Hill, ISBN 0-07-115896-0

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: error_id

public subroutine show_errors()

Reports all informational/error messages encountered author: P J Knight, CCFE, Culham Science Centre None This routine provides a summary audit trail of all the errors encountered during the program's execution. Introduction to Fortran 90/95, Stephen J, Chapman, pp.467-472, McGraw-Hill, ISBN 0-07-115896-0

Arguments

None