Load variable system(s) from a lua file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_varSys_type), | intent(out), | allocatable | :: | me(:) |
The variable system to read in |
|
type(flu_State) | :: | conf |
Lua handle connected to the script to read the table from |
|||
integer, | intent(in), | optional | :: | parent |
A parent table handle in which to look the current variables up |
|
character(len=*), | intent(in), | optional | :: | key |
load from this key |
subroutine tem_varSys_load_vector( me, conf, parent, key )
! ---------------------------------------------------------------------------
!> The variable system to read in
type(tem_varSys_type), intent(out), allocatable :: me(:)
!> Lua handle connected to the script to read the table from
type(flu_State) :: conf
!> A parent table handle in which to look the current variables up
integer, intent(in), optional :: parent
!> load from this key
character(len=*), optional, intent(in) :: key
! ---------------------------------------------------------------------------
integer :: thandle, subhandle
integer :: nSys, iSys
character(len=LabelLen) :: local_key
! ---------------------------------------------------------------------------
if( present( key )) then
local_key = key
else
local_key = 'varsys'
endif
call aot_table_open( L = conf, &
& parent = parent, &
& thandle = thandle, &
& key = trim(local_key) )
!varsys table is present, load variable system
if( thandle > 0 ) then
! Now the 'varsys' table is opened. Let's first check, if
! there is a single variable system directly inside, or if there are
! several, so we have to open a table first and check whether it has
! another table
call aot_table_open( L = conf, &
& parent = thandle, &
& thandle = subhandle, &
& pos = 1 )
! more than one varSys
if ( subhandle > 0 ) then
call aot_table_close( L = conf, thandle = subhandle )
nSys = aot_table_length( L = conf, thandle = thandle )
allocate(me(nSys))
! load each varSys
do iSys = 1, nSys
call aot_table_open( L = conf, &
& parent = thandle, &
& thandle = subhandle, &
& pos = iSys )
call tem_varSys_load_single( me = me(iSys), &
& conf = conf, &
& parent = subhandle, &
& openTable = .false. )
call aot_table_close( L = conf, thandle = subhandle )
end do
else !single varSys
nSys = 1
allocate(me(nSys))
call tem_varSys_load_single( me = me(1), &
& conf = conf, &
& parent = thandle, &
& openTable = .false. )
end if
else
write(logUnit(1),*) 'Error: Failed to load varsys table'
call tem_abort()
end if
call aot_table_close( L = conf, thandle = thandle )
end subroutine tem_varSys_load_vector