Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
1 merge request!220Allow the users to change the compression rate of datasets.
...@@ -25,6 +25,7 @@ Snapshots: ...@@ -25,6 +25,7 @@ Snapshots:
basename: output # Common part of the name of output files basename: output # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.01 # Time difference between consecutive outputs (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) UnitMass_in_cgs: 1 # (Optional) Unit system for the outputs (Grams)
UnitLength_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters) UnitLength_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters)
UnitVelocity_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters per second) 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, ...@@ -2918,6 +2918,8 @@ void engine_init(struct engine *e, struct space *s,
parser_get_param_double(params, "Snapshots:delta_time"); parser_get_param_double(params, "Snapshots:delta_time");
e->ti_nextSnapshot = 0; e->ti_nextSnapshot = 0;
parser_get_param_string(params, "Snapshots:basename", e->snapshotBaseName); 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)); e->snapshotUnits = malloc(sizeof(struct UnitSystem));
units_init_default(e->snapshotUnits, params, "Snapshots", internal_units); units_init_default(e->snapshotUnits, params, "Snapshots", internal_units);
e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min"); e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
......
...@@ -150,6 +150,7 @@ struct engine { ...@@ -150,6 +150,7 @@ struct engine {
double deltaTimeSnapshot; double deltaTimeSnapshot;
int ti_nextSnapshot; int ti_nextSnapshot;
char snapshotBaseName[200]; char snapshotBaseName[200];
int snapshotCompression;
struct UnitSystem *snapshotUnits; struct UnitSystem *snapshotUnits;
/* Statistics information */ /* Statistics information */
......
...@@ -224,10 +224,12 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, ...@@ -224,10 +224,12 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile,
} }
/* Impose data compression */ /* Impose data compression */
h_err = H5Pset_deflate(h_prop, 4); if(e->snapshotCompression > 0) {
if (h_err < 0) { h_err = H5Pset_deflate(h_prop, e->snapshotCompression);
error("Error while setting compression options for field '%s'.", if (h_err < 0) {
props.name); error("Error while setting compression options for field '%s'.",
props.name);
}
} }
/* Create dataset */ /* Create dataset */
......
...@@ -261,10 +261,12 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile, ...@@ -261,10 +261,12 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
} }
/* Impose data compression */ /* Impose data compression */
h_err = H5Pset_deflate(h_prop, 4); if (e->snapshotCompression > 0) {
if (h_err < 0) { h_err = H5Pset_deflate(h_prop, e->snapshotCompression);
error("Error while setting compression options for field '%s'.", if (h_err < 0) {
props.name); error("Error while setting compression options for field '%s'.",
props.name);
}
} }
/* Create dataset */ /* Create dataset */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment