11 use iso_c_binding,
only : c_short, c_int, c_float, c_double, c_bool
45 logical (c_bool),
intent(in) :: lactive(:,:)
48 integer (c_int) :: istat
54 call die(
"A RUNOFF_ZONE grid must be supplied in order to make use of this option.", __file__, __line__)
58 allocate (
runoff_zone( count( lactive ) ), stat=istat )
59 call assert(istat==0,
"Failed to allocate memory for the RUNOFF_ZONE variable", __file__, __line__)
64 call assert(istat==0,
"Failed to allocate memory for the RUNOFF_RATIOS variable", __file__, __line__)
68 call cf_dict%get_values( skey=
"RUNOFF_RATIO_MONTHLY_FILE", slstring=slstring )
80 character (len=*),
intent(in) :: sFilename
83 character (len=65536) :: sRecord, sSubstring
84 integer (c_int) :: iStat
85 integer (c_int) :: iLineNum
86 integer (c_int) :: iFieldNum
87 integer (c_int) :: iIndex
88 integer (c_int) :: iNumLines
89 integer (c_int) :: iNumFields
90 type (ASCII_FILE_T) :: RUNOFF_RATIO_FILE
92 call runoff_ratio_file%open( sfilename = sfilename, &
93 scommentchars =
"#%!", &
94 sdelimiters =
"WHITESPACE", &
95 lhasheader = .
false._c_bool )
97 inumlines = runoff_ratio_file%numLines()
100 srecord = runoff_ratio_file%readLine()
105 call assert( istat == 0,
"Problem allocating memory for runoff ratio table values", &
109 call assert( istat == 0,
"Problem allocating memory for runoff ratio table date values vector", &
119 srecord = runoff_ratio_file%readLine()
121 if ( runoff_ratio_file%isEOF() )
exit
123 ilinenum = ilinenum + 1
127 call chomp(srecord, ssubstring, runoff_ratio_file%sDelimiters )
129 if ( len_trim(ssubstring) == 0 ) &
130 call die(
"Missing date in the monthly runoff ratio file", &
131 __file__, __line__,
"Problem occured on line number " &
132 //
ascharacter(runoff_ratio_file%currentLineNum() ) &
133 //
" of file "//
dquote(sfilename) )
137 do iindex = 2, inumfields
140 call chomp(srecord, ssubstring, runoff_ratio_file%sDelimiters )
142 if ( len_trim(ssubstring) == 0 ) &
143 call die(
"Missing or corrupt value in the runoff ratio file", &
144 __file__, __line__,
"Problem occured on line number " &
145 //
ascharacter(runoff_ratio_file%currentLineNum() ) &
146 //
" of file "//
dquote(sfilename) )
162 integer (c_int) :: ijulianday
163 integer (c_int) :: imonth
164 integer (c_int) :: iday
165 integer (c_int) :: iyear
166 integer (c_int) :: idaysinmonth
167 integer (c_int) :: inumdaysfromorigin
168 integer (c_int) :: ilinenum
169 integer (c_int) :: ifieldnum
170 real (c_float) :: ffactor
171 logical (c_bool) :: lmatch
172 integer (c_int) :: icount
189 if ( .not. lmatch ) &
190 call die(
"Failed to find an appropriate date value in the RUNOFF_RATIO file.", &
200 icount = icount + count(
runoff_zone == ifieldnum )
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
Defines the DATA_CATALOG_T data type, which contains type-bound procedures to add,...
type(data_catalog_t), public dat
DAT is a global to hold data catalog entries.
This module contains the DATETIME_T class and associated time and date-related routines,...
type(dict_t), public cf_dict
subroutine, public die(smessage, smodule, iline, shints, scalledby, icalledbyline)
Module runoff__gridded_values provides support for estimating fog drip given a gridded map of RUNOFF_...
subroutine read_runoff_ratio_table(sfilename)
type(data_catalog_entry_t), pointer prunoff_zone
subroutine, public runoff_gridded_values_initialize(lactive)
Initialize the infiltration grid.
type(datetime_t), dimension(:), allocatable runoff_table_dates
subroutine, public runoff_gridded_values_update_ratios()
real(c_float), dimension(:), allocatable, public runoff_ratios
real(c_float), dimension(:,:), allocatable runoff_table_values
integer(c_int), dimension(:), allocatable runoff_zone
type(date_range_t), public sim_dt