使用Fortran读取一组HDF5的数据集
我一直在使用Fortran读取一组HDF5文件的成员数据集 我可以列出我的HDF5组的成员。但我无法访问组中某个成员的数据使用Fortran读取一组HDF5的数据集,fortran,hdf5,Fortran,Hdf5,我一直在使用Fortran读取一组HDF5文件的成员数据集 我可以列出我的HDF5组的成员。但我无法访问组中某个成员的数据 program sds_info use hdf5 implicit none ! Variables declaration CHARACTER*100 :: file_name CHARACTER*100 :: sds_name CHARACTER*100 :: gr_name INTEGER(HID_T):: file_id, gr_id, dse
program sds_info
use hdf5
implicit none
! Variables declaration
CHARACTER*100 :: file_name
CHARACTER*100 :: sds_name
CHARACTER*100 :: gr_name
INTEGER(HID_T):: file_id, gr_id, dset_id, attr_id
INTEGER :: status, error, storage, nlinks,max_corder, attr_num
REAL, DIMENSION(1) :: dset_data, data_out
INTEGER, DIMENSION(1) :: buf
INTEGER(HSIZE_T), DIMENSION(1):: data_dims
INTEGER(HSIZE_T), DIMENSION(1) ::dims
!
! varaibles to read a dataset in a group
CHARACTER*100 :: ap_name
integer(HID_T):: ap_id
real, allocatable, dimension(:) :: ap
integer(HSIZE_T), dimension(15624960) :: ap_dim
integer :: nmembers ! Number of group members
CHARACTER(LEN=20) :: name_buffer ! Buffer to hold object's name
integer :: i
integer :: type
!
! Variables initalization
file_name = "PVAR8.h5"
sds_name = "time"
gr_name = "part"
attr_name = "attr1"
ap_name="ap"
! Initialize the interface
call h5open_f(status)
! Open an hdf5 file
call h5fopen_f(file_name, H5F_ACC_RDWR_F, file_id, status)
! Open a group
call h5gopen_f(file_id, gr_name, gr_id, status )
!
! Open a dataset
call h5dopen_f(file_id, sds_name, dset_id, error)
! Get the number of attributes
call h5aget_num_attrs_f(dset_id, attr_num, error)
print *, "attr_num ",attr_num
! Read the dataset
call h5dread_f(dset_id, H5T_NATIVE_REAL, data_out, data_dims, error)
print *, "data_out ",data_out
! Terminate access to the group
call h5gclose_f(gr_id, error)
! Terminate access to the dataset
call h5dclose_f(dset_id, error)
! Terminate access to the file
call h5fclose_f(file_id, error)
! Close FORTRAN interface.
call h5close_f(status)
end program sds_info
我可以读取组,但如何使用Fortran访问和读取HDF5中组成员的数据?如果您不一定要使用特定技术,请查看以解决您的问题 使用Fortran中的HDFql,您可以从文件PVAR8.h5中读取存储在group part中的数据类型real的数据集时间,如下所示: 程序测试 ! 使用HDFql模块,确保Fortran编译器可以找到它 使用HDFql ! 声明变量 REALKIND=8::value 整数::状态 ! 注册变量值以供HDFql后续使用 状态=hdfql\u变量\u瞬态\u寄存器值 ! 选择,即从数据集时间读取数据,并用它填充变量值 state=hdfql_execute从PVAR8.h5/部分/时间选择内存0 ! 显示变量值的内容 写入*,*数据集值:,值 结束程序
还可以找到其他HDFql示例。程序在什么情况下不能按预期工作?程序的错误信息和/或输出是什么?