Skip to content

Commit

Permalink
Merge pull request ESCOMP#882 from JessicaNeedham/JessicaNeedham-IO-s…
Browse files Browse the repository at this point in the history
…izeagemortality

Add a new fates dimension to track cohort age.
  • Loading branch information
glemieux authored Mar 26, 2020
2 parents 5220caa + cad203f commit 0d93237
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Externals_CLM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local_path = src/fates
protocol = git
repo_url = https://github.com/NGEET/fates
tag = sci.1.33.0_api.8.1.0
tag = sci.1.34.0_api.9.0.0
required = True

[PTCLM]
Expand Down
5 changes: 3 additions & 2 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,8 @@ sub setup_cmdl_fates_mode {
}
} else {
# dis-allow fates specific namelist items with non-fates runs
my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
"use_fates_cohort_age_tracking",
"use_fates_inventory_init", "fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode" );
foreach my $var ( @list ) {
if ( defined($nl->get_value($var)) ) {
Expand Down Expand Up @@ -3897,7 +3898,7 @@ sub setup_logic_fates {
if ($physv->as_long() >= $physv->as_long("clm4_5") && &value_is_true( $nl_flags->{'use_fates'}) ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'});
my @list = ( "use_fates_spitfire", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
"use_fates_inventory_init", "use_fates_logging","fates_parteh_mode" );
"use_fates_inventory_init", "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking" );
foreach my $var ( @list ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'} );
}
Expand Down
1 change: 1 addition & 0 deletions bld/namelist_files/namelist_defaults_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,7 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18
<!-- ===== FATES DEFAULTS =========== -->
<use_fates_spitfire use_fates=".true.">.false.</use_fates_spitfire>
<use_fates_planthydro use_fates=".true.">.false.</use_fates_planthydro>
<use_fates_cohort_age_tracking use_fates=".true.">.false.</use_fates_cohort_age_tracking>
<use_fates_ed_st3 use_fates=".true.">.false.</use_fates_ed_st3>
<use_fates_ed_prescribed_phys use_fates=".true.">.false.</use_fates_ed_prescribed_phys>
<use_fates_logging use_fates=".true.">.false.</use_fates_logging>
Expand Down
11 changes: 8 additions & 3 deletions bld/namelist_files/namelist_definition_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,14 @@ Toggle to turn on the logging module (only relevant if FATES is being used).
</entry>

<entry id="use_fates_planthydro" type="logical" category="physics"
group="clm_inparm" valid_values="" value=".false.">
Toggle to turn on plant hydraulics (only relevant if FATES is on).
(use_fates_planthydro=".true." is EXPERIMENTAL NOT SUPPORTED! Nor is it Tested!)
group="clm_inparm" valid_values="" value=".false.">
Toggle to turn on plant hydraulics (only relevant if FATES is on).
(use_fates_planthydro=".true." is EXPERIMENTAL NOT SUPPORTED! Nor is it Tested!)
</entry>

<entry id="use_fates_cohort_age_tracking" type="logical" category="physics"
group="clm_inparm" valid_values="" value=".false.">
Toggle to turn on cohort age tracking (only relevant if FATES is on).
</entry>

<entry id="use_fates_ed_st3" type="logical" category="physics"
Expand Down
10 changes: 10 additions & 0 deletions cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,16 @@
<option name="wallclock">00:40:00</option>
</options>
</test>
<test name="ERS_Ld30" grid="f45_f45_mg37" compset="I2000Clm50FatesCruGs" testmods="clm/FatesSizeAgeMort">
<machines>
<machine name="cheyenne" compiler="intel" category="fates"/>
<machine name="hobart" compiler="nag" category="fates"/>
<machine name="lawrencium-lr3" compiler="intel" category="fates"/>
</machines>
<options>
<option name="wallclock">00:40:00</option>
</options>
</test>
<test name="ERS_Ld60" grid="f45_f45_mg37" compset="I2000Clm50FatesCruGs" testmods="clm/FatesPPhys">
<machines>
<machine name="cheyenne" compiler="intel" category="fates"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../FatesColdDef
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hist_empty_htapes = .true.
use_fates_cohort_age_tracking=.true.
hist_fincl1 = 'M9_SCPF','M10_SCPF','M10_CAPF','NPLANT_CACLS','NPLANT_CAPF', 'M9_SCLS','M10_SCLS','M10_CACLS'
1 change: 1 addition & 0 deletions src/main/clm_varctl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ module clm_varctl
logical, public :: use_fates_spitfire = .false. ! true => use spitfire model
logical, public :: use_fates_logging = .false. ! true => turn on logging module
logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro
logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking
logical, public :: use_fates_ed_st3 = .false. ! true => static stand structure
logical, public :: use_fates_ed_prescribed_phys = .false. ! true => prescribed physiology
logical, public :: use_fates_inventory_init = .false. ! true => initialize fates from inventory
Expand Down
5 changes: 4 additions & 1 deletion src/main/controlMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,12 @@ subroutine control_init( )
namelist /clm_inparm/ fates_paramfile, use_fates, &
use_fates_spitfire, use_fates_logging, &
use_fates_planthydro, use_fates_ed_st3, &
use_fates_cohort_age_tracking, &
use_fates_ed_prescribed_phys, &
use_fates_inventory_init, &
fates_inventory_ctrl_filename, &
fates_parteh_mode


! CLM 5.0 nitrogen flags
namelist /clm_inparm/ use_flexibleCN, use_luna
Expand Down Expand Up @@ -638,6 +639,7 @@ subroutine control_spmd()
call mpi_bcast (use_fates_spitfire, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_logging, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_ed_st3, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_ed_prescribed_phys, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (use_fates_inventory_init, 1, MPI_LOGICAL, 0, mpicom, ier)
Expand Down Expand Up @@ -983,6 +985,7 @@ subroutine control_print ()
write(iulog, *) ' fates_paramfile = ', fates_paramfile
write(iulog, *) ' fates_parteh_mode = ', fates_parteh_mode
write(iulog, *) ' use_fates_planthydro = ', use_fates_planthydro
write(iulog, *) ' use_fates_cohort_age_tracking = ', use_fates_cohort_age_tracking
write(iulog, *) ' use_fates_ed_st3 = ',use_fates_ed_st3
write(iulog, *) ' use_fates_ed_prescribed_phys = ',use_fates_ed_prescribed_phys
write(iulog, *) ' use_fates_inventory_init = ',use_fates_inventory_init
Expand Down
29 changes: 27 additions & 2 deletions src/main/histFileMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module histFileMod
use PatchType , only : patch
use EDTypesMod , only : nclmax
use EDTypesMod , only : nlevleaf
use FatesInterfaceMod , only : nlevsclass, nlevage
use FatesInterfaceMod , only : nlevsclass, nlevage, nlevcoage
use FatesInterfaceMod , only : nlevheight
use EDTypesMod , only : nfsc
use FatesLitterMod , only : ncwd
Expand Down Expand Up @@ -1071,6 +1071,7 @@ subroutine hist_update_hbuf(bounds)
do t = 1,ntapes
!$OMP PARALLEL DO PRIVATE (f, num2d, numdims)
do f = 1,tape(t)%nflds

numdims = tape(t)%hlist(f)%field%numdims

if ( numdims == 1) then
Expand Down Expand Up @@ -1392,6 +1393,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d)
! !USES:
use subgridAveMod , only : p2g, c2g, l2g, p2l, c2l, p2c
use decompMod , only : BOUNDS_LEVEL_PROC
use clm_varctl , only : iulog
!
! !ARGUMENTS:
integer, intent(in) :: t ! tape index
Expand Down Expand Up @@ -1442,6 +1444,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d)
no_snow_behavior = tape(t)%hlist(f)%field%no_snow_behavior
hpindex = tape(t)%hlist(f)%field%hpindex


if (no_snow_behavior /= no_snow_unset) then
! For multi-layer snow fields, build a special output variable that handles
! missing snow layers appropriately
Expand All @@ -1461,6 +1464,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d)
call hist_set_snow_field_2d(field, clmptr_ra(hpindex)%ptr, no_snow_behavior, type1d, &
beg1d, end1d)
else

field => clmptr_ra(hpindex)%ptr(:,1:num2d)
field_allocated = .false.
end if
Expand Down Expand Up @@ -2066,17 +2070,20 @@ subroutine htape_create (t, histrest)
call ncd_defdim(lnfid, 'scale_type_string_length', scale_type_strlen, dimid)
call ncd_defdim( lnfid, 'levdcmp', nlevdecomp_full, dimid)


if(use_fates)then
call ncd_defdim(lnfid, 'fates_levscag', nlevsclass * nlevage, dimid)
call ncd_defdim(lnfid, 'fates_levscagpf', nlevsclass * nlevage * numpft_fates, dimid)
call ncd_defdim(lnfid, 'fates_levagepft', nlevage * numpft_fates, dimid)
call ncd_defdim(lnfid, 'fates_levscls', nlevsclass, dimid)
call ncd_defdim(lnfid, 'fates_levcacls', nlevcoage, dimid)
call ncd_defdim(lnfid, 'fates_levpft', numpft_fates, dimid)
call ncd_defdim(lnfid, 'fates_levage', nlevage, dimid)
call ncd_defdim(lnfid, 'fates_levheight', nlevheight, dimid)
call ncd_defdim(lnfid, 'fates_levfuel', nfsc, dimid)
call ncd_defdim(lnfid, 'fates_levcwdsc', ncwd, dimid)
call ncd_defdim(lnfid, 'fates_levscpf', nlevsclass*numpft_fates, dimid)
call ncd_defdim(lnfid, 'fates_levcapf', nlevcoage*numpft_fates, dimid)
call ncd_defdim(lnfid, 'fates_levcan', nclmax, dimid)
call ncd_defdim(lnfid, 'fates_levcnlf', nlevleaf * nclmax, dimid)
call ncd_defdim(lnfid, 'fates_levcnlfpf', nlevleaf * nclmax * numpft_fates, dimid)
Expand Down Expand Up @@ -2500,6 +2507,9 @@ subroutine htape_timeconst(t, mode)
use FatesInterfaceMod, only : fates_hdim_levsclass
use FatesInterfaceMod, only : fates_hdim_pfmap_levscpf
use FatesInterfaceMod, only : fates_hdim_scmap_levscpf
use FatesInterfaceMod, only : fates_hdim_levcoage
use FatesInterfaceMod, only : fates_hdim_pfmap_levcapf
use FatesInterfaceMod, only : fates_hdim_camap_levcapf
use FatesInterfaceMod, only : fates_hdim_levage
use FatesInterfaceMod, only : fates_hdim_levheight
use FatesInterfaceMod, only : fates_hdim_levpft
Expand Down Expand Up @@ -2591,6 +2601,12 @@ subroutine htape_timeconst(t, mode)
long_name='FATES pft index of the combined pft-size class dimension', units='-', ncid=nfid(t))
call ncd_defvar(varname='fates_scmap_levscpf',xtype=ncd_int, dim1name='fates_levscpf', &
long_name='FATES size index of the combined pft-size class dimension', units='-', ncid=nfid(t))
call ncd_defvar(varname='fates_levcacls', xtype=tape(t)%ncprec, dim1name='fates_levcacls', &
long_name='FATES cohort age class lower bound', units='years', ncid=nfid(t))
call ncd_defvar(varname='fates_pftmap_levcapf',xtype=ncd_int, dim1name='fates_levcapf', &
long_name='FATES pft index of the combined pft-cohort age class dimension', units='-', ncid=nfid(t))
call ncd_defvar(varname='fates_camap_levcapf',xtype=ncd_int, dim1name='fates_levcapf', &
long_name='FATES cohort age index of the combined pft-cohort age dimension', units='-', ncid=nfid(t))
call ncd_defvar(varname='fates_levage',xtype=tape(t)%ncprec, dim1name='fates_levage', &
long_name='FATES patch age (yr)', ncid=nfid(t))
call ncd_defvar(varname='fates_levheight',xtype=tape(t)%ncprec, dim1name='fates_levheight', &
Expand Down Expand Up @@ -2655,8 +2671,11 @@ subroutine htape_timeconst(t, mode)
call ncd_io(varname='fates_scmap_levscag',data=fates_hdim_scmap_levscag, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_agmap_levscag',data=fates_hdim_agmap_levscag, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_levscls',data=fates_hdim_levsclass, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_levcacls',data=fates_hdim_levcoage, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_pftmap_levscpf',data=fates_hdim_pfmap_levscpf, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_scmap_levscpf',data=fates_hdim_scmap_levscpf, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_pftmap_levcapf',data=fates_hdim_pfmap_levcapf, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_camap_levcapf',data=fates_hdim_camap_levcapf, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_levage',data=fates_hdim_levage, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_levheight',data=fates_hdim_levheight, ncid=nfid(t), flag='write')
call ncd_io(varname='fates_levpft',data=fates_hdim_levpft, ncid=nfid(t), flag='write')
Expand Down Expand Up @@ -4910,6 +4929,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out,
num2d = nlevdecomp_full
case ('fates_levscls')
num2d = nlevsclass
case('fates_levcacls')
num2d = nlevcoage
case ('fates_levpft')
num2d = numpft_fates
case ('fates_levage')
Expand All @@ -4922,6 +4943,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out,
num2d = ncwd
case ('fates_levscpf')
num2d = nlevsclass*numpft_fates
case ('fates_levcapf')
num2d = nlevcoage*numpft_fates
case ('fates_levscag')
num2d = nlevsclass*nlevage
case ('fates_levscagpf')
Expand Down Expand Up @@ -4974,8 +4997,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out,
end select

! History buffer pointer

hpindex = pointer_index()


if (present(ptr_lnd)) then
l_type1d = grlnd
Expand All @@ -4991,6 +5014,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out,
l_type1d = namel
l_type1d_out = namel
clmptr_ra(hpindex)%ptr => ptr_lunit

if (present(set_lake)) then
do l = bounds%begl,bounds%endl
if (lun%lakpoi(l)) ptr_lunit(l,:) = set_lake
Expand Down Expand Up @@ -5056,6 +5080,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out,
l_type1d = namep
l_type1d_out = namep
clmptr_ra(hpindex)%ptr => ptr_patch

if (present(set_lake)) then
do p = bounds%begp,bounds%endp
l =patch%landunit(p)
Expand Down
24 changes: 22 additions & 2 deletions src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module CLMFatesInterfaceMod
use clm_varctl , only : fates_parteh_mode
use clm_varctl , only : use_fates_spitfire
use clm_varctl , only : use_fates_planthydro
use clm_varctl , only : use_fates_cohort_age_tracking
use clm_varctl , only : use_fates_ed_st3
use clm_varctl , only : use_fates_ed_prescribed_phys
use clm_varctl , only : use_fates_logging
Expand Down Expand Up @@ -244,6 +245,7 @@ subroutine init(this, bounds_proc )
integer :: pass_ed_prescribed_phys
integer :: pass_logging
integer :: pass_planthydro
integer :: pass_cohort_age_tracking
integer :: pass_inventory_init
integer :: pass_is_restart
integer :: nc ! thread index
Expand Down Expand Up @@ -339,6 +341,13 @@ subroutine init(this, bounds_proc )
end if
call set_fates_ctrlparms('use_planthydro',ival=pass_planthydro)

if(use_fates_cohort_age_tracking) then
pass_cohort_age_tracking = 1
else
pass_cohort_age_tracking = 0
end if
call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking)

if(use_fates_logging) then
pass_logging = 1
else
Expand Down Expand Up @@ -1946,6 +1955,7 @@ subroutine init_history_io(this,bounds_proc)
use FatesIOVariableKindMod, only : patch_r8, patch_ground_r8, patch_size_pft_r8
use FatesIOVariableKindMod, only : site_r8, site_ground_r8, site_size_pft_r8
use FatesIOVariableKindMod, only : site_size_r8, site_pft_r8, site_age_r8
use FatesIOVariableKindMod, only : site_coage_r8, site_coage_pft_r8
use FatesIOVariableKindMod, only : site_fuel_r8, site_cwdsc_r8, site_scag_r8
use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8
use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8
Expand Down Expand Up @@ -2081,12 +2091,15 @@ subroutine init_history_io(this,bounds_proc)
ptr_patch=this%fates_hist%hvars(ivar)%r82d, &
default=trim(vdefault))


case(site_ground_r8, site_size_pft_r8, site_size_r8, site_pft_r8, &
site_age_r8, site_height_r8, site_fuel_r8, site_cwdsc_r8, &
site_age_r8, site_height_r8, site_coage_r8,site_coage_pft_r8, &
site_fuel_r8, site_cwdsc_r8, &
site_can_r8,site_cnlf_r8, site_cnlfpft_r8, site_scag_r8, &
site_scagpft_r8, site_agepft_r8, site_elem_r8, site_elpft_r8, &
site_elcwd_r8, site_elage_r8)


d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index
dim2name = this%fates_hist%dim_bounds(d_index)%name
call hist_addfld2d(fname=trim(vname),units=trim(vunits), &
Expand All @@ -2102,6 +2115,7 @@ subroutine init_history_io(this,bounds_proc)
end select

end associate

end do
end subroutine init_history_io

Expand Down Expand Up @@ -2335,7 +2349,7 @@ end subroutine wrap_hydraulics_drive
subroutine hlm_bounds_to_fates_bounds(hlm, fates)

use FatesIODimensionsMod, only : fates_bounds_type
use FatesInterfaceMod, only : nlevsclass, nlevage
use FatesInterfaceMod, only : nlevsclass, nlevage, nlevcoage
use FatesInterfaceMod, only : nlevheight
use EDtypesMod, only : nfsc
use FatesLitterMod, only : ncwd
Expand Down Expand Up @@ -2366,6 +2380,12 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates)
fates%size_class_begin = 1
fates%size_class_end = nlevsclass

fates%coagepf_class_begin = 1
fates%coagepf_class_end = nlevcoage * numpft_fates

fates%coage_class_begin = 1
fates%coage_class_end = nlevcoage

fates%pft_class_begin = 1
fates%pft_class_end = numpft_fates

Expand Down

0 comments on commit 0d93237

Please sign in to comment.