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
302b8e47
Commit
302b8e47
authored
3 years ago
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
use hdf5_tools::hdf5_type_id to simplify code
parent
1ae9d5ba
No related branches found
No related tags found
2 merge requests
!48
merge develop
,
!46
Feature/warning free
Pipeline
#138759
failed
3 years ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpp/hdf5_tools.cpp
+5
-22
5 additions, 22 deletions
cpp/hdf5_tools.cpp
with
5 additions
and
22 deletions
cpp/hdf5_tools.cpp
+
5
−
22
View file @
302b8e47
...
@@ -208,13 +208,7 @@ std::vector<number> hdf5_tools::read_vector(
...
@@ -208,13 +208,7 @@ std::vector<number> hdf5_tools::read_vector(
hsize_t
vector_length
;
hsize_t
vector_length
;
// first, read size of array
// first, read size of array
hid_t
dset
,
dspace
;
hid_t
dset
,
dspace
;
hid_t
mem_dtype
;
hid_t
mem_dtype
=
H5Tcopy
(
hdf5_tools
::
hdf5_type_id
<
number
>
());
if
(
typeid
(
number
)
==
typeid
(
int
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_INT
);
else
if
(
typeid
(
number
)
==
typeid
(
double
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_DOUBLE
);
else
return
result
;
dset
=
H5Dopen
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
dset
=
H5Dopen
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
dspace
=
H5Dget_space
(
dset
);
dspace
=
H5Dget_space
(
dset
);
assert
(
H5Sget_simple_extent_ndims
(
dspace
)
==
1
);
assert
(
H5Sget_simple_extent_ndims
(
dspace
)
==
1
);
...
@@ -235,15 +229,7 @@ number hdf5_tools::read_value(
...
@@ -235,15 +229,7 @@ number hdf5_tools::read_value(
TIMEZONE
(
"hdf5_tools::read_value"
);
TIMEZONE
(
"hdf5_tools::read_value"
);
number
result
;
number
result
;
hid_t
dset
;
hid_t
dset
;
hid_t
mem_dtype
;
hid_t
mem_dtype
=
H5Tcopy
(
hdf5_tools
::
hdf5_type_id
<
number
>
());
if
(
typeid
(
number
)
==
typeid
(
int
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_INT
);
else
if
(
typeid
(
number
)
==
typeid
(
long
long
int
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_LLONG
);
else
if
(
typeid
(
number
)
==
typeid
(
double
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_DOUBLE
);
else
return
result
;
if
(
H5Lexists
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
))
if
(
H5Lexists
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
))
{
{
dset
=
H5Dopen
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
dset
=
H5Dopen
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
...
@@ -270,13 +256,10 @@ int hdf5_tools::write_value_with_single_rank(
...
@@ -270,13 +256,10 @@ int hdf5_tools::write_value_with_single_rank(
const
std
::
string
dset_name
,
const
std
::
string
dset_name
,
const
number
value
)
const
number
value
)
{
{
assert
(
typeid
(
number
)
==
typeid
(
int
)
||
typeid
(
number
)
==
typeid
(
double
));
hid_t
dset
,
mem_dtype
;
hid_t
dset
,
mem_dtype
;
if
(
typeid
(
number
)
==
typeid
(
int
))
mem_dtype
=
H5Tcopy
(
hdf5_tools
::
hdf5_type_id
<
number
>
());
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_INT
);
else
if
(
typeid
(
number
)
==
typeid
(
double
))
mem_dtype
=
H5Tcopy
(
H5T_NATIVE_DOUBLE
);
else
return
EXIT_FAILURE
;
if
(
H5Lexists
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
))
if
(
H5Lexists
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
))
{
{
dset
=
H5Dopen
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
dset
=
H5Dopen
(
group
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
...
...
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