@@ -447,16 +447,21 @@ function FieldExchanger.update_sim!(sim::ClimaLandSimulation, csf, area_fraction
447447 Interfacer. update_field! (sim, Val (:snow_precipitation ), csf. P_snow)
448448end
449449
450+ """
451+ FieldExchanger.import_atmos_fields!(csf, sim::ClimaLandSimulation, atmos_sim)
452+
453+ Import non-default coupler fields from the atmosphere simulation into the coupler fields.
454+ These include the diffuse fraction of light, shortwave and longwave downwelling radiation,
455+ air pressure, and CO2 concentration.
456+
457+ The default coupler fields will be imported by the default method implemented in
458+ FieldExchanger.jl.
459+ """
450460function FieldExchanger. import_atmos_fields! (csf, sim:: ClimaLandSimulation , atmos_sim)
451461 Interfacer. get_field! (csf. diffuse_fraction, atmos_sim, Val (:diffuse_fraction ))
452462 Interfacer. get_field! (csf. SW_d, atmos_sim, Val (:SW_d ))
453463 Interfacer. get_field! (csf. LW_d, atmos_sim, Val (:LW_d ))
454464 Interfacer. get_field! (csf. P_atmos, atmos_sim, Val (:air_pressure ))
455- Interfacer. get_field! (csf. T_atmos, atmos_sim, Val (:air_temperature ))
456- Interfacer. get_field! (csf. q_atmos, atmos_sim, Val (:specific_humidity ))
457- Interfacer. get_field! (csf. ρ_atmos, atmos_sim, Val (:air_density ))
458- Interfacer. get_field! (csf. P_liq, atmos_sim, Val (:liquid_precipitation ))
459- Interfacer. get_field! (csf. P_snow, atmos_sim, Val (:snow_precipitation ))
460465 # CO2 is a scalar for now so it doesn't need remapping
461466 csf. c_co2 .= Interfacer. get_field (atmos_sim, Val (:co2 ))
462467 return nothing
@@ -596,75 +601,82 @@ function FluxCalculator.compute_surface_fluxes!(
596601 # Combine turbulent energy fluxes from each component of the land model
597602 # Use temporary variables to avoid allocating
598603 Interfacer. remap! (
599- csf. temp1 ,
604+ csf. scalar_temp1 ,
600605 canopy_dest. lhf .+ soil_dest. lhf .* (1 .- p. snow. snow_cover_fraction) .+
601606 p. snow. snow_cover_fraction .* snow_dest. lhf,
602607 )
603608 Interfacer. remap! (
604- csf. temp2 ,
609+ csf. scalar_temp2 ,
605610 canopy_dest. shf .+ soil_dest. shf .* (1 .- p. snow. snow_cover_fraction) .+
606611 p. snow. snow_cover_fraction .* snow_dest. shf,
607612 )
608613
609614 # Zero out the fluxes where the area fraction is zero
610- @. csf. temp1 = ifelse (area_fraction == 0 , zero (csf. temp1), csf. temp1)
611- @. csf. temp2 = ifelse (area_fraction == 0 , zero (csf. temp2), csf. temp2)
615+ @. csf. scalar_temp1 =
616+ ifelse (area_fraction == 0 , zero (csf. scalar_temp1), csf. scalar_temp1)
617+ @. csf. scalar_temp2 =
618+ ifelse (area_fraction == 0 , zero (csf. scalar_temp2), csf. scalar_temp2)
612619
613620 # Update the coupler field in-place
614- @. csf. F_lh += csf. temp1 * area_fraction
615- @. csf. F_sh += csf. temp2 * area_fraction
621+ @. csf. F_lh += csf. scalar_temp1 * area_fraction
622+ @. csf. F_sh += csf. scalar_temp2 * area_fraction
616623
617624 # Combine turbulent moisture fluxes from each component of the land model
618625 # Note that we multiply by ρ_liq to convert from m s-1 to kg m-2 s-1
619626 ρ_liq = (LP. ρ_cloud_liq (sim. model. soil. parameters. earth_param_set))
620627 Interfacer. remap! (
621- csf. temp1 ,
628+ csf. scalar_temp1 ,
622629 (
623630 canopy_dest. transpiration .+
624631 (soil_dest. vapor_flux_liq .+ soil_dest. vapor_flux_ice) .*
625632 (1 .- p. snow. snow_cover_fraction) .+
626633 p. snow. snow_cover_fraction .* snow_dest. vapor_flux
627634 ) .* ρ_liq,
628635 )
629- @. csf. temp1 = ifelse (area_fraction == 0 , zero (csf. temp1), csf. temp1)
630- @. csf. F_turb_moisture += csf. temp1 * area_fraction
636+ @. csf. scalar_temp1 =
637+ ifelse (area_fraction == 0 , zero (csf. scalar_temp1), csf. scalar_temp1)
638+ @. csf. F_turb_moisture += csf. scalar_temp1 * area_fraction
631639
632640 # Combine turbulent momentum fluxes from each component of the land model
633641 # Note that we exclude the canopy component here for now, since we can have nonzero momentum fluxes
634642 # where there is zero LAI. This should be fixed in ClimaLand.
635643 Interfacer. remap! (
636- csf. temp1 ,
644+ csf. scalar_temp1 ,
637645 soil_dest. ρτxz .* (1 .- p. snow. snow_cover_fraction) .+
638646 p. snow. snow_cover_fraction .* snow_dest. ρτxz,
639647 )
640- @. csf. temp1 = ifelse (area_fraction == 0 , zero (csf. temp1), csf. temp1)
641- @. csf. F_turb_ρτxz += csf. temp1 * area_fraction
648+ @. csf. scalar_temp1 =
649+ ifelse (area_fraction == 0 , zero (csf. scalar_temp1), csf. scalar_temp1)
650+ @. csf. F_turb_ρτxz += csf. scalar_temp1 * area_fraction
642651
643652 Interfacer. remap! (
644- csf. temp1 ,
653+ csf. scalar_temp1 ,
645654 soil_dest. ρτyz .* (1 .- p. snow. snow_cover_fraction) .+
646655 p. snow. snow_cover_fraction .* snow_dest. ρτyz,
647656 )
648- @. csf. temp1 = ifelse (area_fraction == 0 , zero (csf. temp1), csf. temp1)
649- @. csf. F_turb_ρτyz += csf. temp1 * area_fraction
657+ @. csf. scalar_temp1 =
658+ ifelse (area_fraction == 0 , zero (csf. scalar_temp1), csf. scalar_temp1)
659+ @. csf. F_turb_ρτyz += csf. scalar_temp1 * area_fraction
650660
651661 # Combine the buoyancy flux from each component of the land model
652662 # Note that we exclude the canopy component here for now, since ClimaLand doesn't
653663 # include its extra resistance term in the buoyancy flux calculation.
654664 Interfacer. remap! (
655- csf. temp1 ,
665+ csf. scalar_temp1 ,
656666 soil_dest. buoy_flux .* (1 .- p. snow. snow_cover_fraction) .+
657667 p. snow. snow_cover_fraction .* snow_dest. buoy_flux,
658668 )
659- @. csf. temp1 = ifelse (area_fraction == 0 , zero (csf. temp1), csf. temp1)
660- @. csf. buoyancy_flux += csf. temp1 * area_fraction
669+ @. csf. scalar_temp1 =
670+ ifelse (area_fraction == 0 , zero (csf. scalar_temp1), csf. scalar_temp1)
671+ @. csf. buoyancy_flux += csf. scalar_temp1 * area_fraction
661672
662673 # Compute ustar from the momentum fluxes and surface air density
663674 # ustar = sqrt(ρτ / ρ)
664- @. csf. temp1 = sqrt (sqrt (csf. F_turb_ρτxz^ 2 + csf. F_turb_ρτyz^ 2 ) / csf. ρ_atmos)
665- @. csf. temp1 = ifelse (area_fraction == 0 , zero (csf. temp1), csf. temp1)
675+ @. csf. scalar_temp1 = sqrt (sqrt (csf. F_turb_ρτxz^ 2 + csf. F_turb_ρτyz^ 2 ) / csf. ρ_atmos)
676+ @. csf. scalar_temp1 =
677+ ifelse (area_fraction == 0 , zero (csf. scalar_temp1), csf. scalar_temp1)
666678 # If ustar is zero, set it to eps to avoid division by zero in the atmosphere
667- @. csf. ustar += max (csf. temp1 * area_fraction, eps (FT))
679+ @. csf. ustar += max (csf. scalar_temp1 * area_fraction, eps (FT))
668680
669681 # Compute the Monin-Obukhov length from ustar and the buoyancy flux
670682 # L_MO = -u^3 / (k * buoyancy_flux)
@@ -674,11 +686,13 @@ function FluxCalculator.compute_surface_fluxes!(
674686 return abs (v) < eps (FT) ? eps (FT) * sign_of_v : v
675687 end
676688 surface_params = LP. surface_fluxes_parameters (sim. model. soil. parameters. earth_param_set)
677- @. csf. temp1 =
689+ @. csf. scalar_temp1 =
678690 - csf. ustar^ 3 / SFP. von_karman_const (surface_params) / non_zero (csf. buoyancy_flux)
679- @. csf. temp1 = ifelse (area_fraction == 0 , zero (csf. temp1), csf. temp1)
691+ @. csf. scalar_temp1 =
692+ ifelse (area_fraction == 0 , zero (csf. scalar_temp1), csf. scalar_temp1)
680693 # When L_MO is infinite, avoid multiplication by zero to prevent NaN
681- @. csf. L_MO += ifelse (isinf (csf. temp1), csf. temp1, csf. temp1 * area_fraction)
694+ @. csf. L_MO +=
695+ ifelse (isinf (csf. scalar_temp1), csf. scalar_temp1, csf. scalar_temp1 * area_fraction)
682696
683697 return nothing
684698end
0 commit comments