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

Minor bug in creation of soil color in mksurfdata_map: points can be given the default soil color, when they should have a real color #4

Closed
billsacks opened this issue Dec 16, 2017 · 1 comment
Assignees
Labels
bug something is working incorrectly

Comments

@billsacks
Copy link
Member

Bill Sacks < sacks@ucar.edu > - 2012-01-29 20:29:57 -0700
Bugzilla Id: 1457
Bugzilla CC: mvertens@ucar.edu, rfisher@ucar.edu,

I think there is a bug in mksoilcol in module mksoilMod in mksurfdata_map... I haven't done any testing to confirm this, but the logic looks wrong to me:

The relevant code is copied below.

It looks like the intention is that, in the first do loop, wst(0,no) should be 0 if there is ever a non-zero color in this output cell. However, it seems there is an unintentional order dependence here: Consider the following two cases, showing the colors in input grid cells corresponding to a single output grid cell; assume for simplicity that all weights are 0.25:

(1) 0, 0, 0, 1

(2) 1, 0, 0, 0

In case (1), wst(0,no) will be correctly set to 0.0 when the 1 value is read. This will result in soil_color_o = 1.

In case (2), wst(0,no) will be set to 0.0 at first, but upon reading the three 0 values, wst(0,no) will become 0.75. This will result in soil_color_o = 0, which will later be changed to either 4 or 15.

So, if I'm correct in my interpretation of this algorithm, soil_color_o sometimes depends on the order in which values appear in the source grid cells!

 do n = 1,tgridmap%ns
    ni = tgridmap%src_indx(n)
    no = tgridmap%dst_indx(n)
    wt = tgridmap%wovr(n)
    k  = soil_color_i(ni) * tdomain%mask(ni)
    wst(k,no) = wst(k,no) + wt
    if (k>0 .and. wst(k,no)>0.) then
       color(no) = 1
       wst(0,no) = 0.0
    end if
 enddo

 soil_color_o(:) = 0
 do no = 1,ns_o

    ! Rank non-zero weights by color type. wsti(1) is the most extensive
    ! color type. 

    if (color(no) == 1) then
       call mkrank (nsoicol, wst(0:nsoicol,no), miss, wsti, num)
       soil_color_o(no) = wsti(1)
    end if

    ! If land but no color, set color to 15 (in older dataset generic 
    ! soil color 4)
    
    if (nsoicol == 8) then
       if (soil_color_o(no)==0) soil_color_o(no) = 4
    else if (nsoicol == 20) then
       if (soil_color_o(no)==0) soil_color_o(no) = 15
    end if
@billsacks billsacks added this to the clm5 milestone Dec 16, 2017
@billsacks billsacks removed this from the clm5 milestone Nov 7, 2018
@billsacks billsacks added tag: bug - impacts science bug something is working incorrectly and removed type: bug - impacts science labels May 24, 2019
@billsacks billsacks changed the title minor bug (I think) in creation of soil color in mksurfdata_map Minor bug in creation of soil color in mksurfdata_map: points can be given soil color 0, when they should have a real color Jul 1, 2019
billsacks added a commit to billsacks/ctsm that referenced this issue Jul 1, 2019
Add a unit test that exposes the bug in ESCOMP#4 - in some cases,
points are given soil color 0 when they should be given a real
color. Also change code to fix this bug. (The new unit test fails
without the changes in mksoilUtilsMod.F90.)

(Addresses ESCOMP#4, but fully fixing that issue will require
recreating all surface datasets.)
@billsacks billsacks added next this should get some attention in the next week or two. Normally each Thursday SE meeting. and removed tag: bug - impacts science labels Jul 2, 2019
@billsacks
Copy link
Member Author

I have verified that this is, indeed, a bug by isolating the relevant logic and wrapping it in a unit test (74b69e3). However, this has absolutely no impact on a 1-degree surface dataset (./mksurfdata.pl -no-crop -glc_nec 10 -y 1850 -res 0.9x1.25). Now that I understand the nature of the bug, I am not surprised by that finding: I think this will only change the outcome in uncommon circumstances (maybe more common for high-resolution datasets?).

@billsacks billsacks changed the title Minor bug in creation of soil color in mksurfdata_map: points can be given soil color 0, when they should have a real color Minor bug in creation of soil color in mksurfdata_map: points can be given the default soil color, when they should have a real color Jul 2, 2019
@billsacks billsacks self-assigned this Jul 10, 2019
@billsacks billsacks removed the next this should get some attention in the next week or two. Normally each Thursday SE meeting. label Jul 10, 2019
@ekluzek ekluzek mentioned this issue Aug 21, 2019
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
Added disturbance index names and partial addition of logging NL entry
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
Update to 10/10/2017 release
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
Bring in sci.1.3.1_api.2.0.0 from ngeet/fates-release
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
Sla and nitrogen profiles are now scaled by leaf area alone. SAI is based on target leaf area.
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
…to_merge

code-cleaning and store-to-repro during disturbance inducing mortality
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
fire mortality -- restart diagnostics
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
small fixes related to degredation and CWD/disturbance fluxes
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
updates to python scripts to work with new parameter files
billsacks referenced this issue in billsacks/ctsm Apr 15, 2020
MiCurry pushed a commit to MiCurry/CTSM that referenced this issue Sep 16, 2021
billsacks pushed a commit that referenced this issue Dec 14, 2021
Store netCDF files via Git LFS
billsacks added a commit that referenced this issue Jan 30, 2022
negin513 added a commit that referenced this issue Feb 18, 2022
ekluzek pushed a commit that referenced this issue Jun 21, 2022
ekluzek pushed a commit that referenced this issue Jul 10, 2023
ekluzek added a commit that referenced this issue Feb 17, 2024
Backup the PPE branch to ctsm5.1.dev030, but working on Derecho
wwieder added a commit to wwieder/ctsm that referenced this issue Apr 9, 2024
samsrabin referenced this issue in samsrabin/CTSM Apr 19, 2024
Addition of new data model testlists
Adds new aux_cdeps tests lists to every CDEPS component
Fixes issues related to the creation of regional meshes and single column configurations
Fixes the inline interface to be used by prognostic components
samsrabin referenced this issue in samsrabin/CTSM Apr 19, 2024
Merge feature/hafs_couplehycom_cdeps back to support/HAFS
jedwards4b added a commit to jedwards4b/ctsm that referenced this issue Jun 2, 2024
AGonzalezNicolas pushed a commit to HPSCTerrSys/clm5_0 that referenced this issue Jun 27, 2024
…lio (PR ESCOMP#4)

Squashed commit of the ff:

[3f64c755] Refactored utils.py
[101fda55] Updated new script name in setup.cfg
[984010ec] Added DATM namelist generator scripts
[15f69442] Added modelio namelist generator scripts
[ab4bdfa3] Added MOSART namelist generator
[80f5b711] Namelist generators for drv_in and drv_flds_in
[6711a086] Moved drv_flds_in functions from gen_lnd_in.py to gen_drv_flds_in.py
[c672c768] Moved drv_in params from gen_lnd_in.py to gen_drv_in.py
[443d383b] Bump script version to 0.2
AGonzalezNicolas added a commit to HPSCTerrSys/clm5_0 that referenced this issue Jun 27, 2024
…art, and modelio (PR ESCOMP#4) 'a0185014c1c2a75ea80b8af3d921a452bfdfb168' into eclm
adrifoster pushed a commit to adrifoster/CTSM that referenced this issue Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is working incorrectly
Projects
Status: Done (non release/external)
Development

No branches or pull requests

1 participant