Skip to content

Conversation

@jimmielin
Copy link
Member

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):

  • Port tracer_data, a generic reader for chemistry and aerosol data, from CAM to CAM-SIMA. The module is as close to the original tracer_data as possible, only removing CAM-specific features (i.e., chunking and physics buffer), FV dycore polar averaging, structured dycore latitude weighting, and a rmv_file flag that deletes files after being read -- closes CCPPize/move tracer_data to CAM-SIMA #432.
  • Moves conservative regridding utility src/utils/horizontal_interpolate.F90 to 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.
  • Add string utilities increment_string, last_non_digit, and get_last_significant_char in support of tracer_data.
  • Add registry entries for prescribed bulk (BAM) aerosol and prescribed ozone for radiation.
  • Add tracer_data chemistry and aerosols (BAM) input regression test (Derecho GNU).
  • Add a check for NaN values in physics check data -- closes NaNs in model state are not detected by physics data differences check #440.
    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.,
 ********** Physics Check Data Results **********

 TIMESTEP:            1

 Variable                                          # Diffs  Max Diff   Max Diff loc (rank, col, lev)
 --------                                          -------  --------   -----------------------------
 ocar1                                                  48       NaN   (0,1,25)
 (!) 48 NaN values in variable!
 bcar1                                                  48       NaN   (0,1,25)
 (!) 48 NaN values in variable!
 sslt1                                                  48       NaN   (0,1,25)

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:

A       src/utils/tracer_data.F90
  - new tracer_data utility in CAM-SIMA ported from CAM (will not be moved from CAM)

A       src/utils/horizontal_interpolate.F90
  - move horizontal_interpolate conservative regridder for chemistry data from CAM.

A       cime_config/testdefs/testmods_dirs/cam/outfrq_trcdata_bam_derecho/shell_commands
A       cime_config/testdefs/testmods_dirs/cam/outfrq_trcdata_bam_derecho/user_nl_cam
  - new tracer_data chemistry and aerosols input data regression test.

List all existing files that have been modified, and describe the changes:
(Helpful git command: git diff --name-status development...<your_branch_name>)

M       cime_config/testdefs/testlist_cam.xml
  - new tracer_data chemistry and aerosols input data regression test.

M       src/data/registry.xml
  - add prescribed ozone for radiation.
  - add prescribed BAM aerosol fields for radiation (used for input check).

M       src/physics/utils/physics_data.F90
  - check for NaNs in physics data check.

M       src/physics/utils/physics_grid.F90
  - make public the `dycore_unstructured` logical for tracer_data.

M       src/utils/string_utils.F90
  - new string utilities `increment_string`, `last_non_digit`, and `get_last_significant_char` in support of tracer_data.

If there are new failures (compared to the test/existing-test-failures.txt file),
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:

Copy link
Collaborator

@nusbaume nusbaume left a 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!

Comment on lines 596 to 605
! 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
Copy link
Collaborator

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:

Suggested change
! 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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, updated!

Comment on lines 164 to 165
unstructured = hdim2_d <= 1
dycore_unstructured = unstructured
Copy link
Collaborator

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.

Copy link
Member Author

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

Comment on lines +21 to +23
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.
Copy link
Collaborator

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.

Copy link
Member Author

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.


implicit none
private
save
Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, removed!

Comment on lines 2402 to 2405
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')
Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, added!

end subroutine vert_interp_mixrat

! Interpolate data from current time-interpolated values to model levels
subroutine vert_interp(ncol, levsiz, pin, pmid, datain, dataout)
Copy link
Collaborator

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).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, marked as pure!

end subroutine vert_interp

! Interpolate data from current time-interpolated values to top interface pressure
subroutine vert_interp_ub(ncol, nlevs, plevs, datain, dataout)
Copy link
Collaborator

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).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, marked as pure!

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)
Copy link
Collaborator

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).

Copy link
Member Author

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)
Copy link
Collaborator

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?

Copy link
Member Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants