Skip to content

Commit

Permalink
add diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Jul 11, 2024
1 parent c7d4742 commit 66e807d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .buildkite/longruns_gpu/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ steps:
- label: ":seedling: Soil-Canopy"
command:
- julia --color=yes --project=.buildkite experiments/long_runs/land.jl
artifact_paths: "$$JOB_NAME/output_active/*"
artifact_paths: "$$JOB_NAME/*png"
agents:
slurm_gpus: 1
slurm_time: 12:00:00
env:
CLIMACOMMS_DEVICE: "CUDA"
JOB_NAME: "soil_canopy"
JOB_NAME: "land_longrun_gpu"
3 changes: 1 addition & 2 deletions experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ root_path = "land_longrun_$(device_suffix)"
diagnostics_outdir = joinpath(root_path, "global_diagnostics")
outdir =
ClimaUtilities.OutputPathGenerator.generate_output_path(diagnostics_outdir)
!ispath(outdir) && mkpath(outdir)

function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))

Expand Down Expand Up @@ -650,7 +649,7 @@ setup_and_solve_problem(; greet = true)
# read in diagnostics and make some plots!
#### ClimaAnalysis ####
simdir = ClimaAnalysis.SimDir(outdir)
short_names_2D = ["gpp"] #["ai", "rn", "ct", "lhf", "shf", "vflux", "gpp"]
short_names_2D = ["gpp", "ct", "ai", "slw", "si"] #["ai", "rn", "ct", "lhf", "shf", "vflux", "gpp"]
# short_names_3D = ["tsoil", "si", "slw"]
times = 0.0:(60.0 * 60.0 * 1):(60.0 * 60.0 * 24)
for t in times
Expand Down
2 changes: 2 additions & 0 deletions src/diagnostics/Diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ using ..Bucket: BucketModel

import ..SoilCanopyModel

import ..Domains: top_center_to_surface

import ClimaDiagnostics:
DiagnosticVariable, ScheduledDiagnostic, average_pre_output_hook!

Expand Down
12 changes: 7 additions & 5 deletions src/diagnostics/default_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ function default_diagnostics(

if output_vars == :long
soilcanopy_diagnostics = [
"rn",
"lhf",
"rae",
"shf",
"rn_canopy",
"rn_soil",
"lhf_soil",
"lhf_canopy",
"shf_canopy",
"shf_soil",
"vflux",
"tsoil",
"slw",
Expand Down Expand Up @@ -113,7 +115,7 @@ function default_diagnostics(
"soilco2",
]
elseif output_vars == :short
soilcanopy_diagnostics = ["gpp"]
soilcanopy_diagnostics = ["gpp", "ct", "ai", "slw", "si"]
end

default_outputs =
Expand Down
6 changes: 3 additions & 3 deletions src/diagnostics/define_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ function define_diagnostics!(land_model)
long_name = "Area Index",
standard_name = "area_index",
units = "",
comments = "The area index.", #?? of steam, leaves, roots?
comments = "The area index of leaves.",
compute! = (out, Y, p, t) ->
compute_area_index!(out, Y, p, t, land_model),
)
Expand Down Expand Up @@ -627,7 +627,7 @@ function define_diagnostics!(land_model)
short_name = "ct",
long_name = "Canopy Temperature",
standard_name = "canopy_temperature",
units = "",
units = "K",
comments = "Canopy temperature.", #?? of steam, leaves, roots?
compute! = (out, Y, p, t) ->
compute_canopy_temperature!(out, Y, p, t, land_model),
Expand All @@ -638,7 +638,7 @@ function define_diagnostics!(land_model)
long_name = "Soil Ice",
standard_name = "soil_ice",
units = "m^3 m^-3",
comments = "soil ice.", #?? of steam, leaves, roots?
comments = "soil ice.",
compute! = (out, Y, p, t) ->
compute_soil_ice!(out, Y, p, t, land_model),
)
Expand Down
26 changes: 13 additions & 13 deletions src/diagnostics/soilcanopy_compute_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ end

function compute_soil_temperature!(out, Y, p, t, land_model::SoilCanopyModel)
if isnothing(out)
return copy(p.drivers.T) # or is it p.soil.T?
return copy(p.soil.T) # or is it p.soil.T?
else
out .= p.drivers.T
out .= p.soil.T
end
end

function compute_soil_water_liquid(out, Y, p, t, land_model::SoilCanopyModel)
function compute_soil_water_liquid!(out, Y, p, t, land_model::SoilCanopyModel)
if isnothing(out)
return copy(p.soil.θ_l) # or is it in Y.soil?
return copy(top_center_to_surface(p.soil.θ_l)) # or is it in Y.soil?
else
out .= p.soil.θ_l
out .= top_center_to_surface(p.soil.θ_l)
end
end

Expand Down Expand Up @@ -512,11 +512,11 @@ function compute_cross_section_roots(out, Y, p, t, land_model::SoilCanopyModel)
end
end

function compute_area_index(out, Y, p, t, land_model::SoilCanopyModel)
function compute_area_index!(out, Y, p, t, land_model::SoilCanopyModel)
if isnothing(out)
return copy(p.canopy.hydraulics.area_index)
return copy(p.canopy.hydraulics.area_index.leaf)
else
p.canopy.hydraulics.area_index
out .= p.canopy.hydraulics.area_index.leaf
end
end

Expand Down Expand Up @@ -562,18 +562,18 @@ function compute_canopy_aerodynamic_resistance(
end
end

function compute_canopy_temperature(out, Y, p, t, land_model::SoilCanopyModel)
function compute_canopy_temperature!(out, Y, p, t, land_model::SoilCanopyModel)
if isnothing(out)
return copy(Y.canopy.energy.T)
else
Y.canopy.energy.T
out .= Y.canopy.energy.T
end
end

function compute_soil_ice(out, Y, p, t, land_model::SoilCanopyModel)
function compute_soil_ice!(out, Y, p, t, land_model::SoilCanopyModel)
if isnothing(out)
return copy(Y.soil.θ_i)
return copy(top_center_to_surface(Y.soil.θ_i))
else
Y.soil.θ_i
out .= top_center_to_surface(Y.soil.θ_i)
end
end

0 comments on commit 66e807d

Please sign in to comment.