check_aot_error_scalar Subroutine

private subroutine check_aot_error_scalar(iError, key, event_string)

Auxiliary subroutine to check on errors from attempting to get values from the Lua script with aot_get_val.

If a fatal error was encountered, the routine aborts the program!

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iError

aoterr code to interpret (returned by aot_get_val)

character(len=*), intent(in) :: key

Lua key that was attempted to be read

character(len=*), intent(in), optional :: event_string

Optional event string to describe the circumstances


Source Code

  subroutine check_aot_error_scalar( iError, key, event_string )
    !> aoterr code to interpret (returned by aot_get_val)
    integer, intent(in) :: iError
    !> Lua key that was attempted to be read
    character(len=*), intent(in) :: key
    !> Optional event string to describe the circumstances
    character(len=*), intent(in), optional :: event_string

    if (btest(iError, aoterr_Fatal)) then
      if (present(event_string)) then
        write(logUnit(0),*) 'Lua Error while ' // trim(event_string) // '!'
      else
        write(logUnit(0),*) 'Encountered Lua Error for ' // trim(key) // '!'
      end if
      if (btest(iError, aoterr_NonExistent)) then
        write(logUnit(0),*) ' -> expected value "'//trim(key)//'" not found!'
      end if
      if (btest(iError, aoterr_WrongType)) then
        write(logUnit(0),*) ' -> value "'//trim(key)//'" has wrong type!'
      end if
      write(logUnit(0),*) 'Aborting... '
      call tem_abort()
    end if
  end subroutine check_aot_error_scalar