Skip to content

Commit b8faf2c

Browse files
authored
Spatial parameter gap filling; soil longer run; bug with texture parameters (#1165)
1 parent c93d0ef commit b8faf2c

File tree

3 files changed

+56
-28
lines changed

3 files changed

+56
-28
lines changed

.buildkite/longruns_gpu/pipeline.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ steps:
4949
- "snowy_land_longrun_gpu/*pdf"
5050
agents:
5151
slurm_gpus: 1
52-
slurm_time: 15:00:00
52+
slurm_time: 3:00:00
5353
env:
5454
CLIMACOMMS_DEVICE: "CUDA"
5555

@@ -69,7 +69,7 @@ steps:
6969
artifact_paths: "soil_longrun_gpu/*pdf"
7070
agents:
7171
slurm_gpus: 1
72-
slurm_time: 15:00:00
72+
slurm_time: 3:00:00
7373
env:
7474
CLIMACOMMS_DEVICE: "CUDA"
7575

@@ -83,18 +83,29 @@ steps:
8383
env:
8484
CLIMACOMMS_DEVICE: "CUDA"
8585

86-
- group: "Very long run of snowy land"
86+
- group: "Longer runs of Global Land Models"
8787
if: build.env("LONGER_RUN") != null
8888
steps:
89-
- label: ":snow_capped_mountain: Snowy Land"
89+
- label: "Snowy Land, 10 years"
9090
command:
9191
- julia --color=yes --project=.buildkite experiments/long_runs/snowy_land.jl
9292
artifact_paths:
9393
- "snowy_land_longrun_gpu/*png"
9494
- "snowy_land_longrun_gpu/*pdf"
9595
agents:
9696
slurm_gpus: 1
97-
slurm_time: 24:00:00
97+
slurm_time: 15:00:00
9898
env:
9999
CLIMACOMMS_DEVICE: "CUDA"
100100
LONGER_RUN: ""
101+
102+
- label: "Soil, 10 years"
103+
command:
104+
- julia --color=yes --project=.buildkite experiments/long_runs/soil.jl
105+
artifact_paths: "soil_longrun_gpu/*pdf"
106+
agents:
107+
slurm_gpus: 1
108+
slurm_time: 15:00:00
109+
env:
110+
CLIMACOMMS_DEVICE: "CUDA"
111+
LONGER_RUN: ""

experiments/long_runs/soil.jl

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ import NCDatasets
4343
using Poppler_jll: pdfunite
4444

4545
const FT = Float64;
46-
time_interpolation_method = LinearInterpolation(PeriodicCalendar())
46+
# If you want to do a very long run locally, you can enter `export
47+
# LONGER_RUN=""` in the terminal and run this script. If you want to do a very
48+
# long run on Buildkite manually, then make a new build and pass `LONGER_RUN=""`
49+
# as an environment variable. In both cases, the value of `LONGER_RUN` does not
50+
# matter.
51+
const LONGER_RUN = haskey(ENV, "LONGER_RUN") ? true : false
4752
context = ClimaComms.context()
4853
ClimaComms.init(context)
4954
device = ClimaComms.device()
@@ -53,12 +58,23 @@ diagnostics_outdir = joinpath(root_path, "global_diagnostics")
5358
outdir =
5459
ClimaUtilities.OutputPathGenerator.generate_output_path(diagnostics_outdir)
5560

56-
function setup_model(FT, start_date, domain, earth_param_set)
61+
function setup_model(FT, start_date, stop_date, domain, earth_param_set)
62+
time_interpolation_method =
63+
LONGER_RUN ? LinearInterpolation() :
64+
LinearInterpolation(PeriodicCalendar())
5765
surface_space = domain.space.surface
5866
subsurface_space = domain.space.subsurface
5967
# Forcing data
60-
era5_ncdata_path =
61-
ClimaLand.Artifacts.era5_land_forcing_data2008_path(; context)
68+
if LONGER_RUN
69+
era5_ncdata_path = ClimaLand.Artifacts.find_era5_year_paths(
70+
start_date,
71+
stop_date;
72+
context,
73+
)
74+
else
75+
era5_ncdata_path =
76+
ClimaLand.Artifacts.era5_land_forcing_data2008_path(; context)
77+
end
6278
atmos, radiation = ClimaLand.prescribed_forcing_era5(
6379
era5_ncdata_path,
6480
surface_space,
@@ -133,8 +149,10 @@ function setup_model(FT, start_date, domain, earth_param_set)
133149
end
134150

135151
function setup_simulation(; greet = false)
136-
start_date = DateTime(2008)
137-
stop_date = DateTime(2010)
152+
# If not LONGER_RUN, run for 2 years; note that the forcing from 2008 is repeated.
153+
# If LONGER run, run for 10 years, with the correct forcing each year.
154+
start_date = LONGER_RUN ? DateTime(2004) : DateTime(2008)
155+
stop_date = LONGER_RUN ? DateTime(2014) : DateTime(2010)
138156
Δt = 450.0
139157
nelements = (101, 15)
140158
if greet
@@ -147,7 +165,7 @@ function setup_simulation(; greet = false)
147165
domain =
148166
ClimaLand.ModelSetup.global_domain(FT; comms_ctx = context, nelements)
149167
params = LP.LandParameters(FT)
150-
model = setup_model(FT, start_date, domain, params)
168+
model = setup_model(FT, start_date, stop_date, domain, params)
151169
diagnostics = ClimaLand.default_diagnostics(
152170
model,
153171
start_date;

src/simulations/spatial_parameters.jl

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,17 @@ function default_spatially_varying_soil_parameters(
280280
file_reader_kwargs = (; preprocess_func = (data) -> data > 0,),
281281
)
282282
# If the parameter mask = 0, set to physical value
283+
# (equal to the mean where we have data; the mean of α is in log space)
283284
# This function in applied in **simulation mask** aware
284285
# manner.
286+
# That is, we replace values in the simulation, but without data, with the mean
287+
# over the data.
285288
masked_to_value(field, mask, value) =
286289
mask == 1.0 ? field : eltype(field)(value)
287290

288-
μ = FT(0.27)
291+
μ = FT(0.33)
289292
vg_α .= masked_to_value.(vg_α, soil_params_mask, 10.0^μ)
290-
μ = FT(1.65)
293+
μ = FT(1.74)
291294
vg_n .= masked_to_value.(vg_n, soil_params_mask, μ)
292295

293296
vg_fields_to_hcm_field::FT, n::FT) where {FT} =
@@ -326,20 +329,15 @@ function default_spatially_varying_soil_parameters(
326329
regridder_kwargs = (; extrapolation_bc,),
327330
)
328331

329-
μ = FT(-6)
332+
# Set missing values to the mean. For Ksat, we use the mean in log space.
333+
μ = FT(-5.08)
330334
K_sat .= masked_to_value.(K_sat, soil_params_mask, 10.0^μ)
331335

332-
ν .= masked_to_value.(ν, soil_params_mask, 1)
336+
ν .= masked_to_value.(ν, soil_params_mask, 0.47)
333337

334-
θ_r .= masked_to_value.(θ_r, soil_params_mask, 0)
338+
θ_r .= masked_to_value.(θ_r, soil_params_mask, 0.09)
335339

336-
337-
S_s =
338-
masked_to_value.(
339-
ClimaCore.Fields.zeros(subsurface_space) .+ FT(1e-3),
340-
soil_params_mask,
341-
1,
342-
)
340+
S_s = ClimaCore.Fields.zeros(subsurface_space) .+ FT(1e-3)
343341

344342
soilgrids_artifact_path =
345343
ClimaLand.Artifacts.soil_grids_params_artifact_path(;
@@ -372,10 +370,11 @@ function default_spatially_varying_soil_parameters(
372370
# we require that the sum of these be less than 1 and equal to or bigger than zero.
373371
# The input should satisfy this almost exactly, but the regridded values may not.
374372
# Values of zero are OK here, so we dont need to apply any masking
375-
texture_norm = @. min(ν_ss_gravel + ν_ss_quartz + ν_ss_om, 1)
376-
@. ν_ss_gravel = ν_ss_gravel / max(texture_norm, eps(FT))
377-
@. ν_ss_om = ν_ss_om / max(texture_norm, eps(FT))
378-
@. ν_ss_quartz = ν_ss_quartz / max(texture_norm, eps(FT))
373+
# if sum > 1, normalize by sum, else "normalize" by 1 (i.e., do not normalize)
374+
texture_norm = @. max(ν_ss_gravel + ν_ss_quartz + ν_ss_om, 1)
375+
@. ν_ss_gravel = ν_ss_gravel / texture_norm
376+
@. ν_ss_om = ν_ss_om / texture_norm
377+
@. ν_ss_quartz = ν_ss_quartz / texture_norm
379378

380379
# Read in f_max data and topmodel params land sea mask
381380
infile_path = ClimaLand.Artifacts.topmodel_data_path()

0 commit comments

Comments
 (0)