3 use iso_c_binding,
only : c_short, c_int, c_float, c_double, c_bool
15 real (c_float),
allocatable ::
tmin(:)
16 real (c_float),
allocatable ::
tmax(:)
17 real (c_float),
allocatable ::
precip(:)
28 type (FSTRING_LIST_T) :: slList
29 integer (kind=c_int) :: indx
30 integer (kind=c_int) :: iStat
31 character (len=:),
allocatable :: date_str
32 type (DATETIME_T) :: tempdate
33 type (DATETIME_T) :: firstdate
34 type (DATETIME_T) :: lastdate
35 integer (c_int) :: error_count
36 integer (c_int) :: first_indx
40 call params%get_parameters(skey=
"TMIN", fvalues=
tmin)
41 call params%get_parameters(skey=
"TMAX", fvalues=
tmax)
44 call params%get_parameters( skey=
"Date", slvalues=sllist)
47 call assert( istat==0,
"Failed to allocate memory for WEATHER_DATE array", &
50 call logs%write(
" Date | PRCP | TMIN | TMAX")
51 call logs%write(
"-------------|---------------|--------------|--------------")
53 call weather_date(1)%setDateFormat(sdateformat=
"YYYY-MM-DD")
55 print *,
"Scanning weather data file for anomalies... There are "//
ascharacter(sllist%count)//
" entries."
60 do indx=1, sllist%count
62 date_str = sllist%get(indx)
63 call weather_date(indx)%parsedate( date_str, __file__, __line__ )
68 if ( ( tempdate <
sim_dt%start ) .or. ( tempdate >
sim_dt%end ) )
then
74 elseif ( (
weather_date(indx) == tempdate) .and. (error_count == 0))
then
86 elseif ((
weather_date(indx) == tempdate) .and. (error_count > 0))
then
88 call warn(
"Missing or out of order date sequence "//
ascharacter(error_count)//
" value(s) in" &
89 //
" single-station weather data file. Problem date(s) span "//firstdate%prettydate()//
" to " &
90 //lastdate%prettydate()//
".", lfatal=
true)
93 elseif (error_count == 0)
then
96 error_count = error_count + 1
98 call tempdate%addDay()
102 error_count = error_count + 1
103 call tempdate%addDay()
110 call tempdate%addDay()
116 call weather_date(1)%setDateFormat(sdateformat=
"MM-DD-YYYY")
124 type (DATETIME_T),
intent(in) :: dt
126 integer (c_int) :: indx
127 logical (c_bool) :: date_found
141 call assert(date_found,
"Failed to find a matching date value in the daily weather data table.", &
150 type (DATETIME_T),
intent(in) :: dt
151 real (kind=c_float),
intent(out) :: precip_value
163 type (DATETIME_T),
intent(in) :: dt
164 real (kind=c_float),
intent(out) :: tmax_value
175 type (DATETIME_T),
intent(in) :: dt
176 real (kind=c_float),
intent(out) :: tmin_value
This module contains physical constants and convenience functions aimed at performing unit conversion...
logical(c_bool), parameter, public true
logical(c_bool), parameter, public false
real(c_double), parameter, public m_per_foot
This module contains the DATETIME_T class and associated time and date-related routines,...
subroutine, public warn(smessage, smodule, iline, shints, lfatal, iloglevel, lecho)
subroutine, public die(smessage, smodule, iline, shints, scalledby, icalledbyline)
real(c_float), parameter, public na_float
real(c_float), parameter, private na_float
type(logfile_t), public logs
type(parameters_t), public params
type(date_range_t), public sim_dt
subroutine weather_data_tabular_initialize()
subroutine weather_data_tabular_get_tmin(dt, tmin_value)
subroutine weather_data_find_date_indx(dt)
real(c_float), dimension(:), allocatable tmax
real(c_float), dimension(:), allocatable precip
real(c_float), dimension(:), allocatable tmin
subroutine weather_data_tabular_get_precip(dt, precip_value)
integer(c_int), save, private date_indx
subroutine weather_data_tabular_get_tmax(dt, tmax_value)
type(datetime_t), dimension(:), allocatable weather_date