Skip to content

Commit

Permalink
Fix covariance value checks in Markov weather generator
Browse files Browse the repository at this point in the history
- close #224
- address DrylandEcology/rSFSTEP2#32

- function `SW_MKV_read_cov` was enforcing that covariance values >= 0 since commit 7fbdf6e which is wrong because covariance can take any real value.
-> Fixed by checking that covariance values are finite (real) numbers.
  • Loading branch information
dschlaep committed Aug 15, 2018
1 parent d7cb02d commit 879d4b6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions SW_Markov.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,11 @@ Bool SW_MKV_read_cov(void) {
t1, t2, lineno, MyFileName);
}

// Covariance values >= 0
if (!isfinite(t3) || !isfinite(t4) || !isfinite(t5) || !isfinite(t6) ||
LT(t3, 0.) || LT(t4, 0.) || LT(t5, 0.) || LT(t6, 0.))
// Covariance values are finite
if (!isfinite(t3) || !isfinite(t4) || !isfinite(t5) || !isfinite(t6))
{
msg_type = LOGFATAL;
sprintf(msg, "One of the covariance values is out of range "\
sprintf(msg, "One of the covariance values is not a real number "\
"(t3 = %f; t4 = %f; t5 = %f; t6 = %f) in line %d of file %s\n",
t3, t4, t5, t6, lineno, MyFileName);
}
Expand Down

0 comments on commit 879d4b6

Please sign in to comment.