From ffe37c3310c7ad4d8f0e220130966830f46a6995 Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Mon, 7 Oct 2024 10:28:16 +0200 Subject: [PATCH] Check that sowdates dictionary really contains an entry for the farm --- src/farm/farm.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/farm/farm.jl b/src/farm/farm.jl index 3bc3109..ec25c23 100644 --- a/src/farm/farm.jl +++ b/src/farm/farm.jl @@ -70,9 +70,15 @@ function stepagent!(farmer::BasicFarmer, model::SimulationModel) @warn "minsowdate and/or maxsowdate is `missing` for crop \"$(ctype.name)\", not assigning sowdates" end end - elseif cropname(field) == "no growth" && model.date == farmer.sowdates[f] - # if a field has been harvested, check if the next crop can be sown - @sow(farmer.croprotations[f][1]) + elseif cropname(field) == "no growth" + if haskey(farmer.sowdates, f) + if model.date == farmer.sowdates[f] + # if a field has been harvested, check if the next crop can be sown + @sow(farmer.croprotations[f][1]) + end + else + @warn "farmer sowdates is empty, farmer = $farmer" + end end end end -- GitLab