From dca1fd7622f93af4d2292412cfd268cbddbecdfe Mon Sep 17 00:00:00 2001 From: hol430 Date: Fri, 3 May 2019 09:56:46 +1000 Subject: [PATCH] Guard clause for sorghum code. --- Models/Plant/Organs/Root.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Models/Plant/Organs/Root.cs b/Models/Plant/Organs/Root.cs index 7aa061807c..59f394b9eb 100644 --- a/Models/Plant/Organs/Root.cs +++ b/Models/Plant/Organs/Root.cs @@ -1110,7 +1110,7 @@ public double PlantAvailableWaterSupply() double[] supply = new double[PlantZone.soil.Thickness.Length]; var currentLayer = Soil.LayerIndexOfDepth(Depth, PlantZone.soil.Thickness); - var layertop = MathUtilities.Sum(PlantZone.soil.Thickness, 0, currentLayer-1); + var layertop = MathUtilities.Sum(PlantZone.soil.Thickness, 0, Math.Max(0, currentLayer - 1)); var layerBottom = MathUtilities.Sum(PlantZone.soil.Thickness, 0, currentLayer); var layerProportion = Math.Min(MathUtilities.Divide(Depth - layertop, layerBottom - layertop, 0.0), 1.0);