Skip to content

Commit

Permalink
Merge pull request #3318 from CliMA/gb/insolation
Browse files Browse the repository at this point in the history
Add insolation_tuple only when needed
  • Loading branch information
Sbozzolo authored Sep 19, 2024
2 parents 3395e5a + 6dbb52a commit 8886eac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/cache/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ function build_cache(

radiation_args =
atmos.radiation_mode isa RRTMGPI.AbstractRRTMGPMode ?
(params, precomputed.ᶜp, prescribe_ozone, aerosol_names) : ()
(
params,
precomputed.ᶜp,
prescribe_ozone,
aerosol_names,
atmos.insolation,
) : ()

hyperdiff = hyperdiffusion_cache(Y, atmos)
rayleigh_sponge = rayleigh_sponge_cache(Y, atmos)
Expand Down
21 changes: 16 additions & 5 deletions src/parameterized_tendencies/radiation/radiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function radiation_model_cache(
params,
ᶜp, # Used for ozone
prescribe_ozone,
aerosol_names;
aerosol_names,
insolation_mode;
interpolation = RRTMGPI.BestFit(),
bottom_extrapolation = RRTMGPI.SameAsInterpolation(),
data_loader = rrtmgp_data_loader,
Expand Down Expand Up @@ -253,11 +254,21 @@ function radiation_model_cache(
kwargs...,
)
end
return merge(
(;
orbital_data,
rrtmgp_model,
ᶠradiation_flux = similar(Y.f, Geometry.WVector{FT}),
),
insolation_cache(insolation_mode, Y),
)
end

insolation_cache(_, _) = (;)
function insolation_cache(::TimeVaryingInsolation, Y)
FT = Spaces.undertype(axes(Y.c))
return (;
orbital_data,
rrtmgp_model,
insolation_tuple = similar(Spaces.level(Y.c, 1), Tuple{FT, FT, FT}),
ᶠradiation_flux = similar(Y.f, Geometry.WVector{FT}),
insolation_tuple = similar(Spaces.level(Y.c, 1), Tuple{FT, FT, FT})
)
end

Expand Down

0 comments on commit 8886eac

Please sign in to comment.