Skip to content

Fix post_process non-MPI builds never reading input file#1272

Merged
sbryngelson merged 5 commits intoMFlowCode:masterfrom
sbryngelson:fix/post-process-no-mpi-input-reading
Feb 27, 2026
Merged

Fix post_process non-MPI builds never reading input file#1272
sbryngelson merged 5 commits intoMFlowCode:masterfrom
sbryngelson:fix/post-process-no-mpi-input-reading

Conversation

@sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Feb 27, 2026

Summary

In s_initialize_mpi_domain in src/post_process/m_start_up.fpp, the entire subroutine body was wrapped in #ifdef MFC_MPI. Non-MPI builds (--no-mpi) therefore skipped all input reading, leaving every parameter at its Fortran default — case_dir blank, m/n/p = 0, etc. The result was a misleading runtime error:

Time-step folder                    [400 spaces]                    /p_all/p0/0 is missing. Exiting.

The fix removes the outer #ifdef MFC_MPI guard so that s_mpi_initialize(), s_assign_default_values_to_user_inputs(), s_read_input_file(), and s_check_input_file() are always called — exactly as pre_process and simulation already do. The MPI-specific functions (s_mpi_bcast_user_inputs, s_mpi_decompose_computational_domain, etc.) already guard their own bodies with #ifdef MFC_MPI internally, so they become no-ops in non-MPI builds.

Test plan

  • Non-MPI build (--no-mpi) of post_process now reads post_process.inp and processes output correctly
  • MPI build behavior unchanged
  • parallel_io = T with --no-mpi is still caught by the existing @:PROHIBIT in the Fortran checker (pre-existing guard)

🤖 Generated with Claude Code

sbryngelson and others added 5 commits February 26, 2026 19:23
In s_initialize_mpi_domain, the entire body including
s_assign_default_values_to_user_inputs(), s_read_input_file(), and
s_check_input_file() was guarded by #ifdef MFC_MPI. Non-MPI builds
therefore ran with all parameters at Fortran defaults (case_dir blank,
m/n/p = 0), causing a misleading "Time-step folder missing" error.

pre_process and simulation already call these unconditionally; the
individual MPI functions (s_mpi_bcast_user_inputs, etc.) handle the
#ifdef MFC_MPI guard internally as stubs when MPI is absent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move three Fortran @:PROHIBIT checks that test case parameters against
build configuration flags into case_validator.py, so they fire before
any binary is invoked rather than at Fortran runtime:

- parallel_io = T requires --mpi (all stages, via check_build_flags)
- precision = 2 requires no --single (post_process, in check_output_format)
- 3D cylindrical + p > 0 requires no --single (simulation only,
  via check_geometry_precision_simulation)

CFG() from state.py carries the active build config (mpi, single, mixed).
During standalone './mfc.sh validate', CFG() holds defaults (mpi=T,
single=F) so these checks do not produce false positives.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The three build-flag compatibility checks moved to case_validator.py
in the previous commit no longer need Fortran-side enforcement.
Remove them and their now-empty subroutines:

- pre_process/m_checker.fpp: s_check_parallel_io (parallel_io + --no-mpi)
- simulation/m_checker.fpp: s_check_inputs_geometry_precision (3D cyl + --single)
- post_process/m_checker.fpp: s_check_inputs_output_format (precision=2 + --single)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
self.get('p', 0) always returns an int (0 when absent), so the
p is not None check was always True and never needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MFlowCode MFlowCode deleted a comment from github-actions bot Feb 27, 2026
@MFlowCode MFlowCode deleted a comment from github-actions bot Feb 27, 2026
@MFlowCode MFlowCode deleted a comment from github-actions bot Feb 27, 2026
@MFlowCode MFlowCode deleted a comment from github-actions bot Feb 27, 2026
@MFlowCode MFlowCode deleted a comment from github-actions bot Feb 27, 2026
@sbryngelson sbryngelson marked this pull request as ready for review February 27, 2026 01:00
Copilot AI review requested due to automatic review settings February 27, 2026 01:00
@sbryngelson sbryngelson merged commit b62b08b into MFlowCode:master Feb 27, 2026
36 of 52 checks passed
@github-actions
Copy link

Claude Code Review

Head SHA: 1c41100b7a89c95d353fe9d0ee34a78d9bf7bf1e

Files changed: 6

  • src/post_process/m_start_up.fpp
  • src/post_process/m_checker.fpp
  • src/pre_process/m_checker.fpp
  • src/simulation/m_checker.fpp
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/lint_docs.py

Summary

  • Core fix is correct. The outer #ifdef MFC_MPI guard in s_initialize_mpi_domain prevented all input-reading in non-MPI post_process builds, causing the misleading blank case_dir error. Removing it is the right fix.
  • Three Fortran #ifdef-guarded runtime checks are moved from m_checker.fpp files into Python case_validator.py, giving earlier (pre-binary) error reporting.
  • Logic equivalence for all moved checks is correct (verified the cylindrical/single-precision De Morgan reduction).
  • validate_common() now calls check_build_flags(), which broadens the parallel_io + --no-mpi check from pre_process-only to all three stages — this is an improvement, not a regression.

Findings

[Minor] s_check_inputs_fft now always called outside #ifdef MFC_MPI
src/post_process/m_start_up.fpp — the last call inside the removed guard:

call s_mpi_bcast_user_inputs()
call s_initialize_parallel_io()
call s_mpi_decompose_computational_domain()
call s_check_inputs_fft()   ! ← now always called

The first three functions are documented as having internal #ifdef MFC_MPI guards, but s_check_inputs_fft is not mentioned. If it interrogates MPI decomposition state (e.g., num_procs_y, num_procs_z, which are set by s_mpi_decompose_computational_domain), it may produce incorrect results or a confusing error in non-MPI builds where those variables remain at default (1). Worth a quick look at s_check_inputs_fft's body to confirm it is safe when num_procs_y = num_procs_z = 1.

[Design note] Removed Fortran @:PROHIBIT checks have no Fortran fallback
src/post_process/m_checker.fpp:27, src/pre_process/m_checker.fpp:27, src/simulation/m_checker.fpp:39 — the checks for precision==2 + --single, parallel_io + --no-mpi, and 3D cylindrical + --single now live only in Python. Users running the compiled binary directly (bypassing ./mfc.sh) will no longer get any diagnostic and may see a cryptic runtime failure instead. This is a deliberate design tradeoff (earlier Python detection vs. defense-in-depth), but it is worth noting in the PR rationale. If the project policy is toolchain-only invocation, this is fine.

[Nit] Comment typo in m_start_up.fpp
src/post_process/m_start_up.fpp — the updated comment reads:

! carried out if the post-process is in fact not truly executed in parallel.

"not truly executed in parallel" is the negated condition (i.e., serial run). The comment is logically correct but mirrors the old pre-existing phrasing that is slightly awkward. Not a blocker.


No blocking issues found. The core bug fix is sound and the moved checks are logically equivalent.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a2a8a4 and 1c41100.

📒 Files selected for processing (6)
  • src/post_process/m_checker.fpp
  • src/post_process/m_start_up.fpp
  • src/pre_process/m_checker.fpp
  • src/simulation/m_checker.fpp
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/lint_docs.py

📝 Walkthrough

Walkthrough

This PR refactors input validation by removing runtime checks from Fortran modules and consolidating them into the Python toolchain validator. Four validation subroutines are deleted from three Fortran modules (s_check_inputs_output_format, s_check_parallel_io, s_check_inputs_geometry_precision), while two new validation methods are added to CaseValidator (check_build_flags, check_geometry_precision_simulation). The MPI initialization conditional guard in m_start_up.fpp is also removed, making the MPI code path unconditional.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Review effort 3/5, size:S

Suggested reviewers

  • wilfonba

Poem

🐰 With nimble paws, we moved the guards,
From Fortran's checks to Python's wards,
Validation now lives earlier still,
Before the code will bend to will,
A cleaner flow, a tighter dance! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug where post_process built without MPI (--no-mpi) never read the input file, leaving all parameters at their Fortran default values and producing misleading error messages. The fix aligns post_process with the existing pattern used by pre_process and simulation.

Changes:

  • Remove outer #ifdef MFC_MPI guard in s_initialize_mpi_domain so input file reading occurs in all builds
  • Migrate three build-flag compatibility checks from Fortran to Python case validator for earlier error detection
  • Update documentation lint skip list for the new build-flag check methods

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/post_process/m_start_up.fpp Remove outer #ifdef MFC_MPI guard in s_initialize_mpi_domain; update comment to say "post-process" instead of "simulation"
toolchain/mfc/case_validator.py Add check_build_flags() and check_geometry_precision_simulation() methods; add precision == 2 check to check_output_format()
src/pre_process/m_checker.fpp Remove s_check_parallel_io() subroutine (migrated to Python)
src/post_process/m_checker.fpp Remove s_check_inputs_output_format() subroutine (migrated to Python)
src/simulation/m_checker.fpp Remove s_check_inputs_geometry_precision() subroutine and call (migrated to Python)
toolchain/mfc/lint_docs.py Add new build-flag check methods to skip list as they have no physics documentation

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.04%. Comparing base (1412eb2) to head (1c41100).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1272      +/-   ##
==========================================
- Coverage   44.05%   44.04%   -0.02%     
==========================================
  Files          70       70              
  Lines       20496    20492       -4     
  Branches     1991     1992       +1     
==========================================
- Hits         9029     9025       -4     
+ Misses      10328    10327       -1     
- Partials     1139     1140       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants