diff --git a/src/farm/farm.jl b/src/farm/farm.jl index 5d024dd08696cf9b5280d26b788ef3b7ce99d084..3bc3109e4efc086672a26681f147c3deb78065ce 100644 --- a/src/farm/farm.jl +++ b/src/farm/farm.jl @@ -64,7 +64,11 @@ function stepagent!(farmer::BasicFarmer, model::SimulationModel) @sow("no growth") cycle!(farmer.croprotations[f]) # advance the crop rotation nextcrop = model.crops[farmer.croprotations[f][1]] - farmer.sowdates[f] = @rand(nextcrop.minsowdate:nextcrop.maxsowdate) + if ! (ismissing(nextcrop.minsowdate) || ismissing(nextcrop.maxsowdate)) + farmer.sowdates[f] = @rand(nextcrop.minsowdate:nextcrop.maxsowdate) + else + @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