diff --git a/src/common_io.c b/src/common_io.c index 3133c64f45df7d2ef3711f375fdd318b154d7919..bce2319fe9a1cc847fe806b0a978eeb6a4714893 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -45,8 +45,8 @@ #include "kernel.h" #include "version.h" -const char *particle_type_names[NUM_PARTICLE_TYPES] = { - "Gas", "DM", "Boundary", "Dummy", "Stars", "BH" }; +const char* particle_type_names[NUM_PARTICLE_TYPES] = { + "Gas", "DM", "Boundary", "Dummy", "Star", "BH"}; /** * @brief Converts a C data type to the HDF5 equivalent. @@ -434,14 +434,12 @@ void writeXMFoutputfooter(FILE* xmfFile, int output, float time) { fclose(xmfFile); } - void writeXMFgroupheader(FILE* xmfFile, char* hdfFileName, size_t N, - enum PARTICLE_TYPE ptype) { + enum PARTICLE_TYPE ptype) { fprintf(xmfFile, "\n<Grid Name=\"%s\" GridType=\"Uniform\">\n", - particle_type_names[ptype]); + particle_type_names[ptype]); fprintf(xmfFile, - "<Topology TopologyType=\"Polyvertex\" Dimensions=\"%zi\"/>\n", - N); + "<Topology TopologyType=\"Polyvertex\" Dimensions=\"%zi\"/>\n", N); fprintf(xmfFile, "<Geometry GeometryType=\"XYZ\">\n"); fprintf(xmfFile, "<DataItem Dimensions=\"%zi 3\" NumberType=\"Double\" " @@ -452,11 +450,10 @@ void writeXMFgroupheader(FILE* xmfFile, char* hdfFileName, size_t N, } void writeXMFgroupfooter(FILE* xmfFile, enum PARTICLE_TYPE ptype) { - fprintf(xmfFile, "</Grid> <!-- parttype=%s -->\n", particle_type_names[ptype]); + fprintf(xmfFile, "</Grid> <!-- parttype=%s -->\n", + particle_type_names[ptype]); } - - /** * @brief Writes the lines corresponding to an array of the HDF5 output * @@ -470,7 +467,7 @@ void writeXMFgroupfooter(FILE* xmfFile, enum PARTICLE_TYPE ptype) { * @todo Treat the types in a better way. */ void writeXMFline(FILE* xmfFile, char* fileName, char* partTypeGroupName, - char* name, size_t N, int dim, enum DATA_TYPE type) { + char* name, size_t N, int dim, enum DATA_TYPE type) { fprintf(xmfFile, "<Attribute Name=\"%s\" AttributeType=\"%s\" Center=\"Node\">\n", name, dim == 1 ? "Scalar" : "Vector"); diff --git a/src/common_io.h b/src/common_io.h index 6cc79ad51809d461b188003247e8cf021e3cf0fe..4ad0c6fb754c4288a0c731e2b1e2392998719d52 100644 --- a/src/common_io.h +++ b/src/common_io.h @@ -70,7 +70,7 @@ enum PARTICLE_TYPE { NUM_PARTICLE_TYPES }; -extern const char *particle_type_names[]; +extern const char* particle_type_names[]; #define FILENAME_BUFFER_SIZE 150 #define PARTICLE_GROUP_BUFFER_SIZE 20 @@ -100,10 +100,10 @@ FILE* prepareXMFfile(); void writeXMFoutputheader(FILE* xmfFile, char* hdfFileName, float time); void writeXMFoutputfooter(FILE* xmfFile, int outputCount, float time); void writeXMFgroupheader(FILE* xmfFile, char* hdfFileName, size_t N, - enum PARTICLE_TYPE ptype); + enum PARTICLE_TYPE ptype); void writeXMFgroupfooter(FILE* xmfFile, enum PARTICLE_TYPE ptype); void writeXMFline(FILE* xmfFile, char* fileName, char* partTypeGroupName, - char* name, size_t N, int dim, enum DATA_TYPE type); + char* name, size_t N, int dim, enum DATA_TYPE type); void writeCodeDescription(hid_t h_file); void writeSPHflavour(hid_t h_file); diff --git a/src/serial_io.c b/src/serial_io.c index fe0b0def9e6181ba68c078b6bec14b6b9622ef4e..c0421464a9455dcddb7376c512ec63ce25817344 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -609,12 +609,12 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, FILE* xmfFile = 0; /* Number of particles of each type */ - //const size_t Ndm = Ntot - Ngas; + // const size_t Ndm = Ntot - Ngas; /* MATTHIEU: Temporary fix to preserve master */ - const size_t Ndm = Ntot > 0 ? Ntot - Ngas: 0; + const size_t Ndm = Ntot > 0 ? Ntot - Ngas : 0; /* MATTHIEU: End temporary fix */ - + /* File name */ char fileName[FILENAME_BUFFER_SIZE]; snprintf(fileName, FILENAME_BUFFER_SIZE, "output_%03i.hdf5", outputCount); diff --git a/src/single_io.c b/src/single_io.c index 6f6d1d4913c0ff89e8e4aad215baa951d8a43913..e3231d56de6012e207d6c7c74e7cadd6f18ee326 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -138,7 +138,8 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N, * @param grp The group in which to write. * @param fileName The name of the file in which the data is written * @param xmfFile The FILE used to write the XMF description - * @param partTypeGroupName The name of the group containing the particles in the HDF5 file. + * @param partTypeGroupName The name of the group containing the particles in + *the HDF5 file. * @param name The name of the array to write. * @param type The #DATA_TYPE of the array. * @param N The number of particles to write. @@ -155,9 +156,9 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N, * Calls #error() if an error occurs. */ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, - char* partTypeGroupName, char* name, - enum DATA_TYPE type, int N, int dim, char* part_c, - size_t partSize, struct UnitSystem* us, + char* partTypeGroupName, char* name, enum DATA_TYPE type, + int N, int dim, char* part_c, size_t partSize, + struct UnitSystem* us, enum UnitConversionFactor convFactor) { hid_t h_data = 0, h_err = 0, h_space = 0, h_prop = 0; void* temp = 0; @@ -283,7 +284,8 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, * @param fileName The name of the file in which the data is written * @param xmfFile The FILE used to write the XMF description * @param name The name of the array to write. - * @param partTypeGroupName The name of the group containing the particles in the HDF5 file. + * @param partTypeGroupName The name of the group containing the particles in + *the HDF5 file. * @param type The #DATA_TYPE of the array. * @param N The number of particles to write. * @param dim The dimension of the data (1 for scalar, 3 for vector) @@ -297,10 +299,12 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, * @param convFactor The UnitConversionFactor for this array * */ -#define writeArray(grp, fileName, xmfFile, partTypeGroupName, name, type, N, \ - dim, part, N_total, mpi_rank, offset, field, us, convFactor)\ +#define writeArray(grp, fileName, xmfFile, partTypeGroupName, name, type, N, \ + dim, part, N_total, mpi_rank, offset, field, us, \ + convFactor) \ writeArrayBackEnd(grp, fileName, xmfFile, partTypeGroupName, name, type, N, \ - dim, (char*)(&(part[0]).field), sizeof(part[0]), us, convFactor) + dim, (char*)(&(part[0]).field), sizeof(part[0]), us, \ + convFactor) /* Import the right hydro definition */ #include "hydro_io.h" @@ -478,10 +482,10 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { static int outputCount = 0; /* Number of particles of each type */ - //const size_t Ndm = Ntot - Ngas; + // const size_t Ndm = Ntot - Ngas; /* MATTHIEU: Temporary fix to preserve master */ - const size_t Ndm = Ntot > 0 ? Ntot - Ngas: 0; + const size_t Ndm = Ntot > 0 ? Ntot - Ngas : 0; /* MATTHIEU: End temporary fix */ long long N_total[NUM_PARTICLE_TYPES] = {Ngas, Ndm, 0}; @@ -590,8 +594,8 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { switch (ptype) { case GAS: - hydro_write_particles(h_grp, fileName, partTypeGroupName, - xmfFile, Ngas, Ngas, 0, 0, parts, us); + hydro_write_particles(h_grp, fileName, partTypeGroupName, xmfFile, Ngas, + Ngas, 0, 0, parts, us); break; case DM: @@ -605,8 +609,8 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { collect_dm_gparts(gparts, Ntot, dmparts, Ndm); /* Write DM particles */ - darkmatter_write_particles(h_grp, fileName, partTypeGroupName, - xmfFile, Ndm, Ndm, 0, 0, dmparts, us); + darkmatter_write_particles(h_grp, fileName, partTypeGroupName, xmfFile, + Ndm, Ndm, 0, 0, dmparts, us); /* Free temporary array */ free(dmparts);