@@ -19,11 +19,13 @@ using Random
19
19
abstract type AbstractRRTMGPMode end
20
20
struct GrayRadiation <: AbstractRRTMGPMode
21
21
add_isothermal_boundary_layer:: Bool
22
+ deep_atmosphere:: Bool
22
23
end
23
24
struct ClearSkyRadiation <: AbstractRRTMGPMode
24
25
idealized_h2o:: Bool
25
26
add_isothermal_boundary_layer:: Bool
26
27
aerosol_radiation:: Bool
28
+ deep_atmosphere:: Bool
27
29
end
28
30
struct AllSkyRadiation{ACR <: AbstractCloudInRadiation } <: AbstractRRTMGPMode
29
31
idealized_h2o:: Bool
@@ -39,6 +41,7 @@ struct AllSkyRadiation{ACR <: AbstractCloudInRadiation} <: AbstractRRTMGPMode
39
41
Disable this option when running production runs.
40
42
"""
41
43
reset_rng_seed:: Bool
44
+ deep_atmosphere:: Bool
42
45
end
43
46
struct AllSkyRadiationWithClearSkyDiagnostics{
44
47
ACR <: AbstractCloudInRadiation ,
@@ -56,6 +59,7 @@ struct AllSkyRadiationWithClearSkyDiagnostics{
56
59
Disable this option when running production runs.
57
60
"""
58
61
reset_rng_seed:: Bool
62
+ deep_atmosphere:: Bool
59
63
end
60
64
61
65
"""
@@ -260,7 +264,7 @@ function extrap!(
260
264
@. p = p⁺ * (T / T⁺)^ (cₚ / R)
261
265
end
262
266
263
- struct RRTMGPModel{R, I, B, L, P, LWS, SWS, AS, V}
267
+ struct RRTMGPModel{R, I, B, L, P, LWS, SWS, AS, V, M }
264
268
radiation_mode:: R
265
269
interpolation:: I
266
270
bottom_extrapolation:: B
@@ -270,6 +274,7 @@ struct RRTMGPModel{R, I, B, L, P, LWS, SWS, AS, V}
270
274
sw_solver:: SWS
271
275
as:: AS # Atmospheric state
272
276
views:: V # user-friendly views into the solver
277
+ metric_scaling:: M
273
278
end
274
279
275
280
# Allow cache to be moved on the CPU. Used by ClimaCoupler to save checkpoints
@@ -539,6 +544,7 @@ array.
539
544
`requires_z(interpolation) || requires_z(bottom_extrapolation)`:
540
545
- `center_z`: z-coordinate in m at cell centers
541
546
- `face_z`: z-coordinate in m at cell faces
547
+ - `planet_radius`: planet radius (used to compute metric scaling factor)
542
548
"""
543
549
RRTMGPModel (
544
550
params:: RRTMGP.Parameters.ARP ,
@@ -694,6 +700,11 @@ function _RRTMGPModel(
694
700
end
695
701
696
702
p_lev = DA {FT} (undef, nlay + 1 , ncol)
703
+ if radiation_mode. deep_atmosphere && :planet_radius in keys (dict)
704
+ metric_scaling = DA {FT} (undef, nlay + 1 , ncol)
705
+ else
706
+ metric_scaling = nothing
707
+ end
697
708
t_lev = DA {FT} (undef, nlay + 1 , ncol)
698
709
t_sfc = DA {FT} (undef, ncol)
699
710
set_and_save! (t_sfc, " surface_temperature" , t... , dict)
@@ -863,7 +874,6 @@ function _RRTMGPModel(
863
874
else
864
875
aerosol_state = nothing
865
876
end
866
-
867
877
as = RRTMGP. AtmosphericStates. AtmosphericState (
868
878
lon,
869
879
lat,
@@ -876,7 +886,6 @@ function _RRTMGPModel(
876
886
cloud_state,
877
887
aerosol_state,
878
888
)
879
-
880
889
end
881
890
882
891
sw_solver = RRTMGP. RTE. TwoStreamSWRTE (
@@ -901,6 +910,14 @@ function _RRTMGPModel(
901
910
set_and_save! (z_lay, " center_z" , t... , dict)
902
911
z_lev = DA {FT} (undef, nlay + 1 , ncol)
903
912
set_and_save! (z_lev, " face_z" , t... , dict)
913
+ if radiation_mode. deep_atmosphere && :planet_radius in keys (dict)
914
+ planet_radius = pop! (dict, :planet_radius )
915
+ # Area ratio appears in denominator of RRTMGP scaling functions,
916
+ # we therefore pass the multiplicative inverse from ClimaAtmos to
917
+ # use mult ops instead of div in RRTMGP GPU kernels.
918
+ metric_scaling .=
919
+ inv .(((z_lev .+ planet_radius) ./ planet_radius) .^ (FT (2 )))
920
+ end
904
921
end
905
922
906
923
if length (dict) > 0
@@ -921,6 +938,7 @@ function _RRTMGPModel(
921
938
sw_solver,
922
939
as,
923
940
NamedTuple (views),
941
+ metric_scaling,
924
942
)
925
943
end
926
944
@@ -1143,14 +1161,15 @@ get_vmr_h2o(vmr::RRTMGP.Vmrs.Vmr, idx_gases_sw) =
1143
1161
view (vmr. vmr, idx_gases_sw[" h2o" ], :, :)
1144
1162
1145
1163
NVTX. @annotate update_lw_fluxes! (:: GrayRadiation , model) =
1146
- RRTMGP. RTESolver. solve_lw! (model. lw_solver, model. as)
1164
+ RRTMGP. RTESolver. solve_lw! (model. lw_solver, model. as, model . metric_scaling )
1147
1165
NVTX. @annotate update_lw_fluxes! (:: ClearSkyRadiation , model) =
1148
1166
RRTMGP. RTESolver. solve_lw! (
1149
1167
model. lw_solver,
1150
1168
model. as,
1151
1169
model. lookups. lookup_lw,
1152
1170
nothing ,
1153
1171
model. lookups. lookup_lw_aero,
1172
+ model. metric_scaling,
1154
1173
)
1155
1174
NVTX. @annotate update_lw_fluxes! (:: AllSkyRadiation , model) =
1156
1175
RRTMGP. RTESolver. solve_lw! (
@@ -1159,6 +1178,7 @@ NVTX.@annotate update_lw_fluxes!(::AllSkyRadiation, model) =
1159
1178
model. lookups. lookup_lw,
1160
1179
model. lookups. lookup_lw_cld,
1161
1180
model. lookups. lookup_lw_aero,
1181
+ model. metric_scaling,
1162
1182
)
1163
1183
NVTX. @annotate function update_lw_fluxes! (
1164
1184
:: AllSkyRadiationWithClearSkyDiagnostics ,
@@ -1170,6 +1190,7 @@ NVTX.@annotate function update_lw_fluxes!(
1170
1190
model. lookups. lookup_lw,
1171
1191
nothing ,
1172
1192
model. lookups. lookup_lw_aero,
1193
+ model. metric_scaling,
1173
1194
)
1174
1195
parent (model. face_clear_lw_flux_up) .= parent (model. face_lw_flux_up)
1175
1196
parent (model. face_clear_lw_flux_dn) .= parent (model. face_lw_flux_dn)
@@ -1180,18 +1201,20 @@ NVTX.@annotate function update_lw_fluxes!(
1180
1201
model. lookups. lookup_lw,
1181
1202
model. lookups. lookup_lw_cld,
1182
1203
model. lookups. lookup_lw_aero,
1204
+ model. metric_scaling,
1183
1205
)
1184
1206
end
1185
1207
1186
1208
NVTX. @annotate update_sw_fluxes! (:: GrayRadiation , model) =
1187
- RRTMGP. RTESolver. solve_sw! (model. sw_solver, model. as)
1209
+ RRTMGP. RTESolver. solve_sw! (model. sw_solver, model. as, model . metric_scaling )
1188
1210
NVTX. @annotate update_sw_fluxes! (:: ClearSkyRadiation , model) =
1189
1211
RRTMGP. RTESolver. solve_sw! (
1190
1212
model. sw_solver,
1191
1213
model. as,
1192
1214
model. lookups. lookup_sw,
1193
1215
nothing ,
1194
1216
model. lookups. lookup_sw_aero,
1217
+ model. metric_scaling,
1195
1218
)
1196
1219
NVTX. @annotate update_sw_fluxes! (:: AllSkyRadiation , model) =
1197
1220
RRTMGP. RTESolver. solve_sw! (
@@ -1200,6 +1223,7 @@ NVTX.@annotate update_sw_fluxes!(::AllSkyRadiation, model) =
1200
1223
model. lookups. lookup_sw,
1201
1224
model. lookups. lookup_sw_cld,
1202
1225
model. lookups. lookup_sw_aero,
1226
+ model. metric_scaling,
1203
1227
)
1204
1228
NVTX. @annotate function update_sw_fluxes! (
1205
1229
:: AllSkyRadiationWithClearSkyDiagnostics ,
@@ -1211,6 +1235,7 @@ NVTX.@annotate function update_sw_fluxes!(
1211
1235
model. lookups. lookup_sw,
1212
1236
nothing ,
1213
1237
model. lookups. lookup_sw_aero,
1238
+ model. metric_scaling,
1214
1239
)
1215
1240
parent (model. face_clear_sw_flux_up) .= parent (model. face_sw_flux_up)
1216
1241
parent (model. face_clear_sw_flux_dn) .= parent (model. face_sw_flux_dn)
@@ -1223,6 +1248,7 @@ NVTX.@annotate function update_sw_fluxes!(
1223
1248
model. lookups. lookup_sw,
1224
1249
model. lookups. lookup_sw_cld,
1225
1250
model. lookups. lookup_sw_aero,
1251
+ model. metric_scaling,
1226
1252
)
1227
1253
end
1228
1254
0 commit comments