Fixed gadget file writing.

This commit is contained in:
Guilhem Lavaux 2012-04-01 17:49:19 -05:00
parent 58203422a7
commit 6035eaec4d
3 changed files with 18 additions and 3 deletions

View File

@ -343,3 +343,12 @@ void UnformattedWrite::writeInt64(int64_t i)
a.i = i;
writeOrderedBuffer(&a, 8);
}
void UnformattedWrite::writeInt8(int8_t i)
throw (FilesystemFullException)
{
union { char b; int8_t i; } a;
a.i = i;
writeOrderedBuffer(&a, 1);
}

View File

@ -94,7 +94,11 @@ namespace CosmoTool
throw (FilesystemFullException);
void writeInt64(int64_t i)
throw (FilesystemFullException);
void writeInt8(int8_t c)
throw (FilesystemFullException);
void writeOrderedBuffer(void *buffer, int size)
throw(FilesystemFullException);
protected:
bool swapOrdering;
CheckpointSize cSize;
@ -102,8 +106,6 @@ namespace CosmoTool
uint64_t checkPointAccum;
std::ofstream *f;
void writeOrderedBuffer(void *buffer, int size)
throw(FilesystemFullException);
};
};

View File

@ -292,6 +292,7 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
npart[i] = 0;
mass[i] = 0;
}
mass[1] = 1.0;
npart[1] = data->NumPart;
@ -314,6 +315,8 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
f->writeReal64(data->Omega_M);
f->writeReal64(data->Omega_Lambda);
f->writeReal64(data->Hubble);
char buf[100] = { 0, };
f->writeOrderedBuffer(buf, 96);
f->endCheckpoint();
f->beginCheckpoint();
@ -337,9 +340,10 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
f->beginCheckpoint();
for(int n = 0; n < data->NumPart; n++)
{
f->writeReal32(data->Id[n]);
f->writeInt32(data->Id[n]);
}
f->endCheckpoint();
delete f;
}