-
Notifications
You must be signed in to change notification settings - Fork 16
Implement tracer_data in CAM-SIMA; registry entries for prescribed ozone/BAM; NaN check in physics data check #441
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
base: development
Are you sure you want to change the base?
Conversation
… BAM prescribed aero
nusbaume
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing in this major new capability @jimmielin! I have some change requests, some of which would require non-trivial amounts of effort.
However, given that it is unclear what the future of all of this code will be, I am happy if you want to push back on some of my requests, or make them issues that we can tackle in the future. Just let me know!
| ! First, check if there are NaNs anywhere in the state | ||
| if (shr_infnan_isnan(current_value(col))) then | ||
| nan_count = nan_count + 1 | ||
| has_nan = .true. | ||
|
|
||
| ! Set max diff to NaN (if not already) to signal NaN was found | ||
| if (.not. shr_infnan_isnan(max_diff(1))) then | ||
| max_diff(1) = current_value(col) - buffer(col) ! = nan | ||
| max_diff_col = col | ||
| end if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might change this code block a little to avoid extra function calls/math:
| ! First, check if there are NaNs anywhere in the state | |
| if (shr_infnan_isnan(current_value(col))) then | |
| nan_count = nan_count + 1 | |
| has_nan = .true. | |
| ! Set max diff to NaN (if not already) to signal NaN was found | |
| if (.not. shr_infnan_isnan(max_diff(1))) then | |
| max_diff(1) = current_value(col) - buffer(col) ! = nan | |
| max_diff_col = col | |
| end if | |
| if (shr_infnan_isnan(current_value(col))) then | |
| nan_count = nan_count + 1 | |
| if (.not. has_nan) then ! First NaN found for this variable | |
| has_nan = .true. | |
| ! Set max diff to NaN (if not already) to signal NaN was found | |
| max_diff(1) = current_value(col) ! = nan | |
| max_diff_col = col | |
| end if |
This same change request holds for the code block used in the 3d subroutine as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated!
src/physics/utils/physics_grid.F90
Outdated
| unstructured = hdim2_d <= 1 | ||
| dycore_unstructured = unstructured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this will increase the scope of this PR slightly, but can we get rid of unstructured, and instead just replace it entirely with dycore_unstructured? I don't see any reason to keep two different variables that contain the same info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! Changed in ffbc6a8
| public :: increment_string ! Increment a string whose ending characters are digits. | ||
| public :: last_non_digit ! Get position of last non-digit in the input string. | ||
| public :: get_last_significant_char ! Get position of last significant (non-blank, non-null) character in string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is a big ask, but can we move all of these new functions to src/core_utils/string_core_utils.F90, and then add unit tests for them?
You should be able to add the tests directly to test/unit/fortran/src/test_string_core_utils.pf and they will then run automatically as part of every PR's Github Actions. You can then point to them here like what is done for the other "core" functions above in order to avoid having to change any other file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, moved to string_core_utils and added unit tests!
I still kept the public exports from string_utils.F90 that point to the actual functions in string_core_utils in line with what's being done now with other subroutines, but please let me know if you want me to remove these as well.
src/utils/horizontal_interpolate.F90
Outdated
|
|
||
| implicit none | ||
| private | ||
| save |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think save is needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, removed!
src/utils/tracer_data.F90
Outdated
| call endrun('src_x values are not ascending') | ||
| end if | ||
| if (.not. ALL(trg_x(n, 1:ntrg) < trg_x(n, 2:ntrg + 1))) then | ||
| call endrun('trg_x values are not ascending') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding the subroutine name to these endrun call messages? Otherwise I am not sure I would always know where these errors are coming from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, added!
src/utils/tracer_data.F90
Outdated
| end subroutine vert_interp_mixrat | ||
|
|
||
| ! Interpolate data from current time-interpolated values to model levels | ||
| subroutine vert_interp(ncol, levsiz, pin, pmid, datain, dataout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this subroutine can be labeled pure (or even turned into a function as it only has one output).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, marked as pure!
src/utils/tracer_data.F90
Outdated
| end subroutine vert_interp | ||
|
|
||
| ! Interpolate data from current time-interpolated values to top interface pressure | ||
| subroutine vert_interp_ub(ncol, nlevs, plevs, datain, dataout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this subroutine can be labeled pure (or even turned into a function as it only has one output).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, marked as pure!
src/utils/tracer_data.F90
Outdated
| end subroutine vert_interp_ub | ||
|
|
||
| ! Interpolate data from current time-interpolated values to press | ||
| subroutine vert_interp_ub_var(ncol, nlevs, plevs, press, datain, dataout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this subroutine can be labeled pure (or even turned into a function as it only has one output).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, marked as pure!
|
|
||
| ! rebin src (source) to trg (target). | ||
| ! originally from mo_util | ||
| pure subroutine rebin(nsrc, ntrg, src_x, trg_x, src, trg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of this subroutine entirely, and instead just use the one from ccpp_tuvx_utils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same subroutine, but ccpp_tuvx_utils is in physics/ncar_ccpp/to_be_ccppized/. Could I confirm if we are OK with CAM-SIMA code depending on atmos_phys code? Thanks!
Tag name (required for release branches):
Originator(s): @jimmielin
Description (include the issue title, and the keyword ['closes', 'fixes', 'resolves'] followed by the issue number):
src/utils/horizontal_interpolate.F90to CAM-SIMA (intended to be included in a sparse checkout from CAM in the future) -- currently only used for aircraft inputs, but could be used for all regridded data read from tracer_data in the future.increment_string,last_non_digit, andget_last_significant_charin support of tracer_data.If any NaN values are detected in the model state, the difference count is incremented and the maximum difference will be denoted as NaN.
The number of NaNs will be reported in the output. e.g.,
Describe any changes made to build system: N/A
Describe any changes made to the namelist: N/A
List any changes to the defaults for the input datasets (e.g. boundary datasets): N/A
List all files eliminated and why: N/A
List all files added and what they do:
List all existing files that have been modified, and describe the changes:
(Helpful git command:
git diff --name-status development...<your_branch_name>)If there are new failures (compared to the
test/existing-test-failures.txtfile),have them OK'd by the gatekeeper, note them here, and add them to the file.
If there are baseline differences, include the test and the reason for the
diff. What is the nature of the change? Roundoff?
derecho/intel/aux_sima:
derecho/gnu/aux_sima:
If this changes climate describe any run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced:
CAM-SIMA date used for the baseline comparison tests if different than latest: