The attribute interface works for single processor output and single valued attribute

This commit is contained in:
Vitesh Shah 2018-12-15 17:21:03 +01:00
parent d2c7b33cf6
commit 3e38c4ef8c
1 changed files with 93 additions and 53 deletions

View File

@ -60,13 +60,22 @@ module HDF5_utilities
module procedure HDF5_write_pInt7 !ABOVE 8 DIMENSIONS IT GIVES ERROR: THE CALL TO H5DREAD_F DOESNT WORK
end interface HDF5_write
!--------------------------------------------------------------------------------------------------
!> @brief attached attributes of type char,pInt or pReal to a file/dataset/group
!--------------------------------------------------------------------------------------------------
interface HDF5_attributes
module procedure HDF5_addStringAttribute
module procedure HDF5_addIntegerAttribute
module procedure HDF5_addRealAttribute
end interface HDF5_attributes
!--------------------------------------------------------------------------------------------------
public :: &
HDF5_utilities_init, &
HDF5_openFile, &
HDF5_closeFile, &
HDF5_addStringAttribute, &
HDF5_addIntegerAttribute, &
HDF5_addRealAttribute, &
HDF5_closeGroup ,&
HDF5_openGroup, &
HDF5_addGroup, &
@ -275,7 +284,7 @@ end subroutine HDF5_addStringAttribute
!--------------------------------------------------------------------------------------------------
!> @brief adds a StringAttribute to the results file
!> @brief adds a IntegerAttribute to the results file
!--------------------------------------------------------------------------------------------------
subroutine HDF5_addIntegerAttribute(entity,attrLabel,attrValue)
@ -288,7 +297,7 @@ subroutine HDF5_addIntegerAttribute(entity,attrLabel,attrValue)
call h5screate_f(H5S_SCALAR_F,space_id,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addIntegerAttribute: h5screate_f')
call h5tcopy_f(H5T_NATIVE_Integer, type_id, hdferr)
call h5tcopy_f(H5T_NATIVE_INTEGER, type_id, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addIntegerAttribute: h5tcopy_f')
call h5tset_size_f(type_id, 1_HSIZE_T, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addIntegerAttribute: h5tset_size_f')
@ -305,6 +314,37 @@ subroutine HDF5_addIntegerAttribute(entity,attrLabel,attrValue)
end subroutine HDF5_addIntegerAttribute
!--------------------------------------------------------------------------------------------------
!> @brief adds a Real number Attribute to the results file
!--------------------------------------------------------------------------------------------------
subroutine HDF5_addRealAttribute(entity,attrLabel,attrValue)
implicit none
integer(HID_T), intent(in) :: entity
character(len=*), intent(in) :: attrLabel
real(pReal), intent(in) :: attrValue
integer(HDF5_ERR_TYPE) :: hdferr
integer(HID_T) :: attr_id, space_id, type_id
call h5screate_f(H5S_SCALAR_F,space_id,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5screate_f')
call h5tcopy_f(H5T_NATIVE_DOUBLE, type_id, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5tcopy_f')
call h5tset_size_f(type_id, 8_HSIZE_T, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5tset_size_f')
call h5acreate_f(entity, trim(attrLabel),type_id,space_id,attr_id,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5acreate_f')
call h5awrite_f(attr_id, type_id, attrValue, int([1],HSIZE_T), hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5awrite_f')
call h5aclose_f(attr_id,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5aclose_f')
call h5tclose_f(type_id,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5tclose_f')
call h5sclose_f(space_id,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addRealAttribute: h5sclose_f')
end subroutine HDF5_addRealAttribute
!--------------------------------------------------------------------------------------------------
!> @brief set link to object in results file
!--------------------------------------------------------------------------------------------------
@ -2935,7 +2975,7 @@ end subroutine HDF5_write_pInt7
end module HDF5_Utilities
!!!!!!!!!!!!