Skip to content

Commit

Permalink
Allow interpolation on Distributed architectures (#3499)
Browse files Browse the repository at this point in the history
* bugfix

* allow interpolation on Distributed
  • Loading branch information
simone-silvestri committed Mar 25, 2024
1 parent 0f005a8 commit 7c2c0e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Fields/interpolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ using Oceananigans.Grids: topology, node,
ZRegOrthogonalSphericalShellGrid,
RectilinearGrid, LatitudeLongitudeGrid

using Oceananigans.Architectures: child_architecture

# GPU-compatile middle point calculation
@inline middle_point(l, h) = Base.unsafe_trunc(Int, (l + h) / 2)

Expand Down Expand Up @@ -313,6 +315,12 @@ function interpolate!(to_field::Field, from_field::AbstractField)

to_arch = architecture(to_field)
from_arch = architecture(from_field)

# In case architectures are `Distributed` we
# verify that the fields are on the same child architecture
to_arch = child_architecture(to_arch)
from_arch = child_architecture(from_arch)

if !isnothing(from_arch) && to_arch != from_arch
msg = "Cannot interpolate! because from_field is on $from_arch while to_field is on $to_arch."
throw(ArgumentError(msg))
Expand Down

0 comments on commit 7c2c0e7

Please sign in to comment.