MODULE time_manager_mod
Overview
Other modules used
types_mod
utilities_mod
Public interfaces
use time_manager_mod, only : |
time_type |
operator(+) |
|
operator(-) |
|
operator(*) |
|
operator(/) |
|
operator(>) |
|
operator(>=) |
|
operator(==) |
|
operator(/=) |
|
operator(<) |
|
operator(<=) |
|
operator(//) |
|
set_time |
|
set_time_missing |
|
increment_time |
|
decrement_time |
|
get_time |
|
interval_alarm |
|
repeat_alarm |
|
THIRTY_DAY_MONTHS |
|
JULIAN |
|
GREGORIAN |
|
NOLEAP |
|
NO_CALENDAR |
|
GREGORIAN_MARS |
|
set_calendar_type |
|
get_calendar_type |
|
get_calendar_string |
|
set_date |
|
get_date |
|
increment_date |
|
decrement_date |
|
days_in_month |
|
leap_year |
|
length_of_year |
|
days_in_year |
|
month_name |
|
julian_day |
|
time_manager_init |
|
print_time |
|
print_date |
|
write_time |
|
read_time |
|
interactive_time |
var = set_time(seconds [, days])
type(time_type) :: set_time
integer, intent(in) :: seconds
integer, optional, intent(in) :: days
Fills a time type. If seconds are > 86400, they are converted into the appropriate number of days. Note that seconds are specified first.
|
Number of seconds. If larger than 86400, they are converted into the appropriate number of days. |
days |
Number of days. Default is 0. |
var = set_time_missing()
type(time_type) :: set_time_missing
Set a time type to a missing value. The resulting time value will cause an error if used for an arithmetic operation or if get_time() is called.
var = increment_time(time, seconds [, days])
type(time_type) :: increment_time
type(time_type), intent(in) :: time
integer, intent(in) :: seconds
integer, optional, intent(in) :: days
Adds the specified number of seconds and optionally, days, to the given time and returns the new time. Increments cannot be negative (see decrement_time below).
|
time value to be incremented. |
|
number of seconds to add to given time. |
days |
optionally a number of days to add to the given time. |
var = decrement_time(time, seconds [, days])
type(time_type) :: decrement_time
type(time_type), intent(in) :: time
integer, intent(in) :: seconds
integer, intent(in), optional :: days
Subtract the specified number of seconds and optionally, days, to the given time and returns the new time. Decrements cannot be negative (see increment_time above).
|
time value to be decremented. |
|
number of seconds to subtract from the given time. |
days |
optionally a number of days to subtract from the given time. |
var = interval_alarm(time, time_interval, alarm, alarm_interval)
logical :: interval_alarm
type(time_type), intent(in) :: time
type(time_type), intent(in) :: time_interval
type(time_type), intent(inout) :: alarm
type(time_type), intent(in) :: alarm_interval
Supports a commonly used type of test on times for models. Given the current time, and a time for an alarm, determines if this is the closest time to the alarm time given a time step of time_interval. If this is the closest time (alarm - time <= time_interval/2), the function returns true and the alarm is incremented by the alarm_interval. Watch for problems if the new alarm time is less than time + time_interval.
|
Current time. |
|
Bin size for determining if alarm time is close enough to now. |
|
When alarm next goes off next. Updated by this routine. |
|
How often alarm goes off. |
var = repeat_alarm(time, alarm_frequency, alarm_length)
type(time_type) :: repeat_alarm
type(time_type), intent(in) :: time
type(time_type), intent(in) :: alarm_frequency
type(time_type), intent(in) :: alarm_length
Repeat_alarm supports an alarm that goes off with alarm_frequency and lasts for alarm_length. If the nearest occurence of an alarm time is less than half an alarm_length from the input time, repeat_alarm is true. For instance, if the alarm_frequency is 1 day, and the alarm_length is 2 hours, then repeat_alarm is true from time 2300 on day n to time 0100 on day n + 1 for all n.
|
Current time. |
|
How often the alarm goes off. |
|
How long the alarm is true. |
var = get_calendar_type()
integer :: get_calendar_type
Returns default calendar type for mapping from time to date. Calendar types are public integer parameters that define various calendars. See elsewhere in this file for the list.
var = set_date(year, month, day [, hours, minutes, seconds])
type(time_type) :: set_date
integer, intent(in) :: year
integer, intent(in) :: month
integer, intent(in) :: day
integer, intent(in), optional :: hours
integer, intent(in), optional :: minutes
integer, intent(in), optional :: seconds
Given a date interpreted using the current calendar type, compute the corresponding time.
|
Integer year. |
|
Integer month number. |
|
Integer day number. |
hours |
Integer hour. Default is 0. |
minutes |
Integer minutes. Default is 0. |
seconds |
Integer seconds. Default is 0. |
var = increment_date(time [, years, months, days, hours, minutes, seconds])
type(time_type) :: increment_date
type(time_type), intent(in) :: time
integer, intent(in), optional :: years
integer, intent(in), optional :: months
integer, intent(in), optional :: days
integer, intent(in), optional :: hours
integer, intent(in), optional :: minutes
integer, intent(in), optional :: seconds
Given a time and some date increment, compute a new time. The interpretation of the date depends on the currently selected calendar type.
|
Current time. |
year |
Integer years to add. Default is 0. |
month |
Integer months to add. Default is 0. |
day |
Integer days to add. Default is 0. |
hours |
Integer hours to add. Default is 0. |
minutes |
Integer minutes to add. Default is 0. |
seconds |
Integer seconds to add. Default is 0. |
var = decrement_date(time [, years, months, days, hours, minutes, seconds])
type(time_type) :: decrement_date
type(time_type), intent(in) :: time
integer, intent(in), optional :: years
integer, intent(in), optional :: months
integer, intent(in), optional :: days
integer, intent(in), optional :: hours
integer, intent(in), optional :: minutes
integer, intent(in), optional :: seconds
Given a time and some date decrement, compute a new time. The interpretation of the date depends on the currently selected calendar type.
|
Current time. |
year |
Integer years to subtract. Default is 0. |
month |
Integer months to subtract. Default is 0. |
day |
Integer days to subtract. Default is 0. |
hours |
Integer hours to subtract. Default is 0. |
minutes |
Integer minutes to subtract. Default is 0. |
seconds |
Integer seconds to subtract. Default is 0. |
var = days_in_month(time)
integer :: days_in_month
type(time_type), intent(in) :: time
Given a time, determine the month based on the currently selected calendar type and return the numbers of days in that month.
|
Current time. |
var = leap_year(time)
logical :: leap_year
type(time_type),intent(in) :: time
Given a time, determine if the current year is a leap year in the currently selected calendar type.
|
Current time. |
var = length_of_year()
integer :: length_of_year
For the currently selected calendar type, return the number of days in a year if that value is fixed (e.g. there are not leap years). For other calendar types, see days_in_year() which takes a time argument to determine the current year.
var = days_in_year(time)
integer :: days_in_year
type(time_type), intent(in) :: time
Given a time, determine the year based on the currently selected calendar type and return the numbers of days in that year.
|
Current time. |
var = month_name(n)
character(len=9) :: month_name
integer, intent(in) :: n
Return a character string containing the month name corresponding to the given month number.
|
Month number. Must be between 1 and 12, inclusive. |
var = julian_day(year, month, day)
integer :: julian_day
integer, intent(in) :: year
integer, intent(in) :: month
integer, intent(in) :: day
Given a date in year/month/day format, compute the day number from the beginning of the year. The currently selected calendar type must be GREGORIAN.
|
Year number in the Gregorian calendar. |
|
Month number in the Gregorian calendar. |
|
Day of month in the Gregorian calendar. |
var = read_time(file_unit [, form, ios_out])
type(time_type) :: read_time
integer, intent(in) :: file_unit
character(len=*), intent(in), optional :: form
integer, intent(out), optional :: ios_out
Read a time from the given file unit number. The unit must already be open. The default format is ascii/formatted. If an error is encountered and ios_out is specified, the error status will be returned to the caller; otherwise the error is fatal.
|
Integer file unit number of an already open file. |
|
Format to read the time. Options are ‘formatted’ or ‘unformatted’. Default is ‘formatted’. |
|
On error, if specified, the error status code is returned here. If not specified, an error calls the standard error_handler and exits. |
call get_time(time, seconds [, days])
type(time_type), intent(in) :: time
integer, intent(out) :: seconds
integer, intent(out), optional :: days
Returns days and seconds ( < 86400 ) corresponding to a time. If the optional ‘days’ argument is not given, the days are converted to seconds and the total time is returned as seconds. Note that seconds preceeds days in the argument list.
|
Time to convert into seconds and days. |
|
If days is specified, number of seconds in the current day. Otherwise, total number of seconds in time. |
|
If specified, number of days in time. |
call set_calendar_type(mytype) or call set_calendar_type(calstring)
integer, intent(in) :: mytype
or
character(len=*), intent(in) :: calstring
Selects the current calendar type, for converting between time and year/month/day. The argument can either be one of the predefined calendar integer parameter types (see elsewhere in this file for the list of types), or a string which matches the name of the integer parameters. The string interface is especially suitable for namelist use.
|
Integer parameter to select the calendar type. |
or
|
Character string to select the calendar type. Valid strings match the names of the integer parameters. |
call get_calendar_string(mystring)
character(len=*), intent(out) :: mystring
Return the character string corresponding to the currently selected calendar type.
|
Character string corresponding to the current calendar type. |
call get_date(time, year, month, day, hour, minute, second)
type(time_type), intent(in) :: time
integer, intent(out) :: year
integer, intent(out) :: month
integer, intent(out) :: day
integer, intent(out) :: hour
integer, intent(out) :: minute
integer, intent(out) :: second
Given a time, compute the corresponding date given the currently selected calendar type.
|
Input time. |
|
Corresponding calendar year. |
|
Corresponding calendar month. |
|
Corresponding calendar day. |
|
Corresponding hour. |
|
Corresponding minute. |
|
Corresponding second. |
call time_manager_init()
Initializes any internal data needed by the time manager code. Does not need to be called before using any of the time manager routines; it will be called internally before executing any of the other routines.
call print_time(time [, str, iunit])
type(time_type), intent(in) :: time
character(len=*), intent(in), optional :: str
integer, intent(in), optional :: iunit
Print the time as days and seconds. If the optional str argument is specified, print that string as a label. If iunit is specified, write output to that unit; otherwise write to standard output/terminal.
|
Time to be printed as days/seconds. |
str |
String label to print before days/seconds. Default: ‘TIME: ‘. |
iunit |
Unit number to write output on. Default is standard output/terminal (unit 6). |
call print_date(time [, str, iunit])
type(time_type), intent(in) :: time
character(len=*), intent(in), optional :: str
integer, intent(in), optional :: iunit
Print the time as year/month/day/hour/minute/second, as computed from the currently selected calendar type. If the optional str argument is specified, print that string as a label. If iunit is specified, write output to that unit; otherwise write to standard output/terminal.
|
Time to be printed as a calendar date/time. |
str |
String label to print before date. Default: ‘DATE: ‘. |
iunit |
Unit number to write output on. Default is standard output/terminal (unit 6). |
call write_time(file_unit, time [, form, ios_out])
integer, intent(in) :: file_unit
type(time_type), intent(in) :: time
character(len=*), intent(in), optional :: form
integer, intent(out), optional :: ios_out
Write a time to an already open file unit. The optional ‘form’ argument controls whether it is formatted or unformatted. On error, the optional ‘ios_out’ argument returns the error code; otherwise a fatal error is triggered.
|
Integer unit number for an already open file. |
|
Time to write to the file. |
form |
String format specifier; either ‘unformatted’ or ‘formatted’. Defaults to ‘formatted’. |
ios_out |
If specified, on error the i/o status error code is returned here. Otherwise, the standard error handler is called and the program exits. |
call interactive_time(time)
type(time_type), intent(inout) :: time
Prompt the user for a time as a calendar date, based on the currently selected calendar type. Writes prompt to standard output and reads from standard input.
|
Time type to be returned. |
type time_type
private
integer :: seconds
integer :: days
end type time_type
This type is used to define a time interval.
integer :: NO_CALENDAR
integer :: GREGORIAN
integer :: GREGORIAN_MARS
integer :: JULIAN
integer :: THIRTY_DAY_MONTHS
integer :: NOLEAP
The public integer parameters which define different calendar types. The same names defined as strings can be used to set the calendar type.
operator(+)
operator(-)
operator(*)
operator(/)
operator(>)
operator(>=)
operator(==)
operator(/=)
operator(<)
operator(<=)
operator(//)
Arithmetic operations are defined for time types, so expressions like
t3 = t1 + t2
Namelist
No namelist is currently defined for the time manager code.
Files
none
References
none
Private components
N/A