Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
7b8a55db
Commit
7b8a55db
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Single file i/o now writes chunked and compressed arrays.
parent
c71b6dcc
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!98
Compressed i/o
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/single_io.c
+36
-11
36 additions, 11 deletions
src/single_io.c
with
36 additions
and
11 deletions
src/single_io.c
+
36
−
11
View file @
7b8a55db
...
...
@@ -94,7 +94,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N,
* "compulsory": "optional ", name); */
/* Open data space */
h_data
=
H5Dopen
1
(
grp
,
name
);
h_data
=
H5Dopen
(
grp
,
name
,
H5P_DEFAULT
);
if
(
h_data
<
0
)
{
error
(
"Error while opening data space '%s'."
,
name
);
}
...
...
@@ -157,7 +157,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
enum
DATA_TYPE
type
,
int
N
,
int
dim
,
char
*
part_c
,
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
;
void
*
temp
=
0
;
int
i
=
0
,
rank
=
0
;
const
size_t
typeSize
=
sizeOfType
(
type
);
...
...
@@ -165,9 +165,10 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
const
size_t
partSize
=
sizeof
(
struct
part
);
char
*
temp_c
=
0
;
hsize_t
shape
[
2
];
hsize_t
chunk_shape
[
2
];
char
buffer
[
150
];
/*
message("Writing '%s' array...", name);
*/
message
(
"Writing '%s' array..."
,
name
);
/* Allocate temporary buffer */
temp
=
malloc
(
N
*
dim
*
sizeOfType
(
type
));
...
...
@@ -188,10 +189,14 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
rank
=
2
;
shape
[
0
]
=
N
;
shape
[
1
]
=
dim
;
chunk_shape
[
0
]
=
1
<<
16
;
/* Just a guess...*/
chunk_shape
[
1
]
=
dim
;
}
else
{
rank
=
1
;
shape
[
0
]
=
N
;
shape
[
1
]
=
0
;
chunk_shape
[
0
]
=
1
<<
16
;
/* Just a guess...*/
chunk_shape
[
1
]
=
0
;
}
/* Change shape of data space */
...
...
@@ -200,8 +205,25 @@ void writeArrayBackEnd(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
=
H5Dcreate1
(
grp
,
name
,
hdf5Type
(
type
),
h_space
,
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
);
}
...
...
@@ -225,6 +247,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name,
/* Free and close everything */
free
(
temp
);
H5Pclose
(
h_prop
);
H5Dclose
(
h_data
);
H5Sclose
(
h_space
);
}
...
...
@@ -313,7 +336,7 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts, int* N,
/* Open header to read simulation properties */
/* message("Reading runtime parameters..."); */
h_grp
=
H5Gopen
1
(
h_file
,
"/RuntimePars"
);
h_grp
=
H5Gopen
(
h_file
,
"/RuntimePars"
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while opening runtime parameters
\n
"
);
/* Read the relevant information */
...
...
@@ -324,7 +347,7 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts, int* N,
/* Open header to read simulation properties */
/* message("Reading file header..."); */
h_grp
=
H5Gopen
1
(
h_file
,
"/Header"
);
h_grp
=
H5Gopen
(
h_file
,
"/Header"
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while opening file header
\n
"
);
/* Read the relevant information and print status */
...
...
@@ -352,7 +375,7 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts, int* N,
/* Open SPH particles group */
/* message("Reading particle arrays..."); */
h_grp
=
H5Gopen
1
(
h_file
,
"/PartType0"
);
h_grp
=
H5Gopen
(
h_file
,
"/PartType0"
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while opening particle group.
\n
"
);
/* Read particle fields into the particle structure */
...
...
@@ -415,7 +438,8 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Open header to write simulation properties */
/* message("Writing runtime parameters..."); */
h_grp
=
H5Gcreate1
(
h_file
,
"/RuntimePars"
,
0
);
h_grp
=
H5Gcreate
(
h_file
,
"/RuntimePars"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while creating runtime parameters group
\n
"
);
/* Write the relevant information */
...
...
@@ -426,7 +450,7 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Open header to write simulation properties */
/* message("Writing file header..."); */
h_grp
=
H5Gcreate
1
(
h_file
,
"/Header"
,
0
);
h_grp
=
H5Gcreate
(
h_file
,
"/Header"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while creating file header
\n
"
);
/* Print the relevant information and print status */
...
...
@@ -451,7 +475,7 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
writeCodeDescription
(
h_file
);
/* Print the SPH parameters */
h_grpsph
=
H5Gcreate
1
(
h_file
,
"/SPH"
,
0
);
h_grpsph
=
H5Gcreate
(
h_file
,
"/SPH"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grpsph
<
0
)
error
(
"Error while creating SPH group"
);
writeSPHflavour
(
h_grpsph
);
H5Gclose
(
h_grpsph
);
...
...
@@ -461,7 +485,8 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Create SPH particles group */
/* message("Writing particle arrays..."); */
h_grp
=
H5Gcreate1
(
h_file
,
"/PartType0"
,
0
);
h_grp
=
H5Gcreate
(
h_file
,
"/PartType0"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while creating particle group.
\n
"
);
/* Write particle fields from the particle structure */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment