Skip to content

Commit 73dcb28

Browse files
authored
Merge pull request #1129 from CliMA/zs/bucket_initcond
add bucket initial condition
2 parents a1a6e6e + c8a2012 commit 73dcb28

File tree

9 files changed

+99
-5
lines changed

9 files changed

+99
-5
lines changed

.buildkite/pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ steps:
195195
artifact_paths: "experiments/ClimaEarth/output/amip_default/artifacts/*"
196196
agents:
197197
slurm_mem: 20GB
198+
199+
- label: "AMIP: bucket initial condition test"
200+
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"
201+
artifact_paths: "experiments/ClimaEarth/output/amip_bucket_ic/artifacts/*"
202+
agents:
203+
slurm_ntasks: 1
204+
slurm_mem: 20GB
198205

199206
- label: "AMIP target: albedo from function"
200207
key: "target_amip_albedo_function"

NEWS.md

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

77
### ClimaEarth features
88

9+
### Read bucket initial conditions from NetCDF files
10+
11+
Added functionality to allow the bucket initial conditions to be overwritten by interpolated NetCDF datasets.
12+
To use this feature from the YAML interface, just pass the path of the file to `land_initial_condition`.
13+
We expect the file to contain the following variables:
14+
`W`, for subsurface water storage (2D),
15+
`Ws`, for surface water content (2D),
16+
`T`, for soil temperature (3D),
17+
`S`, for snow water equivalent (2D).
18+
919
### Sea-surface temperature and sea ice concentration data can now be automatically downloaded
1020

1121
Sea-surface temperature and sea ice concentration require external files. Now, a
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apply_limiter: false
2+
dt: "150secs"
3+
dt_cpl: "150secs"
4+
dt_rad: "1hours"
5+
dt_save_to_sol: "1days"
6+
dz_bottom: 30
7+
dz_top: 3000
8+
h_elem: 4
9+
land_initial_condition: "experiments/ClimaEarth/input/bucket_ic_august.nc"
10+
mode_name: "amip"
11+
moist: "equil"
12+
precip_model: "0M"
13+
rad: "gray"
14+
rayleigh_sponge: true
15+
t_end: "300secs"
16+
vert_diff: "true"
17+
z_elem: 50
18+
z_stretch: false

experiments/ClimaEarth/cli_options.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ function argparse_settings()
155155
help = "Access land surface albedo information from data file. [`map_static` (default), `function`, `map_temporal`]"
156156
arg_type = String
157157
default = "map_static" # to be replaced by land config file, when available
158+
"--land_initial_condition"
159+
help = "A file path for a NetCDF file (read documentation about requirements)"
160+
arg_type = String
161+
default = ""
158162
"--land_temperature_anomaly"
159163
help = "Type of temperature anomaly for bucket model. [`amip`, `aquaplanet` (default)]"
160164
arg_type = String

experiments/ClimaEarth/components/land/climaland_bucket.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ClimaLand as CL
99
import ClimaLand.Parameters as LP
1010
import ClimaDiagnostics as CD
1111
import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer
12+
using NCDatasets
1213

1314
###
1415
### Functions required by ClimaCoupler.jl for a SurfaceModelSimulation
@@ -52,6 +53,7 @@ function bucket_init(
5253
tspan::Tuple{Float64, Float64},
5354
config::String,
5455
albedo_type::String,
56+
land_initial_condition::String,
5557
land_temperature_anomaly::String,
5658
output_dir::String;
5759
space,
@@ -138,6 +140,53 @@ function bucket_init(
138140
Y.bucket.Ws .= 0.0
139141
Y.bucket.σS .= 0.0
140142

143+
# Overwrite initial conditions with interpolated values from a netcdf file using
144+
# the `SpaceVaryingInputs` tool. We expect the file to contain the following variables:
145+
# - `W`, for subsurface water storage (2D),
146+
# - `Ws`, for surface water content (2D),
147+
# - `T`, for soil temperature (3D),
148+
# - `S`, for snow water equivalent (2D).
149+
150+
if !isempty(land_initial_condition)
151+
ds = NCDataset(land_initial_condition)
152+
has_all_variables = all(key -> haskey(ds, key), ["W", "Ws", "T", "S"])
153+
@assert has_all_variables "The land iniital condition file is expected to contain the variables W, Ws, T, and S (read documentation about requirements)."
154+
close(ds)
155+
156+
surface_space = domain.space.surface
157+
subsurface_space = domain.space.subsurface
158+
regridder_type = :InterpolationsRegridder
159+
extrapolation_bc = (Interpolations.Periodic(), Interpolations.Flat(), Interpolations.Flat())
160+
Y.bucket.W .= SpaceVaryingInput(
161+
land_initial_condition,
162+
"W",
163+
surface_space;
164+
regridder_type,
165+
regridder_kwargs = (; extrapolation_bc,),
166+
)
167+
Y.bucket.Ws .= SpaceVaryingInput(
168+
land_initial_condition,
169+
"Ws",
170+
surface_space;
171+
regridder_type,
172+
regridder_kwargs = (; extrapolation_bc,),
173+
)
174+
Y.bucket.T .= SpaceVaryingInput(
175+
land_initial_condition,
176+
"T",
177+
subsurface_space;
178+
regridder_type,
179+
regridder_kwargs = (; extrapolation_bc,),
180+
)
181+
Y.bucket.σS .= SpaceVaryingInput(
182+
land_initial_condition,
183+
"S",
184+
surface_space;
185+
regridder_type,
186+
regridder_kwargs = (; extrapolation_bc,),
187+
)
188+
end
189+
141190
# Set initial aux variable values
142191
set_initial_cache! = CL.make_set_initial_cache(model)
143192
set_initial_cache!(p, Y, tspan[1])
1.25 MB
Binary file not shown.

experiments/ClimaEarth/run_amip.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ add_extra_diagnostics!(config_dict)
118118
turb_flux_partition,
119119
land_domain_type,
120120
land_albedo_type,
121+
land_initial_condition,
121122
land_temperature_anomaly,
122123
energy_check,
123124
conservation_softfail,
@@ -253,6 +254,7 @@ if mode_name == "amip"
253254
tspan,
254255
land_domain_type,
255256
land_albedo_type,
257+
land_initial_condition,
256258
land_temperature_anomaly,
257259
land_output_dir;
258260
dt = component_dt_dict["dt_land"],
@@ -351,6 +353,7 @@ elseif mode_name in ("slabplanet", "slabplanet_aqua", "slabplanet_terra")
351353
tspan,
352354
land_domain_type,
353355
land_albedo_type,
356+
land_initial_condition,
354357
land_temperature_anomaly,
355358
land_output_dir;
356359
dt = component_dt_dict["dt_land"],
@@ -401,6 +404,7 @@ elseif mode_name == "slabplanet_eisenman"
401404
tspan,
402405
land_domain_type,
403406
land_albedo_type,
407+
land_initial_condition,
404408
land_temperature_anomaly,
405409
land_output_dir;
406410
dt = component_dt_dict["dt_land"],

experiments/ClimaEarth/run_cloudy_slabplanet.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ atmos_config_object.toml_dict["max_area_limiter_scale"]["value"] = 0
156156

157157
comms_ctx = Utilities.get_comms_context(Dict("device" => "auto"))
158158

159-
#=
160-
## Data File Paths
161-
=#
162-
land_mask_data = joinpath(@clima_artifact("landsea_mask_60arcseconds", comms_ctx), "landsea_mask.nc")
163-
164159
#=
165160
## Component Model Initialization
166161
=#
@@ -187,6 +182,10 @@ thermo_params = get_thermo_params(atmos_sim)
187182
## init a 2D boundary space at the surface
188183
boundary_space = CC.Spaces.horizontal_space(atmos_sim.domain.face_space) # TODO: specify this in the coupler and pass it to all component models #665
189184

185+
# Land initial condition
186+
# Use the default land initial condition (not reading from a file)
187+
land_initial_condition = ""
188+
190189
#=
191190
### Land-sea Fraction
192191
This is a static field that contains the area fraction of land and sea, ranging from 0 to 1. If applicable, sea ice is included in the sea fraction. at this stage.
@@ -206,6 +205,7 @@ land_sim = bucket_init(
206205
tspan,
207206
"sphere",
208207
"map_static",
208+
land_initial_condition,
209209
"aquaplanet",
210210
land_output_dir;
211211
dt = Δt_cpl,

experiments/ClimaEarth/user_io/arg_parsing.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function get_coupler_args(config_dict::Dict)
8585
# ClimaLand-specific information
8686
land_domain_type = config_dict["land_domain_type"]
8787
land_albedo_type = config_dict["land_albedo_type"]
88+
land_initial_condition = config_dict["land_initial_condition"]
8889
land_temperature_anomaly = config_dict["land_temperature_anomaly"]
8990
use_land_diagnostics = config_dict["use_land_diagnostics"]
9091

@@ -116,6 +117,7 @@ function get_coupler_args(config_dict::Dict)
116117
plot_diagnostics,
117118
land_domain_type,
118119
land_albedo_type,
120+
land_initial_condition,
119121
land_temperature_anomaly,
120122
use_land_diagnostics,
121123
)

0 commit comments

Comments
 (0)