Fix reading multibunch injection file *-onebunch.h5
Merge request reports
Activity
mentioned in commit 08370c50
1721 throw OpalException("ParallelCyclotronTracker::readOneBunchFromFile()", 1722 "No particles in file " + onebunch_m + "."); 1723 } 1719 1724 1720 long numParticles = dataSource.getNumParticles(); 1721 1725 size_t numParticlesPerNode = numParticles / Ippl::getNodes(); 1722 1726 1723 1727 size_t firstParticle = numParticlesPerNode * Ippl::myNode(); 1724 1728 size_t lastParticle = firstParticle + numParticlesPerNode - 1; 1725 1729 if (Ippl::myNode() == Ippl::getNodes() - 1) 1726 1730 lastParticle = numParticles - 1; 1727 1731 1728 1732 numParticles = lastParticle - firstParticle + 1; 1733 1729 1734 PAssert_GE(numParticles, 0l); Yes, this line, 1734. The inequality
numParticles>=0l
will always be true. Not sure if it should be replaced by something else. The compiler full warning:home/scratch/OPAL/src/src/Algorithms/ParallelCyclotronTracker.cpp: In member function ‘bool ParallelCyclotronTracker::readOneBunchFromFile(size_t)’: /home/scratch/OPAL/src/ippl/src/Utility/PAssert.h:124:40: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] #define PAssert_GE(a, b) PAssert_CMP(a >= b, a, b) ^ /home/scratch/OPAL/src/ippl/src/Utility/PAssert.h:118:38: note: in definition of macro ‘PAssert_CMP’ #define PAssert_CMP(cmp, a, b) if (!(cmp)) toss_cookies(#cmp, #a, #b, a, b, __F ^ /home/scratch/OPAL/src/src/Algorithms/ParallelCyclotronTracker.cpp:1734:5: note: in expansion of macro ‘PAssert_GE’ PAssert_GE(numParticles, 0l); ^
Up to you. numParticles is redefined in line 1732 (to the number of particles in the node). So in theory it could make sense to check two times. But from the logic I would think that the calculation in line 1732 can't be negative (or have an overflow), so one could remove line 1734 I think.
I removed it (see c6253ca8).
I can add this check but
lastParticle
cannot be smaller (equal) thanfirstParticle
size_t firstParticle = numParticlesPerNode * Ippl::myNode(); size_t lastParticle = firstParticle + numParticlesPerNode - 1;
So just to be safe 7fc28948
@snuverink_j I fixed the underscore bug in the assert. So, the master compiles fine again.