HDF文件的基本操作
1、打开HDF文件
相关函数: hid_t H5Fopen( const char
*name, unsigned flags, hid_t fapl_id )
作 用:打开一个已经存在的HDF文件 (Opens an
existing HDF5 file. )
返 回 值
:成功则返回一个文件ID,失败则返回一个负值。(Returns a file identifier if successful;
otherwise returns a negative value. )
参 数:
const char *name
被打开文件的名称。(IN: Name of the file
to be opened.)
unsigned flags
存储标志:H5F_ACC_RDWR、H5F_ACC_RDONLY
IN: File access flags.
Allowable values are:
H5F_ACC_RDWR
Allow read and write access to
file.
H5F_ACC_RDONLY
Allow read-only access to
file.
H5F_ACC_RDWR and H5F_ACC_RDONLY
are mutually exclusive; use exactly one.
An additional flag,
H5F_ACC_DEBUG, prints debug information. This flag can be combined
with one of the above values using the bit-wise OR operator (`|'),
but it is used only by HDF5 Library developers; it is neither
tested nor supported for use in applications.
hid_t fapl_idIN: Identifier for
the file access properties list. If parallel file access is
desired, this is a collective call according to the communicator
stored in the fapl_id. Use H5P_DEFAULT for default file access
properties.
2、创建HDF文件
相关函数: hid_t H5Fcreate( const
char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id
)
作 用:创建一个HDF文件 (Opens an existing
HDF5 file. )
返 回 值
:成功则返回一个文件ID,失败则返回一个负值。(Returns a file identifier if successful;
otherwise returns a negative value. )
参 数:
const char *name
需要创建的文件名称。(IN: Name of the file
to access.)
unsigned flags
存储标志:H5F_ACC_TRUNC、H5F_ACC_EXCL、
IN: File access flags.
Allowable values are:
* H5F_ACC_TRUNCTruncate file,
if it already exists, erasing all data previously stored in the
file.H5F_ACC_EXCLFail if file already exists.
* H5F_ACC_TRUNC and
H5F_ACC_EXCL are mutually exclusive; use exactly one.
* An additional flag,
H5F_ACC_DEBUG, prints debug information. This flag can be combined
with one of the above values using the bit-wise OR operator (`|'),
but it is used only by HDF5 Library developers; it is neither
tested nor supported for use in applications.
hid_t fcpl_id
H5P_DEFAULT
IN: File creation property list
identifier, used when modifying default file meta-data. Use
H5P_DEFAULT to specify default file creation
properties.
hid_t fapl_id
H5P_DEFAULT
IN: File access property list
identifier. If parallel file access is desired, this is a
collective call according to the communicator stored in the
fapl_id. Use H5P_DEFAULT for default file access
properties.