Commit 0602c9bb authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

fix bug when too big number of particles (int) vs (unsigned int)

parent cce9606e
...@@ -243,11 +243,12 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection ...@@ -243,11 +243,12 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection
std::cerr << "ASSERT fails i="<<i<<" icomp="<<icomp<<"\n"; std::cerr << "ASSERT fails i="<<i<<" icomp="<<icomp<<"\n";
} }
assert(icomp==0 ||icomp==1 || icomp==4); // gas || halo || stars only assert(icomp==0 ||icomp==1 || icomp==4); // gas || halo || stars only
int istart=offset_comp[icomp]; // index start in the new pos array assert(offset_comp[icomp]>=0);
unsigned int istart=offset_comp[icomp]; // index start in the new pos array
// positions // positions
if (particles->pos.size()>0) { if (particles->pos.size()>0) {
assert((istart*3)+2<(int)particles->pos.size()); assert((istart*3)+2<(unsigned int)particles->pos.size());
found=true; found=true;
pos[istart*3+0] = particles->pos[i*3+0]; // x pos[istart*3+0] = particles->pos[i*3+0]; // x
pos[istart*3+1] = particles->pos[i*3+1]; // y pos[istart*3+1] = particles->pos[i*3+1]; // y
...@@ -256,7 +257,7 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection ...@@ -256,7 +257,7 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection
// velocities // velocities
if (particles->vel.size()>0) { if (particles->vel.size()>0) {
assert((istart*3)+2<(int)particles->vel.size()); assert((istart*3)+2<(unsigned int)particles->vel.size());
found=true; found=true;
vel[istart*3+0] = particles->vel[i*3+0]; // x vel[istart*3+0] = particles->vel[i*3+0]; // x
vel[istart*3+1] = particles->vel[i*3+1]; // y vel[istart*3+1] = particles->vel[i*3+1]; // y
...@@ -265,23 +266,23 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection ...@@ -265,23 +266,23 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection
// masses // masses
if (particles->mass.size()>0) { if (particles->mass.size()>0) {
assert(istart<(int)particles->mass.size()); assert(istart<(unsigned int)particles->mass.size());
found=true; found=true;
mass[istart] = particles->mass[i]; mass[istart] = particles->mass[i];
} }
// id // id
if (particles->id.size()>0) { if (particles->id.size()>0) {
assert(istart<(int)particles->id.size()); assert(istart<(unsigned int)particles->id.size());
found=true; found=true;
id[istart] = particles->id[i]; id[istart] = particles->id[i];
} }
// metal // metal
if (particles->metal.size()>0) { // && (icomp==0 || icomp==4)) { // metal for gas or stars if (particles->metal.size()>0) { // && (icomp==0 || icomp==4)) { // metal for gas or stars
if (!(istart<(int)particles->metal.size())) { if (!(istart<(unsigned int)particles->metal.size())) {
std::cerr << " istart ="<<istart<< " metal.size ="<< particles->metal.size() << "\n"; std::cerr << " istart ="<<istart<< " metal.size ="<< particles->metal.size() << "\n";
} }
assert(istart<(int)particles->metal.size()); assert(istart<(unsigned int)particles->metal.size());
found=true; found=true;
metal[istart] = particles->metal[i]; metal[istart] = particles->metal[i];
} }
......
...@@ -651,7 +651,7 @@ void uns_get_interface_type_(const int * id, char * dest, int lenstring) ...@@ -651,7 +651,7 @@ void uns_get_interface_type_(const int * id, char * dest, int lenstring)
// return the Component Range Vector belonging to the UNS's object "index" // return the Component Range Vector belonging to the UNS's object "index"
void getCrv(int index) void getCrv(int index)
{ {
assert(index<(int)unsv.size()); assert(index<(unsigned int)unsv.size());
crv = ((CunsIn2<float>*)unsv[index].obj)->snapshot->getSnapshotRange(); crv = ((CunsIn2<float>*)unsv[index].obj)->snapshot->getSnapshotRange();
//ComponentRange::list(crv); //ComponentRange::list(crv);
} }
......
...@@ -232,7 +232,7 @@ int UserSelection::isComponent(const std::string comp) ...@@ -232,7 +232,7 @@ int UserSelection::isComponent(const std::string comp)
int offset; int offset;
int icrv=ComponentRange::getIndexMatchType(crv,type,offset); int icrv=ComponentRange::getIndexMatchType(crv,type,offset);
if (icrv != -1 && !nodata) { if (icrv != -1 && !nodata) {
assert(icrv<(int)crv->size()); assert((unsigned int) icrv<crv->size());
comp_bits |= tools::Ctools::compBits(type); comp_bits |= tools::Ctools::compBits(type);
first=(*crv)[icrv].first; first=(*crv)[icrv].first;
last =(*crv)[icrv].last; last =(*crv)[icrv].last;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment