Commit 81aee06b authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'snapshot_compression' into 'master'

Allow the users to change the compression rate of datasets.

Compression is switched off by default for performance.

See merge request !220
parents 4d45b74f c257ba94
......@@ -25,6 +25,7 @@ Snapshots:
basename: output # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units)
delta_time: 0.01 # Time difference between consecutive outputs (in internal units)
compression: 0 # (Optional) Set the level of compression of the HDF5 datasets [0-9]. 0 does no compression.
UnitMass_in_cgs: 1 # (Optional) Unit system for the outputs (Grams)
UnitLength_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters)
UnitVelocity_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters per second)
......
......@@ -2918,6 +2918,8 @@ void engine_init(struct engine *e, struct space *s,
parser_get_param_double(params, "Snapshots:delta_time");
e->ti_nextSnapshot = 0;
parser_get_param_string(params, "Snapshots:basename", e->snapshotBaseName);
e->snapshotCompression =
parser_get_opt_param_int(params, "Snapshots:compression", 0);
e->snapshotUnits = malloc(sizeof(struct UnitSystem));
units_init_default(e->snapshotUnits, params, "Snapshots", internal_units);
e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
......
......@@ -150,6 +150,7 @@ struct engine {
double deltaTimeSnapshot;
int ti_nextSnapshot;
char snapshotBaseName[200];
int snapshotCompression;
struct UnitSystem *snapshotUnits;
/* Statistics information */
......
......@@ -176,7 +176,7 @@ void readArray(hid_t grp, const struct io_props props, size_t N,
* Routines writing an output file
*-----------------------------------------------------------------------------*/
void prepareArray(hid_t grp, char* fileName, FILE* xmfFile,
void prepareArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
char* partTypeGroupName, const struct io_props props,
long long N_total, const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units) {
......@@ -224,10 +224,12 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile,
}
/* Impose data compression */
h_err = H5Pset_deflate(h_prop, 4);
if (h_err < 0) {
error("Error while setting compression options for field '%s'.",
props.name);
if(e->snapshotCompression > 0) {
h_err = H5Pset_deflate(h_prop, e->snapshotCompression);
if (h_err < 0) {
error("Error while setting compression options for field '%s'.",
props.name);
}
}
/* Create dataset */
......@@ -291,7 +293,7 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
/* Prepare the arrays in the file */
if (mpi_rank == 0)
prepareArray(grp, fileName, xmfFile, partTypeGroupName, props, N_total,
prepareArray(e, grp, fileName, xmfFile, partTypeGroupName, props, N_total,
internal_units, snapshot_units);
/* Allocate temporary buffer */
......
......@@ -261,10 +261,12 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
}
/* Impose data compression */
h_err = H5Pset_deflate(h_prop, 4);
if (h_err < 0) {
error("Error while setting compression options for field '%s'.",
props.name);
if (e->snapshotCompression > 0) {
h_err = H5Pset_deflate(h_prop, e->snapshotCompression);
if (h_err < 0) {
error("Error while setting compression options for field '%s'.",
props.name);
}
}
/* Create dataset */
......
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