Synchronize the status bits across all processes and update the time.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_simControl_type), | intent(inout) | :: | me |
Simulation control information. |
||
type(tem_comm_env_type), | intent(in) | :: | proc |
Communicator to use for the communication of status flags. |
||
real(kind=rk), | intent(in), | optional | :: | dt |
Time step to use for updating the simulation time. If this is not given, no advance of the time will be done. |
|
integer, | intent(in), | optional | :: | d_iter |
Number of iterations to add to the current number of iterations. (Default: 1) |
|
integer, | intent(in), | optional | :: | outUnit |
Unit to write messages to. If this argument is present, the current time will be printed whenever the interval of the simControl is triggered. |
subroutine tem_simControl_syncUpdate(me, proc, dt, d_iter, outUnit)
! -------------------------------------------------------------------- !
!> Simulation control information.
type(tem_simControl_type), intent(inout) :: me
!> Unit to write messages to.
!!
!! If this argument is present, the current time will be printed whenever
!! the interval of the simControl is triggered.
integer, intent(in), optional :: outUnit
!> Communicator to use for the communication of status flags.
type(tem_comm_env_type), intent(in) :: proc
!> Time step to use for updating the simulation time.
!!
!! If this is not given, no advance of the time will be done.
real(kind=rk), intent(in), optional :: dt
!> Number of iterations to add to the current number of iterations.
!! (Default: 1)
integer, intent(in), optional :: d_iter
! -------------------------------------------------------------------- !
logical :: max_reached(tem_time_n_ids)
logical :: stat_interval
logical :: out_interval
! -------------------------------------------------------------------- !
call tem_startTimer(timerHandle = me%syncUpdate_timer)
if (present(dt)) then
call tem_time_advance( me = me%now, &
& sim_dt = dt, &
& iter = d_iter )
end if
max_reached = tem_timeControl_reached_max(me%timeControl, me%now)
me%status%bits(tem_stat_max_sim) = max_reached(tem_time_sim_id)
me%status%bits(tem_stat_max_iter) = max_reached(tem_time_iter_id)
if (mod(me%now%iter, me%timeControl%check_iter) == 0) then
me%status%bits(tem_stat_max_clock) = max_reached(tem_time_clock_id)
me%status%bits(tem_stat_interval) = tem_timeControl_triggered( &
& me = me%timeControl, &
& now = me%now )
me%status%bits(tem_stat_stop_file) &
& = tem_stop_file_exists( abortCriteria = me%abortCriteria, &
& rank = proc%rank )
stat_interval = me%status%bits(tem_stat_interval)
if (me%delay_check) then
call tem_status_communicate_delayed(me = me%status, comm = proc%comm)
me%status%bits(tem_stat_max_sim) = max_reached(tem_time_sim_id)
me%status%bits(tem_stat_max_iter) = max_reached(tem_time_iter_id)
out_interval = stat_interval
else
call tem_status_communicate(me = me%status, comm = proc%comm)
out_interval = me%status%bits(tem_stat_interval)
end if
if (present(outUnit) .and. out_interval) then
call tem_time_set_clock(me%now)
call tem_time_dump(me%now, outUnit)
end if
call tem_timeControl_update( me = me%timeControl, &
& now = me%now, &
& hasTriggered = out_interval, &
& localTriggered = stat_interval )
end if
call tem_stopTimer(timerHandle = me%syncUpdate_timer)
end subroutine tem_simControl_syncUpdate