Skip to content

Commit

Permalink
Merge #1856
Browse files Browse the repository at this point in the history
1856: fix surface flux diagnostics in remapped files r=szy21 a=szy21



Co-authored-by: Zhaoyi Shen <[email protected]>
  • Loading branch information
bors[bot] and szy21 authored Jul 11, 2023
2 parents a49eb88 + 0678ecf commit 93b7336
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion perf/flame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ allocs_limit["flame_perf_target_edmfx"] = 285440
allocs_limit["flame_perf_target_diagnostic_edmfx"] = 10480
allocs_limit["flame_perf_target_edmf"] = 7326724944
allocs_limit["flame_perf_target_threaded"] = 6175664
allocs_limit["flame_perf_target_callbacks"] = 42862920
allocs_limit["flame_perf_target_callbacks"] = 43994936
allocs_limit["flame_perf_gw"] = 4887558624

if allocs < allocs_limit[job_id] * buffer
Expand Down
17 changes: 4 additions & 13 deletions post_processing/remap/remap_helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,11 @@ function remap2latlon(filein, data_dir, remap_tmpdir, weightfile, nlat, nlon)
end

if :sfc_flux_energy in propertynames(diag)
sfc_flux_energy_phy = Geometry.WVector.(diag.sfc_flux_energy)
nc_sfc_flux_energy[:, 1] = sfc_flux_energy_phy.components.data.:1
sfc_flux_momentum = diag.sfc_flux_momentum
sfc_local_geometry = Fields.local_geometry_field(sfc_flux_momentum)
w_unit = @. CT3(
SurfaceConditions.unit_basis_vector_data(CT3, sfc_local_geometry),
)
sfc_flux_momentum_phy =
Geometry.UVVector.(adjoint.(sfc_flux_momentum) .* w_unit)
nc_sfc_flux_u[:, 1] = sfc_flux_momentum_phy.components.data.:1
nc_sfc_flux_v[:, 1] = sfc_flux_momentum_phy.components.data.:2
nc_sfc_flux_energy[:, 1] = diag.sfc_flux_energy
nc_sfc_flux_u[:, 1] = diag.sfc_flux_u
nc_sfc_flux_v[:, 1] = diag.sfc_flux_v
if :sfc_evaporation in propertynames(diag)
sfc_evaporation_phy = Geometry.WVector.(diag.sfc_evaporation)
nc_sfc_evaporation[:, 1] = sfc_evaporation_phy.components.data.:1
nc_sfc_evaporation[:, 1] = diag.sfc_evaporation
end
end

Expand Down
19 changes: 15 additions & 4 deletions src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ClimaCore.DataLayouts as DL
import ClimaAtmos.RRTMGPInterface as RRTMGPI
import ClimaAtmos.SurfaceConditions: unit_basis_vector_data
import Thermodynamics as TD
import LinearAlgebra
import ClimaCore.Fields
Expand Down Expand Up @@ -376,16 +377,26 @@ function compute_diagnostics(integrator)
end

if !isnothing(p.atmos.vert_diff)
sfc_local_geometry =
Fields.level(Fields.local_geometry_field(Y.f), Fields.half)
surface_ct3_unit =
CT3.(unit_basis_vector_data.(CT3, sfc_local_geometry))
(; ρ_flux_uₕ, ρ_flux_h_tot) = p.sfc_conditions
sfc_flux_momentum =
Geometry.UVVector.(
adjoint.(ρ_flux_uₕ ./ Spaces.level(ᶠinterp.(Y.c.ρ), half)) .*
surface_ct3_unit
)
vert_diff_diagnostic = (;
sfc_flux_momentum = ρ_flux_uₕ ./
Spaces.level(ᶠinterp.(Y.c.ρ), half),
sfc_flux_energy = ρ_flux_h_tot,
sfc_flux_u = sfc_flux_momentum.components.data.:1,
sfc_flux_v = sfc_flux_momentum.components.data.:2,
sfc_flux_energy = dot.(ρ_flux_h_tot, surface_ct3_unit),
)
if :ρq_tot in propertynames(Y.c)
(; ρ_flux_q_tot) = p.sfc_conditions
vert_diff_diagnostic = (;
vert_diff_diagnostic...,
sfc_evaporation = p.sfc_conditions.ρ_flux_q_tot,
sfc_evaporation = dot.(ρ_flux_q_tot, surface_ct3_unit),
)
end
else
Expand Down

0 comments on commit 93b7336

Please sign in to comment.