The routine handles a single system_clock wrap when t_max is positive.
If t_max is unavailable or non-positive, the routine falls back to direct
subtraction because wrap-safe reconstruction is not possible. The function
result, dt, is the tick distance from t_start to t_end.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ik), | intent(in) | :: | t_end |
End tick captured from |
||
| integer(kind=ik), | intent(in) | :: | t_start |
Start tick captured from |
||
| integer(kind=ik), | intent(in) | :: | t_max |
Maximum count returned by |
pure integer(ik) function ticks_diff(t_end, t_start, t_max) result(dt) integer(ik), intent(in) :: t_end !! End tick captured from `system_clock`. integer(ik), intent(in) :: t_start !! Start tick captured from `system_clock`. integer(ik), intent(in) :: t_max !! Maximum count returned by `system_clock`; non-positive means unknown. if (t_max > 0_ik) then if (t_end >= t_start) then dt = t_end - t_start else dt = (t_max - t_start + 1_ik) + t_end end if else dt = t_end - t_start end if end function ticks_diff