enable more complex attributes
This commit is contained in:
parent
8e295cbadf
commit
3c8d96c54c
|
@ -70,6 +70,8 @@ module HDF5_utilities
|
|||
module procedure HDF5_addAttribute_str
|
||||
module procedure HDF5_addAttribute_int
|
||||
module procedure HDF5_addAttribute_real
|
||||
module procedure HDF5_addAttribute_int_array
|
||||
module procedure HDF5_addAttribute_real_array
|
||||
end interface HDF5_addAttribute
|
||||
|
||||
|
||||
|
@ -419,6 +421,94 @@ subroutine HDF5_addAttribute_real(loc_id,attrLabel,attrValue,path)
|
|||
end subroutine HDF5_addAttribute_real
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief adds a integer attribute to the path given relative to the location
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine HDF5_addAttribute_int_array(loc_id,attrLabel,attrValue,path)
|
||||
|
||||
integer(HID_T), intent(in) :: loc_id
|
||||
character(len=*), intent(in) :: attrLabel
|
||||
integer(pInt), intent(in), dimension(:) :: attrValue
|
||||
character(len=*), intent(in), optional :: path
|
||||
|
||||
integer :: hdferr
|
||||
integer(HID_T) :: attr_id, space_id
|
||||
integer(HSIZE_T),dimension(1) :: array_size
|
||||
logical :: attrExists
|
||||
character(len=256) :: p
|
||||
|
||||
if (present(path)) then
|
||||
p = trim(path)
|
||||
else
|
||||
p = '.'
|
||||
endif
|
||||
|
||||
array_size = size(attrValue,kind=HSIZE_T)
|
||||
|
||||
call h5screate_simple_f(1, array_size, space_id, hdferr, array_size)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5screate_f')
|
||||
call h5aexists_by_name_f(loc_id,trim(p),attrLabel,attrExists,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5aexists_by_name_f')
|
||||
if (attrExists) then
|
||||
call h5adelete_by_name_f(loc_id, trim(p), attrLabel, hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5adelete_by_name_f')
|
||||
endif
|
||||
call h5acreate_by_name_f(loc_id,trim(p),trim(attrLabel),H5T_NATIVE_INTEGER,space_id,attr_id,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5acreate_f')
|
||||
call h5awrite_f(attr_id, H5T_NATIVE_INTEGER, attrValue, array_size, hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5awrite_f')
|
||||
call h5aclose_f(attr_id,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5tclose_f')
|
||||
call h5sclose_f(space_id,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5sclose_f')
|
||||
|
||||
end subroutine HDF5_addAttribute_int_array
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief adds a real attribute to the path given relative to the location
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine HDF5_addAttribute_real_array(loc_id,attrLabel,attrValue,path)
|
||||
|
||||
integer(HID_T), intent(in) :: loc_id
|
||||
character(len=*), intent(in) :: attrLabel
|
||||
real(pReal), intent(in), dimension(:) :: attrValue
|
||||
character(len=*), intent(in), optional :: path
|
||||
|
||||
integer :: hdferr
|
||||
integer(HID_T) :: attr_id, space_id
|
||||
integer(HSIZE_T),dimension(1) :: array_size
|
||||
logical :: attrExists
|
||||
character(len=256) :: p
|
||||
|
||||
if (present(path)) then
|
||||
p = trim(path)
|
||||
else
|
||||
p = '.'
|
||||
endif
|
||||
|
||||
array_size = size(attrValue,kind=HSIZE_T)
|
||||
|
||||
call h5screate_simple_f(1, array_size, space_id, hdferr, array_size)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5screate_f')
|
||||
call h5aexists_by_name_f(loc_id,trim(p),attrLabel,attrExists,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5aexists_by_name_f')
|
||||
if (attrExists) then
|
||||
call h5adelete_by_name_f(loc_id, trim(p), attrLabel, hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5adelete_by_name_f')
|
||||
endif
|
||||
call h5acreate_by_name_f(loc_id,trim(p),trim(attrLabel),H5T_NATIVE_DOUBLE,space_id,attr_id,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5acreate_f')
|
||||
call h5awrite_f(attr_id, H5T_NATIVE_DOUBLE, attrValue, array_size, hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5awrite_f')
|
||||
call h5aclose_f(attr_id,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5tclose_f')
|
||||
call h5sclose_f(space_id,hdferr)
|
||||
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_addAttribute_int_array: h5sclose_f')
|
||||
|
||||
end subroutine HDF5_addAttribute_real_array
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief set link to object in results file
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -28,6 +28,17 @@ module results
|
|||
|
||||
end interface results_writeDataset
|
||||
|
||||
interface results_addAttribute
|
||||
|
||||
module procedure results_addAttribute_real
|
||||
module procedure results_addAttribute_int
|
||||
module procedure results_addAttribute_str
|
||||
|
||||
module procedure results_addAttribute_int_array
|
||||
module procedure results_addAttribute_real_array
|
||||
|
||||
end interface results_addAttribute
|
||||
|
||||
public :: &
|
||||
results_init, &
|
||||
results_openJobFile, &
|
||||
|
@ -144,15 +155,67 @@ end subroutine results_setLink
|
|||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief adds an attribute to an object
|
||||
!> @brief adds a string attribute to an object in the results file
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine results_addAttribute(attrLabel,attrValue,path)
|
||||
subroutine results_addAttribute_str(attrLabel,attrValue,path)
|
||||
|
||||
character(len=*), intent(in) :: attrLabel, attrValue, path
|
||||
|
||||
call HDF5_addAttribute_str(resultsFile,attrLabel, attrValue, path)
|
||||
call HDF5_addAttribute(resultsFile,attrLabel, attrValue, path)
|
||||
|
||||
end subroutine results_addAttribute
|
||||
end subroutine results_addAttribute_str
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief adds an integer attribute an object in the results file
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine results_addAttribute_int(attrLabel,attrValue,path)
|
||||
|
||||
character(len=*), intent(in) :: attrLabel, path
|
||||
integer, intent(in) :: attrValue
|
||||
|
||||
call HDF5_addAttribute(resultsFile,attrLabel, attrValue, path)
|
||||
|
||||
end subroutine results_addAttribute_int
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief adds a real attribute an object in the results file
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine results_addAttribute_real(attrLabel,attrValue,path)
|
||||
|
||||
character(len=*), intent(in) :: attrLabel, path
|
||||
real(pReal), intent(in) :: attrValue
|
||||
|
||||
call HDF5_addAttribute(resultsFile,attrLabel, attrValue, path)
|
||||
|
||||
end subroutine results_addAttribute_real
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief adds an integer array attribute an object in the results file
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine results_addAttribute_int_array(attrLabel,attrValue,path)
|
||||
|
||||
character(len=*), intent(in) :: attrLabel, path
|
||||
integer, intent(in), dimension(:) :: attrValue
|
||||
|
||||
call HDF5_addAttribute(resultsFile,attrLabel, attrValue, path)
|
||||
|
||||
end subroutine results_addAttribute_int_array
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief adds a real array attribute an object in the results file
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine results_addAttribute_real_array(attrLabel,attrValue,path)
|
||||
|
||||
character(len=*), intent(in) :: attrLabel, path
|
||||
real(pReal), intent(in), dimension(:) :: attrValue
|
||||
|
||||
call HDF5_addAttribute(resultsFile,attrLabel, attrValue, path)
|
||||
|
||||
end subroutine results_addAttribute_real_array
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue