TillF / WASA-SED

WASA-SED is a numerical model for simulation hydrological and sediment fluxes from meso-scale catchments (Mueller et al., 2010). This repository contains documentation, sample data set and source code.
Other
14 stars 10 forks source link

Floating point exception during runtime if compiled with DEBUG=1 #53

Closed tpilz closed 6 years ago

tpilz commented 6 years ago

When running WASA in debug mode (compiled with make DEBUG=1 all), a floating point exception occurs:

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

Backtrace for this error:
#0  0x7FAE52938E08
#1  0x7FAE52937F90
#2  0x7FAE520694AF
#3  0x7FAE52646CD4
#4  0x7FAE5264BC04
#5  0x5C938F in reservoir_ at reservoir.f90:535 (discriminator 16)
#6  0x65D819 in routing_ at routing.f90:199
#7  0x678467 in MAIN__ at wasa.f90:31 (discriminator 1)

This is caused by a problem in file reservoir.f90 when trying to estimate parameters for the spillway rating curve. When using the old default parameters from file reservoir.dat, parameter 'damb' is always greater zero which causes 'alpha_over' being a negative fractional number causing a fpe during calculation of 'k_over'. This problem only becomes obvious when compiling with DEBUG flags but yet it is always present, potentially causing erroneous calculation of spillway outflow from reservoirs.

One would have to check when this rating curve was introduced and whether this is a problem of parameterisation or wrong implementation of a formula.

tpilz commented 6 years ago

... this was a parameterisation problem. Added some range checks for parameters in reservoir.dat, commit 28aea09