Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/amip_configs/amip.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FLOAT_TYPE: "Float32"
albedo_model: "CouplerAlbedo"
atmos_config_file: "config/atmos_configs/climaatmos_diagedmf.yml"
bucket_albedo_type: "map_temporal"
checkpoint_dt: "366days"
coupler_toml: ["toml/amip.toml"]
dt: "120secs"
dt_cpl: "120secs"
energy_check: false
land_model: "integrated"
mode_name: "amip"
netcdf_output_at_levels: true
output_default_diagnostics: true
Expand Down
92 changes: 53 additions & 39 deletions experiments/ClimaEarth/components/land/climaland_integrated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ function FluxCalculator.compute_surface_fluxes!(
@. coupled_atmos.u = StaticArrays.SVector(p.scratch1, p.scratch2)

# Use scratch space for remapped atmospheric fields to avoid allocations
Interfacer.remap!(p.scratch1, csf.ρ_atmos)
Interfacer.remap!(p.scratch2, csf.T_atmos)
Interfacer.remap!(p.scratch3, csf.q_atmos)
#Interfacer.remap!(p.scratch1, csf.ρ_atmos)
#Interfacer.remap!(p.scratch2, csf.T_atmos)
#Interfacer.remap!(p.scratch3, csf.q_atmos)
@. coupled_atmos.thermal_state =
TD.PhaseEquil_ρTq(thermo_params, p.scratch1, p.scratch2, p.scratch3)
TD.PhaseEquil_ρTq(thermo_params, csf.ρ_atmos, csf.T_atmos, csf.q_atmos)

# set the same atmosphere state for all sub-components
@assert sim.model.soil.boundary_conditions.top.atmos ===
Expand All @@ -581,17 +581,20 @@ function FluxCalculator.compute_surface_fluxes!(

# Combine turbulent energy fluxes from each component of the land model
# Use temporary variables to avoid allocating
Interfacer.remap!(
csf.scalar_temp1,
canopy_dest.lhf .+ soil_dest.lhf .* (1 .- p.snow.snow_cover_fraction) .+
p.snow.snow_cover_fraction .* snow_dest.lhf,
)
Interfacer.remap!(
csf.scalar_temp2,
canopy_dest.shf .+ soil_dest.shf .* (1 .- p.snow.snow_cover_fraction) .+
p.snow.snow_cover_fraction .* snow_dest.shf,
)

@. p.scratch1 = canopy_dest.lhf + soil_dest.lhf * (1 .- p.snow.snow_cover_fraction) +
p.snow.snow_cover_fraction * snow_dest.lhf
#Interfacer.remap!(
# csf.scalar_temp1,
# p.scratch1,
#)
csf.scalar_temp1 .= p.scratch1
@. p.scratch1 = canopy_dest.shf + soil_dest.shf * (1 - p.snow.snow_cover_fraction) +
p.snow.snow_cover_fraction * snow_dest.shf
#Interfacer.remap!(
# csf.scalar_temp2,
# p.scratch1
#)
csf.scalar_temp2 .= p.scratch1
# Zero out the fluxes where the area fraction is zero
@. csf.scalar_temp1 =
ifelse(area_fraction == 0, zero(csf.scalar_temp1), csf.scalar_temp1)
Expand All @@ -605,48 +608,59 @@ function FluxCalculator.compute_surface_fluxes!(
# Combine turbulent moisture fluxes from each component of the land model
# Note that we multiply by ρ_liq to convert from m s-1 to kg m-2 s-1
ρ_liq = (LP.ρ_cloud_liq(sim.model.soil.parameters.earth_param_set))
Interfacer.remap!(
csf.scalar_temp1,
(
canopy_dest.transpiration .+
(soil_dest.vapor_flux_liq .+ soil_dest.vapor_flux_ice) .*
(1 .- p.snow.snow_cover_fraction) .+
p.snow.snow_cover_fraction .* snow_dest.vapor_flux
) .* ρ_liq,
)
@. p.scratch1 = (canopy_dest.transpiration +
(soil_dest.vapor_flux_liq + soil_dest.vapor_flux_ice) *
(1 - p.snow.snow_cover_fraction) +
p.snow.snow_cover_fraction * snow_dest.vapor_flux
) * ρ_liq
#Interfacer.remap!(
# csf.scalar_temp1,
# p.scratch1
#)
csf.scalar_temp1 .= p.scratch1

@. csf.scalar_temp1 =
ifelse(area_fraction == 0, zero(csf.scalar_temp1), csf.scalar_temp1)
@. csf.F_turb_moisture += csf.scalar_temp1 * area_fraction

# Combine turbulent momentum fluxes from each component of the land model
# Note that we exclude the canopy component here for now, since we can have nonzero momentum fluxes
# where there is zero LAI. This should be fixed in ClimaLand.
Interfacer.remap!(
csf.scalar_temp1,
soil_dest.ρτxz .* (1 .- p.snow.snow_cover_fraction) .+
p.snow.snow_cover_fraction .* snow_dest.ρτxz,
)
@. p.scratch1 = soil_dest.ρτxz * (1 - p.snow.snow_cover_fraction) +
p.snow.snow_cover_fraction * snow_dest.ρτxz
#Interfacer.remap!(
# csf.scalar_temp1,
# p.scratch1,
#)
csf.scalar_temp1 .= p.scratch1

@. csf.scalar_temp1 =
ifelse(area_fraction == 0, zero(csf.scalar_temp1), csf.scalar_temp1)
@. csf.F_turb_ρτxz += csf.scalar_temp1 * area_fraction

Interfacer.remap!(
csf.scalar_temp1,
soil_dest.ρτyz .* (1 .- p.snow.snow_cover_fraction) .+
p.snow.snow_cover_fraction .* snow_dest.ρτyz,
)
@. p.scratch1 = soil_dest.ρτyz * (1 - p.snow.snow_cover_fraction) +
p.snow.snow_cover_fraction * snow_dest.ρτyz
#Interfacer.remap!(
# csf.scalar_temp1,
# p.scratch1
#)
csf.scalar_temp1 .= p.scratch1

@. csf.scalar_temp1 =
ifelse(area_fraction == 0, zero(csf.scalar_temp1), csf.scalar_temp1)
@. csf.F_turb_ρτyz += csf.scalar_temp1 * area_fraction

# Combine the buoyancy flux from each component of the land model
# Note that we exclude the canopy component here for now, since ClimaLand doesn't
# include its extra resistance term in the buoyancy flux calculation.
Interfacer.remap!(
csf.scalar_temp1,
soil_dest.buoy_flux .* (1 .- p.snow.snow_cover_fraction) .+
p.snow.snow_cover_fraction .* snow_dest.buoy_flux,
)
@. p.scratch1 = soil_dest.buoy_flux * (1 - p.snow.snow_cover_fraction) +
p.snow.snow_cover_fraction * snow_dest.buoy_flux
#Interfacer.remap!(
# csf.scalar_temp1,
# p.scratch1
#)
csf.scalar_temp1 .= p.scratch1

@. csf.scalar_temp1 =
ifelse(area_fraction == 0, zero(csf.scalar_temp1), csf.scalar_temp1)
@. csf.buoyancy_flux += csf.scalar_temp1 * area_fraction
Expand Down
Loading