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

Add soil tillage for crops #2040

Merged
merged 104 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
298845e
First commit bringing tillage in from Mike Graham's code.
samsrabin May 20, 2023
a2f56c3
Compile fixes to previous.
samsrabin May 22, 2023
4c00684
Added namelist setup logic for tillage params.
samsrabin May 22, 2023
2adb528
Fixes to reading tillage namelist.
samsrabin May 22, 2023
ff41083
Replace index vars: i_litr2 → i_cel_lit, i_litr3 → i_lig_lit.
samsrabin May 22, 2023
416eae4
Only apply tillage multipliers once per column!
samsrabin May 31, 2023
7a006dc
Remove patch loops in get_tillage_multipliers*() subroutines.
samsrabin Jun 1, 2023
aefd94a
Is it that crop columns have multiple patches but only 1 is active?
samsrabin Jun 1, 2023
e909270
Is it that my filtering of non-crop columns didn't work?
samsrabin Jun 1, 2023
4a447d4
Added TODO: Figure out how to simply identify crop columns.
samsrabin Jun 1, 2023
5dda283
Only set tillage_mults(:) = 1 once per get_tillage_multipliers*() sub…
samsrabin Jun 1, 2023
2453126
Removed unneeded patch stuff from tillage_init().
samsrabin Jun 2, 2023
6c4a6e7
Removed unused indices from get_tillage_multipliers*().
samsrabin Jun 2, 2023
f1732c7
Simplified specification of tillage multipliers.
samsrabin Jun 2, 2023
e80cfdf
Merged get_tillage_multipliers*() subroutines.
samsrabin Jun 2, 2023
6c36b20
Simplify application of tillage multipliers.
samsrabin Jun 2, 2023
aaf20aa
Tillage params now duplicated as private vars.
samsrabin Jun 2, 2023
6e1102f
Added tillage params to namelist_defaults_ctsm.xml.
samsrabin Jun 2, 2023
6fedb42
Added high-intensity tillage from Mike Graham's code.
samsrabin Jun 2, 2023
eb42243
Removed a check from tillage_init() that was already in CLMBuildNamel…
samsrabin Jun 2, 2023
e132e43
Removed a TODO that was already done.
samsrabin Jun 13, 2023
9386d81
Corrected capitalization of TillageMod's .F90.
samsrabin Jun 14, 2023
df7e4de
Moved filling of tillage_mults_allphases to its own subroutine.
samsrabin Jun 16, 2023
2a812c4
Error if called with soil_decomp_method other than CENTURYKoven2013.
samsrabin Jun 16, 2023
270a5cd
Do not loop through soil layers within a loop through soil layers.
samsrabin Jun 21, 2023
2d79b38
Merge tag 'ctsm5.1.dev128' into tillage-reorg02
samsrabin Jun 22, 2023
6a2f1ae
Typo fix.
samsrabin Jul 6, 2023
80ea55c
Replaced do_tillage_* logicals with character tillage_mode.
samsrabin Jul 6, 2023
6acf76e
Discard use_original_tillage_private.
samsrabin Jul 6, 2023
4308802
Run fixes.
samsrabin Jul 17, 2023
6c0049a
Only call tillage_init_century() if doing tillage.
samsrabin Jul 17, 2023
e85505e
Allow tillage with FATES.
samsrabin Jul 17, 2023
d144df9
Added note about GDP dependence in old code.
samsrabin Jul 17, 2023
44eeaf7
Reorder tillage_mults_allphases fill for consistency.
samsrabin Jul 17, 2023
35b7f23
Removed an old comment in TillageMod.
samsrabin Jul 17, 2023
9090a6e
TillageMod now has its own copies of indices for soil pools.
samsrabin Jul 17, 2023
8c43072
Initialize tillage for MIMICS; not yet applying.
samsrabin Jul 17, 2023
a5e770e
Added note.
samsrabin Jul 7, 2023
07a259f
Only pass one patch's idop to get_tillage_multipliers().
samsrabin Jul 7, 2023
48b697e
Generalize tillage to work with multiple active crop patches.
samsrabin Jul 7, 2023
70e65c3
Merge branch 'tillage-multi-patch' into tillage-dev
samsrabin Jul 18, 2023
13f898c
Merge branch 'tillage-dev' into tillage-mimics
samsrabin Jul 18, 2023
eb3171d
Moved TillageMod.F90 to soilbiogeochem/
samsrabin Jul 18, 2023
955ec7f
Tillage now applied to MIMICS.
samsrabin Jul 18, 2023
6c4e019
Compile fixes.
samsrabin Jul 18, 2023
f9a03e6
Merge branch 'tillage-mimics' into tillage-dev
samsrabin Jul 19, 2023
d629ddd
Added script to add tillage parameters to params file.
samsrabin Jul 24, 2023
c148410
Tillage multipliers now read from params file.
samsrabin Jul 24, 2023
de88db0
Add git status info to params file.
samsrabin Jul 25, 2023
49b15ad
Save paramfile as NETCDF3_CLASSIC.
samsrabin Jul 26, 2023
0441df0
Replaced logical do_tillage_* with integer tillage_intensity.
samsrabin Jul 26, 2023
163147e
Removed unused 'use' in readParams_netcdf().
samsrabin Jul 26, 2023
23a89d6
Renamed nphases to ntill_intensities_max for consistency with netCDF …
samsrabin Jul 26, 2023
f61f983
Move present(idop) checks to beginning of decomp_rates_* subroutines.
samsrabin Jul 26, 2023
c1757d1
Rework get_apply_tillage_multipliers() to j;c loop instead of c;j.
samsrabin Jul 26, 2023
8cfeafe
Slice decomp_k by column and soil layer before passing to get_apply_t…
samsrabin Jul 26, 2023
750f5b9
Merge branch 'tillage-dev' into tillage
samsrabin Jul 26, 2023
7eaf5e2
Merge tag 'ctsm5.1.dev132' into tillage
samsrabin Aug 9, 2023
4a8adff
Bugfix to check that tillage is off when use_crop false.
samsrabin Aug 9, 2023
d856f1b
Improved description of get_tillage_multipliers().
samsrabin Aug 14, 2023
b71fa23
Improved description of use_original_tillage parameter.
samsrabin Aug 14, 2023
c5ee474
Improved error message when tillage on but use_crop off.
samsrabin Aug 14, 2023
fe568e1
Use get_do_tillage() in first readParams_netcdf() return check.
samsrabin Aug 14, 2023
3495f4b
Added a space.
samsrabin Aug 14, 2023
1865649
get_apply_tillage_multipliers(): multiple crop patches are OK.
samsrabin Aug 14, 2023
9063873
get_apply_tillage_multipliers: Check for sumwt < 1.
samsrabin Aug 14, 2023
f01adc6
Share idpp calculation code.
samsrabin Aug 14, 2023
cb5a889
Prepend bgc_ to till_decompk_multipliers.
samsrabin Aug 21, 2023
86b81fb
Till to 32 cm depth rather than top 5 soil layers.
samsrabin Aug 21, 2023
69451e2
Allow partially-tilled soil layers.
samsrabin Aug 21, 2023
8e67f28
max_tillage_depth is now a namelist parameter.
samsrabin Aug 21, 2023
b18572d
Added a comment and TODO.
samsrabin Aug 22, 2023
7af6bf6
Max till depth now 26cm (match text of Graham et al., 2021).
samsrabin Aug 22, 2023
ebda444
Renamed var & added text re: original tillage settings.
samsrabin Aug 22, 2023
2d76faa
Moved fraction_tilled calculation to new function get_fraction_tilled().
samsrabin Aug 31, 2023
e628c71
Added unit test for get_fraction_tilled().
samsrabin Aug 31, 2023
b12c780
Corrected a unit in a comment.
samsrabin Sep 1, 2023
c5171fe
get_apply_tillage_multipliers(): Skip non-crop columns more simply.
samsrabin Sep 1, 2023
579ca9a
Bug fix in get_fraction_tilled().
samsrabin Sep 15, 2023
7f7dfc8
test_get_fraction_tilled(): Use nlayers instead of 5.
samsrabin Sep 18, 2023
46da730
test_get_fraction_tilled(): Now works with new function call.
samsrabin Sep 18, 2023
9c1618b
get_fraction_tilled() no longer takes argument j.
samsrabin Sep 18, 2023
b87fbd9
get_fraction_tilled() can now handle zero-thickness layers.
samsrabin Sep 18, 2023
c0d8784
Simplify and split up test_get_fraction_tilled().
samsrabin Sep 18, 2023
77d0c7d
get_fraction_tilled() receives layer_bottom, not layer_top.
samsrabin Sep 18, 2023
3c24b25
Prevent tillage from being enabled.
samsrabin Oct 2, 2023
d43c617
Merge tag 'ctsm5.1.dev142' into tillage
samsrabin Oct 2, 2023
c8d6754
Removed a TODO.
samsrabin Oct 5, 2023
7510431
Removed an incorrect comment.
samsrabin Oct 5, 2023
d565176
Do not till generic crops.
samsrabin Oct 5, 2023
b86402e
Warn instead of fail when trying to enable tillage.
samsrabin Oct 5, 2023
1a3a8b7
Delete add_tillage_to_paramsfile.py.
samsrabin Oct 5, 2023
ae56384
Use ntill_intensities_max; set to private.
samsrabin Oct 5, 2023
d1f08a7
Add script used to add tillage to paramfile.
samsrabin Dec 29, 2023
d566b6d
Specify posNOTonfile=.true. in call of ncd_io() for till_decompk_mult…
samsrabin Dec 27, 2023
693750c
Replace a ntill_stages_max with ntill_intensities_max.
samsrabin Dec 29, 2023
9af1a04
Merge tag 'ctsm5.1.dev159' into tillage
samsrabin Dec 29, 2023
fffa851
Typo fix in crop Tech Note.
samsrabin Dec 29, 2023
ff610b4
Add tillage documentation to Tech Note.
samsrabin Dec 29, 2023
c86e1b6
Add "Running with tillage" section to User's Guide.
samsrabin Dec 29, 2023
f344ff1
Add 'till' testdef.
samsrabin Dec 29, 2023
0665754
Use parameter files with tillage multipliers (*.c240105.nc).
samsrabin Jan 5, 2024
2f69473
Remove warning about tillage not being scientifically tested.
samsrabin Jan 5, 2024
142c2c1
Enable tillage in two aux_clm tests.
samsrabin Jan 5, 2024
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
18 changes: 17 additions & 1 deletion bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,11 @@ sub process_namelist_inline_logic {
###############################
setup_logic_crop_inparm($opts, $nl_flags, $definition, $defaults, $nl);

###############################
# namelist group: tillage #
###############################
setup_logic_tillage($opts, $nl_flags, $definition, $defaults, $nl);

###############################
# namelist group: ch4par_in #
###############################
Expand Down Expand Up @@ -2241,6 +2246,17 @@ sub setup_logic_crop_inparm {
}
}

#-------------------------------------------------------------------------------

sub setup_logic_tillage {
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

my $tillage_mode = remove_leading_and_trailing_quotes( $nl->get_value( "tillage_mode" ) );
if ( $tillage_mode ne "off" && $tillage_mode ne "" && not &value_is_true($nl->get_value('use_crop')) ) {
$log->fatal_error( "Tillage only works on crop columns, so use_crop must be true if tillage is enabled." );
}
}

#-------------------------------------------------------------------------------
sub error_if_set {
# do a fatal_error and exit if any of the input variable names are set
Expand Down Expand Up @@ -4538,7 +4554,7 @@ sub write_output_files {
soil_resis_inparm bgc_shared canopyfluxes_inparm aerosol
clmu_inparm clm_soilstate_inparm clm_nitrogen clm_snowhydrology_inparm
cnprecision_inparm clm_glacier_behavior crop_inparm irrigation_inparm
surfacealbedo_inparm water_tracers_inparm);
surfacealbedo_inparm water_tracers_inparm tillage_inparm);

#@groups = qw(clm_inparm clm_canopyhydrology_inparm clm_soilhydrology_inparm
# finidat_consistency_checks dynpft_consistency_checks);
Expand Down
14 changes: 11 additions & 3 deletions bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- The default filenames are given relative to the root directory
for the CLM2 data in the CESM distribution -->
<!-- Plant function types (relative to {csmdata}) -->
<paramfile phys="clm5_1" >lnd/clm2/paramdata/ctsm51_params.c231117.nc</paramfile>
<paramfile phys="clm5_0" >lnd/clm2/paramdata/clm50_params.c231117.nc</paramfile>
<paramfile phys="clm4_5" >lnd/clm2/paramdata/clm45_params.c231117.nc</paramfile>
<paramfile phys="clm5_1" >lnd/clm2/paramdata/ctsm51_params.c240105.nc</paramfile>
<paramfile phys="clm5_0" >lnd/clm2/paramdata/clm50_params.c240105.nc</paramfile>
<paramfile phys="clm4_5" >lnd/clm2/paramdata/clm45_params.c240105.nc</paramfile>

<!-- ================================================================== -->
<!-- FATES default parameter file -->
Expand Down Expand Up @@ -2796,4 +2796,12 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1
<stream_meshfile_exice use_excess_ice=".true.">lnd/clm2/paramdata/exice_init_0.125x0.125_ESMFmesh_cdf5_c20220802.nc</stream_meshfile_exice>
<stream_mapalgo_exice use_excess_ice=".true.">bilinear</stream_mapalgo_exice>

<!-- ========================================= -->
<!-- Defaults for tillage -->
<!-- ========================================= -->

<tillage_mode>off</tillage_mode>
<use_original_tillage_phases>.false.</use_original_tillage_phases>
<max_tillage_depth>0.26d00</max_tillage_depth>

</namelist_defaults>
18 changes: 18 additions & 0 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2967,5 +2967,23 @@ Mapping method from excess ice input stream data to the model resolution
none = no interpolation
</entry>

<!-- ======================================================================================== -->
<!-- Namelist items controlling tillage -->
<!-- ======================================================================================== -->

<entry id="tillage_mode" type="char*8" category="physics"
group="tillage_inparm" valid_values="off,low,high">
Whether to till crop soil, and if so, with what intensity.
</entry>

<entry id="use_original_tillage_phases" type="logical" category="physics"
group="tillage_inparm" valid_values="" value=".false.">
Toggle to use original (Graham et al. 2021) tillage logic, with bug for seasons crossing into a new calendar year
</entry>

<entry id="max_tillage_depth" type="real" category="physics"
group="tillage_inparm" valid_values="" value="0.26d00">
Maximum depth to till soil (m). Default 0.26; original (Graham et al., 2021) value was unintentionally 0.32.
</entry>

</namelist_definition>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm51_ciso_cwd_hr_params.c231117.nc'
paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm51_ciso_cwd_hr_params.c240105.nc'
hist_fincl1 = 'CWDC_HR','C13_CWDC_HR','C14_CWDC_HR','CWD_HR_L2','CWD_HR_L2_vr','CWD_HR_L3','CWD_HR_L3_vr'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../crop
2 changes: 2 additions & 0 deletions cime_config/testdefs/testmods_dirs/clm/till/user_nl_clm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tillage_mode = 'high'

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ These updates appear in detail in the sections below. Many also appear in :ref:`
Available new features since the CLM5 release
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Addition of bioenergy crops
- Ablity to customize crop calendars (sowing windows/dates, maturity requirements) using stream files
- Ability to customize crop calendars (sowing windows/dates, maturity requirements) using stream files
- Cropland soil tillage

.. _The crop model:

Expand Down Expand Up @@ -708,6 +709,12 @@ Separate reproductive pool
''''''''''''''''''''''''''
One notable difference between natural vegetation and crops is the presence of reproductive carbon and nitrogen pools. Accounting for the reproductive pools helps determine whether crops are performing reasonably through yield calculations. The reproductive pool is maintained similarly to the leaf, stem, and fine root pools, but allocation of carbon and nitrogen does not begin until the grain fill stage of crop development. Equation :eq:`25.5` describes the carbon and nitrogen allocation coefficients to the reproductive pool. In CLM5BGCCROP, as allocation declines in stem, leaf, and root pools (see section :numref:`Grain fill to harvest`) during the grain fill stage of growth, increasing amounts of carbon and nitrogen are available for grain development.

.. _Tillage:

Tillage
'''''''
Tillage is represented as an enhancement of the decomposition rate coefficient; see section :numref:`decomp_mgmt_modifiers`.

.. _The irrigation model:

The irrigation model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,35 @@ The combined decomposition rate scalar (:math:`{r}_{total}`,unitless) is:

r_{total} =r_{tsoil} r_{water} r_{oxygen} r_{depth} .

.. _decomp_mgmt_modifiers:

Management modifiers on decomposition rate
--------------------------------------------------

Tillage of cropland soil is represented as an additional rate scalar that depends on tillage intensity (default off), soil pool, and time since planting :ref:`(Graham et al., 2021) <Grahametal2021>`. The tillage enhancement is strongest in the first 14 days after planting (idpp < 15), weaker in the next 30 days (15 ≤ idpp < 45), weaker still in the next 30 days (45 ≤ idpp < 75), and nonexistent after that (idpp ≥ 75).

.. list-table:: Tillage decomposition rate scalars. Values in each cell represent enhancement in different periods of days past planting: [0, 14], [15, 44], [45, 74].
:header-rows: 1

* - \
- low
- high
* - Litter 2 (cel_lit)
- 1.5, 1.5, 1.1
- 1.8, 1.5, 1.1
* - Litter 3 (lig_lit)
- 1.5, 1.5, 1.1
- 1.8, 1.5, 1.1
* - SOM 1 (act_som)
- 1.0, 1.0, 1.0
- 1.2, 1.0, 1.0
* - SOM 2 (slo_som)
- 3.0, 1.6, 1.3
- 4.8, 3.5, 2.5
* - SOM 3 (pas_som)
- 3.0, 1.6, 1.3
- 4.8, 3.5, 2.5

N-limitation of Decomposition Fluxes
-----------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ Gotangco Castillo C., Levis S., and Thornton P. 2012. Evaluation of the new CNDV

Graham, S.T., Famiglietti, J.S., and Maidment, D.R. 1999. Five-minute, 1/2°, and 1° data sets of continental watersheds and river networks for use in regional and global hydrologic and climate system modeling studies. Water Resour. Res. 35:583-587.

.. _Grahametal2021:

Graham, M. W., Thomas, R. Q., Lombardozzi, D. L., & O'Rourke, M. E. (2021). Modest capacity of no-till farming to offset emissions over 21st century. Environmental Research Letters, 16(5), 054055. doi: 10.1088/1748-9326/abe6c6

.. _Gravenetal2017:

Graven, H., C. E. Allison, D. M. Etheridge, S. Hammer, R. F. Keeling, I. Levin, H. A. J. Meijer, M. Rubino, P. P. Tans, C. M. Trudinger, B. H. Vaughn and J. W. C. White, 2017. Compiled records of carbon isotopes in atmospheric CO2 for historical simulations in CMIP6, Geoscientific Model Development, in review. doi: 10.5194/gmd-2017-166.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. _running-with-tillage:

.. include:: ../substitutions.rst

=====================
Running with tillage
=====================


Cropland tillage (Sect. :numref:`decomp_mgmt_modifiers`) can be toggled by specifying a value of ``'low'`` (low intensity) or ``'high'`` (high intensity) for the ``tillage_mode`` namelist option. By default this option is ``'off'``.

Depth of tillage can be changed with the ``max_tillage_depth`` parameter (meters; default 0.26).

Tillage multipliers for different soil pools and time since planting are defined on the parameter file, in variables ``bgc_till_decompk_multipliers`` (for CENTURY soil) and ``mimics_till_decompk_multipliers`` (for MIMICS soil). These variables were originally added with the script at ``tools/contrib/add_tillage_to_paramsfile.py``, which can be modified as needed to change tillage multipliers.


Example: Crop simulation with tillage
-------------------------------------
::

> cime/scripts/create_newcase -case IHistClm51BgcCrop_till -res f19_g17_gl4 -compset IHistClm51BgcCrop


> cd IHistClm51BgcCrop_till
> ./case.setup

# turn on tillage ('low' or 'high'; default 'off')
> echo "tillage_mode = 'high'" >> user_nl_clm

Reverting fixes relative to original tillage implementation
-----------------------------------------------------------

The current implementation of tillage in CTSM is based on work by :ref:`Graham et al. (2021) <Grahametal2021>`, but with fixes to how days after planting is calculated and to default tillage depth. To run without those changes:

::

> echo "use_original_tillage_phases = .true." >> user_nl_clm
> echo "max_tillage_depth = 0.32" >> user_nl_clm
6 changes: 4 additions & 2 deletions src/biogeochem/CNDriverMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,14 @@ subroutine CNDriverNoLeaching(bounds,
call t_startf('DecompRate')
if (decomp_method == century_decomp) then
call decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, &
soilstate_inst, temperature_inst, ch4_inst, soilbiogeochem_carbonflux_inst)
soilstate_inst, temperature_inst, ch4_inst, soilbiogeochem_carbonflux_inst, &
cnveg_state_inst%idop_patch)
else if (decomp_method == mimics_decomp) then
call decomp_rates_mimics(bounds, num_bgc_soilc, filter_bgc_soilc, &
num_bgc_vegp, filter_bgc_vegp, clm_fates, &
soilstate_inst, temperature_inst, cnveg_carbonflux_inst, ch4_inst, &
soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst)
soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst, &
cnveg_state_inst%idop_patch)
end if
call t_stopf('DecompRate')

Expand Down
40 changes: 34 additions & 6 deletions src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module CNPhenologyMod
public :: CNPhenologyInit ! Initialization
public :: CNPhenology ! Update
public :: CropPhase ! Get the current phase of each crop patch
public :: DaysPastPlanting ! Get how many days it's been since crop was planted

! !PUBLIC for unit testing
public :: CNPhenologySetNML ! Set the namelist setttings explicitly for unit tests
Expand Down Expand Up @@ -2255,12 +2256,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , &
end if

! days past planting may determine harvest

if (jday >= idop(p)) then
idpp = jday - idop(p)
else
idpp = int(dayspyr) + jday - idop(p)
end if
idpp = DaysPastPlanting(idop(p), jday)

! onset_counter initialized to zero when .not. croplive
! offset_counter relevant only at time step of harvest
Expand Down Expand Up @@ -2772,6 +2768,38 @@ subroutine PlantCrop(p, leafcn_in, jday, kyr, do_plant_normal, &

end subroutine PlantCrop

!-----------------------------------------------------------------------
function DaysPastPlanting(idop, jday_in)
! !USES:
use clm_time_manager, only : get_prev_calday, get_curr_days_per_year
!
! !ARGUMENTS:
integer, intent(in) :: idop ! patch day of planting
integer, optional, intent(in) :: jday_in ! julian day of the year
!
! !LOCAL VARIABLES
integer :: DaysPastPlanting
integer :: jday

! Must use separate jday_in and jday because we can't redefine an intent(in)
! variable, even if it wasn't provided in the function call.
if (present(jday_in)) then
jday = jday_in
else
! Use prev instead of curr to avoid jday=1 in last timestep of year
jday = get_prev_calday()
end if

if (jday >= idop) then
DaysPastPlanting = jday - idop
else
! As long as crops have at most a 365-day growing season, using get_curr_days_per_year()
! should give the same result of this function as using get_prev_days_per_year().
DaysPastPlanting = jday - idop + get_curr_days_per_year()
end if

end function DaysPastPlanting

!-----------------------------------------------------------------------
subroutine vernalization(p, &
canopystate_inst, temperature_inst, waterdiagnosticbulk_inst, cnveg_state_inst, crop_inst, &
Expand Down
2 changes: 2 additions & 0 deletions src/main/readParamsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ subroutine readParameters (photosyns_inst)
use SoilBiogeochemLittVertTranspMod , only : readSoilBiogeochemLittVertTranspParams => readParams
use SoilBiogeochemPotentialMod , only : readSoilBiogeochemPotentialParams => readParams
use SoilBiogeochemDecompMod , only : readSoilBiogeochemDecompParams => readParams
use TillageMod , only : readTillageParams => readParams
use SoilBiogeochemDecompCascadeMIMICSMod, only : readSoilBiogeochemDecompMimicsParams => readParams
use SoilBiogeochemDecompCascadeBGCMod , only : readSoilBiogeochemDecompBgcParams => readParams
use ch4Mod , only : readCH4Params => readParams
Expand Down Expand Up @@ -105,6 +106,7 @@ subroutine readParameters (photosyns_inst)
call readSoilBiogeochemDecompBgcParams(ncid)
end if
call readSoilBiogeochemDecompParams(ncid)
call readTillageParams(ncid, NLFilename_in)
call readSoilBiogeochemLittVertTranspParams(ncid)
call readSoilBiogeochemNitrifDenitrifParams(ncid)
call readSoilBiogeochemNLeachingParams(ncid)
Expand Down
1 change: 1 addition & 0 deletions src/soilbiogeochem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ list(APPEND clm_sources
SoilBiogeochemStateType.F90
SoilBiogeochemNitrogenStateType.F90
SoilBiogeochemNitrogenFluxType.F90
TillageMod.F90
)

sourcelist_to_parent(clm_sources)
20 changes: 17 additions & 3 deletions src/soilbiogeochem/SoilBiogeochemDecompCascadeBGCMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ subroutine init_decompcascade_bgc(bounds, soilbiogeochem_state_inst, soilstate_i
! initialize rate constants and decomposition pathways following the decomposition cascade of the BGC model.
! written by C. Koven
!
! !USES:
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
type(soilbiogeochem_state_type) , intent(inout) :: soilbiogeochem_state_inst
Expand Down Expand Up @@ -511,7 +509,8 @@ end subroutine init_decompcascade_bgc

!-----------------------------------------------------------------------
subroutine decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, &
soilstate_inst, temperature_inst, ch4_inst, soilbiogeochem_carbonflux_inst)
soilstate_inst, temperature_inst, ch4_inst, soilbiogeochem_carbonflux_inst, &
idop)
!
! !DESCRIPTION:
! calculate rate constants and decomposition pathways for the CENTURY decomposition cascade model
Expand All @@ -521,6 +520,9 @@ subroutine decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, &
use clm_time_manager , only : get_average_days_per_year, get_step_size
use shr_const_mod , only : SHR_CONST_PI
use clm_varcon , only : secspday
use TillageMod , only : get_do_tillage
use TillageMod , only : get_apply_tillage_multipliers
use landunit_varcon , only : istcrop
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
Expand All @@ -530,6 +532,7 @@ subroutine decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, &
type(temperature_type) , intent(in) :: temperature_inst
type(ch4_type) , intent(in) :: ch4_inst
type(soilbiogeochem_carbonflux_type) , intent(inout) :: soilbiogeochem_carbonflux_inst
integer, optional , intent(in) :: idop(:) ! patch day of planting
Copy link
Contributor

Choose a reason for hiding this comment

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

This is tangential to the work here, and perhaps something you've already done with the prescribed planting dates: Is it worth adding this variable to history to better identify crop phenology? I'm not sure if similar variables exist for leaf emergence and harvest, but it would be great to add (if they don't exist) and write them out. Likely easier to analyze than the current CPHASE variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did indeed add output for day of planting and harvest for the crop calendar work; you can see all the outputs I added here. No such variables exist for emergence and the vegetative-reproductive transition, but they could for sure be added in the future.

!
! !LOCAL VARIABLES:
real(r8), parameter :: eps = 1.e-6_r8
Expand Down Expand Up @@ -595,6 +598,10 @@ subroutine decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, &
errMsg(sourcefile, __LINE__))
endif

if (get_do_tillage() .and. .not. present(idop)) then
call endrun("Do not enable tillage without providing idop to decomp_rate_constants_bgc().")
end if

days_per_year = get_average_days_per_year()
dt = real( get_step_size(), r8 )

Expand Down Expand Up @@ -895,6 +902,12 @@ subroutine decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, &
decomp_k(c,j,i_cwd) = k_frag * t_scalar(c,j) * w_scalar(c,j) * &
depth_scalar(c,j) * o_scalar(c,j) * spinup_geogterm_cwd(c)
end if

! Tillage
if (get_do_tillage()) then
call get_apply_tillage_multipliers(idop, c, j, decomp_k(c,j,:))
end if

! Above into soil matrix
if(use_soil_matrixcn)then
! same for cwd but only if fates is not enabled; fates handles CWD
Expand All @@ -904,6 +917,7 @@ subroutine decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, &
end if !use_soil_matrixcn
end do
end do

pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_l1s1) = 1.0_r8
pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_l2s1) = 1.0_r8
pathfrac_decomp_cascade(bounds%begc:bounds%endc,1:nlevdecomp,i_l3s2) = 1.0_r8
Expand Down
Loading
Loading