Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TurTLE
TurTLE
Commits
fe341a24
Commit
fe341a24
authored
Jun 01, 2017
by
Cristian Lalescu
Browse files
add "require_size" hdf5 functionality
parent
8c6fe88e
Pipeline
#13236
passed with stage
in 6 minutes and 4 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bfps/_base.py
View file @
fe341a24
...
...
@@ -175,9 +175,12 @@ class _base(object):
def
rewrite_par
(
self
,
group
=
None
,
parameters
=
None
):
parameters
=
None
,
file_name
=
None
):
assert
(
group
!=
'parameters'
)
ofile
=
h5py
.
File
(
os
.
path
.
join
(
self
.
work_dir
,
self
.
simname
+
'.h5'
),
'r+'
)
if
type
(
file_name
)
==
None
:
file_name
=
os
.
path
.
join
(
self
.
work_dir
,
self
.
simname
+
'.h5'
)
ofile
=
h5py
.
File
(
file_name
,
'a'
)
for
k
in
parameters
.
keys
():
if
group
not
in
ofile
.
keys
():
ofile
.
create_group
(
group
)
...
...
bfps/cpp/hdf5_tools.cpp
View file @
fe341a24
#include
"hdf5_tools.hpp"
int
hdf5_tools
::
require_size_single_dataset
(
hid_t
dset
,
int
tsize
)
{
int
ndims
;
hsize_t
space
;
space
=
H5Dget_space
(
dset
);
ndims
=
H5Sget_simple_extent_ndims
(
space
);
hsize_t
*
dims
=
new
hsize_t
[
ndims
];
H5Sget_simple_extent_dims
(
space
,
dims
,
NULL
);
if
(
dims
[
0
]
<
tsize
)
{
dims
[
0
]
=
tsize
;
H5Dset_extent
(
dset
,
dims
);
}
H5Sclose
(
space
);
delete
[]
dims
;
return
EXIT_SUCCESS
;
}
int
hdf5_tools
::
grow_single_dataset
(
hid_t
dset
,
int
tincrement
)
{
int
ndims
;
...
...
@@ -15,6 +33,21 @@ int hdf5_tools::grow_single_dataset(hid_t dset, int tincrement)
return
EXIT_SUCCESS
;
}
herr_t
hdf5_tools
::
require_size_dataset_visitor
(
hid_t
o_id
,
const
char
*
name
,
const
H5O_info_t
*
info
,
void
*
op_data
)
{
if
(
info
->
type
==
H5O_TYPE_DATASET
)
{
hsize_t
dset
=
H5Dopen
(
o_id
,
name
,
H5P_DEFAULT
);
require_size_single_dataset
(
dset
,
*
((
int
*
)(
op_data
)));
H5Dclose
(
dset
);
}
return
EXIT_SUCCESS
;
}
herr_t
hdf5_tools
::
grow_dataset_visitor
(
hid_t
o_id
,
const
char
*
name
,
...
...
@@ -50,6 +83,26 @@ int hdf5_tools::grow_file_datasets(
return
file_problems
;
}
int
hdf5_tools
::
require_size_file_datasets
(
const
hid_t
stat_file
,
const
std
::
string
group_name
,
int
tsize
)
{
int
file_problems
=
0
;
hid_t
group
;
group
=
H5Gopen
(
stat_file
,
group_name
.
c_str
(),
H5P_DEFAULT
);
H5Ovisit
(
group
,
H5_INDEX_NAME
,
H5_ITER_NATIVE
,
require_size_dataset_visitor
,
&
tsize
);
H5Gclose
(
group
);
return
file_problems
;
}
template
<
typename
number
>
std
::
vector
<
number
>
hdf5_tools
::
read_vector
(
const
hid_t
group
,
...
...
bfps/cpp/hdf5_tools.hpp
View file @
fe341a24
...
...
@@ -48,6 +48,21 @@ namespace hdf5_tools
const
std
::
string
group_name
,
int
tincrement
);
int
require_size_single_dataset
(
hid_t
dset
,
int
tincrement
);
herr_t
require_size_dataset_visitor
(
hid_t
o_id
,
const
char
*
name
,
const
H5O_info_t
*
info
,
void
*
op_data
);
int
require_size_file_datasets
(
const
hid_t
stat_file
,
const
std
::
string
group_name
,
int
tincrement
);
template
<
typename
number
>
std
::
vector
<
number
>
read_vector
(
const
hid_t
group
,
...
...
Write
Preview
Supports
Markdown
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