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

further cleanup of make_bcs utility and CatchmentCN routines #576

Merged
merged 24 commits into from
Jun 14, 2022

Conversation

gmao-rreichle
Copy link
Contributor

@gmao-rreichle gmao-rreichle commented Apr 20, 2022

An inconsistency in NLv5 Catchment model parameters was discovered that impacts 6 tiles (out of ~1.6 million) on the EASEv2 M09 grid. The 6 tiles in question end up with some PEATCLSM parameters (incl. porosity=0.93), even though they (probably) should have mineral soil properties (which is still reflected in some parameters associated with the 0-30 cm soil layer). An investigation is ongoing.

During this investigation, a few minor problems with the make_bcs script were discovered and fixed in the branch associated with this PR. More fixes might be needed.

The PR will be zero-diff for all model runs. It is not yet clear how the inconsistency in the Catchment model parameters will be resolved. We will probably need to introduce a new bcs version to fix the parameter inconsistency, which probably means that will the PR will also be zero-diff for the make_bcs package.

cc: @rdkoster @gmao-jkolassa @biljanaorescanin @weiyuan-jiang @gmao-qliu

UPDATED 11 Jun 2022: This PR will be merged without addressing the above-mentioned parameter inconsistency, which requires further study. The bulk of the PR consists of long overdue cleanup.

- reinstated "source g5_modules" command within SBATCH job scripts created by make_bcs
- renamed environment variables for clarification
- removed obsolete "cd" and "SBATCH --chdir"
@gmao-rreichle gmao-rreichle added 0 diff The changes in this pull request have verified to be zero-diff with the target branch. Contingent - DNA These changes are contingent on other PRs (DNA=do not approve) labels Apr 20, 2022
@gmao-rreichle gmao-rreichle added bugfix This fixes a bug cleanup labels Apr 20, 2022
@gmao-rreichle
Copy link
Contributor Author

UPDATE (5/5/22):
The subroutines dealing with HWSD/PEATMAP processing and the Woesten soil parameters were partially cleaned up and some documentation was added. The changes are not meant to be final. The latest commit ef69e84 successfully tested 0-diff for the generation of NLv4 and NLv5 bcs in EASEv2_M09 resolution. Additional tests for other bcs versions and resolutions will be needed.

It remains unclear how the tiles identified by Sebastian end up with peat as profile soil class. The attached pdf and xls files provide additional information.
SMAP_L4_Meeting_20220504_NLv5_bcs_only.pdf
soilparam_peat_tiles_rr_20220504.xlsx

cc: @rdkoster @gmao-jkolassa @biljanaorescanin @weiyuan-jiang @gmao-qliu

@gmao-rreichle gmao-rreichle changed the title further bug fixes and cleanup of make_bcs utility further cleanup of make_bcs utility and CatchmentCN routines May 23, 2022
@biljanaorescanin biljanaorescanin requested review from a team as code owners May 24, 2022 01:08
@biljanaorescanin biljanaorescanin removed the Contingent - DNA These changes are contingent on other PRs (DNA=do not approve) label May 24, 2022
@gmao-rreichle
Copy link
Contributor Author

I've run one bcs test (EASE M09)

Thanks, @biljanaorescanin. Which bcs version did you run? Given the extent of the changes in this PR, we need to run multiple versions at multiple resolutions. At the very least, we need to run NLv4 and NLv5 on M09 and M36, and we need to run NLv3 at c720, c360, c180 and c90.

@biljanaorescanin
Copy link
Contributor

@gmao-rreichle I did NLv3. Sure, I will run other cases and add a comment once I am done.

@biljanaorescanin
Copy link
Contributor

@gmao-rreichle @weiyuan-jiang I've added last commit so we don't have warning messages in catchcn_params.nc4 and catch_param.nc4 . I am testing it now to confirm.

@gmao-rreichle gmao-rreichle added the Contingent - DNA These changes are contingent on other PRs (DNA=do not approve) label May 25, 2022
@gmao-rreichle
Copy link
Contributor Author

I added the "contingent" label again. Not sure why this was removed. We are not quite done with this PR. Hopefully final touches and testing underway now.

@gmao-rreichle gmao-rreichle removed the Contingent - DNA These changes are contingent on other PRs (DNA=do not approve) label May 26, 2022
@gmao-rreichle
Copy link
Contributor Author

The previous two commits fix a netcdf dimension error that had been present for a long time in the catch_params.nc4 and catchcn_params.nc4 files generated by make_bcs. The data in the files was successfully verified 0-diff after the commits.
Owing to the bug in the old version of these nc4 files, nccmp and cdo do not work properly for comparing the catch_params.nc4 files before and after the dimensions bug fix. I verified 0-diff for data across the old and new nc4 files using matlab.

@biljanaorescanin successfully completed final developer tests today (GEOSldas runs that use bcs generated with the branch associated with this PR).

@gmao-rreichle
Copy link
Contributor Author

PR is ready for final verification and merging by GCM gatekeeper.

PR only touches make_bcs and CatchmentCN and is trivially 0-diff for all GCM tests.

Suggested log entry:

make_bcs and CatchmentCN cleanup:
- removed generation of unused/obsolete bcs file CLM4.5_veg_typs_fracs
- cleanup of incomplete CatchCN albedo scaling 
- partial cleanup and improved documentation of subroutines dealing with HWSD/PEATMAP processing and Woesten soil parameters 

! For PEATMAP, the sub-layer weight of 2.33 should only count towards cFamily(1:3), and in most cases the
! maxloc statement below should therefore result in o_clp = 1, 2, or 3 only. However, if the top-layer orgC
! is peat for most contributing raster grid cells and the sub-layer orgC values are relatively evenly spread
! over orgC classes 1, 2, and 3, then maxloc(cFamily) can result in o_clp=4.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this is what we don't want.
o_clp=4 should only be allowed if o_clp makes up more than 0.5 of a grid cell.
This may explain that Sebastian found 6 'buried' peat tiles which were not peat in the top layer but in the profile layer.


! ----------------------------------------------------------------------------------------
!
! Determine *top* layer mineral/organic soil class of tile n

if(o_cl == 4) then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to include in this 'if-statement' a line like
o_clp = 4
We want all o_cl to become full peat tiles.
With this we would get rid of those inconsistent tiles with top soil being peat but not profile being peat.

@weiyuan-jiang
Copy link
Contributor

bug is here:

elseif(nint(Table2(1,Pix2))==fill) then ! A use 1st grid area of a merge
iTable(2,ip) = nint(Table1(3,Pix1))
iTable(3,ip) = nint(Table1(4,Pix1))
rTable(4,ip) = Table1(2,Pix1)
rTable(5,ip) = Table1(2,Pix1)

When line 344 is executed, Pix1 = -999 which leads to crash. It is exposed by debug mode but exists in optimized mode ( just does not crash) .

We may have to examine why it checks table 2 of pix2 but use table 1 of pix1

@gmao-rreichle @biljanaorescanin

@gmao-rreichle
Copy link
Contributor Author

We may have to examine why it checks table 2 of pix2 but use table 1 of pix1

Thanks, @weiyuan-jiang, for the sleuthing. I've never looked at this program and cannot quickly make sense of what's going on here. I'm still unclear what happens when we run the (usual) build with optimization, and what a fix would look like. If we also get Pix1=-999 with the optimized build, then lines 344-347 should result in garbage, which is concerning. @atrayano, are you familiar with the code in question? [In brief, when we run this code for make_bcs using a debug build, the run stops with an error message that an index value is negative. No such stop and error message is produced when we run the (usual) optimized build. See previous comment by @weiyuan-jiang.]

cc: @biljanaorescanin @rdkoster

@atrayano
Copy link
Contributor

atrayano commented Jun 8, 2022

@gmao-rreichle Yes, I am familiar with this code , it was written by Max Suarez many years ago. I have seen the negative (-999) Pix error once in a while, and usually this is a result of the rasterization process not covering completely the Earth

@weiyuan-jiang
Copy link
Contributor

The good news is I only saw one bad pix. Maybe we can throw away that one ? @gmao-rreichle @biljanaorescanin @atrayano

@atrayano
Copy link
Contributor

atrayano commented Jun 8, 2022

@weiyuan-jiang Unfortunately, we cannot throw away the "bad" Pix. My first impulse is to write a piece of code to check the raster(s) for -999 and possibly do something to re-assign a "good" value (for example, assign the value from a neighbor)

@biljanaorescanin
Copy link
Contributor

biljanaorescanin commented Jun 10, 2022

@sdrabenh I made an issue for things we didn't address #596, we are ready to proceed with this PR as it is.

@gmao-rreichle left a comment for suggested log entry:

make_bcs and CatchmentCN cleanup:

  • removed generation of unused/obsolete bcs file CLM4.5_veg_typs_fracs
  • cleanup of incomplete CatchCN albedo scaling
  • partial cleanup and improved documentation of subroutines dealing with HWSD/PEATMAP processing and Woesten soil parameters

@sdrabenh sdrabenh merged commit 2ff0572 into develop Jun 14, 2022
@sdrabenh sdrabenh deleted the rreichle/cleanup/make_bcs branch June 14, 2022 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 diff The changes in this pull request have verified to be zero-diff with the target branch. bugfix This fixes a bug cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants