Skip to content

Comments

Fix moncon_cutoff declared as integer, truncating 1e-8 to 0#1174

Open
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix/moncon-cutoff-type
Open

Fix moncon_cutoff declared as integer, truncating 1e-8 to 0#1174
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix/moncon-cutoff-type

Conversation

@sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Feb 21, 2026

Summary

Severity: CRITICAL — completely disables the THINC monotonicity constraint.

File: src/common/m_constants.fpp, line 47

moncon_cutoff is declared as integer but assigned the real literal 1e-8_wp. Fortran silently truncates this to 0. Every comparison like moncon > moncon_cutoff is then always true (since moncon_cutoff = 0), so the THINC monotonicity constraint is never enforced.

Before

integer, parameter :: moncon_cutoff = 1e-8_wp  ! becomes 0

After

real(wp), parameter :: moncon_cutoff = 1e-8_wp  ! stays 1e-8

Why this went undetected

Fortran truncates real-to-integer conversions at compile time with at most a warning (often suppressed). THINC still produces plausible-looking results without the monotonicity constraint — the interface compression just allows more extrema than intended, which is hard to notice visually.

Test plan

  • Run THINC interface compression test case and verify monotonicity constraint activates
  • Check that interface overshoots are now suppressed

🤖 Generated with Claude Code

Fixes #1195

Copilot AI review requested due to automatic review settings February 21, 2026 03:22
@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 28 minutes and 25 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

  • Type consistency
    The cutoff constant moncon_cutoff was changed from integer to real to fix truncation. Verify all uses throughout the codebase treat moncon_cutoff as a real (no local integer declarations or implicit conversions). Search for any places that compare or assign this constant to integer variables or use integer literals in the same expressions, as those will reintroduce logic bugs.

  • Magnitude / precision check
    Ensure the chosen value (1e-8_wp) is appropriate for the working precision (wp) used across targets. If wp can be single precision on some builds, this cutoff may underflow relative to epsilon; validate the value against machine epsilon or test cases to confirm the monotonicity limiter becomes active as intended.

@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

Fixes a constant type bug in the shared m_constants module where moncon_cutoff was declared as an integer while being assigned a working-precision real literal, which effectively truncated the cutoff to 0 and disabled THINC’s monotonicity constraint.

Changes:

  • Change moncon_cutoff from integer, parameter to real(wp), parameter so 1e-8_wp is preserved.
  • Restores intended thresholding behavior for THINC monotonicity checks (used in src/simulation/m_muscl.fpp).
Comments suppressed due to low confidence (1)

src/common/m_constants.fpp:47

  • The inline comment has a spelling/grammar issue: “extremas” should be “extrema” (plural of extremum).
    real(wp), parameter :: moncon_cutoff = 1e-8_wp !< Monotonicity constraint's limiter to prevent extremas in THINC

cubic-dev-ai[bot]

This comment was marked as off-topic.

moncon_cutoff is assigned 1e-8_wp but declared as integer, so Fortran
silently truncates it to 0. This makes all THINC monotonicity constraint
comparisons always true, completely disabling the constraint.

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

codecov bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.05%. Comparing base (84c46e0) to head (e12577c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1174   +/-   ##
=======================================
  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.

fluid_rho broadcast uses MPI_LOGICAL instead of mpi_p (real type)

1 participant