Commit 82dc339c authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Removed unnecessary brackets in the i/o modules.

parent 099a44d5
......@@ -119,9 +119,7 @@ void readArray_chunk(hid_t h_data, hid_t h_plist_id,
/* Using HDF5 dataspaces would be better */
const hid_t h_err = H5Dread(h_data, io_hdf5_type(props.type), h_memspace,
h_filespace, h_plist_id, temp);
if (h_err < 0) {
error("Error while reading data array '%s'.", props.name);
}
if (h_err < 0) error("Error while reading data array '%s'.", props.name);
/* Unit conversion if necessary */
const double factor =
......@@ -387,10 +385,9 @@ void writeArray_chunk(struct engine* e, hid_t h_data,
/* Create data space */
const hid_t h_memspace = H5Screate(H5S_SIMPLE);
if (h_memspace < 0) {
if (h_memspace < 0)
error("Error while creating data space (memory) for field '%s'.",
props.name);
}
int rank;
hsize_t shape[2];
......@@ -411,19 +408,17 @@ void writeArray_chunk(struct engine* e, hid_t h_data,
/* Change shape of memory data space */
hid_t h_err = H5Sset_extent_simple(h_memspace, rank, shape, NULL);
if (h_err < 0) {
if (h_err < 0)
error("Error while changing data space (memory) shape for field '%s'.",
props.name);
}
/* Select the hyper-salb corresponding to this rank */
hid_t h_filespace = H5Dget_space(h_data);
if (N > 0) {
if (N > 0)
H5Sselect_hyperslab(h_filespace, H5S_SELECT_SET, offsets, NULL, shape,
NULL);
} else {
else
H5Sselect_none(h_filespace);
}
/* message("Writing %lld '%s', %zd elements = %zd bytes (int=%d) at offset
* %zd", N, props.name, N * props.dimension, N * props.dimension * typeSize, */
......@@ -437,9 +432,7 @@ void writeArray_chunk(struct engine* e, hid_t h_data,
/* Write temporary buffer to HDF5 dataspace */
h_err = H5Dwrite(h_data, io_hdf5_type(props.type), h_memspace, h_filespace,
H5P_DEFAULT, temp);
if (h_err < 0) {
error("Error while writing data array '%s'.", props.name);
}
if (h_err < 0) error("Error while writing data array '%s'.", props.name);
#ifdef IO_SPEED_MEASUREMENT
MPI_Barrier(MPI_COMM_WORLD);
......@@ -590,9 +583,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
hid_t h_plist_id = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_mpio(h_plist_id, comm, info);
h_file = H5Fopen(fileName, H5F_ACC_RDONLY, h_plist_id);
if (h_file < 0) {
error("Error while opening file '%s'.", fileName);
}
if (h_file < 0) error("Error while opening file '%s'.", fileName);
/* Open header to read simulation properties */
/* message("Reading runtime parameters..."); */
......@@ -651,8 +642,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
}
/* message("Found %lld particles in a %speriodic box of size [%f %f %f].", */
/* N_total[0], (periodic ? "": "non-"), dim[0], */
/* dim[1], dim[2]); */
/* N_total[0], (periodic ? "": "non-"), dim[0], dim[1], dim[2]); */
/* Divide the particles among the tasks. */
for (int ptype = 0; ptype < swift_type_count; ++ptype) {
......@@ -752,9 +742,8 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
snprintf(partTypeGroupName, PARTICLE_GROUP_BUFFER_SIZE, "/PartType%d",
ptype);
h_grp = H5Gopen(h_file, partTypeGroupName, H5P_DEFAULT);
if (h_grp < 0) {
if (h_grp < 0)
error("Error while opening particle group %s.", partTypeGroupName);
}
int num_fields = 0;
struct io_props list[100];
......@@ -1167,9 +1156,7 @@ void write_output_parallel(struct engine* e, const char* baseName,
/* Open HDF5 file with the chosen parameters */
hid_t h_file = H5Fopen(fileName, H5F_ACC_RDWR, plist_id);
if (h_file < 0) {
error("Error while opening file '%s'.", fileName);
}
if (h_file < 0) error("Error while opening file '%s'.", fileName);
#ifdef IO_SPEED_MEASUREMENT
MPI_Barrier(MPI_COMM_WORLD);
......
......@@ -137,9 +137,7 @@ void readArray(hid_t grp, const struct io_props props, size_t N,
/* Using HDF5 dataspaces would be better */
const hid_t h_err = H5Dread(h_data, io_hdf5_type(props.type), h_memspace,
h_filespace, H5P_DEFAULT, temp);
if (h_err < 0) {
error("Error while reading data array '%s'.", props.name);
}
if (h_err < 0) error("Error while reading data array '%s'.", props.name);
/* Unit conversion if necessary */
const double factor =
......@@ -198,9 +196,8 @@ void prepareArray(const struct engine* e, hid_t grp, char* fileName,
/* Create data space */
const hid_t h_space = H5Screate(H5S_SIMPLE);
if (h_space < 0) {
if (h_space < 0)
error("Error while creating data space for field '%s'.", props.name);
}
int rank = 0;
hsize_t shape[2];
......@@ -224,19 +221,17 @@ void prepareArray(const struct engine* e, hid_t grp, char* fileName,
/* Change shape of data space */
hid_t h_err = H5Sset_extent_simple(h_space, rank, shape, shape);
if (h_err < 0) {
if (h_err < 0)
error("Error while changing data space shape for field '%s'.", props.name);
}
/* Dataset properties */
const hid_t h_prop = H5Pcreate(H5P_DATASET_CREATE);
/* Set chunk size */
h_err = H5Pset_chunk(h_prop, rank, chunk_shape);
if (h_err < 0) {
if (h_err < 0)
error("Error while setting chunk size (%llu, %llu) for field '%s'.",
chunk_shape[0], chunk_shape[1], props.name);
}
/* Impose data compression */
if (e->snapshot_compression > 0) {
......@@ -254,9 +249,7 @@ void prepareArray(const struct engine* e, hid_t grp, char* fileName,
/* Create dataset */
const hid_t h_data = H5Dcreate(grp, props.name, io_hdf5_type(props.type),
h_space, H5P_DEFAULT, h_prop, H5P_DEFAULT);
if (h_data < 0) {
error("Error while creating dataspace '%s'.", props.name);
}
if (h_data < 0) error("Error while creating dataspace '%s'.", props.name);
/* Write XMF description for this data set */
xmf_write_line(xmfFile, fileName, partTypeGroupName, props.name, N_total,
......@@ -497,10 +490,7 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units,
}
/* message("Found %lld particles in a %speriodic box of size [%f %f %f].",
*/
/* N_total, (periodic ? "": "non-"), dim[0], dim[1], dim[2]); */
fflush(stdout);
N_total, (periodic ? "": "non-"), dim[0], dim[1], dim[2]); */
/* Close header */
H5Gclose(h_grp);
......@@ -618,9 +608,8 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units,
snprintf(partTypeGroupName, PARTICLE_GROUP_BUFFER_SIZE, "/PartType%d",
ptype);
h_grp = H5Gopen(h_file, partTypeGroupName, H5P_DEFAULT);
if (h_grp < 0) {
if (h_grp < 0)
error("Error while opening particle group %s.", partTypeGroupName);
}
int num_fields = 0;
struct io_props list[100];
......@@ -777,9 +766,7 @@ void write_output_serial(struct engine* e, const char* baseName,
/* Open file */
/* message("Opening file '%s'.", fileName); */
h_file = H5Fcreate(fileName, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (h_file < 0) {
error("Error while opening file '%s'.", fileName);
}
if (h_file < 0) error("Error while opening file '%s'.", fileName);
/* Open header to write simulation properties */
/* message("Writing runtime parameters..."); */
......@@ -933,9 +920,7 @@ void write_output_serial(struct engine* e, const char* baseName,
ptype);
h_grp = H5Gcreate(h_file, partTypeGroupName, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT);
if (h_grp < 0) {
error("Error while creating particle group.\n");
}
if (h_grp < 0) error("Error while creating particle group.\n");
/* Close particle group */
H5Gclose(h_grp);
......@@ -972,9 +957,8 @@ void write_output_serial(struct engine* e, const char* baseName,
snprintf(partTypeGroupName, PARTICLE_GROUP_BUFFER_SIZE, "/PartType%d",
ptype);
h_grp = H5Gopen(h_file, partTypeGroupName, H5P_DEFAULT);
if (h_grp < 0) {
if (h_grp < 0)
error("Error while opening particle group %s.", partTypeGroupName);
}
int num_fields = 0;
struct io_props list[100];
......
......@@ -102,9 +102,7 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N,
/* Open data space */
const hid_t h_data = H5Dopen(h_grp, prop.name, H5P_DEFAULT);
if (h_data < 0) {
error("Error while opening data space '%s'.", prop.name);
}
if (h_data < 0) error("Error while opening data space '%s'.", prop.name);
/* Allocate temporary buffer */
void* temp = malloc(num_elements * typeSize);
......@@ -115,9 +113,7 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N,
/* Using HDF5 dataspaces would be better */
const hid_t h_err = H5Dread(h_data, io_hdf5_type(prop.type), H5S_ALL, H5S_ALL,
H5P_DEFAULT, temp);
if (h_err < 0) {
error("Error while reading data array '%s'.", prop.name);
}
if (h_err < 0) error("Error while reading data array '%s'.", prop.name);
/* Unit conversion if necessary */
const double unit_factor =
......@@ -205,12 +201,12 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName,
/* Create data space */
const hid_t h_space = H5Screate(H5S_SIMPLE);
if (h_space < 0)
error("Error while creating data space for field '%s'.", props.name);
int rank;
hsize_t shape[2];
hsize_t chunk_shape[2];
if (h_space < 0) {
error("Error while creating data space for field '%s'.", props.name);
}
if (props.dimension > 1) {
rank = 2;
......@@ -231,19 +227,17 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName,
/* Change shape of data space */
hid_t h_err = H5Sset_extent_simple(h_space, rank, shape, shape);
if (h_err < 0) {
if (h_err < 0)
error("Error while changing data space shape for field '%s'.", props.name);
}
/* Dataset properties */
const hid_t h_prop = H5Pcreate(H5P_DATASET_CREATE);
/* Set chunk size */
h_err = H5Pset_chunk(h_prop, rank, chunk_shape);
if (h_err < 0) {
if (h_err < 0)
error("Error while setting chunk size (%llu, %llu) for field '%s'.",
chunk_shape[0], chunk_shape[1], props.name);
}
/* Impose data compression */
if (e->snapshot_compression > 0) {
......@@ -261,16 +255,12 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName,
/* Create dataset */
const hid_t h_data = H5Dcreate(grp, props.name, io_hdf5_type(props.type),
h_space, H5P_DEFAULT, h_prop, H5P_DEFAULT);
if (h_data < 0) {
error("Error while creating dataspace '%s'.", props.name);
}
if (h_data < 0) error("Error while creating dataspace '%s'.", props.name);
/* Write temporary buffer to HDF5 dataspace */
h_err = H5Dwrite(h_data, io_hdf5_type(props.type), h_space, H5S_ALL,
H5P_DEFAULT, temp);
if (h_err < 0) {
error("Error while writing data array '%s'.", props.name);
}
if (h_err < 0) error("Error while writing data array '%s'.", props.name);
/* Write XMF description for this data set */
xmf_write_line(xmfFile, fileName, partTypeGroupName, props.name, N,
......@@ -345,9 +335,7 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units,
/* Open file */
/* message("Opening file '%s' as IC.", fileName); */
h_file = H5Fopen(fileName, H5F_ACC_RDONLY, H5P_DEFAULT);
if (h_file < 0) {
error("Error while opening file '%s'.", fileName);
}
if (h_file < 0) error("Error while opening file '%s'.", fileName);
/* Open header to read simulation properties */
/* message("Reading runtime parameters..."); */
......@@ -498,9 +486,8 @@ void read_ic_single(char* fileName, const struct unit_system* internal_units,
snprintf(partTypeGroupName, PARTICLE_GROUP_BUFFER_SIZE, "/PartType%d",
ptype);
h_grp = H5Gopen(h_file, partTypeGroupName, H5P_DEFAULT);
if (h_grp < 0) {
if (h_grp < 0)
error("Error while opening particle group %s.", partTypeGroupName);
}
int num_fields = 0;
struct io_props list[100];
......@@ -631,9 +618,7 @@ void write_output_single(struct engine* e, const char* baseName,
/* Open file */
/* message("Opening file '%s'.", fileName); */
h_file = H5Fcreate(fileName, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (h_file < 0) {
error("Error while opening file '%s'.", fileName);
}
if (h_file < 0) error("Error while opening file '%s'.", fileName);
/* Open header to write simulation properties */
/* message("Writing runtime parameters..."); */
......@@ -791,9 +776,7 @@ void write_output_single(struct engine* e, const char* baseName,
ptype);
h_grp = H5Gcreate(h_file, partTypeGroupName, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT);
if (h_grp < 0) {
error("Error while creating particle group.\n");
}
if (h_grp < 0) error("Error while creating particle group.\n");
int num_fields = 0;
struct io_props list[100];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment