Skip to content

Commit

Permalink
Call CropPhenology regardless of doalb
Browse files Browse the repository at this point in the history
However, do NOT call CropPhenology on time step 0.

See some discussion in ESCOMP#1626 and
ESCOMP#1623 .
  • Loading branch information
billsacks committed Feb 3, 2022
1 parent 8d9f988 commit dadbc62
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/biogeochem/CNDriverMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ end subroutine CNDriverInit
!-----------------------------------------------------------------------
subroutine CNDriverNoLeaching(bounds, &
num_soilc, filter_soilc, num_soilp, filter_soilp, num_pcropp, filter_pcropp, &
num_exposedvegp, filter_exposedvegp, num_noexposedvegp, filter_noexposedvegp, doalb, &
num_exposedvegp, filter_exposedvegp, num_noexposedvegp, filter_noexposedvegp, &
cnveg_state_inst, &
cnveg_carbonflux_inst, cnveg_carbonstate_inst, &
c13_cnveg_carbonflux_inst, c13_cnveg_carbonstate_inst, &
Expand Down Expand Up @@ -154,7 +154,6 @@ subroutine CNDriverNoLeaching(bounds,
integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg
integer , intent(in) :: num_noexposedvegp ! number of points in filter_noexposedvegp
integer , intent(in) :: filter_noexposedvegp(:) ! patch filter where frac_veg_nosno is 0
logical , intent(in) :: doalb ! true = surface albedo calculation time step
type(cnveg_state_type) , intent(inout) :: cnveg_state_inst
type(cnveg_carbonflux_type) , intent(inout) :: cnveg_carbonflux_inst
type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst
Expand Down Expand Up @@ -370,7 +369,7 @@ subroutine CNDriverNoLeaching(bounds,
call t_startf('CNPhenology_phase1')
call CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
filter_soilp, num_pcropp, filter_pcropp, &
doalb, waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, &
waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, &
crop_inst, canopystate_inst, soilstate_inst, dgvs_inst, &
cnveg_state_inst, cnveg_carbonstate_inst, cnveg_carbonflux_inst, &
cnveg_nitrogenstate_inst, cnveg_nitrogenflux_inst, &
Expand Down Expand Up @@ -467,7 +466,7 @@ subroutine CNDriverNoLeaching(bounds,
if ( .not. use_fun ) then
call CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
filter_soilp, num_pcropp, filter_pcropp, &
doalb, waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, &
waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, &
crop_inst, canopystate_inst, soilstate_inst, dgvs_inst, &
cnveg_state_inst, cnveg_carbonstate_inst, cnveg_carbonflux_inst, &
cnveg_nitrogenstate_inst, cnveg_nitrogenflux_inst, &
Expand All @@ -478,7 +477,7 @@ subroutine CNDriverNoLeaching(bounds,
end if
call CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
filter_soilp, num_pcropp, filter_pcropp, &
doalb, waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, &
waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, &
crop_inst, canopystate_inst, soilstate_inst, dgvs_inst, &
cnveg_state_inst, cnveg_carbonstate_inst, cnveg_carbonflux_inst, &
cnveg_nitrogenstate_inst, cnveg_nitrogenflux_inst, &
Expand Down
22 changes: 19 additions & 3 deletions src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,14 @@ end subroutine readParams
!-----------------------------------------------------------------------
subroutine CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
filter_soilp, num_pcropp, filter_pcropp, &
doalb, waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, crop_inst, &
waterdiagnosticbulk_inst, wateratm2lndbulk_inst, temperature_inst, atm2lnd_inst, crop_inst, &
canopystate_inst, soilstate_inst, dgvs_inst, &
cnveg_state_inst, cnveg_carbonstate_inst, cnveg_carbonflux_inst, &
cnveg_nitrogenstate_inst, cnveg_nitrogenflux_inst, &
c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst, &
leaf_prof_patch, froot_prof_patch, phase)
! !USES:
use clm_time_manager , only: is_first_step
use CNSharedParamsMod, only: use_fun
!
! !DESCRIPTION:
Expand All @@ -312,7 +313,6 @@ subroutine CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
integer , intent(in) :: filter_soilp(:) ! filter for soil patches
integer , intent(in) :: num_pcropp ! number of prog. crop patches in filter
integer , intent(in) :: filter_pcropp(:)! filter for prognostic crop patches
logical , intent(in) :: doalb ! true if time for sfc albedo calc
type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst
type(wateratm2lndbulk_type) , intent(in) :: wateratm2lndbulk_inst
type(temperature_type) , intent(inout) :: temperature_inst
Expand Down Expand Up @@ -355,7 +355,19 @@ subroutine CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
soilstate_inst, temperature_inst, atm2lnd_inst, wateratm2lndbulk_inst, cnveg_state_inst, &
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst)

if (doalb .and. num_pcropp > 0 ) then
! BACKWARDS_COMPATIBILITY(wjs, 2022-02-03) Old restart files generated at the end
! of the year can indicate that a crop was panted on Jan 1, because that used to be
! the time given to the last time step of the year. This would cause problems if we
! ran CropPhenology in time step 0, because now time step 0 is labeled as Dec 31,
! so CropPhenology would see the crop as having been planted 364 days ago, and so
! would want to harvest this newly-planted crop. To avoid this situation, we avoid
! calling CropPhenology on time step 0.
!
! This .not. is_first_step() condition can be removed either when we can rely on
! all restart files having been generated with
! https://github.com/ESCOMP/CTSM/issues/1623 resolved, or we stop having a time
! step 0 (https://github.com/ESCOMP/CTSM/issues/925).
if (num_pcropp > 0 .and. .not. is_first_step()) then
call CropPhenology(num_pcropp, filter_pcropp, &
waterdiagnosticbulk_inst, temperature_inst, crop_inst, canopystate_inst, cnveg_state_inst, &
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, &
Expand Down Expand Up @@ -548,6 +560,10 @@ subroutine CNPhenologyClimate (num_soilp, filter_soilp, num_pcropp, filter_pcrop
! The following crop related steps are done here rather than CropPhenology
! so that they will be completed each time-step rather than with doalb.
!
! NOTE(wjs, 2022-02-03) The above comment about doalb no longer applies, because
! there is no longer a doalb conditional around the CropPhenology call. Therefore,
! we could move these calculations into CropPhenology if it made sense to do so.
!
! The following lines come from ibis's climate.f + stats.f
! gdd SUMMATIONS ARE RELATIVE TO THE PLANTING DATE (see subr. updateAccFlds)

Expand Down
3 changes: 0 additions & 3 deletions src/biogeochem/CNVegetationFacade.F90
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,6 @@ subroutine EcosystemDynamicsPreDrainage(this, bounds, &
num_pcropp, filter_pcropp, &
num_exposedvegp, filter_exposedvegp, &
num_noexposedvegp, filter_noexposedvegp, &
doalb, &
soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst, &
c13_soilbiogeochem_carbonflux_inst, c13_soilbiogeochem_carbonstate_inst, &
c14_soilbiogeochem_carbonflux_inst, c14_soilbiogeochem_carbonstate_inst, &
Expand Down Expand Up @@ -915,7 +914,6 @@ subroutine EcosystemDynamicsPreDrainage(this, bounds, &
integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg
integer , intent(in) :: num_noexposedvegp ! number of points in filter_noexposedvegp
integer , intent(in) :: filter_noexposedvegp(:) ! patch filter where frac_veg_nosno is 0
logical , intent(in) :: doalb ! true = surface albedo calculation time step
type(soilbiogeochem_state_type) , intent(inout) :: soilbiogeochem_state_inst
type(soilbiogeochem_carbonflux_type) , intent(inout) :: soilbiogeochem_carbonflux_inst
type(soilbiogeochem_carbonstate_type) , intent(inout) :: soilbiogeochem_carbonstate_inst
Expand Down Expand Up @@ -956,7 +954,6 @@ subroutine EcosystemDynamicsPreDrainage(this, bounds, &
num_pcropp, filter_pcropp, &
num_exposedvegp, filter_exposedvegp, &
num_noexposedvegp, filter_noexposedvegp, &
doalb, &
this%cnveg_state_inst, &
this%cnveg_carbonflux_inst, this%cnveg_carbonstate_inst, &
this%c13_cnveg_carbonflux_inst, this%c13_cnveg_carbonstate_inst, &
Expand Down
1 change: 0 additions & 1 deletion src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
filter(nc)%num_pcropp, filter(nc)%pcropp, &
filter(nc)%num_exposedvegp, filter(nc)%exposedvegp, &
filter(nc)%num_noexposedvegp, filter(nc)%noexposedvegp, &
doalb, &
soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst, &
c13_soilbiogeochem_carbonflux_inst, c13_soilbiogeochem_carbonstate_inst, &
c14_soilbiogeochem_carbonflux_inst, c14_soilbiogeochem_carbonstate_inst, &
Expand Down

0 comments on commit dadbc62

Please sign in to comment.