Load a time control definition from a Lua script.
The time control description me is loaded from conf within parent and under the name key. If no key is provided the name is assumed to be 'time_control'. If the table is not found at all, all components of the control are set to never.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_timeControl_type), | intent(out) | :: | me |
Time control definition to load from a Lua config. |
||
type(flu_State) | :: | conf |
Handle for the Lua script. |
|||
integer, | intent(in), | optional | :: | parent |
Parent table to read from. |
|
character(len=*), | intent(in), | optional | :: | key |
Name of the time control table. Default: 'time_control' |
|
logical, | intent(in), | optional | :: | delay_check |
Default setting for the delay_check. If set to true the check will use a nonblocking iAllreduce and delay the evaluation by one check_iter block. This setting may be overwritten by the user in the timecontrol block. |
subroutine tem_timeControl_load(me, conf, parent, key, delay_check)
! -------------------------------------------------------------------- !
!> Time control definition to load from a Lua config.
type(tem_timeControl_type), intent(out) :: me
!> Handle for the Lua script.
type(flu_state) :: conf
!> Parent table to read from.
integer, intent(in), optional :: parent
!> Name of the time control table. Default: 'time_control'
character(len=*), intent(in), optional :: key
!> Default setting for the delay_check.
!!
!! If set to true the check will use a nonblocking iAllreduce and delay
!! the evaluation by one check_iter block.
!! This setting may be overwritten by the user in the timecontrol block.
logical, intent(in), optional :: delay_check
! -------------------------------------------------------------------- !
type(tem_time_type) :: usermin
integer :: thandle, iErr
character(len=labelLen) :: localKey
logical :: def_delay
! -------------------------------------------------------------------- !
if (present(key)) then
localKey = key
else
localKey = 'time_control'
end if
if (present(delay_check)) then
def_delay = delay_check
else
def_delay = .false.
end if
call aot_table_open( L = conf, &
& parent = parent, &
& thandle = thandle, &
& key = localKey )
if (thandle /= 0) then
call tem_time_load(me = usermin, &
& conf = conf, &
& key = 'min', &
& parent = thandle )
call tem_time_load(me = me%max, &
& conf = conf, &
& key = 'max', &
& parent = thandle )
call tem_time_load(me = me%interval, &
& conf = conf, &
& key = 'interval', &
& parent = thandle )
call aot_get_val(L = conf, &
& thandle = thandle, &
& val = me%check_iter, &
& key = 'check_iter', &
& default = 1, &
& ErrCode = iErr )
call aot_get_val(L = conf, &
& thandle = thandle, &
& val = me%delay_check, &
& key = 'delay_check', &
& default = def_delay, &
& ErrCode = iErr )
if (me%delay_check) then
write(logUnit(1),*) 'Delaying clock checks by one interval' &
// '(delay_check=True).'
end if
! check iter can not be smaller than 1
if ( me%check_iter < 1 ) then
me%check_iter = 1
end if
else
! No table defined, set all times to never.
usermin = tem_time_never()
me%max = tem_time_never()
me%interval = tem_time_never()
me%check_iter = 1
end if
call aot_table_close(L = conf, thandle = thandle)
me%min = tem_time_default_zero( time = usermin, &
& dependency = me%interval )
me%trigger = me%min
me%min_reached = .false.
me%needs_reduce = ( tem_time_needs_reduce(me%min) &
& .or. tem_time_needs_reduce(me%max) &
& .or. tem_time_needs_reduce(me%interval) )
end subroutine tem_timeControl_load