Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we remove the space from InterpolationsRegridder? #113

Open
charleskawczynski opened this issue Oct 3, 2024 · 1 comment
Open

Can we remove the space from InterpolationsRegridder? #113

charleskawczynski opened this issue Oct 3, 2024 · 1 comment

Comments

@charleskawczynski
Copy link
Member

I'm seeing huge stack traces in https://buildkite.com/clima/climaland-long-runs/builds/1330#01925384-a92c-4f92-885e-69fe03731fc1. I think it's because there are a lot (~23) of InterpolationsRegridder objects (and therefore spaces) in a DataLayouts kernel, and this results in a massive method signature

@Sbozzolo
Copy link
Member

Sbozzolo commented Oct 3, 2024

Yes, I think that should be possible. The only place where it is not easy is where we determine the extrapolation boundary conditions automatically (at the constructor):

"""
InterpolationsRegridder(target_space::ClimaCore.Spaces.AbstractSpace
[; extrapolation_bc::Tuple])
An online regridder that uses Interpolations.jl
Currently, InterpolationsRegridder is only implemented for LatLong and LatLongZ spaces. It
performs linear interpolation along each of the directions (separately). By default, it
imposes periodic boundary conditions for longitude, flat for latitude, and throwing errors
when extrapolating in z. This can be customized by passing the `extrapolation_bc` keyword
argument.
InterpolationsRegridder is GPU and MPI compatible in the simplest possible way: each MPI
process has the entire input data and everything is copied to GPU.
Keyword arguments
=================
The optional keyword argument `extrapolation_bc` controls what should be done when the
interpolation point is not in the domain of definition. This has to be a tuple of N
elements, where N is the number of spatial dimensions. For 3D spaces, the default is
`(Interpolations.Periodic(), Interpolations.Flat(), Interpolations.Throw())`.
"""
function Regridders.InterpolationsRegridder(
target_space::ClimaCore.Spaces.AbstractSpace;
extrapolation_bc::Union{Nothing, Tuple} = nothing,
)
coordinates = ClimaCore.Fields.coordinate_field(target_space)
if isnothing(extrapolation_bc)
extrapolation_bc = ()
if eltype(coordinates) <: ClimaCore.Geometry.LatLongPoint
extrapolation_bc = (Intp.Periodic(), Intp.Flat())
elseif eltype(coordinates) <: ClimaCore.Geometry.LatLongZPoint
extrapolation_bc = (Intp.Periodic(), Intp.Flat(), Intp.Throw())
else
error("Only lat-long, lat-long-z spaces are supported")
end
end
return InterpolationsRegridder(target_space, coordinates, extrapolation_bc)
end

This would change a little bit the spirit of the regridder (the initial idea was to have a regridder attached to a specific variable and calling it multitple times would be cheap), but I don't see big problems with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants