30 module time_interp_mod
36 operator(+),
operator(-),
operator(>), &
37 operator(<),
operator( // ),
operator( / ), &
38 operator(>=),
operator(<=),
operator( * ), &
46 use 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
138 integer,
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)
173 write(logunit,time_interp_nml)
175 module_is_initialized = .true.
177 end subroutine time_interp_init
198 subroutine 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
264 function set_modtime (Tin, modtime)
result (Tout)
266 integer,
intent(in),
optional :: modtime
268 integer :: 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)
297 end function set_modtime
299 subroutine error_handler(string)
300 character(len=*),
intent(in) :: string
302 call error_mesg (
'time_interp_mod', trim(string), fatal)
304 end subroutine error_handler
307 #include "time_interp_r4.fh"
308 #include "time_interp_r8.fh"
310 end module time_interp_mod
integer function, public check_nml_error(IOSTAT, NML_NAME)
Checks the iostat argument that is returned after reading a namelist and determines if the error code...
subroutine, public write_version_number(version, tag, unit)
Prints to the log file (or a specified unit) the version id string and tag name.
logical function, public fms_error_handler(routine, message, err_msg)
Facilitates the control of fatal error conditions.
subroutine, public error_mesg(routine, message, level)
Print notes, warnings and error messages; terminates program for warning and error messages....
integer function stdout()
This function returns the current standard fortran unit numbers for output.
integer function stdlog()
This function returns the current standard fortran unit numbers for log messages. Log messages,...
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...
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,...
Returns a weight and dates or indices for interpolating between two dates. The interface fraction_of_...
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.
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...
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 print_date(Time, str, unit)
Prints the time to standard output (or optional unit) as a date.
integer function, public days_in_month(Time, err_msg)
Given a time, computes the corresponding date given the selected date time mapping algorithm.
real(kind=r8_kind) function, public time_type_to_real(time)
Converts time to seconds and returns it as a real number.
integer function, public get_calendar_type()
Returns default calendar type for mapping from time to date.
subroutine, public print_time(Time, str, unit)
Prints the given time_type argument as a time (using days, seconds and ticks)
subroutine, public time_list_error(T, Terr)
This routine converts the integer tdays to a string.
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...