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

Compression now also in serial mode.

parent f5033d79
Branches
Tags
2 merge requests!136Master,!98Compressed i/o
......@@ -175,9 +175,10 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
enum DATA_TYPE type, long long N_total, int dim,
struct UnitSystem* us, enum UnitConversionFactor convFactor) {
hid_t h_data = 0, h_err = 0, h_space = 0;
hid_t h_data = 0, h_err = 0, h_space = 0, h_prop = 0;
int rank = 0;
hsize_t shape[2];
hsize_t chunk_shape[2];
char buffer[150];
/* Create data space */
......@@ -190,10 +191,14 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
rank = 2;
shape[0] = N_total;
shape[1] = dim;
chunk_shape[0] = 1 << 16; /* Just a guess...*/
chunk_shape[1] = dim;
} else {
rank = 1;
shape[0] = N_total;
shape[1] = 0;
chunk_shape[0] = 1 << 16; /* Just a guess...*/
chunk_shape[1] = 0;
}
/* Change shape of data space */
......@@ -202,8 +207,24 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
error("Error while changing data space shape for field '%s'.", name);
}
/* Dataset properties */
h_prop = H5Pcreate(H5P_DATASET_CREATE);
/* 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'.",
chunk_shape[0], chunk_shape[1], name);
}
/* Impose data compression */
h_err = H5Pset_deflate(h_prop, 4);
if (h_err < 0) {
error("Error while setting compression options for field '%s'.", name);
}
/* Create dataset */
h_data = H5Dcreate(grp, name, hdf5Type(type), h_space, H5P_DEFAULT, H5P_DEFAULT,
h_data = H5Dcreate(grp, name, hdf5Type(type), h_space, H5P_DEFAULT, h_prop,
H5P_DEFAULT);
if (h_data < 0) {
error("Error while creating dataspace '%s'.", name);
......@@ -220,6 +241,7 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name,
writeAttribute_f(h_data, "a-scale exponent", aFactor(us, convFactor));
writeAttribute_s(h_data, "Conversion factor", buffer);
H5Pclose(h_prop);
H5Dclose(h_data);
H5Sclose(h_space);
}
......@@ -612,7 +634,7 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
/* Create SPH particles group */
/* message("Writing particle arrays..."); */
h_grp = H5Gcreate(h_file, "/PartType0", H5P_DEFAULT);
h_grp = H5Gcreate(h_file, "/PartType0", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (h_grp < 0) error("Error while creating particle group.\n");
/* Close particle group */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment