10 use iso_c_binding,
only : c_short, c_int, c_float, c_double, c_bool
34 integer (c_int),
allocatable ::
et_zone(:)
46 logical (c_bool),
intent(in) :: lactive(:,:)
49 integer (c_int) :: istat
54 if ( .not.
associated(
pet_grid) )
then
57 call die(
"A POTENTIAL_ET or REFERENCE_ET0 grid must be supplied in order to make" &
58 //
" use of this option.", __file__, __line__)
64 call die(
"A ET_ZONE grid must be supplied in order to make use of this option.", __file__, __line__)
68 allocate (
et_zone( count( lactive ) ), stat=istat )
69 call assert(istat==0,
"Failed to allocate memory for the ET_ZONE variable", __file__, __line__)
73 allocate (
et_ratios( count( lactive ) ), stat=istat)
74 call assert(istat==0,
"Failed to allocate memory for the ET_RATIOS variable", __file__, __line__)
77 call cf_dict%get_values( skey=
"ET_RATIO_MONTHLY_FILE", slstring=slstring )
89 character (len=*),
intent(in) :: sFilename
92 character (len=65536) :: sRecord, sSubstring
93 integer (c_int) :: iStat
94 integer (c_int) :: iLineNum
95 integer (c_int) :: iFieldNum
96 integer (c_int) :: iIndex
97 integer (c_int) :: iNumLines
98 integer (c_int) :: iNumFields
99 type (ASCII_FILE_T) :: ET_RATIO_FILE
101 integer (c_int),
parameter :: ET_ZONE_FIELD = 1
103 call et_ratio_file%open( sfilename = sfilename, &
104 scommentchars =
"#%!", &
105 sdelimiters =
"WHITESPACE", &
106 lhasheader = .
false._c_bool )
108 inumlines = et_ratio_file%numLines()
111 srecord = et_ratio_file%readLine()
116 call assert( istat == 0,
"Problem allocating memory for et ratio table values", &
125 srecord = et_ratio_file%readLine()
127 if ( et_ratio_file%isEOF() )
exit
129 ilinenum = ilinenum + 1
133 call chomp(srecord, ssubstring, et_ratio_file%sDelimiters )
135 if ( len_trim(ssubstring) == 0 ) &
136 call die(
"Missing ET ZONE in the monthly et ratio file", &
137 __file__, __line__,
"Problem occured on line number " &
139 //
" of file "//
dquote(sfilename) )
143 do iindex = 2, inumfields
146 call chomp(srecord, ssubstring, et_ratio_file%sDelimiters )
148 if ( len_trim(ssubstring) == 0 ) &
149 call die(
"Missing or corrupt value in the et ratio file", &
150 __file__, __line__,
"Problem occured on line number " &
152 //
" of file "//
dquote(sfilename) )
167 integer (c_int) :: ilinenum
168 integer (c_int) :: ifieldnum
169 integer (c_int) :: iet_zone_id
170 real (c_float) :: ffactor
171 integer (c_int) :: icount
176 associate( dt =>
sim_dt%curr )
182 ifieldnum = dt%iMonth + 1
185 if ( dt%iDay == 1 )
then
190 icount = icount + count(
et_zone == ifieldnum )
192 where (
et_zone == iet_zone_id )
This module contains physical constants and convenience functions aimed at performing unit conversion...
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
Module et__zone_values provides support for estimating reference ET given a zone map of ET_ZONE.
real(c_float), dimension(:), allocatable, public et_ratios
subroutine read_et_ratio_table(sfilename)
subroutine, public et_zone_values_initialize(lactive)
Initialize the ET grid.
real(c_float), dimension(:,:), allocatable et_table_values
type(data_catalog_entry_t), pointer pet_zone
integer(c_int), dimension(:), allocatable et_zone
type(data_catalog_entry_t), pointer, public pet_grid
subroutine, public et_zone_values_calculate()
subroutine, public die(smessage, smodule, iline, shints, scalledby, icalledbyline)
type(date_range_t), public sim_dt