Skip to content
Snippets Groups Projects
Commit b952cd38 authored by Marco Matthies's avatar Marco Matthies
Browse files

Deal with missing minsowdate or maxsowdate for crop

parent fc23eab9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment