Harald Klimach avatar Harald Klimach committed 554b398

Changed the aot_get_value interface to use optional thandle instead of
dedicated interface for the global variables, to avoid need for distinguishing
in the calling routines for this difference.

Comments (0)

Files changed (12)

source/aot_table_module.f90

 module aot_table_module
   use flu_binding
   use aot_kinds_module, only: double_k, single_k, long_k
+  use aot_err_module, only: aoterr_Fatal, aoterr_NonExistent, &
+    &                       aoterr_WrongType
   use aot_top_module, only: aot_top_get_val
   use aot_table_ops_module, only: aot_table_open, aot_table_close, &
     &                             aot_table_length, aot_table_first, &
     module procedure set_table_logical
   end interface
 
-  !> Get a value from a table.
+  !> Get a value from the script.
   !!
+  !! This is the central interface to retrieve values from a Lua script,
+  !! its general shape looks like
+  !! <tt>call aot_{top}_get_val(<outputs>, <id>, default)</tt>.
+  !! Where the "outputs" are <tt>val</tt> and <tt>errCode</tt>. While "id" is
+  !! at least the Lua context <tt>L</tt>. For the global variables there has to
+  !! be a <tt>key</tt> for the identification of the variable.
+  !!
+  !! The <tt>errCode</tt> returns an error code with various bits set for
+  !! different errors, that might happen while retrieving the variable.
+  !! They can be checked by <tt>btest</tt> and the different error codes are:
+  !!- aoterr_fatal: Something went irrecoverably wrong
+  !!- aoterr_nonExistent: The requested variable is not set in the Lua script
+  !!- aoterr_wrongType: The requested variable in the Lua script does not meet
+  !!                    the requested data type
+  !!
+  !! For example a check for a fatal error can be done by
+  !! `btest(errCode, aoterr_fatal)`.
+  !!
+  !! For the access to global variables in the Lua script the interface
+  !! therefore looks like:
+  !! `call aot_get_val(val, errCode, L, key, default)`.
   !! First the given key is looked up, if this fails, the value
   !! at the given position is looked up, and if this also fails,
   !! the default value is returned.
   !! See for example get_table_real() for a more detailed
   !! description of the parameters.
   !!
-  !! Note that positional addressing only works intuitively as long as there
+  !! Note, that positional addressing only works intuitively as long as there
   !! have been no entries specified by keys in the table.
   !! This kind of resembles the behavior of Fortran interfaces with named or
   !! unnamed arguments, as soon as you provide a name, all following arguments
   !!
   !! The reason for this is, that positional addressing in Lua refers only to
   !! the unnamed entries of the tables.
+  !!
+  !! See for example aot_table_module#get_table_real for a more detailed
+  !! description of the parameters.
   interface aot_get_val
     module procedure get_table_real
     module procedure get_table_double
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     real(kind=single_k), intent(out) :: val
     !! the Lua script.
     real(kind=single_k), intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_real
 
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     real(kind=double_k), intent(out) :: val
     !! the Lua script.
     real(kind=double_k), intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_double
 
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     integer, intent(out) :: val
     !! the Lua script.
     integer, intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_integer
 
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     integer(kind=long_k), intent(out) :: val
     !! the Lua script.
     integer(kind=long_k), intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_long
 
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     logical, intent(out) :: val
     !! the Lua script.
     logical, intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_logical
 
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     character(len=*) :: val
     !! the Lua script.
     character(len=*), intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_string
 

source/aot_vector_module.f90

   !! specified to limit the allocated memory by these routines (and make the
   !! interfaces distinguishable).
   interface aot_get_val
-    module procedure get_config_real_vvect
-    module procedure get_config_double_vvect
-    module procedure get_config_integer_vvect
-    module procedure get_config_long_vvect
-    module procedure get_config_logical_vvect
-
     module procedure get_table_real_vvect
     module procedure get_table_double_vvect
     module procedure get_table_integer_vvect
   !! If the Lua table is longer than the available elements in the array
   !! only the first elements from the table will be stored in the array.
   interface aot_get_val
-    module procedure get_config_real_v
-    module procedure get_config_double_v
-    module procedure get_config_integer_v
-    module procedure get_config_long_v
-    module procedure get_config_logical_v
-
     module procedure get_table_real_v
     module procedure get_table_double_v
     module procedure get_table_integer_v
   subroutine get_table_real_vvect(val, ErrCode, maxlength, L, thandle, &
     &                             key, pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table, will have the same length as the table
     !! but not exceed maxlength, if provided.
     !! Components will be filled with the help of this default definition.
     real(kind=single_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                   key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_real_vvect
 
   subroutine get_table_double_vvect(val, ErrCode, maxlength, L, thandle, &
     &                               key, pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table, will have the same length as the table
     !! but not exceed maxlength, if provided.
     !! Components will be filled with the help of this default definition.
     real(kind=double_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                   key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_double_vvect
 
   subroutine get_table_integer_vvect(val, ErrCode, maxlength, L, thandle, &
     &                                key, pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table, will have the same length as the table
     !! but not exceed maxlength, if provided.
     !! Components will be filled with the help of this default definition.
     integer, intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                   key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_integer_vvect
 
   subroutine get_table_long_vvect(val, ErrCode, maxlength, L, thandle, &
     &                             key, pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table, will have the same length as the table
     !! but not exceed maxlength, if provided.
     !! Components will be filled with the help of this default definition.
     integer(kind=long_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                   key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_long_vvect
 
   subroutine get_table_logical_vvect(val, ErrCode, maxlength, L, thandle, &
     &                                key, pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table, will have the same length as the table
     !! but not exceed maxlength, if provided.
     !! Components will be filled with the help of this default definition.
     logical, intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                   key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_logical_vvect
 
 
 
-  !> This routine obtains a vectorial quantity with variable length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! For the dynamically sized array, which will be allocated, a upper limit
-  !! to allocate has to be specified.
-  subroutine get_config_real_vvect(val, ErrCode, maxlength, L, &
-    &                              key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table, will have the same length as the table
-    !! but not exceed maxlength, if provided.
-    real(kind=single_k), intent(out), allocatable :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! Will be allocated with the same length as the returned vector.
-    !! If the complete vector is not given in the Lua script, and no default
-    !! is provided, an zerosized array will be returned.
-    integer, intent(out), allocatable :: ErrCode(:)
-
-    !> Maximal length to allocate for the vector.
-    integer, intent(in) :: maxlength
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    real(kind=single_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted global variable
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
-
-  end subroutine get_config_real_vvect
-
-
-  !> This routine obtains a vectorial quantity with variable length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! For the dynamically sized array, which will be allocated, a upper limit
-  !! to allocate has to be specified.
-  subroutine get_config_double_vvect(val, ErrCode, maxlength, L, &
-    &                                key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table, will have the same length as the table
-    !! but not exceed maxlength, if provided.
-    real(kind=double_k), intent(out), allocatable :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! Will be allocated with the same length as the returned vector.
-    !! If the complete vector is not given in the Lua script, and no default
-    !! is provided, an zerosized array will be returned.
-    integer, intent(out), allocatable :: ErrCode(:)
-
-    !> Maximal length to allocate for the vector.
-    integer, intent(in) :: maxlength
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    real(kind=double_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted global variable
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
-
-  end subroutine get_config_double_vvect
-
-
-  !> This routine obtains a vectorial quantity with variable length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! For the dynamically sized array, which will be allocated, a upper limit
-  !! to allocate has to be specified.
-  subroutine get_config_integer_vvect(val, ErrCode, maxlength, L, &
-    &                                 key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table, will have the same length as the table
-    !! but not exceed maxlength, if provided.
-    integer, intent(out), allocatable :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! Will be allocated with the same length as the returned vector.
-    !! If the complete vector is not given in the Lua script, and no default
-    !! is provided, an zerosized array will be returned.
-    integer, intent(out), allocatable :: ErrCode(:)
-
-    !> Maximal length to allocate for the vector.
-    integer, intent(in) :: maxlength
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    integer, intent(in), optional :: default(:)
-
-    ! Get the requeseted global variable
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
-
-  end subroutine get_config_integer_vvect
-
-
-  !> This routine obtains a vectorial quantity with variable length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! For the dynamically sized array, which will be allocated, a upper limit
-  !! to allocate has to be specified.
-  subroutine get_config_long_vvect(val, ErrCode, maxlength, L, &
-    &                              key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table, will have the same length as the table
-    !! but not exceed maxlength, if provided.
-    integer(kind=long_k), intent(out), allocatable :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! Will be allocated with the same length as the returned vector.
-    !! If the complete vector is not given in the Lua script, and no default
-    !! is provided, an zerosized array will be returned.
-    integer, intent(out), allocatable :: ErrCode(:)
-
-    !> Maximal length to allocate for the vector.
-    integer, intent(in) :: maxlength
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    integer(kind=long_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted global variable
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
-
-  end subroutine get_config_long_vvect
-
-
-  !> This routine obtains a vectorial quantity with variable length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! For the dynamically sized array, which will be allocated, a upper limit
-  !! to allocate has to be specified.
-  subroutine get_config_logical_vvect(val, ErrCode, maxlength, L, &
-    &                                 key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table, will have the same length as the table
-    !! but not exceed maxlength, if provided.
-    logical, intent(out), allocatable :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! Will be allocated with the same length as the returned vector.
-    !! If the complete vector is not given in the Lua script, and no default
-    !! is provided, an zerosized array will be returned.
-    integer, intent(out), allocatable :: ErrCode(:)
-
-    !> Maximal length to allocate for the vector.
-    integer, intent(in) :: maxlength
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    logical, intent(in), optional :: default(:)
-
-    ! Get the requeseted global variable
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
-
-  end subroutine get_config_logical_vvect
-
-
   !> This routine obtains a vectorial quantity with fixed length from a Lua
   !! table as a whole.
   !!
   subroutine get_table_real_v(val, ErrCode, L, thandle, key, &
     &                         pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table.
     real(kind=single_k), intent(out) :: val(:)
     !! Components will be filled with the help of this default definition.
     real(kind=single_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
+
   end subroutine get_table_real_v
 
 
   subroutine get_table_double_v(val, ErrCode, L, thandle, key, &
     &                         pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table.
     real(kind=double_k), intent(out) :: val(:)
     !! Components will be filled with the help of this default definition.
     real(kind=double_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
+
   end subroutine get_table_double_v
 
 
   subroutine get_table_integer_v(val, ErrCode, L, thandle, key, &
     &                         pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table.
     integer, intent(out) :: val(:)
     !! Components will be filled with the help of this default definition.
     integer, intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
+
   end subroutine get_table_integer_v
 
 
   subroutine get_table_long_v(val, ErrCode, L, thandle, key, &
     &                         pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table.
     integer(kind=long_k), intent(out) :: val(:)
     !! Components will be filled with the help of this default definition.
     integer(kind=long_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
+
   end subroutine get_table_long_v
 
 
   subroutine get_table_logical_v(val, ErrCode, L, thandle, key, &
     &                         pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table.
     logical, intent(out) :: val(:)
     !! Components will be filled with the help of this default definition.
     logical, intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
+
   end subroutine get_table_logical_v
 
 
 
 
-  !> This routine obtains a vectorial quantity with fixed length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! Components which are not found are filled with the data given in
-  !! the default vector. For each component an error code will be returned
-  !! to indicate the success when reading it.
-  !! If the vector is not defined at all, all components will be indicated
-  !! as non-existent.
-  !! Components, which are neither defined in the Lua script, nor in the
-  !! default will be marked with the aoterr_Fatal flag.
-  subroutine get_config_real_v(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table.
-    real(kind=single_k), intent(out) :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! This array has to have the same length as val.
-    integer, intent(out) :: ErrCode(:)
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    real(kind=single_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted value from the provided table
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, L, default)
-  end subroutine get_config_real_v
-
-
-  !> This routine obtains a vectorial quantity with fixed length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! Components which are not found are filled with the data given in
-  !! the default vector. For each component an error code will be returned
-  !! to indicate the success when reading it.
-  !! If the vector is not defined at all, all components will be indicated
-  !! as non-existent.
-  !! Components, which are neither defined in the Lua script, nor in the
-  !! default will be marked with the aoterr_Fatal flag.
-  subroutine get_config_double_v(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table.
-    real(kind=double_k), intent(out) :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! This array has to have the same length as val.
-    integer, intent(out) :: ErrCode(:)
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    real(kind=double_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted value from the provided table
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, L, default)
-  end subroutine get_config_double_v
-
-
-  !> This routine obtains a vectorial quantity with fixed length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! Components which are not found are filled with the data given in
-  !! the default vector. For each component an error code will be returned
-  !! to indicate the success when reading it.
-  !! If the vector is not defined at all, all components will be indicated
-  !! as non-existent.
-  !! Components, which are neither defined in the Lua script, nor in the
-  !! default will be marked with the aoterr_Fatal flag.
-  subroutine get_config_integer_v(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table.
-    integer, intent(out) :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! This array has to have the same length as val.
-    integer, intent(out) :: ErrCode(:)
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    integer, intent(in), optional :: default(:)
-
-    ! Get the requeseted value from the provided table
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, L, default)
-  end subroutine get_config_integer_v
-
-
-  !> This routine obtains a vectorial quantity with fixed length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! Components which are not found are filled with the data given in
-  !! the default vector. For each component an error code will be returned
-  !! to indicate the success when reading it.
-  !! If the vector is not defined at all, all components will be indicated
-  !! as non-existent.
-  !! Components, which are neither defined in the Lua script, nor in the
-  !! default will be marked with the aoterr_Fatal flag.
-  subroutine get_config_long_v(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table.
-    integer(kind=long_k), intent(out) :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! This array has to have the same length as val.
-    integer, intent(out) :: ErrCode(:)
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    integer(kind=long_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted value from the provided table
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, L, default)
-  end subroutine get_config_long_v
-
-
-  !> This routine obtains a vectorial quantity with fixed length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! Components which are not found are filled with the data given in
-  !! the default vector. For each component an error code will be returned
-  !! to indicate the success when reading it.
-  !! If the vector is not defined at all, all components will be indicated
-  !! as non-existent.
-  !! Components, which are neither defined in the Lua script, nor in the
-  !! default will be marked with the aoterr_Fatal flag.
-  subroutine get_config_logical_v(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table.
-    logical, intent(out) :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! This array has to have the same length as val.
-    integer, intent(out) :: ErrCode(:)
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    logical, intent(in), optional :: default(:)
-
-    ! Get the requeseted value from the provided table
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, L, default)
-  end subroutine get_config_logical_v
-
-
-
-
-
   subroutine get_top_real_vvect(val, ErrCode, maxlength, L, default)
     type(flu_State) :: L !< Handle to the lua script
 

source/aotus_module.f90

 !> This module provides high level Fortran interfaces to retrieve values from a
 !! Lua script.
 !!
-!! Its central interface is aot_get_val, which is a generic interface that
-!! allows access to scalars and vectors in global Lua variables as well as
-!! nested tables.
+!! Its central interface is aot_table_module#aot_get_val, which is a generic
+!! interface that allows access to scalars and vectors in global Lua variables
+!! as well as nested tables.
 !!
 !! In the \ref aot_overview "overview page" there are some more general
 !! remarks and further pointers.
     &                       aoterr_Fatal, aoterr_NonExistent, aoterr_WrongType
   use aot_table_module, only: aot_get_val, aot_table_set_val, &
     &                         aot_table_open, aot_table_close
-  use aot_vector_module, only: aot_get_val, aot_top_get_val
-
-  ! The following module enables an interface for quadruple precision numbers,
-  ! if the compiler supports them. However, you should be aware, that this is
-  ! merely a convenience interface, as the values provided by Lua are only
-  ! double precision.
-  use aot_quadruple_module
-
-  ! Support for extdouble precision.
-  use aot_extdouble_module
+  use aot_vector_module, only: aot_top_get_val, aot_get_val
 
   implicit none
 
   ! Inherited from the flu_binding module, publish for convenience.
   public :: flu_State
 
-  !> Get a global configuration value from the script.
-  !!
-  !! This provides a convenient direct access to
-  !! global variables from the Lua script.
-  !! The interface is also used for other values than the global ones, and the
-  !! general shape of it looks like
-  !! <tt>call aot_{top}_get_val(<outputs>, <id>, default)</tt>.
-  !! Where the "outputs" are <tt>val</tt> and <tt>errCode</tt>. While "id" is
-  !! at least the Lua context <tt>L</tt>. For the global variables there has to
-  !! be a <tt>key</tt> for the identification of the variable.
-  !!
-  !! The <tt>errCode</tt> returns an error code with various bits set for
-  !! different errors, that might happen while retrieving the variable.
-  !! They can be checked by <tt>btest</tt> and the different error codes are:
-  !!- aoterr_fatal: Something went irrecoverably wrong
-  !!- aoterr_nonExistent: The requested variable is not set in the Lua script
-  !!- aoterr_wrongType: The requested variable in the Lua script does not meet
-  !!                    the requested data type
-  !!
-  !! For example a check for a fatal error can be done by
-  !! `btest(errCode, aoterr_fatal)`.
-  !!
-  !! For the access to global variables in the Lua script the interface
-  !! therefore looks like:
-  !! `call aot_get_val(val, errCode, L, key, default)`.
-  !! See for example aotus_module#get_config_real for a more detailed
-  !! description of the parameters.
-  interface aot_get_val
-    module procedure get_config_real
-    module procedure get_config_double
-    module procedure get_config_integer
-    module procedure get_config_long
-    module procedure get_config_string
-    module procedure get_config_logical
-  end interface
-
 contains
 
   !> Subroutine to load and execute a script from a file.
   end subroutine close_config
 
 
-  !> Obtain a global real valued variable by its name.
-  subroutine get_config_real(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    real(kind=single_k), intent(out) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    real(kind=single_k), optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_real
-
-
-  !> Obtain a global double valued variable by its name.
-  subroutine get_config_double(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    real(kind=double_k), intent(out) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    real(kind=double_k), optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_double
-
-
-  !> Obtain a global integer valued variable by its name.
-  subroutine get_config_integer(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    integer, intent(out) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    integer, optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_integer
-
-
-  !> Obtain a global long valued variable by its name.
-  subroutine get_config_long(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    integer(kind=long_k), intent(out) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    integer(kind=long_k), optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_long
-
-
-  !> Obtain a global logical variable by its name.
-  subroutine get_config_logical(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    logical, intent(out) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    logical, optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_logical
-
-
-  !> Obtain a global string variable by its name.
-  subroutine get_config_string(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    character(len=*) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    character(len=*), optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_string
-
-
   !> Subroutine to load a script from a file and put it into a character buffer.
   !!
   !! This is useful to rerun a given code in a file without the need to touch

source/extdouble/aot_extdouble_module.f90

-! Copyright (C) 2011-2013 German Research School for Simulation Sciences GmbH,
-!              Aachen and others.
-! Please see the ../COPYRIGHT file one directory above for details.
-
-module aot_extdouble_module
-  use flu_binding
-  use aot_extdouble_top_module, only: xdble_k
-  use aot_top_module, only: aot_top_get_val, aot_err_handler, &
-    &                       aoterr_Fatal, aoterr_NonExistent, aoterr_WrongType
-
-  implicit none
-
-  private
-
-  public :: aot_get_val
-
-  interface aot_get_val
-    module procedure get_config_extdouble
-  end interface
-
-contains
-
-  subroutine get_config_extdouble(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    real(kind=xdble_k), intent(out) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    real(kind=xdble_k), optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_extdouble
-
-end module aot_extdouble_module

source/extdouble/aot_extdouble_table_module.f90

 module aot_extdouble_table_module
   use flu_binding
   use aot_kinds_module, only: double_k
+  use aot_err_module, only: aoterr_Fatal, aoterr_NonExistent
   use aot_extdouble_top_module, only: xdble_k
   use aot_top_module, only: aot_top_get_val
   use aot_table_ops_module, only: aot_table_open, aot_table_close, &
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     real(kind=xdble_k), intent(out) :: val
     !! the Lua script.
     real(kind=xdble_k), intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_extdouble
 

source/extdouble/aot_extdouble_vector_module.f90

   !! specified to limit the allocated memory by these routines (and make the
   !! interfaces distinguishable).
   interface aot_get_val
-    module procedure get_config_extdouble_vvect
-
     module procedure get_table_extdouble_vvect
   end interface
 
   !! If the Lua table is longer than the available elements in the array
   !! only the first elements from the table will be stored in the array.
   interface aot_get_val
-    module procedure get_config_extdouble_v
-
     module procedure get_table_extdouble_v
   end interface
 
   subroutine get_table_extdouble_vvect(val, ErrCode, maxlength, L, thandle, &
     &                                  key, pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table, will have the same length as the table
     !! but not exceed maxlength, if provided.
     !! Components will be filled with the help of this default definition.
     real(kind=xdble_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                   key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_extdouble_vvect
 
 
-  !> This routine obtains a vectorial quantity with variable length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! For the dynamically sized array, which will be allocated, a upper limit
-  !! to allocate has to be specified.
-  subroutine get_config_extdouble_vvect(val, ErrCode, maxlength, L, &
-    &                                   key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table, will have the same length as the table
-    !! but not exceed maxlength, if provided.
-    real(kind=xdble_k), intent(out), allocatable :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! Will be allocated with the same length as the returned vector.
-    !! If the complete vector is not given in the Lua script, and no default
-    !! is provided, an zerosized array will be returned.
-    integer, intent(out), allocatable :: ErrCode(:)
-
-    !> Maximal length to allocate for the vector.
-    integer, intent(in) :: maxlength
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    real(kind=xdble_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted global variable
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
-
-  end subroutine get_config_extdouble_vvect
-
-
   !> This routine obtains a vectorial quantity with fixed length from a Lua
   !! table as a whole.
   !!
   !! Components, which are neither defined in the Lua script, nor in the
   !! default will be marked with the aoterr_Fatal flag.
   subroutine get_table_extdouble_v(val, ErrCode, L, thandle, key, &
-    &                         pos, default)
+    &                              pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table.
     real(kind=xdble_k), intent(out) :: val(:)
     !! Components will be filled with the help of this default definition.
     real(kind=xdble_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                 key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
+
   end subroutine get_table_extdouble_v
 
 

source/extdouble/dummy_extdouble_module.f90

-! Copyright (C) 2011-2013 German Research School for Simulation Sciences GmbH,
-!              Aachen and others.
-! Please see the ../COPYRIGHT file one directory above for details.
-
-module aot_extdouble_module
-  implicit none
-
-  private
-
-  integer, parameter :: xdble_k = selected_real_kind(18)
-
-end module aot_extdouble_module

source/quadruple/aot_quadruple_module.f90

-! Copyright (C) 2011-2013 German Research School for Simulation Sciences GmbH,
-!              Aachen and others.
-! Please see the ../COPYRIGHT file one directory above for details.
-
-module aot_quadruple_module
-  use flu_binding
-  use aot_quadruple_top_module, only: quad_k
-  use aot_top_module, only: aot_top_get_val, aot_err_handler, &
-    &                       aoterr_Fatal, aoterr_NonExistent, aoterr_WrongType
-
-  implicit none
-
-  private
-
-  public :: aot_get_val
-
-  interface aot_get_val
-    module procedure get_config_quadruple
-  end interface
-
-contains
-
-  subroutine get_config_quadruple(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle for the Lua script to get the value from.
-    character(len=*), intent(in) :: key !< Variable name to look for.
-
-    !> Value of the Variable in the script
-    real(kind=quad_k), intent(out) :: val
-
-    !> ErrorCode to indicate what kind of problem might have occured.
-    integer, intent(out) :: ErrCode
-
-    !> Some default value that should be used, if the variable is not set in the
-    !! Lua script.
-    real(kind=quad_k), optional, intent(in) :: default
-
-    call flu_getglobal(L, key)
-    call aot_top_get_val(val, ErrCode, L, default)
-
-  end subroutine get_config_quadruple
-
-end module aot_quadruple_module

source/quadruple/aot_quadruple_table_module.f90

 module aot_quadruple_table_module
   use flu_binding
   use aot_kinds_module, only: double_k
+  use aot_err_module, only: aoterr_Fatal, aoterr_NonExistent
   use aot_quadruple_top_module, only: quad_k
   use aot_top_module, only: aot_top_get_val
   use aot_table_ops_module, only: aot_table_open, aot_table_close, &
     type(flu_State) :: L !< Handle to the Lua script.
 
     !> Handle to the table to look the value up in.
-    integer, intent(in) :: thandle
+    integer, intent(in), optional :: thandle
 
     !> Value of the table entry if it exists.
     real(kind=quad_k), intent(out) :: val
     !! the Lua script.
     real(kind=quad_k), intent(in), optional :: default
 
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
-    call aot_top_get_val(val, ErrCode, L, default)
+    logical :: valid_args
+
+    valid_args = .true.
+    if (present(thandle)) then
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_quadruple
 

source/quadruple/aot_quadruple_vector_module.f90

 
   implicit none
 
-  public :: aot_table_get_val, aot_get_val, aot_top_get_val
+  public :: aot_table_get_val !, aot_get_val, aot_top_get_val
 
   !> Use these routines to obtain a vector whose length is unknown.
   !!
   !! Lua script with these routines. A maximal length has to be
   !! specified to limit the allocated memory by these routines (and make the
   !! interfaces distinguishable).
-  interface aot_get_val
-    module procedure get_config_quadruple_vvect
-
-    module procedure get_table_quadruple_vvect
-  end interface
+!!  interface aot_get_val
+!!    module procedure get_table_quadruple_vvect
+!!  end interface
 
   interface aot_table_get_val
     module procedure get_table_quadruple_vvect
   !! values from the Lua table, as far as they exist.
   !! If the Lua table is longer than the available elements in the array
   !! only the first elements from the table will be stored in the array.
-  interface aot_get_val
-    module procedure get_config_quadruple_v
-
-    module procedure get_table_quadruple_v
-  end interface
+!!  interface aot_get_val
+!!    module procedure get_table_quadruple_v
+!!  end interface
 
   interface aot_table_get_val
     module procedure get_table_quadruple_v
   subroutine get_table_quadruple_vvect(val, ErrCode, maxlength, L, thandle, &
     &                                  key, pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table, will have the same length as the table
     !! but not exceed maxlength, if provided.
     !! Components will be filled with the help of this default definition.
     real(kind=quad_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                   key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                   key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, maxlength, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
 
   end subroutine get_table_quadruple_vvect
 
 
-  !> This routine obtains a vectorial quantity with variable length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! For the dynamically sized array, which will be allocated, a upper limit
-  !! to allocate has to be specified.
-  subroutine get_config_quadruple_vvect(val, ErrCode, maxlength, L, &
-    &                                   key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table, will have the same length as the table
-    !! but not exceed maxlength, if provided.
-    real(kind=quad_k), intent(out), allocatable :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! Will be allocated with the same length as the returned vector.
-    !! If the complete vector is not given in the Lua script, and no default
-    !! is provided, an zerosized array will be returned.
-    integer, intent(out), allocatable :: ErrCode(:)
-
-    !> Maximal length to allocate for the vector.
-    integer, intent(in) :: maxlength
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    real(kind=quad_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted global variable
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, maxlength, L, default)
-
-  end subroutine get_config_quadruple_vvect
-
-
   !> This routine obtains a vectorial quantity with fixed length from a Lua
   !! table as a whole.
   !!
   !! Components, which are neither defined in the Lua script, nor in the
   !! default will be marked with the aoterr_Fatal flag.
   subroutine get_table_quadruple_v(val, ErrCode, L, thandle, key, &
-    &                         pos, default)
+    &                              pos, default)
     type(flu_State) :: L !< Handle to the lua script
-    integer, intent(in) :: thandle !< Handle of the parent table
+    integer, intent(in), optional :: thandle !< Handle of the parent table
 
     !> Vector read from the Lua table.
     real(kind=quad_k), intent(out) :: val(:)
     !! Components will be filled with the help of this default definition.
     real(kind=quad_k), intent(in), optional :: default(:)
 
-    ! Get the requeseted value from the provided table
-    call aot_table_push(L=L, thandle=thandle, &
-      &                 key=key, pos=pos)
+    logical :: valid_args
 
-    call aot_top_get_val(val, ErrCode, L, default)
+    valid_args = .true.
+    if (present(thandle)) then
+      ! Get the requested value from the provided table
+      call aot_table_push(L=L, thandle=thandle, &
+        &                 key=key, pos=pos)
+    else
+      if (present(key)) then
+        ! Get the requeseted global variable
+        call flu_getglobal(L, key)
+      else
+        valid_args = .false.
+      end if
+    end if
+    if (valid_args) then
+      call aot_top_get_val(val, ErrCode, L, default)
+    else
+      ErrCode = ibSet(0, aoterr_NonExistent)
+      ErrCode = ibSet(ErrCode, aoterr_Fatal)
+    end if
+
   end subroutine get_table_quadruple_v
 
 
-  !> This routine obtains a vectorial quantity with fixed length from a Lua
-  !! global variable as a whole.
-  !!
-  !! It is intented to ease the reading of vectors on the Fortran side by
-  !! capsulating the parsing of the Lua table internally.
-  !! Components which are not found are filled with the data given in
-  !! the default vector. For each component an error code will be returned
-  !! to indicate the success when reading it.
-  !! If the vector is not defined at all, all components will be indicated
-  !! as non-existent.
-  !! Components, which are neither defined in the Lua script, nor in the
-  !! default will be marked with the aoterr_Fatal flag.
-  subroutine get_config_quadruple_v(val, ErrCode, L, key, default)
-    type(flu_State) :: L !< Handle to the lua script
-
-    !> Vector read from the Lua table.
-    real(kind=quad_k), intent(out) :: val(:)
-
-    !> Error code describing problems encountered in each of the components.
-    !! This array has to have the same length as val.
-    integer, intent(out) :: ErrCode(:)
-
-    !> Name of the variable (vector) to read.
-    character(len=*), intent(in) :: key
-
-    !> A default vector to use, if no proper definition is found.
-    !! Components will be filled with the help of this default definition.
-    real(kind=quad_k), intent(in), optional :: default(:)
-
-    ! Get the requeseted value from the provided table
-    call flu_getglobal(L, key)
-
-    call aot_top_get_val(val, ErrCode, L, default)
-  end subroutine get_config_quadruple_v
-
-
   subroutine get_top_quadruple_vvect(val, ErrCode, maxlength, L, default)
     type(flu_State) :: L !< Handle to the lua script
 

source/quadruple/dummy_quadruple_module.f90

-! Copyright (C) 2011-2013 German Research School for Simulation Sciences GmbH,
-!              Aachen and others.
-! Please see the ../COPYRIGHT file one directory above for details.
-
-module aot_quadruple_module
-  implicit none
-
-  private
-
-  integer, parameter :: quad_k = selected_real_kind(33)
-
-end module aot_quadruple_module
                      'source/aot_vector_module.f90']
 
     if bld.env['quad_support']:
-        aotus_sources += ['source/quadruple/aot_quadruple_module.f90']
         aotus_sources += ['source/quadruple/aot_quadruple_fun_module.f90']
         aotus_sources += ['source/quadruple/aot_quadruple_table_module.f90']
         aotus_sources += ['source/quadruple/aot_quadruple_top_module.f90']
         aotus_sources += ['source/quadruple/aot_quadruple_out_module.f90']
         aotus_sources += ['source/quadruple/aot_quadruple_vector_module.f90']
     else:
-        aotus_sources += ['source/quadruple/dummy_quadruple_module.f90']
         aotus_sources += ['source/quadruple/dummy_quadruple_fun_module.f90']
         aotus_sources += ['source/quadruple/dummy_quadruple_table_module.f90']
         aotus_sources += ['source/quadruple/dummy_quadruple_top_module.f90']
         aotus_sources += ['source/quadruple/dummy_quadruple_vector_module.f90']
 
     if bld.env['xdble_support']:
-        aotus_sources += ['source/extdouble/aot_extdouble_module.f90']
         aotus_sources += ['source/extdouble/aot_extdouble_fun_module.f90']
         aotus_sources += ['source/extdouble/aot_extdouble_table_module.f90']
         aotus_sources += ['source/extdouble/aot_extdouble_top_module.f90']
         aotus_sources += ['source/extdouble/aot_extdouble_out_module.f90']
         aotus_sources += ['source/extdouble/aot_extdouble_vector_module.f90']
     else:
-        aotus_sources += ['source/extdouble/dummy_extdouble_module.f90']
         aotus_sources += ['source/extdouble/dummy_extdouble_fun_module.f90']
         aotus_sources += ['source/extdouble/dummy_extdouble_table_module.f90']
         aotus_sources += ['source/extdouble/dummy_extdouble_top_module.f90']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.