[ HDF5 Tutorial Top ] [ Parallel HDF5 Topics Top ] [ Next ] [ Prev ]

Creating / Accessing a File with PHDF5


The programming model for creating and accessing a file is as follows:
  1. Set up an access template object to control the file access mechanism.
  2. Open the file.
  3. Close the file.
Each process of the MPI communicator creates an access template and sets it up with MPI parallel access information. This is done with the H5Pcreate / h5pcreate_f call to obtain the file access property list and the H5Pset_fapl_mpio / h5pset_fapl_mpio_f call to set up parallel I/O access:
C:

   hid_t  H5Pcreate ( H5P_class_t classtype (IN) );

herr_t H5Pset_fapl_mpio ( hid_t plist_id (IN), MPI_Comm comm (IN), MPI_Info info (IN) );

FORTRAN90: h5pcreate_f ( classtype, plist_id, hdferr ) IN: integer :: classtype OUT: integer (hid_t) :: plist_id OUT: integer :: hdferr h5pset_fapl_mpio_f ( plist_id, comm, info, hdferr ) IN: integer (hid_t) :: plist_id IN: integer :: comm IN: integer :: info OUT: integer :: hdferr

Where:

Following is example code for creating an access template in HDF5:

C:
    23      MPI_Comm comm  = MPI_COMM_WORLD;
    24      MPI_Info info  = MPI_INFO_NULL;
    25
    26      /*
    27       * Initialize MPI
    28       */
    29      MPI_Init(&argc, &argv);
    30      MPI_Comm_size(comm, &mpi_size);
    31      MPI_Comm_rank(comm, &mpi_rank);
    32
    33      /*
    34       * Set up file access property list with parallel I/O access
    35       */
    36      plist_id = H5Pcreate(H5P_FILE_ACCESS);
    37      H5Pset_fapl_mpio(plist_id, comm, info);

FORTRAN90:
    23       comm = MPI_COMM_WORLD
    24       info = MPI_INFO_NULL
    25
    26       CALL MPI_INIT(mpierror)
    27       CALL MPI_COMM_SIZE(comm, mpi_size, mpierror)
    28       CALL MPI_COMM_RANK(comm, mpi_rank, mpierror)
    29       !
    30       ! Initialize FORTRAN interface 
    31       !
    32       CALL h5open_f(error)
    33
    34       !
    35       ! Setup file access property list with parallel I/O access.
    36       !
    37       CALL h5pcreate_f(H5P_FILE_ACCESS_F, plist_id, error)
    38       CALL h5pset_fapl_mpio_f(plist_id, comm, info, error)
The following example programs create an HDF5 file using Parallel HDF5:


NCSA
The National Center for Supercomputing Applications

University of Illinois at Urbana-Champaign

hdfhelp@ncsa.uiuc.edu

Last Modified: November 16, 2001