initialise_error_list Subroutine

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

Contents

Source Code


Source Code

  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.
    !! <P>The error messages are read in from a JSON-format file.
    !! None
    !
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    use fson_library, only: fson_parse, fson_value, fson_get, fson_destroy
    implicit none

    !  Arguments

    !  Local variables

    integer :: n_errortypes
    character(len=180) :: filename
    type(fson_value), pointer :: errorfile

    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    !  Parse the json file
    character(len=200) :: process_dir
    CALL get_environment_variable("PYTHON_PROCESS_ROOT", process_dir)
    if (process_dir == "") then
      filename = INSTALLDIR//'/process//utilities/errorlist.json'
    else
      filename = trim(process_dir)//'/utilities/errorlist.json'
    end if
    errorfile => fson_parse(trim(filename))

    !  Allocate memory for error_type array contents

    call fson_get(errorfile, "n_errortypes", n_errortypes)

    ! Guard against re-allocation
    if (allocated(error_type)) deallocate(error_type)
    allocate(error_type(n_errortypes))

    error_type(:)%level = ERROR_OKAY
    error_type(:)%message = ' '

    !  Extract information arrays from the file

    call fson_get(errorfile, "errors", "level", error_type%level)
    call fson_get(errorfile, "errors", "message", error_type%message)

    !  Clean up

    call fson_destroy(errorfile)

  end subroutine initialise_error_list