Skip to content

Commit 7dcfb0f

Browse files
Merge pull request #1217 from CliMA/ne/bucket_parameters
Add optional `toml_files` kwarg to the `BucketSimulation` func
2 parents 23fd60d + 23ffb5a commit 7dcfb0f

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

NEWS.md

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

77
### ClimaCoupler features
88

9+
#### Add support for parameter files in `BucketSimulation` PR[#1217](https://github.com/CliMA/ClimaCoupler.jl/pull/1217)
10+
Add a keyword argument `parameter_files` to `BucketSimulation` to enable
11+
calibration in a coupled simulation, passed via the `"coupler_toml"` argument.
12+
913
#### Add `ClimaLandSimulation` object PR[#1199](https://github.com/CliMA/ClimaCoupler.jl/pull/1199)
1014
Add methods to support running `ClimaLand.LandModel` in a coupled simulation.
1115
Also add tests to verify the constructor setup and taking a step.

experiments/ClimaEarth/components/atmosphere/climaatmos.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,9 @@ function get_atmos_config_dict(coupler_dict::Dict, job_id::String, atmos_output_
427427
atmos_toml = joinpath.(pkgdir(CA), atmos_config["toml"])
428428
coupler_toml = joinpath.(pkgdir(ClimaCoupler), coupler_dict["coupler_toml"])
429429
toml = isempty(coupler_toml) ? atmos_toml : coupler_toml
430-
if haskey(atmos_config, "calibration_toml")
431-
push!(toml, atmos_config["calibration_toml"])
432-
end
433430
if !isempty(toml)
434431
@info "Overwriting Atmos parameters from input TOML file(s): $toml"
435-
atmos_config = merge(atmos_config, Dict("toml" => toml))
432+
atmos_config["toml"] = toml
436433
end
437434

438435
# Specify atmos output directory to be inside the coupler output directory

experiments/ClimaEarth/components/land/climaland_bucket.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ClimaTimeSteppers as CTS
77
import Thermodynamics as TD
88
import ClimaLand as CL
99
import ClimaLand.Parameters as LP
10+
import ClimaParams as CP
1011
import ClimaDiagnostics as CD
1112
import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer
1213
using NCDatasets
@@ -77,6 +78,7 @@ function BucketSimulation(
7778
albedo_type::String = "map_static",
7879
land_initial_condition::String = "",
7980
energy_check::Bool = false,
81+
parameter_files = [],
8082
) where {FT, TT <: Union{Float64, ITime}}
8183
@assert domain_type == "sphere" "Currently only spherical shell domains are supported; single column may be supported in the future."
8284

@@ -117,7 +119,13 @@ function BucketSimulation(
117119
κ_soil = FT(1.5) # soil conductivity
118120
ρc_soil = FT(2e6) # soil volumetric heat capacity
119121

120-
params = CL.Bucket.BucketModelParameters(FT; albedo, z_0m, z_0b, τc, σS_c, W_f, κ_soil, ρc_soil)
122+
params = if isempty(parameter_files)
123+
CL.Bucket.BucketModelParameters(FT; albedo, z_0m, z_0b, τc, σS_c, W_f, κ_soil, ρc_soil)
124+
else
125+
toml_dict = CP.create_toml_dict(FT; override_file = CP.merge_toml_files(parameter_files; override = true))
126+
# τc should be the only exception, it depends on `dt`
127+
CL.Bucket.BucketModelParameters(toml_dict; z_0m, z_0b, albedo, τc)
128+
end
121129

122130
n_vertical_elements = 7
123131
# Note that this does not take into account topography of the surface, which is OK for this land model.

experiments/ClimaEarth/setup_run.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ function setup_and_run(config_dict::AbstractDict)
200200
energy_check,
201201
conservation_softfail,
202202
output_dir_root,
203+
parameter_files,
203204
) = get_coupler_args(config_dict)
204205

205206
#=
@@ -341,6 +342,7 @@ function setup_and_run(config_dict::AbstractDict)
341342
albedo_type = land_albedo_type,
342343
land_initial_condition,
343344
energy_check,
345+
parameter_files,
344346
)
345347

346348
## sea ice model
@@ -387,6 +389,7 @@ function setup_and_run(config_dict::AbstractDict)
387389
albedo_type = land_albedo_type,
388390
land_initial_condition,
389391
energy_check,
392+
parameter_files,
390393
)
391394

392395
## ocean model
@@ -435,6 +438,7 @@ function setup_and_run(config_dict::AbstractDict)
435438
albedo_type = land_albedo_type,
436439
land_initial_condition,
437440
energy_check,
441+
parameter_files,
438442
)
439443

440444
## ocean stub (here set to zero area coverage)

experiments/ClimaEarth/user_io/arg_parsing.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ function get_coupler_args(config_dict::Dict)
5858
random_seed = config_dict["unique_seed"] ? time_ns() : 1234
5959
FT = config_dict["FLOAT_TYPE"] == "Float64" ? Float64 : Float32
6060

61+
# Vector of TOML files containing model parameters
62+
parameter_files = config_dict["coupler_toml"]
63+
6164
# Time information
6265
t_end = Float64(Utilities.time_to_seconds(config_dict["t_end"]))
6366
t_start = Float64(Utilities.time_to_seconds(config_dict["t_start"]))
@@ -140,6 +143,7 @@ function get_coupler_args(config_dict::Dict)
140143
land_initial_condition,
141144
land_temperature_anomaly,
142145
use_land_diagnostics,
146+
parameter_files,
143147
)
144148
end
145149

@@ -157,7 +161,6 @@ Extract the necessary arguments from the atmosphere configuration dictionary.
157161
function get_atmos_args(atmos_config_dict)
158162
dt_rad = atmos_config_dict["dt_rad"]
159163
output_default_diagnostics = atmos_config_dict["output_default_diagnostics"]
160-
161164
return (; dt_rad, output_default_diagnostics)
162165
end
163166

0 commit comments

Comments
 (0)