-
Notifications
You must be signed in to change notification settings - Fork 23
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
add a logical function to determine if year is leap year #35
Conversation
Thanks a lot for your work on this, @jedwards4b . What would you think about replacing the equality logic in shr_cal_leapyear with the use of 'mod', checking if mod(yr, 4) == 0, etc.? It seems like the equality comparisons could be prone to roundoff error with some compilers, at least for large years. I'm not sure if mod or modulo is the right function to use here: their behavior differs for negative numbers, which may be irrelevant since I don't think we can have a negative year in CESM(???). |
@billsacks after considerable thought I realized that no new logic that we can introduce will handle all of the possible edge cases that I have documented here. |
@jedwards4b - I really appreciate you carefully thinking through these edge cases. I'm not seeing how that relates to the comment I made, though. I'm just suggesting replacing conditionals like |
I see now, sorry. |
Looks good, thanks! |
correct mismatch of leap year ### Description of changes Handle a number of special cases in matching inputdata dates to model dates. These cases are: - Model is no_leap, data is Gregorian and leapyear date 2/29 is encountered in data - skip date - Model is Gregorian, data is no_leap and leapyear date 2/29 is encountered in model - repeat 2/28 data - Model is Gregorian, data is gregorian but leapyears do not align. - if in model leap year repeat data from 2/28 - if in data leap year skip date 2/29 ### Specific notes Contributors other than yourself, if any: @mvertens CDEPS Issues Fixed (include github issue #): #190 Are there dependencies on other component PRs (if so list): ESCOMP/CESM_share#35 Are changes expected to change answers (bfb, different to roundoff, more substantial): bfb Any User Interface Changes (namelist or namelist defaults changes): Testing performed (e.g. aux_cdeps, CESM prealpha, etc): Neon spinup of over 100 years Hashes used for testing: sM ./ccs_config modified sandbox, ccs_config_cesm0.0.44 (branch main) --> ccs_config_cesm0.0.38 ./cime clean sandbox, on cime6.0.45 s ./components/cdeps clean sandbox, 0f3f707 (branch leap_year_corrections) --> cdeps0.12.63 ./components/cdeps/fox clean sandbox, on 4.1.2.1 ./components/cdeps/share/genf90 clean sandbox, on genf90_200608 ./components/cism clean sandbox, on cismwrap_2_1_95 ./components/cism/source_cism clean sandbox, on cism_main_2.01.011 M ./components/cmeps modified sandbox, on cmeps0.13.71 ./components/cpl7 clean sandbox, on cpl7.0.14 ./components/mizuRoute clean sandbox, on 34723c2e4df7caa16812770f8d53ebc83fa22360 ./components/mosart clean sandbox, on mosart1_0_45 ./components/rtm clean sandbox, on rtm1_0_78 e-o ./doc/doc-builder -, not checked out --> v1.0.8 ./libraries/mct clean sandbox, on MCT_2.11.0 ./libraries/parallelio clean sandbox, on pio2_5_7 s ./share clean sandbox, bfa2b5d0a9de06153f2ac94a95818568a1f5cf11 (branch shr_cal_leapyear) --> share1.0.12 ./src/fates clean sandbox, on sci.1.58.1_api.24.1.0
Add a test to see if the current year is a leap year.