From d65fb4919732c07f29b230cce1f5d9b4efa18eed Mon Sep 17 00:00:00 2001 From: AlexisRenchon Date: Fri, 9 Aug 2024 09:36:34 -0700 Subject: [PATCH] Fix GPU bug from sif model The implementation of the sif model in the Canopy module broke GPU compatibility. This PR fixes this bug. Co-authored-by: AlexisRenchon Co-authored-by: SBozzolo --- experiments/benchmarks/land.jl | 2 +- .../integrated/global/global_soil_canopy.jl | 2 +- experiments/long_runs/land.jl | 3 ++- src/standalone/Vegetation/optimality_farquhar.jl | 1 + .../Vegetation/solar_induced_fluorescence.jl | 14 ++++++++++---- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/experiments/benchmarks/land.jl b/experiments/benchmarks/land.jl index 3abec4200e..85368220be 100644 --- a/experiments/benchmarks/land.jl +++ b/experiments/benchmarks/land.jl @@ -470,7 +470,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15)) # or PR #645 for details. # For now, this clipping is similar to what CLM does. LAIfunction = TimeVaryingInput( - joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"), + joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"), "lai", surface_space; reference_date = ref_time, diff --git a/experiments/integrated/global/global_soil_canopy.jl b/experiments/integrated/global/global_soil_canopy.jl index 4a6962e807..137e244b84 100644 --- a/experiments/integrated/global/global_soil_canopy.jl +++ b/experiments/integrated/global/global_soil_canopy.jl @@ -231,7 +231,7 @@ photosynthesis_args = (; # Set up plant hydraulics # Not ideal LAIfunction = TimeVaryingInput( - joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"), + joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"), "lai", surface_space; reference_date = ref_time, diff --git a/experiments/long_runs/land.jl b/experiments/long_runs/land.jl index e48d785748..7aed2cd370 100644 --- a/experiments/long_runs/land.jl +++ b/experiments/long_runs/land.jl @@ -462,6 +462,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15)) ) ) # Set up plant hydraulics + # Note that we clip all values of LAI below 0.05 to zero. # This is because we currently run into issues when LAI is # of order eps(FT) in the SW radiation code. @@ -469,7 +470,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15)) # or PR #645 for details. # For now, this clipping is similar to what CLM does. LAIfunction = TimeVaryingInput( - joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"), + joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"), "lai", surface_space; reference_date = ref_time, diff --git a/src/standalone/Vegetation/optimality_farquhar.jl b/src/standalone/Vegetation/optimality_farquhar.jl index a2212269b7..1422b20271 100644 --- a/src/standalone/Vegetation/optimality_farquhar.jl +++ b/src/standalone/Vegetation/optimality_farquhar.jl @@ -153,3 +153,4 @@ function update_photosynthesis!( @. Rd = dark_respiration(Vcmax25, β, f, ΔHRd, T, To, R) @. An = net_photosynthesis(Ac, Aj, Rd, β) end +Base.broadcastable(m::OptimalityFarquharParameters) = tuple(m) diff --git a/src/standalone/Vegetation/solar_induced_fluorescence.jl b/src/standalone/Vegetation/solar_induced_fluorescence.jl index f2ca8e6df7..17e8f1131d 100644 --- a/src/standalone/Vegetation/solar_induced_fluorescence.jl +++ b/src/standalone/Vegetation/solar_induced_fluorescence.jl @@ -76,6 +76,7 @@ function update_SIF!( T_freeze, photosynthesis_parameters, ) + (; ΔHJmax, To, θj, ϕ) = photosynthesis_parameters sif_parameters = sif_model.parameters @. SIF = compute_SIF_at_a_point( APAR, @@ -83,7 +84,10 @@ function update_SIF!( Vcmax25, R, T_freeze, - photosynthesis_parameters, + ΔHJmax, + To, + θj, + ϕ, sif_parameters, ) end @@ -95,10 +99,12 @@ function compute_SIF_at_a_point( Vcmax25::FT, R::FT, T_freeze::FT, - photosynthesis_parameters, - sif_parameters, + ΔHJmax::FT, + To::FT, + θj::FT, + ϕ::FT, + sif_parameters::SIFParameters{FT}, ) where {FT} - (; ΔHJmax, To, θj, ϕ) = photosynthesis_parameters Jmax = max_electron_transport(Vcmax25, ΔHJmax, Tc, To, R) J = electron_transport(APAR, Jmax, θj, ϕ) (; kf, kd_p1, kd_p2, min_kd, kn_p1, kn_p2, kp, kappa_p1, kappa_p2) =