check_aot_error_vector Subroutine

private subroutine check_aot_error_vector(iError, key, event_string)

Auxiliary subroutine to check on errors from attempting to get an array of 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_vector( 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

    integer :: iComp

    if (any(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
      do iComp=lbound(iError,1),ubound(iError,1)
        if (btest(iError(iComp), aoterr_NonExistent)) then
          write(logUnit(0),"(a,i0,a)") ' -> expected value "'//trim(key)//'[', &
            &                        iComp, ']" not found!'
        end if
        if (btest(iError(iComp), aoterr_WrongType)) then
          write(logUnit(0),"(a,i0,a)") ' -> value "'//trim(key)//'[', iComp, &
            &                        ']" has wrong type!'
        end if
      end do
      write(logUnit(0),*) 'Aborting... '
      call tem_abort()
    end if
  end subroutine check_aot_error_vector