Skip to content

Commit 44068dd

Browse files
committed
fix tests; format
1 parent 9f2c696 commit 44068dd

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

experiments/ClimaEarth/components/land/climaland_bucket.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,16 @@ function BucketSimulation(
124124
τc = FT(float(dt))
125125
params = CL.Bucket.BucketModelParameters(toml_dict; albedo, τc)
126126

127-
args = (params, CL.CoupledAtmosphere{FT}(surface_space, atmos_h), CL.CoupledRadiativeFluxes{FT}(), domain)
127+
# Interpolate atmosphere height field to surface space of land model,
128+
# since that's where we compute fluxes for this land model
129+
atmos_h = Interfacer.remap(surface_space, atmos_h)
130+
131+
args = (
132+
params,
133+
CL.CoupledAtmosphere{FT}(surface_space, atmos_h),
134+
CL.CoupledRadiativeFluxes{FT}(),
135+
domain,
136+
)
128137
model = CL.Bucket.BucketModel{FT, typeof.(args)...}(args...)
129138

130139
# Initial conditions with no moisture
@@ -320,16 +329,14 @@ end
320329
function Interfacer.update_field!(sim::BucketSimulation, ::Val{:air_humidity}, field)
321330
Interfacer.remap!(sim.integrator.p.drivers.q, field)
322331
end
323-
function Interfacer.update_field!(
324-
sim::BucketSimulation,
325-
::Val{:air_velocity},
326-
u_int,
327-
v_int,
328-
)
332+
function Interfacer.update_field!(sim::BucketSimulation, ::Val{:air_velocity}, u_int, v_int)
329333
Interfacer.remap!(sim.integrator.p.bucket.scratch1, u_int)
330334
Interfacer.remap!(sim.integrator.p.bucket.scratch2, v_int)
331335
sim.integrator.p.drivers.u .=
332-
StaticArrays.SVector.(sim.integrator.p.bucket.scratch1, sim.integrator.p.bucket.scratch2)
336+
StaticArrays.SVector.(
337+
sim.integrator.p.bucket.scratch1,
338+
sim.integrator.p.bucket.scratch2,
339+
)
333340
end
334341
function Interfacer.update_field!(
335342
sim::BucketSimulation,
@@ -414,7 +421,7 @@ for this model. These are then summed using area-weighting across all surface
414421
models to get the total fluxes. Fluxes where the area fraction is zero are set to zero.
415422
416423
Currently, this calculation is done on the land surface space, and the computed fluxes
417-
are remapped onto the coupler boundary space as the coupler fields are updated. In the future,
424+
are remapped onto the coupler boundary space as the coupler fields are updated. In the future,
418425
we may compute fluxes in the bucket model's internal `step!` function.
419426
420427
# Arguments

experiments/ClimaEarth/setup_run.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ function CoupledSimulation(config_dict::AbstractDict)
416416
output_dir = dir_paths.land_output_dir,
417417
area_fraction = land_fraction,
418418
surface_elevation,
419+
atmos_h,
419420
land_temperature_anomaly,
420421
use_land_diagnostics,
421422
albedo_type = bucket_albedo_type,

test/flux_calculator_tests.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ for FT in (Float32, Float64)
189189
atmos_sim.integrator.T,
190190
TD.PhasePartition.(atmos_sim.integrator.q),
191191
)
192+
surface_fluxes_params = FluxCalculator.get_surface_params(atmos_sim)
192193

193194
# Get surface properties
194195
height_sfc = Interfacer.get_field(atmos_sim, Val(:height_sfc))
@@ -219,7 +220,6 @@ for FT in (Float32, Float64)
219220
SF.ConstantGustinessSpec.(gustiness),
220221
)
221222

222-
surface_fluxes_params = FluxCalculator.get_surface_params(atmos_sim)
223223
fluxes_expected =
224224
FluxCalculator.get_surface_fluxes.(
225225
surface_fluxes_params,
@@ -230,17 +230,15 @@ for FT in (Float32, Float64)
230230
thermo_state_sfc,
231231
height_sfc,
232232
0, # d
233-
config,
233+
Ref(config),
234234
)
235235

236236
# Compare expected and computed fluxes
237237
@test fields.F_turb_ρτxz fluxes_expected.F_turb_ρτxz
238238
@test fields.F_turb_ρτyz fluxes_expected.F_turb_ρτyz
239239
@test fields.F_lh fluxes_expected.F_lh
240240
@test fields.F_sh fluxes_expected.F_sh
241-
# The ClimaCore DataLayout underlying the expected moisture flux uses
242-
# Array instead of SubArray, so we can't compare the fields directly without copy.
243-
@test copy(fields.F_turb_moisture) fluxes_expected.F_turb_moisture
241+
@test fields.F_turb_moisture fluxes_expected.F_turb_moisture
244242
end
245243

246244
@testset "get_surface_params for FT=$FT" begin

0 commit comments

Comments
 (0)