Opened 2 years ago

Last modified 14 months ago

#550 new defect

stomate_cforcing wrong timestep calculation (gregorian calendar)

Reported by: ajornet Owned by: somebody
Priority: major Milestone: Not scheduled yet
Component: Biogeochemical processes Version: trunc
Keywords: days_since_beg one_year gegorian Cc:

Description

The calculation of the timestep (iatt) for the stomate_Cforcing file is sometimes not correct when using the gregorian calendar.

In stomate.f90:

! ::nbyear Number of years saved for carbon spinup
sf_time = MODULO(REAL(days_since_beg,r_std)-1,one_year*REAL(nbyear,r_std))
iatt=FLOOR(sf_time/dt_forcesoil) + 1

days_since_beg is a variable that counts the total number of days ran in an experiment. The value is passed throughout the stomate_restart files. So it accumulates the days between multiple simulations.

Given the example:
From 1979 to 2048 (also included) there are 25568 days (gregorian!). The very last day of 2048 (leap) is calculated as:

sf_time = MODULO((25568 - 1) , (365.2425 * 1)) = int(0.02499) = 0
iatt=floor(0/dt_forcesoil) + 1 = 0 + 1 = 1 -> timestep

Data will be placed at the 1st timestep of the output stomate_Cforcing.nc file. That's not correct, it should be placed at the very last time step. Afterwards, it will reinitialize value to zero for the data to place in the stomate_Cforcing file:

IF ((iatt<iatt_old) .and. (.not. cumul_Cforcing)) THEN
   nforce(:)=0
   soilcarbon_input(:,:,:,:) = zero
   control_moist(:,:,:) = zero

So forcesoil won't properly work due to zero's timesteps.

I attach a couple of Python scripts to simulate days_since_beg across multiple years. It also calculates the timestep at the end of the year when FORCESOIL_STEP_PER_YEAR=12. Check below the output:

current year, leap, days since beg= 1979 False 365
ite years, leftover days, timestep= 0 364 12.0
...
...
...
current year, leap, days since beg= 2046 False 24837
ite years, leftover days, timestep= 67 364 12.0

current year, leap, days since beg= 2047 False 25202
ite years, leftover days, timestep= 68 364 12.0

current year, leap, days since beg= 2048 True 25568
ite years, leftover days, timestep= 70 0 1.0 ---> wrong timestep

The method to calculate the current day of the year is not sufficient when using a Gregorian calendar.

Attachments (2)

findiattbug.py (1.6 KB) - added by ajornet 2 years ago.
moredates.py (580 bytes) - added by ajornet 2 years ago.

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by ajornet

Changed 2 years ago by ajornet

comment:2 Changed 14 months ago by luyssaert

  • Milestone changed from ORCHIDEE 4.0 to Not scheduled yet
Note: See TracTickets for help on using tickets.