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

Types:daymetvars, metvars_out, metvars_in
Variables:daymetvars, metvars_in, metvars_out, cldf_d1, cldf_d2, cldf_d3, cldf_d4, cldf_w1, cldf_w2, cldf_w3, cldf_w4, thresh_pctl, tmin_d1, tmax_w1, cldf_w, wind_intercept_bias_b, tmin_bias_min, wind_bias_min, tmax_sd_d1, tmax_sd_d2, tmax_sd_w1, tmax_sd_w2, tmin_sd_d1, tmin_sd_d2, tmin_sd_w1, tmin_sd_w2, wind_sd_d1, wind_sd_d2, wind_sd_w1, wind_sd_w2, wind_slope_bias_k, wind_slope_bias_l, wind_slope_bias_x0, p001_1, p101_1, wind_d1, wind_w1, p11_1, tmax_d1, cldf_d, p001_2, p11_2, p101_2, wind_d2, tmax_w2, tmin_w2, cldf_sd_w, tmax_d2, tmin_d2, cldf_sd_d, wind_w2, wind_intercept_bias_a, tmin_w1, g_scale_coeff, gp_shape, tmin_bias_max, wind_bias_max, thresh, tmax_sd_breaks, tmin_sd_breaks, wind_sd_w, wind_sd_d, wind_bias_coeffs, tmin_bias_coeffs, wind_intercept_bias_coeffs, b, a, tmin_sd_d, tmax_sd_w, tmax_sd_d, tmin_sd_w
Routines:calc_cloud_params(), init_weathergen(), temp_sd(), meansd(), rmsmooth(), weathergen(), roundto()

Needed modules

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 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 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]

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:
Use :

randomdistmod (ran_gamma_gp(), ran_gamma(), ran_normal(), ranur(), gamma_cdf_inv(), gamma_pdf(), gamma_cdf()), parametersmod (tfreeze(), sp(), dp())

Called from:

gwgen

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:

weathergen()

Call to:

temp_sd()

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 :

parametersmod (sp())

Called from:

gwgen

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:

weathergen()

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 and cldf_sd_d to calculate the necessary parameters for the adjustment of the monthly cloud fraction mean depending on the wet/dry state

Called from:init_weathergen()
subroutine weathergenmod/temp_sd(pday, dm)
Parameters:
  • pday [logical,in] :: precipitation status (mm/day)
  • dm [daymetvars,inout]
Called from:

meansd()