Skip to content

Commit

Permalink
Cache: clean up reference state
Browse files Browse the repository at this point in the history
  • Loading branch information
Sbozzolo committed Oct 23, 2023
1 parent 4d8a557 commit 95c4ee5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/cache/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,23 @@ function default_cache(
simulation,
surface_setup,
)

FT = eltype(params)

ᶜcoord = Fields.local_geometry_field(Y.c).coordinates
R_d = FT(CAP.R_d(params))
MSLP = FT(CAP.MSLP(params))
grav = FT(CAP.grav(params))
T_ref = FT(255)
ᶜΦ = CAP.grav(params) .* ᶜcoord.z
ᶜρ_ref = @. MSLP * exp(-grav * ᶜcoord.z / (R_d * T_ref)) / (R_d * T_ref)
ᶜp_ref = @. ᶜρ_ref * R_d * T_ref
if !numerics.use_reference_state
ᶜρ_ref .*= 0
ᶜp_ref .*= 0
ᶜΦ = grav .* ᶜcoord.z

if atmos.numerics.use_reference_state
R_d = FT(CAP.R_d(params))
MSLP = FT(CAP.MSLP(params))
T_ref = FT(255)
ᶜρ_ref = @. MSLP * exp(-grav * ᶜcoord.z / (R_d * T_ref)) / (R_d * T_ref)
ᶜp_ref = @. ᶜρ_ref * R_d * T_ref
else
ᶜρ_ref = zero(ᶜΦ)
ᶜp_ref = zero(ᶜΦ)
end

if eltype(ᶜcoord) <: Geometry.LatLongZPoint
Ω = CAP.Omega(params)
ᶜf = @. 2 * Ω * sind(ᶜcoord.lat)
Expand Down

0 comments on commit 95c4ee5

Please sign in to comment.