36 operator(+),
operator(-),
operator(>), &
37 operator(<),
operator( // ),
operator( / ), &
38 operator(>=),
operator(<=),
operator( * ), &
42use fms_mod,
only: write_version_number, &
43 error_mesg, fatal, stdout, stdlog, &
46use mpp_mod,
only: input_nml_file
128 module procedure time_interp_frac_r8, time_interp_year_r8, &
129 time_interp_month_r8, time_interp_day_r8, &
130 time_interp_list_r8, time_interp_modulo_r8
131 module procedure time_interp_frac_r4, time_interp_year_r4, &
132 time_interp_month_r4, time_interp_day_r4, &
133 time_interp_list_r4, time_interp_modulo_r4
138integer,
public,
parameter :: NONE=0, year=1, month=2, day=3
142 integer,
parameter :: secmin = 60, minhour = 60, hourday = 24, &
143 sechour = secmin*minhour, &
144 secday = secmin*minhour*hourday
146 integer,
parameter :: monyear = 12
147 integer,
parameter :: halfday = secday/2
149 integer :: yrmod, momod, dymod
150 logical :: mod_leapyear
153#include<file_version.h>
155 logical :: module_is_initialized=.false.
156 logical :: perthlike_behavior=.false.
158 namelist / time_interp_nml / perthlike_behavior
163 subroutine time_interp_init()
164 integer :: ierr, io, logunit
166 if ( module_is_initialized )
return
168 read (input_nml_file, time_interp_nml, iostat=io)
169 ierr = check_nml_error(io,
'time_interp_nml')
171 call write_version_number(
"TIME_INTERP_MOD", version)
173 write(logunit,time_interp_nml)
175 module_is_initialized = .true.
177 end subroutine time_interp_init
198subroutine bisect(Timelist,Time,index1,index2)
199 type(
time_type) ,
intent(in) :: Timelist(:)
201 integer,
optional,
intent(out) :: index1, index2
203 integer :: i,il,iu,n,i1,i2
205 n =
size(timelist(:))
207 if (time==timelist(1))
then
209 else if (time==timelist(n))
then
215 if(timelist(i) > time)
then
224 if(
PRESENT(index1)) index1 = i1
225 if(
PRESENT(index2)) index2 = i2
232 function year_midpt (yr)
234 integer,
intent(in) :: yr
235 type (time_type) :: year_midpt, year_beg, year_end
241 year_midpt = (year_beg + year_end) / 2
243 end function year_midpt
245 function month_midpt (yr, mo)
247 integer,
intent(in) :: yr, mo
248 type (time_type) :: month_midpt, month_beg, month_end
260 month_midpt = (month_beg + month_end) / 2
262 end function month_midpt
264function set_modtime (Tin, modtime)
result (Tout)
266integer,
intent(in),
optional :: modtime
268integer :: yr, mo, dy, hr, mn, se, mtime
270 if(
present(modtime))
then
280 call get_date (tin, yr, mo, dy, hr, mn, se)
283 if (.not.mod_leapyear .and. mo == 2 .and. dy > 28)
then
286 tout =
set_date(yr, mo, dy, hr, mn, se)
288 call get_date (tin, yr, mo, dy, hr, mn, se)
289 yr = yrmod; mo = momod
290 tout =
set_date(yr, mo, dy, hr, mn, se)
292 call get_date (tin, yr, mo, dy, hr, mn, se)
293 yr = yrmod; mo = momod; dy = dymod
294 tout =
set_date(yr, mo, dy, hr, mn, se)
297end function set_modtime
299subroutine error_handler(string)
300 character(len=*),
intent(in) :: string
302 call error_mesg (
'time_interp_mod', trim(string), fatal)
304end subroutine error_handler
307#include "time_interp_r4.fh"
308#include "time_interp_r8.fh"
310end module time_interp_mod
real(r8_kind) function, public fraction_of_year(time)
Wrapper function to return the fractional time into the current year Always returns an r8_kind,...
subroutine bisect(timelist, time, index1, index2)
Given an array of times in ascending order and a specific time returns values of index1 and index2 su...
Returns a weight and dates or indices for interpolating between two dates. The interface fraction_of_...
subroutine, public print_date(time, str, unit)
Prints the time to standard output (or optional unit) as a date.
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...
subroutine, public time_list_error(t, terr)
This routine converts the integer tdays to a string.
integer function, public get_calendar_type()
Returns default calendar type for mapping from time to date.
integer function, public days_in_month(time, err_msg)
Given a time, computes the corresponding date given the selected date time mapping algorithm.
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)....
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.
real(kind=r8_kind) function, public time_type_to_real(time)
Converts time to seconds and returns it as a real number.
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 und...
subroutine, public print_time(time, str, unit)
Prints the given time_type argument as a time (using days, seconds and ticks)
Given an input date in year, month, days, etc., creates a time_type that represents this time interva...
Given some number of seconds and days, returns the corresponding time_type.
Type to represent amounts of time. Implemented as seconds and days to allow for larger intervals.
Wrapper for the real to time interface Takes seconds as reals to convert to a time_type representatio...