From d7225444f4e5a51dd4f9f16e19349e25d60b67d2 Mon Sep 17 00:00:00 2001 From: Gabriele Bozzola Date: Tue, 3 Dec 2024 08:52:10 -0800 Subject: [PATCH] Remove do_dss from cache `do_dss` is a compile-time constant that is fully determined by the space. --- src/cache/cache.jl | 9 +-------- src/prognostic_equations/dss.jl | 3 ++- src/prognostic_equations/hyperdiffusion.jl | 3 +-- src/prognostic_equations/remaining_tendency.jl | 2 +- src/utils/utilities.jl | 12 ++++++++++++ test/coupler_compatibility.jl | 1 - 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/cache/cache.jl b/src/cache/cache.jl index a8925fb7be..ccc97c88d5 100644 --- a/src/cache/cache.jl +++ b/src/cache/cache.jl @@ -13,7 +13,6 @@ struct AtmosCache{ PREC, SCRA, HYPE, - DSS, PR, LSAD, EXTFORCING, @@ -70,8 +69,6 @@ struct AtmosCache{ ghost buffers for DSS""" hyperdiff::HYPE - do_dss::DSS - """Additional parameters used by the various tendencies""" precipitation::PR large_scale_advection::LSAD @@ -117,11 +114,8 @@ function build_cache(Y, atmos, params, surface_setup, sim_info, aerosol_names) (; ᶜf³, ᶠf¹²) = compute_coriolis(ᶜcoord, ᶠcoord, params) - quadrature_style = - Spaces.quadrature_style(Spaces.horizontal_space(axes(Y.c))) - do_dss = quadrature_style isa Quadratures.GLL ghost_buffer = - !do_dss ? (;) : + !do_dss(axes(Y.c)) ? (;) : (; c = Spaces.create_dss_buffer(Y.c), f = Spaces.create_dss_buffer(Y.f)) net_energy_flux_toa = [Geometry.WVector(FT(0))] @@ -201,7 +195,6 @@ function build_cache(Y, atmos, params, surface_setup, sim_info, aerosol_names) precomputed, scratch, hyperdiff, - do_dss, precipitation, large_scale_advection, external_forcing, diff --git a/src/prognostic_equations/dss.jl b/src/prognostic_equations/dss.jl index b7232ac2d6..d3ad0fd011 100644 --- a/src/prognostic_equations/dss.jl +++ b/src/prognostic_equations/dss.jl @@ -13,7 +13,8 @@ using ClimaCore.Utilities: half import ClimaCore.Fields: ColumnField NVTX.@annotate function dss!(Y, p, t) - if p.do_dss + if do_dss(axes(Y.c)) Spaces.weighted_dss!(Y.c => p.ghost_buffer.c, Y.f => p.ghost_buffer.f) end + return nothing end diff --git a/src/prognostic_equations/hyperdiffusion.jl b/src/prognostic_equations/hyperdiffusion.jl index 0a41e42d0b..6c4a5d30d4 100644 --- a/src/prognostic_equations/hyperdiffusion.jl +++ b/src/prognostic_equations/hyperdiffusion.jl @@ -15,7 +15,6 @@ hyperdiffusion_cache(Y, hyperdiff::Nothing, _) = (;) function hyperdiffusion_cache(Y, hyperdiff::ClimaHyperdiffusion, turbconv_model) quadrature_style = Spaces.quadrature_style(Spaces.horizontal_space(axes(Y.c))) - do_dss = quadrature_style isa Quadratures.GLL FT = eltype(Y) n = n_mass_flux_subdomains(turbconv_model) @@ -44,7 +43,7 @@ function hyperdiffusion_cache(Y, hyperdiff::ClimaHyperdiffusion, turbconv_model) (;) sgs_quantities = (; sgs_quantities..., maybe_ᶜ∇²tke⁰...) quantities = (; gs_quantities..., sgs_quantities...) - if do_dss + if do_dss(axes(Y.c)) quantities = (; quantities..., hyperdiffusion_ghost_buffer = map( diff --git a/src/prognostic_equations/remaining_tendency.jl b/src/prognostic_equations/remaining_tendency.jl index a31344f1d9..908671a42b 100644 --- a/src/prognostic_equations/remaining_tendency.jl +++ b/src/prognostic_equations/remaining_tendency.jl @@ -2,7 +2,7 @@ NVTX.@annotate function hyperdiffusion_tendency!(Yₜ, Yₜ_lim, Y, p, t) prep_tracer_hyperdiffusion_tendency!(Yₜ_lim, Y, p, t) prep_hyperdiffusion_tendency!(Yₜ, Y, p, t) - if p.do_dss && !isnothing(p.atmos.hyperdiff) + if do_dss(axes(Y.c)) && !isnothing(p.atmos.hyperdiff) pairs = dss_hyperdiffusion_tendency_pairs(p) Spaces.weighted_dss!(pairs...) end diff --git a/src/utils/utilities.jl b/src/utils/utilities.jl index 06a248bbae..18320791c3 100644 --- a/src/utils/utilities.jl +++ b/src/utils/utilities.jl @@ -262,6 +262,18 @@ function verify_callbacks(t) end end + +""" + do_dss(space) + +Return whether the underlying horizontal space required DSS or not. +""" +function do_dss(space::Spaces.AbstractSpace) + return Spaces.quadrature_style(Spaces.horizontal_space(space)) isa + Quadratures.GLL +end + + using ClimaComms is_distributed(::ClimaComms.SingletonCommsContext) = false is_distributed(::ClimaComms.MPICommsContext) = true diff --git a/test/coupler_compatibility.jl b/test/coupler_compatibility.jl index e7b063d4b9..c361b363c8 100644 --- a/test/coupler_compatibility.jl +++ b/test/coupler_compatibility.jl @@ -79,7 +79,6 @@ const T2 = 290 p.precomputed, p.scratch, p.hyperdiff, - p.do_dss, p.precipitation, p.large_scale_advection, p.external_forcing,