Skip to content

Fix scalar assignment from a 2D divergence - #70

Open
certik wants to merge 2 commits into
BerkeleyLab:mainfrom
certik:fix/scalar-divergence-assignment-20261017
Open

certik wants to merge 2 commits into
BerkeleyLab:mainfrom
certik:fix/scalar-divergence-assignment-20261017

Conversation

@certik

@certik certik commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix assignment from an interior-only divergence_2D_t to an extended-grid scalar_2D_t: copy the complete interior, zero all four boundaries, and initialize the gradient operators from the copied metadata. The previous RHS-relative slicing lost interior values and left subsequent .grad. operations without initialized operators.

Register test/divergence_assignment_2D_test_m.F90 in test/driver.f90. It checks nonsquare grids, orders 2 and 4, interior values, all boundaries, repeated assignment, and gradients against separately constructed expected scalars.

Expected scalars use explicit procedure pointers to pure module initializers, matching the existing constructor interface and avoiding executable-stack callbacks on macOS. Every numerical assertion and tolerance is unchanged.

Correctness only: preserve upstream precision; no native, performance, GPU, or CI changes.

Verification

Compared base d28eee9b37b4b74abe7f21bb2ccbdfb5c17f3e8a with this branch on macOS ARM using isolated FPM 0.13 builds and saved logs. The test-only portability follow-up was rebuilt and rerun; no compiler rebuild was performed.

  • Regression added to the base: SIGSEGV with both GFortran 16.2 and LFortran.
  • Fixed LFortran full suite: 32/32 passed, including the regression.
  • Local Flang 24 development full suite: 32/32 passed. This is supplemental coverage, not local parity with CI's Flang 19–23 versions.
  • Fixed regression: 1/1 passed with LFortran, GFortran 16.2, and Flang 24.
  • GFortran full suite: 31/32 on the fix versus 30/31 on the untouched base. Both fail the same pre-existing vector_3D_t dot-product test.

Runs used fpm test --target driver for the full suite and added -- --contains 'The scalar_2D_t divergence assignment' for the regression. LFortran used --cpp --realloc-lhs-arrays --separate-compilation with the existing LLVM 11.1.0 compiler build; its stale configure-time version string is not a current commit identifier.

The initial Flang constructor errors were reproduced locally before the follow-up. The pointer-only intermediate fix exposed a macOS stack-trampoline fault, so the final test uses module callbacks instead of a host-associated internal procedure; the library API and numerical fix are untouched.

The follow-up Build run, on 363f8999e7c4575d8926c669fbb2ce8eab7cea06, passes all ten Flang 19–23/latest checks, including both macOS jobs, and all five Linux LFortran checks.

Only the two macOS LFortran jobs remain blocked by the same source-independent packaging failure: the Homebrew LFortran 0.67.0_1 bottles abort at lfortran --version, requiring libz3.5.1.dylib while Z3 5.3.1 is installed. Neither job reaches compilation. No dependency, workflow, compiler-version, or check-skipping workaround is included.

CI is 15/17 compiler jobs passing, not fully green. A failed-job retry was requested, but GitHub denied it because repository admin rights are required; no retry ran. These external packaging failures are documented without expanding this correctness-only PR. The numerical fix and portable regression are ready for review.

(cherry picked from commit 44976dc)
Pass explicit procedure pointers to the existing scalar constructors. Use pure module procedures for expected fields so Flang on macOS does not require executable-stack trampolines for a host-associated callback. Preserve the zero-boundary oracle and all numerical assertions.
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