weathergenmod module¶
Description
This module includes subroutines to calculate daily maximum and minimum temperature and cloud cover fraction based on an annual timeseries of monthly values of these variables The weather generator is based on the WGEN model (Richardson, 1981) with extension to use monthly summary data from Geng et al., 1986, and Geng and Auburn 1986. Additional statistical relationships for both temperature, cloudiness and wind speed have been produced by P.S. Sommer and J.O. Kaplan using global weather station datasets (GHCN and global synoptic cloud reports).
Coded in 2007-2009 by Jed Kaplan and Joe Melton, ARVE Group, EPFL/UVic, jed.kaplan@unil.ch, 2011, Shawn Koppenhoefer, shawn.koppenhoefer@unil.ch 2016, Philipp Sommer, philipp.sommer@unil.ch
Quick access
Needed modules
randomdistmod
(randomstate()
): Random number generators and distributions moduleparametersmod
(sp()
,i4()
,dp()
): Simple module defining some types and parameters
Types
-
type
weathergenmod/
metvars_in
¶ Derived datatype for the monthly weather generator input
Type fields: %
cldf
[real]%
tmin
[real]%
tmax
[real]%
prec
[real]%
rndst
[randomstate]%
wetf
[real]%
resid
(4) [real]%
wetd
[real]%
pday
(2) [logical]%
wind
[real]
-
type
-
type
weathergenmod/
metvars_out
¶ Derived datatype for the daily weather generator output
Type fields: %
wind_sd
[real]%
tmin
[real]%
pday
(2) [logical]%
wind_mn
[real]%
wind_bias
[real]%
wind_intercept_bias
[real]%
cldf
[real]%
resid
(4) [real]%
tmin_sd
[real]%
tmax
[real]%
tmin_bias
[real]%
prec
[real]%
rndst
[randomstate]%
tmin_mn
[real]%
unorm
(4) [real]%
wind
[real]
-
type
-
type
weathergenmod/
daymetvars
¶ Derived datatype for monthly climate variables
Type fields: %
wind_sd
[real]%
cldf_sd
[real]%
tmax_sd
[real]%
tmin_sd
[real]%
cldf_mn
[real]%
wind_mn
[real]%
tmin_mn
[real]%
tmax_mn
[real]
-
type
Variables
-
weathergenmod/
tmax_sd_w1
[real]¶
-
-
weathergenmod/
tmax_sd_w2
[real]¶
-
-
weathergenmod/
tmax_sd_d1
[real]¶
-
-
weathergenmod/
tmax_sd_d2
[real]¶
-
-
weathergenmod/
cldf_w2
[real]¶
-
-
weathergenmod/
p101_2
[real]¶
-
-
weathergenmod/
p101_1
[real]¶
-
-
weathergenmod/
tmax_d1
[real]¶
-
-
weathergenmod/
tmax_w2
[real]¶
-
-
weathergenmod/
tmax_w1
[real]¶
-
-
weathergenmod/
cldf_d1
[real]¶
-
-
weathergenmod/
cldf_d3
[real]¶
-
-
weathergenmod/
cldf_d2
[real]¶
-
-
weathergenmod/
cldf_d4
[real]¶
-
-
weathergenmod/
wind_bias_max
[real]¶
-
-
weathergenmod/
wind_bias_coeffs
(6) [real]¶
-
-
weathergenmod/
wind_sd_w
(6) [real]¶
-
-
weathergenmod/
wind_bias_min
[real]¶
-
-
weathergenmod/
wind_sd_w1
[real]¶
-
-
weathergenmod/
wind_sd_w2
[real]¶
-
-
weathergenmod/
wind_slope_bias_x0
[real]¶
-
-
weathergenmod/
thresh
[real]¶
-
-
weathergenmod/
g_scale_coeff
[real]¶
-
-
weathergenmod/
p11_1
[real]¶
-
-
weathergenmod/
tmin_sd_w2
[real]¶
-
-
weathergenmod/
p001_1
[real]¶
-
-
weathergenmod/
tmin_sd_d2
[real]¶
-
-
weathergenmod/
tmin_sd_d1
[real]¶
-
-
weathergenmod/
wind_sd_d1
[real]¶
-
-
weathergenmod/
wind_sd_d2
[real]¶
-
-
weathergenmod/
thresh_pctl
[logical]¶
-
-
weathergenmod/
tmax_sd_breaks
(3) [real]¶
-
-
weathergenmod/
tmin_bias_max
[real]¶
-
-
weathergenmod/
tmin_w1
[real]¶
-
-
weathergenmod/
tmin_w2
[real]¶
-
-
weathergenmod/
p11_2
[real]¶
-
-
weathergenmod/
gp_shape
[real]¶
-
-
weathergenmod/
metvars_out
[public]
-
-
weathergenmod/
tmin_d1
[real]¶
-
-
weathergenmod/
tmin_d2
[real]¶
-
-
weathergenmod/
cldf_w4
[real]¶
-
-
weathergenmod/
wind_slope_bias_k
[real]¶
-
-
weathergenmod/
b
(4,4) [real]¶
-
-
weathergenmod/
cldf_w1
[real]¶
-
-
weathergenmod/
wind_slope_bias_l
[real]¶
-
-
weathergenmod/
cldf_w3
[real]¶
-
-
weathergenmod/
daymetvars
[private]
-
-
weathergenmod/
tmin_bias_min
[real]¶
-
-
weathergenmod/
tmin_sd_breaks
(3) [real]¶
-
-
weathergenmod/
tmin_sd_w
(4,6) [real]¶
-
-
weathergenmod/
cldf_w
[real]¶
-
-
weathergenmod/
wind_d2
[real]¶
-
-
weathergenmod/
p001_2
[real]¶
-
-
weathergenmod/
tmin_sd_d
(4,6) [real]¶
-
-
weathergenmod/
wind_d1
[real]¶
-
-
weathergenmod/
wind_w2
[real]¶
-
-
weathergenmod/
wind_w1
[real]¶
-
-
weathergenmod/
cldf_d
[real]¶
-
-
weathergenmod/
a
(4,4) [real]¶
-
-
weathergenmod/
wind_intercept_bias_coeffs
(6) [real]¶
-
-
weathergenmod/
tmax_sd_w
(4,6) [real]¶
-
-
weathergenmod/
wind_intercept_bias_b
[real]¶
-
-
weathergenmod/
wind_intercept_bias_a
[real]¶
-
-
weathergenmod/
tmin_bias_coeffs
(6) [real]¶
-
-
weathergenmod/
cldf_sd_d
[real]¶
-
-
weathergenmod/
tmax_sd_d
(4,6) [real]¶
-
-
weathergenmod/
tmin_sd_w1
[real]¶
-
-
weathergenmod/
metvars_in
[public]
-
-
weathergenmod/
wind_sd_d
(6) [real]¶
-
-
weathergenmod/
cldf_sd_w
[real]¶
-
-
weathergenmod/
tmax_d2
[real]¶
-
Subroutines and functions
-
subroutine
weathergenmod/
init_weathergen
([f_unit])¶ initialize the weather generator and read in the parameters from the namelist
Options: f_unit [integer,in,optional] Called from: gwgen
Call to: calc_cloud_params()
-
subroutine
weathergenmod/
weathergen
(met_in, met_out)¶ Parameters: - met_in [metvars_in,in]
- met_out [metvars_out,out]
Use : randomdistmod
(ran_gamma_gp()
,ran_gamma()
,ran_normal()
,ranur()
,gamma_cdf_inv()
,gamma_pdf()
,gamma_cdf()
),parametersmod
(tfreeze()
,sp()
,dp()
)Called from: Call to: ranur()
,gamma_cdf_inv()
,gamma_cdf()
,gamma_pdf()
,ran_gamma_gp()
,roundto()
,meansd()
,ran_normal()
-
subroutine
weathergenmod/
meansd
(pday, tmn, tmx, cld, wind, dm)¶ Adjust the monthly means of temperature, cloud and wind corresponding to the wet/dry state
This routine makes the first approximation inside the weather generator to adjust the monthly mean according to the wet/dry state using the best fit lines from the parameterization.
Min. and max. temperature, as well as the wind speed, are calculated via
\[x_{w/d} = x_{w/d1} + x_{w/d2} \cdot \bar{x}\]Where \(x\) stands either for the \(T_{min}, T_{max}, T_{min, sd}, T_{max, sd}, wind\) or \(wind_{sd}\). \(w/d\) stands for the wet dry state deterimined by pday.
The cloud fraction is calculated via
\[c_{w/d} = \frac{-a_{w/d} - 1}{a_{w/d}^2 * \bar{c} - a_{w/d}^2 - a_{w/d}} - \frac{1}{a_{w/d}}\]and it’s standard deviation via
\[c_{sd, w/d} = a_{sd, w/d}^2 \cdot c_{w/d} \cdot (1 - c_{w/d})\]Parameters: - pday [logical,in] :: precipitation status (mm/day)
- tmn [real,in] :: smooth interpolation of monthly minimum temperature (degC)
- tmx [real,in] :: smooth interpolation of monthly maximum temperature (degC)
- cld [real,in] :: fraction (0-1)
- wind [real,in] :: wind speed (m/s)
- dm [daymetvars,out] :: the
daymetvars
for the first daily approximation
Called from: Call to:
-
subroutine
weathergenmod/
rmsmooth
(m, dmonth, bcond, r)¶ Iterative, mean preserving method to smoothly interpolate mean data to pseudo-sub-timestep values From Rymes, M.D. and D.R. Myers, 2001. Solar Energy (71) 4, 225-231
Parameters: - m (*) [real,in] :: vector of mean values at super-time step (e.g., monthly), minimum three values
- dmonth (*) [integer,in] :: vector of number of intervals for the time step (e.g., days per month)
- bcond (2) [real,in] :: boundary conditions for the result vector (1=left side, 2=right side)
- r (*) [real,out] :: result vector of values at chosen time step
Use : Called from:
-
function
weathergenmod/
roundto
(val, precision)¶ round a value to the given precision
Parameters: - val [real,in] :: the input value
- precision [integer,in] :: the precision
Return: roundto [real]
Called from:
-
subroutine
weathergenmod/
calc_cloud_params
()¶ Calculate the parameters used for the first approximation in
meansd()
This subroutine uses
cldf_w
,cldf_d
,cldf_sd_w
andcldf_sd_d
to calculate the necessary parameters for the adjustment of the monthly cloud fraction mean depending on the wet/dry stateCalled from: init_weathergen()
-
subroutine
weathergenmod/
temp_sd
(pday, dm)¶ Parameters: - pday [logical,in] :: precipitation status (mm/day)
- dm [daymetvars,inout]
Called from: