Skip to content

Commit

Permalink
Merge branch 'find_soil_layer'
Browse files Browse the repository at this point in the history
Change hard-coded soil layers in phenology to use a target depth

Adds infrastructure for finding the soil layer containing a given depth
(covered by unit tests).

In phenology code, replaces hard-coded level 3 with a target soil
depth. This value is read from the parameter file. The default value is
set in a way that is bit-for-bit for standard CLM45 and CLM50
configurations, but this will change answers for non-SP configurations
using the NWP soil layer structure or non-standard soil layer
structures.

This is important for the sake of supporting flexible soil layers, as in
the NWP configuration.

Also, some cleanup of the CNPhenology parameter reading code.

Resolves ESCOMP#952
  • Loading branch information
billsacks committed Apr 6, 2020
2 parents 384c726 + 2a48f6b commit 9e25889
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 79 deletions.
4 changes: 2 additions & 2 deletions bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ 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_0">lnd/clm2/paramdata/clm5_params.c190829.nc</paramfile>
<paramfile phys="clm4_5">lnd/clm2/paramdata/clm_params.c190829.nc</paramfile>
<paramfile phys="clm5_0">lnd/clm2/paramdata/clm5_params.c200402.nc</paramfile>
<paramfile phys="clm4_5">lnd/clm2/paramdata/clm_params.c200402.nc</paramfile>

<!-- ================================================================== -->
<!-- FATES default parameter file -->
Expand Down
148 changes: 148 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,152 @@
===============================================================
Tag name: ctsm1.0.dev087
Originator(s): sacks (Bill Sacks)
Date: Mon Apr 6 11:23:51 MDT 2020
One-line Summary: Change hard-coded soil layers in phenology to use a target depth

Purpose of changes
------------------

Adds infrastructure for finding the soil layer containing a given depth
(covered by unit tests).

In phenology code, replaces hard-coded level 3 with a target soil
depth. This value is read from the parameter file. The default value is
set in a way that is bit-for-bit for standard CLM45 and CLM50
configurations, but this will change answers for non-SP configurations
using the NWP soil layer structure or non-standard soil layer
structures.

This is important for the sake of supporting flexible soil layers, as in
the NWP configuration.

Also, some cleanup of the CNPhenology parameter reading code.


Bugs fixed or introduced
------------------------

Issues fixed (include CTSM Issue #):
- Resolves ESCOMP/ctsm#952 (Change hard coded soil layers in phenology
to use a target depth)


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.)

[Put an [X] in the box for any configuration with significant answer changes.]

[ ] clm5_0

[X] ctsm5_0-nwp -- only for non-SP cases

[ ] clm4_5

Notes of particular relevance for users
---------------------------------------

Caveats for users (e.g., need to interpolate initial conditions): none

Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): none

Changes made to namelist defaults (e.g., changed parameter values): none

Changes to the datasets (e.g., parameter, surface or initial files):
- New parameter added to NetCDF parameter file: phenology_soil_depth

Substantial timing or memory changes: none expected (not checked)

Notes of particular relevance for developers: (including Code reviews and testing)
---------------------------------------------
NOTE: Be sure to review the steps in README.CHECKLIST.master_tags as well as the coding style in the Developers Guide

Caveats for developers (e.g., code that is duplicated that requires double maintenance): none

Changes to tests or testing: none

Code reviewed by: Erik Kluzek


CTSM testing:

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

build-namelist tests:

cheyenne - not run

tools-tests (test/tools):

cheyenne - not run

PTCLM testing (tools/shared/PTCLM/test):

cheyenne - not run

python testing (see instructions in python/README.md; document testing done):

(any machine) - not run

regular tests (aux_clm):

cheyenne ---- ok
izumi ------- pass

ok means tests pass, a few answer changes as expected

If the tag used for baseline comparisons was NOT the previous tag, note that here:


Answer changes
--------------

Changes answers relative to baseline:

If a tag changes answers relative to baseline comparison the
following should be filled in (otherwise remove this section):

Summarize any changes to answers, i.e.,
- what code configurations: Non-SP cases with NWP or non-standard
soil layer structures
- what platforms/compilers: all
- nature of change (roundoff; larger than roundoff/same climate; new climate):
larger than roundoff; same vs. new climate not investigated

Differences in non-SP cases with soil layer structure different
from that of standard clm45 or clm50. Differences observed in
tests
ERS_D_Ld3.f10_f10_musgs.I2000Clm50BgcCruGs.cheyenne_intel.clm-deepsoil_bedrock
and
SOILSTRUCTUD_Ld5.f10_f10_musgs.I2000Clm50BgcCropGs.cheyenne_intel.clm-default.

ERP_P36x2_D_Ld5.f10_f10_musgs.I2000Ctsm50NwpBgcCropGswpGs.cheyenne_intel.clm-default
had no differences; I'm guessing this is just because there didn't
happen to be the appropriate PFTs present to show differences in
this short, coarse-resolution test.

If bitwise differences were observed, how did you show they were no worse
than roundoff? N/A

If this tag changes climate describe the run(s) done to evaluate the new
climate (put details of the simulations in the experiment database)
- casename: N/A

URL for LMWG diagnostics output used to validate new climate: N/A


Detailed list of changes
------------------------

List any externals directories updated (cime, rtm, mosart, cism, fates, etc.): none

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

===============================================================
===============================================================
Tag name: ctsm1.0.dev086
Originator(s): mvertens (Mariana Vertenstein)
Date: Thu Mar 19 16:03:26 MDT 2020
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
============================================================================================================================
ctsm1.0.dev087 sacks 04/06/2020 Change hard-coded soil layers in phenology to use a target depth
ctsm1.0.dev086 mvertens 03/19/2020 Updates to NUOPC cap and minor fixes to ncdio_pio
ctsm1.0.dev085 sacks 03/16/2020 Update cime
ctsm1.0.dev084 negins 02/19/2020 Bounds assertion for C isotopes when threading is on
Expand Down
98 changes: 28 additions & 70 deletions src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ module CNPhenologyMod
use pftconMod , only : pftcon
use SoilStateType , only : soilstate_type
use TemperatureType , only : temperature_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use Wateratm2lndBulkType , only : wateratm2lndbulk_type
use ColumnType , only : col
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use Wateratm2lndBulkType , only : wateratm2lndbulk_type
use initVerticalMod , only : find_soil_layer_containing_depth
use ColumnType , only : col
use GridcellType , only : grc
use PatchType , only : patch
use atm2lndType , only : atm2lnd_type
use atm2lndType , only : atm2lnd_type
!
implicit none
private
Expand All @@ -59,6 +59,7 @@ module CNPhenologyMod
real(r8) :: crit_offset_swi ! critical number of water stress days to initiate offset
real(r8) :: soilpsi_off ! critical soil water potential for leaf offset
real(r8) :: lwtop ! live wood turnover proportion (annual fraction)
real(r8) :: phenology_soil_depth ! soil depth used for measuring states for phenology triggers
end type params_type

type(params_type) :: params_inst
Expand All @@ -76,6 +77,7 @@ module CNPhenologyMod
real(r8) :: crit_offset_swi ! water stress days for offset trigger
real(r8) :: soilpsi_off ! water potential for offset trigger (MPa)
real(r8) :: lwtop ! live wood turnover proportion (annual fraction)
integer :: phenology_soil_layer ! soil layer used for measuring states for phenology triggers

! CropPhenology variables and constants
real(r8) :: p1d, p1v ! photoperiod factor constants for crop vernalization
Expand Down Expand Up @@ -164,77 +166,29 @@ subroutine readParams ( ncid )
! !DESCRIPTION:
!
! !USES:
use ncdio_pio , only: file_desc_t,ncd_io
use ncdio_pio , only: file_desc_t
use paramUtilMod , only : readNcdioScalar

! !ARGUMENTS:
implicit none
type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id
!
! !LOCAL VARIABLES:
character(len=32) :: subname = 'CNPhenolParamsType'
character(len=100) :: errCode = '-Error reading in parameters file:'
logical :: readv ! has variable been read in or not
real(r8) :: tempr ! temporary to read in parameter
character(len=100) :: tString ! temp. var for reading
character(len=*), parameter :: subname = 'readParams_CNPhenology'
!-----------------------------------------------------------------------

!
! read in parameters
!
tString='crit_dayl'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%crit_dayl=tempr

tString='ndays_on'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%ndays_on=tempr

tString='ndays_off'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%ndays_off=tempr

tString='fstor2tran'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%fstor2tran=tempr

tString='crit_onset_fdd'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%crit_onset_fdd=tempr

tString='crit_onset_swi'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%crit_onset_swi=tempr

tString='soilpsi_on'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%soilpsi_on=tempr

tString='crit_offset_fdd'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%crit_offset_fdd=tempr

tString='crit_offset_swi'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%crit_offset_swi=tempr

tString='soilpsi_off'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%soilpsi_off=tempr

tString='lwtop_ann'
call ncd_io(varname=trim(tString),data=tempr, flag='read', ncid=ncid, readvar=readv)
if ( .not. readv ) call endrun( msg=trim(errCode)//trim(tString)//errMsg(sourcefile, __LINE__))
params_inst%lwtop=tempr
call readNcdioScalar(ncid, 'crit_dayl', subname, params_inst%crit_dayl)
call readNcdioScalar(ncid, 'ndays_on', subname, params_inst%ndays_on)
call readNcdioScalar(ncid, 'ndays_off', subname, params_inst%ndays_off)
call readNcdioScalar(ncid, 'fstor2tran', subname, params_inst%fstor2tran)
call readNcdioScalar(ncid, 'crit_onset_fdd', subname, params_inst%crit_onset_fdd)
call readNcdioScalar(ncid, 'crit_onset_swi', subname, params_inst%crit_onset_swi)
call readNcdioScalar(ncid, 'soilpsi_on', subname, params_inst%soilpsi_on)
call readNcdioScalar(ncid, 'crit_offset_fdd', subname, params_inst%crit_offset_fdd)
call readNcdioScalar(ncid, 'crit_offset_swi', subname, params_inst%crit_offset_swi)
call readNcdioScalar(ncid, 'soilpsi_off', subname, params_inst%soilpsi_off)
call readNcdioScalar(ncid, 'lwtop_ann', subname, params_inst%lwtop)
call readNcdioScalar(ncid, 'phenology_soil_depth', subname, params_inst%phenology_soil_depth)

end subroutine readParams

Expand Down Expand Up @@ -376,6 +330,10 @@ subroutine CNPhenologyInit(bounds)
! set transfer parameters
fstor2tran=params_inst%fstor2tran

call find_soil_layer_containing_depth( &
depth = params_inst%phenology_soil_depth, &
layer = phenology_soil_layer)

! -----------------------------------------
! Constants for CNStressDecidPhenology
! -----------------------------------------
Expand Down Expand Up @@ -903,7 +861,7 @@ subroutine CNSeasonDecidPhenology (num_soilp, filter_soilp , &
! if the gdd flag is set, and if the soil is above freezing
! then accumulate growing degree days for onset trigger

soilt = t_soisno(c,3)
soilt = t_soisno(c, phenology_soil_layer)
if (onset_gddflag(p) == 1.0_r8 .and. soilt > SHR_CONST_TKFRZ) then
onset_gdd(p) = onset_gdd(p) + (soilt-SHR_CONST_TKFRZ)*fracday
end if
Expand Down Expand Up @@ -1120,8 +1078,8 @@ subroutine CNStressDecidPhenology (num_soilp, filter_soilp , &
g = patch%gridcell(p)

if (stress_decid(ivt(p)) == 1._r8) then
soilt = t_soisno(c,3)
psi = soilpsi(c,3)
soilt = t_soisno(c, phenology_soil_layer)
psi = soilpsi(c, phenology_soil_layer)

! onset gdd sum from Biome-BGC, v4.1.2
crit_onset_gdd = exp(4.8_r8 + 0.13_r8*(annavg_t2m(p) - SHR_CONST_TKFRZ))
Expand Down
1 change: 1 addition & 0 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ list(APPEND clm_sources
glc2lndMod.F90
glcBehaviorMod.F90
initSubgridMod.F90
initVerticalMod.F90
landunit_varcon.F90
lnd2glcMod.F90
ncdio_utils.F90
Expand Down
Loading

0 comments on commit 9e25889

Please sign in to comment.