Two unrelated notions of time, kept apart on purpose.
Monotonic time (monotonic_ms, monotonic_us) counts from an
unspecified origin and only ever moves forward. Use it to measure how
long something took, or to pace a loop against real time. Differences
are meaningful; the absolute value is not.
Wall-clock time (now_local, now_utc) is the calendar date and
time. Use it to stamp a log line or name an output file. It can jump
backwards when the system clock is corrected, so it must never be used
to measure a duration.
pic_timerpic_timer measures intervals and reports real(dp) seconds, which is
what a benchmark wants. This module reports whole milliseconds or
microseconds as integer(int64), which is what a simulation pacing
itself against the wall clock wants: integers compare and accumulate
exactly, so a frame budget does not drift with rounding.
Nothing here is reproducible between runs, by definition. Code whose
results must replay identically from a seed must not call any of it.
format_iso8601 is the exception: it is a pure function of its
argument, and it builds its text with zfill rather than internal I/O
so that the bytes are identical on every compiler.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int64), | public, | parameter | :: | PIC_CLOCK_NO_CLOCK | = | -1_int64 |
Returned by |
| integer(kind=default_int), | private, | parameter | :: | DATE_AND_TIME_VALUES | = | 8_default_int |
Length of the VALUES array |
| integer(kind=int64), | private, | parameter | :: | DAYS_EPOCH_SHIFT | = | 719468_int64 | |
| integer(kind=int64), | private, | parameter | :: | MS_PER_DAY | = | 86400000_int64 |
Offset between the civil-calendar epoch used by |
| integer(kind=int64), | private, | parameter | :: | MS_PER_HOUR | = | 3600000_int64 | |
| integer(kind=int64), | private, | parameter | :: | MS_PER_MINUTE | = | 60000_int64 | |
| integer(kind=int64), | private, | parameter | :: | MS_PER_SECOND | = | 1000_int64 | |
| integer(kind=int64), | private, | parameter | :: | US_PER_SECOND | = | 1000000_int64 |
A broken-down calendar date and time.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | public | :: | day | = | 1 | ||
| integer(kind=default_int), | public | :: | hour | = | 0 | ||
| integer(kind=default_int), | public | :: | millisecond | = | 0 | ||
| integer(kind=default_int), | public | :: | minute | = | 0 | ||
| integer(kind=default_int), | public | :: | month | = | 1 | ||
| integer(kind=default_int), | public | :: | second | = | 0 | ||
| logical, | public | :: | utc_offset_known | = | .true. |
False when the processor could not supply an offset from UTC. The date and time are still valid; only their relation to UTC is not. |
|
| integer(kind=default_int), | public | :: | utc_offset_min | = | 0 | ||
| integer(kind=default_int), | public | :: | year | = | 1970 |
Inverse of unix_time_ms, producing a UTC datetime_t.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | ms |
ISO 8601, for example 2026-09-14T09:46:00.123Z.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(datetime_t), | intent(in) | :: | dt |
Milliseconds from an unspecified origin, or PIC_CLOCK_NO_CLOCK.
Microseconds from an unspecified origin, or PIC_CLOCK_NO_CLOCK.
Milliseconds since 1970-01-01T00:00:00Z.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(datetime_t), | intent(in) | :: | dt |
Days from 1970-01-01 to the given proleptic Gregorian date.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | y_in | |||
| integer(kind=int64), | intent(in) | :: | m | |||
| integer(kind=int64), | intent(in) | :: | d |
Shared body of monotonic_ms and monotonic_us.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | units_per_second |
The trailing zone designator of an ISO 8601 timestamp.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | offset_min |
value in decimal, zero filled on the left to width characters.
A value too wide to fit is not truncated; the field simply grows.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | value | |||
| integer, | intent(in) | :: | width |
The current local date and time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(datetime_t), | intent(out) | :: | dt | |||
| type(error_t), | intent(inout), | optional | :: | err |
The current date and time in UTC, with utc_offset_min zero.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(datetime_t), | intent(out) | :: | dt | |||
| type(error_t), | intent(inout), | optional | :: | err |
Inverse of days_from_civil.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | days | |||
| integer(kind=int64), | intent(out) | :: | y | |||
| integer(kind=int64), | intent(out) | :: | m | |||
| integer(kind=int64), | intent(out) | :: | d |