Skip to content

Couple a compressible (terrain-following) Breeze atmosphere#350

Open
glwagner wants to merge 2 commits into
mainfrom
glw/couple-compressible-atmosphere
Open

Couple a compressible (terrain-following) Breeze atmosphere#350
glwagner wants to merge 2 commits into
mainfrom
glw/couple-compressible-atmosphere

Conversation

@glwagner

Copy link
Copy Markdown
Member

Summary

AtmosphereOceanModel could not couple a CompressibleDynamics (terrain-following)
Breeze atmosphere — the air–sea coupler's Breeze interface assumed anelastic dynamics in
two spots and errored before the first step. Both are fixed in
ext/NumericalEarthBreezeExt/breeze_atmosphere_interface.jl:

  1. interpolate_state! read atmosphere.dynamics.reference_state.density /
    .surface_pressure. Compressible dynamics have reference_state === nothing, giving
    FieldError: type Nothing has no field density. Now falls back to the 3-D
    terrain_reference_density (surface level [i,j,1] is exactly what the interpolation
    kernel indexes) and the scalar surface_pressure.
  2. surface_layer_height reads the lowest cell's zspacing, which indexes a device
    array on a terrain-following GPU grid → Scalar indexing is disallowed. The single
    scalar read is now wrapped in @allowscalar (GPUArraysCore), as the prior comment hinted.

The anelastic path is unchanged (the new branch only triggers when reference_state === nothing).

Testing

Verified on an NVIDIA GH200: a terrain-following compressible Breeze atmosphere over real
fjord terrain (Nærøyfjord) coupled to a hydrostatic + CATKE immersed-boundary ocean now
steps stably, with air–sea sensible/latent/momentum fluxes computed at the interface and
the ocean responding to the coupled wind stress. Before this change both a full
hydrostatic ocean and a SlabOcean failed identically (so it was the atmosphere side).

🤖 Generated with Claude Code

The air–sea coupler's Breeze interface assumed anelastic dynamics in two places,
so an `AtmosphereOceanModel` built on a `CompressibleDynamics` atmosphere errored
before stepping:

1. `interpolate_state!` read `atmosphere.dynamics.reference_state.density` /
   `.surface_pressure`. Compressible dynamics have `reference_state === nothing`
   (→ `FieldError: type Nothing has no field density`). Fall back to the 3-D
   `terrain_reference_density` (its surface level `[i,j,1]` is what the interpolation
   kernel reads) and the scalar `surface_pressure`.

2. `surface_layer_height` reads the lowest cell's `zspacing`, which indexes a device
   array on a terrain-following GPU grid (→ "Scalar indexing is disallowed"). Wrap the
   single scalar read in `@allowscalar` (GPUArraysCore), as the existing comment hinted.

Verified on GPU (NVIDIA GH200): a terrain-following compressible atmosphere over real
fjord terrain coupled to a hydrostatic + CATKE immersed-boundary ocean now steps stably,
with air–sea fluxes computed at the interface. The anelastic path is unchanged.

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

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ricalEarthBreezeExt/breeze_atmosphere_interface.jl 71.42% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant