Open iljah opened 8 years ago
The (triple) for loop is closed by the single curly braces, this is fully intentional.
However the block after the for loops should be two levels back. Either it was badly formatted or a clever automatic indentation tool in some text editor fooled me.
But they stop before result is assigned, also intentional? Similar thing in https://github.com/fmihpc/vlasiator/blob/master/projects/Harris/Harris.cpp#L90 and in https://github.com/fmihpc/vlasiator/blob/master/projects/Magnetosphere/Magnetosphere.cpp#L184 and in https://github.com/fmihpc/vlasiator/blob/master/projects/Riemann1/Riemann1.cpp#L108
Huh? Returns after the curly braces which close the for loop stack. Perfectly fine code. One /could/ pove the block back 5 levels but it'd look weird. I fashioned it this way since the for loops are one-liners.
But if you have time to spare/waste on fixing these two, please do. If I touch the code there some time I might remember to do it. These work as intended so it's not a problem. If your futuristic compiler finds actual bugs due to misleading indentation (we have had some, so it's well possible), then let us know however.
Currently the code looks as if the thing which gcc complains about would be executed more than one time. If the code is supposed to be outside of for loops why is it indented as if it should be inside? I'll document all the occuring instances before fixing them...
There is curly braces however to avoid the reader being misled. I agree the indentation is not as clean as could be, but this is not high on my task list at the moment.
As far as I can see it is intentional and code is correct. To be honest there are a few inconsistencies:
The line is commented out, I didn't even see it. ;) This looks like a remnant of actually 2D simulations, but in any case could/should be taken out.
The easiest way to fix this, and other indentation & style issues is to create an astyle with the correct style for Vlasiator, and run it on the whole source code.
Same setup as in #235, here's an example of new functionality in GCC:
result in https://github.com/fmihpc/vlasiator/blob/master/projects/Dispersion/Dispersion.cpp#L147 is only executed once as fas as I can see