Global full land (snow+soil+canopy) run

The code sets up the ClimaLand land model on a spherical domain, forcing with ERA5 data, but does not actually run the simulation. To run the simulation, we strongly recommend using a GPU.

First we import a lot of packages:

import ClimaComms
ClimaComms.@import_required_backends
using ClimaUtilities
import Interpolations
import ClimaUtilities.TimeVaryingInputs:
    TimeVaryingInput, LinearInterpolation, PeriodicCalendar
import ClimaParams as CP
import ClimaLand
import ClimaLand.Parameters as LP
import ClimaLand.Simulations: LandSimulation, solve!
using Dates
using CairoMakie, ClimaAnalysis, GeoMakie, Printf, StatsBase
import ClimaLand.LandSimVis as LandSimVis;

Set the simulation float type, determine the context (MPI or on a single node), and device type (CPU or GPU). Create a default output directory for diagnostics.

const FT = Float64;
context = ClimaComms.context()
ClimaComms.init(context)
device = ClimaComms.device()
device_suffix = device isa ClimaComms.CPUSingleThreaded ? "cpu" : "gpu"
root_path = "land_longrun_$(device_suffix)"
diagnostics_outdir = joinpath(root_path, "global_diagnostics")
outdir =
    ClimaUtilities.OutputPathGenerator.generate_output_path(diagnostics_outdir);
toml_dict = LP.create_toml_dict(FT)
ParamDict{Float64} with 636 parameters

We can optionally save the simulation parameters to a file for later reference. Here we specify the filepath where we want to save the parameters, and then ClimaParams handles the saving. Note that any parameters overwritten via keyword arguments when constructing models will not be reflected in this file.

parameter_log_file = joinpath(root_path, "parameters.toml")
CP.log_parameter_information(toml_dict, parameter_log_file)
┌ Warning: Keys are present in parameter file but not used in the simulation. 
│  Typically this is due to a mismatch in parameter name in toml and in source. Offending keys: Any["beta_min", "bucket_z_0m", "canopy_momentum_roughness_length", "pmodel_Ha_Vcmax", "kf", "f_over", "moisture_stress_pc", "pmodel_ϕ0_c3", "kd_p2", "z0", "pmodel_ϕ0_c4", "pmodel_ϕa1_c4", "pmodel_bRd", "bucket_z_0b", "critical_snow_fraction", "canopy_height", "plant_S_s", "kn_p2", "RAI", "alpha_0", "moisture_stress_c", "x0", "pmodel_oi", "kappa_p2", "delta_S", "bucket_beta_decay_exponent", "bucket_capacity_fraction", "pmodel_ΔHko", "K_sat_plant", "k", "alpha_snow", "Weibull_c", "SAI", "pmodel_α", "min_kd", "pmodel_ΔHkc", "psi_63", "pmodel_aRd", "pmodel_ϕa0_c3", "pmodel_Kc25", "moisture_stress_sc", "pmodel_ϕa2_c4", "pmodel_Hd_Vcmax", "kn_p1", "pmodel_Γstar25", "pmodel_ϕa1_c3", "pmodel_Ha_Jmax", "delta_alpha", "R_sb", "pmodel_Hd_Jmax", "pmodel_aS_Vcmax", "pmodel_bS_Vcmax", "bucket_soil_conductivity", "pmodel_aS_Jmax", "plant_nu", "critical_snow_water_equivalent", "pmodel_fC3", "a", "pmodel_cstar", "canopy_scalar_roughness_length", "pmodel_ΔHΓstar", "beta_0", "pmodel_bS_Jmax", "pmodel_ϕa2_c3", "ac_canopy", "land_bucket_capacity", "bucket_soil_heat_capacity", "pmodel_Ko25", "kd_p1", "kp", "beta", "pmodel_β", "pmodel_ϕa0_c4", "kappa_p1", "gamma"]
└ @ ClimaParams ~/.julia/packages/ClimaParams/c6eE0/src/ClimaParams.jl:358

Set timestep, start_date, stop_date:

Δt = 450.0
start_date = DateTime(2008)
stop_date = DateTime(2009);

Create the domain - this is intentionally low resolution, about 4.5 x 4.5 degrees horizontally, to avoid allocating a lot of memory when building the documentation. By default and for testing runs we use nelements = (101, 15), which is about 0.9 x 0.9 degrees horizontally with 15 layers vertically.

nelements = (20, 7)
domain = ClimaLand.Domains.global_domain(FT; context, nelements);

Low-resolution forcing data from ERA5 is used here, but high-resolution should be used for production runs.

forcing = ClimaLand.prescribed_forcing_era5(
    start_date,
    stop_date,
    domain.space.surface,
    toml_dict,
    FT;
    use_lowres_forcing = true,
    max_wind_speed = 25.0,
    time_interpolation_method = LinearInterpolation(PeriodicCalendar()),
    regridder_type = :InterpolationsRegridder,
    context,
);

MODIS LAI is prescribed for the canopy model:

LAI = ClimaLand.Canopy.prescribed_lai_modis(
    domain.space.surface,
    start_date,
    stop_date,
);

Make the model:

model = ClimaLand.LandModel{FT}(forcing, LAI, toml_dict, domain, Δt);
simulation = ClimaLand.Simulations.LandSimulation(
    start_date,
    stop_date,
    Δt,
    model;
    outdir,
    user_callbacks = (),
);

Run the simulation and make plots:

ClimaLand.Simulations.solve!(simulation)
LandSimVis.make_annual_timeseries(simulation; savedir = root_path)
LandSimVis.make_heatmaps(simulation;date = stop_date, savedir = root_path)
LandSimVis.make_leaderboard_plots(simulation, savedir = root_path)

This page was generated using Literate.jl.