Skip to content

Commit 36597ae

Browse files
committed
update rrtmgp interfaces; add constituent stubs to get atmospheric physics to build
1 parent e2e6008 commit 36597ae

File tree

3 files changed

+113
-22
lines changed

3 files changed

+113
-22
lines changed

src/physics/rrtmgp/radiation.F90

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ module radiation
220220

221221
integer :: nlwgpts
222222
integer :: nswgpts
223+
integer :: changeseed
224+
integer :: irad_always_modified
223225

224226
real(kind=r8) :: tiny
225227

@@ -413,7 +415,7 @@ subroutine radiation_init(pbuf2d)
413415
use rrtmgp_inputs_setup, only: rrtmgp_inputs_setup_init
414416
use rrtmgp_inputs_cam, only: rrtmgp_inputs_cam_init
415417
use rrtmgp_cloud_optics_setup, only: rrtmgp_cloud_optics_setup_init
416-
use rrtmgp_sw_solar_var, only: rrtmgp_sw_solar_var_init
418+
use rrtmgp_sw_solar_var_setup, only: rrtmgp_sw_solar_var_setup_init
417419
use solar_irrad_data, only: do_spctrl_scaling, has_spectrum
418420
use cloud_rad_props, only: cloud_rad_props_init
419421
use rad_constituents, only: iceopticsfile, liqopticsfile
@@ -445,14 +447,16 @@ subroutine radiation_init(pbuf2d)
445447
! liquid budgets.
446448
integer :: history_budget_histfile_num ! history file number for budget fields
447449
integer :: ierr, istat, errflg
450+
character(len=5) :: gaslist_tmp(8)
448451

449452
integer :: dtime
453+
real(r8) :: dtime_r8
450454

451455
character(len=*), parameter :: sub = 'radiation_init'
452456
!-----------------------------------------------------------------------
453457

454458
! Initialize available_gases object
455-
call rrtmgp_pre_init(nradgas, gaslist, available_gases, gaslist_lc, errmsg, errflg)
459+
call rrtmgp_pre_init(nradgas, available_gases, gaslist_tmp, gaslist_lc, errmsg, errflg)
456460
if (errflg /= 0) then
457461
call endrun(sub//': '//errmsg)
458462
end if
@@ -467,13 +471,16 @@ subroutine radiation_init(pbuf2d)
467471
call endrun(sub//': sw '//errmsg)
468472
end if
469473

474+
dtime = get_step_size()
475+
dtime_r8 = real(dtime, r8)
476+
470477
! Set up inputs to RRTMGP
471478
call rrtmgp_inputs_setup_init(ktopcam, ktoprad, nlaycam, sw_low_bounds, sw_high_bounds, nswbands, &
472479
pref_edge, nlay, pver, pverp, kdist_sw, kdist_lw, qrl_unused, is_first_step(), use_rad_dt_cosz, &
473-
get_step_size(), get_nstep(), iradsw, dt_avg, irad_always, is_first_restart_step(), &
480+
dtime_r8, get_nstep(), iradsw, dt_avg, irad_always, is_first_restart_step(), &
474481
p_top_for_equil_rad, nlwbands, nradgas, gasnamelength, idx_sw_diag, idx_nir_diag, idx_uv_diag, &
475-
idx_sw_cloudsim, idx_lw_diag, idx_lw_cloudsim, nswgpts, nlwgpts, nlayp, nextsw_cday, &
476-
get_curr_calday(), band2gpt_sw, errmsg, errflg)
482+
idx_sw_cloudsim, idx_lw_diag, idx_lw_cloudsim, nswgpts, nlwgpts, changeseed, nlayp, nextsw_cday, &
483+
get_curr_calday(), band2gpt_sw, irad_always_modified, errmsg, errflg)
477484
if (errflg /= 0) then
478485
call endrun(sub//': '//errmsg)
479486
end if
@@ -485,7 +492,7 @@ subroutine radiation_init(pbuf2d)
485492
! Set radconstants module-level index variables that we're setting in CCPP-ized scheme now
486493
call radconstants_init(idx_sw_diag, idx_nir_diag, idx_uv_diag, idx_lw_diag)
487494

488-
call rrtmgp_sw_solar_var_init(nswbands, do_spctrl_scaling, has_spectrum, errmsg, errflg)
495+
call rrtmgp_sw_solar_var_setup_init(nswbands, do_spctrl_scaling, has_spectrum, errmsg, errflg)
489496
if (errflg /= 0) then
490497
call endrun(sub//': '//errmsg)
491498
end if
@@ -890,6 +897,7 @@ subroutine radiation_tend( &
890897
real(r8) :: cld_lw_abs(nlwbands,state%ncol,pver) ! Cloud absorption optics depth
891898
real(r8) :: snow_lw_abs(nlwbands,state%ncol,pver) ! Snow absorption optics depth
892899
real(r8) :: grau_lw_abs(nlwbands,state%ncol,pver) ! Graupel absorption optics depth
900+
real(r8) :: c_cld_lw_abs(nlwbands,state%ncol,pver)
893901
real(r8) :: cld_tau(nswbands,state%ncol,pver) ! Cloud absorption optical depth (sw)
894902
real(r8) :: snow_tau(nswbands,state%ncol,pver) ! Snow absorption optical depth (sw)
895903
real(r8) :: grau_tau(nswbands,state%ncol,pver) ! Graupel absorption optical depth (sw)
@@ -1005,8 +1013,11 @@ subroutine radiation_tend( &
10051013
real(r8) :: gb_snow_lw(pcols,pver) ! grid-box mean LW snow optical depth
10061014

10071015
logical :: is_mpas ! Flag for whether the dycore is MPAS
1016+
logical :: dosw_heat, dolw_heat
10081017
real(r8) :: ftem(pcols,pver) ! Temporary workspace for outfld variables
10091018
real(r8), target :: zero_variable(1,1)
1019+
integer :: dtime
1020+
real(r8) :: dtime_r8
10101021

10111022
character(len=512) :: errmsg
10121023
integer :: errflg, err
@@ -1048,8 +1059,12 @@ subroutine radiation_tend( &
10481059
end do
10491060
end if
10501061

1062+
dtime = get_step_size()
1063+
dtime_r8 = real(dtime, r8)
1064+
10511065
! Get next SW radiation timestep
1052-
call rrtmgp_pre_timestep_init(get_nstep(), get_step_size(), iradsw, irad_always, offset, errmsg, errflg)
1066+
call rrtmgp_pre_timestep_init(ncol, coszrs, get_nstep(), dtime_r8, iradsw, &
1067+
irad_always_modified, offset, idxday, nday, idxnite, nnite, errmsg, errflg)
10531068
if (errflg /= 0) then
10541069
call endrun(sub//': '//errmsg)
10551070
end if
@@ -1060,9 +1075,10 @@ subroutine radiation_tend( &
10601075

10611076
! Determine if we're running radiation (sw and/or lw) this timestep,
10621077
! find daylight and nighttime indices, and initialize fluxes
1063-
call rrtmgp_pre_run(coszrs(:ncol), get_nstep(), get_step_size(), iradsw, iradlw, irad_always, &
1064-
ncol, next_cday, idxday, nday, idxnite, nnite, dosw, dolw, nlay, nlwbands, &
1065-
nswbands, spectralflux, nextsw_cday, fsw, fswc, flw, flwc, errmsg, errflg)
1078+
call rrtmgp_pre_run(coszrs(:ncol), get_nstep(), dtime_r8, iradsw, iradlw, irad_always_modified, &
1079+
ncol, next_cday, idxday, nday, idxnite, nnite, dosw, dolw, dosw_heat, dolw_heat, &
1080+
nlay, nlwbands, nswbands, spectralflux, nextsw_cday, fsw, fswc, flw, flwc, &
1081+
errmsg, errflg)
10661082
if (errflg /= 0) then
10671083
call endrun(sub//': '//errmsg)
10681084
end if
@@ -1178,7 +1194,7 @@ subroutine radiation_tend( &
11781194
! Prepare state variables, daylit columns, albedos for RRTMGP
11791195
! Also calculate modified cloud fraction
11801196
call rrtmgp_inputs_run(dosw, dolw, associated(cldfsnow), associated(cldfgrau), &
1181-
masterproc, iulog, is_mpas, state%pmid(:ncol,:), state%pint(:ncol,:), state%t(:ncol,:), &
1197+
(.not. is_mpas), state%pmid(:ncol,:), state%pint(:ncol,:), state%t(:ncol,:), &
11821198
nday, idxday, cldfprime(:ncol,:), coszrs(:ncol), kdist_sw, t_sfc, &
11831199
emis_sfc, t_rad, pmid_rad, pint_rad, t_day, pmid_day, &
11841200
pint_day, coszrs_day, alb_dir, alb_dif, cam_in%lwup(:ncol), stebol, &
@@ -1203,7 +1219,7 @@ subroutine radiation_tend( &
12031219
if (dosw) then
12041220

12051221
! Set cloud optical properties in cloud_sw object.
1206-
call rrtmgp_sw_cloud_optics_run(dosw, ncol, pver, ktopcam, ktoprad, nlay, nswgpts, nday, idxday, &
1222+
call rrtmgp_sw_cloud_optics_run(dosw, ncol, pver, ktopcam, ktoprad, nswgpts, nday, idxday, &
12071223
fillvalue, nswbands, iulog, mu(:ncol,:), lambda(:ncol,:), nnite, idxnite, cld, cldfsnow_in, &
12081224
cldfgrau_in, cldfprime(:ncol,:), cld_tau(:,:ncol,:), grau_tau(:,:ncol,:), snow_tau(:,:ncol,:), &
12091225
degrau(:ncol,:), dei(:ncol,:), des(:ncol,:), iclwp(:ncol,:), iciwp(:ncol,:), icswp(:ncol,:), &
@@ -1260,8 +1276,8 @@ subroutine radiation_tend( &
12601276
!$acc end data
12611277

12621278
! Scale the solar source
1263-
call rrtmgp_sw_solar_var_run(toa_flux, band2gpt_sw, nswbands, sol_irrad, we, nbins, sol_tsi, &
1264-
do_spctrl_scaling, sfac, eccf, errmsg, errflg)
1279+
call rrtmgp_sw_solar_var_run(toa_flux, 2, band2gpt_sw, nswbands, sol_irrad, we, nbins, sol_tsi, &
1280+
nday, dosw, do_spctrl_scaling, sfac, eccf, errmsg, errflg)
12651281
if (errflg /= 0) then
12661282
call endrun(sub//': '//errmsg)
12671283
end if
@@ -1311,11 +1327,11 @@ subroutine radiation_tend( &
13111327
if (dolw) then
13121328

13131329
! Set cloud optical properties in cloud_lw object.
1314-
call rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, nlaycam, cld(:ncol,:), cldfsnow_in, &
1330+
call rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, cld(:ncol,:), cldfsnow_in, &
13151331
cldfgrau_in, cldfprime(:ncol,:), kdist_lw, cloud_lw, lambda(:ncol,:), mu(:ncol,:), &
13161332
iclwp(:ncol,:), iciwp(:ncol,:), tiny, dei(:ncol,:), icswp(:ncol,:), des(:ncol,:), &
13171333
icgrauwp(:ncol,:), degrau(:ncol,:), nlwbands, do_snow, do_graupel, pver, ktopcam, &
1318-
tauc, cldf, cld_lw_abs, snow_lw_abs, grau_lw_abs, errmsg, errflg)
1334+
cld_lw_abs, snow_lw_abs, grau_lw_abs, c_cld_lw_abs, errmsg, errflg)
13191335
if (errflg /= 0) then
13201336
call endrun(sub//': '//errmsg)
13211337
end if
@@ -1326,9 +1342,9 @@ subroutine radiation_tend( &
13261342
grau_lw_abs_cloudsim(:ncol,:) = grau_lw_abs(idx_lw_cloudsim,:,:)
13271343

13281344
! Create McICA stochastic arrays for lw cloud optical properties
1329-
call rrtmgp_lw_mcica_subcol_gen_run(dolw, ktoprad, &
1330-
kdist_lw, nlwbands, nlwgpts, ncol, pver, nlaycam, nlwgpts, &
1331-
state%pmid(:ncol,:), cldf, tauc, cloud_lw, errmsg, errflg )
1345+
call rrtmgp_lw_mcica_subcol_gen_run(dolw, ktoprad, ktopcam, &
1346+
kdist_lw, nlwbands, changeseed, ncol, pver, nlaycam, cldfprime(:ncol,:), &
1347+
c_cld_lw_abs, nlwgpts, state%pmid(:ncol,:), cloud_lw, errmsg, errflg )
13321348
if (errflg /= 0) then
13331349
call endrun(sub//': '//errmsg)
13341350
end if
@@ -1491,9 +1507,9 @@ subroutine radiation_tend( &
14911507
cam_out%netsw(:) = 0._r8
14921508

14931509
! Calculate radiative heating (Q*dp), set netsw flux, and do object cleanup
1494-
call rrtmgp_post_run(qrs_prime(:ncol,:), qrl_prime(:ncol,:), fsns(:ncol), state%pdel(:ncol,:), atm_optics_sw, cloud_sw, &
1495-
aer_sw, fsw, fswc, atm_optics_lw, sources_lw, cloud_lw, aer_lw, flw, flwc, qrs(:ncol,:), qrl(:ncol,:), &
1496-
cam_out%netsw(:ncol), errmsg, errflg)
1510+
call rrtmgp_post_run(nlay, dolw, qrs_prime(:ncol,:), qrl_prime(:ncol,:), fsns(:ncol), state%pdel(:ncol,:), &
1511+
atm_optics_sw, cloud_sw, aer_sw, fsw, fswc, atm_optics_lw, sources_lw, cloud_lw, aer_lw, flw, flwc,&
1512+
cam_out%flwds(:ncol), qrs(:ncol,:), qrl(:ncol,:), cam_out%netsw(:ncol), errmsg, errflg)
14971513
if (errflg /= 0) then
14981514
call endrun(sub//': '//errmsg)
14991515
end if

src/utils/cam_ccpp/ccpp_constituent_prop_mod.F90

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ module ccpp_constituent_prop_mod
2323

2424
end type ccpp_constituent_prop_ptr_t
2525

26+
type, public :: ccpp_constituent_properties_t
27+
contains
28+
procedure :: instantiate
29+
end type ccpp_constituent_properties_t
30+
2631
! CCPP properties init routine
2732
public :: ccpp_const_props_init
2833

2934
! Public properties DDT variable:
3035
type(ccpp_constituent_prop_ptr_t), allocatable, public :: ccpp_const_props(:)
36+
integer, public, parameter :: int_unassigned = HUGE(-1)
3137

3238
contains
3339

@@ -275,4 +281,31 @@ subroutine ccpp_const_props_init(ix_qv)
275281

276282
end subroutine ccpp_const_props_init
277283

284+
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++
285+
!CAM-equivalent stub so dynamic constituents register routines can build
286+
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++
287+
subroutine instantiate(this, std_name, long_name, units, vertical_dim, &
288+
advected, default_value, min_value, molar_mass, water_species, &
289+
mixing_ratio_type, errcode, errmsg)
290+
use ccpp_kinds, only: kind_phys
291+
292+
! Dummy arguments
293+
class(ccpp_constituent_properties_t), intent(inout) :: this
294+
character(len=*), intent(in) :: std_name
295+
character(len=*), intent(in) :: long_name
296+
character(len=*), intent(in) :: units
297+
character(len=*), intent(in) :: vertical_dim
298+
logical, optional, intent(in) :: advected
299+
real(kind_phys), optional, intent(in) :: default_value
300+
real(kind_phys), optional, intent(in) :: min_value
301+
real(kind_phys), optional, intent(in) :: molar_mass
302+
logical, optional, intent(in) :: water_species
303+
character(len=*), optional, intent(in) :: mixing_ratio_type
304+
integer, intent(out) :: errcode
305+
character(len=*), intent(out) :: errmsg
306+
307+
! STUB DOES NOTHING
308+
309+
end subroutine instantiate
310+
278311
end module ccpp_constituent_prop_mod
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module ccpp_scheme_utils
2+
3+
! Module of utilities available to CCPP schemes; CAM stubs to enable CCPPized schemes to build
4+
5+
implicit none
6+
private
7+
8+
!! Public interfaces
9+
public :: ccpp_constituent_index ! Lookup index constituent by name
10+
public :: ccpp_constituent_indices ! Lookup indices of consitutents by name
11+
12+
contains
13+
subroutine ccpp_constituent_index(standard_name, const_index, errcode, errmsg)
14+
! Dummy arguments
15+
character(len=*), intent(in) :: standard_name
16+
integer, intent(out) :: const_index
17+
integer, optional, intent(out) :: errcode
18+
character(len=*), optional, intent(out) :: errmsg
19+
20+
! Local variable
21+
character(len=*), parameter :: subname = 'ccpp_constituent_index'
22+
23+
! STUB DOES NOTHING
24+
25+
end subroutine ccpp_constituent_index
26+
27+
subroutine ccpp_constituent_indices(standard_names, const_inds, errcode, errmsg)
28+
! Dummy arguments
29+
character(len=*), intent(in) :: standard_names(:)
30+
integer, intent(out) :: const_inds(:)
31+
integer, optional, intent(out) :: errcode
32+
character(len=*), optional, intent(out) :: errmsg
33+
34+
! Local variables
35+
integer :: indx
36+
character(len=*), parameter :: subname = 'ccpp_constituent_indices'
37+
38+
! STUB DOES NOTHING
39+
40+
end subroutine ccpp_constituent_indices
41+
42+
end module ccpp_scheme_utils

0 commit comments

Comments
 (0)