29 module time_interp_mod
35 operator(+),
operator(-),
operator(>), &
36 operator(<),
operator( // ),
operator( / ), &
37 operator(>=),
operator(<=),
operator( * ), &
45 use mpp_mod,
only: input_nml_file
127 module procedure time_interp_frac_r8, time_interp_year_r8, &
128 time_interp_month_r8, time_interp_day_r8, &
129 time_interp_list_r8, time_interp_modulo_r8
130 module procedure time_interp_frac_r4, time_interp_year_r4, &
131 time_interp_month_r4, time_interp_day_r4, &
132 time_interp_list_r4, time_interp_modulo_r4
137 integer,
public,
parameter :: NONE=0, year=1, month=2, day=3
141 integer,
parameter :: secmin = 60, minhour = 60, hourday = 24, &
142 sechour = secmin*minhour, &
143 secday = secmin*minhour*hourday
145 integer,
parameter :: monyear = 12
146 integer,
parameter :: halfday = secday/2
148 integer :: yrmod, momod, dymod
149 logical :: mod_leapyear
152 #include<file_version.h>
154 logical :: module_is_initialized=.false.
155 logical :: perthlike_behavior=.false.
157 namelist / time_interp_nml / perthlike_behavior
162 subroutine time_interp_init()
163 integer :: ierr, io, logunit
165 if ( module_is_initialized )
return
167 read (input_nml_file, time_interp_nml, iostat=io)
172 write(logunit,time_interp_nml)
174 module_is_initialized = .true.
176 end subroutine time_interp_init
197 subroutine bisect(Timelist,Time,index1,index2)
198 type(
time_type) ,
intent(in) :: Timelist(:)
200 integer,
optional,
intent(out) :: index1, index2
202 integer :: i,il,iu,n,i1,i2
204 n =
size(timelist(:))
206 if (time==timelist(1))
then
208 else if (time==timelist(n))
then
214 if(timelist(i) > time)
then
223 if(
PRESENT(index1)) index1 = i1
224 if(
PRESENT(index2)) index2 = i2
231 function year_midpt (yr)
233 integer,
intent(in) :: yr
234 type (time_type) :: year_midpt, year_beg, year_end
240 year_midpt = (year_beg + year_end) / 2
242 end function year_midpt
244 function month_midpt (yr, mo)
246 integer,
intent(in) :: yr, mo
247 type (time_type) :: month_midpt, month_beg, month_end
259 month_midpt = (month_beg + month_end) / 2
261 end function month_midpt
263 function set_modtime (Tin, modtime)
result (Tout)
265 integer,
intent(in),
optional :: modtime
267 integer :: yr, mo, dy, hr, mn, se, mtime
269 if(
present(modtime))
then
279 call get_date (tin, yr, mo, dy, hr, mn, se)
282 if (.not.mod_leapyear .and. mo == 2 .and. dy > 28)
then
285 tout =
set_date(yr, mo, dy, hr, mn, se)
287 call get_date (tin, yr, mo, dy, hr, mn, se)
288 yr = yrmod; mo = momod
289 tout =
set_date(yr, mo, dy, hr, mn, se)
291 call get_date (tin, yr, mo, dy, hr, mn, se)
292 yr = yrmod; mo = momod; dy = dymod
293 tout =
set_date(yr, mo, dy, hr, mn, se)
296 end function set_modtime
298 subroutine error_handler(string)
299 character(len=*),
intent(in) :: string
301 call error_mesg (
'time_interp_mod', trim(string), fatal)
303 end subroutine error_handler
306 #include "time_interp_r4.fh"
307 #include "time_interp_r8.fh"
309 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...