Skip to content

Comments

Fix 6 safe pre/post-process bugs (batch)#1240

Open
sbryngelson wants to merge 8 commits intoMFlowCode:masterfrom
sbryngelson:fix/safe-bugfixes-batch
Open

Fix 6 safe pre/post-process bugs (batch)#1240
sbryngelson wants to merge 8 commits intoMFlowCode:masterfrom
sbryngelson:fix/safe-bugfixes-batch

Conversation

@sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Feb 22, 2026

User description

Summary

Batches 6 low-risk bug fixes that only touch pre-process or post-process CPU code paths. These have no GPU kernel, MPI hot-path, or simulation numerics impact, making them safe to merge with GitHub CI alone.

Included fixes

Supersedes

Closes #1214, closes #1177, closes #1178, closes #1189, closes #1191, closes #1218

Test plan

  • All GitHub CI checks pass (ubuntu MPI debug, ubuntu no-mpi, macOS)
  • No Fortran source files in simulation hot path are touched
  • Each fix is a 1-3 line change in pre-process or post-process only

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Corrected vertex index handling in OBJ file reader for accurate face parsing.
    • Fixed time value propagation in bubble-related I/O operations.
    • Improved Euclidean distance computation logic in interface data output.
    • Optimized simplex noise index wrapping for better performance.
  • Refactor

    • Adjusted default probe coordinate bounds initialization from y-dimension to z-dimension.

CodeAnt-AI Description

Fix file I/O and preprocessing bugs that produced incorrect outputs and stray directories

What Changed

  • OBJ reader now uses the correct vertex index for the third vertex so imported models have correct face geometry
  • Simplex noise index wrapping corrected so noise includes the full index range (fixes missing pattern at index 255)
  • Directory cleanup and creation no longer use a literal '/*' glob; startup removes the intended directory and creates the proper time-step folder
  • 3D integral probe z-bounds are initialized correctly so volume integrals use valid z-range values
  • Lagrangian bubble output time column now uses the broadcast file time, eliminating garbage timestamps
  • Interface-point selection computes distances with the current candidate point and exits early when too close, preventing near-duplicate stored points

Impact

✅ Accurate OBJ geometry import
✅ Fewer stray/junk directories after startup
✅ Correct timestamps in bubble post-process output

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Copilot AI review requested due to automatic review settings February 22, 2026 20:54
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 22, 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 22, 2026

📝 Walkthrough

Walkthrough

This PR fixes five critical bugs across multiple modules: OBJ reader vertex indexing collision, Lagrangian bubble output time value initialization, interface contour point spacing computation, simplex noise index wrapping range, directory cleanup semantics, and integral z-bounds copy-paste error.

Changes

Cohort / File(s) Summary
OBJ Reader Vertex Indexing
src/common/m_model.fpp
Introduced separate variable iv3 for third vertex index read from face lines, eliminating confusion where triangle counter j was overwritten by vertex index, causing incorrect triangle vertex assignments.
Lagrangian Bubble Time Initialization
src/post_process/m_data_output.fpp
Added time_real = file_time assignment after MPI_BCAST in three bubble-related I/O paths to propagate read file time values instead of using uninitialized garbage.
Interface Contour Distance Logic
src/post_process/m_data_output.fpp
Moved Euclidean distance computation inside the loop over existing points, changed cycle to exit for early rejection, and removed dead distance code in counter==0 branch to properly check spacing against all stored points.
Directory Cleanup Semantics
src/pre_process/m_start_up.fpp
Changed cleanup from creating a literal * directory by attempting mkdir -p path/* to explicitly deleting the entire rank directory before recreating the per-rank subdirectory.
Simplex Noise Index Wrapping
src/pre_process/m_simplex_noise.fpp
Replaced modulo wrapping (mod(i, 255)) with bitwise AND wrapping (iand(i, 255)) in two locations to achieve full 0–255 permutation table coverage instead of skipping index 255.
Integral Bounds Initialization
src/simulation/m_global_parameters.fpp
Fixed copy-paste error where integral(i)%ymin and integral(i)%ymax were assigned twice; now correctly assigns integral(i)%zmin and integral(i)%zmax for z-dimension bounds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Suggested labels

bug, critical-fix, high-priority, size:L

Suggested reviewers

  • wilfonba

Poem

🐰 A rabbit hops through debug trails,
Six bugs squashed—our hero prevails!
Vertices sorted, times now bright,
Noise wraps full, distances right,
Bounds initialized without fail,
The code now tells a cleaner tale! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix 6 safe pre/post-process bugs (batch)' directly and clearly describes the main change: a batch of six bug fixes in pre/post-process code paths.
Linked Issues check ✅ Passed All six linked issues (#1214, #1177, #1178, #1189, #1191, #1218) are directly addressed by corresponding code changes: directory cleanup, z-bounds initialization, OBJ vertex indexing, time initialization, loop index correction, and simplex noise wrapping.
Out of Scope Changes check ✅ Passed All changes in five modified files are within scope and directly address the listed objectives. Each modification targets one specific bug mentioned in linked issues with no extraneous changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description comprehensively covers all required template sections: summary, fixes linked issues, includes type of change (bug fixes), testing plan, and GPU expansion (not applicable). Provides clear, specific details about each change.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 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:S This PR changes 10-29 lines, ignoring generated files label Feb 22, 2026
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 22, 2026

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Index validation
    After reading face indices (k, l, iv3) there is no validation or handling of negative indices (OBJ allows negative indices) or out-of-range values. This can cause out-of-bounds access on vertices(...) and crash or corrupt memory at runtime. Add bounds checks and negative-index handling.

  • OBJ parsing
    The new OBJ face read uses a simple list read (three integers) which will fail or produce incorrect indices for common OBJ face formats that include texture/normal indices (e.g. "f v/vt/vn") or for quad faces. The reader should be hardened to accept or reject these formats explicitly and/or parse tokens to extract vertex indices only.

  • Directory Deletion
    The code now calls s_delete_directory(trim(proc_rank_dir)) (removed the literal '*' bug). Verify that s_delete_directory's semantics are correct here: it should remove only contents (or handle a missing directory) and must not unintentionally remove parent directories needed later. Also ensure this is safe in parallel runs (no race conditions from multiple processes hitting the same filesystem path) and that failures (nonexistent path, permissions) are handled gracefully.

  • Permutation mask
    The change from mod(i,255) to iand(i,255) fixes skipping index 255 by using a bitmask. Verify that input indices i/j are non-negative or that negative values are handled as intended; also confirm integer kind/magnitude matches the expectations of p_vec indexing.

  • Dedup logic change
    The duplicate-point detection in s_write_intf_data_file was reworked: the per-point Euclidean distance is now computed inside the loop and the code uses exit when a close point is found. Confirm the new behavior exactly matches the intended semantics (do not add a new point if any existing point lies within tgp). Also check loop ordering and index usage (x/y indices) to ensure comparisons use the correct coordinate arrays and the counter logic is robust.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 22, 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

Batches several small correctness fixes across MFC utilities and I/O paths, targeting directory handling, initialization bugs, indexing errors, and post-process output correctness.

Changes:

  • Fixes directory cleanup logic in serial pre-process so it deletes the intended rank directory instead of using a non-expanding wildcard.
  • Corrects initialization/indexing issues (integral z-bounds init, OBJ face parsing index handling).
  • Fixes post-process outputs (initialize time_real from restart metadata; correct interface point distance checking) and simplex-noise index wrapping.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/simulation/m_global_parameters.fpp Initializes volume-integral zmin/zmax correctly (instead of mistakenly repeating y-bounds).
src/pre_process/m_start_up.fpp Replaces wildcard-based directory “cleanup” with deletion of the actual per-rank directory, then recreates /0.
src/pre_process/m_simplex_noise.fpp Uses iand(…,255) for correct 0–255 permutation indexing in 2D simplex noise.
src/post_process/m_data_output.fpp Initializes time_real from file_time and fixes the interface-point distance check loop to use the correct index and early-exit logic.
src/common/m_model.fpp Fixes OBJ face parsing so the third vertex index doesn’t overwrite the triangle counter (j).

Copy link
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/post_process/m_data_output.fpp`:
- Line 1271: The assignment time_real = file_time in the Silo output function is
dead code because time_real is never used; either remove that assignment from
the Silo branch or add the simulation time metadata to the DBPUTPM call so Silo
stores time. Locate the Silo variant of the output routine (the code path that
calls DBPUTPM) and either delete the time_real variable and its assignment, or
build an options list containing the time (e.g., set "time" or "cycle" entries
using file_time/time_real) and pass it into DBPUTPM so the point-mesh metadata
includes the simulation time.

In `@src/pre_process/m_start_up.fpp`:
- Around line 358-361: The Windows implementation of s_create_directory does not
create parent directories recursively, causing failures when code calls
s_delete_directory(...) then s_create_directory(trim(proc_rank_dir)//'/0') (and
similar calls elsewhere); update the Windows branch in the s_create_directory
implementation (in m_compile_specific) to invoke mkdir with the /s flag (e.g.,
use "mkdir /s <path>" or the equivalent command string) so parent directories
are created recursively, and ensure any other uses of s_create_directory (the
second occurrence noted) benefit from the same change.

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 30.76923% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.06%. Comparing base (df28255) to head (08a7f25).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
src/post_process/m_data_output.fpp 40.00% 3 Missing ⚠️
src/common/m_model.fpp 0.00% 2 Missing ⚠️
src/pre_process/m_simplex_noise.fpp 0.00% 2 Missing ⚠️
src/pre_process/m_start_up.fpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1240      +/-   ##
==========================================
+ Coverage   44.05%   44.06%   +0.01%     
==========================================
  Files          70       70              
  Lines       20496    20497       +1     
  Branches     1989     1989              
==========================================
+ Hits         9030     9033       +3     
+ Misses      10328    10326       -2     
  Partials     1138     1138              

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

sbryngelson and others added 7 commits February 23, 2026 09:48
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…a_files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The z-bounds initialization for volume integrals repeats ymin/ymax
instead of zmin/zmax. 3D volume integrals use uninitialized z-bounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When reading face lines, j is overwritten by the third vertex index
from the file, then used as the triangle index for model%trs(j).
Introduces a separate iv3 variable for the third vertex index.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
time_real is declared but never assigned from file_time after the
MPI broadcast. The time column in output contains garbage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
euc_d was computed outside the inner loop using the outer variable i
(stale from a previous loop) instead of the current stored-point
index. Moved distance computation inside the do-loop over stored
points and changed cycle to exit for correct early termination when
a candidate point is too close to any existing point.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sbryngelson sbryngelson force-pushed the fix/safe-bugfixes-batch branch from 0dabbbc to 08a7f25 Compare February 23, 2026 14:48
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 23, 2026

CodeAnt AI is running Incremental review


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

@codeant-ai codeant-ai bot added size:S This PR changes 10-29 lines, ignoring generated files and removed size:S This PR changes 10-29 lines, ignoring generated files labels Feb 23, 2026
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 23, 2026

CodeAnt AI Incremental review completed.

@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 23, 2026

CodeAnt AI is running Incremental review


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

@codeant-ai codeant-ai bot added size:S This PR changes 10-29 lines, ignoring generated files and removed size:S This PR changes 10-29 lines, ignoring generated files labels Feb 23, 2026
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 23, 2026

CodeAnt AI Incremental review completed.

@MFlowCode MFlowCode deleted a comment from github-actions bot Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files

Development

Successfully merging this pull request may close these issues.

1 participant