Reads the dataset names under a given base group in an HDF5 file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hdf5_obj), | intent(inout) | :: | this |
A HDF5 object |
||
| character(len=*), | intent(in) | :: | basegroup |
Base group to explore |
||
| character(len=str64), | intent(out), | allocatable | :: | names(:) |
Dataset names under the base group |
impure subroutine hdf5_obj_ReadDatasetNames(this,basegroup,names) !> Reads the dataset names under a given base group in an HDF5 file. use iso_c_binding implicit none class(hdf5_obj), intent(inout) :: this !! A HDF5 object character(len=*), intent(in) :: basegroup !! Base group to explore character(len=str64), & allocatable, intent(out) :: names(:) !! Dataset names under the base group ! Work variables integer(HID_T) :: obj type(H5O_info_t) :: info character(len=str64):: obj_name integer(SIZE_T) :: name_size integer :: idx integer :: ierr integer :: nobj character(len=:), & allocatable :: groupname character(len=:), & allocatable :: name_ ! Initilize the array of names as an empty array names = [character(len=str64)::] ! Make sure basegroup is properly formatted, ! with '/' at the begining and end groupname=this%FixGroupName(basegroup) ! Get total number of objects under this group call H5Gn_members_f(this%fid,groupname,nobj,ierr) ! Iterate over objects under the basegroup do idx = 0, nobj - 1 ! Open object call H5Oopen_by_idx_f(this%fid,groupname,H5_INDEX_NAME_F,H5_ITER_NATIVE_F, int(idx,HSIZE_T),obj,ierr) if (ierr.eq.0) then ! Get name and info of the object call H5Iget_name_f(obj,obj_name,int(str64,SIZE_T),name_size,ierr) call H5Oget_info_f(obj,info,ierr) ! Consider only objects that are datasets if ( info%type .eq. H5O_TYPE_DATASET_F) then ! Add object name to list name_ = obj_name(len(groupname)+1:name_size) names = [character(len=str64):: names(:), name_] end if ! Close object call H5Oclose_f(obj,ierr) end if end do return end subroutine hdf5_obj_ReadDatasetNames