Skip to content

Comments

Fix mv read loop hardcoding 4 instead of nnode#1190

Open
sbryngelson wants to merge 3 commits intoMFlowCode:masterfrom
sbryngelson:fix/mv-loop-nnode
Open

Fix mv read loop hardcoding 4 instead of nnode#1190
sbryngelson wants to merge 3 commits intoMFlowCode:masterfrom
sbryngelson:fix/mv-loop-nnode

Conversation

@sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Feb 21, 2026

Summary

Severity: HIGH — mv data file loop uses wrong bounds and offsets when nnode != 4.

File: src/pre_process/m_start_up.fpp, lines 479-482

The pb (pressure) read loop just above correctly uses nnode for both the loop bound and file number offset calculation. The mv (mass/velocity) read loop immediately below hardcodes 4 instead.

Before

! pb loop (correct)
do r = 1, nnode
    write (file_num, '(I0)') sys_size + r + (i - 1)*nnode
    file_loc = ... '/pb' ...

! mv loop (wrong)
do r = 1, 4                                              ! should be nnode
    write (file_num, '(I0)') sys_size + r + (i - 1)*4    ! should be nnode
    file_loc = ... '/mv' ...

After

do r = 1, nnode
    write (file_num, '(I0)') sys_size + r + (i - 1)*nnode

Why this went undetected

nnode is 4 in the most common configuration, so the hardcoded value happens to be correct.

Test plan

  • Run bubble restart with non-default nnode value
  • Verify all mv data files are read correctly

🤖 Generated with Claude Code

Fixes #1210

Copilot AI review requested due to automatic review settings February 21, 2026 03:23
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 21, 2026

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

Warning

Rate limit exceeded

@sbryngelson has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ 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.

@codeant-ai codeant-ai bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Feb 21, 2026
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 21, 2026

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Parallel I/O inconsistency
    The serial mv loop was updated to use nnode, but the parallel ic-reading loop still uses a hardcoded 4 in the bound sys_size + 2*nb*4. This is an inconsistency: parallel I/O ranges should be updated to use nnode as well (or otherwise validated) so serialized and parallel read logic match.

  • File-number string width
    file_num is allocated with length based only on sys_size digits. When computing filenames with indices like sys_size + r + (i-1)*nnode (and the pb/mv ranges), the printed numeric value may require more digits than computed. This can lead to truncated filenames or incorrect file names when nnode, nb, or sys_size grows. Ensure file_num can hold the maximum index used.

  • Serial mv loop update
    The serial mv file-read loop was changed to iterate r=1..nnode and to compute the file number using nnode (sys_size + r + (i-1)*nnode). Verify this matches the intended file-numbering scheme for all nb and nnode combinations and is consistent with the pb loop. Validate with non-default nnode to ensure expected files are opened and read.

@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 21, 2026

CodeAnt AI finished reviewing your PR.

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 bug in the bubble restart file reading logic where the mv data file loop was hardcoded to iterate 4 times instead of using the nnode variable, which could cause incorrect file reads when nnode != 4.

Changes:

  • Updated the mv data file loop to use nnode instead of the hardcoded value 4
  • Corrected the file number offset calculation to use nnode for proper indexing

cubic-dev-ai[bot]

This comment was marked as off-topic.

The pb loop just above correctly uses nnode for both the loop bound
and file number offset. The mv loop should match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sbryngelson and others added 2 commits February 21, 2026 00:51
…ommon

Fix all remaining instances of the literal integer 4 representing the
QBMM quadrature node count (nnode) across simulation and common modules,
completing the nnode parameterization started in the PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix remaining instances of the literal 4 representing QBMM quadrature
node count in pre_process/m_global_parameters.fpp and m_start_up.fpp,
consistent with the fixes already applied to common and simulation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 10.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.05%. Comparing base (84c46e0) to head (5838245).

Files with missing lines Patch % Lines
src/common/m_mpi_common.fpp 7.14% 13 Missing ⚠️
src/pre_process/m_start_up.fpp 0.00% 3 Missing ⚠️
src/pre_process/m_global_parameters.fpp 33.33% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1190   +/-   ##
=======================================
  Coverage   44.05%   44.05%           
=======================================
  Files          70       70           
  Lines       20498    20498           
  Branches     1990     1990           
=======================================
  Hits         9030     9030           
  Misses      10329    10329           
  Partials     1139     1139           

☔ 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

size:XS This PR changes 0-9 lines, ignoring generated files

Development

Successfully merging this pull request may close these issues.

time_real used uninitialized in Lagrangian bubble output

1 participant