Skip to content
Snippets Groups Projects
Commit 2284d6d7 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

C++ fixes to serial i/o.

parent a9030eb3
No related branches found
No related tags found
No related merge requests found
...@@ -149,10 +149,10 @@ void readArray(hid_t grp, const struct io_props props, size_t N, ...@@ -149,10 +149,10 @@ void readArray(hid_t grp, const struct io_props props, size_t N,
/* message("Converting ! factor=%e", factor); */ /* message("Converting ! factor=%e", factor); */
if (io_is_double_precision(props.type)) { if (io_is_double_precision(props.type)) {
double* temp_d = temp; double* temp_d = (double*)temp;
for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor;
} else { } else {
float* temp_f = temp; float* temp_f = (float*)temp;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
float maximum = 0.f; float maximum = 0.f;
...@@ -220,7 +220,7 @@ void readArray(hid_t grp, const struct io_props props, size_t N, ...@@ -220,7 +220,7 @@ void readArray(hid_t grp, const struct io_props props, size_t N,
} }
/* Copy temporary buffer to particle data */ /* Copy temporary buffer to particle data */
char* temp_c = temp; char* temp_c = (char*)temp;
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; ++i)
memcpy(props.field + i * props.partSize, &temp_c[i * copySize], copySize); memcpy(props.field + i * props.partSize, &temp_c[i * copySize], copySize);
...@@ -474,7 +474,8 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units, ...@@ -474,7 +474,8 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units,
long long offset[swift_type_count] = {0}; long long offset[swift_type_count] = {0};
int dimension = 3; /* Assume 3D if nothing is specified */ int dimension = 3; /* Assume 3D if nothing is specified */
size_t Ndm = 0; size_t Ndm = 0;
struct unit_system* ic_units = malloc(sizeof(struct unit_system)); struct unit_system* ic_units =
(struct unit_system*)malloc(sizeof(struct unit_system));
/* First read some information about the content */ /* First read some information about the content */
if (mpi_rank == 0) { if (mpi_rank == 0) {
...@@ -592,8 +593,8 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units, ...@@ -592,8 +593,8 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units,
/* Allocate memory to store SPH particles */ /* Allocate memory to store SPH particles */
if (with_hydro) { if (with_hydro) {
*Ngas = N[0]; *Ngas = N[0];
if (posix_memalign((void*)parts, part_align, *Ngas * sizeof(struct part)) != if (posix_memalign((void**)parts, part_align,
0) *Ngas * sizeof(struct part)) != 0)
error("Error while allocating memory for SPH particles"); error("Error while allocating memory for SPH particles");
bzero(*parts, *Ngas * sizeof(struct part)); bzero(*parts, *Ngas * sizeof(struct part));
} }
...@@ -601,7 +602,7 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units, ...@@ -601,7 +602,7 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units,
/* Allocate memory to store stars particles */ /* Allocate memory to store stars particles */
if (with_stars) { if (with_stars) {
*Nstars = N[swift_type_stars]; *Nstars = N[swift_type_stars];
if (posix_memalign((void*)sparts, spart_align, if (posix_memalign((void**)sparts, spart_align,
*Nstars * sizeof(struct spart)) != 0) *Nstars * sizeof(struct spart)) != 0)
error("Error while allocating memory for stars particles"); error("Error while allocating memory for stars particles");
bzero(*sparts, *Nstars * sizeof(struct spart)); bzero(*sparts, *Nstars * sizeof(struct spart));
...@@ -613,7 +614,7 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units, ...@@ -613,7 +614,7 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units,
*Ngparts = (with_hydro ? N[swift_type_gas] : 0) + *Ngparts = (with_hydro ? N[swift_type_gas] : 0) +
N[swift_type_dark_matter] + N[swift_type_dark_matter] +
(with_stars ? N[swift_type_stars] : 0); (with_stars ? N[swift_type_stars] : 0);
if (posix_memalign((void*)gparts, gpart_align, if (posix_memalign((void**)gparts, gpart_align,
*Ngparts * sizeof(struct gpart)) != 0) *Ngparts * sizeof(struct gpart)) != 0)
error("Error while allocating memory for gravity particles"); error("Error while allocating memory for gravity particles");
bzero(*gparts, *Ngparts * sizeof(struct gpart)); bzero(*gparts, *Ngparts * sizeof(struct gpart));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment