Skip to content

Commit ba8e3ff

Browse files
Fix JET.test-call failure in get_boundary (#2142)
1 parent 32225d3 commit ba8e3ff

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/Operators/finitedifference.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,29 +185,30 @@ boundary_width(
185185
args...,
186186
) = invalid_boundary_condition_error(typeof(op), typeof(bc))
187187

188+
get_boundary(bcs::NamedTuple, name::Symbol) =
189+
hasfield(typeof(bcs), name) ? getfield(bcs, name) : NullBoundaryCondition()
190+
191+
get_boundary(bcs::@NamedTuple{}, name::Symbol) = NullBoundaryCondition()
192+
188193
get_boundary(
189194
op::FiniteDifferenceOperator,
190195
::LeftBoundaryWindow{name},
191-
) where {name} =
192-
hasproperty(op.bcs, name) ? getproperty(op.bcs, name) :
193-
NullBoundaryCondition()
196+
) where {name} = get_boundary(op.bcs, name)
194197

195198
get_boundary(
196199
op::FiniteDifferenceOperator,
197200
::RightBoundaryWindow{name},
198-
) where {name} =
199-
hasproperty(op.bcs, name) ? getproperty(op.bcs, name) :
200-
NullBoundaryCondition()
201+
) where {name} = get_boundary(op.bcs, name)
201202

202203
has_boundary(
203204
op::FiniteDifferenceOperator,
204205
::LeftBoundaryWindow{name},
205-
) where {name} = hasproperty(op.bcs, name)
206+
) where {name} = hasfield(typeof(op.bcs), name)
206207

207208
has_boundary(
208209
op::FiniteDifferenceOperator,
209210
::RightBoundaryWindow{name},
210-
) where {name} = hasproperty(op.bcs, name)
211+
) where {name} = hasfield(typeof(op.bcs), name)
211212

212213
strip_space(op::FiniteDifferenceOperator, parent_space) =
213214
unionall_type(typeof(op))(

test/Operators/finitedifference/opt_examples.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#=
2+
julia --project=.buildkite
3+
using Revise; include("test/Operators/finitedifference/opt_examples.jl")
4+
=#
15
import ClimaCore
26
using ClimaComms
37
ClimaComms.@import_required_backends
@@ -47,6 +51,14 @@ function alloc_test_f2c_interp(cfield, ffield)
4751
@test p == 0 broken = using_cuda
4852
end
4953

54+
function jet_test_f2c_interp2(cfield, ffield)
55+
(; fx, fy, fz, fϕ, fψ) = ffield
56+
(; cx, cy, cz, cϕ, cψ) = cfield
57+
Ic = Operators.InterpolateF2C()
58+
@. cz = cx * cy * Ic(fy) * Ic(fx) **
59+
return nothing
60+
end
61+
5062
function alloc_test_c2f_interp(cfield, ffield, If)
5163
(;fx,fy,fz,fϕ,fψ) = ffield
5264
(;cx,cy,cz,cϕ,cψ) = cfield
@@ -468,6 +480,9 @@ end
468480
wvec_glob = Geometry.WVector
469481

470482
alloc_test_f2c_interp(cfield, ffield)
483+
if !(ClimaComms.device(ffield) isa ClimaComms.CUDADevice)
484+
JET.@test_call jet_test_f2c_interp2(cfield, ffield)
485+
end
471486

472487
alloc_test_c2f_interp(
473488
cfield,

0 commit comments

Comments
 (0)