Skip to content
Snippets Groups Projects
Commit 2ed7e717 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Better style in single_io.c

parent 6acdaca9
Branches
Tags
2 merge requests!136Master,!116Basic implementation of gparts
...@@ -459,23 +459,21 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts, ...@@ -459,23 +459,21 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts,
*/ */
void write_output_single(struct engine* e, struct UnitSystem* us) { void write_output_single(struct engine* e, struct UnitSystem* us) {
hid_t h_file = 0, h_grp = 0, h_grpsph = 0; hid_t h_file = 0, h_grp = 0;
const size_t Ngas = e->s->nr_parts; const size_t Ngas = e->s->nr_parts;
const size_t Ntot = e->s->nr_gparts; const size_t Ntot = e->s->nr_gparts;
int periodic = e->s->periodic; int periodic = e->s->periodic;
int numFiles = 1; int numFiles = 1;
struct part* parts = e->s->parts; struct part* parts = e->s->parts;
struct gpart* gparts = e->s->gparts; struct gpart* gparts = e->s->gparts;
struct gpart* dmparts = NULL;
FILE* xmfFile = 0;
static int outputCount = 0; static int outputCount = 0;
/* Number of particles of each type */ /* Number of particles of each type */
const size_t Ndm = Ntot - Ngas; const size_t Ndm = Ntot - Ngas;
int numParticles[NUM_PARTICLE_TYPES] = {Ngas, Ndm, int numParticles[NUM_PARTICLE_TYPES] = /* Gadget-2 convention here */
0}; /* Gadget-2 convention here */ {Ngas, Ndm, 0}; /* Could use size_t instead */
int numParticlesHighWord[NUM_PARTICLE_TYPES] = { int numParticlesHighWord[NUM_PARTICLE_TYPES] =
0}; /* Could use size_t instead */ {0};
/* File name */ /* File name */
char fileName[FILENAME_BUFFER_SIZE]; char fileName[FILENAME_BUFFER_SIZE];
...@@ -485,6 +483,7 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { ...@@ -485,6 +483,7 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
if (outputCount == 0) createXMFfile(); if (outputCount == 0) createXMFfile();
/* Prepare the XMF file for the new entry */ /* Prepare the XMF file for the new entry */
FILE* xmfFile = 0;
xmfFile = prepareXMFfile(); xmfFile = prepareXMFfile();
/* Write the part corresponding to this specific output */ /* Write the part corresponding to this specific output */
...@@ -539,10 +538,10 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { ...@@ -539,10 +538,10 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
writeCodeDescription(h_file); writeCodeDescription(h_file);
/* Print the SPH parameters */ /* Print the SPH parameters */
h_grpsph = H5Gcreate(h_file, "/SPH", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); h_grp = H5Gcreate(h_file, "/SPH", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (h_grpsph < 0) error("Error while creating SPH group"); if (h_grp < 0) error("Error while creating SPH group");
writeSPHflavour(h_grpsph); writeSPHflavour(h_grp);
H5Gclose(h_grpsph); H5Gclose(h_grp);
/* Print the system of Units */ /* Print the system of Units */
writeUnitSystem(h_file, us); writeUnitSystem(h_file, us);
...@@ -574,6 +573,7 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { ...@@ -574,6 +573,7 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
case DM: case DM:
/* Allocate temporary array */ /* Allocate temporary array */
struct gpart* dmparts = NULL;
if (posix_memalign((void*)&dmparts, gpart_align, if (posix_memalign((void*)&dmparts, gpart_align,
Ndm * sizeof(struct gpart)) != 0) Ndm * sizeof(struct gpart)) != 0)
error("Error while allocating temporart memory for DM particles"); error("Error while allocating temporart memory for DM particles");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment