Skip to content

Commit 2f57713

Browse files
authored
Merge pull request #1535 from CliMA/js/zs/upd-sim-bucket
use correct method for bucket update_sim
2 parents 3faaaee + 05da18b commit 2f57713

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

experiments/ClimaEarth/components/land/climaland_bucket.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ClimaLand as CL
99
import ClimaLand.Parameters as LP
1010
import ClimaParams as CP
1111
import ClimaDiagnostics as CD
12-
import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer
12+
import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer, FieldExchanger
1313
using NCDatasets
1414
include("climaland_helpers.jl")
1515

@@ -368,23 +368,26 @@ Updates the surface component model cache with the current coupler fields beside
368368
- `sim`: [Interfacer.SurfaceModelSimulation] containing a surface model simulation object.
369369
- `csf`: [NamedTuple] containing coupler fields.
370370
"""
371-
function update_sim!(sim::BucketSimulation, csf)
371+
function FieldExchanger.update_sim!(sim::BucketSimulation, csf)
372372
# radiative fluxes
373373
# TODO add SW_d, LW_d fields to BucketSimulation and update there instead
374374
Interfacer.update_field!(sim, Val(:SW_d), csf.SW_d)
375375
Interfacer.update_field!(sim, Val(:LW_d), csf.LW_d)
376376

377377
model = sim.model
378-
Y = sim.integrator.U
378+
Y = sim.integrator.u
379379
p = sim.integrator.p
380380
t = sim.integrator.t
381381

382382
# TODO: get sigma from parameters
383+
FT = eltype(Y)
383384
σ = FT(5.67e-8)
384-
@. sim.integrator.p.bucket.R_n =
385-
(1 - CL.surface_albedo(model, Y, p)) * sim.radiative_fluxes.SW_d +
386-
Interfacer.get_field(sim, Val(:emissivity)) *
387-
(sim.radiative_fluxes.LW_d - σ * CL.surface_temperature(model, Y, p, t)^4)
385+
# Note: here we add negative signs to account for a difference in sign convention
386+
# between ClimaLand.jl and ClimaCoupler.jl in SW_d and LW_d.
387+
sim.integrator.p.bucket.R_n .=
388+
.-(1 .- CL.surface_albedo(model, Y, p)) .* sim.radiative_fluxes.SW_d .-
389+
Interfacer.get_field(sim, Val(:emissivity)) .*
390+
(sim.radiative_fluxes.LW_d .- σ .* CL.surface_temperature(model, Y, p, t) .^ 4)
388391

389392
# precipitation
390393
Interfacer.update_field!(sim, Val(:liquid_precipitation), csf.P_liq)

0 commit comments

Comments
 (0)