KUL-RSDA / AquaCrop

FAO AquaCrop source code
https://www.fao.org/aquacrop/en/
Other
49 stars 15 forks source link

MaizeGDD.CRO causes a crash in cool environments when the simulation period is too short #336

Open mcguirepatr opened 9 months ago

mcguirepatr commented 9 months ago

With the standalone version on GitHub, at least with monthly driving data, if I only have a simulation run for less than the crop maturation time period, then it crashes with a seg fault. For example, with MaizeGDD or DryBeanGDD, if I try to simulate in a cool place (ave. temps near near 9 degrees C), then it can take 2 or more years to reach maturity. And if I only have a simulation go for 1 year, then it crashes because there isn't enough data in SIMUL/TCrop.

My temporary solution is to increase the simulation period.

How do I more elegantly set things up? Or is there a fix you can make? Patrick McGuire University of Reading & National Centre for Atmospheric Science (NCAS)

KUL-RSDA commented 9 months ago

It might be a convenient fix if the standalone adjusts the end date of the simulation and cropping period depending on the date when the GDD of the applied crop (in GDD mode) is reached. A related warning is already raised in the AquaCrop GUI in such a situation. For now (and this has always been the case in previous Pascal-based standalone versions, so version < v7.0) the standalone expects the end of the simulation and cropping period to be after the date when the GDD is reached. If this is not the case, the code crashes or gets stuck in an endless loop as you observed which, admittedly, is not nice. Note that I have written "it might be a convenient fix". There is one possible drawback of this automatic adjustment in case of multiple 'runs'. Due to the extended cropping period, the previous run might extend into the start date of the next run of the project file. The question is then whether the second run starting/ending dates should also be automatically shifted. Eventually the standalone may automatically adjust dates that the user does not want to be changed. In other words, the standalone currently assumes the dates in the project files to be correct. Your suggested temporally solution may be fine for your current application. There is nothing more elegant for now. We give this issue an 'enhancement label' that the AquaCrop team or the user community can pick it up and open a pull request in the future.

mcguirepatr commented 9 months ago

Yes, it would be nice to adjust the simulation and cropping period depending on the date when the GDD for the cropis reached.

However, in the possibly nearer-term, just having it not crash, and returning a warning/error message, and going on to the next simulation period (without any adjustments) would be even more useful. I set up MaizeGDD and DryBeanGDD to simulate for 565 days starting at Jan 1 of the years 1970, 1990, 2010, 2030, 2050, 2070, and 2090. The site is cool in the beginning (1970), causing it to have a MaizeGDD maturity period of 2000 days, or something like that, so it crashes. But the site warms up with RCP8.5 over the next 130 years, making it so MaizeGDD doesn't crash AquaCrop in the latter years. But it already crashed AquaCrop in 1970, so it doesn't reach the later decades.

mbechtold commented 9 months ago

Thanks Patrick. We discussed this. Agree that this makes sense to implement. However we cannot make it a priority right now and keep the issue open for later pick-up.