Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_curr_yearfrac and get_prev_yearfrac with Gregorian calendar #1593

Merged
merged 8 commits into from
Jan 25, 2022
10 changes: 10 additions & 0 deletions cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,16 @@
<option name="tput_tolerance">0.5</option>
</options>
</test>
<test name="SMS_Ly5_Mmpi-serial" grid="1x1_smallvilleIA" compset="IHistClm50BgcCropQianRs" testmods="clm/gregorian_cropMonthOutput">
<machines>
<machine name="cheyenne" compiler="gnu" category="aux_clm"/>
</machines>
<options>
<option name="wallclock">01:00:00</option>
<option name="comment" >Multi-year Gregorian test with transient and crop to test code that might break in leap years.</option>
<option name="tput_tolerance">0.5</option>
</options>
</test>
<test name="LII_D_Ld3" grid="f19_g17" compset="I2000Clm50BgcCrop" testmods="clm/default">
<machines>
<machine name="cheyenne" compiler="intel" category="aux_clm"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../cropMonthOutput
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./xmlchange CALENDAR=GREGORIAN
4 changes: 2 additions & 2 deletions src/biogeochem/CNAnnualUpdateMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ subroutine CNAnnualUpdate(bounds, num_soilc, filter_soilc, num_soilp, filter_soi
! On the radiation time step, update annual summation variables
!
! !USES:
use clm_time_manager, only: get_step_size_real, get_days_per_year
use clm_time_manager, only: get_step_size_real, get_curr_days_per_year
use clm_varcon , only: secspday
use SubgridAveMod , only: p2c
!
Expand All @@ -51,7 +51,7 @@ subroutine CNAnnualUpdate(bounds, num_soilc, filter_soilc, num_soilp, filter_soi
!-----------------------------------------------------------------------

dt = get_step_size_real()
secspyear = get_days_per_year() * secspday
secspyear = get_curr_days_per_year() * secspday

do fc = 1,num_soilc
c = filter_soilc(fc)
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/CNC14DecayMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module CNC14DecayMod
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
use clm_time_manager , only : get_step_size_real, get_days_per_year
use clm_time_manager , only : get_step_size_real, get_curr_days_per_year
use clm_varpar , only : nlevdecomp, ndecomp_pools
use clm_varcon , only : secspday
use clm_varctl , only : spinup_state
Expand Down Expand Up @@ -87,7 +87,7 @@ subroutine C14Decay( bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &

! set time steps
dt = get_step_size_real()
days_per_year = get_days_per_year()
days_per_year = get_curr_days_per_year()

half_life = 5730._r8 * secspday * days_per_year
decay_const = - log(0.5_r8) / half_life
Expand Down
2 changes: 1 addition & 1 deletion src/biogeochem/CNCIsoAtmTimeSeriesReadMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module CIsoAtmTimeseriesMod
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
use clm_time_manager , only : get_curr_date,get_days_per_year, get_curr_yearfrac
use clm_time_manager , only : get_curr_date, get_curr_yearfrac
use clm_varcon , only : c14ratio, secspday
use shr_const_mod , only : SHR_CONST_PDB ! Ratio of C13/C12
use clm_varctl , only : iulog
Expand Down
6 changes: 3 additions & 3 deletions src/biogeochem/CNFUNMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ subroutine CNFUNInit (bounds,cnveg_state_inst,cnveg_carbonstate_inst,cnveg_nitro
!
! !USES:
use clm_varcon , only: secspday, fun_period
use clm_time_manager, only: get_step_size_real,get_nstep,get_curr_date,get_days_per_year
use clm_time_manager, only: get_step_size_real,get_nstep,get_curr_date,get_curr_days_per_year
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
Expand Down Expand Up @@ -166,7 +166,7 @@ subroutine CNFUNInit (bounds,cnveg_state_inst,cnveg_carbonstate_inst,cnveg_nitro
!---
! set time steps
dt = get_step_size_real()
dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
nstep = get_nstep()
timestep_fun = real(secspday * fun_period)
nstep_fun = int(secspday * dayspyr / dt)
Expand Down Expand Up @@ -210,7 +210,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp&
& soilbiogeochem_nitrogenstate_inst)

! !USES:
use clm_time_manager, only : get_step_size_real, get_curr_date, get_days_per_year
use clm_time_manager, only : get_step_size_real, get_curr_date
use clm_varpar , only : nlevdecomp
use clm_varcon , only : secspday, smallValue, fun_period, tfrz, dzsoi_decomp, spval
use clm_varctl , only : use_nitrif_denitrif
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/CNFireBaseMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte
! seconds_per_year is the number of seconds in a year.
!
! !USES:
use clm_time_manager , only: get_step_size_real,get_days_per_year,get_curr_date
use clm_time_manager , only: get_step_size_real,get_curr_days_per_year,get_curr_date
use clm_varctl , only: use_cndv
use clm_varcon , only: secspday
use pftconMod , only: nc3crop
Expand Down Expand Up @@ -683,7 +683,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte
! calculate burned area fraction per sec
dt = get_step_size_real()

dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
!
! patch loop
!
Expand Down
8 changes: 4 additions & 4 deletions src/biogeochem/CNFireLi2014Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
! Computes column-level burned area
!
! !USES:
use clm_time_manager , only: get_step_size_real, get_days_per_year, get_curr_date, get_nstep
use clm_time_manager , only: get_step_size_real, get_curr_days_per_year, get_curr_date, get_nstep
use clm_varcon , only: secspday, secsphr
use pftconMod , only: nc4_grass, nc3crop, ndllf_evr_tmp_tree
use pftconMod , only: nbrdlf_evr_trp_tree, nbrdlf_dcd_trp_tree, nbrdlf_evr_shrub
Expand Down Expand Up @@ -247,7 +247,7 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
leafc_col(bounds%begc:bounds%endc))

call get_curr_date (kyr, kmo, kda, mcsec)
dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
! Get model step size
dt = get_step_size_real()
!
Expand Down Expand Up @@ -646,7 +646,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte
! seconds_per_year is the number of seconds in a year.
!
! !USES:
use clm_time_manager , only: get_step_size_real,get_days_per_year,get_curr_date
use clm_time_manager , only: get_step_size_real,get_curr_days_per_year,get_curr_date
use clm_varctl , only: use_cndv
use clm_varcon , only: secspday
use clm_varpar , only: i_met_lit, i_litr_max
Expand Down Expand Up @@ -886,7 +886,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte
! calculate burned area fraction per sec
dt = get_step_size_real()

dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
!
! patch loop
!
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/CNFireLi2016Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
! Computes column-level burned area
!
! !USES:
use clm_time_manager , only: get_step_size_real, get_days_per_year, get_curr_date, get_nstep
use clm_time_manager , only: get_step_size_real, get_curr_days_per_year, get_curr_date, get_nstep
use clm_varcon , only: secspday, secsphr
use clm_varctl , only: spinup_state
use pftconMod , only: nc4_grass, nc3crop, ndllf_evr_tmp_tree
Expand Down Expand Up @@ -268,7 +268,7 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
deadstemc_col(bounds%begc:bounds%endc))

call get_curr_date (kyr, kmo, kda, mcsec)
dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
! Get model step size
dt = get_step_size_real()
!
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/CNFireLi2021Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
! Computes column-level burned area
!
! !USES:
use clm_time_manager , only: get_step_size_real, get_days_per_year, get_curr_date, get_nstep
use clm_time_manager , only: get_step_size_real, get_curr_days_per_year, get_curr_date, get_nstep
use clm_varcon , only: secspday, secsphr
use clm_varctl , only: spinup_state
use pftconMod , only: nc4_grass, nc3crop, ndllf_evr_tmp_tree
Expand Down Expand Up @@ -267,7 +267,7 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_
deadstemc_col(bounds%begc:bounds%endc))

call get_curr_date (kyr, kmo, kda, mcsec)
dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
! Get model step size
dt = get_step_size_real()
!
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/CNGapMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ subroutine CNGapMortality (bounds, num_soilc, filter_soilc, num_soilp, filter_so
! Gap-phase mortality routine for coupled carbon-nitrogen code (CN)
!
! !USES:
use clm_time_manager , only: get_days_per_year
use clm_time_manager , only: get_curr_days_per_year
use clm_varpar , only: nlevdecomp_full
use clm_varcon , only: secspday
use clm_varctl , only: use_cndv, spinup_state
Expand Down Expand Up @@ -180,7 +180,7 @@ subroutine CNGapMortality (bounds, num_soilc, filter_soilc, num_soilp, filter_so

end if

m = am/(get_days_per_year() * secspday)
m = am/(get_curr_days_per_year() * secspday)

!------------------------------------------------------
! patch-level gap mortality carbon fluxes
Expand Down
8 changes: 4 additions & 4 deletions src/biogeochem/CNNDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ subroutine CNFreeLivingFixation(num_soilc, filter_soilc, &
waterfluxbulk_inst, soilbiogeochem_nitrogenflux_inst)


use clm_time_manager , only : get_days_per_year
use clm_time_manager , only : get_curr_days_per_year
use shr_sys_mod , only : shr_sys_flush
use clm_varcon , only : secspday, spval

Expand All @@ -178,7 +178,7 @@ subroutine CNFreeLivingFixation(num_soilc, filter_soilc, &
ffix_to_sminn => soilbiogeochem_nitrogenflux_inst%ffix_to_sminn_col & ! Output: [real(:) ] : free living N fixation to soil mineral N (gN/m2/s)
)

dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
secs_per_year = dayspyr*24_r8*3600_r8

do fc = 1,num_soilc
Expand All @@ -200,7 +200,7 @@ subroutine CNNFixation(num_soilc, filter_soilc, &
! All N fixation goes to the soil mineral N pool.
!
! !USES:
use clm_time_manager , only : get_days_per_year
use clm_time_manager , only : get_curr_days_per_year
use shr_sys_mod , only : shr_sys_flush
use clm_varcon , only : secspday, spval
use CNSharedParamsMod , only: use_fun
Expand All @@ -224,7 +224,7 @@ subroutine CNNFixation(num_soilc, filter_soilc, &
nfix_to_sminn => soilbiogeochem_nitrogenflux_inst%nfix_to_sminn_col & ! Output: [real(r8) (:)] symbiotic/asymbiotic N fixation to soil mineral N (gN/m2/s)
)

dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()

if ( nfix_timeconst > 0._r8 .and. nfix_timeconst < 500._r8 ) then
! use exponential relaxation with time constant nfix_timeconst for NPP - NFIX relation
Expand Down
16 changes: 8 additions & 8 deletions src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ subroutine CNPhenologyClimate (num_soilp, filter_soilp, num_pcropp, filter_pcrop
! For coupled carbon-nitrogen code (CN).
!
! !USES:
use clm_time_manager , only : get_days_per_year
use clm_time_manager , only : get_curr_days_per_year
use clm_time_manager , only : get_curr_date, is_first_step
!
! !ARGUMENTS:
Expand Down Expand Up @@ -537,7 +537,7 @@ subroutine CNPhenologyClimate (num_soilp, filter_soilp, num_pcropp, filter_pcrop

! set time steps

dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()

do fp = 1,num_soilp
p = filter_soilp(fp)
Expand Down Expand Up @@ -589,7 +589,7 @@ subroutine CNEvergreenPhenology (num_soilp, filter_soilp , &
!
! !USES:
use clm_varcon , only : secspday
use clm_time_manager , only : get_days_per_year
use clm_time_manager , only : get_curr_days_per_year
use clm_varctl , only : CN_evergreen_phenology_opt
!
! !ARGUMENTS:
Expand Down Expand Up @@ -677,7 +677,7 @@ subroutine CNEvergreenPhenology (num_soilp, filter_soilp , &
lgsf => cnveg_state_inst%lgsf_patch & ! Output: [real(r8) (:) ] long growing season factor [0-1]
)

dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()

do fp = 1,num_soilp
p = filter_soilp(fp)
Expand Down Expand Up @@ -1204,7 +1204,7 @@ subroutine CNStressDecidPhenology (num_soilp, filter_soilp , &
! per year.
!
! !USES:
use clm_time_manager , only : get_days_per_year
use clm_time_manager , only : get_curr_days_per_year
use CNSharedParamsMod, only : use_fun
use clm_varcon , only : secspday
use shr_const_mod , only : SHR_CONST_TKFRZ, SHR_CONST_PI
Expand Down Expand Up @@ -1323,7 +1323,7 @@ subroutine CNStressDecidPhenology (num_soilp, filter_soilp , &
)

! set time steps
dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()

! specify rain threshold for leaf onset
rain_threshold = 20._r8
Expand Down Expand Up @@ -1644,7 +1644,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , &
! handle CN fluxes during the phenological onset & offset periods.

! !USES:
use clm_time_manager , only : get_curr_date, get_curr_calday, get_days_per_year, get_rad_step_size
use clm_time_manager , only : get_curr_date, get_curr_calday, get_curr_days_per_year, get_rad_step_size
use pftconMod , only : ntmp_corn, nswheat, nwwheat, ntmp_soybean
use pftconMod , only : nirrig_tmp_corn, nirrig_swheat, nirrig_wwheat, nirrig_tmp_soybean
use pftconMod , only : ntrp_corn, nsugarcane, ntrp_soybean, ncotton, nrice
Expand Down Expand Up @@ -1749,7 +1749,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , &
)

! get time info
dayspyr = get_days_per_year()
dayspyr = get_curr_days_per_year()
jday = get_curr_calday()
call get_curr_date(kyr, kmo, kda, mcsec)
dtrad = real( get_rad_step_size(), r8 )
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/ch4Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4261,7 +4261,7 @@ subroutine ch4_annualupdate(bounds, num_methc, filter_methc, num_methp, filter_m
! !DESCRIPTION: Annual mean fields.
!
! !USES:
use clm_time_manager, only: get_step_size_real, get_days_per_year, get_nstep
use clm_time_manager, only: get_step_size_real, get_curr_days_per_year, get_nstep
use clm_varcon , only: secspday
!
! !ARGUMENTS:
Expand Down Expand Up @@ -4303,7 +4303,7 @@ subroutine ch4_annualupdate(bounds, num_methc, filter_methc, num_methp, filter_m

! set time steps
dt = get_step_size_real()
secsperyear = real( get_days_per_year() * secspday, r8)
secsperyear = real( get_curr_days_per_year() * secspday, r8)

do fc = 1,num_methc
c = filter_methc(fc)
Expand Down
4 changes: 2 additions & 2 deletions src/cpl/lilac/lnd_comp_esmf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ subroutine lnd_run(gcomp, import_state, export_state, clock, rc)
! Determine calendar day info
!--------------------------------

calday = get_curr_calday()
caldayp1 = get_curr_calday(offset=dtime)
calday = get_curr_calday(reuse_day_365_for_day_366=.true.)
caldayp1 = get_curr_calday(offset=dtime, reuse_day_365_for_day_366=.true.)

!--------------------------------
! Get time of next atmospheric shortwave calculation
Expand Down
4 changes: 2 additions & 2 deletions src/cpl/mct/lnd_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ subroutine lnd_run_mct(EClock, cdata_l, x2l_l, l2x_l)
! Determine doalb based on nextsw_cday sent from atm model

nstep = get_nstep()
caldayp1 = get_curr_calday(offset=dtime)
caldayp1 = get_curr_calday(offset=dtime, reuse_day_365_for_day_366=.true.)
if (nstep == 0) then
doalb = .false.
else if (nstep == 1) then
Expand All @@ -444,7 +444,7 @@ subroutine lnd_run_mct(EClock, cdata_l, x2l_l, l2x_l)
call t_barrierf('sync_clm_run1', mpicom)
call t_startf ('clm_run')
call t_startf ('shr_orb_decl')
calday = get_curr_calday()
calday = get_curr_calday(reuse_day_365_for_day_366=.true.)
call shr_orb_decl( calday , eccen, mvelpp, lambm0, obliqr, declin , eccf )
call shr_orb_decl( nextsw_cday, eccen, mvelpp, lambm0, obliqr, declinp1, eccf )
call t_stopf ('shr_orb_decl')
Expand Down
4 changes: 2 additions & 2 deletions src/cpl/mct/ndepStreamMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ end subroutine check_units
subroutine ndep_interp(bounds, atm2lnd_inst)

!-----------------------------------------------------------------------
use clm_time_manager, only : get_curr_date, get_days_per_year
use clm_time_manager, only : get_curr_date, get_curr_days_per_year
use clm_varcon , only : secspday
use atm2lndType , only : atm2lnd_type
!
Expand All @@ -244,7 +244,7 @@ subroutine ndep_interp(bounds, atm2lnd_inst)

if ( divide_by_secs_per_yr )then
ig = 0
dayspyr = get_days_per_year( )
dayspyr = get_curr_days_per_year( )
do g = bounds%begg,bounds%endg
ig = ig+1
atm2lnd_inst%forc_ndep_grc(g) = sdat%avs(1)%rAttr(1,ig) / (secspday * dayspyr)
Expand Down
4 changes: 2 additions & 2 deletions src/cpl/nuopc/lnd_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ subroutine ModelAdvance(gcomp, rc)
! Determine doalb based on nextsw_cday sent from atm model
!--------------------------------

caldayp1 = get_curr_calday(offset=dtime)
caldayp1 = get_curr_calday(offset=dtime, reuse_day_365_for_day_366=.true.)

if (nstep == 0) then
doalb = .false.
Expand Down Expand Up @@ -870,7 +870,7 @@ subroutine ModelAdvance(gcomp, rc)
! Note - the orbital inquiries set the values in clm_varorb via the module use statements
call clm_orbital_update(clock, iulog, masterproc, eccen, obliqr, lambm0, mvelpp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
calday = get_curr_calday()
calday = get_curr_calday(reuse_day_365_for_day_366=.true.)
call shr_orb_decl( calday , eccen, mvelpp, lambm0, obliqr, declin , eccf )
call shr_orb_decl( nextsw_cday, eccen, mvelpp, lambm0, obliqr, declinp1, eccf )
call t_stopf ('shr_orb_decl')
Expand Down
Loading