Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
d614f766
Commit
d614f766
authored
11 months ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Implement HDF5 output of double precision complex values
parent
1b49f1f0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libnptm/file_io.cpp
+10
-4
10 additions, 4 deletions
src/libnptm/file_io.cpp
with
10 additions
and
4 deletions
src/libnptm/file_io.cpp
+
10
−
4
View file @
d614f766
...
@@ -81,7 +81,7 @@ HDFFile* HDFFile::from_schema(
...
@@ -81,7 +81,7 @@ HDFFile* HDFFile::from_schema(
herr_t
status
;
herr_t
status
;
string
*
rec_types
=
schema
.
get_record_types
();
string
*
rec_types
=
schema
.
get_record_types
();
string
*
rec_names
=
schema
.
get_record_names
();
string
*
rec_names
=
schema
.
get_record_names
();
string
known_types
[]
=
{
"INT32"
,
"FLOAT64"
};
string
known_types
[]
=
{
"INT32"
,
"FLOAT64"
,
"COMPLEX128"
};
int
rec_num
=
schema
.
get_record_number
();
int
rec_num
=
schema
.
get_record_number
();
regex
re
;
regex
re
;
smatch
m
;
smatch
m
;
...
@@ -99,8 +99,9 @@ HDFFile* HDFFile::from_schema(
...
@@ -99,8 +99,9 @@ HDFFile* HDFFile::from_schema(
str_target
=
m
.
suffix
().
str
();
str_target
=
m
.
suffix
().
str
();
if
(
type_index
==
1
)
data_type
=
H5Tcopy
(
H5T_NATIVE_INT
);
if
(
type_index
==
1
)
data_type
=
H5Tcopy
(
H5T_NATIVE_INT
);
else
if
(
type_index
==
2
)
data_type
=
H5Tcopy
(
H5T_NATIVE_DOUBLE
);
else
if
(
type_index
==
2
)
data_type
=
H5Tcopy
(
H5T_NATIVE_DOUBLE
);
else
if
(
type_index
==
3
)
data_type
=
H5Tcopy
(
H5T_NATIVE_DOUBLE
);
}
}
if
(
type_index
==
2
)
break
;
if
(
type_index
==
3
)
break
;
}
}
if
(
found_type
)
{
if
(
found_type
)
{
re
=
regex
(
"[0-9]+"
);
re
=
regex
(
"[0-9]+"
);
...
@@ -119,6 +120,9 @@ HDFFile* HDFFile::from_schema(
...
@@ -119,6 +120,9 @@ HDFFile* HDFFile::from_schema(
max_dims
[
ti
]
=
dim
;
max_dims
[
ti
]
=
dim
;
str_target
=
m
.
suffix
().
str
();
str_target
=
m
.
suffix
().
str
();
}
}
int
multiplier
=
(
type_index
==
3
)
?
2
:
1
;
dims
[
rank
-
1
]
*=
multiplier
;
max_dims
[
rank
-
1
]
*=
multiplier
;
hid_t
dataspace_id
=
H5Screate_simple
(
rank
,
dims
,
max_dims
);
hid_t
dataspace_id
=
H5Screate_simple
(
rank
,
dims
,
max_dims
);
hid_t
dataset_id
=
H5Dcreate
(
hid_t
dataset_id
=
H5Dcreate
(
file_id
,
rec_names
[
ri
].
c_str
(),
data_type
,
dataspace_id
,
H5P_DEFAULT
,
file_id
,
rec_names
[
ri
].
c_str
(),
data_type
,
dataspace_id
,
H5P_DEFAULT
,
...
@@ -183,7 +187,7 @@ herr_t HDFFile::write(
...
@@ -183,7 +187,7 @@ herr_t HDFFile::write(
hid_t
mem_space_id
,
hid_t
file_space_id
,
hid_t
dapl_id
,
hid_t
mem_space_id
,
hid_t
file_space_id
,
hid_t
dapl_id
,
hid_t
dxpl_id
hid_t
dxpl_id
)
{
)
{
string
known_types
[]
=
{
"INT32"
,
"FLOAT64"
};
string
known_types
[]
=
{
"INT32"
,
"FLOAT64"
,
"COMPLEX128"
};
regex
re
;
regex
re
;
smatch
m
;
smatch
m
;
bool
found_type
=
false
;
bool
found_type
=
false
;
...
@@ -191,7 +195,7 @@ herr_t HDFFile::write(
...
@@ -191,7 +195,7 @@ herr_t HDFFile::write(
while
(
!
found_type
)
{
while
(
!
found_type
)
{
re
=
regex
(
known_types
[
type_index
++
]);
re
=
regex
(
known_types
[
type_index
++
]);
found_type
=
regex_search
(
data_type
,
m
,
re
);
found_type
=
regex_search
(
data_type
,
m
,
re
);
if
(
type_index
==
2
)
break
;
if
(
type_index
==
3
)
break
;
}
}
if
(
found_type
)
{
if
(
found_type
)
{
hid_t
dataset_id
=
H5Dopen2
(
file_id
,
dataset_name
.
c_str
(),
dapl_id
);
hid_t
dataset_id
=
H5Dopen2
(
file_id
,
dataset_name
.
c_str
(),
dapl_id
);
...
@@ -201,6 +205,8 @@ herr_t HDFFile::write(
...
@@ -201,6 +205,8 @@ herr_t HDFFile::write(
mem_type_id
=
H5T_NATIVE_INT
;
break
;
mem_type_id
=
H5T_NATIVE_INT
;
break
;
case
2
:
case
2
:
mem_type_id
=
H5T_NATIVE_DOUBLE
;
break
;
mem_type_id
=
H5T_NATIVE_DOUBLE
;
break
;
case
3
:
mem_type_id
=
H5T_NATIVE_DOUBLE
;
break
;
default:
default:
throw
UnrecognizedParameterException
(
"unrecognized data type
\"
"
+
data_type
+
"
\"
"
);
throw
UnrecognizedParameterException
(
"unrecognized data type
\"
"
+
data_type
+
"
\"
"
);
}
}
...
...
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