Fixlet to gadget writer and use std::string instead of char *

This commit is contained in:
Guilhem Lavaux 2013-03-07 09:39:10 -06:00
parent dc03871f37
commit 1dcdde7bf5
2 changed files with 8 additions and 6 deletions

View File

@ -274,10 +274,10 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id, int loadflags, i
void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
void CosmoTool::writeGadget(const std::string& fname, SimuData *data, int GadgetFormat)
{
UnformattedWrite *f;
int npart[6];
int npart[6], npartTotal[6];
float mass[6];
if (data->Pos[0] == 0 || data->Vel[0] == 0 || data->Id == 0)
@ -289,12 +289,12 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
for (int i = 0; i < 6; i++)
{
npart[i] = 0;
npart[i] = npartTotal[i] = 0;
mass[i] = 0;
}
mass[1] = 1.0;
npart[1] = data->NumPart;
npartTotal[1] = data->TotalNumPart;
f->beginCheckpoint();
for (int i = 0; i < 6; i++)
@ -308,7 +308,7 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
f->writeInt32(0);
for (int i = 0; i < 6; i++)
f->writeInt32(npart[i]);
f->writeInt32(npartTotal[i]);
f->writeInt32(0);
f->writeInt32(1);
f->writeReal64(data->BoxSize);

View File

@ -1,6 +1,8 @@
#ifndef __COSMO_LOAD_GADGET_HPP
#define __COSMO_LOAD_GADGET_HPP
#include <string>
#include "load_data.hpp"
#include "loadSimu.hpp"
@ -11,7 +13,7 @@ namespace CosmoTool {
SimuData *loadGadgetMulti(const char *fname, int id, int flags, int GadgetFormat = 1);
// Only single snapshot supported
void writeGadget(const char *fname, SimuData *data, int GadgetFormat = 1);
void writeGadget(const std::string& fname, SimuData *data, int GadgetFormat = 1);
};