Skip to content

Add unit testing for RRTMGP utilities - #369

Open
peverwhee wants to merge 5 commits into
ESCOMP:mainfrom
peverwhee:unit-testing-court
Open

Add unit testing for RRTMGP utilities#369
peverwhee wants to merge 5 commits into
ESCOMP:mainfrom
peverwhee:unit-testing-court

Conversation

@peverwhee

@peverwhee peverwhee commented Mar 9, 2026

Copy link
Copy Markdown
Collaborator

Tag name (The PR title should also include the tag name): n/a
Originator(s): peverwhee

Description (include issue title and the keyword ['closes', 'fixes', 'resolves'] and issue number):

Adds unit tests for the following RRTMGP utilities (and small scheme):

  • schemes/rrtmgp/utils/rrtmgp_dry_static_energy_tendency.F90 (4 tests)
  • schemes/rrtmgp/utils/calculate_net_heating.F90 (2 tests)
  • schemes/rrtmgp/utils/radiation_tools.F90 (2 tests)
  • schemes/rrtmgp/utils/radiation_utils.F90 (21 tests)
  • schemes/rrtmgp/rrtmgp_sw_solar_var_setup.F90 (2 tests)

List all namelist files that were added or changed: n/a

List all files eliminated and why: n/a

List all files added and what they do:

A    test/unit-test/include/interpolate_stub.F90
- add stub so that radiation_tools.F90 will build

A    test/unit-test/tests/rrtmgp/CMakeLists.txt
A    test/unit-test/tests/rrtmgp/test_calculate_net_heating.pf
A    test/unit-test/tests/rrtmgp/test_radiation_tools.pf
A    test/unit-test/tests/rrtmgp/test_radiation_utils.pf
A    test/unit-test/tests/rrtmgp/test_rrtmgp_dry_static_energy_tendency.pf
A    test/unit-test/tests/rrtmgp/test_rrtmgp_sw_solar_var_setup.pf
- Add unit tests for RRTMGP

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

M    schemes/rrtmgp/utils/rrtmgp_dry_static_energy_tendency.F90
M    schemes/rrtmgp/utils/rrtmgp_dry_static_energy_tendency.meta
- change qrs_prime and qrl_prime to inout variables (bugfix)

M    test/unit-test/CMakeLists.txt
M    test/unit-test/tests/CMakeLists.txt
- add cmake infrastructure to see RRTMGP test directories

List all automated tests that failed, as well as an explanation for why they weren't fixed: n/a

Is this an answer-changing PR? If so, is it a new physics package, algorithm change, tuning change, etc? no

If yes to the above question, describe how this code was validated with the new/modified features:

@peverwhee
peverwhee requested a review from nusbaume March 9, 2026 16:06
@peverwhee peverwhee self-assigned this Mar 9, 2026
@nusbaume
nusbaume requested a review from jimmielin July 8, 2026 16:31
@jimmielin

Copy link
Copy Markdown
Collaborator

Thanks @peverwhee! I had a couple nitpicks and one suggestion, and also one that is not in the changed files but I noticed while skimming radiation_utils.F90, in get_{sw,lw}_spectral_boundaries_ccpp

if (.not. wavenumber_boundaries_set) then
write(errmsg,'(a,a)') sub, ': ERROR, wavenumber boundaries not set.'
end if
select case (units)

if (.not. wavenumber_boundaries_set) then
write(errmsg,'(a,a)') sub, ': ERROR, wavenumber boundaries not set.'
end if
select case (units)

I think there should be a

errflg = 1
return

in these if clauses.


integer :: errflg, ncol
character(len=512) :: errmsg
real(kind_phys) :: qrl(1,2), qrs(1,2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nitpick, but this appears to be unused locals


integer :: errflg, ncol
character(len=512) :: errmsg
real(kind_phys) :: qrl(1,2), qrs(1,2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here

Comment on lines +15 to +16
call radiation_utils_init(nswbands, nlwbands, low_shortwave, high_shortwave, &
low_longwave, high_longwave, errmsg, errflg)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should we validate errflg here?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants