@@ -720,6 +720,96 @@ add_diagnostic_variable!(
720720 compute! = compute_evspsbl!,
721721)
722722
723+ # ##
724+ # Latent heat flux (2d)
725+ # ##
726+ compute_hfls!(out, state, cache, time) =
727+ compute_hfls!(out, state, cache, time, cache. atmos. moisture_model)
728+ compute_hfls!(_, _, _, _, model:: T ) where {T} =
729+ error_diagnostic_variable(" hfls" , model)
730+
731+ function compute_hfls!(
732+ out,
733+ state,
734+ cache,
735+ time,
736+ moisture_model:: T ,
737+ ) where {T <: Union{EquilMoistModel, NonEquilMoistModel} }
738+ (; ρ_flux_q_tot) = cache. precomputed. sfc_conditions
739+ (; surface_ct3_unit) = cache. core
740+ thermo_params = CAP. thermodynamics_params(cache. params)
741+ LH_v0 = TD. Parameters. LH_v0(thermo_params)
742+
743+ if isnothing(out)
744+ return dot.(ρ_flux_q_tot, surface_ct3_unit) .* LH_v0
745+ else
746+ out .= dot.(ρ_flux_q_tot, surface_ct3_unit) .* LH_v0
747+ end
748+ end
749+
750+ add_diagnostic_variable!(
751+ short_name = " hfls" ,
752+ long_name = " Surface Upward Latent Heat Flux" ,
753+ standard_name = " surface_upward_latent_heat_flux" ,
754+ units = " W m^-2" ,
755+ compute! = compute_hfls!,
756+ )
757+
758+ # ##
759+ # Sensible heat flux (2d)
760+ # ##
761+ compute_hfss!(out, state, cache, time) =
762+ compute_hfss!(out, state, cache, time, cache. atmos. moisture_model)
763+ compute_hfss!(_, _, _, _, model:: T ) where {T} =
764+ error_diagnostic_variable(" hfss" , model)
765+
766+ function compute_hfss!(
767+ out,
768+ state,
769+ cache,
770+ time,
771+ moisture_model:: T ,
772+ ) where {T <: DryModel }
773+ (; ρ_flux_h_tot) = cache. precomputed. sfc_conditions
774+ (; surface_ct3_unit) = cache. core
775+
776+ if isnothing(out)
777+ return dot.(ρ_flux_h_tot, surface_ct3_unit)
778+ else
779+ out .= dot.(ρ_flux_h_tot, surface_ct3_unit)
780+ end
781+ end
782+
783+ function compute_hfss!(
784+ out,
785+ state,
786+ cache,
787+ time,
788+ moisture_model:: T ,
789+ ) where {T <: Union{EquilMoistModel, NonEquilMoistModel} }
790+ (; ρ_flux_h_tot, ρ_flux_q_tot) = cache. precomputed. sfc_conditions
791+ (; surface_ct3_unit) = cache. core
792+ thermo_params = CAP. thermodynamics_params(cache. params)
793+ LH_v0 = TD. Parameters. LH_v0(thermo_params)
794+
795+ if isnothing(out)
796+ return dot.(ρ_flux_h_tot, surface_ct3_unit) .-
797+ dot.(ρ_flux_q_tot, surface_ct3_unit) .* LH_v0
798+ else
799+ out .=
800+ dot.(ρ_flux_h_tot, surface_ct3_unit) .-
801+ dot.(ρ_flux_q_tot, surface_ct3_unit) .* LH_v0
802+ end
803+ end
804+
805+ add_diagnostic_variable!(
806+ short_name = " hfss" ,
807+ long_name = " Surface Upward Sensible Heat Flux" ,
808+ standard_name = " surface_upward_sensible_heat_flux" ,
809+ units = " W m^-2" ,
810+ compute! = compute_hfss!,
811+ )
812+
723813# ##
724814# Precipitation (2d)
725815# ##
0 commit comments