Skip to content

Commit

Permalink
Merge tag 'ctsm5.1.dev122' into ctsm.newtestgrids
Browse files Browse the repository at this point in the history
Rework handling of evaporation constraint in SoilFluxes

Occasionally, h2osoi_ice was going significantly negative in
UpdateState_TopLayerFluxes - see
ESCOMP#1979. As noted in that issue, this
seems to be due to h2osoi_ice having a very different magnitude from
h2osoi_liq, leading to greater-than-roundoff-level differences from zero
final state in a relative sense (i.e., relative to the magnitude of
h2osoi_ice) - I think because of the appearance of the sum (h2osoi_ice +
h2osoi_liq) in the equations that limit fluxes.

To try to deal with this, I have reworked the handling of the
evaporation constraint to directly limit both the liqevap and solidevap,
so that both of them should result in the equivalent liq or ice states
going to 0 within roundoff.

To do that, I needed to move the partitioning of the total flux into
liquid and solid to earlier in the subroutine and then recalculate those
partitioning fluxes in conditions where we're applying an evaporation
constraint.

Note that I applied a max of 0 to the new fluxes because many initial
conditions files have roundoff-level negative H2OSOI_LIQ, so without
this limit, we were getting roundoff-level negative fluxes.

Resolves ESCOMP#1979
  • Loading branch information
ekluzek committed Apr 27, 2023
2 parents bbe21f4 + cdb6187 commit 7572d07
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 93 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.61.0_api.25.0.0
tag = sci.1.65.3_api.25.4.0
required = True

[externals_description]
Expand Down
2 changes: 1 addition & 1 deletion bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- FATES default parameter file -->
<!-- ================================================================== -->

<fates_paramfile>lnd/clm2/paramdata/fates_params_api.25.0.0_12pft_c221128.nc</fates_paramfile>
<fates_paramfile>lnd/clm2/paramdata/fates_params_api.25.4.0_12pft_c230327.nc</fates_paramfile>

<!-- ======================================================================================== -->
<!-- clm 5.0 BGC nitrogen model -->
Expand Down
7 changes: 0 additions & 7 deletions cime_config/testdefs/ExpectedTestFails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@
</phase>
</test>

<test name="FUNITCTSM_P1x1.f10_f10_mg37.I2000Clm50Sp.cheyenne_intel">
<phase name="RUN">
<status>FAIL</status>
<issue>#1972</issue>
</phase>
</test>

<!-- fates test suite failures -->

<test name="ERS_Lm12.1x1_brazil.I2000Clm50FatesCruRsGs.cheyenne_intel.clm-FatesFireLightningPopDens">
Expand Down
2 changes: 1 addition & 1 deletion cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@
<machine name="cheyenne" compiler="gnu" category="fates"/>
</machines>
<options>
<option name="wallclock">00:40:00</option>
<option name="wallclock">00:50:00</option>
</options>
</test>
<test name="ERS_Lm13" grid="f45_f45_mg37" compset="I2000Clm50Fates" testmods="clm/FatesColdNoComp">
Expand Down
11 changes: 3 additions & 8 deletions doc/.ChangeLog_template
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,10 @@ infrastructure should be run when appropriate, as described below.

clm_pymods test suite on cheyenne -

regular tests:
- aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing
- Fortran unit tests on cheyenne (until https://github.com/ESCOMP/CTSM/issues/1972 is resolved): from src, run:
../cime/scripts/fortran_unit_testing/run_tests.py --build-dir `mktemp -d --tmpdir=. unit_tests.XXXXXXXX`

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

cheyenne ----
izumi -------

fates tests: (give name of baseline if different from CTSM tagname, normally fates baselines are fates-<FATES TAG>-<CTSM TAG>)
cheyenne ----
Expand Down
271 changes: 271 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,275 @@
===============================================================
Tag name: ctsm5.1.dev122
Originator(s): sacks (Bill Sacks)
Date: Sun Apr 23 19:36:37 MDT 2023
One-line Summary: Rework handling of evaporation constraint in SoilFluxes

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

Occasionally, h2osoi_ice was going significantly negative in
UpdateState_TopLayerFluxes - see
https://github.com/ESCOMP/CTSM/issues/1979. As noted in that issue, this
seems to be due to h2osoi_ice having a very different magnitude from
h2osoi_liq, leading to greater-than-roundoff-level differences from zero
final state in a relative sense (i.e., relative to the magnitude of
h2osoi_ice) - I think because of the appearance of the sum (h2osoi_ice +
h2osoi_liq) in the equations that limit fluxes.

To try to deal with this, I have reworked the handling of the
evaporation constraint to directly limit both the liqevap and solidevap,
so that both of them should result in the equivalent liq or ice states
going to 0 within roundoff.

To do that, I needed to move the partitioning of the total flux into
liquid and solid to earlier in the subroutine and then recalculate those
partitioning fluxes in conditions where we're applying an evaporation
constraint.

Note that I applied a max of 0 to the new fluxes because many initial
conditions files have roundoff-level negative H2OSOI_LIQ, so without
this limit, we were getting roundoff-level negative fluxes.

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_1

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


Bugs fixed or introduced
------------------------
CTSM issues fixed (include CTSM Issue #):
- Resolves ESCOMP/CTSM#1979 (Need some changes to avoid negative h2osoi_ice in UpdateState_TopLayerFluxes)


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

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

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

Tests passed, some baseline differences as expected.

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

Changes answers relative to baseline: YES

Summarize any changes to answers, i.e.,
- what code configurations: potentially all
- what platforms/compilers: potentially all
- nature of change (roundoff; larger than roundoff/same climate; new climate):
roundoff

Differences were only observed in a few tests:
- ERP_P36x2_Ld30.f45_f45_mg37.I2000Clm51FatesSpCruRsGs.cheyenne_intel.clm-FatesColdSatPhen
- ERI_D_Ld9_P48x1.T31_g37.I2000Clm50Sp.izumi_nag.clm-reduceOutput
- SMS_D_Ln9_P36x3.f19_g17.IHistClm50Sp.cheyenne_intel.clm-waccmx_offline
- SMS_D_Ln9_P36x3_Vmct.f19_g17.IHistClm50Sp.cheyenne_intel.clm-waccmx_offline

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

Only two tests had greater-than-roundoff-level differences in the
cprnc output:
SMS_D_Ln9_P36x3.f19_g17.IHistClm50Sp.cheyenne_intel.clm-waccmx_offline
and the mct equivalent,
SMS_D_Ln9_P36x3_Vmct.f19_g17.IHistClm50Sp.cheyenne_intel.clm-waccmx_offline.
To verify that differences were fundamentally no greater than
roundoff-level, I introduced temporary code; this minimal diff
ended up being enough to give just roundoff-level differences from baseline:

diff --git a/src/biogeophys/SoilFluxesMod.F90 b/src/biogeophys/SoilFluxesMod.F90
index c316d30fe..6a958c0ee 100644
--- a/src/biogeophys/SoilFluxesMod.F90
+++ b/src/biogeophys/SoilFluxesMod.F90
@@ -45,7 +45,7 @@ subroutine SoilFluxes (bounds, num_urbanl, filter_urbanl, &
! Update surface fluxes based on the new ground temperature
!
! !USES:
- use clm_time_manager , only : get_step_size_real
+ use clm_time_manager , only : get_step_size_real, get_nstep
use clm_varcon , only : hvap, cpair, grav, vkc, tfrz, sb
use landunit_varcon , only : istsoil, istcrop
use column_varcon , only : icol_roof, icol_sunwall, icol_shadewall, icol_road_perv
@@ -79,7 +79,9 @@ subroutine SoilFluxes (bounds, num_urbanl, filter_urbanl, &
real(r8) :: t_grnd0(bounds%begc:bounds%endc) ! t_grnd of previous time step
real(r8) :: lw_grnd
real(r8) :: evaporation_limit ! top layer moisture available for evaporation
- real(r8) :: evaporation_demand ! evaporative demand
+ real(r8) :: evaporation_demand ! evaporative demand
+ real(r8) :: qflx_liqevap_orig
+ real(r8) :: qflx_solidevap_orig
!-----------------------------------------------------------------------

associate( &
@@ -291,6 +293,7 @@ subroutine SoilFluxes (bounds, num_urbanl, filter_urbanl, &
qflx_evap_soi(p) = qflx_evap_soi(p) - frac_sno_eff(c)*(evaporation_demand - evaporation_limit)
qflx_liqevap_from_top_layer(p) = max(h2osoi_liq(c,j)/(frac_sno_eff(c)*dtime), 0._r8)
qflx_solidevap_from_top_layer(p) = max(h2osoi_ice(c,j)/(frac_sno_eff(c)*dtime), 0._r8)
+
! conserve total energy flux
eflx_sh_grnd(p) = eflx_sh_grnd(p) + frac_sno_eff(c)*(evaporation_demand - evaporation_limit)*htvp(c)
endif
@@ -307,6 +310,24 @@ subroutine SoilFluxes (bounds, num_urbanl, filter_urbanl, &
qflx_ev_snow(p) = qflx_evap_soi(p)
qflx_liqevap_from_top_layer(p) = max(h2osoi_liq(c,j)/dtime, 0._r8)
qflx_solidevap_from_top_layer(p) = max(h2osoi_ice(c,j)/dtime, 0._r8)
+
+ if (h2osoi_liq(c,j) + h2osoi_ice(c,j) > 0._r8) then
+ qflx_liqevap_orig = max(qflx_evap_soi(p)*(h2osoi_liq(c,j)/ &
+ (h2osoi_liq(c,j)+h2osoi_ice(c,j))), 0._r8)
+ else
+ qflx_liqevap_orig = 0._r8
+ end if
+ qflx_solidevap_orig = qflx_evap_soi(p) - qflx_liqevap_orig
+ if (qflx_solidevap_from_top_layer(p) == 0._r8 .and. &
+ qflx_solidevap_orig < 0._r8 .and. &
+ qflx_solidevap_orig > -1.e-16_r8) then
+ write(iulog,'(a, i0, 1x, i0, 1x, 5e24.17)') &
+ 'WJS adj urb: solid orig le 0, new 0: nstep, p, orig, new, qflx_evap_soi, h2osoi_liq, h2osoi_ice = ', &
+ get_nstep(), p, qflx_solidevap_orig, qflx_solidevap_from_top_layer(p), &
+ qflx_evap_soi(p), h2osoi_liq(c,j), h2osoi_ice(c,j)
+ qflx_solidevap_from_top_layer(p) = qflx_solidevap_orig
+ end if
+
! conserve total energy flux
eflx_sh_grnd(p) = eflx_sh_grnd(p) +(evaporation_demand -evaporation_limit)*htvp(c)
endif

(Note that the diffs in
ERP_P36x2_Ld30.f45_f45_mg37.I2000Clm51FatesSpCruRsGs.cheyenne_intel.clm-FatesColdSatPhen
were ambiguous as to whether they were roundoff-level due to the
single-precision output in that test; I reran with double precision
for the baseline and the branch and was able to verify that the
diffs were only double-precision roundoff-level.)

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

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

===============================================================
===============================================================
Tag name: ctsm5.1.dev121
Originator(s): glemieux (Gregory Lemieux,LBL/NGEET,510-486-5049)
Date: Wed Apr 5 13:34:09 MDT 2023
One-line Summary: Changes soil moisture initialization logic for FATES

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

This PR changes the logic for soil moisture initialization to initialize
with wetter soils (75% of saturated water content, as opposed to 15% of
absolute water content) for all FATES configurations. The rationale for
this is that in FATES-nocomp simulations, Jessica Needham was finding very
high initial mortality rates in some seasonal tropical forest regions which
she traced it back to the initial soil moisture killing off plants before the
ecosystem could get established.

This also updates the fates externals pointer to the latest tag which includes
a number of science updates since the last tag update and updates the the
default parameter file.

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_1

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


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

Externals issues fixed (include issue #):
Partially addresses FATES#994 -- Bare ground establishment problem and increased soil moisture

Known bugs found since the previous tag (include issue #):
#1979 -- Need to loosen tolerance on near-zero truncation of h2osoi_ice in UpdateState_TopLayerFluxes

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

Changes made to namelist defaults (e.g., changed parameter values):
fates_paramfile updated to fates_params_api.25.4.0_12pft_c230327.nc

Notes of particular relevance for developers:
---------------------------------------------

Caveats for developers (e.g., code that is duplicated that requires double maintenance):
This changes the starting level for a COLD start of soil moisture for ALL FATES cases to a much
higher value than for non-FATES. In the long run we'd like to have these the same and/or
have the value changable on the namelist.

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
izumi ------- OK

fates tests: (give name of baseline if different from CTSM tagname, normally fates baselines are fates-<FATES TAG>-<CTSM TAG>)
cheyenne ---- OK
izumi ------- OK

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

FATES tests run against fates-sci.1.65.3_api.25.4.0-ctsm5.1.dev120 baseline


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

Changes answers relative to baseline:

Changes answers in fates suite for all non-hydro fates tests since the soil
moisture initialization matches that of fates hydro now. Changes answer
for all fates testmods in the aux_clm suite as the science tag has iterated
forward by 4 minor version updates. All diffs accounted for with prior fates
suite tests.

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

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

- FATES: sci.1.61.0_api.25.0.0 -> sci.1.65.3_api.25.4.0

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

https://github.com/ESCOMP/CTSM/pull/1962 -- Cold start moisture for FATES increased
https://github.com/ESCOMP/CTSM/pull/1978 -- revert some commits now that FUNITCTSM works again

===============================================================
===============================================================
Tag name: ctsm5.1.dev120
Originator(s): sacks (Bill Sacks)
Date: Sat Mar 25 17:49:27 MDT 2023
Expand Down
2 changes: 2 additions & 0 deletions doc/ChangeSum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Tag Who Date Summary
============================================================================================================================
ctsm5.1.dev122 sacks 04/23/2023 Rework handling of evaporation constraint in SoilFluxes
ctsm5.1.dev121 glemieux 04/05/2023 Changes soil moisture initialization logic for FATES
ctsm5.1.dev120 sacks 03/25/2023 Update externals and minor fixes
ctsm5.1.dev119 slevis 03/16/2023 Allow gross unrepresented land use transition (PR #309)
ctsm5.1.dev118 slevis 02/05/2023 Use conda environment rather than ncar_pylib with the fsurdat_modifier system test
Expand Down
Loading

0 comments on commit 7572d07

Please sign in to comment.