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

Bring in snowmip diagnostic fields #449

Merged
merged 71 commits into from
Sep 29, 2018
Merged

Bring in snowmip diagnostic fields #449

merged 71 commits into from
Sep 29, 2018

Conversation

ekluzek
Copy link
Collaborator

@ekluzek ekluzek commented Jul 26, 2018

Description of changes

Adds in new fields needed for SNOWMIP

Specific notes

Contributors other than yourself, if any: flanner, swensosc, justinperket

CTSM Issues Fixed (include github issue #):

Are answers expected to change (and if so in what way)? No (only new diagnostic fields added)

Any User Interface Changes (namelist or namelist defaults changes)?

Add use_SSRE namelist item

Testing performed, if any:

Ran aux_clm test on cheyenne and hobart and tests work as expected and are bit-for-bit
(however, new fields weren't on by default)

https://svn-ccsm-models.cgd.ucar.edu/clm2/branch_tags/SSREsnowmip_tags/SSREsnowmip_n00_clm4_5_18_r272

NOTE: Even though this says it's a "n00" version it does actually contain changes from the baseline
version clm4_5_18_r272. It really should be labeled "n01".
https://svn-ccsm-models.cgd.ucar.edu/clm2/branch_tags/SSREsnowmip_tags/SSREsnowmip_n00_clm4_5_18_r272

NOTE: Even though this says it's a "n00" version it does actually contain changes from the baseline
version clm4_5_18_r272. It really should be labeled "n01".
Add some new diagnostic fields. Some needed for CMIP6. Update the CMIP6 user-mods output.
Fix a couple issues. Get full list of history tapes working correctly. Check for valid range
of CO2. New IC file interpolated from the previous one for f19_g17_gl4 for 2000 Clm50BgcCrop.
@ekluzek ekluzek added priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations type: enhance - science labels Jul 26, 2018
@ekluzek ekluzek added this to the cmip6 milestone Jul 26, 2018
@ekluzek ekluzek self-assigned this Jul 26, 2018
@ekluzek
Copy link
Collaborator Author

ekluzek commented Jul 26, 2018

OK, looking at this I realize more work needs to be done on this. There's some name comments that need to come out. It also currently doesn't test the new fields, so I've done some testing with use_ssre turned on and that's looking fine. So I also need to add a test with the new fields. And it looks like there maybe some duplication that could be eliminated that I'm going to look into.

@ekluzek
Copy link
Collaborator Author

ekluzek commented Jul 26, 2018

The following tests all work fine with use_ssre=T. So that gives me some confidence that the new option is working.

SMS_Lm1_D.f10_f10_musgs.I2000Clm50BgcCrop.cheyenne_intel.clm-snowlayers_3_monthly
SMS_Ld5_D.f09_g16.I1850Clm50BgcCrop.cheyenne_intel.clm-cmip6
SMS_Lm37.f10_f10_musgs.I1850Clm50SpG.cheyenne_intel.clm-glcMEC_long
SMS_D_Lm6_P144x1.f45_f45_mg37.I2000Clm50Fates.cheyenne_intel.clm-FatesColdDef
SMS_D_Ly2.1x1_brazil.IHistClm50BgcQianGs.cheyenne_intel.clm-ciso_bombspike1963
ERP_D_P36x2_Ld30.f10_f10_musgs.I2000Clm50BgcCruGs.cheyenne_intel.clm-default
SMS_D_Ly2.1x1_numaIA.IHistClm50BgcCropGs.cheyenne_intel.clm-ciso_bombspike1963

@ekluzek ekluzek requested review from billsacks and removed request for billsacks July 26, 2018 22:09
@ekluzek
Copy link
Collaborator Author

ekluzek commented Jul 26, 2018

I can see that the duplication has already caused problems, because bug 2431 was fixed in the old, but not new version of TwoStream in SurfaceAlbedoMod.

lon = londeg
if ( lon < 0.0_r8 ) lon = lon + 360.0_r8
get_local_irrig_time = modulo(secs + nint(londeg/degpsec), isecspday)
get_local_irrig_time = modulo(get_local_irrig_time,isecspday)
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this second modulo? There's already a modulo in the line above.

londeg = 360.0_r8
@assertEqual( expected, get_local_time( londeg ) )

! Check for local noon on otherside of the world
Copy link
Member

Choose a reason for hiding this comment

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

For this and some of the other tests you added: I find it significantly easier to understand what tests are doing if they follow the generally-recommended unit testing organization of arrange-act-assert (or equivalently: setup-exercise-verify). That is, each test should test one thing. It gets hard to follow tests when they call the system under test multiple times in a single test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@billsacks and I talked about this. The general advice is to have one test per thing tested to make it easiest to read. It also helps in the theoretical sense so that broken tests will all be shown rather than just the first assert that fails within a test. Bill didn't think this had to change for this PR, but we do want to try to follow best practices for unit testing in general.

call get_curr_date(yr, mon, day, secs, offset )
lon = londeg
if ( lon < 0.0_r8 ) lon = lon + 360.0_r8
get_local_time = secs + nint((lon/degpsec)/real(dtime,r8))*dtime
Copy link
Member

Choose a reason for hiding this comment

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

The division by dtime here yields incorrect results. See #491 (comment) for details.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@billsacks and I went over this with @olyson and we figured out why this was done this way. This is just to make sure the code in SurfaceRadiationMod.F90 would match the closest time-step to local noon. This can be handled appropriately with the is_near_local_noon function. So we can remove the dtime logic that's here. The bottom line is that we want to use the method used in Irrigation for going forward. I still plan to have a bit-for-bit tag, that has two different methods and then we'll remove one with a tag that has answer changes.

@ekluzek
Copy link
Collaborator Author

ekluzek commented Sep 19, 2018

@billsacks thanks for the review! I'll go back through and make changes and/or comments as appropriate.

Note, that I went through several iterations of the compare_local_time unit test and part of how I knew it was working, was changing the delta degree. The last thing I did was to change the time it ran over from just a day, to a full year. I never got it to fail running with gnu on my laptop, but I didn't run it anywhere else. I'll comment more later.

@ekluzek ekluzek added PR status: ready PR: this is ready to merge in, with all tests satisfactory and reviews complete and removed status: work in progress labels Sep 28, 2018
@ekluzek ekluzek merged commit d268871 into master Sep 29, 2018
@ekluzek ekluzek deleted the SSREsnowmip branch September 29, 2018 17:52
billsacks pushed a commit to billsacks/ctsm that referenced this pull request Feb 22, 2019
Bring in snowmip diagnostic fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR status: ready PR: this is ready to merge in, with all tests satisfactory and reviews complete priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants