Skip to content

Commit a1df7b1

Browse files
peverwheeCourtney Peverley
andauthored
Incorporate file I/O object into CCPPized RRTMGP (ESCOMP#258)
Originator(s): peverwhee Description (include issue title and the keyword ['closes', 'fixes', 'resolves'] and issue number): 1. Integrates the new file I/O reader into the ccppized RRTMGP modules. - As a result, splits rrtmgp_lw_cloud_optics.F90 into two (rrtmgp_lw_cloud_optics_data.F90 and utils/rrtmgp_cloud_optics_setup.F90) because the init phase/file I/O piece reads in both LW and SW data. 3. Combines rrtmgp_lw_gas_optics.F90 and rrtmgp_lw_gas_optics_data.F90 to share with NOAA - As a result, splits rrtmgp_inputs.F90 into two (rrtmgp_inputs.F90 and rrtmgp_inputs_setup.F90) to preserve order dependence addresses ESCOMP#154 closes ESCOMP#236 List all namelist files that were added or changed: n/a List all files eliminated and why: D schemes/rrtmgp/rrtmgp_lw_gas_optics_data.F90 List all files added and what they do: A schemes/rrtmgp/rrtmgp_inputs_setup.F90 - essentially the old rrtmgp_inputs_init() A schemes/rrtmgp/rrtmgp_sw_gas_optics.F90 - use file i/o reader to read in gas optics coefficients and load gas optics object (just init phase for now until I complete shortwave) A schemes/rrtmgp/utils/rrtmgp_cloud_optics_setup.F90 - use file i/o reader to read in ice and liquid optics files 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/rrtmgp_inputs.F90 - split out rrtmgp_inputs_init M schemes/rrtmgp/rrtmgp_lw_cloud_optics.F90 - remove init phase; pass in variables read in by rrtmgp_cloud_optics_setup_init() M schemes/rrtmgp/rrtmgp_lw_gas_optics.F90 - add init phase and use file i/o object to read in coefficients file List all automated tests that failed, as well as an explanation for why they weren't fixed: Is this an answer-changing PR? If so, is it a new physics package, algorithm change, tuning change, etc? b4b If yes to the above question, describe how this code was validated with the new/modified features: --------- Co-authored-by: Courtney Peverley <courtneyp@izumi.cgd.ucar.edu>
1 parent addb421 commit a1df7b1

8 files changed

Lines changed: 1137 additions & 538 deletions

File tree

schemes/rrtmgp/rrtmgp_inputs.F90

Lines changed: 0 additions & 335 deletions
Large diffs are not rendered by default.

schemes/rrtmgp/rrtmgp_inputs_setup.F90

Lines changed: 340 additions & 0 deletions
Large diffs are not rendered by default.

schemes/rrtmgp/rrtmgp_lw_cloud_optics.F90

Lines changed: 24 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -8,111 +8,27 @@
88
!! (optical-depth, single-scattering albedo, asymmetry parameter) are computed for ALL
99
!! cloud types visible to RRTMGP.
1010
module rrtmgp_lw_cloud_optics
11-
use ccpp_kinds, only: kind_phys
1211

1312
implicit none
1413
private
15-
public :: rrtmgp_lw_cloud_optics_init
1614
public :: rrtmgp_lw_cloud_optics_run
1715

18-
real(kind_phys), allocatable :: abs_lw_liq(:,:,:)
19-
real(kind_phys), allocatable :: abs_lw_ice(:,:)
20-
real(kind_phys), allocatable :: g_mu(:)
21-
real(kind_phys), allocatable :: g_d_eff(:)
22-
real(kind_phys), allocatable :: g_lambda(:,:)
23-
real(kind_phys) :: tiny
24-
integer :: nmu
25-
integer :: nlambda
26-
integer :: n_g_d
27-
28-
2916
contains
3017

31-
! ######################################################################################
32-
! SUBROUTINE rrtmgp_lw_cloud_optics_init()
33-
! ######################################################################################
34-
!> \section arg_table_rrtmgp_lw_cloud_optics_init Argument Table
35-
!! \htmlinclude rrtmgp_lw_cloud_optics_init.html
36-
!!
37-
subroutine rrtmgp_lw_cloud_optics_init(nmu_in, nlambda_in, n_g_d_in, &
38-
abs_lw_liq_in, abs_lw_ice_in, nlwbands, g_mu_in, g_lambda_in, &
39-
g_d_eff_in, tiny_in, errmsg, errflg)
40-
! Inputs
41-
integer, intent(in) :: nmu_in ! Number of mu samples on grid
42-
integer, intent(in) :: nlambda_in ! Number of lambda scale samples on grid
43-
integer, intent(in) :: n_g_d_in ! Number of radiative effective diameter samples on grid
44-
integer, intent(in) :: nlwbands ! Number of longwave bands
45-
real(kind_phys), dimension(:,:,:), intent(in) :: abs_lw_liq_in ! Longwave mass specific absorption for in-cloud liquid water path
46-
real(kind_phys), dimension(:,:), intent(in) :: abs_lw_ice_in ! Longwave mass specific absorption for in-cloud ice water path
47-
real(kind_phys), dimension(:,:), intent(in) :: g_lambda_in ! lambda scale samples on grid
48-
real(kind_phys), dimension(:), intent(in) :: g_mu_in ! Mu samples on grid
49-
real(kind_phys), dimension(:), intent(in) :: g_d_eff_in ! Radiative effective diameter samples on grid
50-
real(kind_phys), intent(in) :: tiny_in ! Definition of what "tiny" means
51-
52-
! Outputs
53-
character(len=*), intent(out) :: errmsg
54-
integer, intent(out) :: errflg
55-
56-
! Local variables
57-
character(len=256) :: alloc_errmsg
58-
character(len=*), parameter :: sub = 'rrtmgp_lw_cloud_optics_init'
59-
60-
! Set error variables
61-
errmsg = ''
62-
errflg = 0
63-
64-
! Set module-level variables
65-
nmu = nmu_in
66-
nlambda = nlambda_in
67-
n_g_d = n_g_d_in
68-
tiny = tiny_in
69-
! Allocate module-level-variables
70-
allocate(abs_lw_liq(nmu,nlambda,nlwbands), stat=errflg, errmsg=alloc_errmsg)
71-
if (errflg /= 0) then
72-
write(errmsg, '(a,a,a)') sub, ': ERROR allocating abs_lw_liq, message: ', alloc_errmsg
73-
return
74-
end if
75-
allocate(abs_lw_ice(n_g_d,nlwbands), stat=errflg, errmsg=alloc_errmsg)
76-
if (errflg /= 0) then
77-
write(errmsg, '(a,a,a)') sub, ': ERROR allocating abs_lw_ice, message: ', alloc_errmsg
78-
return
79-
end if
80-
allocate(g_mu(nmu), stat=errflg, errmsg=alloc_errmsg)
81-
if (errflg /= 0) then
82-
write(errmsg, '(a,a,a)') sub, ': ERROR allocating g_mu, message: ', alloc_errmsg
83-
return
84-
end if
85-
allocate(g_lambda(nmu,nlambda), stat=errflg, errmsg=alloc_errmsg)
86-
if (errflg /= 0) then
87-
write(errmsg, '(a,a,a)') sub, ': ERROR allocating g_lambda, message: ', alloc_errmsg
88-
return
89-
end if
90-
allocate(g_d_eff(n_g_d), stat=errflg, errmsg=alloc_errmsg)
91-
if (errflg /= 0) then
92-
write(errmsg, '(a,a,a)') sub, ': ERROR allocating g_d_eff, message: ', alloc_errmsg
93-
return
94-
end if
95-
96-
abs_lw_liq = abs_lw_liq_in
97-
abs_lw_ice = abs_lw_ice_in
98-
g_mu = g_mu_in
99-
g_lambda = g_lambda_in
100-
g_d_eff = g_d_eff_in
101-
102-
end subroutine rrtmgp_lw_cloud_optics_init
103-
104-
! ######################################################################################
10518
! SUBROUTINE rrtmgp_lw_cloud_optics_run()
10619
! ######################################################################################
10720
!> \section arg_table_rrtmgp_lw_cloud_optics_run Argument Table
10821
!! \htmlinclude rrtmgp_lw_cloud_optics_run.html
10922
!!
110-
subroutine rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, nlaycam, cld, cldfsnow, cldfgrau, &
111-
cldfprime, kdist_lw, cloud_lw, lamc, pgam, iclwpth, iciwpth, &
112-
dei, icswpth, des, icgrauwpth, degrau, nlwbands, do_snow, do_graupel, pver, &
113-
ktopcam, tauc, cldf, cld_lw_abs, snow_lw_abs, grau_lw_abs, errmsg, errflg)
114-
use ccpp_gas_optics_rrtmgp, only: ty_gas_optics_rrtmgp_ccpp
115-
use ccpp_optical_props, only: ty_optical_props_1scl_ccpp
23+
subroutine rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, nlaycam, cld, cldfsnow, cldfgrau, &
24+
cldfprime, kdist_lw, cloud_lw, lamc, pgam, iclwpth, iciwpth, tiny_in, dei, icswpth, &
25+
des, icgrauwpth, degrau, nlwbands, do_snow, do_graupel, pver, ktopcam, tauc, cldf, &
26+
cld_lw_abs, snow_lw_abs, grau_lw_abs, errmsg, errflg)
27+
use ccpp_gas_optics_rrtmgp, only: ty_gas_optics_rrtmgp_ccpp
28+
use ccpp_optical_props, only: ty_optical_props_1scl_ccpp
29+
use ccpp_kinds, only: kind_phys
30+
use rrtmgp_cloud_optics_setup, only: g_mu, g_lambda, nmu, nlambda, g_d_eff, n_g_d
31+
use rrtmgp_cloud_optics_setup, only: abs_lw_liq, abs_lw_ice
11632
! Compute combined cloud optical properties
11733
! Create MCICA stochastic arrays for cloud LW optical properties
11834
! Initialize optical properties object (cloud_lw) and load with MCICA columns
@@ -137,6 +53,7 @@ subroutine rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, nlaycam, cld, cldfsnow,
13753
real(kind_phys), dimension(:,:), intent(in) :: dei ! Mean effective radius for ice cloud
13854
real(kind_phys), dimension(:,:), intent(in) :: des ! Mean effective radius for snow
13955
real(kind_phys), dimension(:,:), intent(in) :: degrau ! Mean effective radius for graupel
56+
real(kind_phys), intent(in) :: tiny_in
14057
logical, intent(in) :: do_snow ! Flag for whether cldfsnow is present
14158
logical, intent(in) :: do_graupel ! Flag for whether cldfgrau is present
14259
logical, intent(in) :: dolw ! Flag for whether to perform longwave calculation
@@ -179,13 +96,13 @@ subroutine rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, nlaycam, cld, cldfsnow,
17996

18097
! gammadist liquid optics
18198
call liquid_cloud_get_rad_props_lw(ncol, pver, nmu, nlambda, nlwbands, lamc, pgam, g_mu, g_lambda, iclwpth, &
182-
abs_lw_liq, liq_lw_abs, errmsg, errflg)
99+
abs_lw_liq, tiny_in, liq_lw_abs, errmsg, errflg)
183100
if (errflg /= 0) then
184101
return
185102
end if
186103
! Mitchell ice optics
187104
call interpolate_ice_optics_lw(ncol, pver, nlwbands, iciwpth, dei, &
188-
n_g_d, g_d_eff, abs_lw_ice, ice_lw_abs, errmsg, errflg)
105+
n_g_d, g_d_eff, abs_lw_ice, tiny_in, ice_lw_abs, errmsg, errflg)
189106
if (errflg /= 0) then
190107
return
191108
end if
@@ -195,7 +112,7 @@ subroutine rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, nlaycam, cld, cldfsnow,
195112
! add in snow
196113
if (do_snow) then
197114
call interpolate_ice_optics_lw(ncol, pver, nlwbands, icswpth, des, &
198-
n_g_d, g_d_eff, abs_lw_ice, snow_lw_abs, errmsg, errflg)
115+
n_g_d, g_d_eff, abs_lw_ice, tiny_in, snow_lw_abs, errmsg, errflg)
199116
if (errflg /= 0) then
200117
return
201118
end if
@@ -216,7 +133,7 @@ subroutine rrtmgp_lw_cloud_optics_run(dolw, ncol, nlay, nlaycam, cld, cldfsnow,
216133
! add in graupel
217134
if (do_graupel) then
218135
call interpolate_ice_optics_lw(ncol, pver, nlwbands, icgrauwpth, degrau, n_g_d, &
219-
g_d_eff, abs_lw_ice, grau_lw_abs, errmsg, errflg)
136+
g_d_eff, abs_lw_ice, tiny_in, grau_lw_abs, errmsg, errflg)
220137
if (errflg /= 0) then
221138
return
222139
end if
@@ -253,7 +170,8 @@ end subroutine rrtmgp_lw_cloud_optics_run
253170
!==============================================================================
254171

255172
subroutine liquid_cloud_get_rad_props_lw(ncol, pver, nmu, nlambda, nlwbands, lamc, pgam, &
256-
g_mu, g_lambda, iclwpth, abs_lw_liq, abs_od, errmsg, errflg)
173+
g_mu, g_lambda, iclwpth, abs_lw_liq, tiny, abs_od, errmsg, errflg)
174+
use ccpp_kinds, only: kind_phys
257175
! Inputs
258176
integer, intent(in) :: ncol
259177
integer, intent(in) :: pver
@@ -266,6 +184,7 @@ subroutine liquid_cloud_get_rad_props_lw(ncol, pver, nmu, nlambda, nlwbands, lam
266184
real(kind_phys), dimension(:), intent(in) :: g_mu
267185
real(kind_phys), dimension(:,:), intent(in) :: g_lambda
268186
real(kind_phys), dimension(:,:), intent(in) :: iclwpth
187+
real(kind_phys), intent(in) :: tiny
269188
! Outputs
270189
real(kind_phys), dimension(:,:,:), intent(out) :: abs_od
271190
character(len=*), intent(out) :: errmsg
@@ -283,7 +202,7 @@ subroutine liquid_cloud_get_rad_props_lw(ncol, pver, nmu, nlambda, nlwbands, lam
283202
do idx = 1,ncol
284203
if(lamc(idx,kdx) > 0._kind_phys) then ! This seems to be the clue for no cloud from microphysics formulation
285204
call gam_liquid_lw(nlwbands, nmu, nlambda, iclwpth(idx,kdx), lamc(idx,kdx), pgam(idx,kdx), abs_lw_liq, &
286-
g_mu, g_lambda, abs_od(1:nlwbands,idx,kdx), errmsg, errflg)
205+
g_mu, g_lambda, tiny, abs_od(1:nlwbands,idx,kdx), errmsg, errflg)
287206
else
288207
abs_od(1:nlwbands,idx,kdx) = 0._kind_phys
289208
endif
@@ -294,9 +213,10 @@ end subroutine liquid_cloud_get_rad_props_lw
294213

295214
!==============================================================================
296215

297-
subroutine gam_liquid_lw(nlwbands, nmu, nlambda, clwptn, lamc, pgam, abs_lw_liq, g_mu, g_lambda, abs_od, errmsg, errflg)
216+
subroutine gam_liquid_lw(nlwbands, nmu, nlambda, clwptn, lamc, pgam, abs_lw_liq, g_mu, g_lambda, tiny, abs_od, errmsg, errflg)
298217
use interpolate_data, only: interp_type, lininterp, lininterp_finish
299218
use radiation_utils, only: get_mu_lambda_weights_ccpp
219+
use ccpp_kinds, only: kind_phys
300220
! Inputs
301221
integer, intent(in) :: nlwbands
302222
integer, intent(in) :: nmu
@@ -307,6 +227,7 @@ subroutine gam_liquid_lw(nlwbands, nmu, nlambda, clwptn, lamc, pgam, abs_lw_liq,
307227
real(kind_phys), dimension(:,:,:), intent(in) :: abs_lw_liq
308228
real(kind_phys), dimension(:), intent(in) :: g_mu
309229
real(kind_phys), dimension(:,:) , intent(in) :: g_lambda
230+
real(kind_phys), intent(in) :: tiny
310231
! Outputs
311232
real(kind_phys), dimension(:), intent(out) :: abs_od
312233
integer, intent(out) :: errflg
@@ -342,9 +263,10 @@ end subroutine gam_liquid_lw
342263
!==============================================================================
343264

344265
subroutine interpolate_ice_optics_lw(ncol, pver, nlwbands, iciwpth, dei, &
345-
n_g_d, g_d_eff, abs_lw_ice, abs_od, errmsg, errflg)
266+
n_g_d, g_d_eff, abs_lw_ice, tiny, abs_od, errmsg, errflg)
346267
use interpolate_data, only: interp_type, lininterp, lininterp_init, &
347268
lininterp_finish, extrap_method_bndry
269+
use ccpp_kinds, only: kind_phys
348270

349271
integer, intent(in) :: ncol
350272
integer, intent(in) :: n_g_d
@@ -354,6 +276,7 @@ subroutine interpolate_ice_optics_lw(ncol, pver, nlwbands, iciwpth, dei, &
354276
real(kind_phys), dimension(:,:), intent(in) :: iciwpth
355277
real(kind_phys), dimension(:,:), intent(in) :: dei
356278
real(kind_phys), dimension(:,:), intent(in) :: abs_lw_ice
279+
real(kind_phys), intent(in) :: tiny
357280
real(kind_phys), dimension(:,:,:), intent(out) :: abs_od
358281
character(len=*), intent(out) :: errmsg
359282
integer, intent(out) :: errflg

0 commit comments

Comments
 (0)