Commit 30ca6d0a authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

improve header I/O

parent d91b410a
......@@ -63,8 +63,6 @@ class CUNS_OUT:
if not self.__is_valid:
raise RuntimeError("CUNS_OUT is not valid")
if self.__verbose_debug:
print("setData : [select=%s, tag=%s]"%(select,tag))
ok=0
if tag is None: # only one value
tab_value_F=["time"]
......@@ -73,12 +71,15 @@ class CUNS_OUT:
ok=self.__uns.setValueI(select,data_array)
else:
ok=self.__uns.setValueF(select,data_array)
print(ok)
else:
if tag != "id": #not id, then we save float arrays
ok = self.__uns.setArrayF(select,tag,data_array)
else: # save id's array of integers
ok = self.__uns.setArrayI(select,tag,data_array)
if self.__verbose_debug:
print("setData : [select=%s, tag=%s, ok=%d ]"%(select,tag,ok))
return ok
# -----------------------------------------------------
......
......@@ -370,9 +370,11 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
}
if (ngrida>0) {
// Loop over cells
for (int ind=0;ind<twotondim;ind++) {
// Store data cube
//for (int ind=0;ind<twotondim;ind++) {
for (int i=0;i<ngrida;i++) {
// Store data cube
//for (int i=0;i<ngrida;i++) {
for (int ind=0;ind<twotondim;ind++) {
// compute cell center
double px=xg[0*ngrida+i]+xc[0][ind]-xbound[0]; // x
double py=xg[1*ngrida+i]+xc[1][ind]-xbound[1]; // y
......@@ -491,7 +493,8 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
}
// particles ID
if (req_bits&ID_BIT) {
particles->id.push_back(-1.); // no id for gas, use "-1"
//particles->id.push_back(-1.); // no id for gas, use "-1"
particles->id.push_back(-1.*(((particles->ngas+1)*(ncpu-1)+icpu+1))); // no id for gas, use "-1"
particles->load_bits |= ID_BIT;
}
if (take|| !req_bits) { // !req_bits for uns_info and display=f
......
......@@ -816,7 +816,6 @@ int CSnapshotGadgetIn<T>::readHeader(const int id)
t_header.Omega0 = (T) header.Omega0;
t_header.OmegaLambda = (T) header.OmegaLambda;
t_header.HubbleParam = (T) header.HubbleParam;
//std::cerr << "len1="<<len1<< " len2="<<len2<< " bytes_counter="<<bytes_counter<<"\n";
if (in.bad() || len1!=len2 || len1!=bytes_counter)
return 2;
......@@ -1394,7 +1393,7 @@ template <class T> bool CSnapshotGadgetIn<T>::getHeader(const std::string name,
{
std::string nameupper = tools::Ctools::toupper(name);
status = false;
bool status = false;
if (nameupper=="BOXLEN" || nameupper=="BOXSIZE") {
*data= (T) t_header.BoxSize;
......@@ -2210,9 +2209,14 @@ int CSnapshotGadgetOut<T>::setHeader(std::string tag, T data)
header.redshift=data;
ok=1;
}
if (nameupper=="FLAGSFR") {
header.flag_sfr=(int) data;
ok=1;
}
if (nameupper=="BOXLEN" || nameupper=="BOXSIZE") {
header.BoxSize=data;
ok=1;
header.BoxSize=data;
ok=1;
}
if (nameupper=="OMEGA_M" || nameupper=="OMEGA0") {
header.Omega0=data;
......
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