Commit e0879a28 authored by jclamber's avatar jclamber

add STREAMING data reading for gadget files. Abort when trying to save an existing NEMO file

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@223 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 112130cf
......@@ -56,56 +56,56 @@ def printAndSaveProp(uns,unso,comp):
# return a 1D numpy data array with mass
ok,mass=uns.getArrayF(comp,"mass")
if ok:
print "mass =",mass
print "mass =",mass.size, type(mass)
unso.setArrayF(comp,"mass",mass) # save mass
# return a 1D numpy data array with pos
ok,pos=uns.getArrayF(comp,"pos")
if ok:
print "pos =",pos
print "pos ="#,pos
unso.setArrayF(comp,"pos",pos) # save pos
# return a 1D numpy data array with vel
ok,vel=uns.getArrayF(comp,"vel")
if ok:
print "vel =",vel
print "vel ="#,vel
unso.setArrayF(comp,"vel",vel) # save vel
# return a 1D numpy data array with rho
ok,rho=uns.getArrayF(comp,"rho")
if ok:
print "rho =",rho
print "rho ="#,rho
unso.setArrayF(comp,"rho",rho) # save rho
# return a 1D numpy data array with temperature
ok,temp=uns.getArrayF(comp,"temp")
if ok:
print "temp =",temp
print "temp ="#,temp
unso.setArrayF(comp,"temp",temp) # save temperature
# return a 1D numpy data array with hsml
ok,hsml=uns.getArrayF(comp,"hsml")
if ok:
print "hsml =",hsml
print "hsml ="#,hsml
unso.setArrayF(comp,"hsml",hsml) # save hsml
# return a 1D numpy data array with particles age
ok,age=uns.getArrayF(comp,"age")
if ok:
print "age =",age
print "age ="#,age
unso.setArrayF(comp,"age",age) # save age
# return a 1D numpy data array with mettalicity
ok,metal=uns.getArrayF(comp,"metal")
if ok:
print "metal =",metal
print "metal ="#,metal
unso.setArrayF(comp,"metal",metal) # save mettalicity
# return a 1D numy data array with id
ok,indexes=uns.getArrayI(comp,"id")
if ok:
print "indexes =", indexes
print "indexes ="#, indexes
unso.setArrayI(comp,"id",indexes) # save id
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -933,11 +933,15 @@ bool CSnapshotGadgetIn::getData(const std::string comp, std::string name, int *n
*n = 0;
int nbody,first,last;
bool status=getRangeSelect(comp.c_str(),&nbody,&first,&last,false); // find components ranges
if (!status && comp=="all") { // retreive all particles selected by the user
status=1;
first=0;
nbody=getNSel();
bool status=false;
if (comp!="STREAM") {
status=getRangeSelect(comp.c_str(),&nbody,&first,&last,false); // find components ranges
if (!status && comp=="all") { // retreive all particles selected by the user
status=1;
first=0;
nbody=getNSel();
}
}
switch(CunsOut::s_mapStringValues[name]) {
case uns::Nbody :
......
......@@ -853,8 +853,14 @@ int CSnapshotNemoOut::save()
int * n = &nbody;
float * t = &time;
int * b = &bits;
int status=io_nemo(simname.c_str(),"float,save,n,t,x,v,m,p,a,aux,k,dens,e,b",
&n,&t,&pos,&vel,&mass,&pot,&acc,&aux,&keys,&rho,&eps,&b);
int status=0;
if (simname=="-" || (simname!="-" && !tools::Ctools::isFileExist(simname))) {
status=io_nemo(simname.c_str(),"float,save,n,t,x,v,m,p,a,aux,k,dens,e,b",
&n,&t,&pos,&vel,&mass,&pot,&acc,&aux,&keys,&rho,&eps,&b);
} else {
std::cerr << "\n\nfile ["<<simname<<"] exist, NEMO output cannot overwrite files, please remove it !!!\nAborting...\n\n";
std::exit(0);
}
if (status!=0) {
is_saved=true;
}
......
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