From 4a585ee4cd30820a9828e77a89387ddf3431130b Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 1 Aug 2016 12:35:35 +0100 Subject: [PATCH] Make ICC happy with our handling of enumerated types. --- src/io_properties.h | 8 ++++---- src/parallel_io.c | 5 +++-- src/scheduler.c | 14 +++++++------- src/scheduler.h | 6 +++--- src/serial_io.c | 6 ++++-- src/single_io.c | 5 +++-- src/units.c | 34 +++++++++++++++++++--------------- tests/test27cells.c | 2 +- 8 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/io_properties.h b/src/io_properties.h index 2d4a65163f..af0d81aec8 100644 --- a/src/io_properties.h +++ b/src/io_properties.h @@ -27,7 +27,7 @@ * @brief The two sorts of data present in the GADGET IC files: compulsory to * start a run or optional. */ -enum DATA_IMPORTANCE { COMPULSORY = 1, OPTIONAL = 0 }; +enum DATA_IMPORTANCE { COMPULSORY = 1, OPTIONAL = 0, UNUSED = -1 }; /** * @brief The properties of a given dataset for i/o @@ -134,7 +134,7 @@ struct io_props io_make_output_field_(char name[FIELD_BUFFER_SIZE], strcpy(r.name, name); r.type = type; r.dimension = dimension; - r.importance = 0; + r.importance = UNUSED; r.units = units; r.field = field; r.partSize = partSize; @@ -178,7 +178,7 @@ struct io_props io_make_output_field_convert_part_( strcpy(r.name, name); r.type = type; r.dimension = dimension; - r.importance = 0; + r.importance = UNUSED; r.units = units; r.field = field; r.partSize = partSize; @@ -222,7 +222,7 @@ struct io_props io_make_output_field_convert_gpart_( strcpy(r.name, name); r.type = type; r.dimension = dimension; - r.importance = 0; + r.importance = UNUSED; r.units = units; r.field = field; r.partSize = partSize; diff --git a/src/parallel_io.c b/src/parallel_io.c index 2f70b470d9..262ab7d9e4 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -767,7 +767,8 @@ void write_output_parallel(struct engine* e, const char* baseName, /* Add the global information for that particle type to * the XMF meta-file */ if (mpi_rank == 0) - writeXMFgroupheader(xmfFile, fileName, N_total[ptype], ptype); + writeXMFgroupheader(xmfFile, fileName, N_total[ptype], + (enum PARTICLE_TYPE)ptype); /* Open the particle group in the file */ char partTypeGroupName[PARTICLE_GROUP_BUFFER_SIZE]; @@ -828,7 +829,7 @@ void write_output_parallel(struct engine* e, const char* baseName, H5Gclose(h_grp); /* Close this particle group in the XMF file as well */ - if (mpi_rank == 0) writeXMFgroupfooter(xmfFile, ptype); + if (mpi_rank == 0) writeXMFgroupfooter(xmfFile, (enum PARTICLE_TYPE)ptype); } /* Write LXMF file descriptor */ diff --git a/src/scheduler.c b/src/scheduler.c index d760545ea7..a14fe5bed0 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -498,8 +498,8 @@ void scheduler_splittasks(struct scheduler *s) { /* Create the sort for ci. */ // lock_lock( &ci->lock ); if (ci->sorts == NULL) - ci->sorts = - scheduler_addtask(s, task_type_sort, 0, 1 << sid, 0, ci, NULL, 0); + ci->sorts = scheduler_addtask(s, task_type_sort, task_subtype_none, + 1 << sid, 0, ci, NULL, 0); else ci->sorts->flags |= (1 << sid); // lock_unlock_blind( &ci->lock ); @@ -508,8 +508,8 @@ void scheduler_splittasks(struct scheduler *s) { /* Create the sort for cj. */ // lock_lock( &cj->lock ); if (cj->sorts == NULL) - cj->sorts = - scheduler_addtask(s, task_type_sort, 0, 1 << sid, 0, cj, NULL, 0); + cj->sorts = scheduler_addtask(s, task_type_sort, task_subtype_none, + 1 << sid, 0, cj, NULL, 0); else cj->sorts->flags |= (1 << sid); // lock_unlock_blind( &cj->lock ); @@ -534,9 +534,9 @@ void scheduler_splittasks(struct scheduler *s) { * @param tight */ -struct task *scheduler_addtask(struct scheduler *s, int type, int subtype, - int flags, int wait, struct cell *ci, - struct cell *cj, int tight) { +struct task *scheduler_addtask(struct scheduler *s, enum task_types type, + enum task_subtypes subtype, int flags, int wait, + struct cell *ci, struct cell *cj, int tight) { /* Get the next free task. */ const int ind = atomic_inc(&s->tasks_next); diff --git a/src/scheduler.h b/src/scheduler.h index 62af23152e..7d5dd627f8 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -112,9 +112,9 @@ void scheduler_start(struct scheduler *s, unsigned int mask, void scheduler_reset(struct scheduler *s, int nr_tasks); void scheduler_ranktasks(struct scheduler *s); void scheduler_reweight(struct scheduler *s); -struct task *scheduler_addtask(struct scheduler *s, int type, int subtype, - int flags, int wait, struct cell *ci, - struct cell *cj, int tight); +struct task *scheduler_addtask(struct scheduler *s, enum task_types type, + enum task_subtypes subtype, int flags, int wait, + struct cell *ci, struct cell *cj, int tight); void scheduler_splittasks(struct scheduler *s); struct task *scheduler_done(struct scheduler *s, struct task *t); struct task *scheduler_unlock(struct scheduler *s, struct task *t); diff --git a/src/serial_io.c b/src/serial_io.c index 65f3e4798b..c981e5e31d 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -859,7 +859,8 @@ void write_output_serial(struct engine* e, const char* baseName, /* Add the global information for that particle type to the XMF * meta-file */ if (mpi_rank == 0) - writeXMFgroupheader(xmfFile, fileName, N_total[ptype], ptype); + writeXMFgroupheader(xmfFile, fileName, N_total[ptype], + (enum PARTICLE_TYPE)ptype); /* Open the particle group in the file */ char partTypeGroupName[PARTICLE_GROUP_BUFFER_SIZE]; @@ -915,7 +916,8 @@ void write_output_serial(struct engine* e, const char* baseName, H5Gclose(h_grp); /* Close this particle group in the XMF file as well */ - if (mpi_rank == 0) writeXMFgroupfooter(xmfFile, ptype); + if (mpi_rank == 0) + writeXMFgroupfooter(xmfFile, (enum PARTICLE_TYPE)ptype); } /* Close file */ diff --git a/src/single_io.c b/src/single_io.c index 3cc83e852d..93faab6717 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -669,7 +669,8 @@ void write_output_single(struct engine* e, const char* baseName, if (numParticles[ptype] == 0) continue; /* Add the global information for that particle type to the XMF meta-file */ - writeXMFgroupheader(xmfFile, fileName, numParticles[ptype], ptype); + writeXMFgroupheader(xmfFile, fileName, numParticles[ptype], + (enum PARTICLE_TYPE)ptype); /* Open the particle group in the file */ char partTypeGroupName[PARTICLE_GROUP_BUFFER_SIZE]; @@ -724,7 +725,7 @@ void write_output_single(struct engine* e, const char* baseName, H5Gclose(h_grp); /* Close this particle group in the XMF file as well */ - writeXMFgroupfooter(xmfFile, ptype); + writeXMFgroupfooter(xmfFile, (enum PARTICLE_TYPE)ptype); } /* Write LXMF file descriptor */ diff --git a/src/units.c b/src/units.c index 8fa4abfc61..5c262ae036 100644 --- a/src/units.c +++ b/src/units.c @@ -385,11 +385,11 @@ void units_cgs_conversion_string(char* buffer, const struct UnitSystem* us, double units_general_cgs_conversion_factor(const struct UnitSystem* us, const float baseUnitsExponants[5]) { double factor = 1.; - int i; - for (i = 0; i < 5; ++i) + for (int i = 0; i < 5; ++i) if (baseUnitsExponants[i] != 0) - factor *= pow(units_get_base_unit(us, i), baseUnitsExponants[i]); + factor *= pow(units_get_base_unit(us, (enum BaseUnits)i), + baseUnitsExponants[i]); return factor; } @@ -440,13 +440,12 @@ void units_general_cgs_conversion_string(char* buffer, const struct UnitSystem* us, const float baseUnitsExponants[5]) { char temp[14]; - double a_exp = units_general_a_factor(us, baseUnitsExponants); - double h_exp = units_general_h_factor(us, baseUnitsExponants); - int i; + const double a_exp = units_general_a_factor(us, baseUnitsExponants); + const double h_exp = units_general_h_factor(us, baseUnitsExponants); /* Check whether we are unitless or not */ char isAllNonZero = 1; - for (i = 0; i < 5; ++i) + for (int i = 0; i < 5; ++i) if (baseUnitsExponants[i] != 0.) isAllNonZero = 0; if (isAllNonZero) { @@ -476,17 +475,20 @@ void units_general_cgs_conversion_string(char* buffer, strncat(buffer, temp, 12); /* Add conversion units */ - for (i = 0; i < 5; ++i) + for (int i = 0; i < 5; ++i) if (baseUnitsExponants[i] != 0) { if (baseUnitsExponants[i] == 0.) sprintf(temp, " "); else if (baseUnitsExponants[i] == 1.) - sprintf(temp, "%s ", units_get_base_unit_internal_symbol(i)); + sprintf(temp, "%s ", + units_get_base_unit_internal_symbol((enum BaseUnits)i)); else if (remainder(baseUnitsExponants[i], 1.) == 0) - sprintf(temp, "%s^%d ", units_get_base_unit_internal_symbol(i), + sprintf(temp, "%s^%d ", + units_get_base_unit_internal_symbol((enum BaseUnits)i), (int)baseUnitsExponants[i]); else - sprintf(temp, "%s^%7.4f ", units_get_base_unit_internal_symbol(i), + sprintf(temp, "%s^%7.4f ", + units_get_base_unit_internal_symbol((enum BaseUnits)i), baseUnitsExponants[i]); strncat(buffer, temp, 12); } @@ -494,17 +496,19 @@ void units_general_cgs_conversion_string(char* buffer, /* Add CGS units */ strncat(buffer, " [ ", 3); - for (i = 0; i < 5; ++i) { + for (int i = 0; i < 5; ++i) { if (baseUnitsExponants[i] != 0) { if (baseUnitsExponants[i] == 0.) continue; else if (baseUnitsExponants[i] == 1.) - sprintf(temp, "%s ", units_get_base_unit_cgs_symbol(i)); + sprintf(temp, "%s ", units_get_base_unit_cgs_symbol((enum BaseUnits)i)); else if (remainder(baseUnitsExponants[i], 1.) == 0) - sprintf(temp, "%s^%d ", units_get_base_unit_cgs_symbol(i), + sprintf(temp, "%s^%d ", + units_get_base_unit_cgs_symbol((enum BaseUnits)i), (int)baseUnitsExponants[i]); else - sprintf(temp, "%s^%7.4f ", units_get_base_unit_cgs_symbol(i), + sprintf(temp, "%s^%7.4f ", + units_get_base_unit_cgs_symbol((enum BaseUnits)i), baseUnitsExponants[i]); strncat(buffer, temp, 12); } diff --git a/tests/test27cells.c b/tests/test27cells.c index 7c46743f1d..38d4fb62bc 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -253,7 +253,7 @@ int main(int argc, char *argv[]) { double perturbation = 0.; char outputFileNameExtension[200] = ""; char outputFileName[200] = ""; - int vel = velocity_zero; + enum velocity_types vel = velocity_zero; /* Initialize CPU frequency, this also starts time. */ unsigned long long cpufreq = 0; -- GitLab