Skip to content

Commit

Permalink
add bucket initial condition
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Dec 18, 2024
1 parent a1c1dc7 commit 8c80137
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/ci_configs/amip_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dt_save_to_sol: "1days"
dz_bottom: 30
dz_top: 3000
h_elem: 4
land_initial_condition: "experiments/ClimaEarth/test/bucket_ic_august.nc"
mode_name: "amip"
moist: "equil"
precip_model: "0M"
Expand Down
4 changes: 4 additions & 0 deletions experiments/ClimaEarth/cli_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ function argparse_settings()
help = "Access land surface albedo information from data file. [`map_static` (default), `function`, `map_temporal`]"
arg_type = String
default = "map_static" # to be replaced by land config file, when available
"--land_initial_condition"
help = "A file path for a NetCDF file (read documentation about requirements)"
arg_type = String
default = ""
"--land_temperature_anomaly"
help = "Type of temperature anomaly for bucket model. [`amip`, `aquaplanet` (default)]"
arg_type = String
Expand Down
41 changes: 41 additions & 0 deletions experiments/ClimaEarth/components/land/climaland_bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function bucket_init(
tspan::Tuple{Float64, Float64},
config::String,
albedo_type::String,
land_initial_condition::String,
land_temperature_anomaly::String,
output_dir::String;
space,
Expand Down Expand Up @@ -138,6 +139,46 @@ function bucket_init(
Y.bucket.Ws .= 0.0
Y.bucket.σS .= 0.0

# overwrite initial conditions
if !isempty(land_initial_condition)
surface_space = domain.space.surface
subsurface_space = domain.space.subsurface
regridder_type = :InterpolationsRegridder
extrapolation_bc = (
Interpolations.Periodic(),
Interpolations.Flat(),
Interpolations.Flat(),
)
Y.bucket.W .= SpaceVaryingInput(
land_initial_condition,
"W",
surface_space;
regridder_type,
regridder_kwargs = (; extrapolation_bc,),
)
Y.bucket.Ws .= SpaceVaryingInput(
land_initial_condition,
"Ws",
surface_space;
regridder_type,
regridder_kwargs = (; extrapolation_bc,),
)
Y.bucket.T .= SpaceVaryingInput(
land_initial_condition,
"T",
subsurface_space;
regridder_type,
regridder_kwargs = (; extrapolation_bc,),
)
Y.bucket.σS .= SpaceVaryingInput(
land_initial_condition,
"S",
surface_space;
regridder_type,
regridder_kwargs = (; extrapolation_bc,),
)
end

# Set initial aux variable values
set_initial_cache! = CL.make_set_initial_cache(model)
set_initial_cache!(p, Y, tspan[1])
Expand Down
4 changes: 4 additions & 0 deletions experiments/ClimaEarth/run_amip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ add_extra_diagnostics!(config_dict)
turb_flux_partition,
land_domain_type,
land_albedo_type,
land_initial_condition,
land_temperature_anomaly,
energy_check,
conservation_softfail,
Expand Down Expand Up @@ -253,6 +254,7 @@ if mode_name == "amip"
tspan,
land_domain_type,
land_albedo_type,
land_initial_condition,
land_temperature_anomaly,
land_output_dir;
dt = component_dt_dict["dt_land"],
Expand Down Expand Up @@ -351,6 +353,7 @@ elseif mode_name in ("slabplanet", "slabplanet_aqua", "slabplanet_terra")
tspan,
land_domain_type,
land_albedo_type,
land_initial_condition,
land_temperature_anomaly,
land_output_dir;
dt = component_dt_dict["dt_land"],
Expand Down Expand Up @@ -401,6 +404,7 @@ elseif mode_name == "slabplanet_eisenman"
tspan,
land_domain_type,
land_albedo_type,
land_initial_condition,
land_temperature_anomaly,
land_output_dir;
dt = component_dt_dict["dt_land"],
Expand Down
11 changes: 11 additions & 0 deletions experiments/ClimaEarth/test/amip_bucket_ic.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## AMIP testing
# This script runs a coarse AMIP simulation with the bucket initial condition
# read from a file. The purpose of this test is to check if the bucket
# initial condition is read correctly.

# Specify the config file and job id
push!(ARGS, "--config_file", joinpath(@__DIR__, "amip_bucket_ic.yml"))
push!(ARGS, "--job_id", "amip_bucket_ic")

# Run the AMIP test
include("../run_amip.jl")
18 changes: 18 additions & 0 deletions experiments/ClimaEarth/test/amip_bucket_ic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apply_limiter: false
dt: "150secs"
dt_cpl: "150secs"
dt_rad: "1hours"
dt_save_to_sol: "1days"
dz_bottom: 30
dz_top: 3000
h_elem: 4
land_initial_condition: "experiments/ClimaEarth/test/bucket_ic_august.nc"
mode_name: "amip"
moist: "equil"
precip_model: "0M"
rad: "gray"
rayleigh_sponge: true
t_end: "300secs"
vert_diff: "true"
z_elem: 50
z_stretch: false
Binary file added experiments/ClimaEarth/test/bucket_ic_august.nc
Binary file not shown.
2 changes: 2 additions & 0 deletions experiments/ClimaEarth/user_io/arg_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function get_coupler_args(config_dict::Dict)
# ClimaLand-specific information
land_domain_type = config_dict["land_domain_type"]
land_albedo_type = config_dict["land_albedo_type"]
land_initial_condition = config_dict["land_initial_condition"]
land_temperature_anomaly = config_dict["land_temperature_anomaly"]
use_land_diagnostics = config_dict["use_land_diagnostics"]

Expand Down Expand Up @@ -116,6 +117,7 @@ function get_coupler_args(config_dict::Dict)
plot_diagnostics,
land_domain_type,
land_albedo_type,
land_initial_condition,
land_temperature_anomaly,
use_land_diagnostics,
)
Expand Down

0 comments on commit 8c80137

Please sign in to comment.