Skip to content

Commit 4b2d6cc

Browse files
authored
Merge pull request #1254 from CliMA/js/atmos-land-sim
run AMIP with the integrated land model
2 parents ae8c250 + e137e75 commit 4b2d6cc

File tree

17 files changed

+271
-50
lines changed

17 files changed

+271
-50
lines changed

.buildkite/pipeline.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ steps:
176176
agents:
177177
slurm_mem: 20GB
178178

179+
- label: "AMIP: DecayWithHeight + integrated land"
180+
key: "amip_integrated_land"
181+
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl --config_file $CONFIG_PATH/amip_decay_with_height_integrated_land.yml --job_id amip_integrated_land"
182+
artifact_paths: "experiments/ClimaEarth/output/amip_integrated_land/artifacts/*"
183+
agents:
184+
slurm_mem: 20GB
185+
186+
- label: "AMIP: DecayWithHeight + bucket"
187+
key: "amip_decay_with_height_bucket"
188+
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl --config_file $CONFIG_PATH/amip_decay_with_height_bucket.yml --job_id amip_decay_with_height_bucket"
189+
artifact_paths: "experiments/ClimaEarth/output/amip_decay_with_height_bucket/artifacts/*"
190+
agents:
191+
slurm_mem: 20GB
192+
179193
- label: "AMIP: bucket initial condition test"
180194
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl --config_file $CONFIG_PATH/amip_bucket_ic.yml --job_id amip_bucket_ic"
181195
artifact_paths: "experiments/ClimaEarth/output/amip_bucket_ic/artifacts/*"
@@ -283,6 +297,26 @@ steps:
283297
slurm_mem: 20GB
284298
slurm_gpus: 1
285299

300+
- label: "GPU AMIP: DecayWithHeight + integrated land"
301+
key: "gpu_amip_integrated_land"
302+
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl --config_file $CONFIG_PATH/amip_decay_with_height_integrated_land.yml --job_id gpu_amip_integrated_land"
303+
artifact_paths: "experiments/ClimaEarth/output/gpu_amip_integrated_land/artifacts/*"
304+
env:
305+
CLIMACOMMS_DEVICE: "CUDA"
306+
agents:
307+
slurm_mem: 20GB
308+
slurm_gpus: 1
309+
310+
- label: "GPU AMIP: DecayWithHeight + bucket"
311+
key: "gpu_amip_decay_with_height_bucket"
312+
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl --config_file $CONFIG_PATH/amip_decay_with_height_bucket.yml --job_id gpu_amip_decay_with_height_bucket"
313+
artifact_paths: "experiments/ClimaEarth/output/gpu_amip_decay_with_height_bucket/artifacts/*"
314+
env:
315+
CLIMACOMMS_DEVICE: "CUDA"
316+
agents:
317+
slurm_mem: 20GB
318+
slurm_gpus: 1
319+
286320
- label: "GPU AMIP test: albedo from function"
287321
key: "gpu_amip_albedo_function"
288322
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl --config_file $CONFIG_PATH/amip_albedo_function.yml --job_id gpu_amip_albedo_function"

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ ClimaCoupler.jl Release Notes
66

77
### ClimaCoupler features
88

9+
#### Test AMIP with integrated land model. PR[#1254](https://github.com/CliMA/ClimaCoupler.jl/pull/1254)
10+
11+
The integrated ClimaLand model can now be used in coupled simulations.
12+
A short run of AMIP using the full land model is now tested in our regular
13+
Buildkite pipeline, and the restarts test uses the full land model
14+
rather than the bucket.
15+
16+
This PR adds the config option `land_model`, which can be set to either
17+
`bucket` or `integrated` to choose which land model to run with.
18+
919
#### Remove `nans_to_zero`. PR[#1278](https://github.com/CliMA/ClimaCoupler.jl/pull/1278)
20+
1021
Instead of zeroing out all NaNs in a surface field, we zero out all values
1122
where the area fraction is 0, which is logically what we want to do.
1223

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FLOAT_TYPE: "Float32"
2+
albedo_model: "CouplerAlbedo"
3+
atmos_config_file: "config/longrun_configs/amip_target_edonly.yml"
4+
checkpoint_dt: "720hours"
5+
coupler_toml: ["toml/amip.toml"]
6+
dt: "240secs"
7+
dt_cpl: "240secs"
8+
dt_save_state_to_disk: "12hours"
9+
dt_save_to_sol: "12hours"
10+
dz_bottom: 100.0
11+
energy_check: false
12+
h_elem: 8
13+
land_albedo_type: "map_temporal"
14+
land_model: "bucket"
15+
mode_name: "amip"
16+
moist: equil
17+
netcdf_interpolation_num_points: [90, 45, 31]
18+
netcdf_output_at_levels: true
19+
output_default_diagnostics: true
20+
rad: allskywithclear
21+
radiation_reset_rng_seed: true
22+
rayleigh_sponge: true
23+
start_date: "20100101"
24+
surface_setup: "PrescribedSurface"
25+
t_end: "480secs"
26+
topography: "Earth"
27+
topo_smoothing: true
28+
turbconv: ~
29+
vert_diff: "DecayWithHeightDiffusion"
30+
viscous_sponge: true
31+
z_elem: 39
32+
z_max: 60000.0
33+
extra_atmos_diagnostics:
34+
- short_name: [pr, rhoa, uas, vas, thetaa, hussfc, ts]
35+
reduction_time: average
36+
period: 1days
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FLOAT_TYPE: "Float32"
2+
albedo_model: "CouplerAlbedo"
3+
atmos_config_file: "config/longrun_configs/amip_target_edonly.yml"
4+
checkpoint_dt: "720hours"
5+
coupler_toml: ["toml/amip.toml"]
6+
dt: "240secs"
7+
dt_cpl: "240secs"
8+
dt_save_state_to_disk: "12hours"
9+
dt_save_to_sol: "12hours"
10+
dz_bottom: 100.0
11+
energy_check: false
12+
h_elem: 8
13+
land_albedo_type: "map_temporal"
14+
land_model: "integrated"
15+
mode_name: "amip"
16+
moist: equil
17+
netcdf_interpolation_num_points: [90, 45, 31]
18+
netcdf_output_at_levels: true
19+
output_default_diagnostics: true
20+
rad: allskywithclear
21+
radiation_reset_rng_seed: true
22+
rayleigh_sponge: true
23+
start_date: "20100101"
24+
surface_setup: "PrescribedSurface"
25+
t_end: "480secs"
26+
topography: "Earth"
27+
topo_smoothing: true
28+
turbconv: ~
29+
vert_diff: "DecayWithHeightDiffusion"
30+
viscous_sponge: true
31+
z_elem: 39
32+
z_max: 60000.0
33+
extra_atmos_diagnostics:
34+
- short_name: [pr, rhoa, uas, vas, thetaa, hussfc, ts]
35+
reduction_time: average
36+
period: 1days

docs/src/interfacer.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,17 @@ after solving of the simulation has been paused or interrupted. Like
5353
of SciMLBase.jl.
5454

5555
### ComponentModelSimulation - optional functions
56-
- `get_model_prog_state(::ComponentModelSimulation)`: A function that
57-
returns the state vector of the simulation at its current state. This
58-
is used for checkpointing the simulation.
56+
- `Checkpointer.get_model_prog_state(::ComponentModelSimulation)`:
57+
A function that returns the state vector of the simulation at its current
58+
state. This is used for checkpointing the simulation.
59+
60+
- `Checkpointer.get_model_cache(::ComponentModelSimulation)`:
61+
A function that returns the cache of the simulation at its current state.
62+
This is used for checkpointing the simulation.
63+
64+
- `Checkpointer.restore_cache(::ComponentModelSimulation, new_cache)`:
65+
A function that updates the cache of the simulation with the provided
66+
`new_cache`. This is used for restarting the simulation.
5967

6068
- `get_field(::ComponentModelSimulation, ::Val{property})`:
6169
Default `get_field` functions are provided for `energy` and `water` fields,

experiments/ClimaEarth/Manifest-v1.11.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ version = "0.2.12"
344344

345345
[[deps.ClimaLand]]
346346
deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaUtilities", "Dates", "DocStringExtensions", "Insolation", "Interpolations", "LazyArtifacts", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics"]
347-
git-tree-sha1 = "309507cd078678f291e1b8698b64b8200a78ab52"
347+
git-tree-sha1 = "08d08423e0a955180d3eea39c340b81603a00585"
348348
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
349-
version = "0.15.13"
349+
version = "0.15.14"
350350

351351
[deps.ClimaLand.extensions]
352352
CreateParametersExt = "ClimaParams"

experiments/ClimaEarth/Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ version = "0.2.12"
341341

342342
[[deps.ClimaLand]]
343343
deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaUtilities", "Dates", "DocStringExtensions", "Insolation", "Interpolations", "LazyArtifacts", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics"]
344-
git-tree-sha1 = "309507cd078678f291e1b8698b64b8200a78ab52"
344+
git-tree-sha1 = "08d08423e0a955180d3eea39c340b81603a00585"
345345
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
346-
version = "0.15.13"
346+
version = "0.15.14"
347347

348348
[deps.ClimaLand.extensions]
349349
CreateParametersExt = "ClimaParams"

experiments/ClimaEarth/cli_options.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ function argparse_settings()
131131
arg_type = Vector{Dict{Any, Any}}
132132
default = []
133133
### ClimaLand specific
134+
"--land_model"
135+
help = "Land model to use. [`bucket` (default), `integrated`]"
136+
arg_type = String
137+
default = "bucket"
134138
"--land_albedo_type"
135139
help = "Access land surface albedo information from data file. [`map_static` (default), `function`, `map_temporal`]"
136140
arg_type = String

experiments/ClimaEarth/components/land/climaland_integrated.jl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ soil CO2 model. Specific details about the complexity of the model
5454
can be found in the ClimaLand.jl documentation.
5555
"""
5656
function ClimaLandSimulation(
57-
::Type{FT},
57+
::Type{FT};
5858
dt::TT,
5959
tspan::Tuple{TT, TT},
6060
start_date::Dates.DateTime,
6161
output_dir::String,
6262
boundary_space,
63-
area_fraction;
63+
area_fraction,
6464
saveat::Vector{TT} = [tspan[1], tspan[2]],
6565
surface_elevation = CC.Fields.zeros(boundary_space),
6666
land_temperature_anomaly::String = "amip",
@@ -160,7 +160,6 @@ function ClimaLandSimulation(
160160
exp_tendency! = CL.make_exp_tendency(model)
161161
imp_tendency! = CL.make_imp_tendency(model)
162162
jacobian! = CL.make_jacobian(model)
163-
set_initial_cache!(p, Y, tspan[1])
164163

165164
# set up jacobian info
166165
jac_kwargs = (; jac_prototype = CL.FieldMatrixWithSolver(Y), Wfact = jacobian!)
@@ -179,7 +178,7 @@ function ClimaLandSimulation(
179178
model,
180179
start_date,
181180
output_writer = output_writer,
182-
output_vars = :short,
181+
output_vars = :long,
183182
average_period = :monthly,
184183
)
185184
diagnostic_handler = CD.DiagnosticsHandler(scheduled_diagnostics, Y, p, tspan[1]; dt = dt)
@@ -430,7 +429,7 @@ function Interfacer.update_field!(sim::ClimaLandSimulation, ::Val{:cos_zenith_an
430429
end
431430

432431
Interfacer.step!(sim::ClimaLandSimulation, t) = Interfacer.step!(sim.integrator, t - sim.integrator.t, true)
433-
Interfacer.reinit!(sim::ClimaLandSimulation, t) = Interfacer.reinit!(sim.integrator, t)
432+
Interfacer.reinit!(sim::ClimaLandSimulation) = Interfacer.reinit!(sim.integrator)
434433

435434
function FieldExchanger.update_sim!(sim::ClimaLandSimulation, csf, area_fraction)
436435
# update fields for radiative transfer
@@ -486,7 +485,22 @@ function Interfacer.add_coupler_fields!(coupler_field_names, ::ClimaLandSimulati
486485
end
487486

488487
function Checkpointer.get_model_prog_state(sim::ClimaLandSimulation)
489-
error("get_model_prog_state not implemented")
488+
return sim.integrator.u
489+
end
490+
491+
function Checkpointer.get_model_cache(sim::ClimaLandSimulation)
492+
return sim.integrator.p
493+
end
494+
495+
function Checkpointer.restore_cache!(sim::ClimaLandSimulation, new_cache)
496+
old_cache = Checkpointer.get_model_cache(sim)
497+
comms_ctx = ClimaComms.context(sim.model.soil)
498+
restore!(
499+
old_cache,
500+
new_cache,
501+
comms_ctx,
502+
ignore = Set([:dss_buffer_2d, :dss_buffer_3d, :scratch1, :scratch2, :scratch3, :sfc_scratch, :subsfc_scratch]),
503+
)
490504
end
491505

492506
Interfacer.name(::ClimaLandSimulation) = "ClimaLandSimulation"

experiments/ClimaEarth/components/shared/restore.jl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ function restore!(v1::T1, v2::T2, comms_ctx; name = "", ignore) where {T1, T2}
2525
# to CuArray)
2626
fields = filter(x -> !(x in ignore), fieldnames(T2))
2727
if isempty(fields)
28-
if !Base.issingletontype(typeof(v1))
29-
restore!(v1, v2, comms_ctx; name, ignore)
30-
else
31-
v1 == v2 || error("$v1 != $v2")
32-
end
28+
v1 == v2 || error("$v1 != $v2")
3329
else
3430
# Recursive case
3531
for p in fields
@@ -52,12 +48,12 @@ function restore!(
5248
end
5349

5450
function restore!(
55-
v1::T1,
56-
v2::T2,
51+
v1::Union{AbstractData, AbstractArray},
52+
v2::Union{AbstractData, AbstractArray},
5753
comms_ctx;
5854
name,
5955
ignore,
60-
) where {T1 <: Union{AbstractData, AbstractArray}, T2 <: Union{AbstractData, AbstractArray}}
56+
)
6157
ArrayType = parent(v1) isa Array ? Array : ClimaComms.array_type(ClimaComms.device(comms_ctx))
6258
moved_to_device = ArrayType(parent(v2))
6359

@@ -66,20 +62,17 @@ function restore!(
6662
end
6763

6864
function restore!(
69-
v1::T1,
70-
v2::T2,
65+
v1::Union{StaticArrays.StaticArray, Number, UnitRange, LinRange, Symbol},
66+
v2::Union{StaticArrays.StaticArray, Number, UnitRange, LinRange, Symbol},
7167
comms_ctx;
7268
name,
7369
ignore,
74-
) where {
75-
T1 <: Union{StaticArrays.StaticArray, Number, UnitRange, Symbol},
76-
T2 <: Union{StaticArrays.StaticArray, Number, UnitRange, Symbol},
77-
}
70+
)
7871
v1 == v2 || error("$name is a immutable but it inconsistent ($(v1) != $(v2))")
7972
return nothing
8073
end
8174

82-
function restore!(v1::T1, v2::T2, comms_ctx; name, ignore) where {T1 <: Dict, T2 <: Dict}
75+
function restore!(v1::Dict, v2::Dict, comms_ctx; name, ignore)
8376
# RRTGMP has some internal dictionaries
8477
v1 == v2 || error("$name is inconsistent")
8578
return nothing

0 commit comments

Comments
 (0)