Skip to content

Commit

Permalink
add option to turn off land diags
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Oct 7, 2024
1 parent 77589b8 commit f4a3087
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions experiments/ClimaEarth/cli_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ function argparse_settings()
help = "Type of temperature anomaly for bucket model. [`amip`, `aquaplanet` (default)]"
arg_type = String
default = "aquaplanet"
"--use_land_diagnostics"
help = "Boolean flag indicating whether to compute and output land model diagnostics [`true` (default), `false`]"
arg_type = Bool
default = true
end
return s
end
Expand Down
17 changes: 11 additions & 6 deletions experiments/ClimaEarth/components/land/climaland_bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function bucket_init(
t_start::Float64,
energy_check::Bool,
surface_elevation,
use_land_diagnostics::Bool,
) where {FT}
if config != "sphere"
println(
Expand Down Expand Up @@ -132,7 +133,7 @@ function bucket_init(
@. Y.bucket.T = T_sfc_0 + temp_anomaly(coords.subsurface)
# `surface_elevation` is a ClimaCore.Fields.Field(`half` level)
orog_adjusted_T = CC.Fields.field_values(Y.bucket.T) .- lapse_rate .* CC.Fields.field_values(surface_elevation)
# Adjust T based on surface elevation (p.bucket.T_sfc is then set using the
# Adjust T based on surface elevation (p.bucket.T_sfc is then set using the
# set_initial_cache! function)
parent(Y.bucket.T) .= parent(orog_adjusted_T)

Expand All @@ -149,12 +150,16 @@ function bucket_init(
bucket_ode_function = CTS.ClimaODEFunction(T_exp! = exp_tendency!, dss! = CL.dss!)
prob = SciMLBase.ODEProblem(bucket_ode_function, Y, tspan, p)

# Add diagnostics
netcdf_writer = CD.Writers.NetCDFWriter(domain.space.subsurface, artifacts_dir)
scheduled_diagnostics = CL.default_diagnostics(model, date_ref, output_writer = netcdf_writer)
# Add diagnostics, which are output daily by default
if use_land_diagnostics
netcdf_writer = CD.Writers.NetCDFWriter(domain.space.subsurface, artifacts_dir)
scheduled_diagnostics = CL.default_diagnostics(model, date_ref, output_writer = netcdf_writer)

diagnostic_handler = CD.DiagnosticsHandler(scheduled_diagnostics, Y, p, t_start; dt = dt)
diag_cb = CD.DiagnosticsCallback(diagnostic_handler)
diagnostic_handler = CD.DiagnosticsHandler(scheduled_diagnostics, Y, p, t_start; dt = dt)
diag_cb = CD.DiagnosticsCallback(diagnostic_handler)
else
diag_cb = nothing
end

integrator = SciMLBase.init(
prob,
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 @@ -146,6 +146,7 @@ restart_t = Int(config_dict["restart_t"])
evolving_ocean = config_dict["evolving_ocean"]
dt_rad = config_dict["dt_rad"]
use_coupler_diagnostics = config_dict["use_coupler_diagnostics"]
use_land_diagnostics = config_dict["use_land_diagnostics"]

#=
## Setup Communication Context
Expand Down Expand Up @@ -281,6 +282,7 @@ if mode_name == "amip"
t_start = t_start,
energy_check = energy_check,
surface_elevation,
use_land_diagnostics,
)

## ocean stub
Expand Down Expand Up @@ -368,6 +370,7 @@ elseif mode_name in ("slabplanet", "slabplanet_aqua", "slabplanet_terra")
t_start = t_start,
energy_check = energy_check,
surface_elevation,
use_land_diagnostics,
)

## ocean model
Expand Down Expand Up @@ -417,6 +420,7 @@ elseif mode_name == "slabplanet_eisenman"
t_start = t_start,
energy_check = energy_check,
surface_elevation,
use_land_diagnostics,
)

## ocean stub (here set to zero area coverage)
Expand Down
1 change: 1 addition & 0 deletions experiments/ClimaEarth/run_cloudy_slabplanet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ land_sim = bucket_init(
t_start = tspan[1],
energy_check = false,
surface_elevation,
use_land_diagnostics = true,
)

ocean_sim = ocean_init(
Expand Down

0 comments on commit f4a3087

Please sign in to comment.