Run inactive-patch validation over all patch slots - #1727
Closed
Mohit-Ak wants to merge 1 commit into
Closed
Conversation
Three of the four validation loops in s_check_patches were bounded at num_patches rather than num_patches_max, so their else branches -- the inactive-slot validators -- were unreachable. Widen those bounds to match the first loop, which already gets this right.
Author
|
Closing: the Fortran fix is correct but causes widespread pre_process failures across the existing test suite — many test cases inherit a 3-patch BASE_CFG and only override num_patches to 1 or 2, leaving inactive slots with non-default values that the now-reachable validators reject. The fix needs a coordinated update to the test-case generator alongside the Fortran change. Will revisit with a complete fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three of the four per-patch validation loops in
s_check_patcheswere bounded atnum_patchesinstead ofnum_patches_max, so theirelsebranches — the onesthat validate the inactive patch slots — could never be reached.
The first loop (alteration of deprecated geometry numbers, L43) is already
correct: it runs
do i = 1, num_patches_maxand usesif (i <= num_patches)tosplit active from inactive slots. The other three copy that same
if (i <= num_patches) ... else ...shape but only ever iterate tonum_patches, which makes the predicate unconditionally true. That left threevalidators as dead code:
s_check_inactive_patch_alteration_rights(L405)s_check_unsupported_patch_smoothing(L442)s_check_inactive_patch_primitive_variables(L512)The fix widens those three bounds to
num_patches_max. That's the whole change,+3/-3 in one file.
The smoothing loop is worth a second look because it's structurally different —
its predicate is a geometry whitelist (
i > 1 .and. geometry == 2/3/4/...)rather than
i <= num_patches. An inactive slot hasgeometry == dflt_int, soonce the bound is widened it falls through to the
else/unsupported branch,which is the intended behaviour. I verified that empirically rather than by
reading (see the
smoothrow below).Why this can't change results for any valid case
m_global_parameters.fpp:230-268initialises allnum_patches_max(= 10, fromm_constants.fpp:26) slots to defaults in its owndo i = 1, num_patches_maxloop —
alter_patch = .false.withalter_patch(0) = .true.,smoothen = .false.,smooth_patch_id = i, anddflt_realfor every primitive variable.Those defaults are exactly what the inactive-patch validators assert. So for a
well-formed case the newly-reachable checks are no-ops; the change only tightens
validation on misconfigured input and cannot move a golden file.
How it was tested
I built a 1D Sod-like case with
num_patches: 2and then set one forbiddenparameter on the inactive slot 3, one variant per broken loop, plus a clean
control. Run through
./mfc.sh run <case.json> -t pre_process -n 1:controlalteralter_patch(1) = TInactive patch 3: cannot have any alter_patch(i) enabledsmoothsmoothen = T,smooth_coeff = 0.5Inactive patch 3: cannot have smoothen enabledprimpres,vel(1),rhoInactive patch 3: rho must not be setEach bad variant produces a different message, which is what proves the three
loops independently rather than just showing that some check fires. The control
still passes in both directions, so nothing valid became newly rejected.
Both CI gates pass locally on the committed tree:
./mfc.sh lint→372 passed, 4 subtests passed in 9.74s./mfc.sh precheck -j 4→ all 7 checks OK (formatting, spelling, toolchainlint, source lint, doc refs, parameter docs, example cases)
Note on prior work
PR #1599 took the same approach and was closed for author inactivity, not
because anything was wrong with it. This is a clean re-do with the reachability
matrix above as evidence.
Fixes #1482