Skip to content

Commit ccc3115

Browse files
authored
Merge pull request #1207 from CliMA/js/context
uniformly use `context` throughout ClimaLand
2 parents 15278a8 + 5439380 commit ccc3115

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ClimaLand.jl Release Notes
33

44
main
55
-------
6+
- ![breaking change][badge-💥breaking] Rename all `comms_ctx` to `context` PR[#1207](https://github.com/CliMA/ClimaLand.jl/pull/1207)
67
- Output NaNs in diagnostics where the ocean is PR[#1200](https://github.com/CliMA/ClimaLand.jl/pull/1200)
78
- ![breaking change][badge-💥breaking] Make soil albedo parameterization modular
89
PR[#1184](https://github.com/CliMA/ClimaLand.jl/pull/1184)

experiments/long_runs/bucket.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function setup_simulation(; greet = false)
109109
dz_tuple = FT.((1.0, 0.05))
110110
domain = ClimaLand.ModelSetup.global_domain(
111111
FT;
112-
comms_ctx = context,
112+
context,
113113
nelements,
114114
depth,
115115
dz_tuple,

experiments/long_runs/snowy_land.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function setup_model(FT, start_date, stop_date, Δt, domain, earth_param_set)
158158
SAI = FT(0.0) # m2/m2
159159
f_root_to_shoot = FT(3.5)
160160
RAI = FT(1.0)
161-
K_sat_plant = FT(7e-8) # m/s
161+
K_sat_plant = FT(7e-8) # m/s
162162
ψ63 = FT(-4 / 0.0098) # / MPa to m
163163
Weibull_param = FT(4) # unitless
164164
a = FT(0.2 * 0.0098) # 1/m
@@ -354,8 +354,7 @@ function setup_simulation(; greet = false)
354354
@info "Stop Date: $stop_date"
355355
end
356356

357-
domain =
358-
ClimaLand.ModelSetup.global_domain(FT; comms_ctx = context, nelements)
357+
domain = ClimaLand.ModelSetup.global_domain(FT; context, nelements)
359358
params = LP.LandParameters(FT)
360359
model = setup_model(FT, start_date, stop_date, Δt, domain, params)
361360

experiments/long_runs/soil.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ function setup_simulation(; greet = false)
166166
@info "Start Date: $start_date"
167167
@info "Stop Date: $stop_date"
168168
end
169-
domain =
170-
ClimaLand.ModelSetup.global_domain(FT; comms_ctx = context, nelements)
169+
domain = ClimaLand.ModelSetup.global_domain(FT; context, nelements)
171170
params = LP.LandParameters(FT)
172171
model = setup_model(FT, start_date, stop_date, domain, params)
173172
diagnostics = ClimaLand.default_diagnostics(

src/shared_utilities/Domains.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ end
232232
periodic::Tuple{Bool,Bool},
233233
npolynomial::Int,
234234
longlat = nothing,
235-
comms_ctx = ClimaComms.context(),
235+
context = ClimaComms.context(),
236236
radius_earth = FT(6.378e6)
237237
) where {FT}
238238
@@ -255,7 +255,7 @@ function Plane(;
255255
periodic::Tuple{Bool, Bool} = isnothing(longlat) ? (true, true) :
256256
(false, false),
257257
npolynomial::Int = 0,
258-
comms_ctx = ClimaComms.context(),
258+
context = ClimaComms.context(),
259259
radius_earth = 6.378e6,
260260
) where {FT}
261261
if isnothing(longlat)
@@ -306,7 +306,7 @@ function Plane(;
306306
plane = ClimaCore.Domains.RectangleDomain(domain_x, domain_y)
307307

308308
mesh = ClimaCore.Meshes.RectilinearMesh(plane, nelements[1], nelements[2])
309-
grid_topology = ClimaCore.Topologies.Topology2D(comms_ctx, mesh)
309+
grid_topology = ClimaCore.Topologies.Topology2D(context, mesh)
310310
if npolynomial == 0
311311
quad = ClimaCore.Spaces.Quadratures.GL{npolynomial + 1}()
312312
else
@@ -540,7 +540,7 @@ end
540540
nelements::Tuple{Int, Int},
541541
npolynomial::Int,
542542
dz_tuple::Union{Tuple{FT, FT}, Nothing} = nothing,
543-
comms_ctx = ClimaComms.context(),
543+
context = ClimaComms.context(),
544544
) where {FT}
545545
Outer constructor for the `SphericalShell` domain, using keyword arguments.
546546
@@ -558,7 +558,7 @@ function SphericalShell(;
558558
nelements::Tuple{Int, Int},
559559
npolynomial::Int = 0,
560560
dz_tuple::Union{Tuple{FT, FT}, Nothing} = nothing,
561-
comms_ctx = ClimaComms.context(),
561+
context = ClimaComms.context(),
562562
) where {FT}
563563
@assert 0 < radius
564564
@assert 0 < depth
@@ -587,7 +587,7 @@ function SphericalShell(;
587587

588588
horzdomain = ClimaCore.Domains.SphereDomain(radius)
589589
horzmesh = ClimaCore.Meshes.EquiangularCubedSphere(horzdomain, nelements[1])
590-
horztopology = ClimaCore.Topologies.Topology2D(comms_ctx, horzmesh)
590+
horztopology = ClimaCore.Topologies.Topology2D(context, horzmesh)
591591
if npolynomial == 0
592592
quad = ClimaCore.Spaces.Quadratures.GL{npolynomial + 1}()
593593
else
@@ -653,20 +653,20 @@ end
653653
radius::FT,
654654
nelements::Int
655655
npolynomial::Int,
656-
comms_ctx = ClimaComms.context(),
656+
context = ClimaComms.context(),
657657
) where {FT}
658658
Outer constructor for the `SphericalSurface` domain, using keyword arguments.
659659
"""
660660
function SphericalSurface(;
661661
radius::FT,
662662
nelements::Int,
663663
npolynomial::Int = 0,
664-
comms_ctx = ClimaComms.context(),
664+
context = ClimaComms.context(),
665665
) where {FT}
666666
@assert 0 < radius
667667
horzdomain = ClimaCore.Domains.SphereDomain(radius)
668668
horzmesh = Meshes.EquiangularCubedSphere(horzdomain, nelements)
669-
horztopology = Topologies.Topology2D(comms_ctx, horzmesh)
669+
horztopology = Topologies.Topology2D(context, horzmesh)
670670
if npolynomial == 0
671671
quad = ClimaCore.Spaces.Quadratures.GL{npolynomial + 1}()
672672
else

src/shared_utilities/checkpoints.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function _context_from_Y(Y)
8989
end
9090

9191
"""
92-
ClimaLand.save_checkpoint(Y, t, output_dir; model = nothing, comms_ctx = ClimaComms.context(Y))
92+
ClimaLand.save_checkpoint(Y, t, output_dir; model = nothing, context = ClimaComms.context(Y))
9393
9494
Save a simulation checkpoint to an HDF5 file.
9595
@@ -104,21 +104,20 @@ specified output directory.
104104
- `model` (Optional): The ClimaLand model object. If provided the hash of the model
105105
will be stored in the checkpoint file. Defaults to `nothing`. This is used
106106
to check for consistency.
107-
- `comms_ctx` (Optional): The ClimaComms context. This is used for distributed I/O
107+
- `context` (Optional): The ClimaComms context. This is used for distributed I/O
108108
operations. Defaults to the context extracted from the state vector `Y` or the `model`.
109109
"""
110110
function save_checkpoint(
111111
Y,
112112
t,
113113
output_dir;
114114
model = nothing,
115-
comms_ctx = isnothing(model) ? _context_from_Y(Y) :
116-
ClimaComms.context(model),
115+
context = isnothing(model) ? _context_from_Y(Y) : ClimaComms.context(model),
117116
)
118117
day = floor(Int, t / (60 * 60 * 24))
119118
sec = floor(Int, t % (60 * 60 * 24))
120119
output_file = joinpath(output_dir, "day$day.$sec.hdf5")
121-
hdfwriter = InputOutput.HDF5Writer(output_file, comms_ctx)
120+
hdfwriter = InputOutput.HDF5Writer(output_file, context)
122121
# If model was passed, add its hash, otherwise add nothing
123122
hash_model = isnothing(model) ? "nothing" : hash(model)
124123
InputOutput.write_attributes!(

src/simulations/domains.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ discretization, which is correlated to the spatial resolution of the domain.
1717
When `npolynomial` is zero, the element is equivalent to a single point. In this
1818
case, the resolution of the model is sqrt((360*180)/(101*101*6)). The factor of 6 arises
1919
because there are 101x101 elements per side of the cubed sphere, meaning 6*101*101 for the
20-
entire globe.
20+
entire globe.
2121
2222
When `npolynomial` is greater than 1, a Gauss-Legendre-Lobotto quadrature is
2323
used, with `npolynomial + 1` points along the element. In this case, there are
@@ -36,7 +36,7 @@ function global_domain(
3636
dz_tuple = (10.0, 0.05),
3737
depth = 50.0,
3838
npolynomial = 0,
39-
comms_ctx = ClimaComms.context(),
39+
context = ClimaComms.context(),
4040
)
4141
if pkgversion(ClimaCore) < v"0.14.30" && apply_mask
4242
@warn "The land mask cannot be applied with ClimaCore < v0.14.30. Update ClimaCore for significant performance gains."
@@ -52,7 +52,7 @@ function global_domain(
5252
nelements,
5353
npolynomial,
5454
dz_tuple,
55-
comms_ctx,
55+
context,
5656
)
5757
if apply_mask
5858
surface_space = domain.space.surface # 2d space

0 commit comments

Comments
 (0)