Please see The HDF Group's new Support Portal for the latest information.
Contents:
- Mounting Files
- Programming Example
Mounting Files
HDF5 allows you to combine two or more HDF5 files in memory in a manner similar to mounting files in UNIX. The group structure and metadata from one file appear as though they exist in another file. The following steps are involved:- Open the files.
- Choose the mount point in the first file (the parent file). The mount point in HDF5 is a group, which CANNOT be the root group.
- Use the HDF5 routine
H5Fmount
/h5fmount_f
to mount the second file (the child file) in the first file. - Work with the objects in the second file as if they were members of the mount point group in the first file. The previous contents of the mount point group are temporarily hidden.
- Unmount the second file using
H5Funmount
/h5funmount_f
when the work is done.
Programming Example
Description
In the following example, we create one file containing a group and another file containing a dataset. Mounting is used to access the dataset from the second file as a member of a group in the first file. The following figures illustrate this concept.FILE1 FILE2 -------------------- -------------------- ! ! ! ! ! / ! ! / ! ! | ! ! | ! ! | ! ! | ! ! V ! ! V ! ! -------- ! ! ---------- ! ! ! Group ! ! ! ! Dataset! ! ! --------- ! ! ---------- ! !------------------! !------------------!After mounting
FILE2
under the group in FILE1
,
the parent file has the following structure:
FILE1 -------------------- ! ! ! / ! ! | ! ! | ! ! V ! ! -------- ! ! ! Group ! ! ! --------- ! ! | ! ! | ! ! V ! ! ----------- ! ! ! Dataset ! ! ! !---------- ! ! ! !------------------![ C program ] -
h5_mount.c
[ FORTRAN program ] -
mountexample.f90
For details on compiling an HDF5 application: [ click here ]
Remarks
- The first part of the program creates a group in one file and creates
and writes a dataset to another file.
- Both files are reopened and the second file is mounted in the first
using
H5Fmount / h5fmount_f.
If no objects will be modified, the
files can be opened with
H5F_ACC_RDONLY
(H5F_ACC_RDONLY_F
in FORTRAN). If the data is to be modified, the files should be opened withH5F_ACC_RDWR
(H5F_ACC_RDWR_F
in FORTRAN). - In this example, we only read data from the dataset
D
. One can also modify data. If the dataset is modified while the file is mounted, it is modified in the original file after the file is unmounted. - The file is unmounted with H5Funmount / h5funmount_f.
- Note that H5Funmount / h5funmount_f
does not close files. Files are closed with the respective calls to
the H5Fclose / h5fclose_f function.
- Closing the parent file automatically unmounts the child file.
- The
h5dump
utility cannot display files in memory. Therefore, no output ofFILE1
afterFILE2
was mounted is provided.
- - Last modified: 21 December 2016