Skip to content

Commit

Permalink
Merge branch 'soil_texture_interp_bug'
Browse files Browse the repository at this point in the history
Soil texture interpolation bug-fix

When assigning soil texture values from dataset soil levels to model
soil levels, we should be comparing zsoi (NOT zisoi) in the model with
zisoi on the file, i.e. we should be asking whether the node
center (NOT interface) of a given model level falls between two
interface depths on the file.

Resolves #772
  • Loading branch information
billsacks committed Aug 22, 2019
2 parents efca2bd + 167c4d6 commit 53a0ea2
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 22 deletions.
9 changes: 1 addition & 8 deletions cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1668,17 +1668,10 @@
<test name="SMS_D_Ld10" grid="f10_f10_musgs" compset="I2000Clm50BgcCropGs" testmods="clm/tracer_consistency">
<machines>

<machine name="hobart" compiler="nag" category="aux_clm">
<machine name="hobart" compiler="intel" category="aux_clm">
<options>
<option name="wallclock">0:30:00</option>
<option name="comment">Include a tracer consistency check in debug mode.</option>
<!-- There is a memory growth of about 12% over this 10-day
test, just with nag. This may be a real issue, or it may
be a compiler issue. For now, since there's a chance it's
just a compiler issue, we're allowing this level of
memory leak. See
https://github.com/ESCOMP/ctsm/issues/763 for details. -->
<option name="memleak_tolerance">0.3</option>
</options>
</machine>

Expand Down
122 changes: 122 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,126 @@
===============================================================
Tag name: ctsm1.0.dev058
Originator(s): slevis (Samuel Levis,SLevis Consulting LLC,303-665-1310)
Date: Thu Aug 22 10:02:49 MDT 2019
One-line Summary: Soil texture interpolation bug-fix

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

When assigning soil texture values from dataset soil levels to model
soil levels, we should be comparing zsoi (NOT zisoi) in the model with
zisoi on the file, i.e. we should be asking whether the node
center (NOT interface) of a given model level falls between two
interface depths on the file.


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

Issues fixed (include CTSM Issue #): #772


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

[ ] 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: 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:
Unexpected failure of test
SMS_D_Ld10.f10_f10_musgs.I2000Clm50BgcCropGs.hobart_nag.clm-tracer_consistency
Bill Sacks did some follow-up testing and concluded that this may be a
compiler-specific issue, so he changed the test from "nag" to "intel"
and generated the new test's corresponding baseline

Code reviewed by: @billsacks


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

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


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

Changes answers relative to baseline:

Summarize any changes to answers, i.e.,
- what code configurations: not clm45
- what platforms/compilers: all
- nature of change: larger than roundoff/same climate
based on the assumption that shifting soil texture assignments by
one level in model soil levels below the top-most level should not
generate climate-changing differences.

Detailed list of changes
------------------------
1. Changed zisoi to zsoi as described in the Purpose section above.
This caused the larger than roundoff changes. Before the fix some
model soil levels were getting assigned soil textures from a deeper
soil level in the dataset than they should.
2. In the same section of code I completed the if-block to address all
zsoi vs. zisoifl comparisons. This ensures explicit assignment of
soil textures for all model soil levels and avoids leaving some
model soil levels with the texture assignment of the previous model
soil level.

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

===============================================================
===============================================================
Tag name: ctsm1.0.dev057
Originator(s): sacks (Bill Sacks)
Date: Tue Aug 20 13:17:39 MDT 2019
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.dev058 slevis 08/22/2019 Soil texture interpolation bug-fix
ctsm1.0.dev057 sacks 08/20/2019 Fix frac_sno bugs
ctsm1.0.dev056 sacks 08/16/2019 Start adding water tracers to LakeHydrology, and related refactoring
ctsm1.0.dev055 sacks 08/06/2019 Modularize snow cover fraction method
Expand Down
50 changes: 36 additions & 14 deletions src/biogeophys/SoilStateInitTimeConstMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ subroutine SoilStateInitTimeConst(bounds, soilstate_inst, nlfilename)
integer :: begp, endp
integer :: begc, endc
integer :: begg, endg
integer :: found ! flag that equals 0 if not found and 1 if found
!-----------------------------------------------------------------------

begp = bounds%begp; endp= bounds%endp
Expand Down Expand Up @@ -366,25 +367,46 @@ subroutine SoilStateInitTimeConst(bounds, soilstate_inst, nlfilename)
else

do lev = 1,nlevgrnd
! Top-most model soil level corresponds to dataset's top-most soil
! level regardless of corresponding depths
if (lev .eq. 1) then
clay = clay3d(g,1)
sand = sand3d(g,1)
om_frac = organic3d(g,1)/organic_max
else if (lev <= nlevsoi) then
do j = 1,nlevsoifl-1
! NOTE(wjs, 2019-08-01) It appears that the code currently doesn't set
! clay, sand and om_frac explicitly under some conditions. It probably
! should. My understanding is that currently things work okay, though,
! because clay, sand and om_frac will remain set at their previous
! values, which is probably reasonable enough. See also
! <https://github.com/ESCOMP/ctsm/pull/771#discussion_r309509596>.
if (zisoi(lev) > zisoifl(j) .AND. zisoi(lev) <= zisoifl(j+1)) then
clay = clay3d(g,j+1)
sand = sand3d(g,j+1)
om_frac = organic3d(g,j+1)/organic_max
endif
end do
else
found = 0 ! reset value
if (zsoi(lev) <= zisoifl(1)) then
! Search above the dataset's range of zisoifl depths
clay = clay3d(g,1)
sand = sand3d(g,1)
om_frac = organic3d(g,1)/organic_max
found = 1
else if (zsoi(lev) > zisoifl(nlevsoifl)) then
! Search below the dataset's range of zisoifl depths
clay = clay3d(g,nlevsoifl)
sand = sand3d(g,nlevsoifl)
om_frac = organic3d(g,nlevsoifl)/organic_max
found = 1
else
! For remaining model soil levels, search within dataset's
! range of zisoifl values. Look for model node depths
! that are between the dataset's interface depths.
do j = 1,nlevsoifl-1
if (zsoi(lev) > zisoifl(j) .AND. zsoi(lev) <= zisoifl(j+1)) then
clay = clay3d(g,j+1)
sand = sand3d(g,j+1)
om_frac = organic3d(g,j+1)/organic_max
found = 1
endif
if (found == 1) exit ! no need to stay in the loop
end do
end if
! If not found, then something's wrong
if (found == 0) then
write(iulog,*) 'For model soil level =', lev
call endrun(msg="ERROR finding a soil dataset depth to interpolate the model depth to"//errmsg(sourcefile, __LINE__))
end if
else ! if lev > nlevsoi
clay = clay3d(g,nlevsoifl)
sand = sand3d(g,nlevsoifl)
om_frac = 0._r8
Expand Down

0 comments on commit 53a0ea2

Please sign in to comment.