Skip to content

Compute surface_elevation through set! - #808

Open
dkytezab wants to merge 2 commits into
mainfrom
dkz/reactant-surface-elevation
Open

dkytezab wants to merge 2 commits into
mainfrom
dkz/reactant-surface-elevation

Conversation

@dkytezab

Copy link
Copy Markdown
Collaborator

Closes #806. Draft.

surface_elevation(grid::PressureLevelGrid) computes set!(elevation, Φˢᶠᶜ / g) instead of interior(elevation) .= interior(Φˢᶠᶜ) ./ g, which on ReactantState falls back to element-wise indexing of device memory. set! of an operation launches one kernel on the field's architecture, so the CPU and GPU paths stay kernel-based and the result matches the CPU exactly on ReactantState (the MWE in #806).

Test: test/test_pressure_level_grid.jl, the elevation of a surface rising from 100 to 400 m, on every test architecture. A ReactantState test needs the pressure-level vertical to reach the device, which waits on CliMA/Oceananigans.jl#6007. Not yet run locally.

🤖 Generated with Claude Code

Broadcasting between the `interior` views of the surface geopotential and the elevation indexes device
memory element by element on ReactantState, which Reactant refuses. `set!` of the operation `Φˢ / g`
computes it with a kernel on the field's architecture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...rc/Grids/pressure_level_vertical_discretization.jl 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dkytezab
dkytezab marked this pull request as ready for review October 23, 2026 20:43

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

surface_elevation fails on ReactantState: broadcast between interiors of device fields

2 participants