diff --git a/examples/main.c b/examples/main.c index ab8fca8197550470b18c5327ed3a2a5ed5dc6ff3..8fdac673e29c2409f014cbc03dfdfca5add6c761 100644 --- a/examples/main.c +++ b/examples/main.c @@ -834,8 +834,7 @@ int main(int argc, char *argv[]) { talking, restart_file); /* check output field */ - if (myrank == 0) - io_check_output_fields(params, &e, N_total); + if (myrank == 0) io_check_output_fields(params, &e, N_total); if (myrank == 0) { clocks_gettime(&toc); diff --git a/src/common_io.c b/src/common_io.c index 34207113d996b6a1dffb4ba535f67c243e9dff5b..60158b1955b9b65cd8f1d7350bff98cc2dd6f415 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -818,8 +818,7 @@ void io_collect_dm_gparts(const struct gpart* const gparts, size_t Ntot, * @param e The #engine */ void io_check_output_fields(const struct swift_params* params, - const struct engine* e, - const long long *N_total) { + const struct engine* e, const long long* N_total) { /* particles */ const struct part* parts = e->s->parts; @@ -829,7 +828,7 @@ void io_check_output_fields(const struct swift_params* params, /* copy N_total to array with length == 6 */ const long long nr_total[swift_type_count] = { - N_total[0], N_total[1], N_total[2], 0, 0, 0}; + N_total[0], N_total[1], N_total[2], 0, 0, 0}; /* get all the possible outputs */ for (int ptype = 0; ptype < swift_type_count; ptype++) { @@ -876,20 +875,22 @@ void io_check_output_fields(const struct swift_params* params, /* loop over each possible output field */ for (int field_id = 0; field_id < num_fields; field_id++) { char field_name[PARSER_MAX_LINE_SIZE]; - sprintf(field_name, "SelectOutput:%s_%s", - list[field_id].name, part_type_names[ptype]); + sprintf(field_name, "SelectOutput:%s_%s", list[field_id].name, + part_type_names[ptype]); if (strcmp(param_name, field_name) == 0) { found = 1; - /* check if correct input */ - int retParam = 0; - char str[PARSER_MAX_LINE_SIZE]; - sscanf(params->data[param_id].value, "%d%s", &retParam, str); - - if (retParam != 0 && retParam != 1) - message("WARNING: Unexpected input for %s. " - "Received %i but expect 0 or 1. " - "We will write this field.", field_name, retParam); + /* check if correct input */ + int retParam = 0; + char str[PARSER_MAX_LINE_SIZE]; + sscanf(params->data[param_id].value, "%d%s", &retParam, str); + + if (retParam != 0 && retParam != 1) + message( + "WARNING: Unexpected input for %s. " + "Received %i but expect 0 or 1. " + "We will write this field.", + field_name, retParam); continue; } } @@ -937,8 +938,7 @@ void io_write_output_field_parameter(const char* filename) { fprintf(file, " # Particle Type %s\n", part_type_names[ptype]); /* Write everything */ for (int i = 0; i < num_fields; ++i) { - fprintf(file, " %s_%s: 1\n", - list[i].name, part_type_names[ptype]); + fprintf(file, " %s_%s: 1\n", list[i].name, part_type_names[ptype]); } fprintf(file, "\n"); diff --git a/src/common_io.h b/src/common_io.h index 706387582547e5c806624e1d63a1eef72a46d3ff..8f8312b192fbe1d77e83eb06ad2cd11a935d70b1 100644 --- a/src/common_io.h +++ b/src/common_io.h @@ -101,8 +101,7 @@ void io_duplicate_star_gparts(struct threadpool* tp, struct spart* const sparts, size_t Ndm); void io_check_output_fields(const struct swift_params* params, - const struct engine* e, - const long long *N_total); + const struct engine* e, const long long* N_total); void io_write_output_field_parameter(const char* filename); diff --git a/src/parallel_io.c b/src/parallel_io.c index 401e3b7da0f7e9f1f01217651260ac90810ac22d..803d2e48d070251659f6f4a5fa242a52e51bfa9b 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -1022,11 +1022,12 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6], /* Prepare everything */ for (int i = 0; i < num_fields; ++i) { char field[PARSER_MAX_LINE_SIZE]; - sprintf(field, "SelectOutput:%s_%s", list[i].name, part_type_names[ptype]); + sprintf(field, "SelectOutput:%s_%s", list[i].name, + part_type_names[ptype]); int should_write = parser_get_opt_param_int(params, field, 1); if (should_write != 0) - prepareArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], - N_total[ptype], snapshot_units); + prepareArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], + N_total[ptype], snapshot_units); } /* Close particle group */ @@ -1272,7 +1273,8 @@ void write_output_parallel(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) { char field[PARSER_MAX_LINE_SIZE]; - sprintf(field, "SelectOutput:%s_%s", list[i].name, part_type_names[ptype]); + sprintf(field, "SelectOutput:%s_%s", list[i].name, + part_type_names[ptype]); int should_write = parser_get_opt_param_int(params, field, 1); if (should_write != 0) writeArray(e, h_grp, fileName, partTypeGroupName, list[i], Nparticles, diff --git a/src/serial_io.c b/src/serial_io.c index 9c0a3c1fb4f58d88445d78643a90cfb62c63afc7..4e47f758ad3f56b57368b87a63a1f7b643e36630 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -1010,7 +1010,8 @@ void write_output_serial(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) { char field[PARSER_MAX_LINE_SIZE]; - sprintf(field, "SelectOutput:%s_%s", list[i].name, part_type_names[ptype]); + sprintf(field, "SelectOutput:%s_%s", list[i].name, + part_type_names[ptype]); int should_write = parser_get_opt_param_int(params, field, 1); if (should_write != 0) writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], diff --git a/src/single_io.c b/src/single_io.c index 3a89d7a02587173af184bd53c00edc3eb22f858c..a74a0adb74a1cd2d0439a67c098b8c68f2eb2736 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -829,7 +829,8 @@ void write_output_single(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) { char field[PARSER_MAX_LINE_SIZE]; - sprintf(field, "SelectOutput:%s_%s", list[i].name, part_type_names[ptype]); + sprintf(field, "SelectOutput:%s_%s", list[i].name, + part_type_names[ptype]); int should_write = parser_get_opt_param_int(params, field, 1); if (should_write != 0) writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, diff --git a/tests/test125cells.c b/tests/test125cells.c index 33e945abf74a8f3075c2bc7536cbebc4fa372a12..ddce3176d463f2ef754bf82b364858085e317e4b 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -876,7 +876,8 @@ int main(int argc, char *argv[]) { /* Output timing */ message("Brute force calculation took : %15lli ticks.", toc - tic); - sprintf(outputFileName, "brute_force_125_%.150s.dat", outputFileNameExtension); + sprintf(outputFileName, "brute_force_125_%.150s.dat", + outputFileNameExtension); dump_particle_fields(outputFileName, main_cell, solution, 0); /* Clean things to make the sanitizer happy ... */ diff --git a/tests/testActivePair.c b/tests/testActivePair.c index 9629f7c2d092b5cc6f5b38d5ba9ab9e0b669a825..6889a18887894af0a9434f786df21dbf842e87e5 100644 --- a/tests/testActivePair.c +++ b/tests/testActivePair.c @@ -578,7 +578,8 @@ int main(int argc, char *argv[]) { runner->e = &engine; /* Create output file names. */ - sprintf(swiftOutputFileName, "swift_dopair_%.150s.dat", outputFileNameExtension); + sprintf(swiftOutputFileName, "swift_dopair_%.150s.dat", + outputFileNameExtension); sprintf(bruteForceOutputFileName, "brute_force_pair_%.150s.dat", outputFileNameExtension); diff --git a/tests/testSelectOutput.c b/tests/testSelectOutput.c index e16c7a51809c31264d5b85f511b30b5e788640f5..fecffd861e19b48e61c0b5b5e8ab5d8c070e376a 100644 --- a/tests/testSelectOutput.c +++ b/tests/testSelectOutput.c @@ -24,9 +24,10 @@ #include "swift.h" void select_output_engine_init(struct engine *e, struct space *s, - struct cosmology *cosmo, struct swift_params *params, - struct cooling_function_data *cooling, - struct hydro_props *hydro_properties) { + struct cosmology *cosmo, + struct swift_params *params, + struct cooling_function_data *cooling, + struct hydro_props *hydro_properties) { /* set structures */ e->s = s; e->cooling_func = cooling; @@ -42,16 +43,15 @@ void select_output_engine_init(struct engine *e, struct space *s, e->verbose = 1; e->time = 0; e->snapshotOutputCount = 0; - e->snapshotCompression = 0; - + e->snapshotCompression = 0; }; void select_output_space_init(struct space *s, double *dim, int periodic, - size_t Ngas, size_t Nspart, size_t Ngpart, - struct part *parts, struct spart *sparts, - struct gpart *gparts) { + size_t Ngas, size_t Nspart, size_t Ngpart, + struct part *parts, struct spart *sparts, + struct gpart *gparts) { s->periodic = periodic; - for (int i=0; i<3; i++) { + for (int i = 0; i < 3; i++) { s->dim[i] = dim[i]; } @@ -66,18 +66,15 @@ void select_output_space_init(struct space *s, double *dim, int periodic, /* Allocate the extra parts array for the gas particles. */ if (posix_memalign((void **)&s->xparts, xpart_align, - Ngas * sizeof(struct xpart)) != 0) + Ngas * sizeof(struct xpart)) != 0) error("Failed to allocate xparts."); bzero(s->xparts, Ngas * sizeof(struct xpart)); }; -void select_output_space_clean(struct space *s) { - free(s->xparts); -}; - +void select_output_space_clean(struct space *s) { free(s->xparts); }; void select_output_engine_clean(struct engine *e) { - threadpool_clean(&e->threadpool); + threadpool_clean(&e->threadpool); } int main() { @@ -116,8 +113,8 @@ int main() { /* pseudo initialization of the space */ message("Initialization of the space."); struct space s; - select_output_space_init(&s, dim, periodic, Ngas, Nspart, Ngpart, - parts, sparts, gparts); + select_output_space_init(&s, dim, periodic, Ngas, Nspart, Ngpart, parts, + sparts, gparts); /* initialization of cosmology */ message("Initialization of the cosmology."); @@ -136,8 +133,8 @@ int main() { /* pseudo initialization of the engine */ message("Initialization of the engine."); struct engine e; - select_output_engine_init(&e, &s, &cosmo, ¶m_file, - &cooling, &hydro_properties); + select_output_engine_init(&e, &s, &cosmo, ¶m_file, &cooling, + &hydro_properties); /* check output selection */ message("Checking output parameters.");