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

Small answer changes in preparation for adding option for bio-mass heat storage #1241

Merged
merged 11 commits into from
Dec 30, 2020

Conversation

ekluzek
Copy link
Collaborator

@ekluzek ekluzek commented Dec 29, 2020

Description of changes

Some small changes that can change answers in preparation of bringing in the option for bio-mass heat storage. This only changes answers for some compilers. This brings in some new terms (currently set to zero) that will be in use for clm5_1 when bio-mass heat storage is turned on. The terms that change are identical to the BHS version with the exception that some variables have a "p" index in the full BHS version as they are array terms rather than the scalars they are in here.

The full BHS version is PR #1016

Specific notes

Contributors other than yourself, if any: @swensosc

CTSM Issues Fixed (include github issue #): None

Are answers expected to change (and if so in what way)? Roundoff changes for some compilers

Any User Interface Changes (namelist or namelist defaults changes)?
Some new compsets for clm5.1
Change one clm5.0 test to use the new clm5.1 compset, and add another test

Testing performed, if any: Limited testing on izumi

I also added an explicit testing inside the code in an earlier version to ensure the changes were on the order of e-11/e-12 for the terms that change.

…t_veg, dlrad and ulrad, this is shown to be different on the PGI compiler, but should be only different by roundoff, since it's just a difference in order of operations for those terms
…d another additional test as well for one of the new compsets
@ekluzek ekluzek added enhancement new capability or improved behavior of existing capability priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations PR status: ready PR: this is ready to merge in, with all tests satisfactory and reviews complete labels Dec 29, 2020
@ekluzek ekluzek added this to the ctsm5.1.0 milestone Dec 29, 2020
@ekluzek ekluzek self-assigned this Dec 29, 2020
Comment on lines 1077 to 1079
if ( abs(temp - dt_veg(p) ) > 1.e-12 )then
call endrun( "Difference greater than roundoff" )
end if
Copy link
Member

Choose a reason for hiding this comment

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

@ekluzek - Thanks for all of your work to demonstrate only roundoff-level diffs. I know from my own experience how painful that can sometimes be.

One question: are the terms you're checking here all order 1 (in magnitude)? If not, or if you're not sure, I generally use relative diff checks for things like this:

if (abs(temp - dt_veg(p)) > 1.e-13_r8 * temp) then

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point. Actually I'm sure they aren't order 1. dt_veg and err will be order 1, but could also be very small. ulrad and dlrad should be order 100. So doing a relative diff would be a better comparison. If I do that I'm likely to be able to show a relative difference that's a bit smaller as well.

Copy link
Member

Choose a reason for hiding this comment

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

No need to redo things, though, if you have already done it this way and you have a general sense of the magnitude. My main worry with abs diffs is if the terms are very small to begin with - so an abs diff of 1e-12 could be a relative diff of, say, 1e-6. If you're pretty confident that isn't generally the case here, then I think this is good enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went ahead and did a little testing with this to show it's fine. Relative diff's potentially a bit more troublesome if temp is identically zero, or negative. But with a relative diff I was able to show a tolerance of e-14 was fine for two tests.

Copy link
Member

Choose a reason for hiding this comment

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

Relative diff's potentially a bit more troublesome if temp is identically zero, or negative.

Just a thought for the future: If temp is the old (presumed correct) version, then I usually have success with something like if (abs(temp - dt_veg(p)) > 1.e-13_r8 * temp) – or change the last temp to abs(temp) if negative values are acceptable. This avoids divide by 0. If temp (the old version) was exactly 0 at a point, then I typically expect the new version to be exactly zero, too, and I generally want to ensure that's true (which is done by the above) – since exactly 0 vs. slightly different from 0 can sometimes lead to large downstream differences.

…n two tests to verify: SMS.f10_f10_musgs.I2000Clm50BgcCrop.izumi_pgi.clm-crop and SMS_Ld1_Mmpi-serial.f45_f45_mg37.I2000Clm50Sp.izumi_pgi.clm-ptsRLA
@ekluzek
Copy link
Collaborator Author

ekluzek commented Dec 30, 2020

I think this is complete now. I'm running final testing and will tag once that's complete.

@ekluzek ekluzek merged commit 65a9319 into ESCOMP:master Dec 30, 2020
@ekluzek ekluzek deleted the bhsprep_roffanschange branch December 30, 2020 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new capability or improved behavior of existing capability 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