Commit 34f48392 authored by jclamber's avatar jclamber

fix NEMO snapshots with different particles number

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@193 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 64d658bb
......@@ -66,6 +66,7 @@ CSnapshotNemoIn::CSnapshotNemoIn(const std::string _name,
eps = NULL;
last_nbody=0;
last_nemobits=-1;
reset_history();
initparam(const_cast<char**>(argv),const_cast<char**>(defv));
valid=isValidNemo();
}
......@@ -169,19 +170,26 @@ ComponentRangeVector * CSnapshotNemoIn::getSnapshotRange()
// nextFrame()
int CSnapshotNemoIn::nextFrame(uns::UserSelection &user_select)
{
const uns::t_indexes_tab * index_tab=user_select.getIndexesTab();
const int nsel=user_select.getNSel();
int status; // io_nemo status
std::string force_select = "all";
if (! first_stream) { // normal file or second reading (stream)
status=io_nemo(filename.c_str(),"float,read,sp,n,pos,vel,mass,dens,aux,acc,pot,key,e,t,st,b",
force_select.c_str(),&ionbody,&iopos,&iovel,&iomass,&iorho,&ioaux,&ioacc,&iopot,&iokeys,&ioeps,
&iotime, select_time.c_str(),&nemobits);
full_nbody = *ionbody;
crvs = getSnapshotRange();
user_select.setSelection(user_select.getSelection(),crvs);
} else { // "-" first stream, no need to read
first_stream=false;
status=status_ionemo; // status read the first time cf : isValid()
}
const uns::t_indexes_tab * index_tab=user_select.getIndexesTab();
const int nsel_loc=user_select.getNSel();
nsel = user_select.getNSel();
if (status == -1) { // Bad nemobits
PRINT("io_nemo status="<<status<<"\n";);
} else {
......@@ -245,12 +253,13 @@ int CSnapshotNemoIn::nextFrame(uns::UserSelection &user_select)
if ( *nemobits & KeyBit && (req_bits&KEYS_BIT || req_bits&ID_BIT)) keys[cpt] = iokeys[cpt];
if ( *nemobits & EpsBit && req_bits&EPS_BIT) eps[cpt] = ioeps[cpt];
cpt++;
assert(i<nsel_loc);
}
}
assert(nsel==cpt);
assert(nsel_loc==cpt);
}
}
if (nsel) ; // remove compiler warning
if (nsel_loc) ; // remove compiler warning
if (verbose) std::cerr << "CSnapshotNemoIn::nextFrame status = " << status << "\n";
if (status == -1) status=1;
return status;
......
......@@ -29,6 +29,7 @@ UserSelection::UserSelection()
nsel = 0;
indx = NULL;
pos = 0;
select = "";
}
// ============================================================================
// destructor
......
......@@ -38,6 +38,7 @@ public:
//const UserSelection& operator=(const UserSelection& m);
~UserSelection();
bool setSelection(const std::string,const ComponentRangeVector *, bool nodata=false);
std::string getSelection() { return select;}
const t_indexes_tab * getIndexesTab() const { return indx; }
int getNSel() const { return nsel ; }
static std::string parseString(std::string&);
......
......@@ -191,6 +191,10 @@ int main(int argc, char ** argv )
int maxlines = getiparam((char *) "maxline" );
char * select_t = getparam ((char *) "times" );
bool verbose = getbparam((char *) "verbose" );
if (verbose) {
std::cerr << "UNSIO version ="<<uns::VERSION<< "\n";
}
// -----------------------------------------------
// instantiate a new UNS input object (for reading)
......
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