diff --git a/src/common_io.c b/src/common_io.c index 3c001d9da106a46ef5033c8cdec9346d68c54ecd..b7495b1089ab0b46993f492deff6b955f7dc1ccf 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -515,13 +515,13 @@ void writeXMFgroupheader(FILE* xmfFile, char* hdfFileName, size_t N, fprintf(xmfFile, "\n<Grid Name=\"%s\" GridType=\"Uniform\">\n", particle_type_names[ptype]); fprintf(xmfFile, - "<Topology TopologyType=\"Polyvertex\" Dimensions=\"%zi\"/>\n", N); + "<Topology TopologyType=\"Polyvertex\" Dimensions=\"%zu\"/>\n", N); fprintf(xmfFile, "<Geometry GeometryType=\"XYZ\">\n"); fprintf(xmfFile, - "<DataItem Dimensions=\"%zi 3\" NumberType=\"Double\" " + "<DataItem Dimensions=\"%zu 3\" NumberType=\"Double\" " "Precision=\"8\" " "Format=\"HDF\">%s:/PartType%d/Coordinates</DataItem>\n", - N, hdfFileName, ptype); + N, hdfFileName, (int)ptype); fprintf(xmfFile, "</Geometry>\n <!-- Done geometry for %s, start of particle fields " "list -->\n", @@ -555,12 +555,12 @@ void writeXMFline(FILE* xmfFile, const char* fileName, name, dim == 1 ? "Scalar" : "Vector"); if (dim == 1) fprintf(xmfFile, - "<DataItem Dimensions=\"%zi\" NumberType=\"Double\" " + "<DataItem Dimensions=\"%zu\" NumberType=\"Double\" " "Precision=\"%d\" Format=\"HDF\">%s:%s/%s</DataItem>\n", N, type == FLOAT ? 4 : 8, fileName, partTypeGroupName, name); else fprintf(xmfFile, - "<DataItem Dimensions=\"%zi %d\" NumberType=\"Double\" " + "<DataItem Dimensions=\"%zu %d\" NumberType=\"Double\" " "Precision=\"%d\" Format=\"HDF\">%s:%s/%s</DataItem>\n", N, dim, type == FLOAT ? 4 : 8, fileName, partTypeGroupName, name); fprintf(xmfFile, "</Attribute>\n"); @@ -582,7 +582,7 @@ void prepare_dm_gparts(struct gpart* const gparts, size_t Ndm) { for (size_t i = 0; i < Ndm; ++i) { /* 0 or negative ids are not allowed */ if (gparts[i].id_or_neg_offset <= 0) - error("0 or negative ID for DM particle %zd: ID=%lld", i, + error("0 or negative ID for DM particle %zu: ID=%lld", i, gparts[i].id_or_neg_offset); } } @@ -650,7 +650,7 @@ void collect_dm_gparts(const struct gpart* const gparts, size_t Ntot, /* Check that everything is fine */ if (count != Ndm) - error("Collected the wrong number of dm particles (%zd vs. %zd expected)", + error("Collected the wrong number of dm particles (%zu vs. %zu expected)", count, Ndm); } diff --git a/src/debug.c b/src/debug.c index 4601f9bacc2d51d988ee0212b4ccf778bcf15f5c..ea4934363fd0a87584b94a41f6ae1b63e578cfbe 100644 --- a/src/debug.c +++ b/src/debug.c @@ -71,7 +71,7 @@ void printParticle(const struct part *parts, struct xpart *xparts, /* Look for the particle. */ for (size_t i = 0; i < N; i++) if (parts[i].id == id) { - printf("## Particle[%zd]:\n id=%lld ", i, parts[i].id); + printf("## Particle[%zu]:\n id=%lld ", i, parts[i].id); hydro_debug_particle(&parts[i], &xparts[i]); found = 1; break; @@ -100,13 +100,13 @@ void printgParticle(const struct gpart *gparts, const struct part *parts, /* Look for the particle. */ for (size_t i = 0; i < N; i++) if (gparts[i].id_or_neg_offset == id) { - printf("## gParticle[%zd] (DM) :\n id=%lld", i, id); + printf("## gParticle[%zu] (DM) :\n id=%lld", i, id); gravity_debug_particle(&gparts[i]); found = 1; break; } else if (gparts[i].id_or_neg_offset < 0 && parts[-gparts[i].id_or_neg_offset].id == id) { - printf("## gParticle[%zd] (hydro) :\n id=%lld", i, id); + printf("## gParticle[%zu] (hydro) :\n id=%lld", i, id); gravity_debug_particle(&gparts[i]); found = 1; break; @@ -159,7 +159,7 @@ int checkSpacehmax(struct space *s) { /* Now all particles. */ float part_h_max = 0.0f; - for (int k = 0; k < s->nr_parts; k++) { + for (size_t k = 0; k < s->nr_parts; k++) { if (s->parts[k].h > part_h_max) { part_h_max = s->parts[k].h; } @@ -178,7 +178,7 @@ int checkSpacehmax(struct space *s) { } } - for (int k = 0; k < s->nr_parts; k++) { + for (size_t k = 0; k < s->nr_parts; k++) { if (s->parts[k].h > cell_h_max) { message("part %lld is inconsistent (%f > %f)", s->parts[k].id, s->parts[k].h, cell_h_max); diff --git a/src/engine.c b/src/engine.c index 4eb3126d86a70e7d242ea3de6ba783a7daa09411..dcd9283537d72ba3b4b0cf5130a70209f950b97e 100644 --- a/src/engine.c +++ b/src/engine.c @@ -296,7 +296,7 @@ void engine_redistribute(struct engine *e) { parts[k].x[2] * iwidth[2]); #ifdef SWIFT_DEBUG_CHECKS if (cid < 0 || cid >= s->nr_cells) - error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, + error("Bad cell id %i for part %zu at [%.3e,%.3e,%.3e].", cid, k, parts[k].x[0], parts[k].x[1], parts[k].x[2]); #endif @@ -352,7 +352,7 @@ void engine_redistribute(struct engine *e) { gparts[k].x[2] * iwidth[2]); #ifdef SWIFT_DEBUG_CHECKS if (cid < 0 || cid >= s->nr_cells) - error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, + error("Bad cell id %i for part %zu at [%.3e,%.3e,%.3e].", cid, k, gparts[k].x[0], gparts[k].x[1], gparts[k].x[2]); #endif @@ -587,7 +587,7 @@ void engine_redistribute(struct engine *e) { int my_cells = 0; for (int k = 0; k < nr_cells; k++) if (cells[k].nodeID == nodeID) my_cells += 1; - message("node %i now has %zi parts and %zi gparts in %i cells.", nodeID, + message("node %i now has %zu parts and %zu gparts in %i cells.", nodeID, nr_parts, nr_gparts, my_cells); } @@ -878,7 +878,7 @@ void engine_exchange_cells(struct engine *e) { /* Count the number of particles we need to import and re-allocate the buffer if needed. */ - int count_parts_in = 0, count_gparts_in = 0; + size_t count_parts_in = 0, count_gparts_in = 0; for (int k = 0; k < nr_proxies; k++) for (int j = 0; j < e->proxies[k].nr_cells_in; j++) { count_parts_in += e->proxies[k].cells_in[j]->count; @@ -968,7 +968,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, if (pid < 0) { error( "Do not have a proxy for the requested nodeID %i for part with " - "id=%llu, x=[%e,%e,%e].", + "id=%lld, x=[%e,%e,%e].", node_id, s->parts[offset_parts + k].id, s->parts[offset_parts + k].x[0], s->parts[offset_parts + k].x[1], s->parts[offset_parts + k].x[2]); @@ -1032,7 +1032,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, count_gparts_in += e->proxies[k].nr_gparts_in; } if (e->verbose) { - message("sent out %zi/%zi parts/gparts, got %i/%i back.", *Npart, *Ngpart, + message("sent out %zu/%zu parts/gparts, got %i/%i back.", *Npart, *Ngpart, count_parts_in, count_gparts_in); } if (offset_parts + count_parts_in > s->size_parts) { @@ -1126,13 +1126,13 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, reqs_in[pid + 1] == MPI_REQUEST_NULL && reqs_in[pid + 2] == MPI_REQUEST_NULL) { /* Copy the particle data to the part/xpart/gpart arrays. */ - struct proxy *p = &e->proxies[pid / 3]; - memcpy(&s->parts[offset_parts + count_parts], p->parts_in, - sizeof(struct part) * p->nr_parts_in); - memcpy(&s->xparts[offset_parts + count_parts], p->xparts_in, - sizeof(struct xpart) * p->nr_parts_in); - memcpy(&s->gparts[offset_gparts + count_gparts], p->gparts_in, - sizeof(struct gpart) * p->nr_gparts_in); + struct proxy *prox = &e->proxies[pid / 3]; + memcpy(&s->parts[offset_parts + count_parts], prox->parts_in, + sizeof(struct part) * prox->nr_parts_in); + memcpy(&s->xparts[offset_parts + count_parts], prox->xparts_in, + sizeof(struct xpart) * prox->nr_parts_in); + memcpy(&s->gparts[offset_gparts + count_gparts], prox->gparts_in, + sizeof(struct gpart) * prox->nr_gparts_in); /* for (int k = offset; k < offset + count; k++) message( "received particle %lli, x=[%.3e %.3e %.3e], h=%.3e, from node %i.", @@ -1140,8 +1140,8 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, s->parts[k].x[2], s->parts[k].h, p->nodeID); */ /* Re-link the gparts. */ - for (int k = 0; k < p->nr_gparts_in; k++) { - struct gpart *gp = &s->gparts[offset_gparts + count_gparts + k]; + for (int kk = 0; kk < prox->nr_gparts_in; kk++) { + struct gpart *gp = &s->gparts[offset_gparts + count_gparts + kk]; if (gp->id_or_neg_offset <= 0) { struct part *p = &s->parts[offset_gparts + count_parts - gp->id_or_neg_offset]; @@ -1151,8 +1151,8 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, } /* Advance the counters. */ - count_parts += p->nr_parts_in; - count_gparts += p->nr_gparts_in; + count_parts += prox->nr_parts_in; + count_gparts += prox->nr_gparts_in; } } @@ -2021,8 +2021,8 @@ void engine_print_task_counts(struct engine *e) { printf(" %s=%i", taskID_names[k], counts[k]); printf(" skipped=%i ]\n", counts[task_type_count]); fflush(stdout); - message("nr_parts = %zi.", e->s->nr_parts); - message("nr_gparts = %zi.", e->s->nr_gparts); + message("nr_parts = %zu.", e->s->nr_parts); + message("nr_gparts = %zu.", e->s->nr_gparts); } /** @@ -2489,11 +2489,11 @@ void engine_step(struct engine *e) { if (e->nodeID == 0) { /* Print some information to the screen */ - printf(" %6d %14e %14e %10zd %10zd %21.3f\n", e->step, e->time, + printf(" %6d %14e %14e %10zu %10zu %21.3f\n", e->step, e->time, e->timeStep, e->updates, e->g_updates, e->wallclock_time); fflush(stdout); - fprintf(e->file_timesteps, " %6d %14e %14e %10zd %10zd %21.3f\n", e->step, + fprintf(e->file_timesteps, " %6d %14e %14e %10zu %10zu %21.3f\n", e->step, e->time, e->timeStep, e->updates, e->g_updates, e->wallclock_time); fflush(e->file_timesteps); } @@ -2708,7 +2708,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) { /* Re-allocate the local parts. */ if (e->verbose) - message("Re-allocating parts array from %zi to %zi.", s->size_parts, + message("Re-allocating parts array from %zu to %zu.", s->size_parts, (size_t)(s->nr_parts * 1.2)); s->size_parts = s->nr_parts * 1.2; struct part *parts_new = NULL; @@ -2730,7 +2730,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) { /* Re-allocate the local gparts. */ if (e->verbose) - message("Re-allocating gparts array from %zi to %zi.", s->size_gparts, + message("Re-allocating gparts array from %zu to %zu.", s->size_gparts, (size_t)(s->nr_gparts * 1.2)); s->size_gparts = s->nr_gparts * 1.2; struct gpart *gparts_new = NULL; diff --git a/src/parallel_io.c b/src/parallel_io.c index d543aac7e700dc008c439ffca7e45108c6c1904e..5d10cf03137937a4b89db68218bb723d3a282c59 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -528,27 +528,18 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units, int num_fields = 0; struct io_props list[100]; - size_t N = 0; + size_t Nparticles = 0; /* Read particle fields into the particle structure */ switch (ptype) { case GAS: - /* if (!dry_run) */ - /* hydro_read_particles(h_grp, N[ptype], N_total[ptype], - * offset[ptype], */ - /* *parts); */ - /* break; */ - N = *Ngas; + Nparticles = *Ngas; hydro_read_particles(*parts, list, &num_fields); break; case DM: - /* if (!dry_run) */ - /* darkmatter_read_particles(h_grp, N[ptype], N_total[ptype], */ - /* offset[ptype], *gparts); */ - /* break; */ - N = Ndm; + Nparticles = Ndm; darkmatter_read_particles(*gparts, list, &num_fields); break; @@ -559,7 +550,7 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units, /* Read everything */ if (!dry_run) for (int i = 0; i < num_fields; ++i) - readArray(h_grp, list[i], N, N_total[ptype], offset[ptype], + readArray(h_grp, list[i], Nparticles, N_total[ptype], offset[ptype], internal_units, ic_units); /* Close particle group */ @@ -793,13 +784,13 @@ void write_output_parallel(struct engine* e, const char* baseName, int num_fields = 0; struct io_props list[100]; - size_t N = 0; + size_t Nparticles = 0; /* Write particle fields from the particle structure */ switch (ptype) { case GAS: - N = Ngas; + Nparticles = Ngas; hydro_write_particles(parts, list, &num_fields); break; @@ -816,7 +807,7 @@ void write_output_parallel(struct engine* e, const char* baseName, collect_dm_gparts(gparts, Ntot, dmparts, Ndm); /* Write DM particles */ - N = Ndm; + Nparticles = Ndm; darkmatter_write_particles(dmparts, list, &num_fields); /* Free temporary array */ @@ -829,9 +820,9 @@ void write_output_parallel(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) - writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, - N_total[ptype], mpi_rank, offset[ptype], internal_units, - snapshot_units); + writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], + Nparticles, N_total[ptype], mpi_rank, offset[ptype], + internal_units, snapshot_units); /* Free temporary array */ free(dmparts); diff --git a/src/runner.c b/src/runner.c index 018f1f082e8a3236b01684e8c39e84d365746f75..9833524cf3ee711b3b37f2b6339d46aa9fda4612 100644 --- a/src/runner.c +++ b/src/runner.c @@ -609,7 +609,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) { if (!c->split) { /* Loop over all the g-particles in the cell */ - const int nr_gparts = c->gcount; + const size_t nr_gparts = c->gcount; for (size_t k = 0; k < nr_gparts; k++) { /* Get a handle on the gpart. */ diff --git a/src/runner_doiact.h b/src/runner_doiact.h index db439671ff5fee56c086444ddaa8268571c80a15..81f6d0a833c2f06d538d7a46a3a8cd3015db259d 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -2864,14 +2864,15 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, /* Get the sorting index. */ int sid = 0; for (int k = 0; k < 3; k++) - sid = - 3 * sid + ((cj->loc[k] - ci->loc[k] + shift[k] < 0) - ? 0 - : (cj->loc[k] - ci->loc[k] + shift[k] > 0) ? 2 : 1); - sid = sortlistID[sid]; + new_sid = 3 * new_sid + + ((cj->loc[k] - ci->loc[k] + shift[k] < 0) + ? 0 + : (cj->loc[k] - ci->loc[k] + shift[k] > 0) ? 2 : 1); + new_sid = sortlistID[new_sid]; /* Do any of the cells need to be sorted first? */ - if (!(cj->sorted & (1 << sid))) runner_do_sort(r, cj, (1 << sid), 1); + if (!(cj->sorted & (1 << new_sid))) + runner_do_sort(r, cj, (1 << new_sid), 1); /* Compute the interactions. */ DOPAIR_SUBSET(r, ci, parts, ind, count, cj); diff --git a/src/scheduler.c b/src/scheduler.c index adc63e55092ff9bc69e6a2f98d6dfd5c399857f4..5c3b803a0c5a9fcb336cc461944d12fe231c442a 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -111,12 +111,12 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta, static void scheduler_splittask(struct task *t, struct scheduler *s) { /* Static constants. */ - const static int pts[7][8] = { + static const int pts[7][8] = { {-1, 12, 10, 9, 4, 3, 1, 0}, {-1, -1, 11, 10, 5, 4, 2, 1}, {-1, -1, -1, 12, 7, 6, 4, 3}, {-1, -1, -1, -1, 8, 7, 5, 4}, {-1, -1, -1, -1, -1, 12, 10, 9}, {-1, -1, -1, -1, -1, -1, 11, 10}, {-1, -1, -1, -1, -1, -1, -1, 12}}; - const static float sid_scale[13] = {0.1897, 0.4025, 0.1897, 0.4025, 0.5788, + static const float sid_scale[13] = {0.1897, 0.4025, 0.1897, 0.4025, 0.5788, 0.4025, 0.1897, 0.4025, 0.1897, 0.4025, 0.5788, 0.4025, 0.5788}; diff --git a/src/serial_io.c b/src/serial_io.c index d0618ea93e07168274dff02f31ae95c89503859b..5b133d37ac200273fb9a54f0fcf5381a359c44bd 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -220,7 +220,7 @@ void prepareArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile, /* Set chunk size */ h_err = H5Pset_chunk(h_prop, rank, chunk_shape); if (h_err < 0) { - error("Error while setting chunk size (%lld, %lld) for field '%s'.", + error("Error while setting chunk size (%llu, %llu) for field '%s'.", chunk_shape[0], chunk_shape[1], props.name); } @@ -590,26 +590,18 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units, int num_fields = 0; struct io_props list[100]; - size_t N = 0; + size_t Nparticles = 0; /* Read particle fields into the particle structure */ switch (ptype) { case GAS: - /* if (!dry_run) */ - /* hydro_read_particles(h_grp, N[ptype], N_total[ptype], */ - /* offset[ptype], *parts); */ - /* break; */ - N = *Ngas; + Nparticles = *Ngas; hydro_read_particles(*parts, list, &num_fields); break; case DM: - /* if (!dry_run) */ - /* darkmatter_read_particles(h_grp, N[ptype], N_total[ptype], */ - /* offset[ptype], *gparts); */ - /* break; */ - N = Ndm; + Nparticles = Ndm; darkmatter_read_particles(*gparts, list, &num_fields); break; @@ -621,7 +613,7 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units, /* Read everything */ if (!dry_run) for (int i = 0; i < num_fields; ++i) - readArray(h_grp, list[i], N, N_total[ptype], offset[ptype], + readArray(h_grp, list[i], Nparticles, N_total[ptype], offset[ptype], internal_units, ic_units); /* Close particle group */ @@ -886,13 +878,13 @@ void write_output_serial(struct engine* e, const char* baseName, int num_fields = 0; struct io_props list[100]; - size_t N = 0; + size_t Nparticles = 0; /* Write particle fields from the particle structure */ switch (ptype) { case GAS: - N = Ngas; + Nparticles = Ngas; hydro_write_particles(parts, list, &num_fields); break; @@ -907,7 +899,7 @@ void write_output_serial(struct engine* e, const char* baseName, collect_dm_gparts(gparts, Ntot, dmparts, Ndm); /* Write DM particles */ - N = Ndm; + Nparticles = Ndm; darkmatter_write_particles(dmparts, list, &num_fields); break; @@ -918,9 +910,9 @@ void write_output_serial(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) - writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, - N_total[ptype], mpi_rank, offset[ptype], internal_units, - snapshot_units); + writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], + Nparticles, N_total[ptype], mpi_rank, offset[ptype], + internal_units, snapshot_units); /* Free temporary array */ free(dmparts); diff --git a/src/single_io.c b/src/single_io.c index 2d95c2b32fc4b9b2e0e696deb75c9eab1acd9158..df741ac22335fc05ec1ac334636a897e6def3e96 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -257,7 +257,7 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile, /* Set chunk size */ h_err = H5Pset_chunk(h_prop, rank, chunk_shape); if (h_err < 0) { - error("Error while setting chunk size (%lld, %lld) for field '%s'.", + error("Error while setting chunk size (%llu, %llu) for field '%s'.", chunk_shape[0], chunk_shape[1], props.name); } @@ -471,18 +471,18 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units, int num_fields = 0; struct io_props list[100]; - size_t N = 0; + size_t Nparticles = 0; /* Read particle fields into the structure */ switch (ptype) { case GAS: - N = *Ngas; + Nparticles = *Ngas; hydro_read_particles(*parts, list, &num_fields); break; case DM: - N = Ndm; + Nparticles = Ndm; darkmatter_read_particles(*gparts, list, &num_fields); break; @@ -493,7 +493,7 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units, /* Read everything */ if (!dry_run) for (int i = 0; i < num_fields; ++i) - readArray(h_grp, list[i], N, internal_units, ic_units); + readArray(h_grp, list[i], Nparticles, internal_units, ic_units); /* Close particle group */ H5Gclose(h_grp); diff --git a/src/space.c b/src/space.c index 57b7279a508f10e3647105562e5974072a0c57f0..b8d2b61161d330c464f28926d5977b09371ae0b8 100644 --- a/src/space.c +++ b/src/space.c @@ -423,7 +423,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { int *gind; if ((gind = (int *)malloc(sizeof(int) * gind_size)) == NULL) error("Failed to allocate temporary g-particle indices."); - for (int k = 0; k < nr_gparts; k++) { + for (size_t k = 0; k < nr_gparts; k++) { struct gpart *restrict gp = &s->gparts[k]; for (int j = 0; j < 3; j++) if (gp->x[j] < 0.0) @@ -481,7 +481,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { #endif /* Move non-local gparts to the end of the list. */ - for (int k = 0; k < nr_gparts;) { + for (size_t k = 0; k < nr_gparts;) { if (cells[gind[k]].nodeID != local_nodeID) { cells[gind[k]].gcount -= 1; nr_gparts -= 1; @@ -590,7 +590,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { } /* Assign each particle to its cell. */ - for (int k = nr_gparts; k < s->nr_gparts; k++) { + for (size_t k = nr_gparts; k < s->nr_gparts; k++) { const struct gpart *const p = &s->gparts[k]; gind[k] = cell_getid(cdim, p->x[0] * ih[0], p->x[1] * ih[1], p->x[2] * ih[2]); @@ -1574,13 +1574,13 @@ void space_init(struct space *s, const struct swift_params *params, /* Check that all the part positions are reasonable, wrap if periodic. */ if (periodic) { - for (int k = 0; k < Npart; k++) + for (size_t k = 0; k < Npart; k++) for (int j = 0; j < 3; j++) { while (parts[k].x[j] < 0) parts[k].x[j] += dim[j]; while (parts[k].x[j] >= dim[j]) parts[k].x[j] -= dim[j]; } } else { - for (int k = 0; k < Npart; k++) + for (size_t k = 0; k < Npart; k++) for (int j = 0; j < 3; j++) if (parts[k].x[j] < 0 || parts[k].x[j] >= dim[j]) error("Not all particles are within the specified domain."); @@ -1588,13 +1588,13 @@ void space_init(struct space *s, const struct swift_params *params, /* Same for the gparts */ if (periodic) { - for (int k = 0; k < Ngpart; k++) + for (size_t k = 0; k < Ngpart; k++) for (int j = 0; j < 3; j++) { while (gparts[k].x[j] < 0) gparts[k].x[j] += dim[j]; while (gparts[k].x[j] >= dim[j]) gparts[k].x[j] -= dim[j]; } } else { - for (int k = 0; k < Ngpart; k++) + for (size_t k = 0; k < Ngpart; k++) for (int j = 0; j < 3; j++) if (gparts[k].x[j] < 0 || gparts[k].x[j] >= dim[j]) error("Not all g-particles are within the specified domain."); diff --git a/src/tools.c b/src/tools.c index b64e17849081994e1969d5f8de0636768dcb729a..148af4f612fd05d3724787c2908c0f229d3867c5 100644 --- a/src/tools.c +++ b/src/tools.c @@ -499,7 +499,7 @@ void engine_single_density(double *dim, long long int pid, hydro_init_part(&p); /* Loop over all particle pairs (force). */ - for (int k = 0; k < N; k++) { + for (k = 0; k < N; k++) { if (parts[k].id == p.id) continue; for (int i = 0; i < 3; i++) { dx[i] = p.x[i] - parts[k].x[i]; diff --git a/src/version.c b/src/version.c index 68a051fa08c53c68319c1e785c0c6503afe18f4d..8bd94e5651dbc597fcd80bc585a47c6633ee3993 100644 --- a/src/version.c +++ b/src/version.c @@ -218,7 +218,7 @@ const char *hdf5_version(void) { #ifdef HAVE_HDF5 unsigned int majnum, minnum, relnum; H5get_libversion(&majnum, &minnum, &relnum); - sprintf(version, "%i.%i.%i", majnum, minnum, relnum); + sprintf(version, "%u.%u.%u", majnum, minnum, relnum); #else sprintf(version, "Unknown version"); #endif