Skip to content

Commit d5bff71

Browse files
authored
Merge pull request #1461 from peverwhee/rrtmgp-gpu
cam6_4_148: Move GPU directives to atmospheric physics for RRTMGP
2 parents 1ee3228 + 31a1d39 commit d5bff71

File tree

7 files changed

+79
-97
lines changed

7 files changed

+79
-97
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
[submodule "atmos_phys"]
3030
path = src/atmos_phys
3131
url = https://github.com/ESCOMP/atmospheric_physics
32-
fxtag = atmos_phys0_20_001
32+
fxtag = atmos_phys0_21_000
3333
fxrequired = AlwaysRequired
3434
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
3535

@@ -139,7 +139,7 @@ fxDONOTUSEurl = https://github.com/ESCOMP/mizuRoute
139139
[submodule "ccs_config"]
140140
path = ccs_config
141141
url = https://github.com/ESMCI/ccs_config_cesm.git
142-
fxtag = ccs_config_cesm1.0.65
142+
fxtag = ccs_config_cesm1.0.72
143143
fxrequired = ToplevelRequired
144144
fxDONOTUSEurl = https://github.com/ESMCI/ccs_config_cesm.git
145145

cime_config/testdefs/testlist_cam.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
</machines>
8585
<options>
8686
<option name="comment">CAM7-LT, enable gpu for PUMAS, CLUBB, and RRTMGP</option>
87-
<option name="wallclock">00:45:00</option>
87+
<option name="wallclock">02:00:00</option>
8888
</options>
8989
</test>
9090

@@ -1297,7 +1297,7 @@
12971297
<machine name="derecho" compiler="nvhpc" category="prealpha"/>
12981298
</machines>
12991299
<options>
1300-
<option name="wallclock">00:45:00</option>
1300+
<option name="wallclock">02:00:00</option>
13011301
</options>
13021302
</test>
13031303
<test compset="F2000dev" grid="ne30pg3_ne30pg3_mg17" name="ERP_D_Ln9" testmods="cam/outfrq9s" supported="false">

doc/ChangeLog

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
===============================================================
2+
3+
Tag name: cam6_4_148
4+
Originator(s): peverwhee, sjsprecious
5+
Date: 29 January 2026
6+
One-line Summary: Move GPU directives to atmospheric physics for RRTMGP
7+
Github PR URL: https://github.com/ESCOMP/CAM/pull/1461
8+
9+
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
10+
- Moves acc directives for RRTMGP from src/physics/rrtmgp/radiation.F90 to
11+
atmospheric_physics (src/atmos_phys/schemes/rrtmgp/)
12+
13+
Describe any changes made to build system: N/A
14+
15+
Describe any changes made to the namelist: N/A
16+
17+
List any changes to the defaults for the boundary datasets: N/A
18+
19+
Describe any substantial timing or memory changes:
20+
- GPU test now runs thanks to Jian Sun's workaround in ccs_config, but GPU
21+
test now takes longer (until we have a better fix from CISL)
22+
23+
Code reviewed by: cacraigucar
24+
25+
List all files eliminated: N/A
26+
27+
List all files added and what they do: N/A
28+
29+
List all existing files that have been modified, and describe the changes:
30+
M cime_config/testdefs/testlist_cam.xml
31+
- Up the wallclock time for all nvhpc tests to 2:00:00
32+
33+
M src/physics/rrtmgp/radiation.F90
34+
- remove acc directives
35+
36+
M src/physics/rrtmgp/rrtmgp_inputs_cam.F90
37+
- clean-up unused code that has been moved to atmos_phys
38+
39+
M .gitmodules
40+
M src/atmos_phys
41+
M ccs_config
42+
- update atmospheric_physics and ccs_config tags
43+
- atmospheric_physics tag includes new directives in rrtmgp schemes
44+
- ccs_config tag changes nvhpc optimization to allow the GPU test to run AND
45+
updates the list of source code to compile with GPU flags
46+
47+
If there were any failures reported from running test_driver.sh on any test
48+
platform, and checkin with these failures has been OK'd by the gatekeeper,
49+
then copy the lines from the td.*.status files for the failed tests to the
50+
appropriate machine below. All failed tests must be justified.
51+
52+
derecho/intel/aux_cam:
53+
ERI_D_Ln18.ne16pg3_ne16pg3_mt232.FHIST_C4.derecho_intel.cam-outfrq3s_eri (Overall: FAIL) details:
54+
- pre-existing failure
55+
- ERI test discovered a bug in CICE: See: https://github.com/ESCOMP/CESM_CICE/issues/34
56+
57+
derecho/nvhpc/aux_cam:
58+
ERS_Ln9.ne30pg3_ne30pg3_mt232.FHISTC_LTso.derecho_nvhpc.cam-outfrq9s_gpu_default (Overall: PASS) details:
59+
- TEST PASSES AS OF THIS TAG
60+
- generated baselines (with cam6_4_147 + the ccs_config mod) to confirm that
61+
the mods in this tag (cam6_4_148) do not change answers
62+
63+
izumi/nag/aux_cam: all BFB
64+
65+
izumi/gnu/aux_cam: all BFB
166

267
===============================================================
368

src/atmos_phys

src/physics/rrtmgp/radiation.F90

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ end function radiation_do
413413
subroutine radiation_init(pbuf2d)
414414
use rrtmgp_pre, only: rrtmgp_pre_init
415415
use rrtmgp_inputs_setup, only: rrtmgp_inputs_setup_init
416-
use rrtmgp_inputs_cam, only: rrtmgp_inputs_cam_init
417416
use rrtmgp_cloud_optics_setup, only: rrtmgp_cloud_optics_setup_init
418417
use rrtmgp_sw_solar_var_setup, only: rrtmgp_sw_solar_var_setup_init
419418
use solar_irrad_data, only: do_spctrl_scaling, has_spectrum
@@ -484,10 +483,6 @@ subroutine radiation_init(pbuf2d)
484483
call endrun(sub//': '//errmsg)
485484
end if
486485

487-
! Set up CAM-side RRTMGP inputs - will go away once SW radiation is CCPPized
488-
call rrtmgp_inputs_cam_init(ktopcam, ktoprad, idx_sw_diag, idx_nir_diag, idx_uv_diag, idx_sw_cloudsim, idx_lw_diag, &
489-
idx_lw_cloudsim)
490-
491486
! Set radconstants module-level index variables that we're setting in CCPP-ized scheme now
492487
call radconstants_init(idx_sw_diag, idx_nir_diag, idx_uv_diag, idx_lw_diag)
493488

@@ -1264,14 +1259,11 @@ subroutine radiation_tend( &
12641259

12651260
! Compute the gas optics (stored in atm_optics_sw).
12661261
! toa_flux is the reference solar source from RRTMGP data.
1267-
!$acc data copyin(kdist_sw%gas_props,pmid_day,pint_day,t_day,gas_concs_sw%gas_concs,atm_optics_sw%optical_props) &
1268-
!$acc copyout(toa_flux)
12691262
call rrtmgp_sw_gas_optics_run(dosw, 1, nday, nday, pmid_day, pint_day, t_day, &
12701263
gas_concs_sw, atm_optics_sw, kdist_sw, toa_flux, errmsg, errflg)
12711264
if (errflg /= 0) then
12721265
call endrun(sub//': '//errmsg)
12731266
end if
1274-
!$acc end data
12751267

12761268
! Scale the solar source
12771269
call rrtmgp_sw_solar_var_run(toa_flux, 2, band2gpt_sw, nswbands, sol_irrad, we, nbins, sol_tsi, &
@@ -1285,26 +1277,16 @@ subroutine radiation_tend( &
12851277
! Set SW aerosol optical properties in the aer_sw object.
12861278
! This call made even when no daylight columns because it does some
12871279
! diagnostic aerosol output.
1288-
call rrtmgp_set_aer_sw( &
1289-
icall, state, pbuf, nday, idxday, nnite, idxnite, aer_sw)
1280+
call rrtmgp_set_aer_sw(ktopcam, ktoprad, icall, state, pbuf, nday, idxday, nnite, idxnite, aer_sw)
12901281

12911282
if (nday > 0) then
12921283

12931284
! Increment the gas optics (in atm_optics_sw) by the aerosol optics in aer_sw.
1294-
!$acc data copyin(coszrs_day, toa_flux, alb_dir, alb_dif, &
1295-
!$acc atm_optics_sw%optical_props, atm_optics_sw%optical_props%tau, atm_optics_sw%optical_props%ssa, &
1296-
!$acc atm_optics_sw%optical_props%g, aer_sw%optical_props%tau, &
1297-
!$acc aer_sw%optical_props, aer_sw%optical_props%ssa, aer_sw%optical_props%g, &
1298-
!$acc cloud_sw%optical_props, cloud_sw%optical_props%tau, cloud_sw%optical_props%ssa, &
1299-
!$acc cloud_sw%optical_props%g) &
1300-
!$acc copy(fswc%fluxes, fswc%fluxes%flux_net,fswc%fluxes%flux_up,fswc%fluxes%flux_dn, &
1301-
!$acc fsw%fluxes, fsw%fluxes%flux_net,fsw%fluxes%flux_up,fsw%fluxes%flux_dn)
13021285
call rrtmgp_sw_rte_run(dosw, .true., .true., nday, 1, nday, atm_optics_sw, cloud_sw, &
13031286
aer_sw, coszrs_day, toa_flux, alb_dir, alb_dif, fswc, fsw, errmsg, errflg)
13041287
if (errflg /= 0) then
13051288
call endrun(sub//': '//errmsg)
13061289
end if
1307-
!$acc end data
13081290
end if
13091291

13101292
! Transform RRTMGP outputs to CAM outputs and compute heating rates.
@@ -1364,45 +1346,24 @@ subroutine radiation_tend( &
13641346
end if
13651347

13661348
! Compute the gas optics and Planck sources.
1367-
!$acc data copyin(kdist_lw%gas_props, pmid_rad, pint_rad, t_rad, &
1368-
!$acc t_sfc, gas_concs_lw%gas_concs, atm_optics_lw%optical_props) &
1369-
!$acc copy(atm_optics_lw%optical_props%tau, &
1370-
!$acc sources_lw%sources, sources_lw%sources%lay_source, &
1371-
!$acc sources_lw%sources%sfc_source, &
1372-
!$acc sources_lw%sources%lev_source, &
1373-
!$acc sources_lw%sources%sfc_source_jac)
13741349
call rrtmgp_lw_gas_optics_run(dolw, 1, ncol, ncol, pmid_rad, pint_rad, t_rad, &
13751350
t_sfc, gas_concs_lw, atm_optics_lw, sources_lw, t_rad, .false., kdist_lw, errmsg, &
13761351
errflg)
13771352
if (errflg /= 0) then
13781353
call endrun(sub//': '//errmsg)
13791354
end if
1380-
!$acc end data
13811355

13821356
! Set LW aerosol optical properties in the aer_lw object.
1383-
call rrtmgp_set_aer_lw(icall, state, pbuf, aer_lw)
1357+
call rrtmgp_set_aer_lw(ktopcam, ktoprad, icall, state, pbuf, aer_lw)
13841358

13851359
! Call the main rrtmgp_lw driver
1386-
!$acc data copyin(atm_optics_lw%optical_props,atm_optics_lw%optical_props%tau, &
1387-
!$acc aer_lw%optical_props,aer_lw%optical_props%tau, &
1388-
!$acc cloud_lw%optical_props, cloud_lw%optical_props%tau, &
1389-
!$acc sources_lw%sources,sources_lw%sources%lay_source, &
1390-
!$acc sources_lw%sources%sfc_source, &
1391-
!$acc sources_lw%sources%lev_source, &
1392-
!$acc sources_lw%sources%sfc_source_jac, &
1393-
!$acc emis_sfc) &
1394-
!$acc copy(flwc%fluxes, flwc%fluxes%flux_net, flwc%fluxes%flux_up, &
1395-
!$acc flwc%fluxes%flux_dn, flw%fluxes, flw%fluxes%flux_net, &
1396-
!$acc flw%fluxes%flux_up, flw%fluxes%flux_dn, &
1397-
!$acc lw_ds)
13981360
call rrtmgp_lw_rte_run(dolw, dolw, .false., .false., .false., &
13991361
0, atm_optics_lw, cloud_lw, sources_lw, emis_sfc, &
14001362
kdist_lw, aer_lw, fluxlwup_jac, lw_ds, flwc, flw, &
14011363
errmsg, errflg)
14021364
if (errflg /= 0) then
14031365
call endrun(sub//': '//errmsg)
14041366
end if
1405-
!$acc end data
14061367

14071368
! Transform RRTMGP outputs to CAM outputs and compute heating rates.
14081369
call set_lw_diags()

src/physics/rrtmgp/rrtmgp_inputs_cam.F90

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ module rrtmgp_inputs_cam
4444
save
4545

4646
public :: &
47-
rrtmgp_inputs_cam_init, &
4847
rrtmgp_get_gas_mmrs, &
4948
rrtmgp_set_aer_lw, &
5049
rrtmgp_set_aer_sw
@@ -53,16 +52,6 @@ module rrtmgp_inputs_cam
5352
! This value is to match the arbitrary small value used in RRTMG to decide
5453
! when a quantity is effectively zero.
5554
real(r8), parameter :: tiny = 1.0e-80_r8
56-
real(r8) :: sw_low_bounds(nswbands)
57-
real(r8) :: sw_high_bounds(nswbands)
58-
integer :: ktopcam
59-
integer :: ktoprad
60-
integer :: idx_sw_diag
61-
integer :: idx_nir_diag
62-
integer :: idx_uv_diag
63-
integer :: idx_sw_cloudsim
64-
integer :: idx_lw_diag
65-
integer :: idx_lw_cloudsim
6655

6756
! Mapping from RRTMG shortwave bands to RRTMGP. Currently needed to continue using
6857
! the SW optics datasets from RRTMG (even thought there is a slight mismatch in the
@@ -74,43 +63,6 @@ module rrtmgp_inputs_cam
7463
contains
7564
!==================================================================================================
7665

77-
!==================================================================================================
78-
subroutine rrtmgp_inputs_cam_init(ktcam, ktrad, idx_sw_diag_in, idx_nir_diag_in, idx_uv_diag_in, &
79-
idx_sw_cloudsim_in, idx_lw_diag_in, idx_lw_cloudsim_in)
80-
81-
! Note that this routine must be called after the calls to set_wavenumber_bands which set
82-
! the sw/lw band boundaries in the radconstants module.
83-
84-
integer, intent(in) :: ktcam
85-
integer, intent(in) :: ktrad
86-
integer, intent(in) :: idx_sw_diag_in
87-
integer, intent(in) :: idx_nir_diag_in
88-
integer, intent(in) :: idx_uv_diag_in
89-
integer, intent(in) :: idx_sw_cloudsim_in
90-
integer, intent(in) :: idx_lw_diag_in
91-
integer, intent(in) :: idx_lw_cloudsim_in
92-
character(len=512) :: errmsg
93-
integer :: errflg
94-
95-
ktopcam = ktcam
96-
ktoprad = ktrad
97-
idx_sw_diag = idx_sw_diag_in
98-
idx_nir_diag = idx_nir_diag_in
99-
idx_uv_diag = idx_uv_diag_in
100-
idx_sw_cloudsim = idx_sw_cloudsim_in
101-
idx_lw_diag = idx_lw_diag_in
102-
idx_lw_cloudsim = idx_lw_cloudsim_in
103-
104-
! Initialize the module data containing the SW band boundaries.
105-
call get_sw_spectral_boundaries_ccpp(sw_low_bounds, sw_high_bounds, 'cm^-1', errmsg, errflg)
106-
if (errflg /= 0) then
107-
call endrun('rrtmgp_inputs_cam_init: error during get_sw_spectral_boundaries_ccpp - message: '//errmsg)
108-
end if
109-
110-
end subroutine rrtmgp_inputs_cam_init
111-
112-
!=========================================================================================
113-
11466
subroutine rrtmgp_get_gas_mmrs(icall, state, pbuf, nlay, gas_mmrs)
11567

11668
! Retrieve mass mixing ratios for radiatively active gases from rad_constituents
@@ -137,11 +89,13 @@ end subroutine rrtmgp_get_gas_mmrs
13789

13890
!==================================================================================================
13991

140-
subroutine rrtmgp_set_aer_lw(icall, state, pbuf, aer_lw)
92+
subroutine rrtmgp_set_aer_lw(ktopcam, ktoprad, icall, state, pbuf, aer_lw)
14193

14294
! Load LW aerosol optical properties into the RRTMGP object.
14395

14496
! Arguments
97+
integer, intent(in) :: ktopcam
98+
integer, intent(in) :: ktoprad
14599
integer, intent(in) :: icall
146100
type(physics_state), target, intent(in) :: state
147101
type(physics_buffer_desc), pointer :: pbuf(:)
@@ -178,11 +132,13 @@ end subroutine rrtmgp_set_aer_lw
178132
!==================================================================================================
179133

180134
subroutine rrtmgp_set_aer_sw( &
181-
icall, state, pbuf, nday, idxday, nnite, idxnite, aer_sw)
135+
ktopcam, ktoprad, icall, state, pbuf, nday, idxday, nnite, idxnite, aer_sw)
182136

183137
! Load SW aerosol optical properties into the RRTMGP object.
184138

185139
! Arguments
140+
integer, intent(in) :: ktopcam
141+
integer, intent(in) :: ktoprad
186142
integer, intent(in) :: icall
187143
type(physics_state), target, intent(in) :: state
188144
type(physics_buffer_desc), pointer :: pbuf(:)

0 commit comments

Comments
 (0)