@@ -11,6 +11,7 @@ ClimaComms.@import_required_backends
11
11
using OrderedCollections
12
12
using StaticArrays, IntervalSets
13
13
import ClimaCore
14
+ import ClimaCore. InputOutput
14
15
import ClimaCore. Utilities: PlusHalf
15
16
import ClimaCore. DataLayouts
16
17
import ClimaCore. DataLayouts: IJFH
330
331
@test occursin (" ==================== Difference found:" , s)
331
332
end
332
333
334
+ @testset " FieldVector restart + broadcasting" begin
335
+ FT = Float32
336
+ root_path = " bucket_restart"
337
+ rm (root_path; force = true , recursive = true )
338
+ mkpath (root_path)
339
+
340
+ radius = FT (100 )
341
+ depth = FT (3.5 )
342
+ nelements = (1 , 10 )
343
+ npolynomial = 1
344
+ dz_tuple = nothing
345
+ context = ClimaComms. context ()
346
+
347
+ vertdomain = Domains. IntervalDomain (
348
+ Geometry. ZPoint (FT (- depth)),
349
+ Geometry. ZPoint (FT (0 ));
350
+ boundary_names = (:bottom , :top ),
351
+ )
352
+ vertmesh = Meshes. IntervalMesh (vertdomain; nelems = nelements[2 ])
353
+ device = ClimaComms. device ()
354
+ vert_center_space = Spaces. CenterFiniteDifferenceSpace (device, vertmesh)
355
+ horzdomain = Domains. SphereDomain (radius)
356
+ horzmesh = Meshes. EquiangularCubedSphere (horzdomain, nelements[1 ])
357
+ horztopology = Topologies. Topology2D (context, horzmesh)
358
+ quad = Spaces. Quadratures. GLL {npolynomial + 1} ()
359
+ space = Spaces. SpectralElementSpace2D (horztopology, quad)
360
+
361
+ vars = (;
362
+ bucket = (;
363
+ W = Fields. Field (FT, space),
364
+ T = Fields. Field (FT, space),
365
+ Ws = Fields. Field (FT, space),
366
+ σS = Fields. Field (FT, space),
367
+ )
368
+ )
369
+
370
+ Y = Fields. FieldVector (; vars... )
371
+ Y. bucket. T .= 280.0
372
+ Y. bucket. W .= 0.05
373
+ Y. bucket. Ws .= 0.0
374
+ Y. bucket. σS .= 0.08
375
+
376
+ output_file = joinpath (root_path, " day0.0.hdf5" )
377
+ hdfwriter = InputOutput. HDF5Writer (output_file, context)
378
+ InputOutput. write_attributes! (
379
+ hdfwriter,
380
+ " /" ,
381
+ Dict (" time" => 0.0 , " hash" => " 1234" ),
382
+ )
383
+ InputOutput. write! (hdfwriter, Y, " Y" )
384
+ Base. close (hdfwriter)
385
+
386
+ restart_file = output_file
387
+ Y_restart = Fields. FieldVector (; vars... )
388
+ hdfreader = InputOutput. HDF5Reader (restart_file, context)
389
+ Y_restart = InputOutput. read_field (hdfreader, " Y" )
390
+ close (hdfreader)
391
+ Y .= Y_restart
392
+
393
+ end
394
+
333
395
# https://github.com/CliMA/ClimaCore.jl/issues/1465
334
396
@testset " Diagonal FieldVector broadcast expressions" begin
335
397
FT = Float64
0 commit comments