From 4bdb898ed0d0933547cf3f089a9351009a0002de Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Tue, 15 Jul 2025 11:47:58 -0700 Subject: [PATCH 1/2] remove bucket get_new_cache --- NEWS.md | 6 +++ .../components/land/climaland_bucket.jl | 44 +++++-------------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/NEWS.md b/NEWS.md index fda9dcc22a..0ff62a92fa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,12 @@ ClimaCoupler.jl Release Notes ### ClimaCoupler features +#### Remove bucket `get_new_cache` PR[#1437](https://github.com/CliMA/ClimaCoupler.jl/pull/1437) + +As of ClimaLand v0.16.2, total energy and and water are always stored in the bucket cache. +This PR removes the `get_new_cache`, which allocated space for the energy field, +and instead accesses the cached fields directly. + #### Add option for integrated land spun up IC. PR[#1318](https://github.com/CliMA/ClimaCoupler.jl/pull/1318) Adds a boolean flag `land_spun_up_ic` that allows the user to request reading integrated land diff --git a/experiments/ClimaEarth/components/land/climaland_bucket.jl b/experiments/ClimaEarth/components/land/climaland_bucket.jl index 24a061ac8b..891784029f 100644 --- a/experiments/ClimaEarth/components/land/climaland_bucket.jl +++ b/experiments/ClimaEarth/components/land/climaland_bucket.jl @@ -37,20 +37,6 @@ struct BucketSimulation{M <: CL.Bucket.BucketModel, I <: SciMLBase.AbstractODEIn output_writer::OW end -""" - get_new_cache(p, Y, energy_check) -Returns a new `p` with an updated field to store e_per_area if energy conservation - checks are turned on. -""" -function get_new_cache(p, Y, energy_check) - if energy_check - e_per_area_field = CC.Fields.zeros(axes(Y.bucket.W)) - return merge(p, (; e_per_area = e_per_area_field)) - else - return p - end -end - """ bucket_init @@ -140,9 +126,6 @@ function BucketSimulation( # Initial conditions with no moisture Y, p, coords = CL.initialize(model) - # Add space in the cache for the energy if energy checks are enabled - p = get_new_cache(p, Y, energy_check) - # Get temperature anomaly function T_functions = Dict("aquaplanet" => temp_anomaly_aquaplanet, "amip" => temp_anomaly_amip) haskey(T_functions, land_temperature_anomaly) || @@ -262,29 +245,26 @@ Interfacer.get_field(sim::BucketSimulation, ::Val{:surface_temperature}) = """ Interfacer.get_field(sim::BucketSimulation, ::Val{:energy}) -Extension of Interfacer.get_field that provides the total energy contained in the bucket, including the latent heat due to snow melt. -""" -function Interfacer.get_field(sim::BucketSimulation, ::Val{:energy}) - # required by ConservationChecker - e_per_area = sim.integrator.p.e_per_area .= 0 - CC.Operators.column_integral_definite!(e_per_area, sim.model.parameters.ρc_soil .* sim.integrator.u.bucket.T) - - e_per_area .+= - -LP.LH_f0(sim.model.parameters.earth_param_set) .* LP.ρ_cloud_liq(sim.model.parameters.earth_param_set) .* - sim.integrator.u.bucket.σS +Extension of Interfacer.get_field that provides the total energy contained in the bucket, +computed from the temperature of the bucket and also including the latent heat of fusion +of frozen water in the snow. - return e_per_area -end +This method is required by the ConservationChecker to check energy conservation. +""" +Interfacer.get_field(sim::BucketSimulation, ::Val{:energy}) = sim.integrator.p.bucket.total_energy """ Interfacer.get_field(sim::BucketSimulation, ::Val{:water}) -Extension of Interfacer.get_field that provides the total water contained in the bucket, including the liquid water in snow. +Extension of Interfacer.get_field that provides the total water contained in the bucket. +The total water contained in the bucket is the sum of the subsurface water storage `W`, +the snow water equivalent `σS`, and surface water content `Ws`. + +This method is required by the ConservationChecker to check water conservation. """ function Interfacer.get_field(sim::BucketSimulation, ::Val{:water}) ρ_cloud_liq = CL.LP.ρ_cloud_liq(sim.model.parameters.earth_param_set) - return - @. (sim.integrator.u.bucket.σS + sim.integrator.u.bucket.W + sim.integrator.u.bucket.Ws) * ρ_cloud_liq # kg water / m2 + return sim.integrator.p.bucket.total_water .* ρ_cloud_liq # kg water / m2 end function Interfacer.update_field!(sim::BucketSimulation, ::Val{:air_density}, field) From 7a5271fdf12dd97c291553c8ea6de779f72f81cb Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Tue, 15 Jul 2025 17:50:10 -0700 Subject: [PATCH 2/2] increase ClimaLand compat to skip buggy version --- experiments/ClimaEarth/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experiments/ClimaEarth/Project.toml b/experiments/ClimaEarth/Project.toml index e99180396b..25d6e284ce 100644 --- a/experiments/ClimaEarth/Project.toml +++ b/experiments/ClimaEarth/Project.toml @@ -39,7 +39,7 @@ ClimaAnalysis = "0.5.10" ClimaAtmos = "0.27, 0.28, 0.29, 0.30, 0.31" ClimaCalibrate = "0.1" ClimaDiagnostics = "0.2.6" -ClimaLand = "0.17" +ClimaLand = "0.17.1" ClimaOcean = "0.7" ClimaParams = "0.10" ClimaTimeSteppers = "0.7, 0.8"