Open
Conversation
The patch fixes three bugs in wignerseitz.f90:
1. Unallocated private allocatable (tridx): Per OpenMP spec §2.15.3.3, private
copies of allocatables start unallocated. The original code allocated tridx
before the parallel region then listed it as private, causing undefined
behavior when get_pairs tried to use the unallocated array.
Fixed by allocating tridx inside the parallel region (same pattern used
correctly in eeq.f90).
2. Race condition on self%nimg_max: Multiple threads wrote self%nimg_max =
max(nimg, self%nimg_max) simultaneously without synchronization.
Fixed with a local variable and reduction(max:nimg_max).
3. Missing termination in get_pairs do-loop: When all img translations
happen to be equidistant (e.g., in high-symmetry crystals), the loop would
exhaust all mask entries, then minloc with an all-false mask returns pos=0
(undefined per Fortran standard, gfortran returns 0), causing
dist(0) out-of-bounds. Fixed with if (iws >= img) exit guard.
The original symptom was the crash in the pbc testcase.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
===========================================
- Coverage 51.57% 30.68% -20.90%
===========================================
Files 18 2 -16
Lines 1648 176 -1472
Branches 746 72 -674
===========================================
- Hits 850 54 -796
+ Misses 390 85 -305
+ Partials 408 37 -371 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
The patch fixes three bugs in wignerseitz.f90:
The original symptom was the crash in the pbc testcase.