FMS
2024.03
Flexible Modeling System
|
A software package that provides a set of simple interfaces for modelers to perform computations related to time and dates. More...
Data Types | |
interface | assignment(=) |
Operator override interface for use with time_type. More... | |
interface | operator(*) |
Operator override interface for use with time_type. More... | |
interface | operator(+) |
Operator override interface for use with time_type. More... | |
interface | operator(-) |
Operator override interface for use with time_type. More... | |
interface | operator(/) |
Operator override interface for use with time_type. More... | |
interface | operator(//) |
Operator override interface for use with time_type. More... | |
interface | operator(/=) |
Operator override interface for use with time_type. More... | |
interface | operator(<) |
Operator override interface for use with time_type. More... | |
interface | operator(<=) |
Operator override interface for use with time_type. More... | |
interface | operator(==) |
Operator override interface for use with time_type. More... | |
interface | operator(>) |
Operator override interface for use with time_type. More... | |
interface | operator(>=) |
Operator override interface for use with time_type. More... | |
interface | set_date |
Given an input date in year, month, days, etc., creates a time_type that represents this time interval from the internally defined base date. More... | |
interface | set_time |
Given some number of seconds and days, returns the corresponding time_type. More... | |
type | time_type |
Type to represent amounts of time. Implemented as seconds and days to allow for larger intervals. More... | |
Functions/Subroutines | |
character(len=19) function | convert_integer_date_to_char (year, month, day, hour, minute, second) |
character(len=256) function | cut0 (string) |
character(len=15) function, public | date_to_string (time, err_msg) |
Get the a character string that represents the time. The format will be yyyymmdd.hhmmss. | |
integer function, public | day_of_year (time) |
Returns number of day in year for given time. Jan 1st is day 1, not zero! | |
integer function, public | days_in_month (Time, err_msg) |
Given a time, computes the corresponding date given the selected date time mapping algorithm. More... | |
integer function | days_in_month_gregorian (Time) |
Returns the number of days in a gregorian month. | |
integer function | days_in_month_julian (Time) |
Returns the number of days in a julian month. | |
integer function | days_in_month_no_leap (Time) |
Returns the number of days in a 365 day year month. | |
integer function | days_in_month_thirty (Time) |
Returns the number of days in a thirty day month (needed for transparent changes to calendar type). | |
integer function, public | days_in_year (Time) |
Returns the number of days in the calendar year corresponding to the date represented by time for the default calendar. More... | |
integer function | days_in_year_gregorian (Time) |
integer function | days_in_year_julian (Time) |
integer function | days_in_year_no_leap (Time) |
integer function | days_in_year_thirty (Time) |
type(time_type) function, public | decrement_date (Time, years, months, days, hours, minutes, seconds, ticks, err_msg, allow_neg_inc) |
Given a time and some date decrement, computes a new time. Depending on the mapping algorithm from date to time, it may be possible to specify undefined decrements (i.e. if one decrements by 68 days and 3 months in a Julian calendar, it matters which order these operations are done and we don't want to deal with stuff like that, make it an error). More... | |
type(time_type) function, public | decrement_time (Time, seconds, days, ticks, err_msg, allow_neg_inc) |
Decrements a time by seconds and days. More... | |
logical function | error_handler (routine, err_msg_local, err_msg) |
The purpose of this routine is to prevent the addition of an excessive amount of code in order to implement the error handling scheme involving an optional error flag of type character. It allows one line of code to accomplish what would otherwise require 6 lines. A value of .true. for this function is a flag to the caller that it should immediately return to it's caller. | |
integer function, public | get_calendar_type () |
Returns default calendar type for mapping from time to date. | |
subroutine, public | get_date (time, year, month, day, hour, minute, second, tick, err_msg) |
Gets the date for different calendar types. Given a time_interval, returns the corresponding date under the selected calendar. When err_msg present, and when non-blank, a fatal error condition as been detected. The string itself is an error message. It is recommended that, when err_msg is present in the call to this routine, the next line of code should be something similar to this: More... | |
subroutine | get_date_gregorian (time, year, month, day, hour, minute, second, tick) |
Gets the date on a Gregorian calendar. Computes the year, month, day on the fly from the quantity timedays. | |
subroutine, public | get_date_julian (time, year, month, day, hour, minute, second) |
subroutine | get_date_julian_private (time, year, month, day, hour, minute, second, tick) |
Base date for Julian calendar is year 1 with all multiples of 4 years being leap years. | |
subroutine, public | get_date_no_leap (time, year, month, day, hour, minute, second) |
subroutine | get_date_no_leap_private (time, year, month, day, hour, minute, second, tick) |
subroutine | get_date_thirty (time, year, month, day, hour, minute, second, tick) |
Computes date corresponding to time interval for 30 day months, 12 month years. | |
logical function | get_tick_from_string (string, err_msg, allow_rounding, tick) |
integer function, public | get_ticks_per_second () |
Returns the number of ticks per second. | |
subroutine, public | get_time (Time, seconds, days, ticks, err_msg) |
Returns days and seconds ( < 86400 ) corresponding to a time. err_msg should be checked for any errors. More... | |
type(time_type) function, public | increment_date (Time, years, months, days, hours, minutes, seconds, ticks, err_msg, allow_neg_inc) |
logical function | increment_date_private (Time, years, months, days, hours, minutes, seconds, ticks, Time_out, err_msg) |
Given a time and some date increment, computes a new time. Depending on the mapping algorithm from date to time, it may be possible to specify undefined increments (i.e. if one increments by 68 days and 3 months in a Julian calendar, it matters which order these operations are done and we don't want to deal with stuff like that, make it an error). More... | |
type(time_type) function, public | increment_time (Time, seconds, days, ticks, err_msg, allow_neg_inc) |
Increments a time by seconds and days. More... | |
logical function | increment_time_private (Time_in, seconds, days, ticks, Time_out, err_msg) |
Increments a time by seconds, days and ticks. | |
logical function, public | interval_alarm (time, time_interval, alarm, 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. More... | |
logical function, public | leap_year (Time, err_msg) |
Returns true if the year corresponding to the input time is a leap year (for default calendar). Always returns false for THIRTY_DAY_MONTHS and NOLEAP. More... | |
logical function | leap_year_gregorian (Time) |
logical function | leap_year_gregorian_int (year) |
logical function | leap_year_julian (Time) |
Returns the number of days in a julian month. | |
logical function | leap_year_no_leap (Time) |
Another tough one; no leap year returns false for leap year inquiry. | |
logical function | leap_year_thirty (Time) |
No leap years in thirty day months, included for transparency. | |
type(time_type) function, public | length_of_year () |
Returns the mean length of the year in the default calendar setting. More... | |
type(time_type) function | length_of_year_gregorian () |
type(time_type) function | length_of_year_julian () |
type(time_type) function | length_of_year_no_leap () |
type(time_type) function | length_of_year_thirty () |
character(len=9) function, public | month_name (n) |
Returns a character string containing the name of the month corresponding to month number n. More... | |
subroutine, public | print_date (Time, str, unit) |
Prints the time to standard output (or optional unit) as a date. More... | |
subroutine, public | print_time (Time, str, unit) |
Prints the given time_type argument as a time (using days, seconds and ticks) More... | |
type(time_type) function | real4_to_time_type (x, err_msg) |
type(time_type) function | real8_to_time_type (x, err_msg) |
Convert a real number of seconds into a time_type variable. More... | |
logical function, public | repeat_alarm (time, alarm_frequency, 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. More... | |
integer function | safe_rtoi (rval, mode) |
Convert a floating point value to an integer value. More... | |
type(time_type) function | scalar_time_mult (n, time) |
Returns time multipled by integer factor n. More... | |
subroutine, public | set_calendar_type (type, err_msg) |
Sets calendar_type for mapping an interval to a date. For the Gregorian calendar, negative years and the proleptic calendar are not used; and the discontinuity of days in October 1582 (when the Gregorian calendar was adopted by select groups in Europe) is also not taken into account. More... | |
type(time_type) function | set_date_c (string, zero_year_warning, err_msg, allow_rounding) |
Calls set_date_private for different calendar types when given a string input. Examples of acceptable forms of string: More... | |
logical function | set_date_gregorian (year, month, day, hour, minute, second, tick, Time_out, err_msg) |
Sets Time_outdays on a Gregorian calendar Computes the total number of days between 1/1/0001 to the current month/day/year. | |
type(time_type) function | set_date_i (year, month, day, hour, minute, second, tick, err_msg) |
Calls set_date_private to set days for different calendar types. | |
type(time_type) function, public | set_date_julian (year, month, day, hour, minute, second) |
logical function | set_date_julian_private (year, month, day, hour, minute, second, tick, Time_out, err_msg) |
type(time_type) function, public | set_date_no_leap (year, month, day, hour, minute, second) |
logical function | set_date_no_leap_private (year, month, day, hour, minute, second, tick, Time_out, err_msg) |
logical function | set_date_private (year, month, day, hour, minute, second, tick, Time_out, err_msg) |
Sets days for different calendar types. Given an input date in year, month, days, etc., creates a time_type that represents this time interval from the internally defined base date. More... | |
logical function | set_date_thirty (year, month, day, hour, minute, second, tick, Time_out, err_msg) |
subroutine, public | set_ticks_per_second (tps) |
Sets the number of ticks per second. | |
type(time_type) function | set_time_c (string, err_msg, allow_rounding) |
Returns a time_type set to the given amount of time via a string. More... | |
type(time_type) function | set_time_i (seconds, days, ticks, err_msg) |
Returns a time_type set to the given amount of time via integer amounts. More... | |
logical function | set_time_private (seconds, days, ticks, Time_out, err_msg) |
Returns a time interval corresponding to this number of days, seconds, and ticks. days, seconds and ticks may be negative, but resulting time must be positive. | |
subroutine | time_assignment (time1, time2) |
Assigns all components of the time_type variable on RHS to same components of time_type variable on LHS. | |
integer function | time_divide (time1, time2) |
Returns the largest integer, n, for which time1 >= time2 * n. More... | |
logical function | time_eq (time1, time2) |
Returns true if time1 == time2. More... | |
logical function | time_ge (time1, time2) |
Returns true if time1 >= time2. More... | |
logical function | time_gt (time1, time2) |
Returns true if time1 > time2. More... | |
logical function | time_le (time1, time2) |
Returns true if time1 <= time2. More... | |
subroutine, public | time_list_error (T, Terr) |
This routine converts the integer tdays to a string. More... | |
logical function | time_lt (time1, time2) |
Returns true if time1 < time2. More... | |
subroutine, public | time_manager_init () |
Initialization routine. Writes the version information to the log file. | |
type(time_type) function | time_minus (time1, time2) |
Returns difference of two time_types. WARNING: a time type is positive so by definition time1 - time2 is the same as time2 - time1. More... | |
logical function | time_ne (time1, time2) |
Returns true if time1 /= time2. More... | |
type(time_type) function | time_plus (time1, time2) |
Returns sum of two time_types. More... | |
real(r8_kind) function | time_real_divide (time1, time2) |
Returns the double precision quotient of two times. More... | |
type(time_type) function | time_scalar_divide (time, n) |
Returns the largest time, t, for which n * t <= time. More... | |
type(time_type) function | time_scalar_mult (time, n) |
Returns time multiplied by integer factor n. More... | |
real(kind=r8_kind) function, public | time_type_to_real (time) |
Converts time to seconds and returns it as a real number. | |
character(len=24) function, public | valid_calendar_types (ncal, err_msg) |
Returns a character string that describes the calendar type corresponding to the input integer. More... | |
logical function | valid_increments (year, month, day, hour, minute, second, tick, err_msg) |
Variables | |
integer, private | calendar_type = NO_CALENDAR |
integer, parameter | days_in_400_year_period = 146097 |
Used only for gregorian. | |
integer, dimension(12), private | days_per_month = (/31,28,31,30,31,30,31,31,30,31,30,31/) |
integer, parameter | do_floor = 0 |
integer, parameter | do_nearest = 1 |
integer, parameter, public | gregorian = 3 |
integer, parameter, public | invalid_calendar =-1 |
integer, parameter, public | julian = 2 |
integer, parameter | max_type = 4 |
logical | module_is_initialized = .false. |
integer, parameter, public | no_calendar = 0 |
integer, parameter, public | noleap = 4 |
integer, parameter | seconds_per_day = rseconds_per_day |
integer | ticks_per_second = 1 |
A software package that provides a set of simple interfaces for modelers to perform computations related to time and dates.
Optional error flag can be used in calling arguments of public routines. This allows the using routine to terminate the program. It is likely that more diagnostic information is available from the user than from time_manager alone. If the error flag is present then it is the responsibility of the using routine to test it and add additional information to the error message.
Calendar specific routines are private. They are not used, and should not be used, by any using code.
The module defines a type that can be used to represent discrete times (accurate to one second) and to map these times into dates using a variety of calendars. A time is mapped to a date by representing the time with respect to an arbitrary base date (refer to NOTES section for the base date setting).
The time_manager provides a single defined type, time_type, which is used to store time and date quantities. A time_type is a positive definite quantity that represents an interval of time. It can be most easily thought of as representing the number of seconds in some time interval. A time interval can be mapped to a date under a given calendar definition by using it to represent the time that has passed since some base date. A number of interfaces are provided to operate on time_type variables and their associated calendars. Time intervals can be as large as n days where n is the largest number represented by the default integer type on a compiler. This is typically considerably greater than 10 million years (assuming 32 bit integer representation) which is likely to be adequate for most applications. The description of the interfaces is separated into two sections. The first deals with operations on time intervals while the second deals with operations that convert time intervals to dates for a given calendar.
The smallest increment of time is referred to as a tick. A tick cannot be larger than 1 second, which also is the default. The number of ticks per second is set via pubic subroutine set_ticks_per_second. For example, ticks_per_second = 1000 will set the tick to one millisecond.
interface time_manager_mod::assignment(=) |
Operator override interface for use with time_type.
Definition at line 185 of file time_manager.F90.
Private Member Functions | |
subroutine | time_assignment (time1, time2) |
Assigns all components of the time_type variable on RHS to same components of time_type variable on LHS. | |
interface time_manager_mod::operator(*) |
Operator override interface for use with time_type.
Definition at line 156 of file time_manager.F90.
Private Member Functions | |
type(time_type) function | scalar_time_mult (n, time) |
Returns time multipled by integer factor n. More... | |
type(time_type) function | time_scalar_mult (time, n) |
Returns time multiplied by integer factor n. More... | |
|
private |
Returns time multipled by integer factor n.
[in] | time | a time interval |
[in] | n | factor to mulitply by |
Definition at line 800 of file time_manager.F90.
|
private |
Returns time multiplied by integer factor n.
[in] | time | time interval to multply |
[in] | n | factor to multiply by |
Definition at line 761 of file time_manager.F90.
interface time_manager_mod::operator(+) |
Operator override interface for use with time_type.
Definition at line 150 of file time_manager.F90.
Private Member Functions | |
type(time_type) function | time_plus (time1, time2) |
Returns sum of two time_types. More... | |
|
private |
Returns sum of two time_types.
[in] | time1 | time interval to add |
[in] | time2 | time interval to add |
Definition at line 728 of file time_manager.F90.
interface time_manager_mod::operator(-) |
Operator override interface for use with time_type.
Definition at line 153 of file time_manager.F90.
Private Member Functions | |
type(time_type) function | time_minus (time1, time2) |
Returns difference of two time_types. WARNING: a time type is positive so by definition time1 - time2 is the same as time2 - time1. More... | |
|
private |
Returns difference of two time_types. WARNING: a time type is positive so by definition time1 - time2 is the same as time2 - time1.
[in] | time1 | time interval to subtract |
[in] | time2 | time interval to subtract |
Definition at line 743 of file time_manager.F90.
interface time_manager_mod::operator(/) |
Operator override interface for use with time_type.
Definition at line 160 of file time_manager.F90.
Private Member Functions | |
integer function | time_divide (time1, time2) |
Returns the largest integer, n, for which time1 >= time2 * n. More... | |
type(time_type) function | time_scalar_divide (time, n) |
Returns the largest time, t, for which n * t <= time. More... | |
|
private |
Returns the largest integer, n, for which time1 >= time2 * n.
[in] | time1 | a time interval (dividend) |
[in] | time2 | a time interval (divisor) |
Definition at line 813 of file time_manager.F90.
|
private |
Returns the largest time, t, for which n * t <= time.
[in] | time | time interval to divide |
[in] | n | divisor |
Definition at line 944 of file time_manager.F90.
interface time_manager_mod::operator(//) |
Operator override interface for use with time_type.
Definition at line 182 of file time_manager.F90.
Private Member Functions | |
real(r8_kind) function | time_real_divide (time1, time2) |
Returns the double precision quotient of two times. More... | |
|
private |
Returns the double precision quotient of two times.
[in] | time1 | a time interval (dividend) |
[in] | time2 | a time interval (divisor) |
Definition at line 838 of file time_manager.F90.
interface time_manager_mod::operator(/=) |
Operator override interface for use with time_type.
Definition at line 179 of file time_manager.F90.
Private Member Functions | |
logical function | time_ne (time1, time2) |
Returns true if time1 /= time2. More... | |
|
private |
Returns true if time1 /= time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 716 of file time_manager.F90.
interface time_manager_mod::operator(<) |
Operator override interface for use with time_type.
Definition at line 170 of file time_manager.F90.
Private Member Functions | |
logical function | time_lt (time1, time2) |
Returns true if time1 < time2. More... | |
|
private |
Returns true if time1 < time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 671 of file time_manager.F90.
interface time_manager_mod::operator(<=) |
Operator override interface for use with time_type.
Definition at line 173 of file time_manager.F90.
Private Member Functions | |
logical function | time_le (time1, time2) |
Returns true if time1 <= time2. More... | |
|
private |
Returns true if time1 <= time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 689 of file time_manager.F90.
interface time_manager_mod::operator(==) |
Operator override interface for use with time_type.
Definition at line 176 of file time_manager.F90.
Private Member Functions | |
logical function | time_eq (time1, time2) |
Returns true if time1 == time2. More... | |
|
private |
Returns true if time1 == time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 701 of file time_manager.F90.
interface time_manager_mod::operator(>) |
Operator override interface for use with time_type.
Definition at line 164 of file time_manager.F90.
Private Member Functions | |
logical function | time_gt (time1, time2) |
Returns true if time1 > time2. More... | |
|
private |
Returns true if time1 > time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 639 of file time_manager.F90.
interface time_manager_mod::operator(>=) |
Operator override interface for use with time_type.
Definition at line 167 of file time_manager.F90.
Private Member Functions | |
logical function | time_ge (time1, time2) |
Returns true if time1 >= time2. More... | |
|
private |
Returns true if time1 >= time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 659 of file time_manager.F90.
interface time_manager_mod::set_date |
Given an input date in year, month, days, etc., creates a time_type that represents this time interval from the internally defined base date.
Given a date, computes the corresponding time given the selected date time mapping algorithm. Note that it is possible to specify any number of illegal dates; these should be checked for and generate errors as appropriate.
Example usage:
Integer input
String input
time_string | A character string containing a date formatted according to CF conventions. e.g. '1980-12-31 23:59:59.9' |
zero_year_warning | If the year number is zero, it will be silently changed to one, unless zero_year_warning=.true., in which case a WARNING message will also be issued. |
allow_rounding | When .true., any fractions of a second will be rounded off to the nearest tick. When .false., it is a fatal error if the second fraction cannot be exactly represented by a number of ticks. |
err_msg | When present, and when non-blank, a fatal error condition as been detected. The string itself is an error message. It is recommended that, when err_msg is present in the call to this routine, the next line of code should be something similar to this: if(err_msg /= '') call error_mesg('my_routine','additional info: '//trim(err_msg) ,fatal)
|
Definition at line 247 of file time_manager.F90.
Private Member Functions | |
type(time_type) function | set_date_c (string, zero_year_warning, err_msg, allow_rounding) |
Calls set_date_private for different calendar types when given a string input. Examples of acceptable forms of string: More... | |
type(time_type) function | set_date_i (year, month, day, hour, minute, second, tick, err_msg) |
Calls set_date_private to set days for different calendar types. | |
|
private |
Calls set_date_private for different calendar types when given a string input. Examples of acceptable forms of string:
1980-01-01 00:00:00 1980-01-01 00:00:00.50 1980-1-1 0:0:0 1980-1-1
year number must occupy 4 spaces. months, days, hours, minutes, seconds may occupy 1 or 2 spaces year, month and day must be separated by a '-' hour, minute, second must be separated by a ':' hour, minute, second are optional. If not present then zero is assumed. second may be a real number.
zero_year_warning: If the year number is zero, it will be silently changed to one, unless zero_year_warning=.true., in which case a WARNING message will also be issued
Definition at line 1508 of file time_manager.F90.
interface time_manager_mod::set_time |
Given some number of seconds and days, returns the corresponding time_type.
Given some number of seconds and days, returns the corresponding time_type. set_time has two forms; one accepts integer input, the other a character string with the day and second counts. For the first form, there are no restrictions on the range of the inputs, except that the result must be positive time. e.g. days=-1, seconds=86401 is acceptable. For the second form, days and seconds must both be positive.
Example usage:
Definition at line 207 of file time_manager.F90.
Private Member Functions | |
type(time_type) function | set_time_c (string, err_msg, allow_rounding) |
Returns a time_type set to the given amount of time via a string. More... | |
type(time_type) function | set_time_i (seconds, days, ticks, err_msg) |
Returns a time_type set to the given amount of time via integer amounts. More... | |
|
private |
Returns a time_type set to the given amount of time via a string.
[in] | string | Contains days and seconds separated by a single blank. days must be integer, seconds may be integer or real. Examples: '100 43200' '100 43200.50' |
[out] | err_msg | When present, and when non-blank, a fatal error condition as been detected. The string itself is an error message. It is recommended that, when err_msg is present in the call to this routine, the next line of code should be something similar to this: if(err_msg /= '') call error_mesg('my_routine','additional info: '//trim(err_msg),FATAL) |
[in] | allow_rounding | When .true., any fractions of a second will be rounded off to the nearest tick. When .false., it is a fatal error if the second fraction cannot be exactly represented by a number of ticks. |
Definition at line 360 of file time_manager.F90.
|
private |
Returns a time_type set to the given amount of time via integer amounts.
[in] | seconds | A number of seconds |
[in] | days | A number of days |
[in] | ticks | A number of ticks |
[out] | err_msg | When present, and when non-blank, a fatal error condition as been detected. The string itself is an error message. It is recommended that, when err_msg is present in the call to this routine, the next line of code should be something similar to this: if(err_msg /= '') call error_mesg('my_routine','additional info: '//trim(err_msg),FATAL) |
Definition at line 332 of file time_manager.F90.
type time_manager_mod::time_type |
Type to represent amounts of time. Implemented as seconds and days to allow for larger intervals.
Definition at line 141 of file time_manager.F90.
Private Attributes | |
integer | days |
integer | seconds |
integer | ticks |
integer function, public time_manager_mod::days_in_month | ( | type(time_type), intent(in) | Time, |
character(len=*), intent(out), optional | err_msg | ||
) |
Given a time, computes the corresponding date given the selected date time mapping algorithm.
[in] | time | a time interval |
Definition at line 2136 of file time_manager.F90.
integer function, public time_manager_mod::days_in_year | ( | type(time_type), intent(in) | Time | ) |
Returns the number of days in the calendar year corresponding to the date represented by time for the default calendar.
[in] | time | A time interval |
Definition at line 2383 of file time_manager.F90.
type(time_type) function, public time_manager_mod::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, | ||
integer, intent(in), optional | ticks, | ||
character(len=*), intent(out), optional | err_msg, | ||
logical, intent(in), optional | allow_neg_inc | ||
) |
Given a time and some date decrement, computes a new time. Depending on the mapping algorithm from date to time, it may be possible to specify undefined decrements (i.e. if one decrements by 68 days and 3 months in a Julian calendar, it matters which order these operations are done and we don't want to deal with stuff like that, make it an error).
[in] | time | time interval to decrement |
[in] | ticks | amount of time to decrement by units should not exceed next largest unit (ie. 61 seconds should be 1 min 1 sec ) |
Definition at line 2089 of file time_manager.F90.
type(time_type) function, public time_manager_mod::decrement_time | ( | type(time_type), intent(in) | Time, |
integer, intent(in) | seconds, | ||
integer, intent(in), optional | days, | ||
integer, intent(in), optional | ticks, | ||
character(len=*), intent(out), optional | err_msg, | ||
logical, intent(in), optional | allow_neg_inc | ||
) |
Decrements a time by seconds and days.
Given a time and a decrement of days and seconds, returns a time that subtracts this decrement from an input time.
[in] | time | A time interval |
[in] | seconds | Decrement of seconds |
[in] | ticks | Decrement of days and ticks |
[out] | err_msg | Present and non-blank when a fatal error has occured, holds the error message. |
[in] | allow_neg_inc | Throws fatal warning when set to false if negative values are used to decrement. Default is true. |
Definition at line 600 of file time_manager.F90.
subroutine, public time_manager_mod::get_date | ( | 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, | ||
integer, intent(out), optional | tick, | ||
character(len=*), intent(out), optional | err_msg | ||
) |
Gets the date for different calendar types. Given a time_interval, returns the corresponding date under the selected calendar. When err_msg present, and when non-blank, a fatal error condition as been detected. The string itself is an error message. It is recommended that, when err_msg is present in the call to this routine, the next line of code should be something similar to this:
if(err_msg /= '') call error_mesg('my_routine','additional info: '//trim(err_msg),FATAL)
Definition at line 1145 of file time_manager.F90.
subroutine, public time_manager_mod::get_time | ( | type(time_type), intent(in) | Time, |
integer, intent(out) | seconds, | ||
integer, intent(out), optional | days, | ||
integer, intent(out), optional | ticks, | ||
character(len=*), intent(out), optional | err_msg | ||
) |
Returns days and seconds ( < 86400 ) corresponding to a time. err_msg
should be checked for any errors.
time | A time_type interval to get days and seconds from | |
[out] | seconds | The number of seconds |
[out] | days | The number of seconds |
[out] | ticks | The number of ticks |
[out] | err_msg | Contains an error message on failure Example usage: get_time(time, seconds, days, ticks, err_msg)
|
Definition at line 491 of file time_manager.F90.
|
private |
Given a time and some date increment, computes a new time. Depending on the mapping algorithm from date to time, it may be possible to specify undefined increments (i.e. if one increments by 68 days and 3 months in a Julian calendar, it matters which order these operations are done and we don't want to deal with stuff like that, make it an error).
This routine operates in one of two modes.
Negative increments are always allowed in the private version of this routine.
Definition at line 1993 of file time_manager.F90.
type(time_type) function, public time_manager_mod::increment_time | ( | type(time_type), intent(in) | Time, |
integer, intent(in) | seconds, | ||
integer, intent(in), optional | days, | ||
integer, intent(in), optional | ticks, | ||
character(len=*), intent(out), optional | err_msg, | ||
logical, intent(in), optional | allow_neg_inc | ||
) |
Increments a time by seconds and days.
Given a time and an increment of days and seconds, returns a new time_type that represents the given time after the given increment.
[in] | time | A time interval |
[in] | seconds | Increment of seconds |
[in] | ticks | Increment of days and ticks |
[out] | err_msg | When present and non-blank, a fatal error condition has been detected, with the string itself as the error message. |
[in] | allow_neg_inc | When false, negative increments give fatal errors Defaults to true. |
Definition at line 532 of file time_manager.F90.
logical function, public time_manager_mod::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.
This is a specialized operation that is frequently performed in models. Given a time, and a time interval, this function is true if this is the closest time step to the alarm time. The actual computation is:
if((alarm_time - time) <= (time_interval / 2))
If the function is true, the alarm time is incremented by the alarm_interval; WARNING, this is a featured side effect. Otherwise, the function is false and there are no other effects. CAUTION: if the alarm_interval is smaller than the time_interval, the alarm may fail to return true ever again. Watch for problems if the new alarm time is less than time + time_interval
[in] | time | current time |
[in] | time_interval | a time interval |
[in] | alarm_interval | a time interval |
[in,out] | alarm | An alarm time, which is incremented by the alarm_interval if the function is true. |
Definition at line 1000 of file time_manager.F90.
logical function, public time_manager_mod::leap_year | ( | type(time_type), intent(in) | Time, |
character(len=*), intent(out), optional | err_msg | ||
) |
Returns true if the year corresponding to the input time is a leap year (for default calendar). Always returns false for THIRTY_DAY_MONTHS and NOLEAP.
[in] | time | a time interval to check if leap year |
Definition at line 2216 of file time_manager.F90.
type(time_type) function, public time_manager_mod::length_of_year |
Returns the mean length of the year in the default calendar setting.
There are no arguments in this function. It returns the mean length of the year for the default calendar.
Definition at line 2304 of file time_manager.F90.
character (len=9) function, public time_manager_mod::month_name | ( | integer, intent(in) | n | ) |
Returns a character string containing the name of the month corresponding to month number n.
Definition is the same for all calendar types.
[in] | n | Month number |
Definition at line 2465 of file time_manager.F90.
subroutine, public time_manager_mod::print_date | ( | type(time_type), intent(in) | Time, |
character (len=*), intent(in), optional | str, | ||
integer, intent(in), optional | unit | ||
) |
Prints the time to standard output (or optional unit) as a date.
Prints the given time_type argument as a date (using year, month, day, hour, minutes, seconds and ticks). NOTE: there is no check for PE number.
[in] | time | Time that will be printed |
[in] | str | Character string that precedes the printed time |
[in] | unit | Unit number for printed output, defaults to stdout |
Definition at line 2559 of file time_manager.F90.
subroutine, public time_manager_mod::print_time | ( | type(time_type), intent(in) | Time, |
character (len=*), intent(in), optional | str, | ||
integer, intent(in), optional | unit | ||
) |
Prints the given time_type argument as a time (using days, seconds and ticks)
[in] | time | Time that will be printed |
[in] | str | Character string that precedes the printed time |
[in] | unit | Unit number for printed output, defaults to stdout |
Definition at line 2524 of file time_manager.F90.
|
private |
[in] | x | number of seconds |
[out] | err_msg | Error message. |
Definition at line 910 of file time_manager.F90.
|
private |
Convert a real number of seconds into a time_type variable.
[in] | x | Number of seconds. |
[out] | err_msg | Error message. |
Definition at line 885 of file time_manager.F90.
logical function, public time_manager_mod::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.
[in] | time | current time |
[in] | alarm_frequency | a time interval for time in between alarm activations |
[in] | alarm_length | a time interval for amount of time alarm is active for |
Definition at line 1025 of file time_manager.F90.
|
private |
Convert a floating point value to an integer value.
[in] | rval | A floating point value. |
[in] | mode | A rouding mode (either "do_floor" or "do_nearest") |
Definition at line 919 of file time_manager.F90.
|
private |
Returns time multipled by integer factor n.
[in] | time | a time interval |
[in] | n | factor to mulitply by |
Definition at line 800 of file time_manager.F90.
subroutine, public time_manager_mod::set_calendar_type | ( | integer, intent(in) | type, |
character(len=*), intent(out), optional | err_msg | ||
) |
Sets calendar_type for mapping an interval to a date. For the Gregorian calendar, negative years and the proleptic calendar are not used; and the discontinuity of days in October 1582 (when the Gregorian calendar was adopted by select groups in Europe) is also not taken into account.
[in] | type | constant parameter value (ie. one NO_CALENDAR, ) |
Definition at line 1074 of file time_manager.F90.
|
private |
Calls set_date_private for different calendar types when given a string input. Examples of acceptable forms of string:
1980-01-01 00:00:00 1980-01-01 00:00:00.50 1980-1-1 0:0:0 1980-1-1
year number must occupy 4 spaces. months, days, hours, minutes, seconds may occupy 1 or 2 spaces year, month and day must be separated by a '-' hour, minute, second must be separated by a ':' hour, minute, second are optional. If not present then zero is assumed. second may be a real number.
zero_year_warning: If the year number is zero, it will be silently changed to one, unless zero_year_warning=.true., in which case a WARNING message will also be issued
Definition at line 1508 of file time_manager.F90.
|
private |
Sets days for different calendar types. Given an input date in year, month, days, etc., creates a time_type that represents this time interval from the internally defined base date.
[out] | err_msg | error message, if non-empty an error has occured |
Definition at line 1430 of file time_manager.F90.
|
private |
Returns a time_type set to the given amount of time via a string.
[in] | string | Contains days and seconds separated by a single blank. days must be integer, seconds may be integer or real. Examples: '100 43200' '100 43200.50' |
[out] | err_msg | When present, and when non-blank, a fatal error condition as been detected. The string itself is an error message. It is recommended that, when err_msg is present in the call to this routine, the next line of code should be something similar to this: if(err_msg /= '') call error_mesg('my_routine','additional info: '//trim(err_msg),FATAL) |
[in] | allow_rounding | When .true., any fractions of a second will be rounded off to the nearest tick. When .false., it is a fatal error if the second fraction cannot be exactly represented by a number of ticks. |
Definition at line 360 of file time_manager.F90.
|
private |
Returns a time_type set to the given amount of time via integer amounts.
[in] | seconds | A number of seconds |
[in] | days | A number of days |
[in] | ticks | A number of ticks |
[out] | err_msg | When present, and when non-blank, a fatal error condition as been detected. The string itself is an error message. It is recommended that, when err_msg is present in the call to this routine, the next line of code should be something similar to this: if(err_msg /= '') call error_mesg('my_routine','additional info: '//trim(err_msg),FATAL) |
Definition at line 332 of file time_manager.F90.
|
private |
Returns the largest integer, n, for which time1 >= time2 * n.
[in] | time1 | a time interval (dividend) |
[in] | time2 | a time interval (divisor) |
Definition at line 813 of file time_manager.F90.
|
private |
Returns true if time1 == time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 701 of file time_manager.F90.
|
private |
Returns true if time1 >= time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 659 of file time_manager.F90.
|
private |
Returns true if time1 > time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 639 of file time_manager.F90.
|
private |
Returns true if time1 <= time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 689 of file time_manager.F90.
subroutine, public time_manager_mod::time_list_error | ( | type(time_type), intent(in) | T, |
character(len=:), allocatable | Terr | ||
) |
This routine converts the integer tdays to a string.
[in] | t | time_type input |
terr | String holding the tdays |
Allocate the string
Write the integer to the string
Definition at line 2639 of file time_manager.F90.
|
private |
Returns true if time1 < time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 671 of file time_manager.F90.
|
private |
Returns difference of two time_types. WARNING: a time type is positive so by definition time1 - time2 is the same as time2 - time1.
[in] | time1 | time interval to subtract |
[in] | time2 | time interval to subtract |
Definition at line 743 of file time_manager.F90.
|
private |
Returns true if time1 /= time2.
[in] | time1 | time interval to compare |
[in] | time2 | time interval to compare |
Definition at line 716 of file time_manager.F90.
|
private |
Returns sum of two time_types.
[in] | time1 | time interval to add |
[in] | time2 | time interval to add |
Definition at line 728 of file time_manager.F90.
|
private |
Returns the double precision quotient of two times.
[in] | time1 | a time interval (dividend) |
[in] | time2 | a time interval (divisor) |
Definition at line 838 of file time_manager.F90.
|
private |
Returns the largest time, t, for which n * t <= time.
[in] | time | time interval to divide |
[in] | n | divisor |
Definition at line 944 of file time_manager.F90.
|
private |
Returns time multiplied by integer factor n.
[in] | time | time interval to multply |
[in] | n | factor to multiply by |
Definition at line 761 of file time_manager.F90.
character(len=24) function, public time_manager_mod::valid_calendar_types | ( | integer, intent(in) | ncal, |
character(len=*), intent(out), optional | err_msg | ||
) |
Returns a character string that describes the calendar type corresponding to the input integer.
[in] | ncal | Integer corresponding to a valid calendar type |
[out] | err_msg | Holds an error message when present |
Definition at line 2589 of file time_manager.F90.