The simulation clock: simulation time from wall-clock time, with a time scale, pause and a time range, as in OpenFrames' WindowProxy.
While running, time = offset + (wall - wall_ref) * scale, limited to the time range. Setting the time, pausing and changing the scale restart the count from the current time (offset = time, wall_ref = now). A clock can be synchronized to another one (synchronize), whose time it then reports and whose settings it changes.
Wall time is in seconds from system_clock, unless given explicitly with the
optional wall arguments (for tests, or for driving the clock from a host).
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 |
| procedure, public :: is_paused | |
| procedure, public :: pause | |
| procedure, public :: set_time | |
| procedure, public :: set_time_range | |
| procedure, public :: set_time_scale | |
| procedure, public :: synchronize | |
| procedure, public :: synchronized_to | |
| procedure, public :: time | |
| procedure, public :: time_range | |
| procedure, public :: time_scale | |
| procedure, public :: update |
True if the simulation time is paused.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(SimulationClock), | intent(in) | :: | self |
The wall time (s): wall if present, else wall_time().
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in), | optional | :: | wall |
wall time (s) |
True if a points to the clock b.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(SimulationClock), | intent(in), | pointer | :: | a |
the clock pointer (may be null) |
|
| class(SimulationClock), | intent(in), | target | :: | b |
the clock |
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 |
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()) |
Wall-clock time in seconds (system_clock), for the clock's default.
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()) |
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) |