diff --git a/src/farm/farm.jl b/src/farm/farm.jl index 3bc3109e4efc086672a26681f147c3deb78065ce..ec25c23f5b0913af8271c97854f55da123f61a19 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