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

zenith angle time correction #123

Merged

Conversation

jedwards4b
Copy link
Contributor

@jedwards4b jedwards4b commented Oct 1, 2021

Description of changes

Corrects the calculation of solar zenith angle, which was off by one timestep.

Specific notes

Sean ran two five day simulations, with and without your cdeps changes. The changes correct the bug.

Contributors other than yourself, if any: Sean Swenson

CDEPS Issues Fixes #120 #35

Are there dependencies on other component PRs

  • CIME (list)
  • CMEPS (list)

Are changes expected to change answers?

  • bit for bit
  • different at roundoff level
  • more substantial

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

  • Yes
  • No

Testing performed:

  • (required) aux_cdeps
    • machines and compilers:
    • details (e.g. failed tests):
  • (optional) CESM prealpha test
    • machines and compilers
    • details (e.g. failed tests):

Hashes used for testing:

@jedwards4b jedwards4b self-assigned this Oct 1, 2021
@billsacks
Copy link
Member

Thanks a lot for helping to push this forward, @jedwards4b . I think more appropriate reviewers here would be @ekluzek and @swensosc so I'm going to request reviews from them instead of me.

In terms of documenting answer changes: my understanding is that this is more than roundoff-level changes; @swensosc, is that correct?

We had also talked about getting sign-off from people in the ocean group (@mnlevy1981 @alperaltuntas @klindsay28 or others) and sea ice (@dabail10 ), so I'll add them as possible reviewers.

All: feel free to remove yourself or suggest someone else if you feel someone else would be a more appropriate reviewer.

@billsacks billsacks requested review from ekluzek, mnlevy1981, alperaltuntas, dabail10 and swensosc and removed request for billsacks October 1, 2021 19:15
@jedwards4b
Copy link
Contributor Author

jedwards4b commented Oct 1, 2021

Here are plots provided by @swensosc
cdeps_coszen_fix.pdf

@swensosc
Copy link

swensosc commented Oct 1, 2021 via email

@ekluzek ekluzek added the bug Something isn't working label Oct 1, 2021
@@ -1255,7 +1255,7 @@ subroutine shr_strdata_readLBUB(sdat, ns, mDate, mSec, newData, istr, rc)
call ESMF_TraceRegionExit(trim(istr)//'_setup')

! if model current date is outside of model lower or upper bound - find the stream bounds
if (rDateM < rDateLB .or. rDateM > rDateUB) then
if (rDateM < rDateLB .or. rDateM >= rDateUB) then
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've convinced myself this change is correct. Because, it will update the data when rDateM == rDateUB. So this should be done in preparation of that.

!--- advance to next time in [LB,UB] ---
ymd0 = ymd
tod0 = tod
reday0 = reday
call shr_cal_advDateInt(ldt,'seconds',ymd0,tod0,ymd,tod,calendar)
call shr_cal_timeSet(reday,ymd,tod,calendar)

if (reday > reday2) then
Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, looking at this, the reason the previous code is wrong is that it's essentially doing the interval (LB,UB] so not starting at ldt after LB (Lower bound) (so LB is exclusive) and continuing until UB (Upper Bound) inclusive. So LB exclusive and UB inclusive. But, once you reach the UB, you go to the next interval. So it should be [LB,UB) LB inclusive, and UB exclusive, which is what the new code changes do.

Copy link
Collaborator

@ekluzek ekluzek left a comment

Choose a reason for hiding this comment

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

I approve this, but as it's answer changing for several components, we need to bring it in as it's own tag in CESM where answer changes are allowed.

@ekluzek
Copy link
Collaborator

ekluzek commented Oct 1, 2021

@mnlevy1981 @dabail10 and @alperaltuntas can you review this? I'd also like to hear if you agree with the comments I added where I explain why I thought the new changes are correct.

@swensosc can you explain your plots that Jim included a little further? It looks like the magenta plots are the current behavior in pages 3 and 5. If I'm reading it right then pages 4 and 6 are the new behavior. But, what's black and blue correspond to? They looked more displaced to me, so why is this better?

@swensosc
Copy link

swensosc commented Oct 4, 2021 via email

Copy link
Member

@alperaltuntas alperaltuntas left a comment

Choose a reason for hiding this comment

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

I confirm that this PR resolves the issues I posted earlier:
#35
ESMCI/cime#3802

@ekluzek
Copy link
Collaborator

ekluzek commented Oct 4, 2021

@swensosc thanks for that explanation. Now, that I understand the plots I agree that the new behavior is better than the old. @alperaltuntas confirmation that it fixes an issue he found as well, confirms this is correct even more.

@mvertens
Copy link
Collaborator

mvertens commented Jan 6, 2022

@dabail10 @mlevy - could you please review this PR so that it can be merged. I have already checked with @swensosc and he is comfortable with going ahead with the merge once all reviews are in.

@mnlevy1981 mnlevy1981 self-requested a review January 6, 2022 19:38
@jedwards4b jedwards4b merged commit 39f79b4 into ESCOMP:master Jan 6, 2022
@jedwards4b jedwards4b deleted the jedwards/solar_zenith_angle_correction branch January 6, 2022 19:38
@mnlevy1981 mnlevy1981 removed their request for review January 6, 2022 19:38
Copy link
Contributor

@dabail10 dabail10 left a comment

Choose a reason for hiding this comment

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

Do we have a unit test of this to print out the values at a particular lat/lon? It generally looks good to me.

@mnlevy1981
Copy link
Contributor

@klindsay28 and I looked through this code, and have some experiments in mind to determine the extent to which this will change answers in POP... but given @alperaltuntas's assessment that it fixes a bug with the coszen implementation, it seems likely that the result of those experiments will be to let others know what does / does not change with this fix in place rather than raise issues with the code changes themselves.

billsacks added a commit to billsacks/CDEPS that referenced this pull request Mar 15, 2022
…zenith_angle_correction"

This reverts commit 39f79b4, reversing
changes made to 4ebc156.
billsacks added a commit that referenced this pull request Mar 16, 2022
Revert PR #123

### Description of changes

PR #123 (solar zenith angle correction) led to exact restart failures in some situations: see #144. This PR backs out the changes from #123 .

### Specific notes

Contributors other than yourself, if any:

CDEPS Issues Fixed (include github issue #): Temporarily deals with #144.

Are there dependencies on other component PRs (if so list): no

Are changes expected to change answers (bfb, different to roundoff, more substantial): more substantial. I have verified that this brings answers back to being bfb with those in cdeps0.12.35 (i.e., prior to #123) via a run of the aux_clm test suite.

Any User Interface Changes (namelist or namelist defaults changes): no

Testing performed (e.g. aux_cdeps, CESM prealpha, etc): aux_clm

Hashes used for testing: billsacks/ctsm@3fd7f6fbf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cosine solar zenith angle forcing is off by a time-step
8 participants