Module s2fil_error_mod

module s2fil_error_mod

        ! Uses
    use s2_types_mod, only: S2_STRING_LEN

        ! Variables
    integer, private, parameter :: S2FIL_ERROR_NUM = 16
    integer, public, parameter :: S2FIL_ERROR_NONE = 0
    integer, public, parameter :: S2FIL_ERROR_INIT = 1
    integer, public, parameter :: S2FIL_ERROR_NOT_INIT = 2
    integer, public, parameter :: S2FIL_ERROR_INIT_FAIL = 3
    integer, public, parameter :: S2FIL_ERROR_SIZE_INVALID = 4
    integer, public, parameter :: S2FIL_ERROR_MEM_ALLOC_FAIL = 5
    integer, public, parameter :: S2FIL_ERROR_FILTER_TYPE_INVALID = 6
    integer, public, parameter :: S2FIL_ERROR_SCALE_TYPE_INVALID = 7
    integer, public, parameter :: S2FIL_ERROR_DIV_BY_ZERO = 8
    integer, public, parameter :: S2FIL_ERROR_PROG_INPUT_INVALID = 9
    integer, public, parameter :: S2FIL_ERROR_BEAM_NOT_DEF = 10
    integer, public, parameter :: S2FIL_ERROR_FIL_FILE_EXISTS = 11
    integer, public, parameter :: S2FIL_ERROR_FIL_FILE_INVALID = 12
    integer, public, parameter :: S2FIL_ERROR_FIELD_TR_DEF = 13
    integer, public, parameter :: S2FIL_ERROR_FIELD_FILE_EXISTS = 14
    integer, public, parameter :: S2FIL_ERROR_FIELD_FILE_INVALID = 15
    character (len=S2_STRING_LEN), private, parameter, dimension (S2FIL_ERROR_NUM) :: error_comment = (/ 'No error                                                                 ', 'Object already initialised                                               ', 'Object not initialised                                                   ', 'Object initialisation failed                                             ', 'Sizes invalid                                                            ', 'Memory allocation failed                                                 ', 'Invalid filter type                                                      ', 'Invalid scale type                                                       ', 'Divide by zero avoided                                                   ', 'Invalid program command line option                                      ', 'Beam not defined                                                         ', 'Filter file already exists                                               ', 'Filter file invalid                                                      ', 'Filtered field already defined                                           ', 'Field file already exists                                                ', 'Field file invalid                                                       ' /)
    logical, private, parameter, dimension (S2FIL_ERROR_NUM) :: halt_default = (/ .false., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true. /)

        ! Subroutines and functions
    public subroutine s2fil_error (error_code, procedure, comment_add, comment_out, halt_in)

end module s2fil_error_mod
Functionality to handle errors that may occur in the S2FIL library. Public S2FIL 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 - January 2005


Description of Variables

S2FIL_ERROR_NUM

integer, private, parameter :: S2FIL_ERROR_NUM = 16

S2FIL_ERROR_NONE

integer, public, parameter :: S2FIL_ERROR_NONE = 0

S2FIL_ERROR_INIT

integer, public, parameter :: S2FIL_ERROR_INIT = 1

S2FIL_ERROR_NOT_INIT

integer, public, parameter :: S2FIL_ERROR_NOT_INIT = 2

S2FIL_ERROR_INIT_FAIL

integer, public, parameter :: S2FIL_ERROR_INIT_FAIL = 3

S2FIL_ERROR_SIZE_INVALID

integer, public, parameter :: S2FIL_ERROR_SIZE_INVALID = 4

S2FIL_ERROR_MEM_ALLOC_FAIL

integer, public, parameter :: S2FIL_ERROR_MEM_ALLOC_FAIL = 5

S2FIL_ERROR_FILTER_TYPE_INVALID

integer, public, parameter :: S2FIL_ERROR_FILTER_TYPE_INVALID = 6

S2FIL_ERROR_SCALE_TYPE_INVALID

integer, public, parameter :: S2FIL_ERROR_SCALE_TYPE_INVALID = 7

S2FIL_ERROR_DIV_BY_ZERO

integer, public, parameter :: S2FIL_ERROR_DIV_BY_ZERO = 8

S2FIL_ERROR_PROG_INPUT_INVALID

integer, public, parameter :: S2FIL_ERROR_PROG_INPUT_INVALID = 9

S2FIL_ERROR_BEAM_NOT_DEF

integer, public, parameter :: S2FIL_ERROR_BEAM_NOT_DEF = 10

S2FIL_ERROR_FIL_FILE_EXISTS

integer, public, parameter :: S2FIL_ERROR_FIL_FILE_EXISTS = 11

S2FIL_ERROR_FIL_FILE_INVALID

integer, public, parameter :: S2FIL_ERROR_FIL_FILE_INVALID = 12

S2FIL_ERROR_FIELD_TR_DEF

integer, public, parameter :: S2FIL_ERROR_FIELD_TR_DEF = 13

S2FIL_ERROR_FIELD_FILE_EXISTS

integer, public, parameter :: S2FIL_ERROR_FIELD_FILE_EXISTS = 14

S2FIL_ERROR_FIELD_FILE_INVALID

integer, public, parameter :: S2FIL_ERROR_FIELD_FILE_INVALID = 15

error_comment

character (len=S2_STRING_LEN), private, parameter, dimension (S2FIL_ERROR_NUM) :: error_comment = (/ 'No error                                                                 ', 'Object already initialised                                               ', 'Object not initialised                                                   ', 'Object initialisation failed                                             ', 'Sizes invalid                                                            ', 'Memory allocation failed                                                 ', 'Invalid filter type                                                      ', 'Invalid scale type                                                       ', 'Divide by zero avoided                                                   ', 'Invalid program command line option                                      ', 'Beam not defined                                                         ', 'Filter file already exists                                               ', 'Filter file invalid                                                      ', 'Filtered field already defined                                           ', 'Field file already exists                                                ', 'Field file invalid                                                       ' /)
Comment associated with each error type.

halt_default

logical, private, parameter, dimension (S2FIL_ERROR_NUM) :: halt_default = (/ .false., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true., .true. /)
Default program halt status of each error type.

Description of Subroutines and Functions

s2fil_error

public subroutine s2fil_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 s2fil_error
Display error message corresponding to error_code and halt program execution if required.

Variables:

Author: J. D. McEwen

Version: 0.2 - November 2004