Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
395528bd
Commit
395528bd
authored
5 years ago
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
adds hdf5 single value write method
parent
630e7e8a
No related branches found
No related tags found
1 merge request
!25
WIP: First version where particles that collide can be removed
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cpp/hdf5_tools.cpp
+42
-0
42 additions, 0 deletions
cpp/hdf5_tools.cpp
cpp/hdf5_tools.hpp
+6
-0
6 additions, 0 deletions
cpp/hdf5_tools.hpp
with
48 additions
and
0 deletions
cpp/hdf5_tools.cpp
+
42
−
0
View file @
395528bd
...
@@ -169,6 +169,36 @@ number hdf5_tools::read_value(
...
@@ -169,6 +169,36 @@ number hdf5_tools::read_value(
return
result
;
return
result
;
}
}
template
<
typename
number
>
int
hdf5_tools
::
write_value_with_single_rank
(
const
hid_t
group
,
const
std
::
string
dset_name
,
const
number
value
)
{
hid_t
dset
,
mem_dtype
;
if
(
typeid
(
number
)
==
typeid
(
int
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_INT
);
else
if
(
typeid
(
number
)
==
typeid
(
double
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_DOUBLE
);
if
(
H5Lexists
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
))
{
dset
=
H5Dopen
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
}
else
{
hid_t
fspace
;
hsize_t
count
[
1
];
count
[
0
]
=
1
;
fspace
=
H5Screate_simple
(
1
,
count
,
NULL
);
dset
=
H5Dcreate
(
group
,
dset_name
.
c_str
(),
mem_dtype
,
fspace
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
H5Sclose
(
fspace
);
}
H5Dwrite
(
dset
,
mem_dtype
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
&
value
);
H5Dclose
(
dset
);
H5Tclose
(
mem_dtype
);
return
EXIT_SUCCESS
;
}
template
<
typename
dtype
>
template
<
typename
dtype
>
std
::
vector
<
dtype
>
hdf5_tools
::
read_vector_with_single_rank
(
std
::
vector
<
dtype
>
hdf5_tools
::
read_vector_with_single_rank
(
const
int
myrank
,
const
int
myrank
,
...
@@ -269,3 +299,15 @@ double hdf5_tools::read_value<double>(
...
@@ -269,3 +299,15 @@ double hdf5_tools::read_value<double>(
const
hid_t
,
const
hid_t
,
const
std
::
string
);
const
std
::
string
);
template
int
hdf5_tools
::
write_value_with_single_rank
<
int
>(
const
hid_t
group
,
const
std
::
string
dset_name
,
const
int
value
);
template
int
hdf5_tools
::
write_value_with_single_rank
<
double
>(
const
hid_t
group
,
const
std
::
string
dset_name
,
const
double
value
);
This diff is collapsed.
Click to expand it.
cpp/hdf5_tools.hpp
+
6
−
0
View file @
395528bd
...
@@ -84,6 +84,12 @@ namespace hdf5_tools
...
@@ -84,6 +84,12 @@ namespace hdf5_tools
number
read_value
(
number
read_value
(
const
hid_t
group
,
const
hid_t
group
,
const
std
::
string
dset_name
);
const
std
::
string
dset_name
);
template
<
typename
number
>
int
write_value_with_single_rank
(
const
hid_t
group
,
const
std
::
string
dset_name
,
const
number
value
);
}
}
#endif//HDF5_TOOLS_HPP
#endif//HDF5_TOOLS_HPP
...
...
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