load varSys from lua file. Required for harvester to load varSys from tracking or restart header file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_varSys_type), | intent(out) | :: | me |
varSys to read from the Lua script(conf) and fill |
||
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 variable up |
|
character(len=*), | intent(in), | optional | :: | key |
load varsys from this key |
|
logical, | intent(in), | optional | :: | openTable |
subroutine tem_varSys_load_single(me, conf, parent, key, openTable) ! --------------------------------------------------------------------------! !> varSys to read from the Lua script(conf) and fill type(tem_varSys_type), intent(out) :: 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 variable up integer, optional, intent(in) :: parent !> load varsys from this key character(len=*), optional, intent(in) :: key ! if varsys table is already opened then openTable = .false. logical, optional, intent(in) :: openTable ! --------------------------------------------------------------------------! integer :: syshandle, varhandle, varsubhandle, iVar, nVars, pos type(tem_varSys_op_type) :: method character(len=labelLen) :: varname integer :: iError integer, allocatable :: vError(:) character(len=LabelLen) :: local_key logical :: openTable_loc ! --------------------------------------------------------------------------! ! if varsys table is already opened then openTable = .false. if( present(openTable) ) then openTable_loc = openTable else openTable_loc = .true. end if if( present( key )) then local_key = key else local_key = 'varsys' endif if (openTable_loc) then write(logUnit(1),*) 'Loading varsys table ' ! Try to open the varsys table call aot_table_open( L = conf, & & parent = parent, & & thandle = syshandle, & & key = trim(local_key) ) write(logUnit(1),*) 'Syshandle ', syshandle else ! if table is open before just use the parent as syshandle to load ! variable info syshandle = parent end if !varsys table is present, load variable system if (syshandle > 0) then ! Get the variable system name call aot_get_val( L = conf, & & thandle = syshandle, & & val = me%systemname, & & ErrCode = iError, & & key = 'systemname' ) ! get nStateVars call aot_get_val( L = conf, & & thandle = syshandle, & & val = me%nStateVars, & & ErrCode = iError, & & key = 'nStateVars' ) call aot_get_val( L = conf, & & thandle = syshandle, & & val = me%nScalars, & & ErrCode = iError, & & key = 'nScalars' ) call aot_table_open( L = conf, & & parent = syshandle, & & thandle = varhandle, & & key = 'variable' ) if (varhandle > 0) then nVars = aot_table_length( L = conf, thandle = varhandle ) call init( me = me%varname, & & length = nVars ) call init( me = me%method, & & length = nVars ) do iVar = 1, nVars method%myPos = iVar call aot_table_open( L = conf, & & parent = varhandle, & & thandle = varsubhandle, & & pos = iVar ) call aot_get_val( L = conf, & & thandle = varsubhandle, & & val = varname, & & ErrCode = iError, & & key = 'name' ) call append( me = me%varname, & & val = varname, & & pos = pos ) call aot_get_val( L = conf, & & thandle = varsubhandle, & & val = method%nComponents, & & ErrCode = iError, & & key = 'ncomponents' ) call aot_get_val( L = conf, & & thandle = varsubhandle, & & val = method%state_varPos, & & maxLength = method%nComponents, & & ErrCode = vError, & & key = 'state_varpos' ) call append( me = me%method, val = method ) call aot_table_close( L = conf, thandle = varsubhandle) end do call aot_table_close( L = conf, thandle = varhandle) else write(logUnit(1),*) 'Error: Failed to load variable table within ' & & //'varsys table' call tem_abort() end if ! variable table else write(logUnit(1),*) 'Error: Failed to load varsys table single' call tem_abort() end if !varsys table call aot_table_close( L = conf, thandle = syshandle) end subroutine tem_varSys_load_single