Skip to content

Commit

Permalink
Revert to returning zero when dividing by zero
Browse files Browse the repository at this point in the history
In get_field(::ClimaAtmosSimulation, ::Val{:diffuse_fraction}
  • Loading branch information
imreddyTeja committed Feb 27, 2025
1 parent 67d8d6a commit f32cf97
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion experiments/ClimaEarth/components/atmosphere/climaatmos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ function Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:diffuse_fraction
direct_flux_dn = radiation_model.face_sw_direct_flux_dn[1, :]
FT = eltype(total_flux_dn)
diffuse_fraction =
clamp.((total_flux_dn .- direct_flux_dn) ./ (max.(total_flux_dn, eps(FT))), zero(FT), one(FT))
clamp.(
((x, y) -> y > zero(y) ? x / y : zero(y)).(total_flux_dn .- direct_flux_dn, total_flux_dn),
zero(FT),
one(FT),
)
end
return CC.Fields.array2field(diffuse_fraction, lowest_face_space)
end
Expand Down

0 comments on commit f32cf97

Please sign in to comment.