hdf images hdf images

This web site is no longer maintained (but will remain online).
Please see The HDF Group's new Support Portal for the latest information.

HDF5 Tutorial: Advanced Topics
Mounting Files

Contents:


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:
  1. Open the files.
  2. 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.
  3. Use the HDF5 routine H5Fmount / h5fmount_f to mount the second file (the child file) in the first file.
  4. 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.
  5. 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


- - Last modified: 21 December 2016