|
| 1 | +import ClimaCore: |
| 2 | + Domains, |
| 3 | + Meshes, |
| 4 | + Geometry, |
| 5 | + Grids, |
| 6 | + Spaces, |
| 7 | + Topologies, |
| 8 | + Hypsography, |
| 9 | + Fields, |
| 10 | + Operators, |
| 11 | + Utilities |
| 12 | +import ClimaComms |
| 13 | + |
| 14 | +ClimaComms.@import_required_backends |
| 15 | +device = ClimaComms.device() |
| 16 | +comms_ctx = ClimaComms.context(device) |
| 17 | + |
| 18 | +h_domain = Domains.RectangleDomain( |
| 19 | + Domains.IntervalDomain( |
| 20 | + Geometry.XPoint(0.0), |
| 21 | + Geometry.XPoint(1.0); |
| 22 | + periodic = true, |
| 23 | + ), |
| 24 | + Domains.IntervalDomain( |
| 25 | + Geometry.YPoint(0.0), |
| 26 | + Geometry.YPoint(1.0); |
| 27 | + periodic = true, |
| 28 | + ), |
| 29 | +) |
| 30 | +h_mesh = Meshes.RectilinearMesh(h_domain, 10, 10) |
| 31 | +h_grid = Spaces.grid( |
| 32 | + Spaces.SpectralElementSpace2D( |
| 33 | + Topologies.DistributedTopology2D( |
| 34 | + comms_ctx, |
| 35 | + h_mesh, |
| 36 | + Topologies.spacefillingcurve(h_mesh), |
| 37 | + ), |
| 38 | + Spaces.Quadratures.GLL{4}(), |
| 39 | + ), |
| 40 | +) |
| 41 | +z_domain = Domains.IntervalDomain( |
| 42 | + Geometry.ZPoint(0.0), |
| 43 | + Geometry.ZPoint(1.0); |
| 44 | + boundary_names = (:bottom, :top), |
| 45 | +) |
| 46 | +z_grid = Grids.FiniteDifferenceGrid( |
| 47 | + Topologies.IntervalTopology( |
| 48 | + comms_ctx, |
| 49 | + Meshes.IntervalMesh(z_domain, Meshes.Uniform(); nelems = 10), |
| 50 | + ), |
| 51 | +) |
| 52 | +grid = Grids.ExtrudedFiniteDifferenceGrid( |
| 53 | + h_grid, |
| 54 | + z_grid, |
| 55 | + Hypsography.Flat(); |
| 56 | + deep = false, |
| 57 | +) |
| 58 | +center_space = Spaces.CenterExtrudedFiniteDifferenceSpace(grid) |
| 59 | +face_space = Spaces.FaceExtrudedFiniteDifferenceSpace(grid) |
| 60 | + |
| 61 | +# Create fields and show that it fails |
| 62 | +ᶜgradᵥ = Operators.GradientF2C() |
| 63 | + |
| 64 | +level_field = Fields.level(Fields.Field(Float64, face_space), Utilities.half) |
| 65 | +ᶠscalar_field = Fields.Field(Float64, face_space) |
| 66 | +# Does not work: |
| 67 | +using Test |
| 68 | + |
| 69 | +@testset "Broken broadcast expression on GPUs" begin |
| 70 | + if device isa ClimaComms.CUDADevice |
| 71 | + @test_broken begin |
| 72 | + @. ᶜgradᵥ(level_field + ᶠscalar_field) |
| 73 | + end |
| 74 | + else |
| 75 | + @. ᶜgradᵥ(level_field + ᶠscalar_field) |
| 76 | + end |
| 77 | +end |
0 commit comments