Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inference in surface conditions #3292

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/surface_conditions/surface_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ end
surface_state(sfc_setup_wrapper::SurfaceState, _, _, _) = sfc_setup_wrapper

surface_state(
wrapped_sfc_setup::Function,
wrapped_sfc_setup::F,
sfc_local_geometry_values,
int_z_values,
t,
) = wrapped_sfc_setup(sfc_local_geometry_values.coordinates, int_z_values, t)
) where {F <: Function} =
wrapped_sfc_setup(sfc_local_geometry_values.coordinates, int_z_values, t)

# This is a hack for meeting the August 7th deadline. It is to ensure that the
# coupler will be able to construct an integrator before overwriting its surface
Expand Down Expand Up @@ -149,7 +150,7 @@ Computes the surface conditions, given information about the surface and the
first interior point. Implements the assumptions listed for `SurfaceState`.
"""
function surface_state_to_conditions(
wrapped_sfc_setup,
wrapped_sfc_setup::WSS,
surface_local_geometry,
interior_ts,
interior_u,
Expand All @@ -161,7 +162,7 @@ function surface_state_to_conditions(
atmos,
sfc_prognostic_temp,
t,
)
) where {WSS}
surf_state =
surface_state(wrapped_sfc_setup, surface_local_geometry, interior_z, t)
parameterization = surf_state.parameterization
Expand Down
25 changes: 15 additions & 10 deletions src/surface_conditions/surface_setups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ function (::GABLS)(params)
q_vap = FT(0)
z0 = FT(0.1)
parameterization = MoninObukhov(; z0)
surface_state(surface_coordinates, interior_z, t) = SurfaceState(;
parameterization,
T = 265 - FT(0.25) * FT(t) / 3600,
p,
q_vap,
)
function surface_state(surface_coordinates, interior_z, t)
_FT = eltype(surface_coordinates) # do not capture FT
SurfaceState(;
parameterization,
T = 265 - _FT(0.25) * _FT(t) / 3600,
p,
q_vap,
)
end
return surface_state
end

Expand Down Expand Up @@ -119,7 +122,8 @@ function (::LifeCycleTan2018)(params)
z0 = FT(1e-4)
ustar = FT(0.28)
function surface_state(surface_coordinates, interior_z, t)
weight = FT(0.01) + FT(0.99) * (cos(2 * FT(π) * t / 3600) + 1) / 2
_FT = eltype(surface_coordinates) # do not capture FT
weight = _FT(0.01) + _FT(0.99) * (cos(2 * _FT(π) * t / 3600) + 1) / 2
fluxes =
θAndQFluxes(; θ_flux = θ_flux0 * weight, q_flux = q_flux0 * weight)
parameterization = MoninObukhov(; z0, fluxes, ustar)
Expand Down Expand Up @@ -226,9 +230,10 @@ function (::TRMM_LBA)(params)
z0 = FT(1e-4)
ustar = FT(0.28) # 0.28 is taken from Bomex. TODO: Approximate from LES TKE.
function surface_state(surface_coordinates, interior_z, t)
value = cos(FT(π) / 2 * (1 - FT(t) / (FT(5.25) * 3600)))
shf = 270 * max(0, value)^FT(1.5)
lhf = 554 * max(0, value)^FT(1.3)
_FT = eltype(surface_coordinates) # do not capture FT
value = cos(_FT(π) / 2 * (1 - _FT(t) / (_FT(5.25) * 3600)))
shf = 270 * max(0, value)^_FT(1.5)
lhf = 554 * max(0, value)^_FT(1.3)
fluxes = HeatFluxes(; shf, lhf)
parameterization = MoninObukhov(; z0, fluxes, ustar)
return SurfaceState(; parameterization, T, p, q_vap)
Expand Down
Loading