From 7c2c0e7ea26a7ad32aa0253a12cdb3f6d85fc9df Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 25 Mar 2024 15:21:57 -0400 Subject: [PATCH] Allow interpolation on `Distributed` architectures (#3499) * bugfix * allow interpolation on Distributed --- src/Fields/interpolate.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Fields/interpolate.jl b/src/Fields/interpolate.jl index 67b828e975..05f62a1406 100644 --- a/src/Fields/interpolate.jl +++ b/src/Fields/interpolate.jl @@ -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) @@ -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))