-
Notifications
You must be signed in to change notification settings - Fork 44
Bug fix: update pairMap only in case of primary beam particles #1050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Yeah, I added the check on 0 to catch such issues. Thanks for thje fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. I'd suggest dropping the F77 syntax though.
Note that this is not a complete fix. If you want to enable postpr for FLUKA integration jobs, 0 entries will blow up there. That's where I added the checks. |
Just a note on code style: I never found a proper code style for Fortran, but I've generally followed the Python one where it can be applied. It would probably be useful to write one up based on PEP 8 and remove the bits that don't apply. I've generally tried to stay withing 120 character lines though, as opposed to PEP 8 recommendation of 79, or alternatively, 99. Another thing from coding styles: There should be spaces around assignment and logical operators, as well as + and -, but not * and /. This is something @rdemaria and I have discussed a few times in the past, but I never got around to it. |
Good point - I have removed the use of Just to check -- If I correctly understand, the
Yes, I agree with you. In particular, the recommendation of 79 chars on a single line is practically useless - it helps in having many windows or sub-windows of text editors side by side, but it messes up reading complex lines |
parID depends on what you implement. The coupling code should probably assign a pairID I suppose? I don't know if that makes sense or not.
Well, the PEP8 standard only requires 79 characters for docstrings in function headers, and is flexible on code lines with a maximum of 99. For Python, that actually works quite well, and I tend to follow these rules. For Fortran, I generally had 100 characters as an ideal length, and 120 as a maximum. But I do think 120 should be the limit for PR readability. Text is generally more readable if shorter. Anyway, added a feature issue #1051 for this topic. |
As written in my comment, I still had a couple of changes to push, but I was waiting to compile once the code, and I had to wait the long tests on my machine to be over... |
No, I think that it makes no sense to try to assign secondary particles to couples - the concept of couples belongs to DA studies, where beam particles are of interest, not secondary particles out of inelastic interactions. |
Oops, my fault for poking riccardo about it |
My apologies, I thought it was completed! Please just reopen a new PR... |
sure, no worries :) |
My point was to assign them anyway to prevent out of bounds errors and garbage values from memory in the analysis. I added checks to catch this to avoid exactly this. Running PostPR on secondaries will therefore hit my bug trap, as intended. A more sensible solution may be to just filter out secondaries of course and skip them in the loops. Either way, one of these approaches need to be implemented. |
In case secondary particles are injected in the tracking arrays,
pairID
andpairMap
arrays are extended, with an initialisation to 0. This leads theupdatePairMap
subroutine to crash, aspairMap(0,0)
would be updated for all secondary particles, out of bounds.The fix is simple, i.e. to update the
pairMap
only for what concerns primary particles. ThepairMap
is anyway regularly expanded to keep the reshuffling algorithm smooth, without may exceptions.Thanks to @JamesMolson for spotting the problem, in the context of the Fluka-SixTrack coupling.