Skip to content

Commit e63280d

Browse files
authored
Fix method error when has_condensate has integer 0 input (#299)
1 parent 50cde14 commit e63280d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/aux_functions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ See: https://stackoverflow.com/questions/14687665/very-slow-stdpow-for-bases-ver
2727
Smallest acceptable number that is different than zero.
2828
"""
2929
ϵ_numerics(FT) = sqrt(floatmin(FT))
30+
ϵ_numerics(::Type{<:Integer}) = 0

test/correctness.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,18 @@ using the non-deprecated functional API (no `PhasePartition`/state types).
277277
q_any = FT(0.01)
278278
r = TD.specific_humidity_to_mixing_ratio(q_any, q_tot)
279279
@test r q_any / (1 - q_tot)
280+
281+
# Regression test for relative_humidity with default integer arguments
282+
# (Ensures internal type stability when q_liq/q_ice default to Int 0)
283+
T_rh = FT(300)
284+
p_rh = FT(1e5)
285+
rh = TD.relative_humidity(param_set, T_rh, p_rh, q_tot)
286+
287+
# Expected value using explicit floats
288+
p_vap = TD.partial_pressure_vapor(param_set, p_rh, q_tot, FT(0), FT(0))
289+
p_sat = TD.saturation_vapor_pressure(param_set, T_rh, FT(0), FT(0))
290+
rh_expected = p_vap / p_sat
291+
@test rh rh_expected
280292
end
281293

282294
@testset "Reference temperature invariance ($FT)" begin

0 commit comments

Comments
 (0)