Gerrit de Rooij's public domain codes

All codes below are in Fortran, and developed by me for use in my own research. The comments in the source codes identify any algorithms or ideas adopted from the literature and give full references to the relevant papers and websites. Unless stated otherwise, I did not use code from others so the copyright rests solely with UFZ.

When you use any of the material on this website, please acknowledge me as the author of the material.

Rainfall generator

From rain cells to a rainshower

Main features

This Fortran 95 program simulates rainfall according to one of several Bartlett-Lewis-type models described in Pham et al. (2013). Of these, the most basic is left out. The others are the model described by Rodriguez-Iturbe et al. (1988) or modifications thereof. One of these modifications is Onof et al.'s (2013) suggestion to truncate the gamma-distribution of eta (see below). Another is to replace the exponential distribution of the rainfall rate in a rainfall cell by a gamma distribution. This leads to four model configurations (abbreviations according to Pham et al., 2013):

1) MBL: Bartlett-Lewis with the parameters characterizing a storm (pdf of storm duration and pdf of cell arrival times) related to a gamma-distributed parameter eta. The rainfall rate in a rain cell has an exponential distribution. This is the Modified Bartlett-Lewis model, introduced by Rodriguez-Iturbe et al. (1988).

2) TBL: As MBL, but with a truncated gamma distribution for eta (Truncated Bartlett-Lewis).

3) MBLG: As MBL, but with the rainfall rate per cell having a gamma distribution.

4) TBLG: As TBL, but with the rainfall rate per cell having a gamma distribution.

Leap years are automatically taken into consideration. The code assumes that the first day of the period for which the rainfall record is to be generated is January 1st of a year immediately following a leap year. This feature simplifies the generation of rainfall records spanning multiple decades or even centuries.

For very long rainfall series using the untruncated gamma distribution can lead to physically unrealistic rainfall amounts because for small values of eta, the moments of the gamma distribution are unbounded for values of alpha < 4 (Onof et al., 2103). Excessively small values of eta can be avoided by simply not permitting values below a threshold epsilon, which is the rationale for TBL and TBLG. Pham et al. (2013) found that MBL outperformed the other models, but still TBL might be a good choice. For that reason, MBL and MBLG are not explicitly included in the input. To run an MBL- or MBLG-type model, the parameter lower_eta, which gives the lower threshold for eta, needs to be set to zero in the input file for each period for which the parameters are given.

The code requires the model parameters for arbitrary periods of time in which a year is subdivided (usually for each month). Storms are generated for a given period until the starting time of a storm is beyond that period. This starting time is not discarded, but it serves as the starting time of the first storm in the period in which it occurs. The parameters of that storm are generated using the pdfs for the period in which it occurs, not the period in which it was generated. Subsequent storms are generated using the parameters of that period. Rain cells in a storm are generated until a rain cell has a starting time that exceeds the time at which the storm ends. This latest cell is discarded. Rain cells may overlap, creating irregular rainfall rates over time.

The resulting rainfall from individual cells is used to create a time line of rainfall rates (including zero, for dry spells) that gives a continuous record of the rainfall rate as a function of time. This record is processed to provide hourly sums and daily sums. All three records are written to output files.

See the power point slides for example input files and more background. The Fortran file is here, and its executable here.


Kim, D., F. Olivera, H. Cho, and S.A. Socolofsky. 2013. Regionalization of the modified Bartlett-Lewis rectangular pulse stochastic rainfall model. Terr. Atmos. Ocean. Sci. 24:421-436. Doi:10.3319/TAO.2012.11.12.01(Hy).

Onof, C., R.E. Chandler, A. Kakou, P. Northrop, H.S. Wheater, and V. Isham. 2000. Rainfall modelling using Poisson-cluster processes: a review of developments. Stochastic Environmental Research and Risk Assessment 14:384-411.

Onof, C., W.J. Vanhaute, T. Meca-Figueras, J. Kaczmarska, R. Chandler, L. Hege, S. Vanderberghe, P. Willems, and N.E.C. Verhoest. 2013. A truncated random parameter version of the Bartlett-Lewis model. Unpublished communication.

Pham, M.T., W.J. Vanhaute, S. Vanderberghe, B. De Baets, and N.E.C. Verhoest. 2013. An assessment of the ability of Bartlett-Lewis type of rainfall models to reproduce drought statistics. Hydrol. Earth Syst. Sci. 17:5167-5183. Doi:10.5194/hess-17-5167-2013.

Rodriguez-Iturbe, I., D.R. Cox, and V. Isham. 1988. A point process model for rainfall: further developments. Proc. R. Soc. Lond. A 417:283-298.

Xi, B., K.M. Tan, and C. Liu. 2013. Logarithmic transformation-based gamma random number generators. J. Statistical Software 55 (4):1-17.


The source codes and executables can be freely downloaded and used, at the risk of the user. By downloading and/or using any material that directly or indirectly stems from this website, you agree not to hold UFZ or me responsible or liable for any damages or consequences resulting from any use of the material by any party, regardless the way any party gained access to the material. Neither UFZ nor I guarantee that the codes are free of bugs and/or errors, even though the codes were tested and used.