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

New outputs: N to food and seed #2074

Merged
merged 18 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cime_config/testdefs/testmods_dirs/clm/crop/user_nl_clm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
hist_fincl1 += 'GDD0', 'GDD8', 'GDD10',
'GDD020', 'GDD820', 'GDD1020',
'GDDACCUM', 'GDDTSOI', 'A5TMIN', 'A10TMIN',
'HUI'
'HUI', 'GRAINN_TO_FOOD'

! The main point of including this field is to test the SUM history field infrastructure
! This is in the crop testmods because this field is mainly useful in transient crop runs
Expand All @@ -10,7 +10,7 @@ hist_fincl2 += 'DYN_COL_SOIL_ADJUSTMENTS_C'


! Annual crop variables on per-sowing/per-harvest axes, per PFT.
hist_fincl3 = 'SDATES', 'SDATES_PERHARV', 'SYEARS_PERHARV', 'HDATES', 'GRAINC_TO_FOOD_PERHARV', 'GRAINC_TO_FOOD_ANN', 'HDATES', 'GDDHARV_PERHARV', 'GDDACCUM_PERHARV', 'HUI_PERHARV', 'SOWING_REASON_PERHARV', 'HARVEST_REASON_PERHARV', 'SWINDOW_STARTS', 'SWINDOW_ENDS'
hist_fincl3 = 'SDATES', 'SDATES_PERHARV', 'SYEARS_PERHARV', 'HDATES', 'GRAINC_TO_FOOD_PERHARV', 'GRAINC_TO_FOOD_ANN', 'GRAINN_TO_FOOD_PERHARV', 'GRAINN_TO_FOOD_ANN', 'GRAINC_TO_SEED_PERHARV', 'GRAINC_TO_SEED_ANN', 'GRAINN_TO_SEED_PERHARV', 'GRAINN_TO_SEED_ANN', 'HDATES', 'GDDHARV_PERHARV', 'GDDACCUM_PERHARV', 'HUI_PERHARV', 'SOWING_REASON_PERHARV', 'HARVEST_REASON_PERHARV', 'SWINDOW_STARTS', 'SWINDOW_ENDS'
hist_nhtfrq(3) = 17520
hist_mfilt(3) = 1
hist_type1d_pertape(3) = 'PFTS'
Expand Down
45 changes: 45 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@
===============================================================
Tag name: ctsm5.1.dev148
Originator(s): samrabin (Sam Rabin, UCAR/TSS, [email protected])
Date: Fri Nov 3 07:56:43 MDT 2023
One-line Summary: Add GRAINN outputs

Purpose and description of changes
----------------------------------

In response to a user request for GRAINN_TO_FOOD outputs, this adds *_N_TO_FOOD(_ANN) and *_N_TO_SEED(_ANN) outputs for reproductive N pools. These are off by default, unlike their C counterparts. Note that the results are not scientifically supported, and tests have revealed unrealistic values. (Also adds GRAINC_TO_SEED_ANN output.)


Significant changes to scientifically-supported configurations
--------------------------------------------------------------

Does this tag change answers significantly for any of the following physics configurations?
(Details of any changes will be given in the "Answer changes" section below.)

[ ] clm5_1

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


Testing summary:
----------------

[PASS means all tests PASS; OK means tests PASS other than expected fails.]

regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing):

cheyenne ---- OK (with some fieldlist diffs)
izumi ------- PASS (with some fieldlist diffs)


Other details
-------------

Pull Requests that document the changes (include PR ids):
* #2074 (https://github.com/ESCOMP/CTSM/pull/2074)

===============================================================
===============================================================
Tag name: ctsm5.1.dev147
Originator(s): samrabin (Sam Rabin, UCAR/TSS, [email protected])
Date: Mon Oct 30 16:53:20 MDT 2023
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeSum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Tag Who Date Summary
============================================================================================================================
ctsm5.1.dev148 samrabin 11/03/2023 Add GRAINN outputs
ctsm5.1.dev147 samrabin 10/30/2023 Add sowing window input files
ctsm5.1.dev146 glemieux 10/24/2023 FATES cross-grid seed dispersal
ctsm5.1.dev145 slevis 10/19/2023 SNICAR snow albedo scheme updates
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2022,10 +2022,16 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , &
crop_inst%harvest_reason_thisyr_patch(p,s) = -1._r8
do k = repr_grain_min, repr_grain_max
cnveg_carbonflux_inst%repr_grainc_to_food_perharv_patch(p,s,k) = 0._r8
cnveg_carbonflux_inst%repr_grainc_to_seed_perharv_patch(p,s,k) = 0._r8
cnveg_nitrogenflux_inst%repr_grainn_to_food_perharv_patch(p,s,k) = 0._r8
cnveg_nitrogenflux_inst%repr_grainn_to_seed_perharv_patch(p,s,k) = 0._r8
end do
end do
do k = repr_grain_min, repr_grain_max
cnveg_carbonflux_inst%repr_grainc_to_food_thisyr_patch(p,k) = 0._r8
cnveg_carbonflux_inst%repr_grainc_to_seed_thisyr_patch(p,k) = 0._r8
cnveg_nitrogenflux_inst%repr_grainn_to_food_thisyr_patch(p,k) = 0._r8
cnveg_nitrogenflux_inst%repr_grainn_to_seed_thisyr_patch(p,k) = 0._r8
end do
end if

Expand Down Expand Up @@ -3081,6 +3087,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
real(r8) :: cropseedc_deficit_to_restore ! amount of crop seed C deficit that will be restored from this grain pool (gC/m2)
real(r8) :: cropseedn_deficit_to_restore ! amount of crop seed N deficit that will be restored from this grain pool (gN/m2)
real(r8) :: repr_grainc_to_food_thispool ! amount added to / subtracted from repr_grainc_to_food for the pool in question (gC/m2/s)
real(r8) :: repr_grainn_to_food_thispool ! amount added to / subtracted from repr_grainn_to_food for the pool in question (gN/m2/s)
!-----------------------------------------------------------------------

associate( &
Expand Down Expand Up @@ -3121,6 +3128,8 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
repr_grainc_to_food_perharv => cnveg_carbonflux_inst%repr_grainc_to_food_perharv_patch, & ! Output: [real(r8) (:,:,:) ] grain C to food per harvest (gC/m2)
repr_grainc_to_food_thisyr => cnveg_carbonflux_inst%repr_grainc_to_food_thisyr_patch, & ! Output: [real(r8) (:,:) ] grain C to food harvested this calendar year (gC/m2)
repr_grainc_to_seed => cnveg_carbonflux_inst%repr_grainc_to_seed_patch , & ! Output: [real(r8) (:,:) ] grain C to seed (gC/m2/s)
repr_grainc_to_seed_perharv => cnveg_carbonflux_inst%repr_grainc_to_seed_perharv_patch, & ! Output: [real(r8) (:,:,:) ] grain C to seed per harvest (gC/m2)
repr_grainc_to_seed_thisyr => cnveg_carbonflux_inst%repr_grainc_to_seed_thisyr_patch, & ! Output: [real(r8) (:,:) ] grain C to seed harvested this calendar year (gC/m2)
repr_structurec_to_cropprod => cnveg_carbonflux_inst%repr_structurec_to_cropprod_patch, & ! Output: [real(r8) (:,:) ] reproductive structure C to crop product pool (gC/m2/s)
repr_structurec_to_litter => cnveg_carbonflux_inst%repr_structurec_to_litter_patch, & ! Output: [real(r8) (:,:) ] reproductive structure C to litter (gC/m2/s)
leafc_to_biofuelc => cnveg_carbonflux_inst%leafc_to_biofuelc_patch , & ! Output: [real(r8) (:) ] leaf C to biofuel C (gC/m2/s)
Expand All @@ -3130,7 +3139,11 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &

livestemn_to_litter => cnveg_nitrogenflux_inst%livestemn_to_litter_patch , & ! Output: [real(r8) (:) ] livestem N to litter (gN/m2/s)
repr_grainn_to_food => cnveg_nitrogenflux_inst%repr_grainn_to_food_patch , & ! Output: [real(r8) (:,:) ] grain N to food (gN/m2/s)
repr_grainn_to_food_perharv => cnveg_nitrogenflux_inst%repr_grainn_to_food_perharv_patch, & ! Output: [real(r8) (:,:,:) ] grain N to food per harvest (gN/m2)
repr_grainn_to_food_thisyr => cnveg_nitrogenflux_inst%repr_grainn_to_food_thisyr_patch, & ! Output: [real(r8) (:,:) ] grain N to food harvested this calendar year (gN/m2)
repr_grainn_to_seed => cnveg_nitrogenflux_inst%repr_grainn_to_seed_patch , & ! Output: [real(r8) (:,:) ] grain N to seed (gN/m2/s)
repr_grainn_to_seed_perharv => cnveg_nitrogenflux_inst%repr_grainn_to_seed_perharv_patch, & ! Output: [real(r8) (:,:,:) ] grain N to seed per harvest (gN/m2)
repr_grainn_to_seed_thisyr => cnveg_nitrogenflux_inst%repr_grainn_to_seed_thisyr_patch, & ! Output: [real(r8) (:,:) ] grain N to seed harvested this calendar year (gN/m2)
repr_structuren_to_cropprod => cnveg_nitrogenflux_inst%repr_structuren_to_cropprod_patch, & ! Output: [real(r8) (:,:) ] reproductive structure N to crop product pool (gN/m2/s)
repr_structuren_to_litter => cnveg_nitrogenflux_inst%repr_structuren_to_litter_patch, & ! Output: [real(r8) (:,:) ] reproductive structure N to litter (gN/m2/s)
leafn_to_biofueln => cnveg_nitrogenflux_inst%leafn_to_biofueln_patch , & ! Output: [real(r8) (:) ] leaf N to biofuel N (gN/m2/s)
Expand Down Expand Up @@ -3192,10 +3205,19 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
cropseedc_deficit_to_restore = min(cropseedc_deficit_remaining, reproductivec(p,k))
cropseedc_deficit_remaining = cropseedc_deficit_remaining - cropseedc_deficit_to_restore
repr_grainc_to_seed(p,k) = t1 * cropseedc_deficit_to_restore

if (cropseedc_deficit_to_restore > 0._r8) then
repr_grainc_to_seed_perharv(p,h,k) = cropseedc_deficit_to_restore
repr_grainc_to_seed_thisyr(p,k) = repr_grainc_to_seed_thisyr(p,k) &
+ repr_grainc_to_seed_perharv(p,h,k)
end if
cropseedn_deficit_to_restore = min(cropseedn_deficit_remaining, reproductiven(p,k))
cropseedn_deficit_remaining = cropseedn_deficit_remaining - cropseedn_deficit_to_restore
repr_grainn_to_seed(p,k) = t1 * cropseedn_deficit_to_restore
if (cropseedn_deficit_to_restore > 0._r8) then
repr_grainn_to_seed_perharv(p,h,k) = cropseedn_deficit_to_restore
repr_grainn_to_seed_thisyr(p,k) = repr_grainn_to_seed_thisyr(p,k) &
+ repr_grainn_to_seed_perharv(p,h,k)
end if

! Send the remaining grain to the food product pool
repr_grainc_to_food_thispool = cpool_to_reproductivec(p,k) - repr_grainc_to_seed(p,k)
Expand All @@ -3207,8 +3229,15 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
repr_grainc_to_food_thisyr(p,k) = repr_grainc_to_food_thisyr(p,k) &
+ repr_grainc_to_food_perharv(p,h,k)
end if
repr_grainn_to_food_thispool = npool_to_reproductiven(p,k) - repr_grainn_to_seed(p,k)
repr_grainn_to_food(p,k) = t1 * reproductiven(p,k) &
+ npool_to_reproductiven(p,k) - repr_grainn_to_seed(p,k)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked @samsrabin to remind me the diff between "grain to seed" and "grain to food" and I see here that the two terms summed are the reproductive pool. I'm not sure "seed" is the right term for what's left when you subtract food from the reproductive pool, but that's out of scope for this PR.

if (reproductiven(p,k) + repr_grainn_to_food_thispool * dt > 0._r8) then
repr_grainn_to_food_perharv(p,h,k) = reproductiven(p,k) &
+ repr_grainn_to_food_thispool * dt
repr_grainn_to_food_thisyr(p,k) = repr_grainn_to_food_thisyr(p,k) &
+ repr_grainn_to_food_perharv(p,h,k)
end if
end do

do k = repr_structure_min, repr_structure_max
Expand Down
34 changes: 34 additions & 0 deletions src/biogeochem/CNVegCarbonFluxType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ module CNVegCarbonFluxType
real(r8), pointer :: leafc_to_biofuelc_patch (:) ! leaf C to biofuel C (gC/m2/s)
real(r8), pointer :: livestemc_to_biofuelc_patch (:) ! livestem C to biofuel C (gC/m2/s)
real(r8), pointer :: repr_grainc_to_seed_patch (:,:) ! grain C to seed for prognostic crop(gC/m2/s) [patch, repr_grain_min:repr_grain_max]
real(r8), pointer :: repr_grainc_to_seed_perharv_patch (:,:,:) ! grain C to seed for prognostic crop accumulated by harvest (gC/m2) [patch, harvest, repr_grain_min:repr_grain_max]. Not per-second because this variable represents an accumulation over each growing season, to be instantaneously at the end of each calendar year, to provide output that's easier to work with.
real(r8), pointer :: repr_grainc_to_seed_thisyr_patch (:,:) ! grain C to seed for prognostic crop accumulated this calendar year (gC/m2) [patch, repr_grain_min:repr_grain_max]. Not per-second because this variable represents an accumulation over an entire calendar year, to be saved instantaneously at the end of each calendar year, to provide output that's easier to work with.

! maintenance respiration fluxes
real(r8), pointer :: cpool_to_resp_patch (:) ! CNflex excess C maintenance respiration (gC/m2/s)
Expand Down Expand Up @@ -672,6 +674,8 @@ subroutine InitAllocate(this, bounds, carbon_type, alloc_full_veg)
allocate(this%leafc_to_biofuelc_patch (begp:endp)) ; this%leafc_to_biofuelc_patch (:) = nan
allocate(this%livestemc_to_biofuelc_patch (begp:endp)) ; this%livestemc_to_biofuelc_patch (:) = nan
allocate(this%repr_grainc_to_seed_patch(begp:endp, repr_grain_min:repr_grain_max)) ; this%repr_grainc_to_seed_patch (:,:) = nan
allocate(this%repr_grainc_to_seed_perharv_patch(begp:endp, 1:mxharvests, repr_grain_min:repr_grain_max)) ; this%repr_grainc_to_seed_perharv_patch (:,:,:) = nan
allocate(this%repr_grainc_to_seed_thisyr_patch(begp:endp, repr_grain_min:repr_grain_max)) ; this%repr_grainc_to_seed_thisyr_patch (:,:) = nan
allocate(this%reproductivec_xfer_to_reproductivec_patch(begp:endp, nrepr))
this%reproductivec_xfer_to_reproductivec_patch(:,:) = nan
allocate(this%cpool_reproductive_gr_patch (begp:endp, nrepr)) ; this%cpool_reproductive_gr_patch (:,:) = nan
Expand Down Expand Up @@ -977,6 +981,8 @@ subroutine InitHistory(this, bounds, carbon_type)
ptr_patch=this%livestemc_to_biofuelc_patch)

this%repr_grainc_to_seed_patch(begp:endp,:) = spval
this%repr_grainc_to_seed_perharv_patch(begp:endp,:,:) = spval
this%repr_grainc_to_seed_thisyr_patch(begp:endp,:) = spval
do k = repr_grain_min, repr_grain_max
data1dptr => this%repr_grainc_to_seed_patch(:,k)
call hist_addfld1d ( &
Expand All @@ -986,6 +992,25 @@ subroutine InitHistory(this, bounds, carbon_type)
avgflag='A', &
long_name=get_repr_longname(k)//' C to seed', &
ptr_patch=data1dptr)
data2dptr => this%repr_grainc_to_seed_perharv_patch(:,:,k)
call hist_addfld2d ( &
! e.g., GRAINC_TO_SEED_PERHARV
fname=get_repr_hist_fname(k)//'C_TO_SEED_PERHARV', &
units='gC/m^2', &
type2d='mxharvests', &
avgflag='I', &
long_name=get_repr_longname(k)//' C to seed per harvest; should only be output annually', &
ptr_patch=data2dptr, &
default='inactive')
data1dptr => this%repr_grainc_to_seed_thisyr_patch(:,k)
call hist_addfld1d ( &
! e.g., GRAINC_TO_SEED_ANN
fname=get_repr_hist_fname(k)//'C_TO_SEED_ANN', &
units='gC/m^2', &
avgflag='I', &
long_name=get_repr_longname(k)//' C to seed harvested per calendar year; should only be output annually', &
ptr_patch=data1dptr, &
default='inactive')
end do
end if

Expand Down Expand Up @@ -3730,6 +3755,15 @@ subroutine RestartBulkOnly ( this, bounds, ncid, flag )
long_name=get_repr_longname(k)//' C to food per calendar year; should only be output annually', &
units='gC/m2', &
interpinic_flag='interp', readvar=readvar, data=data1dptr)
data1dptr => this%repr_grainc_to_seed_thisyr_patch(:,k)
! e.g., grainc_to_seed_thisyr
varname = get_repr_rest_fname(k)//'c_to_seed_thisyr'
call restartvar(ncid=ncid, flag=flag, varname=varname, &
xtype=ncd_double, &
dim1name='pft', &
long_name=get_repr_longname(k)//' C to seed per calendar year; should only be output annually', &
units='gC/m2', &
interpinic_flag='interp', readvar=readvar, data=data1dptr)
end do

do k = 1, nrepr
Expand Down
Loading