diff --git a/src/distributed_io.c b/src/distributed_io.c index abcf637160b25a43eb863efdeedced2a77346f42..4a1b9865bb013b5291405b900ef31e92538146f8 100644 --- a/src/distributed_io.c +++ b/src/distributed_io.c @@ -109,6 +109,9 @@ void write_distributed_array(const struct engine* e, hid_t grp, if (h_space < 0) error("Error while creating data space for field '%s'.", props.name); + /* Decide what chunk size to use based on compression */ + int log2_chunk_size = e->snapshot_compression > 0 ? 12 : 18; + int rank; hsize_t shape[2]; hsize_t chunk_shape[2]; @@ -117,13 +120,13 @@ void write_distributed_array(const struct engine* e, hid_t grp, rank = 2; shape[0] = N; shape[1] = props.dimension; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = props.dimension; } else { rank = 1; shape[0] = N; shape[1] = 0; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = 0; } diff --git a/src/line_of_sight.c b/src/line_of_sight.c index 4c1af849b0d4b1e09b10257a3134c3100753f2ca..32d37c84a96e86d7fecaf8496373f83dcc8d1397 100644 --- a/src/line_of_sight.c +++ b/src/line_of_sight.c @@ -286,6 +286,9 @@ void write_los_hdf5_dataset(const struct io_props props, const size_t N, if (h_space < 0) error("Error while creating data space for field '%s'.", props.name); + /* Decide what chunk size to use based on compression */ + int log2_chunk_size = e->snapshot_compression > 0 ? 12 : 18; + int rank = 0; hsize_t shape[2]; hsize_t chunk_shape[2]; @@ -293,13 +296,13 @@ void write_los_hdf5_dataset(const struct io_props props, const size_t N, rank = 2; shape[0] = N; shape[1] = props.dimension; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = props.dimension; } else { rank = 1; shape[0] = N; shape[1] = 0; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = 0; } diff --git a/src/serial_io.c b/src/serial_io.c index 8dcbcb56b8a61e799a49f13deaa3ac9af16cd6af..57289c15fbb21c693e7aa1f068045b19e898ce31 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -250,6 +250,9 @@ void prepare_array_serial(const struct engine* e, hid_t grp, char* fileName, if (h_space < 0) error("Error while creating data space for field '%s'.", props.name); + /* Decide what chunk size to use based on compression */ + int log2_chunk_size = e->snapshot_compression > 0 ? 12 : 18; + int rank = 0; hsize_t shape[2]; hsize_t chunk_shape[2]; @@ -257,13 +260,13 @@ void prepare_array_serial(const struct engine* e, hid_t grp, char* fileName, rank = 2; shape[0] = N_total; shape[1] = props.dimension; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = props.dimension; } else { rank = 1; shape[0] = N_total; shape[1] = 0; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = 0; } diff --git a/src/single_io.c b/src/single_io.c index 3086547fd8edbb8f8278157a8f3e24208ece2bc5..45e79169c99730c378c8ecf3f8503c48d78ee6d6 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -255,6 +255,9 @@ void write_array_single(const struct engine* e, hid_t grp, char* fileName, if (h_space < 0) error("Error while creating data space for field '%s'.", props.name); + /* Decide what chunk size to use based on compression */ + int log2_chunk_size = e->snapshot_compression > 0 ? 12 : 18; + int rank; hsize_t shape[2]; hsize_t chunk_shape[2]; @@ -263,13 +266,13 @@ void write_array_single(const struct engine* e, hid_t grp, char* fileName, rank = 2; shape[0] = N; shape[1] = props.dimension; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = props.dimension; } else { rank = 1; shape[0] = N; shape[1] = 0; - chunk_shape[0] = 1 << 20; /* Just a guess...*/ + chunk_shape[0] = 1 << log2_chunk_size; chunk_shape[1] = 0; }