CF units attribute (“seconds since …”, “hours since …”, …)
-> a multiplier converting the raw file time axis to seconds.
Only the leading unit word matters (no calendar, no reference
date — see module docstring). ok = .false. for an
unrecognised leading word; caller decides the fallback.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | units | |||
| real(kind=wp), | intent(out) | :: | scale | |||
| logical, | intent(out) | :: | ok |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=:), | private, | allocatable | :: | u |
pure subroutine data_input_time_scale_from_units(units, scale, ok) !! CF `units` attribute ("seconds since ...", "hours since ...", ...) !! -> a multiplier converting the raw file time axis to seconds. !! Only the leading unit word matters (no calendar, no reference !! date — see module docstring). `ok = .false.` for an !! unrecognised leading word; caller decides the fallback. character(len=*), intent(in) :: units real(wp), intent(out) :: scale logical, intent(out) :: ok character(len=:), allocatable :: u u = to_lower(adjustl(units)) ok = .true. if (index(u, "second") == 1 .or. index(u, "sec") == 1) then scale = 1.0_wp else if (index(u, "minute") == 1 .or. index(u, "min") == 1) then scale = 60.0_wp else if (index(u, "hour") == 1) then scale = 3600.0_wp else if (index(u, "day") == 1) then scale = 86400.0_wp else scale = 1.0_wp ok = .false. end if end subroutine data_input_time_scale_from_units