Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Futility
Futility
Commits
af2449ad
Commit
af2449ad
authored
Sep 02, 2021
by
Graham, Aaron
Browse files
Merge branch 'hdf5_bool_attribute' into 'master'
Hdf5 bool attribute See merge request futility/Futility!348
parents
3e3e7edf
abca9921
Pipeline
#162209
passed with stage
in 2 minutes and 4 seconds
Changes
2
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
src/FileType_HDF5.f90
View file @
af2449ad
...
...
@@ -454,9 +454,12 @@ TYPE,EXTENDS(BaseFileType) :: HDF5FileType
!> @copybrief FileType_HDF5::write_attribute_d0
!> @copydoc FileType_HDF5_write_attribute_d0
PROCEDURE
,
PASS
,
PRIVATE
::
write_attribute_d0
!> @copybrief FileType_HDF5::write_attribute_b0
!> @copydoc FileType_HDF5_write_attribute_b0
PROCEDURE
,
PASS
,
PRIVATE
::
write_attribute_b0
!> Generic typebound interface for all @c attribute writes
GENERIC
::
write_attribute
=>
write_attribute_st0
,
write_attribute_c0
,&
write_attribute_i0
,
write_attribute_d0
write_attribute_i0
,
write_attribute_d0
,
write_attribute_b0
!> @copybrief FileType_HDF5::read_str_attribure_help
!> @copydoc FileType_HDF5_read_str_attribure_help
PROCEDURE
,
PASS
,
PRIVATE
::
read_attribute_st0
...
...
@@ -469,9 +472,12 @@ TYPE,EXTENDS(BaseFileType) :: HDF5FileType
!> @copybrief FileType_HDF5::read_attribute_d0
!> @copydoc FileType_HDF5_read_attribute_d0
PROCEDURE
,
PASS
,
PRIVATE
::
read_attribute_d0
!> @copybrief FileType_HDF5::read_attribute_b0
!> @copydoc FileType_HDF5_read_attribute_b0
PROCEDURE
,
PASS
,
PRIVATE
::
read_attribute_b0
!> Generic typebound interface for all @c attribute writes
GENERIC
::
read_attribute
=>
read_attribute_st0
,
read_attribute_c0
,&
read_attribute_i0
,
read_attribute_d0
read_attribute_i0
,
read_attribute_d0
,
read_attribute_b0
!> @copybrief FileType_HDF5::getDataShape
!> @copydoc FileType_HDF5::getDataShape
PROCEDURE
,
PASS
::
getDataShape
...
...
@@ -7203,6 +7209,45 @@ SUBROUTINE write_attribute_d0(this,obj_name,attr_name,attr_val)
ENDSUBROUTINE
write_attribute_d0
!
!-------------------------------------------------------------------------------
!> @brief Writes an attribute name and logical value to a known dataset
!>
!> @param obj_name the relative path to the dataset
!> @param attr_name the desired name of the attribute
!> @param attr_value the desired value of the attrbute
!>
SUBROUTINE
write_attribute_b0
(
this
,
obj_name
,
attr_name
,
attr_val
)
CLASS
(
HDF5FileType
),
INTENT
(
INOUT
)
::
this
CHARACTER
(
LEN
=*
),
INTENT
(
IN
)
::
obj_name
,
attr_name
LOGICAL
(
SBK
),
INTENT
(
IN
)
::
attr_val
#ifdef FUTILITY_HAVE_HDF5
CHARACTER
::
char_attr_val
INTEGER
::
num_dims
INTEGER
(
HID_T
)
::
attr_id
,
dspace_id
,
obj_id
INTEGER
(
HSIZE_T
),
DIMENSION
(
1
)
::
dims
num_dims
=
1
dims
(
1
)
=
1
!Prepare the File and object for the attribute
CALL
open_object
(
this
,
obj_name
,
obj_id
)
!Create the data space for memory type and size
CALL
h5screate_simple_f
(
num_dims
,
dims
,
dspace_id
,
error
)
!Create and write to the attribute within the dataspce
char_attr_val
=
MERGE
(
'T'
,
'F'
,
attr_val
)
CALL
createAttribute
(
this
,
obj_id
,
attr_name
,
H5T_NATIVE_CHARACTER
,&
dspace_id
,
attr_id
)
CALL
h5awrite_f
(
attr_id
,
H5T_NATIVE_CHARACTER
,
char_attr_val
,
dims
,
error
)
CALL
h5sclose_f
(
dspace_id
,
error
)
CALL
close_attribute
(
this
,
attr_id
)
CALL
close_object
(
this
,
obj_id
)
#endif
ENDSUBROUTINE
write_attribute_b0
!
!-------------------------------------------------------------------------------
!> @brief Set-up to read a string value attribute from a known dataset
!>
!> @param obj_name the relative path to the dataset
...
...
@@ -7341,6 +7386,49 @@ SUBROUTINE read_attribute_d0(this,obj_name,attr_name,attr_val)
ENDSUBROUTINE
read_attribute_d0
!
!-------------------------------------------------------------------------------
!> @brief Reads a logical value attribute from a known dataset
!>
!> @param obj_name the relative path to the dataset
!> @param attr_name the desired name of the attribute
!> @param attr_value the desired value of the attrbute
!>
SUBROUTINE
read_attribute_b0
(
this
,
obj_name
,
attr_name
,
attr_val
)
CLASS
(
HDF5FileType
),
INTENT
(
INOUT
)
::
this
CHARACTER
(
LEN
=*
),
INTENT
(
IN
)
::
obj_name
,
attr_name
LOGICAL
(
SBK
),
INTENT
(
INOUT
)
::
attr_val
#ifdef FUTILITY_HAVE_HDF5
CHARACTER
::
char_attr_val
CHARACTER
(
LEN
=*
),
PARAMETER
::
myName
=
'read_attribute_b0'
INTEGER
(
HID_T
)
::
attr_id
,
obj_id
INTEGER
(
HSIZE_T
),
DIMENSION
(
1
)
::
dims
dims
(
1
)
=
1
!Prepare the File and object for the attribute
CALL
open_object
(
this
,
obj_name
,
obj_id
)
CALL
open_attribute
(
this
,
obj_id
,
attr_name
,
attr_id
)
CALL
h5aread_f
(
attr_id
,
H5T_NATIVE_CHARACTER
,
char_attr_val
,
dims
,
error
)
IF
(
error
/
=
0
)
THEN
CALL
this
%
e
%
raiseError
(
modName
//
'::'
//
myName
//
&
' - Failed to read attribute.'
)
RETURN
ENDIF
IF
(
char_attr_val
==
'T'
)
THEN
attr_val
=
.TRUE.
ELSEIF
(
char_attr_val
==
'F'
)
THEN
attr_val
=
.FALSE.
ELSE
CALL
this
%
e
%
raiseError
(
modName
//
'::'
//
myName
//
' - Character "'
//
&
char_attr_val
//
'" is being read as a logical, which is not supported!'
)
ENDIF
CALL
close_attribute
(
this
,
attr_id
)
CALL
close_object
(
this
,
obj_id
)
#endif
ENDSUBROUTINE
read_attribute_b0
!
!-------------------------------------------------------------------------------
!> @brief Sets up all attribute operations by checking links and opening object`
!>
!> @param obj_name the relative path to the dataset
...
...
src/ParameterLists.f90
View file @
af2449ad
This diff is collapsed.
Click to expand it.
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