<div dir="ltr"><div><div><div>Dear Klaus,<br><br></div> After reading your explanations, I think B+B' (each section makes no assumptions) seems to be the most reasonable approach. It doesn't require any rewrite of sections that implement particle sorting at the beginning of the module like Particles_advance (and most other modules). Also it seems reasonable that those modifying the code (like me) have the burden to arrange the particles as needed, since different modules might require different types of sorting. <br><br> I think it would be reasonable to include a warning for this in the User Guide in sections 8.9 (GridParticles, which describes the three different sorting methods) and in the Particles section itself in section 19. Also it would be helpful to have this warning in the notes section of the subroutine Grid_sortParticles.F90 since anyone who starts grepping around the code to figure out how the particles are sorted will likely go there first (that's the first place I went at least). <br><br> I think this should be sufficient to avoid diversions of the type graduate students are prone to. I appreciate the chance to have input on the code which I've been lucky to work with and on, and I should say I'm sure others on the list may have even better ideas on this than myself.<br><br></div>Cordially,<br><br></div>Josh<br><br><div class="gmail_quote"><div dir="ltr">On Fri, Apr 28, 2017 at 2:08 PM Klaus Weide <<a href="mailto:klaus@flash.uchicago.edu" target="_blank">klaus@flash.uchicago.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, 27 Apr 2017, Joshua Wall wrote:<br>
<br>
> I have found a second assumption in Flash that while not a bug<br>
> directly, can cause problems for users who are introducing their own<br>
> routines for particles that are not contained in Particles_advance.F90. It<br>
> has caused me some amount of headache to track down, so I feel it best to<br>
> at least get it documented on the email archive.<br>
.....<br>
> Hopefully if no change is made at least this helps others with the same<br>
> problem.<br>
<br>
Josh,<br>
<br>
Thank you for sharing this warning for others!<br>
<br>
1. I would appreciate any suggested wording for NOTES or warnings in the<br>
code (and where to put them) (ideally in the form of diffs!), or for some<br>
text to be added in an appropriate place in the Users Guide.<br>
<br>
You probably have a very good idea what kind of warning would have saved<br>
you all that headache!<br>
<br>
<br>
2. Some more general discussion -<br>
<br>
<br>
It appears that one of the following three must be true:<br>
<br>
(A) i. Sections of code that deal with particles in FLASH (while particles<br>
are in a "settled" state, i.e., not in the middle of being transferred<br>
etc.) are allowed to assume that the particles array is sorted in a<br>
particular way.<br>
<br>
ii. Sections of code that may change the order of particles in the<br>
array must clean up after themselves, probably by calling<br>
Grid_sortParticles.<br>
<br>
(B) i. Sections of code that deal with particles in FLASH must not make any<br>
assumptions about the ordering of the particles array. If they require<br>
a particular ordering to operate correctly, they are responsible for<br>
establishing that ordering, probably by calling Grid_sortParticles.<br>
<br>
ii. Sections of code that may change the order of particles in the<br>
array are not required to restore any particular order.<br>
<br>
(C) Something intermediate, ad hoc, muddled.<br>
<br>
Additionally, a similar (but not independent) choice exists for who is<br>
responsible for keeping pt_typeInfo valid. Let's call the corresponding<br>
alternatives (A'), (B'), (C').<br>
<br>
It seems to me that in general the FLASH code assumes (B)+(B'), although<br>
there may be omissions. [New code written with an abundance of caution<br>
could combine (B)i+(A)ii+(B')i+(A')ii...]<br>
<br>
Can we agree that these should be the rules of the road for dealing with<br>
particles in the FLASH code?<br>
<br>
If yes, how can this be made clearer?<br>
<br>
<br>
This should not prevent a more sophisticated approach being implemented in<br>
the future, to prevent unnecessarily repeated sorting.<br>
<br>
<br>
Klaus<br>
</blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div><div><div><div>Joshua Wall<br></div>Doctoral Candidate<br></div>Department of Physics<br></div>Drexel University<br></div>3141 Chestnut Street<br></div>Philadelphia, PA 19104<br></div></div>