Fixed gadget file writing.
This commit is contained in:
parent
58203422a7
commit
6035eaec4d
@ -343,3 +343,12 @@ void UnformattedWrite::writeInt64(int64_t i)
|
|||||||
a.i = i;
|
a.i = i;
|
||||||
writeOrderedBuffer(&a, 8);
|
writeOrderedBuffer(&a, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnformattedWrite::writeInt8(int8_t i)
|
||||||
|
throw (FilesystemFullException)
|
||||||
|
{
|
||||||
|
union { char b; int8_t i; } a;
|
||||||
|
|
||||||
|
a.i = i;
|
||||||
|
writeOrderedBuffer(&a, 1);
|
||||||
|
}
|
||||||
|
@ -94,7 +94,11 @@ namespace CosmoTool
|
|||||||
throw (FilesystemFullException);
|
throw (FilesystemFullException);
|
||||||
void writeInt64(int64_t i)
|
void writeInt64(int64_t i)
|
||||||
throw (FilesystemFullException);
|
throw (FilesystemFullException);
|
||||||
|
void writeInt8(int8_t c)
|
||||||
|
throw (FilesystemFullException);
|
||||||
|
|
||||||
|
void writeOrderedBuffer(void *buffer, int size)
|
||||||
|
throw(FilesystemFullException);
|
||||||
protected:
|
protected:
|
||||||
bool swapOrdering;
|
bool swapOrdering;
|
||||||
CheckpointSize cSize;
|
CheckpointSize cSize;
|
||||||
@ -102,8 +106,6 @@ namespace CosmoTool
|
|||||||
uint64_t checkPointAccum;
|
uint64_t checkPointAccum;
|
||||||
std::ofstream *f;
|
std::ofstream *f;
|
||||||
|
|
||||||
void writeOrderedBuffer(void *buffer, int size)
|
|
||||||
throw(FilesystemFullException);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -292,6 +292,7 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
|
|||||||
npart[i] = 0;
|
npart[i] = 0;
|
||||||
mass[i] = 0;
|
mass[i] = 0;
|
||||||
}
|
}
|
||||||
|
mass[1] = 1.0;
|
||||||
|
|
||||||
npart[1] = data->NumPart;
|
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_M);
|
||||||
f->writeReal64(data->Omega_Lambda);
|
f->writeReal64(data->Omega_Lambda);
|
||||||
f->writeReal64(data->Hubble);
|
f->writeReal64(data->Hubble);
|
||||||
|
char buf[100] = { 0, };
|
||||||
|
f->writeOrderedBuffer(buf, 96);
|
||||||
f->endCheckpoint();
|
f->endCheckpoint();
|
||||||
|
|
||||||
f->beginCheckpoint();
|
f->beginCheckpoint();
|
||||||
@ -337,9 +340,10 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
|
|||||||
f->beginCheckpoint();
|
f->beginCheckpoint();
|
||||||
for(int n = 0; n < data->NumPart; n++)
|
for(int n = 0; n < data->NumPart; n++)
|
||||||
{
|
{
|
||||||
f->writeReal32(data->Id[n]);
|
f->writeInt32(data->Id[n]);
|
||||||
}
|
}
|
||||||
f->endCheckpoint();
|
f->endCheckpoint();
|
||||||
|
delete f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user