Reading a timeformatter description from a Lua script given by conf.
The timeformatter description has to be provided in the table given by thandle. There are two settings for the formatting: - use_iter: use the number of iterations rather than simulated time Default: false, but may be overwritten by caller. - simform: Fortran formatting string for the real number of the simulated time. Default: '(EN12.3)' Thus, the configuration looks like:
\verbatim timeformat = { use_iter = false, simform = '(EN12.3)' } \end verbatim
If timeformat is not a table, the value is attempted to be read as a string for the simform, so it is also possible to write:
\verbatim timeformat = '(EN15.6)' \end verbatim
The key to be used for reading these settings could also be changed by the caller by passing the key to be used in the key argument.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(tem_timeformatter_type), | intent(out) | :: | me |
Time to be read from the Lua script |
||
| type(flu_State), | intent(inout) | :: | conf |
Handle to the Lua script. |
||
| character(len=*), | intent(in), | optional | :: | key |
Name of the table containing the time definition. Default: 'time'. |
|
| integer, | intent(in), | optional | :: | parent |
Handle to the parent table. |
|
| logical, | intent(in), | optional | :: | use_iter_default |
Default for the use_iter setting |
subroutine tem_timeformatter_load(me, conf, key, parent, use_iter_default) ! -------------------------------------------------------------------- ! !> Time to be read from the Lua script type(tem_timeformatter_type), intent(out) :: me !> Handle to the Lua script. type(flu_state), intent(inout) :: conf !> Name of the table containing the time definition. Default: 'time'. character(len=*), intent(in), optional :: key !> Handle to the parent table. integer, intent(in), optional :: parent !> Default for the use_iter setting logical, intent(in), optional :: use_iter_default ! -------------------------------------------------------------------- ! integer :: iErr character(len=labelLen) :: loc_key character(len=labelLen) :: timeform integer :: thandle logical :: use_iter logical :: loc_iter_default ! -------------------------------------------------------------------- ! if ( present(key) ) then loc_key = trim(key) else loc_key = 'timeformat' end if if ( present(use_iter_default) ) then loc_iter_default = use_iter_default else loc_iter_default = .false. end if call aot_table_open(L = conf, & & parent = parent, & & thandle = thandle, & & key = loc_key ) use_iter = loc_iter_default if (thandle /= 0) then ! The timeformat is given as a table load its components accordingly. call aot_get_val(L = conf, & & thandle = thandle, & & val = use_iter, & & key = 'use_iter', & & default = loc_iter_default, & & ErrCode = iErr ) call aot_get_val(L = conf, & & thandle = thandle, & & val = timeform, & & key = 'simform', & & default = default_form, & & ErrCode = iErr ) else ! The time is not given as a table, try to interpret it as a setting for ! the simform. call aot_get_val(L = conf, & & thandle = parent, & & key = loc_key, & & val = timeform, & & default = default_form, & & ErrCode = iErr ) end if call aot_table_close(conf, thandle) if (use_iter) then me = tem_timeformatter_init(timeform = '(I0)', & & stamp = tem_timeformatter_iter_stamp ) else me = tem_timeformatter_init(timeform = timeform, & & stamp = tem_timeformatter_sim_stamp ) end if end subroutine tem_timeformatter_load