From b9c1b5172e27c72d4505e3e304f657c6a50ac80c Mon Sep 17 00:00:00 2001 From: lhausamm <loic_hausammann@hotmail.com> Date: Thu, 31 May 2018 11:02:38 +0200 Subject: [PATCH] Format --- examples/main.c | 3 +-- src/common_io.c | 32 ++++++++++++++++---------------- src/common_io.h | 3 +-- src/parallel_io.c | 10 ++++++---- src/serial_io.c | 3 ++- src/single_io.c | 3 ++- tests/test125cells.c | 3 ++- tests/testActivePair.c | 3 ++- tests/testSelectOutput.c | 35 ++++++++++++++++------------------- 9 files changed, 48 insertions(+), 47 deletions(-) diff --git a/examples/main.c b/examples/main.c index ab8fca8197..8fdac673e2 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 34207113d9..60158b1955 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 7063875825..8f8312b192 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 401e3b7da0..803d2e48d0 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 9c0a3c1fb4..4e47f758ad 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 3a89d7a025..a74a0adb74 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 33e945abf7..ddce3176d4 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 9629f7c2d0..6889a18887 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 e16c7a5180..fecffd861e 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."); -- GitLab