Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use new package versions #502

Merged
merged 1 commit into from
Nov 22, 2023
Merged
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
14 changes: 4 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,33 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f"
TempestRemap_jll = "8573a8c5-1df0-515e-a024-abad257ee284"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
CLIMAParameters = "0.4, 0.5, 0.6, 0.7"
ClimaAtmos = "=0.16.2"
ClimaAtmos = "0.16.3"
ClimaComms = "0.5.6"
juliasloan25 marked this conversation as resolved.
Show resolved Hide resolved
ClimaCore = "0.10"
ClimaCoreTempestRemap = "0.3"
ClimaLSM = "0.3"
ClimaCoreTempestRemap = "0.3.0 - 0.3.10"
ClimaLSM = "0.4"
Dates = "1"
DocStringExtensions = "0.8, 0.9"
Insolation = "0.6"
JLD2 = "0.4"
NCDatasets = "0.11, 0.12"
OrdinaryDiffEq = "5, 6"
Plots = "1.39.0"
juliasloan25 marked this conversation as resolved.
Show resolved Hide resolved
SciMLBase = "1"
SimpleNonlinearSolve = "=0.1.23"
akshaysridhar marked this conversation as resolved.
Show resolved Hide resolved
StaticArrays = "1"
Statistics = "1"
SurfaceFluxes = "0.7"
SurfaceFluxes = "0.8"
TempestRemap_jll = "2"
TerminalLoggers = "0.1"
Thermodynamics = "0.11"
UnPack = "1"
julia = "1.8"
2 changes: 1 addition & 1 deletion config/model_configs/slabplanet_albedo_temporal_map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dt_save_to_sol: "3600secs"
dt_cpl: 200
dt: "200secs"
mono_surface: true
h_elem: 4
h_elem: 6
precip_model: "0M"
land_albedo_type: "map_temporal"
run_name: "slabplanet_albedo_temporal_map"
Expand Down
254 changes: 108 additions & 146 deletions experiments/AMIP/modular/Manifest.toml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions experiments/AMIP/modular/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ IntervalSets = "0.5, 0.6, 0.7"
JSON = "0.21"
MPI = "0.20"
NVTX = "0.3"
OrdinaryDiffEq = "6"
ProgressLogging = "0.1"
RRTMGP = "0.9"
StaticArrays = "1"
TerminalLoggers = "0.1"
YAML = "0.4"

[extras]
Expand Down
64 changes: 34 additions & 30 deletions experiments/AMIP/modular/components/atmosphere/climaatmos_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ function atmos_init(::Type{FT}, atmos_config_dict::Dict) where {FT}
end

# set initial fluxes to zero
@. integrator.p.sfc_conditions.ρ_flux_h_tot = Geometry.Covariant3Vector(FT(0.0))
@. integrator.p.sfc_conditions.ρ_flux_q_tot = Geometry.Covariant3Vector(FT(0.0))
@. integrator.p.sfc_conditions.ρ_flux_uₕ.components = zeros(axes(integrator.p.sfc_conditions.ρ_flux_uₕ.components))
parent(integrator.p.ᶠradiation_flux) .= parent(zeros(axes(integrator.p.ᶠradiation_flux)))
integrator.p.col_integrated_rain .= FT(0)
integrator.p.col_integrated_snow .= FT(0)
@. integrator.p.precomputed.sfc_conditions.ρ_flux_h_tot = Geometry.Covariant3Vector(FT(0.0))
@. integrator.p.precomputed.sfc_conditions.ρ_flux_q_tot = Geometry.Covariant3Vector(FT(0.0))
@. integrator.p.precomputed.sfc_conditions.ρ_flux_uₕ.components =
zeros(axes(integrator.p.precomputed.sfc_conditions.ρ_flux_uₕ.components))
parent(integrator.p.radiation.ᶠradiation_flux) .= parent(zeros(axes(integrator.p.radiation.ᶠradiation_flux)))
integrator.p.precipitation.col_integrated_rain .= FT(0)
integrator.p.precipitation.col_integrated_snow .= FT(0)

sim = ClimaAtmosSimulation(integrator.p.params, Y, spaces, integrator)

Expand All @@ -90,22 +91,22 @@ end

# extensions required by the Interfacer
get_field(sim::ClimaAtmosSimulation, ::Val{:radiative_energy_flux}) =
Fields.level(sim.integrator.p.ᶠradiation_flux, half)
Fields.level(sim.integrator.p.radiation.ᶠradiation_flux, half)
function get_field(sim::ClimaAtmosSimulation, ::Val{:liquid_precipitation})
ρ_liq = CAP.ρ_cloud_liq(sim.integrator.p.params)
sim.integrator.p.col_integrated_rain .* ρ_liq # kg/m^2/s
sim.integrator.p.precipitation.col_integrated_rain .* ρ_liq # kg/m^2/s
end
function get_field(sim::ClimaAtmosSimulation, ::Val{:snow_precipitation})
ρ_liq = CAP.ρ_cloud_liq(sim.integrator.p.params)
sim.integrator.p.col_integrated_snow .* ρ_liq # kg/m^2/s
sim.integrator.p.precipitation.col_integrated_snow .* ρ_liq # kg/m^2/s
end

get_field(sim::ClimaAtmosSimulation, ::Val{:turbulent_energy_flux}) =
Geometry.WVector.(sim.integrator.p.sfc_conditions.ρ_flux_h_tot)
Geometry.WVector.(sim.integrator.p.precomputed.sfc_conditions.ρ_flux_h_tot)
get_field(sim::ClimaAtmosSimulation, ::Val{:turbulent_moisture_flux}) =
Geometry.WVector.(sim.integrator.p.sfc_conditions.ρ_flux_q_tot)
Geometry.WVector.(sim.integrator.p.precomputed.sfc_conditions.ρ_flux_q_tot)

get_field(sim::ClimaAtmosSimulation, ::Val{:thermo_state_int}) = Spaces.level(sim.integrator.p.ᶜts, 1)
get_field(sim::ClimaAtmosSimulation, ::Val{:thermo_state_int}) = Spaces.level(sim.integrator.p.precomputed.ᶜts, 1)

# extensions required by FluxCalculator (partitioned fluxes)
get_field(sim::ClimaAtmosSimulation, ::Val{:height_int}) =
Expand All @@ -116,31 +117,33 @@ function get_field(sim::ClimaAtmosSimulation, ::Val{:uv_int})
uₕ_int = Geometry.UVVector.(Spaces.level(sim.integrator.u.c.uₕ, 1))
return @. StaticArrays.SVector(uₕ_int.components.data.:1, uₕ_int.components.data.:2)
end
get_field(sim::ClimaAtmosSimulation, ::Val{:air_density}) = TD.air_density.(thermo_params, sim.integrator.p.ᶜts)
get_field(sim::ClimaAtmosSimulation, ::Val{:air_temperature}) = TD.air_temperature.(thermo_params, sim.integrator.p.ᶜts)
get_field(sim::ClimaAtmosSimulation, ::Val{:cv_m}) = TD.cv_m.(thermo_params, sim.integrator.p.ᶜts)
get_field(sim::ClimaAtmosSimulation, ::Val{:air_density}) =
TD.air_density.(thermo_params, sim.integrator.p.precomputed.ᶜts)
get_field(sim::ClimaAtmosSimulation, ::Val{:air_temperature}) =
TD.air_temperature.(thermo_params, sim.integrator.p.precomputed.ᶜts)
get_field(sim::ClimaAtmosSimulation, ::Val{:cv_m}) = TD.cv_m.(thermo_params, sim.integrator.p.precomputed.ᶜts)
get_field(sim::ClimaAtmosSimulation, ::Val{:gas_constant_air}) =
TD.gas_constant_air.(thermo_params, sim.integrator.p.ᶜts)
TD.gas_constant_air.(thermo_params, sim.integrator.p.precomputed.ᶜts)

get_surface_params(sim::ClimaAtmosSimulation) = CAP.surface_fluxes_params(sim.integrator.p.params)

function update_field!(atmos_sim::ClimaAtmosSimulation, ::Val{:co2_gm}, field)
if atmos_sim.integrator.p.radiation_model.radiation_mode isa CA.RRTMGPI.GrayRadiation
if atmos_sim.integrator.p.atmos.radiation_mode isa CA.RRTMGPI.GrayRadiation
@warn("Gray radiation model initialized, skipping CO2 update", maxlog = 1)
return
else
atmos_sim.integrator.p.radiation_model.volume_mixing_ratio_co2 .= parent(field)[1]
atmos_sim.integrator.p.radiation.radiation_model.volume_mixing_ratio_co2 .= parent(field)[1]
end
end
# extensions required by the Interfacer
function update_field!(sim::ClimaAtmosSimulation, ::Val{:surface_temperature}, csf)
sim.integrator.p.radiation_model.surface_temperature .= CA.RRTMGPI.field2array(csf.T_S)
sim.integrator.p.radiation.radiation_model.surface_temperature .= CA.RRTMGPI.field2array(csf.T_S)
end

function update_field!(sim::ClimaAtmosSimulation, ::Val{:albedo}, field)
sim.integrator.p.radiation_model.diffuse_sw_surface_albedo .=
sim.integrator.p.radiation.radiation_model.diffuse_sw_surface_albedo .=
reshape(CA.RRTMGPI.field2array(field), 1, length(parent(field)))
sim.integrator.p.radiation_model.direct_sw_surface_albedo .=
sim.integrator.p.radiation.radiation_model.direct_sw_surface_albedo .=
reshape(CA.RRTMGPI.field2array(field), 1, length(parent(field)))
end

Expand All @@ -156,7 +159,7 @@ function update_field!(sim::ClimaAtmosSimulation, ::Val{:turbulent_fluxes}, fiel
vec_ct12_ct1 = @. CT12(CT2(unit_basis_vector_data(CT1, surface_local_geometry)), surface_local_geometry)
vec_ct12_ct2 = @. CT12(CT2(unit_basis_vector_data(CT2, surface_local_geometry)), surface_local_geometry)

sim.integrator.p.sfc_conditions.ρ_flux_uₕ .= (
sim.integrator.p.precomputed.sfc_conditions.ρ_flux_uₕ .= (
surface_normal .⊗
C12.(
swap_space!(ones(axes(vec_ct12_ct1)), F_turb_ρτxz) .* vec_ct12_ct1 .+
Expand All @@ -165,8 +168,9 @@ function update_field!(sim::ClimaAtmosSimulation, ::Val{:turbulent_fluxes}, fiel
)
)

parent(sim.integrator.p.sfc_conditions.ρ_flux_h_tot) .= parent(F_turb_energy) .* parent(surface_normal) # (shf + lhf)
parent(sim.integrator.p.sfc_conditions.ρ_flux_q_tot) .= parent(F_turb_moisture) .* parent(surface_normal) # (evap)
parent(sim.integrator.p.precomputed.sfc_conditions.ρ_flux_h_tot) .= parent(F_turb_energy) .* parent(surface_normal) # (shf + lhf)
parent(sim.integrator.p.precomputed.sfc_conditions.ρ_flux_q_tot) .=
parent(F_turb_moisture) .* parent(surface_normal) # (evap)

# TODO: see if Atmos can rever to a simpler solution
end
Expand Down Expand Up @@ -264,7 +268,7 @@ function atmos_turbulent_fluxes!(atmos_sim::ClimaAtmosSimulation, csf)
if isnothing(atmos_sim.integrator.p.sfc_setup) # trigger flux calculation if not done in Atmos internally
new_p = get_new_cache(atmos_sim, csf)
CA.SurfaceConditions.update_surface_conditions!(atmos_sim.integrator.u, new_p, atmos_sim.integrator.t)
atmos_sim.integrator.p.sfc_conditions .= new_p.sfc_conditions
atmos_sim.integrator.p.precomputed.sfc_conditions .= new_p.precomputed.sfc_conditions
end
end

Expand Down Expand Up @@ -302,7 +306,7 @@ Extension of Interfacer.get_field to get the net TOA radiation, which is a sum o
upward and downward longwave and shortwave radiation.
"""
function get_field(atmos_sim::ClimaAtmosSimulation, ::Val{:F_radiative_TOA})
radiation = atmos_sim.integrator.p.radiation_model
radiation = atmos_sim.integrator.p.radiation.radiation_model
FT = eltype(atmos_sim.integrator.u)
# save radiation source
if radiation != nothing
Expand All @@ -312,19 +316,19 @@ function get_field(atmos_sim::ClimaAtmosSimulation, ::Val{:F_radiative_TOA})
n_faces = length(z[:, 1, 1, 1, 1])

LWd_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_lw_flux_dn), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_lw_flux_dn), face_space),
n_faces - half,
)
LWu_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_lw_flux_up), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_lw_flux_up), face_space),
n_faces - half,
)
SWd_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_sw_flux_dn), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_sw_flux_dn), face_space),
n_faces - half,
)
SWu_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_sw_flux_up), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_sw_flux_up), face_space),
n_faces - half,
)

Expand Down
10 changes: 1 addition & 9 deletions experiments/AMIP/modular/components/land/bucket_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,9 @@ function bucket_init(
α_snow = FT(0.8) # snow albedo
if albedo_type == "map_static" # Read in albedo from static data file (default type)
# By default, this uses a file containing bareground albedo without a time component. Snow albedo is specified separately.
if ClimaComms.iamroot(comms_ctx)
albedo = BulkAlbedoStatic{FT}(regrid_dirpath, α_snow = α_snow, comms = comms_ctx)
end
ClimaComms.barrier(comms_ctx)
albedo = BulkAlbedoStatic{FT}(regrid_dirpath, α_snow = α_snow, comms = comms_ctx)
albedo = BulkAlbedoStatic{FT}(regrid_dirpath, comms_ctx, α_snow = α_snow)
elseif albedo_type == "map_temporal" # Read in albedo from data file containing data over time
# By default, this uses a file containing linearly-interpolated monthly data of total albedo, generated by CESM2's land model (CLM).
if ClimaComms.iamroot(comms_ctx)
albedo = BulkAlbedoTemporal{FT}(regrid_dirpath, date_ref, t_start, space)
end
ClimaComms.barrier(comms_ctx)
albedo = BulkAlbedoTemporal{FT}(regrid_dirpath, date_ref, t_start, space)
elseif albedo_type == "function" # Use prescribed function of lat/lon for surface albedo
function α_sfc(coordinate_point)
Expand Down
4 changes: 2 additions & 2 deletions experiments/AMIP/modular/coupler_driver_modular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ elseif turbulent_fluxes isa PartitionedStateFluxes
# TODO: this is hard coded and needs to be simplified (need CA modification)
new_p = get_new_cache(atmos_sim, cs.fields)
CA.SurfaceConditions.update_surface_conditions!(atmos_sim.integrator.u, new_p, atmos_sim.integrator.t) # sets T_sfc (but SF calculation not necessary - CA)
atmos_sim.integrator.p.sfc_conditions .= new_p.sfc_conditions
atmos_sim.integrator.p.precomputed.sfc_conditions .= new_p.precomputed.sfc_conditions
end

# 4) given the new sfc_conditions, atmos calls the radiative flux callback
Expand Down Expand Up @@ -649,7 +649,7 @@ function solve_coupler!(cs)
# update atmos sfc_conditions for surface temperature - TODO: this needs to be simplified (need CA modification)
new_p = get_new_cache(atmos_sim, cs.fields)
CA.SurfaceConditions.update_surface_conditions!(atmos_sim.integrator.u, new_p, atmos_sim.integrator.t) # to set T_sfc (but SF calculation not necessary - CA modification)
atmos_sim.integrator.p.sfc_conditions .= new_p.sfc_conditions
atmos_sim.integrator.p.precomputed.sfc_conditions .= new_p.precomputed.sfc_conditions
end

import_atmos_fields!(cs.fields, cs.model_sims, cs.boundary_space, turbulent_fluxes) # radiative and/or turbulent
Expand Down
18 changes: 10 additions & 8 deletions experiments/AMIP/modular/user_io/user_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Air temperature (K).
"""
function get_var(cs::CoupledSimulation, ::Val{:T})
p = cs.model_sims.atmos_sim.integrator.p
(; ᶜts, params) = p
(; ᶜts) = p.precomputed
(; params) = p
thermo_params = CAP.thermodynamics_params(params)
@. TD.air_temperature(thermo_params, ᶜts)
end
Expand Down Expand Up @@ -41,7 +42,8 @@ Cloud specific humidity (g kg⁻¹).
"""
function get_var(cs::CoupledSimulation, ::Val{:q_liq_ice})
p = cs.model_sims.atmos_sim.integrator.p
(; ᶜts, params) = p
(; ᶜts) = p.precomputed
(; params) = p
thermo_params = CAP.thermodynamics_params(params)
TD.liquid_specific_humidity.(thermo_params, ᶜts) .* float_type(cs)(1000)
end
Expand All @@ -59,19 +61,19 @@ function get_var(cs::CoupledSimulation, ::Val{:toa_fluxes})
n_faces = length(z[:, 1, 1, 1, 1])

LWd_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_lw_flux_dn), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_lw_flux_dn), face_space),
n_faces - half,
)
LWu_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_lw_flux_up), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_lw_flux_up), face_space),
n_faces - half,
)
SWd_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_sw_flux_dn), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_sw_flux_dn), face_space),
n_faces - half,
)
SWu_TOA = Fields.level(
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation_model.face_sw_flux_up), face_space),
CA.RRTMGPI.array2field(FT.(atmos_sim.integrator.p.radiation.radiation_model.face_sw_flux_up), face_space),
n_faces - half,
)

Expand All @@ -87,8 +89,8 @@ Precipitation rate (Kg m⁻² s⁻¹).
get_var(cs::CoupledSimulation, ::Val{:precipitation_rate}) =
.-swap_space!(
zeros(cs.boundary_space),
cs.model_sims.atmos_sim.integrator.p.col_integrated_rain .+
cs.model_sims.atmos_sim.integrator.p.col_integrated_snow,
cs.model_sims.atmos_sim.integrator.p.precipitation.col_integrated_rain .+
cs.model_sims.atmos_sim.integrator.p.precipitation.col_integrated_snow,
)

# coupler diagnotics
Expand Down
Loading
Loading