Couple a compressible (terrain-following) Breeze atmosphere#350
Open
glwagner wants to merge 2 commits into
Open
Couple a compressible (terrain-following) Breeze atmosphere#350glwagner wants to merge 2 commits into
glwagner wants to merge 2 commits into
Conversation
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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AtmosphereOceanModelcould not couple aCompressibleDynamics(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:interpolate_state!readatmosphere.dynamics.reference_state.density/.surface_pressure. Compressible dynamics havereference_state === nothing, givingFieldError: type Nothing has no field density. Now falls back to the 3-Dterrain_reference_density(surface level[i,j,1]is exactly what the interpolationkernel indexes) and the scalar
surface_pressure.surface_layer_heightreads the lowest cell'szspacing, which indexes a devicearray on a terrain-following GPU grid →
Scalar indexing is disallowed. The singlescalar 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
SlabOceanfailed identically (so it was the atmosphere side).🤖 Generated with Claude Code