Reading a time description from a Lua script given by conf.
The time description has to be provided in the table given by thandle. The time can be given in terms of: - iter: number of iterations - sim: simulated time - clock: running time used to compute the simulation Thus, the configuration looks like: \verbatim time = { iter = 123, sim = 1.23, clock = 12.3 } \end verbatim Omitted time defintions are set to the maximal representable number, indicating something like never. If the time is not provided as a table, it is interpreted as a setting of the sim time, the other entries are set to never.
The optional argument clock_start is useful to overwrite the current time by the settings in a loaded restart header. With clock_start the old reference wtime from tem_time_reset can be maintained, while iterations and simulation time can be inherited from the configuration.
\todo HK: maybe provide the possibility to add up run times from loaded data instead of resetting it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_time_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. |
|
real(kind=rk), | intent(in), | optional | :: | clock_start |
Reference MPI_Wtime mark to use for computation of wallclock This is basically only useful to update the time object for a read in restart without distorting the clock measurement. |
subroutine tem_time_load(me, conf, key, parent, clock_start) ! -------------------------------------------------------------------- ! !> Time to be read from the Lua script type(tem_time_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 !> Reference MPI_Wtime mark to use for computation of wallclock !! !! This is basically only useful to update the time object for a read in !! restart without distorting the clock measurement. real(kind=rk), intent(in), optional :: clock_start ! -------------------------------------------------------------------- ! integer :: iErr character(len=labelLen) :: loc_key integer :: thandle ! -------------------------------------------------------------------- ! if ( present(key) ) then loc_key = trim(key) else loc_key = 'time' end if call aot_table_open(L = conf, & & parent = parent, & & thandle = thandle, & & key = loc_key ) if (thandle /= 0) then ! The time is given as a table load its components accordingly. call aot_get_val(L = conf, & & thandle = thandle, & & val = me%sim, & & key = 'sim', & & default = huge(me%sim), & & ErrCode = iErr ) call aot_get_val(L = conf, & & thandle = thandle, & & val = me%iter, & & key = 'iter', & & default = huge(me%iter), & & ErrCode = iErr ) call aot_get_val(L = conf, & & thandle = thandle, & & val = me%clock, & & key = 'clock', & & default = huge(me%clock), & & ErrCode = iErr ) else ! The time is not given as a table, try to interpret it as a setting for ! the simtime. call aot_get_val(L = conf, & & thandle = parent, & & key = loc_key, & & val = me%sim, & & default = huge(me%sim), & & ErrCode = iErr ) me%iter = huge(me%iter) me%clock = huge(me%clock) end if call aot_table_close(conf, thandle) !>\todo HK: maybe provide the possibility to add up run times from loaded !! data instead of resetting it. if (present(clock_start)) then me%clock_start = clock_start else me%clock_start = MPI_Wtime() end if end subroutine tem_time_load