Skip to content

Commit 15278a8

Browse files
authored
add precip and snowfall to default diags, and add Tair (#1203)
1 parent 45fe601 commit 15278a8

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/diagnostics/default_diagnostics.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ function default_diagnostics(
339339
"shf",
340340
"iwc",
341341
"snowc",
342+
"tair",
343+
"precip",
342344
]
343345
elseif output_vars == :short
344346
snowyland_diagnostics = [
@@ -363,6 +365,8 @@ function default_diagnostics(
363365
"swd",
364366
"lwd",
365367
"snowc",
368+
"tair",
369+
"precip",
366370
]
367371
end
368372

src/diagnostics/define_diagnostics.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,26 @@ function define_diagnostics!(land_model)
600600
compute_snowfall!(out, Y, p, t, land_model),
601601
)
602602

603+
# Total precip (mass flux)
604+
add_diagnostic_variable!(
605+
short_name = "precip",
606+
long_name = "Total precipitation",
607+
standard_name = "total_precipitation",
608+
units = "kg m^-2 s^-1",
609+
comments = "The total flux from precipitation in kg of water per m^2 of ground per second).",
610+
compute! = (out, Y, p, t) -> compute_precip!(out, Y, p, t, land_model),
611+
)
612+
613+
#Air temperature
614+
add_diagnostic_variable!(
615+
short_name = "tair",
616+
long_name = "Air Temperature (K)",
617+
standard_name = "tair",
618+
units = "K",
619+
comments = "The air temperature at the lowest level of the atmosphere (coupled) or 2m level (prescribed).",
620+
compute! = (out, Y, p, t) -> compute_tair!(out, Y, p, t, land_model),
621+
)
622+
603623
# Specific humidity
604624
add_diagnostic_variable!(
605625
short_name = "qsfc",

src/diagnostics/land_compute_methods.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,27 @@ end
275275
@diagnostic_compute "radiation_longwave_down" Union{SoilCanopyModel, LandModel} p.drivers.LW_d
276276
@diagnostic_compute "radiation_shortwave_down" Union{SoilCanopyModel, LandModel} p.drivers.SW_d
277277
@diagnostic_compute "snowfall" Union{SoilCanopyModel, LandModel} p.drivers.P_snow
278+
@diagnostic_compute "tair" Union{SoilCanopyModel, LandModel} p.drivers.T
278279
@diagnostic_compute "specific_humidity" Union{SoilCanopyModel, LandModel} p.drivers.q
279280
@diagnostic_compute "wind_speed" Union{SoilCanopyModel, LandModel} p.drivers.u
280281

282+
function compute_precip!(
283+
out,
284+
Y,
285+
p,
286+
t,
287+
land_model::Union{SoilCanopyModel{FT}, LandModel{FT}},
288+
) where {FT}
289+
if isnothing(out)
290+
out = zeros(land_model.soil.domain.space.surface) # Allocates
291+
fill!(field_values(out), NaN) # fill with NaNs, even over the ocean
292+
@. out = (p.drivers.P_liq + p.drivers.P_snow) * 1000 # density of liquid water (1000kg/m^3)
293+
return out
294+
else
295+
@. out = (p.drivers.P_liq + p.drivers.P_snow) * 1000# density of liquid water (1000kg/m^3)
296+
end
297+
end
298+
281299
## Soil Module ##
282300

283301
@diagnostic_compute "infiltration" Union{SoilCanopyModel, LandModel} p.soil.infiltration

0 commit comments

Comments
 (0)