A simulation clock (see the module documentation).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private | :: | offset | = | 0.0_wp |
simulation time at wall_ref (s) |
|
| logical, | private | :: | paused_ | = | .false. |
true while paused |
|
| real(kind=wp), | private | :: | scale_ | = | 1.0_wp |
simulation seconds per wall second |
|
| logical, | private | :: | started | = | .false. |
false until counting first started (set_time or update) |
|
| type(SimulationClock), | private, | pointer | :: | sync | => | null() |
the clock this one is synchronized to (not owned) |
| real(kind=wp), | private | :: | t_max | = | huge(1.0_wp) |
end of the time range (s; default unlimited) |
|
| real(kind=wp), | private | :: | t_min | = | -huge(1.0_wp) |
start of the time range (s; default unlimited) |
|
| real(kind=wp), | private | :: | time_ | = | 0.0_wp |
the current simulation time (s) |
|
| real(kind=wp), | private | :: | wall_ref | = | 0.0_wp |
wall time (s) at which counting restarted |
True if the simulation time is paused.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(in) | :: | self |
Pause (true) or resume (false) the simulation time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(inout) | :: | self | |||
| logical, | intent(in) | :: | paused |
true: pause; false: resume |
||
| real(kind=wp), | intent(in), | optional | :: | wall |
wall time (s; default: wall_time()) |
Set the simulation time (limited to the time range) and restart counting from it.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | t |
simulation time (s) |
||
| real(kind=wp), | intent(in), | optional | :: | wall |
wall time (s; default: wall_time()) |
Limit the simulation time to [t_min, t_max] (ignored if t_max < t_min).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | t_min |
the time range (s) |
||
| real(kind=wp), | intent(in) | :: | t_max |
the time range (s) |
Simulation seconds per wall-clock second (may be 0 or negative).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | scale |
simulation seconds per wall-clock second |
||
| real(kind=wp), | intent(in), | optional | :: | wall |
wall time (s; default: wall_time()) |
Follow master's time (it must stay alive while synchronized), or stop
following (master not associated, or this clock itself), keeping the
master's current time and settings. Returns false, and changes nothing,
if this would make a cycle.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(inout), | target | :: | self | ||
| type(SimulationClock), | intent(in), | pointer | :: | master |
the clock to follow (null: stop following) |
|
| real(kind=wp), | intent(in), | optional | :: | wall |
wall time (s; default: wall_time()) |
The clock this one is synchronized to (null if none).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(in) | :: | self |
The simulation time at the last update (or as last set).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(in) | :: | self |
The time range the simulation time is limited to (s; +-huge() if unlimited).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(in) | :: | self | |||
| real(kind=wp), | intent(out) | :: | t_min |
the time range (s) |
||
| real(kind=wp), | intent(out) | :: | t_max |
the time range (s) |
Simulation seconds per wall-clock second.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(in) | :: | self |
Advance the clock to the current wall time (call once per frame) and return the simulation time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in), | optional | :: | wall |
wall time (s; default: wall_time()) |
type, public :: SimulationClock private real(wp) :: time_ = 0.0_wp !! the current simulation time (s) real(wp) :: offset = 0.0_wp !! simulation time at wall_ref (s) real(wp) :: wall_ref = 0.0_wp !! wall time (s) at which counting restarted real(wp) :: scale_ = 1.0_wp !! simulation seconds per wall second real(wp) :: t_min = -huge(1.0_wp) !! start of the time range (s; default unlimited) real(wp) :: t_max = huge(1.0_wp) !! end of the time range (s; default unlimited) logical :: paused_ = .false. !! true while paused logical :: started = .false. !! false until counting first started (set_time or update) type(SimulationClock), pointer :: sync => null() !! the clock this one is synchronized to (not owned) contains procedure :: update procedure :: time, set_time procedure :: set_time_range, time_range procedure :: pause, is_paused procedure :: set_time_scale, time_scale procedure :: synchronize, synchronized_to end type SimulationClock