Commit eb61d867 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Allow the users to change the compression rate of datasets. Compression is...

Allow the users to change the compression rate of datasets. Compression is switched off by default for performance.
parent 8f88c063
......@@ -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 */
......
......@@ -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 */
......
......@@ -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