Skip to content

Commit 8180646

Browse files
Assume implied_values = :face
1 parent aca95c1 commit 8180646

File tree

1 file changed

+23
-83
lines changed

1 file changed

+23
-83
lines changed

src/parameterized_tendencies/radiation/RRTMGPInterface.jl

Lines changed: 23 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ struct RRTMGPModel{R, I, B, L, P, LWS, SWS, AS, V}
264264
radiation_mode::R
265265
interpolation::I
266266
bottom_extrapolation::B
267-
implied_values::Symbol
268267
lookups::L
269268
params::P
270269
lw_solver::LWS
@@ -303,11 +302,8 @@ After constructing an `RRTMGPModel`, use it as follows:
303302
- use the values of any fluxes of interest; e.g.,
304303
`field2array(face_flux_field) .= model.face_flux`
305304
306-
To construct the `RRTMGPModel`, one must specify `center_pressure` and
307-
`center_temperature`, or `face_pressure` and `face_temperature`, or all four
308-
values. If only the values at cell centers are specified, the values at cell
309-
faces are "implied values". Likewise, if only the values at faces are specified,
310-
the values at centers are "implied values".
305+
The `RRTMGPModel` assumes that pressure and temperature live on cell centers,
306+
and internally interpolates data to cell faces when needed.
311307
312308
Every keyword argument that corresponds to an array of cell center or cell face
313309
values can be specified as a scalar (corresponding to a constant value
@@ -430,49 +426,9 @@ function RRTMGPModel(
430426
GrayRadiation"
431427
end
432428

433-
if (
434-
:center_pressure in keys(dict) &&
435-
:center_temperature in keys(dict) &&
436-
:face_pressure in keys(dict) &&
437-
:face_temperature in keys(dict)
438-
)
439-
if !(interpolation isa NoInterpolation)
440-
@warn "interpolation is ignored if both center and face pressures/\
441-
temperatures are specified"
442-
end
443-
implied_values = :none
444-
elseif (
445-
:center_pressure in keys(dict) &&
446-
:center_temperature in keys(dict) &&
447-
!(:face_pressure in keys(dict)) &&
448-
!(:face_temperature in keys(dict))
449-
)
450-
if interpolation isa NoInterpolation
451-
error("interpolation cannot be NoInterpolation if only center \
452-
pressures/temperatures are specified")
453-
end
454-
implied_values = :face
455-
elseif (
456-
!(:center_pressure in keys(dict)) &&
457-
!(:center_temperature in keys(dict)) &&
458-
:face_pressure in keys(dict) &&
459-
:face_temperature in keys(dict)
460-
)
461-
if interpolation isa NoInterpolation
462-
error("interpolation cannot be NoInterpolation if only face \
463-
pressures/temperatures are specified")
464-
end
465-
implied_values = :center
466-
else
467-
error("please specify either center_pressure and center_temperature, \
468-
or face_pressure and face_temperature, or all four values")
469-
end
470-
471-
if implied_values != :face
472-
if !(bottom_extrapolation isa SameAsInterpolation)
473-
@warn "bottom_extrapolation is ignored if face_pressure and \
474-
face_temperature are specified"
475-
end
429+
if interpolation isa NoInterpolation
430+
error("interpolation cannot be NoInterpolation if only center \
431+
pressures/temperatures are specified")
476432
end
477433

478434
lookups = NamedTuple()
@@ -652,20 +608,14 @@ function RRTMGPModel(
652608

653609
p_lev = DA{FT}(undef, nlay + 1, ncol)
654610
t_lev = DA{FT}(undef, nlay + 1, ncol)
655-
if implied_values != :face
656-
set_and_save!(p_lev, "face_pressure", t..., dict)
657-
set_and_save!(t_lev, "face_temperature", t..., dict)
658-
end
659611
t_sfc = DA{FT}(undef, ncol)
660612
set_and_save!(t_sfc, "surface_temperature", t..., dict)
661613

662614
if radiation_mode isa GrayRadiation
663615
p_lay = DA{FT}(undef, nlay, ncol)
664616
t_lay = DA{FT}(undef, nlay, ncol)
665-
if implied_values != :center
666-
set_and_save!(p_lay, "center_pressure", t..., dict)
667-
set_and_save!(t_lay, "center_temperature", t..., dict)
668-
end
617+
set_and_save!(p_lay, "center_pressure", t..., dict)
618+
set_and_save!(t_lay, "center_temperature", t..., dict)
669619

670620
z_lev = DA{FT}(undef, nlay + 1, ncol) # TODO: z_lev required but unused
671621

@@ -696,11 +646,9 @@ function RRTMGPModel(
696646
p_lay = view(layerdata, 2, :, :)
697647
t_lay = view(layerdata, 3, :, :)
698648
rh_lay = view(layerdata, 4, :, :)
699-
if implied_values != :center
700-
set_and_save!(p_lay, "center_pressure", t..., dict)
701-
set_and_save!(t_lay, "center_temperature", t..., dict)
702-
set_and_save!(rh_lay, "center_relative_humidity", t..., dict)
703-
end
649+
set_and_save!(p_lay, "center_pressure", t..., dict)
650+
set_and_save!(t_lay, "center_temperature", t..., dict)
651+
set_and_save!(rh_lay, "center_relative_humidity", t..., dict)
704652
vmr_str = "volume_mixing_ratio_"
705653
gas_names = filter(
706654
gas_name ->
@@ -899,7 +847,6 @@ function RRTMGPModel(
899847
radiation_mode,
900848
interpolation,
901849
bottom_extrapolation,
902-
implied_values,
903850
lookups,
904851
params,
905852
lw_solver,
@@ -988,7 +935,7 @@ NVTX.@annotate function update_fluxes!(model, seedval)
988935
)
989936
radiation_mode.reset_rng_seed && Random.seed!(seedval)
990937
end
991-
model.implied_values != :none && update_implied_values!(model)
938+
update_implied_values!(model)
992939
model.radiation_mode.add_isothermal_boundary_layer &&
993940
update_boundary_layer!(model)
994941
clip_values!(model)
@@ -1015,25 +962,18 @@ function update_implied_values!(model)
1015962
z_lay = parent(model.center_z)
1016963
z_lev = parent(model.face_z)
1017964
end
1018-
if model.implied_values == :center
1019-
mode = model.interpolation
1020-
outs = requires_z(mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
1021-
ins = requires_z(mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
1022-
update_views(interp!, mode, outs, ins, (), 1:nlay, 1:nlay, 2:(nlay + 1))
1023-
else # model.implied_values == :face
1024-
mode = model.interpolation
1025-
outs = requires_z(mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
1026-
ins = requires_z(mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
1027-
update_views(interp!, mode, outs, ins, (), 2:nlay, 1:(nlay - 1), 2:nlay)
1028-
others = (t_sfc, model.params)
1029-
update_views(extrap!, mode, outs, ins, others, nlay + 1, nlay, nlay - 1)
1030-
mode =
1031-
model.bottom_extrapolation isa SameAsInterpolation ?
1032-
model.interpolation : model.bottom_extrapolation
1033-
outs = requires_z(mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
1034-
ins = requires_z(mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
1035-
update_views(extrap!, mode, outs, ins, others, 1, 1, 2)
1036-
end
965+
mode = model.interpolation
966+
outs = requires_z(mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
967+
ins = requires_z(mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
968+
update_views(interp!, mode, outs, ins, (), 2:nlay, 1:(nlay - 1), 2:nlay)
969+
others = (t_sfc, model.params)
970+
update_views(extrap!, mode, outs, ins, others, nlay + 1, nlay, nlay - 1)
971+
mode =
972+
model.bottom_extrapolation isa SameAsInterpolation ?
973+
model.interpolation : model.bottom_extrapolation
974+
outs = requires_z(mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
975+
ins = requires_z(mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
976+
update_views(extrap!, mode, outs, ins, others, 1, 1, 2)
1037977
end
1038978

1039979
update_views(f, mode, outs, ins, others, out_range, in_range1, in_range2) = f(

0 commit comments

Comments
 (0)