Fix serial I/O missing beta for bubbles_lagrange in post_process#1274
Conversation
With parallel_io=F (serial), s_write_serial_data_files did not write the Lagrangian void fraction (beta) to p_all/ as q_cons_vf(sys_size+1), while s_write_parallel_data_files correctly does so via alt_sys=sys_size+1. This caused post_process to abort with "q_cons_vf8.dat is missing" for any serial Lagrangian bubble case. Two changes: 1. m_data_output.fpp: write beta as q_cons_vf(sys_size+1) in serial path, mirroring the parallel I/O path. 2. m_data_input.f90: t_step_start output is written by pre_process, which does not know about Lagrangian beta; initialize beta to zero for that timestep rather than aborting. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1274 +/- ##
==========================================
- Coverage 44.05% 44.04% -0.02%
==========================================
Files 70 70
Lines 20496 20499 +3
Branches 1991 1993 +2
==========================================
- Hits 9029 9028 -1
- Misses 10328 10330 +2
- Partials 1139 1141 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Claude Code ReviewHead SHA: 9892f43 Files changed: 2
Summary
Findings1. Over-broad silent zero-initialization guard — moderate concernFile: The new guard triggers for any timestep where the beta file is absent when Suggested fix — tighten the guard: else if (bubbles_lagrange .and. i == beta_idx .and. t_step == t_step_start) then
! beta not written by pre_process; initialize to zero for t_step_start only.
q_cons_vf(i)%sf(0:m, 0:n, 0:p) = 0._wpThis preserves the abort path for any non-initial timestep where the file is unexpectedly missing. 2. Implicit
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTwo files are modified to support Lagrangian bubble void fraction data handling. In 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. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes a regression in serial (non-MPI) post_process for bubbles_lagrange=T cases by ensuring the Lagrangian void fraction (beta) is available to read, matching the parallel I/O expectations.
Changes:
- Update simulation serial output to write
betaasq_cons_vf(sys_size+1).dat, aligning with the parallel I/O numbering scheme. - Update post_process serial input to avoid aborting when the
betafile is missing (intended to covert_step_startwritten by pre_process) by initializingbetato zero.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/simulation/m_data_output.fpp |
Adds serial unformatted output of Lagrangian beta as an extra q_cons_vf(sys_size+1) file. |
src/post_process/m_data_input.f90 |
Adds a missing-file fallback for beta_idx during serial reads to prevent abort on the pre_process-written first timestep. |
| ! Lagrangian beta (void fraction) written as q_cons_vf(sys_size+1) to | ||
| ! match the parallel I/O path and allow post_process to read it. | ||
| if (bubbles_lagrange) then | ||
| write (file_path, '(A,I0,A)') trim(t_step_dir)//'/q_cons_vf', & | ||
| sys_size + 1, '.dat' | ||
|
|
||
| open (2, FILE=trim(file_path), & | ||
| FORM='unformatted', & | ||
| STATUS='new') | ||
|
|
||
| write (2) beta%sf(0:m, 0:n, 0:p); close (2) | ||
| end if |
There was a problem hiding this comment.
beta is an OPTIONAL dummy argument, but this block dereferences beta%sf guarded only by bubbles_lagrange. If s_write_serial_data_files is called without the optional beta actual argument (even if bubbles_lagrange is true due to input/state), this will be an invalid reference at runtime. Guard the write with present(beta) (and optionally also bubbles_lagrange) to match the parallel I/O path’s logic.
| else if (bubbles_lagrange .and. i == beta_idx) then | ||
| ! beta (Lagrangian void fraction) is not written by pre_process | ||
| ! for t_step_start; initialize to zero. |
There was a problem hiding this comment.
This fallback initializes beta to zero whenever the beta file is missing, for any t_step. That can silently hide real I/O/data corruption for later steps (and yield incorrect post-processed results). Consider restricting the zero-initialization to the known pre_process-only step (e.g., t_step == t_step_start / the first step being processed), and keep aborting for missing beta files at other timesteps (or at least emit a clear warning).
| else if (bubbles_lagrange .and. i == beta_idx) then | |
| ! beta (Lagrangian void fraction) is not written by pre_process | |
| ! for t_step_start; initialize to zero. | |
| else if (bubbles_lagrange .and. i == beta_idx .and. t_step == t_step_start) then | |
| ! beta (Lagrangian void fraction) is not written by pre_process | |
| ! for t_step_start; initialize to zero only on that timestep. |
Summary
With
parallel_io=F(serial/no-MPI builds),post_processaborts withq_cons_vf8.dat is missingfor anybubbles_lagrange=Tcase. This is a regression that only affects serial builds — parallel builds (parallel_io=T) work correctly.Root cause: Two issues in the serial I/O path:
s_write_serial_data_filesdid not write the Lagrangian void fraction (beta) top_all/asq_cons_vf(sys_size+1).dat, whiles_write_parallel_data_filescorrectly does so viaalt_sys = sys_size + 1. Meanwhile,post_processalways includesbeta_idxinsys_sizewhenbubbles_lagrange=T, so it always expects this file.t_step_startoutput is written bypre_process, which has no knowledge of Lagrangian beta. So even with fix Error on READE.md #1,t_step_start = 0would still be missing the beta file.Changes
src/simulation/m_data_output.fpp: writebetaasq_cons_vf(sys_size+1).datins_write_serial_data_files, mirroring the parallel I/O path.src/post_process/m_data_input.f90: whenbubbles_lagrange=Tandi == beta_idxand the file is absent, initialize beta to zero instead of aborting. This handles thet_step_starttimestep written bypre_process.Test plan
bubbles_lagrange=Tcase withparallel_io=Fthrough all stages (pre_process → simulation → post_process) and confirm no abortparallel_io=TLagrangian cases are unaffected🤖 Generated with Claude Code