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),
allocatable :: RUNOFF_RATIO_FILE
92 allocate(runoff_ratio_file)
94 call runoff_ratio_file%open( sfilename = sfilename, &
95 scommentchars =
"#%!", &
96 sdelimiters =
"WHITESPACE", &
97 lhasheader = .
true._c_bool )
99 inumlines = runoff_ratio_file%numLines()
102 srecord = runoff_ratio_file%readLine()
107 call assert( istat == 0,
"Problem allocating memory for runoff ratio table values", &
111 call assert( istat == 0,
"Problem allocating memory for runoff ratio table date values vector", &
121 srecord = runoff_ratio_file%readLine()
123 if ( runoff_ratio_file%isEOF() )
exit
125 ilinenum = ilinenum + 1
129 call chomp(srecord, ssubstring, runoff_ratio_file%sDelimiters )
131 if ( len_trim(ssubstring) == 0 ) &
132 call die(
"Missing date in the monthly runoff ratio file", &
133 __file__, __line__,
"Problem occured on line number " &
134 //
ascharacter(runoff_ratio_file%currentLineNum() ) &
135 //
" of file "//
dquote(sfilename) )
139 do iindex = 2, inumfields
142 call chomp(srecord, ssubstring, runoff_ratio_file%sDelimiters )
144 if ( len_trim(ssubstring) == 0 ) &
145 call die(
"Missing or corrupt value in the runoff ratio file", &
146 __file__, __line__,
"Problem occured on line number " &
147 //
ascharacter(runoff_ratio_file%currentLineNum() ) &
148 //
" of file "//
dquote(sfilename) )
164 integer (c_int) :: ilinenum
165 integer (c_int) :: ifieldnum
166 logical (c_bool) :: lmatch
167 integer (c_int) :: icount
184 if ( .not. lmatch ) &
185 call die(
"Failed to find an appropriate date value in the RUNOFF_RATIO file.", &
195 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