27 logical (c_bool),
intent(in) :: is_cell_active(:,:)
28 integer (c_int),
intent(in) :: landuse_index(:)
31 integer (c_int) :: status
32 integer (c_int) :: indx
35 character (len=32) :: sbuf
36 real (c_float),
allocatable :: gdd_base_l(:)
37 real (c_float),
allocatable :: gdd_max_l(:)
38 integer (c_int) :: number_of_landuse_codes
39 integer (c_int),
allocatable :: landuse_code(:)
41 allocate(
gdd_base( count( is_cell_active ) ), stat=status )
42 call assert( status == 0,
"Problem allocating memory", __file__, __line__ )
44 allocate(
gdd_max( count( is_cell_active ) ), stat=status )
45 call assert( status == 0,
"Problem allocating memory", __file__, __line__ )
48 call parameter_list%append(
"LU_Code")
49 call parameter_list%append(
"Landuse_Code")
50 call parameter_list%append(
"Landuse_Lookup_Code")
53 call params%get_parameters( slkeys=parameter_list, ivalues=landuse_code )
54 number_of_landuse_codes = count( landuse_code >= 0 )
55 call parameter_list%clear()
57 call parameter_list%append(
"GDD_Base_Temp")
58 call parameter_list%append(
"GDD_Base_Temperature")
59 call parameter_list%append(
"GDD_Base")
61 call params%get_parameters( slkeys=parameter_list, fvalues=gdd_base_l )
62 call parameter_list%clear()
64 call parameter_list%append(
"GDD_Max_Temp")
65 call parameter_list%append(
"GDD_Maximum_Temperature")
66 call parameter_list%append(
"GDD_Maximum_Temp")
67 call parameter_list%append(
"GDD_Max")
69 call params%get_parameters( slkeys=parameter_list, fvalues=gdd_max_l )
70 call parameter_list%clear()
72 call parameter_list%append(
"GDD_Reset_Date")
73 call parameter_list%append(
"GDD_Reset")
75 call params%get_parameters( slkeys=parameter_list, slvalues=gdd_reset_val_list )
76 call parameter_list%clear()
79 call assert( status==0,
"Problem allocating memory.", __file__, __line__ )
81 if ( gdd_reset_val_list%count == number_of_landuse_codes &
82 .and. gdd_reset_val_list%count_matching(
"<NA>") == 0 )
then
85 do indx=1, gdd_reset_val_list%count
86 sbuf = gdd_reset_val_list%get( indx )
88 where ( landuse_index == indx )
102 if ( ubound( gdd_max_l, 1 ) == number_of_landuse_codes &
103 .and. gdd_max_l(1) >
rtinyval )
then
105 do indx=1, ubound( landuse_index, 1)
106 if( landuse_index( indx ) >= lbound(
gdd_max, 1) .and. landuse_index( indx ) <= ubound(
gdd_max, 1) )
then
107 gdd_max( indx ) = gdd_max_l( landuse_index( indx ) )
118 if ( ubound( gdd_base_l, 1 ) == number_of_landuse_codes &
119 .and. gdd_base_l(1) >
rtinyval )
then
121 do indx=1, ubound( landuse_index, 1)
122 if( landuse_index( indx ) >= lbound(
gdd_base, 1) .and. landuse_index( indx ) <= ubound(
gdd_base, 1) )
then
123 gdd_base( indx ) = gdd_base_l( landuse_index( indx ) )
141 real (c_float),
intent(inout) :: gdd(:)
142 real (c_float),
intent(in) :: tmean(:)
143 real (c_float),
intent(in) :: tmin(:)
144 real (c_float),
intent(in) :: tmax(:)
145 integer (c_int),
intent(in) :: order(:)
148 real (c_float) :: tmax_l
153 integer (c_int) :: indx
155 do indx=lbound(order,1),ubound(order,1)
159 tmax_l = min( tmax(indx),
gdd_max( order(indx) ) )
161 if ( tmax_l <=
gdd_base( order(indx) ) )
then
165 elseif ( tmin(indx) >=
gdd_base( order(indx) ) )
then
171 w = ( tmax_l - tmin(indx)) / 2.0_c_float
173 at = (
gdd_base( order(indx) ) - tmean(indx) ) / w
175 if ( at > 1 ) at = 1.0_c_float
176 if ( at < -1 ) at = -1._c_float
180 dd = real(( ( w * cos( a ) ) - ( (
gdd_base( order(indx) ) - tmean(indx) ) &
181 * ( real(
pi / 2._c_double, c_float ) - a ) ) ) /
pi, c_float)
185 gdd(indx) = gdd(indx) + dd