Skip to content

Commit

Permalink
Merge pull request #245 from DrylandEcology/revert-242-Bugfix_231_Div…
Browse files Browse the repository at this point in the history
…ision_By_Zero

Revert "Divide by zero bug fix, issue #231"
  • Loading branch information
dschlaep committed Apr 26, 2019
2 parents 7f9e519 + d043414 commit b76e85e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions SW_SoilWater.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,13 +984,12 @@ RealD SW_SWCbulk2SWPmatric(RealD fractionGravel, RealD swcBulk, LyrIndex n) {
theta1 = 0.0;
else
theta1 = (swcBulk / lyr->width) * 100. / (1. - fractionGravel);
if (GT(BARCONV, 0.0))
swp = lyr->psisMatric / powe(theta1/lyr->thetasMatric, lyr->bMatric) / BARCONV;
else
LogError(logfp, LOGFATAL, "Attempt to divide by 0, SWP value may not be accurate.");
} else
swp = lyr->psisMatric / powe(theta1/lyr->thetasMatric, lyr->bMatric) / BARCONV;
} else {
LogError(logfp, LOGFATAL, "Invalid SWC value (%.4f) in SW_SWC_swc2potential.\n"
" Year = %d, DOY=%d, Layer = %d\n", swcBulk, SW_Model.year, SW_Model.doy, n);
}

return swp;
}

Expand Down

0 comments on commit b76e85e

Please sign in to comment.