Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Cubism
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mavt-cse
Cubism
Commits
6b0dac6b
Commit
6b0dac6b
authored
Aug 09, 2019
by
kicici
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HDF slice filename format option
parent
b23564c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
include/Cubism/HDF5SliceDumperMPI.h
include/Cubism/HDF5SliceDumperMPI.h
+20
-16
No files found.
include/Cubism/HDF5SliceDumperMPI.h
View file @
6b0dac6b
...
...
@@ -98,6 +98,8 @@ namespace SliceTypesMPI
};
}
enum
class
DumpSliceFilenameFormat
{
FNAME_SLICE_ID
,
SLICE_ID_FNAME
};
///////////////////////////////////////////////////////////////////////////////
// Dumpers
//
...
...
@@ -106,22 +108,24 @@ namespace SliceTypesMPI
// TStreamer::operate : Data access methods for read and write
// TStreamer::getAttributeName : Attribute name of the date ("Scalar", "Vector", "Tensor")
template
<
typename
TStreamer
,
typename
hdf5Real
,
typename
TSlice
>
void
DumpSliceHDF5MPI
(
const
TSlice
&
slice
,
const
int
stepID
,
const
typename
TSlice
::
GridType
::
Real
t
,
const
std
::
string
&
fname
,
const
std
::
string
&
dpath
=
"."
,
const
bool
bXMF
=
true
)
void
DumpSliceHDF5MPI
(
const
TSlice
&
slice
,
const
int
stepID
,
const
typename
TSlice
::
GridType
::
Real
t
,
const
std
::
string
&
fname
,
const
std
::
string
&
dpath
=
"."
,
const
bool
bXMF
=
true
,
const
DumpSliceFilenameFormat
format
=
DumpSliceFilenameFormat
::
FNAME_SLICE_ID
)
{
#ifdef CUBISM_USE_HDF
typedef
typename
TSlice
::
GridType
::
BlockType
B
;
// fname is the base filepath tail without file type extension and
// additional identifiers
std
::
ostringstream
filename
;
std
::
ostringstream
fullpath
;
filename
<<
"slice_"
<<
slice
.
id
()
<<
fname
;
fullpath
<<
dpath
<<
"/"
<<
filename
.
str
()
;
const
std
::
string
filename
=
format
==
DumpSliceFilenameFormat
::
FNAME_SLICE_ID
?
fname
+
"_slice"
+
std
::
to_string
(
slice
.
id
())
:
"slice_"
+
std
::
to_string
(
slice
.
id
())
+
fname
;
std
::
string
fullpath
=
dpath
+
"/"
+
filename
;
static
const
unsigned
int
NCHANNELS
=
TStreamer
::
NCHANNELS
;
const
unsigned
int
width
=
slice
.
localWidth
();
...
...
@@ -144,7 +148,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
{
H5open
();
fapl_id
=
H5Pcreate
(
H5P_FILE_ACCESS
);
file_id
=
H5Fcreate
((
fullpath
.
str
()
+
".h5"
).
c_str
(),
H5F_ACC_TRUNC
,
H5P_DEFAULT
,
fapl_id
);
file_id
=
H5Fcreate
((
fullpath
+
".h5"
).
c_str
(),
H5F_ACC_TRUNC
,
H5P_DEFAULT
,
fapl_id
);
status
=
H5Pclose
(
fapl_id
);
for
(
size_t
i
=
0
;
i
<
2
;
++
i
)
...
...
@@ -179,7 +183,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
H5open
();
fapl_id
=
H5Pcreate
(
H5P_FILE_ACCESS
);
status
=
H5Pset_fapl_mpio
(
fapl_id
,
comm
,
MPI_INFO_NULL
);
if
(
status
<
0
)
H5Eprint1
(
stdout
);
file_id
=
H5Fopen
((
fullpath
.
str
()
+
".h5"
).
c_str
(),
H5F_ACC_RDWR
,
fapl_id
);
file_id
=
H5Fopen
((
fullpath
+
".h5"
).
c_str
(),
H5F_ACC_RDWR
,
fapl_id
);
status
=
H5Pclose
(
fapl_id
);
if
(
status
<
0
)
H5Eprint1
(
stdout
);
///////////////////////////////////////////////////////////////////////////
...
...
@@ -250,7 +254,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
if
(
bXMF
&&
0
==
myRank
)
{
FILE
*
xmf
=
0
;
xmf
=
fopen
((
fullpath
.
str
()
+
".xmf"
).
c_str
(),
"w"
);
xmf
=
fopen
((
fullpath
+
".xmf"
).
c_str
(),
"w"
);
fprintf
(
xmf
,
"<?xml version=
\"
1.0
\"
?>
\n
"
);
fprintf
(
xmf
,
"<!DOCTYPE Xdmf SYSTEM
\"
Xdmf.dtd
\"
[]>
\n
"
);
fprintf
(
xmf
,
"<Xdmf Version=
\"
2.0
\"
>
\n
"
);
...
...
@@ -263,15 +267,15 @@ void DumpSliceHDF5MPI(const TSlice& slice,
fprintf
(
xmf
,
" %e
\n
"
,
0.0
);
fprintf
(
xmf
,
" </DataItem>
\n
"
);
fprintf
(
xmf
,
" <DataItem Name=
\"
mesh_vy
\"
Dimensions=
\"
%d
\"
NumberType=
\"
Float
\"
Precision=
\"
8
\"
Format=
\"
HDF
\"
>
\n
"
,
mesh_dims
[
0
]);
fprintf
(
xmf
,
" %s:/vwidth
\n
"
,(
filename
.
str
()
+
".h5"
).
c_str
());
fprintf
(
xmf
,
" %s:/vwidth
\n
"
,(
filename
+
".h5"
).
c_str
());
fprintf
(
xmf
,
" </DataItem>
\n
"
);
fprintf
(
xmf
,
" <DataItem Name=
\"
mesh_vz
\"
Dimensions=
\"
%d
\"
NumberType=
\"
Float
\"
Precision=
\"
8
\"
Format=
\"
HDF
\"
>
\n
"
,
mesh_dims
[
1
]);
fprintf
(
xmf
,
" %s:/vheight
\n
"
,(
filename
.
str
()
+
".h5"
).
c_str
());
fprintf
(
xmf
,
" %s:/vheight
\n
"
,(
filename
+
".h5"
).
c_str
());
fprintf
(
xmf
,
" </DataItem>
\n
"
);
fprintf
(
xmf
,
" </Geometry>
\n\n
"
);
fprintf
(
xmf
,
" <Attribute Name=
\"
data
\"
AttributeType=
\"
%s
\"
Center=
\"
Cell
\"
>
\n
"
,
TStreamer
::
getAttributeName
());
fprintf
(
xmf
,
" <DataItem Dimensions=
\"
%d %d %d
\"
NumberType=
\"
Float
\"
Precision=
\"
%d
\"
Format=
\"
HDF
\"
>
\n
"
,
(
int
)
dims
[
0
],
(
int
)
dims
[
1
],
(
int
)
dims
[
2
],
(
int
)
sizeof
(
hdf5Real
));
fprintf
(
xmf
,
" %s:/data
\n
"
,(
filename
.
str
()
+
".h5"
).
c_str
());
fprintf
(
xmf
,
" %s:/data
\n
"
,(
filename
+
".h5"
).
c_str
());
fprintf
(
xmf
,
" </DataItem>
\n
"
);
fprintf
(
xmf
,
" </Attribute>
\n
"
);
fprintf
(
xmf
,
" </Grid>
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment