Skip to content

Commit 060a3c3

Browse files
committed
Move hyperdif into numerics, clean up
1 parent 97fbb29 commit 060a3c3

File tree

7 files changed

+103
-66
lines changed

7 files changed

+103
-66
lines changed

src/diagnostics/default_diagnostics.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,15 @@ function default_diagnostics(
215215
end
216216

217217
function default_diagnostics(
218-
atmos_hydrology::AtmosWater,
218+
atmos_water::AtmosWater,
219219
duration,
220220
start_date;
221221
output_writer,
222222
)
223223
diagnostics = []
224224

225225
# Add moisture and precipitation model diagnostics
226-
for model in (atmos_hydrology.moisture_model, atmos_hydrology.precip_model)
226+
for model in (atmos_water.moisture_model, atmos_water.precip_model)
227227
!isnothing(model) && append!(
228228
diagnostics,
229229
default_diagnostics(model, duration, start_date; output_writer),

src/parameterized_tendencies/radiation/radiation.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ radiation_model_cache(Y, atmos::AtmosModel, args...) =
2828
##### No Radiation
2929
#####
3030

31-
radiation_model_cache(Y, radiation_mode::Nothing; args...) = (;)
32-
radiation_tendency!(Yₜ, Y, p, t, ::Nothing) = nothing
31+
radiation_model_cache(
32+
Y,
33+
radiation_mode::Union{Nothing, HeldSuarezForcing};
34+
args...,
35+
) = (;)
36+
radiation_tendency!(Yₜ, Y, p, t, ::Union{Nothing, HeldSuarezForcing}) = nothing
3337

3438
#####
3539
##### RRTMGP Radiation

src/prognostic_equations/remaining_tendency.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
141141
ᶜuₕ = Y.c.uₕ
142142
ᶠu₃ = Y.f.u₃
143143
ᶜρ = Y.c.ρ
144-
(; radiation_mode, moisture_model, rayleigh_sponge, viscous_sponge) = p.atmos
144+
(; radiation_mode, moisture_model, rayleigh_sponge, viscous_sponge) =
145+
p.atmos
145146
(; ls_adv, scm_coriolis) = p.atmos
146147
(; params) = p
147148
thermo_params = CAP.thermodynamics_params(params)

src/solver/model_getters.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ function get_radiation_mode(parsed_args, ::Type{FT}) where {FT}
246246
"gray",
247247
"allsky",
248248
"allskywithclear",
249+
"held_suarez",
249250
"DYCOMS",
250251
"TRMM_LBA",
251252
"ISDAC",
@@ -286,6 +287,8 @@ function get_radiation_mode(parsed_args, ::Type{FT}) where {FT}
286287
reset_rng_seed,
287288
deep_atmosphere,
288289
)
290+
elseif radiation_name == "held_suarez"
291+
HeldSuarezForcing()
289292
elseif radiation_name == "DYCOMS"
290293
RadiationDYCOMS{FT}()
291294
elseif radiation_name == "TRMM_LBA"
@@ -352,11 +355,11 @@ end
352355
function get_forcing_type(parsed_args)
353356
forcing = parsed_args["forcing"]
354357
@assert forcing in (nothing, "held_suarez")
355-
return if forcing == nothing
356-
nothing
357-
elseif forcing == "held_suarez"
358-
HeldSuarezForcing()
358+
if forcing == "held_suarez"
359+
@warn "The 'held_suarez' forcing option is deprecated. Use rad='held_suarez' instead to set HeldSuarezForcing as a radiation mode."
360+
return HeldSuarezForcing() # Still return the object for backward compatibility
359361
end
362+
return nothing
360363
end
361364

362365
struct CallCloudDiagnosticsPerStage end
@@ -372,7 +375,7 @@ end
372375

373376
function get_subsidence_model(parsed_args, radiation_mode, FT)
374377
subsidence = parsed_args["subsidence"]
375-
subsidence == nothing && return nothing
378+
isnothing(subsidence) && return nothing
376379

377380
prof = if subsidence == "Bomex"
378381
APL.Bomex_subsidence(FT)
@@ -382,6 +385,8 @@ function get_subsidence_model(parsed_args, radiation_mode, FT)
382385
APL.Rico_subsidence(FT)
383386
elseif subsidence == "DYCOMS"
384387
@assert radiation_mode isa RadiationDYCOMS
388+
# For DYCOMS case, subsidence is linearly proportional to height
389+
# with slope equal to the divergence rate specified in radiation mode
385390
z -> -z * radiation_mode.divergence
386391
elseif subsidence == "ISDAC"
387392
APL.ISDAC_subsidence(FT)

src/solver/type_getters.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ function get_atmos(config::AtmosConfig, params)
4848
(!isnothing(co2) && !with_rrtmgp) &&
4949
@warn ("$(co2) does nothing if RRTMGP is not used")
5050

51-
disable_momentum_vertical_diffusion = forcing_type isa HeldSuarezForcing
51+
# HeldSuarezForcing can be set via radiation_mode or legacy forcing option for now
52+
final_radiation_mode =
53+
forcing_type isa HeldSuarezForcing ? forcing_type : radiation_mode
54+
disable_momentum_vertical_diffusion =
55+
final_radiation_mode isa HeldSuarezForcing
5256

5357
advection_test = parsed_args["advection_test"]
5458
@assert advection_test in (false, true)
@@ -102,11 +106,10 @@ function get_atmos(config::AtmosConfig, params)
102106
scm_coriolis = get_scm_coriolis(parsed_args, FT),
103107

104108
# AtmosRadiation
105-
radiation_mode,
109+
radiation_mode = final_radiation_mode,
106110
ozone,
107111
co2,
108112
insolation = get_insolation_form(parsed_args),
109-
held_suarez_forcing = forcing_type,
110113

111114
# AtmosTurbconv - Turbulence & Convection
112115
edmfx_model,
@@ -139,8 +142,7 @@ function get_atmos(config::AtmosConfig, params)
139142

140143
# Top-level options (not grouped)
141144
vert_diff,
142-
hyperdiff = get_hyperdiffusion_model(parsed_args, FT),
143-
numerics = get_numerics(parsed_args),
145+
numerics = get_numerics(parsed_args, FT),
144146
disable_surface_flux_tendency = parsed_args["disable_surface_flux_tendency"],
145147
)
146148
# TODO: Should this go in the AtmosModel constructor?
@@ -161,7 +163,7 @@ function get_scale_blending_method(parsed_args)
161163
end
162164
end
163165

164-
function get_numerics(parsed_args)
166+
function get_numerics(parsed_args, FT)
165167
test_dycore =
166168
parsed_args["test_dycore_consistency"] ? TestDycoreConsistency() :
167169
nothing
@@ -189,6 +191,9 @@ function get_numerics(parsed_args)
189191

190192
# wrap each upwinding mode in a Val for dispatch
191193
diff_mode = parsed_args["implicit_diffusion"] ? Implicit() : Explicit()
194+
195+
hyperdiff = get_hyperdiffusion_model(parsed_args, FT)
196+
192197
numerics = AtmosNumerics(;
193198
energy_upwinding,
194199
tracer_upwinding,
@@ -197,6 +202,7 @@ function get_numerics(parsed_args)
197202
limiter,
198203
test_dycore_consistency = test_dycore,
199204
diff_mode,
205+
hyperdiff,
200206
)
201207
@info "numerics $(summary(numerics))"
202208

0 commit comments

Comments
 (0)