Skip to content

WENO/MUSCL case guard w/ recon_type number + Inlining typo causing segmentation faults on compilation#1379

Open
Cowsreal wants to merge 8 commits intoMFlowCode:masterfrom
Cowsreal:minorChanges
Open

WENO/MUSCL case guard w/ recon_type number + Inlining typo causing segmentation faults on compilation#1379
Cowsreal wants to merge 8 commits intoMFlowCode:masterfrom
Cowsreal:minorChanges

Conversation

@Cowsreal
Copy link
Copy Markdown
Contributor

@Cowsreal Cowsreal commented Apr 23, 2026

Description

  1. I ran a whole batch of cases with WENO parameters set while recon_type = 2 was also set. There is no case guard, so this resulted in a MUSCL order 0 simulation being ran, where the toolchain should have warned the user.

  2. I kept running into segmentation faults with phase_change.fpp while trying to compile using OpenMP + CCE 19 on Frontier. The phase change module extensively uses the $:GPU_ROUTINE macro, specifically, the cray_noinline option. It's currently doing nothing when it evaluates the _CRAYFTN branch. I was able to compile after fixing this typo inside the parallel_macros.fpp.

Type of change

  • Bug fix

AI code reviews

Reviews are not triggered automatically. To request a review, comment on the PR:

  • @coderabbitai review — incremental review (new changes only)
  • @coderabbitai full review — full review from scratch
  • /review — Qodo review
  • /improve — Qodo code suggestions
  • @claude full review — Claude full review (also triggers on PR open/reopen/ready)
  • Add label claude-full-review — Claude full review via label

@Cowsreal
Copy link
Copy Markdown
Contributor Author

@claude full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

The pull request restricts emission of Cray-specific directives in src/common/include/parallel\_macros.fpp so !DIR$ NOINLINE and !DIR$ INLINEALWAYS are emitted only when _CRAYFTN is defined. toolchain/mfc/case_validator.py tightens validation: WENO reconstruction (recon_type = 1) now errors if MUSCL parameters are set, MUSCL (recon_type = 2) errors on WENO flags/parameters or nonzero weno_order, and WENO simulation checks return early unless recon_type == 1. toolchain/mfc/test/case.py filters out None values from merged test configs before calling the superclass, and toolchain/mfc/test/cases.py sets optional WENO parameters to None for MUSCL test generation.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers both main issues (case guard and inlining typo) with clear context, but the Type of change checkbox is not properly checked and the Checklist section is entirely missing. Complete the Type of change section by checking the 'Bug fix' checkbox and add the Checklist section with relevant items completed or addressed.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the two main changes: adding a WENO/MUSCL case guard and fixing an inlining typo causing segmentation faults.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
toolchain/mfc/case_validator.py (1)

128-137: Optionally update PHYSICS_DOCS entries to document the new cross-compatibility rules.

The contributing guide states that PHYSICS_DOCS feeds auto-generated physics-constraints docs. The new rules ("recon_type = 1 rejects MUSCL params" / "recon_type = 2 rejects WENO params and requires weno_order unset or 0") aren't reflected in the explanations for check_weno / check_muscl. Consider appending a sentence to each so the auto-generated docs stay in sync.

📝 Suggested doc additions
     "check_weno": {
         "title": "WENO Reconstruction",
         "category": "Numerical Schemes",
-        "explanation": ("weno_order must be 1, 3, 5, or 7. Grid must have enough cells. Only one of mapped_weno, wenoz, teno can be active."),
+        "explanation": ("weno_order must be 1, 3, 5, or 7. Grid must have enough cells. Only one of mapped_weno, wenoz, teno can be active. When recon_type = 1 (WENO), MUSCL parameters (muscl_order, muscl_lim) must not be set."),
     },
     "check_muscl": {
         "title": "MUSCL Reconstruction",
         "category": "Numerical Schemes",
-        "explanation": "muscl_order must be 1 or 2. Second order requires muscl_lim in {1,2,3,4,5}.",
+        "explanation": "muscl_order must be 1 or 2. Second order requires muscl_lim in {1,2,3,4,5}. When recon_type = 2 (MUSCL), WENO-specific parameters must not be enabled and weno_order must be unset or 0.",
     },

As per coding guidelines (contributing.md): cross-parameter validation rules should be reflected in PHYSICS_DOCS so auto-generated physics-constraints docs stay accurate.

src/common/include/parallel_macros.fpp (1)

66-103: Cray directive gating looks correct.

Both branches now emit !DIR$ NOINLINE/!DIR$ INLINEALWAYS only inside #ifdef _CRAYFTN, while non-Cray OpenACC/OpenMP paths fall through to $:acc_directive/$:omp_directive via the outer #elif arms. This should resolve the Cray+OpenMP Frontier compile failure without affecting NVHPC/GNU/Intel code paths.

Two small readability nits (optional):

  • Lines 77–78 and 97–98: the empty #else / #endif inside the inner #if MFC_OpenACC … #elif MFC_OpenMP is a no-op and can be dropped for clarity.
  • Lines 79–80: the Fypp comment describing "non-Cray CPU builds … nothing is emitted" is placed inside the #ifdef _CRAYFTN branch, which is where non-Cray builds are by definition not taken. Consider relocating it above the #ifdef _CRAYFTN or next to the outer #endif so the intent reads correctly.
🧹 Proposed minor cleanup for cray_inline branch (mirror for cray_noinline)
 `#ifdef` _CRAYFTN
         $:cray_directive
 `#if` MFC_OpenACC
         $:acc_directive
 `#elif` MFC_OpenMP
         $:omp_directive
-#else
 `#endif`
 `#elif` MFC_OpenACC
         $:acc_directive
 `#elif` MFC_OpenMP
         $:omp_directive
 `#endif`

Please confirm with a Cray+OpenMP build on Frontier that phase_change.fpp now compiles cleanly and that NVHPC+OpenACC and GNU CPU-only builds are unaffected (the change touches the shared GPU_ROUTINE path used across compilers).


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3500d2bd-6664-4d2a-ae6f-1de6eff829c2

📥 Commits

Reviewing files that changed from the base of the PR and between 10a2f60 and 6cae040.

📒 Files selected for processing (2)
  • src/common/include/parallel_macros.fpp
  • toolchain/mfc/case_validator.py

Comment thread toolchain/mfc/case_validator.py Outdated
@Cowsreal
Copy link
Copy Markdown
Contributor Author

Cowsreal commented Apr 24, 2026

Issue: MUSCL guard add certain real valued WENO parameters, that have default values set in BASE_CFG which don't fail the test cases.

Solution: In the corresponding test cases, push None for those parameters, then pop them out inside the TestCase constructor before they trip schema. This does not interfere wiht any already existing test cases since no one else uses None.

@Cowsreal
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Cowsreal
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/common/include/parallel_macros.fpp (1)

95-107: Optional: mirror the cray_noinline explanatory comment and drop the empty #else/#endif.

The cray_inline branch is structurally symmetric to cray_noinline, but:

  • Lines 101-102 contain an empty #else / #endif pair that doesn't emit anything. It's dead code (the #if MFC_OpenACC / #elif MFC_OpenMP above it doesn't need an #else).
  • The equivalent slot in the cray_noinline branch (lines 81-82) carries a comment explaining why nothing is emitted on non-Cray CPU builds — worth mirroring here for future readers of the macro.
♻️ Suggested tidy-up
 `#ifdef` _CRAYFTN
         $:cray_directive
 `#if` MFC_OpenACC
         $:acc_directive
 `#elif` MFC_OpenMP
         $:omp_directive
 `#else`
+        #! On non-Cray CPU builds (no _CRAYFTN, no MFC_OpenACC, no MFC_OpenMP), nothing is
+        #! emitted — intentional, since !DIR$ INLINEALWAYS is a Cray-specific directive.
 `#endif`
 `#elif` MFC_OpenACC
         $:acc_directive
 `#elif` MFC_OpenMP
         $:omp_directive
 `#endif`

(Alternatively drop the empty #else/#endif entirely since the inner #if/#elif without an #else is valid.)

toolchain/mfc/test/cases.py (1)

303-303: LGTM on the sentinel-None approach; minor readability suggestion.

Pushing weno_eps/wenoz_q/teno_CT as None correctly pairs with the new filter in TestCase.__init__ to strip BASE_CFG defaults before validation — matches the approach described in the PR. Optional: consider wrapping this multi-key dict onto multiple lines (as done elsewhere in this file) to make the WENO-suppression intent more obvious to future readers.

✏️ Optional readability tweak
-        for muscl_order in [1, 2]:
-            stack.push(f"muscl_order={muscl_order}", {"muscl_order": muscl_order, "recon_type": 2, "weno_order": 0, "weno_eps": None, "wenoz_q": None, "teno_CT": None})
+        for muscl_order in [1, 2]:
+            stack.push(
+                f"muscl_order={muscl_order}",
+                {
+                    "muscl_order": muscl_order,
+                    "recon_type": 2,
+                    "weno_order": 0,
+                    # Suppress BASE_CFG WENO defaults so check_muscl doesn't
+                    # reject MUSCL cases; filtered out in TestCase.__init__.
+                    "weno_eps": None,
+                    "wenoz_q": None,
+                    "teno_CT": None,
+                },
+            )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 57b4b57a-10e2-4289-b7c2-a00af61c582f

📥 Commits

Reviewing files that changed from the base of the PR and between 6cae040 and b9bf565.

📒 Files selected for processing (4)
  • src/common/include/parallel_macros.fpp
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/test/case.py
  • toolchain/mfc/test/cases.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant