Skip to content

Commit 78ddd14

Browse files
authored
Merge pull request #1195 from CliMA/js/cleanup
various cleanup
2 parents 0a139ff + 0a02579 commit 78ddd14

22 files changed

+93
-100
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ ClimaCoupler.jl Release Notes
66

77
### ClimaCoupler features
88

9+
### Coupler fields surface variable names all use `_sfc` PR[#1195](https://github.com/CliMA/ClimaCoupler.jl/pull/1195)
10+
`T_S`, `z0m_S`, and `z0b_S` are renamed to `T_sfc`, `z0m_sfc`, and `z0b_sfc`.
11+
This makes them consistent with the other surface fields, e.g. `ρ_sfc` and `q_sfc`.
12+
913
#### Driver function `setup_and_run` added PR[#1178](https://github.com/CliMA/ClimaCoupler.jl/pull/1178)
1014
A new function `setup_and_run` is added, which takes in a path to a config file,
1115
and contains all the code to initialize component models and run the simulation.

docs/src/interfacer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ following properties:
106106
| `surface_temperature` | temperature over the combined surface space | K |
107107
| `turbulent_fluxes` | turbulent fluxes (note: only required when using `PartitionedStateFluxes` option - see our `FluxCalculator` module docs for more information) | W m^-2 |
108108

109-
- `calculate_surface_air_density(atmos_sim::Interfacer.AtmosModelSimulation, T_S::ClimaCore.Fields.Field)`:
109+
- `calculate_surface_air_density(atmos_sim::Interfacer.AtmosModelSimulation, T_sfc::ClimaCore.Fields.Field)`:
110110
A function to return the air density of the atmosphere simulation
111111
extrapolated to the surface, with units of [kg m^-3].
112112

experiments/ClimaEarth/components/atmosphere/climaatmos.jl

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ include("climaatmos_extra_diags.jl")
1616
###
1717
### Functions required by ClimaCoupler.jl for an AtmosModelSimulation
1818
###
19-
struct ClimaAtmosSimulation{P, Y, D, I} <: Interfacer.AtmosModelSimulation
19+
struct ClimaAtmosSimulation{P, D, I} <: Interfacer.AtmosModelSimulation
2020
params::P
21-
Y_init::Y
2221
domain::D
2322
integrator::I
2423
end
@@ -69,7 +68,7 @@ function ClimaAtmosSimulation(atmos_config)
6968
@. ᶠradiation_flux = CC.Geometry.WVector(FT(0))
7069
end
7170

72-
sim = ClimaAtmosSimulation(integrator.p.params, Y, spaces, integrator)
71+
sim = ClimaAtmosSimulation(integrator.p.params, spaces, integrator)
7372

7473
# DSS state to ensure we have continuous fields
7574
dss_state!(sim)
@@ -191,7 +190,7 @@ function Interfacer.update_field!(sim::ClimaAtmosSimulation, ::Val{:surface_temp
191190
# note that this field is also being updated internally by the surface thermo state in ClimaAtmos
192191
# if turbulent fluxes are calculated, to ensure consistency. In case the turbulent fluxes are not
193192
# calculated, we update the field here.
194-
sim.integrator.p.radiation.rrtmgp_model.surface_temperature .= CC.Fields.field2array(csf.T_S)
193+
sim.integrator.p.radiation.rrtmgp_model.surface_temperature .= CC.Fields.field2array(csf.T_sfc)
195194
end
196195
# extensions required by FluxCalculator (partitioned fluxes)
197196
Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:height_int}) =
@@ -259,31 +258,28 @@ function FieldExchanger.update_sim!(atmos_sim::ClimaAtmosSimulation, csf, turbul
259258
p = atmos_sim.integrator.p
260259
t = atmos_sim.integrator.t
261260

262-
!isempty(atmos_sim.integrator.p.radiation) &&
263-
!(p.atmos.insolation isa CA.IdealizedInsolation) &&
264-
CA.set_insolation_variables!(u, p, t, p.atmos.insolation)
265-
261+
# Perform radiation-specific updates
266262
if hasradiation(atmos_sim.integrator)
263+
!(p.atmos.insolation isa CA.IdealizedInsolation) && CA.set_insolation_variables!(u, p, t, p.atmos.insolation)
267264
Interfacer.update_field!(atmos_sim, Val(:surface_direct_albedo), csf.surface_direct_albedo)
268265
Interfacer.update_field!(atmos_sim, Val(:surface_diffuse_albedo), csf.surface_diffuse_albedo)
266+
Interfacer.update_field!(atmos_sim, Val(:surface_temperature), csf)
269267
end
270268

271-
!isempty(atmos_sim.integrator.p.radiation) && Interfacer.update_field!(atmos_sim, Val(:surface_temperature), csf)
272-
273269
if turbulent_fluxes isa FluxCalculator.PartitionedStateFluxes
274270
Interfacer.update_field!(atmos_sim, Val(:turbulent_fluxes), csf)
275271
end
276272
end
277273

278274
"""
279-
FluxCalculator.calculate_surface_air_density(atmos_sim::ClimaAtmosSimulation, T_S::CC.Fields.Field)
275+
FluxCalculator.calculate_surface_air_density(atmos_sim::ClimaAtmosSimulation, T_sfc::CC.Fields.Field)
280276
281277
Extension for this function to calculate surface density.
282278
"""
283-
function FluxCalculator.calculate_surface_air_density(atmos_sim::ClimaAtmosSimulation, T_S::CC.Fields.Field)
279+
function FluxCalculator.calculate_surface_air_density(atmos_sim::ClimaAtmosSimulation, T_sfc::CC.Fields.Field)
284280
thermo_params = get_thermo_params(atmos_sim)
285281
ts_int = Interfacer.get_field(atmos_sim, Val(:thermo_state_int))
286-
FluxCalculator.extrapolate_ρ_to_sfc.(Ref(thermo_params), ts_int, Utilities.swap_space!(axes(ts_int.ρ), T_S))
282+
FluxCalculator.extrapolate_ρ_to_sfc.(Ref(thermo_params), ts_int, Utilities.swap_space!(axes(ts_int.ρ), T_sfc))
287283
end
288284

289285
# FluxCalculator.get_surface_params required by FluxCalculator (partitioned fluxes)
@@ -416,9 +412,9 @@ Returns a new `p` with the updated surface conditions.
416412
"""
417413
function get_new_cache(atmos_sim::ClimaAtmosSimulation, csf)
418414
if hasmoisture(atmos_sim.integrator)
419-
csf_sfc = (csf.T_S, csf.z0m_S, csf.z0b_S, csf.beta, csf.q_sfc)
415+
csf_sfc = (csf.T_sfc, csf.z0m_sfc, csf.z0b_sfc, csf.beta, csf.q_sfc)
420416
else
421-
csf_sfc = (csf.T_S, csf.z0m_S, csf.z0b_S, csf.beta)
417+
csf_sfc = (csf.T_sfc, csf.z0m_sfc, csf.z0b_sfc, csf.beta)
422418
end
423419

424420
p = atmos_sim.integrator.p
@@ -442,8 +438,8 @@ trigger flux calculation during Atmos `Interfacer.step!`. We only want to trigge
442438
timestep from ClimaCoupler.
443439
444440
For debigging atmos, we can set the following atmos defaults:
445-
csf.z0m_S .= 1.0e-5
446-
csf.z0b_S .= 1.0e-5
441+
csf.z0m_sfc .= 1.0e-5
442+
csf.z0b_sfc .= 1.0e-5
447443
csf.beta .= 1
448444
csf = merge(csf, (;q_sfc = nothing))
449445
"""

experiments/ClimaEarth/components/land/climaland_bucket.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ using NCDatasets
1515
### Functions required by ClimaCoupler.jl for a SurfaceModelSimulation
1616
###
1717
"""
18-
BucketSimulation{M, Y, D, I}
18+
BucketSimulation{M, D, I}
1919
2020
The bucket model simulation object.
2121
"""
22-
struct BucketSimulation{M, Y, D, I, A} <: Interfacer.LandModelSimulation
22+
struct BucketSimulation{M, D, I, A} <: Interfacer.LandModelSimulation
2323
model::M
24-
Y_init::Y
2524
domain::D
2625
integrator::I
2726
area_fraction::A
@@ -222,7 +221,7 @@ function BucketSimulation(
222221
callback = SciMLBase.CallbackSet(diag_cb),
223222
)
224223

225-
sim = BucketSimulation(model, Y, (; domain = domain, soil_depth = d_soil), integrator, area_fraction)
224+
sim = BucketSimulation(model, (; domain = domain, soil_depth = d_soil), integrator, area_fraction)
226225

227226
# DSS state to ensure we have continuous fields
228227
dss_state!(sim)

experiments/ClimaEarth/components/ocean/eisenman_seaice.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer, Utilities
77
### Functions required by ClimaCoupler.jl for a SurfaceModelSimulation
88
###
99
"""
10-
EisenmanIceSimulation{P, Y, D, I}
10+
EisenmanIceSimulation{P, D, I}
1111
1212
Thermodynamic 0-layer, based on the Semtner 1976 model and later refined by
1313
Eisenmen 2009 and Zhang et al 2021.
1414
1515
Note that Eisenman sea ice assumes gray radiation, no snow coverage, and
1616
PartitionedStateFluxes for the surface flux calculation.
1717
"""
18-
struct EisenmanIceSimulation{P, Y, D, I} <: Interfacer.SeaIceModelSimulation
18+
struct EisenmanIceSimulation{P, D, I} <: Interfacer.SeaIceModelSimulation
1919
params_ice::P
20-
Y_init::Y
2120
domain::D
2221
integrator::I
2322
end
@@ -83,7 +82,7 @@ function EisenmanIceSimulation(
8382
problem = SciMLBase.ODEProblem(ode_function, Y, Float64.(tspan), cache)
8483
integrator = SciMLBase.init(problem, ode_algo, dt = Float64(dt), saveat = Float64.(saveat), adaptive = false)
8584

86-
sim = EisenmanIceSimulation(params, Y, space, integrator)
85+
sim = EisenmanIceSimulation(params, space, integrator)
8786
return sim
8887
end
8988

experiments/ClimaEarth/components/ocean/prescr_seaice.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer, Utilities
1111
### Functions required by ClimaCoupler.jl for a SurfaceModelSimulation
1212
###
1313
"""
14-
PrescribedIceSimulation{P, Y, D, I}
14+
PrescribedIceSimulation{P, D, I}
1515
1616
Ice concentration is prescribed, and we solve the following energy equation:
1717
@@ -27,9 +27,8 @@ Ice concentration is prescribed, and we solve the following energy equation:
2727
2828
In the current version, the sea ice has a prescribed thickness.
2929
"""
30-
struct PrescribedIceSimulation{P, Y, D, I} <: Interfacer.SeaIceModelSimulation
30+
struct PrescribedIceSimulation{P, D, I} <: Interfacer.SeaIceModelSimulation
3131
params::P
32-
Y_init::Y
3332
domain::D
3433
integrator::I
3534
end
@@ -143,7 +142,7 @@ function PrescribedIceSimulation(
143142
problem = SciMLBase.ODEProblem(ode_function, Y, Float64.(tspan), (; cache..., params = params))
144143
integrator = SciMLBase.init(problem, ode_algo, dt = Float64(dt), saveat = Float64.(saveat), adaptive = false)
145144

146-
sim = PrescribedIceSimulation(params, Y, space, integrator)
145+
sim = PrescribedIceSimulation(params, space, integrator)
147146

148147
# DSS state to ensure we have continuous fields
149148
dss_state!(sim)

experiments/ClimaEarth/components/ocean/slab_ocean.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import ClimaCoupler: Checkpointer, FluxCalculator, Interfacer, Utilities
77
### Functions required by ClimaCoupler.jl for a SurfaceModelSimulation
88
###
99
"""
10-
SlabOceanSimulation{P, Y, D, I}
10+
SlabOceanSimulation{P, D, I}
1111
1212
Equation:
1313
1414
(h * ρ * c) dTdt = -(F_turb_energy + F_radiative)
1515
1616
"""
17-
struct SlabOceanSimulation{P, Y, D, I} <: Interfacer.OceanModelSimulation
17+
struct SlabOceanSimulation{P, D, I} <: Interfacer.OceanModelSimulation
1818
params::P
19-
Y_init::Y
2019
domain::D
2120
integrator::I
2221
end
@@ -96,7 +95,7 @@ function SlabOceanSimulation(
9695
problem = SciMLBase.ODEProblem(ode_function, Y, Float64.(tspan), cache)
9796
integrator = SciMLBase.init(problem, ode_algo, dt = Float64(dt), saveat = Float64.(saveat), adaptive = false)
9897

99-
sim = SlabOceanSimulation(params, Y, space, integrator)
98+
sim = SlabOceanSimulation(params, space, integrator)
10099

101100
# DSS state to ensure we have continuous fields
102101
dss_state!(sim)

experiments/ClimaEarth/run_cloudless_aquaplanet.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ ocean_sim = SlabOceanSimulation(
173173

174174
## coupler exchange fields
175175
coupler_field_names = (
176-
:T_S,
177-
:z0m_S,
178-
:z0b_S,
176+
:T_sfc,
177+
:z0m_sfc,
178+
:z0b_sfc,
179179
:ρ_sfc,
180180
:q_sfc,
181181
:surface_direct_albedo,

experiments/ClimaEarth/run_cloudy_aquaplanet.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ ocean_sim = SlabOceanSimulation(
196196

197197
## coupler exchange fields
198198
coupler_field_names = (
199-
:T_S,
200-
:z0m_S,
201-
:z0b_S,
199+
:T_sfc,
200+
:z0m_sfc,
201+
:z0b_sfc,
202202
:ρ_sfc,
203203
:q_sfc,
204204
:surface_direct_albedo,

experiments/ClimaEarth/run_cloudy_slabplanet.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ ocean_sim = SlabOceanSimulation(
240240

241241
## coupler exchange fields
242242
coupler_field_names = (
243-
:T_S,
244-
:z0m_S,
245-
:z0b_S,
243+
:T_sfc,
244+
:z0m_sfc,
245+
:z0b_sfc,
246246
:ρ_sfc,
247247
:q_sfc,
248248
:surface_direct_albedo,

0 commit comments

Comments
 (0)