diff --git a/mmakefile b/mmakefile index a022c9bb3a77651e533b841522e6db4fcce012fa..292ffd1824dd73b627eaa6912a9a30eb60d9f503 100644 --- a/mmakefile +++ b/mmakefile @@ -1,7 +1,8 @@ # nemocvs: - rsync -CRav --exclude-from=exclude.txt build/CMakeLists.txt build/FindNEMO.cmake . ${NEMO}/usr/jcl/unsio + rsync -CRav --exclude-from=exclude.txt CMakeLists.txt INSTALL LICENSE 3rdparty cmake man src template test_src ${NEMO}/usr/jcl/unsio + tar : cd ..;tar czhvf unsio/unsio-`date "+%d%b-%Y-%H.%M"`.tar.gz `ls unsio/src/*.{f,F,cc,h} unsio/test_src/*.{f,F,cc,h} unsio/CMakeLists.txt unsio/cmake/*.cmake unsio/doc/*.{odp,pdf,txt} unsio/INSTALL unsio/mmakefile unsio/man/man3/* unsio/3rdparty/nemolight/build/CMakeLists.txt unsio/3rdparty/nemolight/src/*.{c,h} unsio/3rdparty/nemolight/src/inc/*.{c,h} unsio/3rdparty/nemolight/src/inc/snapshot/*.{c,h} unsio/3rdparty/nemolight/src/fortran_old_gcc/*.{c,h} unsio/template/uns_devel/cmake/*.cmake unsio/template/uns_devel/README unsio/template/uns_devel/CMakeLists.txt unsio/template/uns_devel/src/*.{c,cc,F} unsio/template/uns_devel/lib/src/*.{c,cc,F} 2> /dev/null` diff --git a/src/camr.cc b/src/camr.cc index 776d44a093c60de8f3503e1059e0f21200a86a88..d1af52e41d8cbdb739de34e6b953e50448169332 100644 --- a/src/camr.cc +++ b/src/camr.cc @@ -354,11 +354,16 @@ int CAmr::loadData(uns::CParticles * particles, particles->rho.push_back(rho); // rho var(i,ind,1) * scale_nH particles->load_bits |= RHO_BIT; } - if (req_bits&TEMP_BIT) { + if (req_bits&TEMP_BIT && nvarh>4) { float temp= std::max(0.0,var[4*ngrida*twotondim+ind*ngrida+i]/rho); particles->temp.push_back(temp); particles->load_bits |= TEMP_BIT; } + if (req_bits&METAL_BIT && nvarh>5) { + float metal= var[5*ngrida*twotondim+ind*ngrida+i]; + particles->metal.push_back(metal); + particles->load_bits |= METAL_BIT; + } if (take) { particles->indexes.push_back(0); // GAS particles particles->ngas++; // One more gas particles diff --git a/src/cfortio.h b/src/cfortio.h index 9c97f12413f902631c5b7ac29a0590e5d1241d68..3347b3cabfcd9d7ab42a507b1e7860cb323548a7 100644 --- a/src/cfortio.h +++ b/src/cfortio.h @@ -31,13 +31,14 @@ public: bool good() { if (!fake_reading) return in.good(); else return true;} - inline int readDataBlock(char * ptr) { + inline int readDataBlock(char * ptr, bool abort=true) { if (!fake_reading) { - int len1=readFRecord(); + int len1=readFRecord(abort); readData(ptr,1,len1); - int len2=readFRecord(); + int len2=readFRecord(abort); if (len2==len1) ; // remove warning.... - assert(good() && len1==len2); + if (abort) + assert(good() && len1==len2); return len1; } else return 1; } @@ -60,14 +61,18 @@ public: } // read fortran record - inline int readFRecord() { + inline int readFRecord(bool abort=true) { if (!fake_reading) { int len; in.read((char *) &len,sizeof(int)); // We SWAP data if (swap) { // swapping requested swapBytes(&len,sizeof(int)); } - assert(in.good()); + if (abort) + assert(in.good()); + else { + if (! in.good()) len=0; + } return len; } else return 1; diff --git a/src/cpart.cc b/src/cpart.cc index 98262e79bbd34fee29daf2616376eecd9dc237bc..5029f7e47514b7e41e78c6a91845898349081756 100644 --- a/src/cpart.cc +++ b/src/cpart.cc @@ -115,12 +115,21 @@ int CPart::loadData(uns::CParticles * particles, // read masses tmp[6] = new double[npart]; // alloc part.readDataBlock((char *) tmp[6]); - double * agetmp; + double * agetmp, * metaltmp; if (nstar>0) { // || 1) { // there are stars part.skipBlock(); // skip identity part.skipBlock(); // skip level agetmp = new double[npart]; part.readDataBlock((char *) agetmp); + + bool found_metal=false; + if (req_bits&METAL_BIT) { + metaltmp = new double[npart]; + int status=part.readDataBlock((char *) metaltmp, false); + if (status) found_metal=true; + std::cerr << "Metalicity status =" << status << "\n"; + + } for (int k=0; kload_bits |= MASS_BIT; take=true; } - if (agetmp[k]!=0 && req_bits&AGE_BIT) { // stars only + if (agetmp[k]!=0 && req_bits&AGE_BIT) { // stars only (age) particles->age.push_back(agetmp[k]); particles->load_bits |= AGE_BIT; } + if (agetmp[k]!=0 && req_bits&METAL_BIT && found_metal) { // stars only (metallicity) + particles->metal.push_back(metaltmp[k]); + particles->load_bits |= METAL_BIT; + } if (take && agetmp[k]!=0) { particles->indexes.push_back(4); // save star positions particles->nstars++; @@ -167,6 +180,9 @@ int CPart::loadData(uns::CParticles * particles, } // garbage delete [] agetmp; + if (req_bits&METAL_BIT) { + delete [] metaltmp; + } } else { // there are no stars if (comp_bits&HALO_BIT) { // DM sel diff --git a/src/snapshotramses.cc b/src/snapshotramses.cc index 39a21b665a5398dd2ff22e2b284418bf859b1f22..f33e85ad485042c32b6ce8d5b0e40977f5e9bcde 100644 --- a/src/snapshotramses.cc +++ b/src/snapshotramses.cc @@ -210,13 +210,15 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select) // particles reordering if (particles->ntot) { // exist particles to reorder - std::vector pos,vel,mass; + std::vector pos,vel,mass,metal; if (particles->pos.size()>0) - pos.resize(particles->pos.size()); // resize new pos vector + pos.resize(particles->pos.size()); // resize new pos vector if (particles->vel.size()>0) - vel.resize(particles->vel.size()); // resize new pos vector + vel.resize(particles->vel.size()); // resize new pos vector if (particles->mass.size()>0) - mass.resize(particles->mass.size()); // resize new mass vector + mass.resize(particles->mass.size()); // resize new mass vector + if (particles->metal.size()>0) + metal.resize(particles->metal.size()); // resize new metal vector for (int i=0; intot; i++) { @@ -251,6 +253,13 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select) mass[istart] = particles->mass[i]; } + // metal + if (particles->metal.size()>0 && (icomp==0 || icomp==4)) { // metal for gas or stars + assert(istart<(int)particles->metal.size()); + found=true; + metal[istart] = particles->metal[i]; + } + if (found) { // found particles offset_comp[icomp]++; // update offset } @@ -259,6 +268,7 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select) particles->pos=pos; particles->vel=vel; particles->mass=mass; + particles->metal=metal; } return 1; } diff --git a/src/snapshotramses.h b/src/snapshotramses.h index 0be3fe22313d20de5ede2e4de9b3ded6299000b4..8d444c3310b7e36c697ffdde8cccc9292f6756ef 100644 --- a/src/snapshotramses.h +++ b/src/snapshotramses.h @@ -31,7 +31,7 @@ public: ntot=ngas=ndm,nstars=0; load_bits=0; } - std::vector pos,vel,mass,hsml,rho,temp,age; + std::vector pos,vel,mass,hsml,rho,temp,age,metal; std::vector indexes; int ntot, ngas, ndm, nstars; unsigned int load_bits;