module s2dw_error_mod
        ! Uses
    use s2dw_types_mod, only: STRING_LEN
        ! Variables
    integer, private, parameter :: S2DW_ERROR_NUM = 14
    integer, public, parameter :: S2DW_ERROR_NONE = 0
    integer, public, parameter :: S2DW_ERROR_INIT = 1
    integer, public, parameter :: S2DW_ERROR_NOT_INIT = 2
    integer, public, parameter :: S2DW_ERROR_INIT_FAIL = 3
    integer, public, parameter :: S2DW_ERROR_MEM_ALLOC_FAIL = 4
    integer, public, parameter :: S2DW_ERROR_ARTH = 5
    integer, public, parameter :: S2DW_ERROR_ARTH_WARNING = 6
    integer, public, parameter :: S2DW_ERROR_SIZE_WARNING = 7
    integer, public, parameter :: S2DW_ERROR_SIZE_INVALID = 8
    integer, public, parameter :: S2DW_ERROR_SIZE_NOT_DEF = 9
    integer, public, parameter :: S2DW_ERROR_ARG_INVALID = 10
    integer, public, parameter :: S2DW_ERROR_ARG_WARNING = 11
    integer, public, parameter :: S2DW_ERROR_QUAD_STEP_EXCEED = 12
    integer, public, parameter :: S2DW_ERROR_ADMISS_FAIL = 13
    integer, public, parameter :: S2DW_ERROR_FILEIO = 14
    character (len=STRING_LEN), private, parameter, dimension (S2DW_ERROR_NUM+1) :: error_comment = (/ 'No error                                                                 ', 'Attempt to initialise object that has already been initialised           ', 'Object not initialised                                                   ', 'Object initialisation failed                                             ', 'Memory allocation failed                                                 ', 'Arithmetic exception                                                     ', 'Arithmetic warning                                                       ', 'Warning: Sizes not in recommended range                                  ', 'Invalid sizes                                                            ', 'Sizes not defined                                                        ', 'Arguments invalid                                                        ', 'Argument warning                                                         ', 'Exceeded number of steps limit whem computing quadrature                 ', 'Admissibility test failed (resolution of identity not satisfied)         ', 'File IO error                                                            ' /)
    logical, private, parameter, dimension (S2DW_ERROR_NUM+1) :: halt_default = (/ .false., .true., .true., .true., .true., .true., .false., .false., .true., .true., .true., .false., .true., .true., .true. /)
        ! Subroutines and functions
    public subroutine s2dw_error (error_code, procedure, comment_add, comment_out, halt_in)
end module s2dw_error_mod
 Functionality to handle errors that may occur in the s2dw library.  Public
 s2dw error codes are defined, with corresponding private error comments and 
 default halt execution status.
Author: J. D. McEwen (mcewen@mrao.cam.ac.uk)
Version: 0.1 October 2007
integer, private, parameter :: S2DW_ERROR_NUM = 14
integer, public, parameter :: S2DW_ERROR_NONE = 0
integer, public, parameter :: S2DW_ERROR_INIT = 1
integer, public, parameter :: S2DW_ERROR_NOT_INIT = 2
integer, public, parameter :: S2DW_ERROR_INIT_FAIL = 3
integer, public, parameter :: S2DW_ERROR_MEM_ALLOC_FAIL = 4
integer, public, parameter :: S2DW_ERROR_ARTH = 5
integer, public, parameter :: S2DW_ERROR_ARTH_WARNING = 6
integer, public, parameter :: S2DW_ERROR_SIZE_WARNING = 7
integer, public, parameter :: S2DW_ERROR_SIZE_INVALID = 8
integer, public, parameter :: S2DW_ERROR_SIZE_NOT_DEF = 9
integer, public, parameter :: S2DW_ERROR_ARG_INVALID = 10
integer, public, parameter :: S2DW_ERROR_ARG_WARNING = 11
integer, public, parameter :: S2DW_ERROR_QUAD_STEP_EXCEED = 12
integer, public, parameter :: S2DW_ERROR_ADMISS_FAIL = 13
integer, public, parameter :: S2DW_ERROR_FILEIO = 14
character (len=STRING_LEN), private, parameter, dimension (S2DW_ERROR_NUM+1) :: error_comment = (/ 'No error ', 'Attempt to initialise object that has already been initialised ', 'Object not initialised ', 'Object initialisation failed ', 'Memory allocation failed ', 'Arithmetic exception ', 'Arithmetic warning ', 'Warning: Sizes not in recommended range ', 'Invalid sizes ', 'Sizes not defined ', 'Arguments invalid ', 'Argument warning ', 'Exceeded number of steps limit whem computing quadrature ', 'Admissibility test failed (resolution of identity not satisfied) ', 'File IO error ' /)Comment associated with each error type.
logical, private, parameter, dimension (S2DW_ERROR_NUM+1) :: halt_default = (/ .false., .true., .true., .true., .true., .true., .false., .false., .true., .true., .true., .false., .true., .true., .true. /)Default program halt status of each error type.
public subroutine s2dw_error (error_code, procedure, comment_add, comment_out, halt_in)
    integer, intent(in) :: error_code
    character (len=*), optional, intent(in) :: procedure
    character (len=*), optional, intent(in) :: comment_add
    character (len=*), optional, intent(inout) :: comment_out
    logical, optional, intent(in) :: halt_in
end subroutine s2dw_error
 Displays error message corresponding to error_code and halt program 
 execution if required.
Variables:
Author: J. D. McEwen
Version: 0.1 August 2004