PSUmodeling / Cycles

Cycles agroecosystem model
https://psumodeling.github.io/Cycles/
Other
11 stars 0 forks source link

Possible issue with leap year #9

Closed aramcharan closed 9 years ago

aramcharan commented 9 years ago

Comparing thermal time accumulation, it appears that maize gets harvested one day earlier than it should. The weather file I'm using has no leap years. Will email relevant files.

shiyuning commented 9 years ago

I saw the output. I don't think the crop is harvested earlier than it should. The difference in thermal time accumulation is caused by the handling of output in the C version. In the C version, the daily outputs are printed at the end of day, after the daily cycle and operations. So on the day of crop harvest, the thermal time is 0 because at the end of day there is no crop left. So we should fix this to output before the crop is killed?

shiyuning commented 9 years ago

This is not a bug. This is caused by different "margins" used in VB and C to calculate forced harvest. In Amanda's VB version, the margin is 9 days while in C it's 10 days. Therefore, the crop is always harvested one day earlier in C than in VB. To change the margin, go to DailyOperation.c and find the ForcedMaturity function. The variable "margin" is defined in there (it is set as 9 now).