From 7cef5d5807c860696af689722760b8b0ef453fe8 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Wed, 6 Sep 2023 13:11:51 -0700 Subject: [PATCH] Test that set_precomputed_quantities is idempotent --- src/prognostic_equations/limited_tendencies.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/prognostic_equations/limited_tendencies.jl b/src/prognostic_equations/limited_tendencies.jl index f9ec8c735a2..fd388172611 100644 --- a/src/prognostic_equations/limited_tendencies.jl +++ b/src/prognostic_equations/limited_tendencies.jl @@ -12,9 +12,20 @@ using ClimaCore.Utilities: half import ClimaCore.Fields: ColumnField +using Test +alleqeq(a::Fields.FieldVector, b::Fields.FieldVector) = + all(x -> x[1] == x[2], zip(Fields._values(a), Fields._values(b))) + function limited_tendency!(Yₜ, Y, p, t) Yₜ .= zero(eltype(Yₜ)) + + # Y0 = deepcopy(Y) set_precomputed_quantities!(Y, p, t) + Y1 = deepcopy(Y) + set_precomputed_quantities!(Y, p, t) + Y2 = deepcopy(Y) + @test alleqeq(Y1, Y2) + horizontal_tracer_advection_tendency!(Yₜ, Y, p, t) NVTX.@range "tracer hyperdiffusion tendency" color = colorant"yellow" begin tracer_hyperdiffusion_tendency!(Yₜ, Y, p, t)