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

Reduce duplication between caps #1086

Merged
merged 17 commits into from
Sep 25, 2020
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
1 change: 1 addition & 0 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def _main_func():
os.path.join(lnd_root,"src","fates","parteh"),
os.path.join(lnd_root,"src","utils"),
os.path.join(lnd_root,"src","cpl"),
os.path.join(lnd_root,"src","cpl","utils"),
os.path.join(lnd_root,"src","cpl",driver)]

if lilac_mode == 'on':
Expand Down
128 changes: 128 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,132 @@
===============================================================
Tag name: ctsm5.1.dev002
Originator(s): slevis (Samuel Levis,303-665-1310)
Date: Mon Sep 25 09:39:19 MDT 2020
One-line Summary: Reduce duplication between caps

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

Eliminate duplication of the "derived quantities for required fields"
and corresponding error checking codes that repeat across the mct,
nuopc, and lilac caps. This consolidates the code and reduces
maintenance requirements.


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

Issues fixed (include CTSM Issue #): #918 #1094


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

[X] clm5_0

[X] ctsm5_0-nwp

[X] 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): None

Substantial timing or memory changes: [For timing changes, can check PFS test(s) in the test suite] None

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: @billsacks @slevisconsulting


CTSM testing:

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

build-namelist tests:

cheyenne -

tools-tests (test/tools):

cheyenne -

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

cheyenne -

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

(any machine) -

regular tests (aux_clm):

cheyenne ---- OK
izumi ------- PASS

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: All
- what platforms/compilers: All
- nature of change: Larger than roundoff/same climate


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

Changes were implemented in three steps:

1) Bit-for-bit: @billsacks simplified subroutine QSat by making three
arguments optional (es, qsdT, esdT).

2) Answer-changing: @slevisconsulting replaced local calculations of
qsat in /src/cpl/mct, /src/cpl/lilac, and /src/cpl/nuopc with calls to
CTSM's subroutine QSat. Subroutine QSat uses a higher-order polynomial
approximation to estimate qsat, which explains the larger than
round-off diffs. When moving the three identical local approximations
to QSat as a temporary test instead of using the higher-order
polynomial approximation, the diffs reduce to round-off.

3) Bit-for-bit: @slevisconsulting consolidated repeating codes in
/src/cpl/mct, /src/cpl/lilac, and /src/cpl/nuopc by placing in the new
file /src/utils/lnd_import_export_utils.F90.

List any externals directories updated (cime, rtm, mosart, cism, fates, etc.):
Modified code in /src/cpl @billsacks IS THAT CONSIDERED AN EXTERNAL DIRECTORY?

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

===============================================================
===============================================================
Tag name: ctsm5.1.dev001
Originator(s): erik (Erik Kluzek,UCAR/TSS,303-497-1326)
Date: Wed Sep 23 02:29:08 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
============================================================================================================================
ctsm5.1.dev002 slevis 09/25/2020 Reduce duplication between caps
ctsm5.1.dev001 erik 09/23/2020 Start the clm5_1 physics series, with some changes to the fire model from Fang Li
ctsm1.0.dev113 negins 09/08/2020 Some bit-for-bit changes needed for the Perturbed Parameter Ensemble work
ctsm1.0.dev112 sacks/ww 08/28/2020 Small changes to mksurfdata_map, singlept tool and run_sys_tests
Expand Down
5 changes: 2 additions & 3 deletions src/biogeophys/BareGroundFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ subroutine BareGroundFluxes(bounds, num_noexposedvegp, filter_noexposedvegp, &
real(r8) :: z0hg_patch(bounds%begp:bounds%endp)
real(r8) :: z0qg_patch(bounds%begp:bounds%endp)
real(r8) :: e_ref2m ! 2 m height surface saturated vapor pressure [Pa]
real(r8) :: de2mdT ! derivative of 2 m height surface saturated vapor pressure on t_ref2m
real(r8) :: qsat_ref2m ! 2 m height surface saturated specific humidity [kg/kg]
real(r8) :: dqsat2mdT ! derivative of 2 m height surface saturated specific humidity on t_ref2m
real(r8) :: www ! surface soil wetness [-]
!------------------------------------------------------------------------------

Expand Down Expand Up @@ -419,7 +417,8 @@ subroutine BareGroundFluxes(bounds, num_noexposedvegp, filter_noexposedvegp, &
q_ref2m(p) = forc_q(c) + temp2(p)*dqh(p)*(1._r8/temp22m(p) - 1._r8/temp2(p))

! 2 m height relative humidity
call QSat(t_ref2m(p), forc_pbot(c), e_ref2m, de2mdT, qsat_ref2m, dqsat2mdT)
call QSat(t_ref2m(p), forc_pbot(c), qsat_ref2m, &
es = e_ref2m)

rh_ref2m(p) = min(100._r8, q_ref2m(p) / qsat_ref2m * 100._r8)

Expand Down
14 changes: 8 additions & 6 deletions src/biogeophys/CanopyFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,10 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp,
real(r8) :: wtalq(bounds%begp:bounds%endp) ! normalized latent heat cond. for air and leaf [-]
real(r8) :: wtgaq ! normalized latent heat cond. for air and ground [-]
real(r8) :: el(bounds%begp:bounds%endp) ! vapor pressure on leaf surface [pa]
real(r8) :: deldT ! derivative of "el" on "t_veg" [pa/K]
real(r8) :: qsatl(bounds%begp:bounds%endp) ! leaf specific humidity [kg/kg]
real(r8) :: qsatldT(bounds%begp:bounds%endp) ! derivative of "qsatl" on "t_veg"
real(r8) :: e_ref2m ! 2 m height surface saturated vapor pressure [Pa]
real(r8) :: de2mdT ! derivative of 2 m height surface saturated vapor pressure on t_ref2m
real(r8) :: qsat_ref2m ! 2 m height surface saturated specific humidity [kg/kg]
real(r8) :: dqsat2mdT ! derivative of 2 m height surface saturated specific humidity on t_ref2m
real(r8) :: air(bounds%begp:bounds%endp) ! atmos. radiation temporay set
real(r8) :: bir(bounds%begp:bounds%endp) ! atmos. radiation temporay set
real(r8) :: cir(bounds%begp:bounds%endp) ! atmos. radiation temporay set
Expand Down Expand Up @@ -741,7 +738,9 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp,
! Saturated vapor pressure, specific humidity, and their derivatives
! at the leaf surface

call QSat (t_veg(p), forc_pbot(c), el(p), deldT, qsatl(p), qsatldT(p))
call QSat (t_veg(p), forc_pbot(c), qsatl(p), &
es = el(p), &
qsdT = qsatldT(p))

! Determine atmospheric co2 and o2

Expand Down Expand Up @@ -1110,7 +1109,9 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp,
! Re-calculate saturated vapor pressure, specific humidity, and their
! derivatives at the leaf surface

call QSat(t_veg(p), forc_pbot(c), el(p), deldT, qsatl(p), qsatldT(p))
call QSat(t_veg(p), forc_pbot(c), qsatl(p), &
es = el(p), &
qsdT = qsatldT(p))

! Update vegetation/ground surface temperature, canopy air
! temperature, canopy vapor pressure, aerodynamic temperature, and
Expand Down Expand Up @@ -1229,7 +1230,8 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp,

! 2 m height relative humidity

call QSat(t_ref2m(p), forc_pbot(c), e_ref2m, de2mdT, qsat_ref2m, dqsat2mdT)
call QSat(t_ref2m(p), forc_pbot(c), qsat_ref2m, &
es = e_ref2m)
rh_ref2m(p) = min(100._r8, q_ref2m(p) / qsat_ref2m * 100._r8)
rh_ref2m_r(p) = rh_ref2m(p)

Expand Down
13 changes: 6 additions & 7 deletions src/biogeophys/LakeFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ subroutine LakeFluxes(bounds, num_lakec, filter_lakec, num_lakep, filter_lakep,
integer :: jtop(bounds%begc:bounds%endc) ! top level for each column (no longer all 1)
real(r8) :: ax ! used in iteration loop for calculating t_grnd (numerator of NR solution)
real(r8) :: bx ! used in iteration loop for calculating t_grnd (denomin. of NR solution)
real(r8) :: degdT ! d(eg)/dT
real(r8) :: dqh(bounds%begp:bounds%endp) ! diff of humidity between ref. height and surface
real(r8) :: dth(bounds%begp:bounds%endp) ! diff of virtual temp. between ref. height and surface
real(r8) :: dthv ! diff of vir. poten. temp. between ref. height and surface
real(r8) :: dzsur(bounds%begc:bounds%endc) ! 1/2 the top layer thickness (m)
real(r8) :: eg ! water vapor pressure at temperature T [pa]
real(r8) :: htvp(bounds%begc:bounds%endc) ! latent heat of vapor of water (or sublimation) [j/kg]
real(r8) :: obu(bounds%begp:bounds%endp) ! monin-obukhov length (m)
real(r8) :: obuold(bounds%begp:bounds%endp) ! monin-obukhov length of previous iteration
Expand Down Expand Up @@ -173,9 +171,7 @@ subroutine LakeFluxes(bounds, num_lakec, filter_lakec, num_lakep, filter_lakep,
real(r8) :: t_grnd_temp ! Used in surface flux correction over frozen ground
real(r8) :: betaprime(bounds%begc:bounds%endc) ! Effective beta: sabg_lyr(p,jtop) for snow layers, beta otherwise
real(r8) :: e_ref2m ! 2 m height surface saturated vapor pressure [Pa]
real(r8) :: de2mdT ! derivative of 2 m height surface saturated vapor pressure on t_ref2m
real(r8) :: qsat_ref2m ! 2 m height surface saturated specific humidity [kg/kg]
real(r8) :: dqsat2mdT ! derivative of 2 m height surface saturated specific humidity on t_ref2m
real(r8) :: sabg_nir ! NIR that is absorbed (W/m^2)

! For calculating roughness lengths
Expand Down Expand Up @@ -364,7 +360,8 @@ subroutine LakeFluxes(bounds, num_lakec, filter_lakec, num_lakep, filter_lakep,
! Saturated vapor pressure, specific humidity and their derivatives
! at lake surface

call QSat(t_grnd(c), forc_pbot(c), eg, degdT, qsatg(c), qsatgdT(c))
call QSat(t_grnd(c), forc_pbot(c), qsatg(c), &
qsdT = qsatgdT(c))

! Potential, virtual potential temperature, and wind speed at the
! reference height
Expand Down Expand Up @@ -491,7 +488,8 @@ subroutine LakeFluxes(bounds, num_lakec, filter_lakec, num_lakep, filter_lakep,
! Re-calculate saturated vapor pressure, specific humidity and their
! derivatives at lake surface

call QSat(t_grnd(c), forc_pbot(c), eg, degdT, qsatg(c), qsatgdT(c))
call QSat(t_grnd(c), forc_pbot(c), qsatg(c), &
qsdT = qsatgdT(c))

dth(p)=thm(p)-t_grnd(c)
dqh(p)=forc_q(c)-qsatg(c)
Expand Down Expand Up @@ -643,7 +641,8 @@ subroutine LakeFluxes(bounds, num_lakec, filter_lakec, num_lakep, filter_lakep,

! 2 m height relative humidity

call QSat(t_ref2m(p), forc_pbot(c), e_ref2m, de2mdT, qsat_ref2m, dqsat2mdT)
call QSat(t_ref2m(p), forc_pbot(c), qsat_ref2m, &
es = e_ref2m)
rh_ref2m(p) = min(100._r8, q_ref2m(p) / qsat_ref2m * 100._r8)

! Human Heat Stress
Expand Down
Loading