Skip to content

Commit

Permalink
Make RRTMGP inherit float type
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Feb 6, 2024
1 parent 51398e5 commit ed67148
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 7 additions & 10 deletions src/parameterized_tendencies/radiation/RRTMGPInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ function extrap!(::BestFit, p, T, z, p⁺, T⁺, z⁺, p⁺⁺, T⁺⁺, z⁺⁺
@. p = best_fit_p(T, z, p⁺, T⁺, z⁺, p⁺⁺, T⁺⁺, z⁺⁺)
end
function extrap!(::UseSurfaceTempAtBottom, p, T, p⁺, T⁺, p⁺⁺, T⁺⁺, Tₛ, params)
FT = eltype(p)
cₚ = FT(RRTMGP.Parameters.cp_d(params))
R = FT(RRTMGP.Parameters.R_d(params))
cₚ = RRTMGP.Parameters.cp_d(params)
R = RRTMGP.Parameters.R_d(params)
@. T = Tₛ
@. p = p⁺ * (T / T⁺)^(cₚ / R)
end
Expand All @@ -305,10 +304,9 @@ function extrap!(
Tₛ,
params,
)
FT = eltype(p)
g = FT(RRTMGP.Parameters.grav(params))
cₚ = FT(RRTMGP.Parameters.cp_d(params))
R = FT(RRTMGP.Parameters.R_d(params))
g = RRTMGP.Parameters.grav(params)
cₚ = RRTMGP.Parameters.cp_d(params)
R = RRTMGP.Parameters.R_d(params)
@. T = T⁺ + g / cₚ * (z⁺ - z)
@. p = p⁺ * (T / T⁺)^(cₚ / R)
end
Expand Down Expand Up @@ -382,7 +380,6 @@ array.
- `lookup_tables/cloudysky_lw.nc`
- `lookup_tables/clearsky_sw.nc`
- `lookup_tables/cloudysky_sw.nc`
- `FT`: floating-point number type (performance with `Float32` is questionable)
- `DA`: array type (defaults to `CuArray` when a compatible GPU is available)
# Keyword Arguments
Expand Down Expand Up @@ -482,7 +479,6 @@ array.
function RRTMGPModel(
params::RRTMGP.Parameters.ARP,
data_loader::Function,
::Type{FT},
context;
ncol::Int,
domain_nlay::Int,
Expand All @@ -498,9 +494,10 @@ function RRTMGPModel(
add_isothermal_boundary_layer::Bool = false,
max_threads::Int = 256,
kwargs...,
) where {FT <: AbstractFloat}
)
device = ClimaComms.device(context)
DA = ClimaComms.array_type(device)
FT = typeof(params.grav)
# turn kwargs into a Dict, so that values can be dynamically popped from it
dict = Dict(kwargs)

Expand Down
2 changes: 0 additions & 2 deletions src/parameterized_tendencies/radiation/radiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ function radiation_model_cache(
radiation_model = RRTMGPI.RRTMGPModel(
rrtmgp_params,
data_loader,
# TODO: pass FT through so that it can be controlled at the top-level
Float64,
context;
ncol = length(Spaces.all_nodes(axes(Spaces.level(Y.c, 1)))),
domain_nlay = Spaces.nlevels(axes(Y.c)),
Expand Down

0 comments on commit ed67148

Please sign in to comment.