Introduction to HDF5 
HDF5 User Guide 
Other HDF5 documents and links 
And in this document, the HDF5 Reference Manual  
H5   H5A   H5D   H5E   H5F   H5G   H5I  
H5P   H5R   H5RA   H5S   H5T   H5Z   Tools  

H5F: File Interface

File API Functions

These functions are designed to provide file-level access to HDF5 files. Further manipulation of objects inside a file is performed through one of APIs documented below.

The C Interfaces:
             

The FORTRAN90 Interfaces:
In general, each FORTRAN90 subroutine performs exactly the same task as the corresponding C function. The links below go to the C function descriptions, which serve as general descriptions for both. A button, under Non-C API(s) at the end of the C function description, opens an external browser window displaying the FORTRAN90-specific information. You will probably want to adjust the size and location of this external window so that both browser windows are visible and to facilitate moving easily between them.
                    


Name: H5Fopen
Signature:
hid_t H5Fopen(const char *name, unsigned flags, hid_t access_id )
Purpose:
Opens an existing file.
Description:
H5Fopen opens an existing file and is the primary function for accessing existing HDF5 files.

The parameter access_id is a file access property list identifier or H5P_DEFAULT for the default I/O access parameters.

The flags argument determines whether writing to an existing file will be allowed or not. The file is opened with read and write permission if flags is set to H5F_ACC_RDWR. All flags may be combined with the bit-wise OR operator (`|') to change the behavior of the file open call. The more complex behaviors of a file's access are controlled through the file-access property list.

Files which are opened more than once return a unique identifier for each H5Fopen() call and can be accessed through all file identifiers.

The return value is a file identifier for the open file and it should be closed by calling H5Fclose() when it is no longer needed.

Parameters:
const char *name
Name of the file to access.
unsigned flags
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 is used only by HDF5 library developers; it is neither tested nor supported for use in applications.
    hid_t access_id
    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 access_id. Use H5P_DEFAULT for default file access properties.
  • Returns:
    Returns a file identifier if successful; otherwise returns a negative value.
    Non-C API(s):

    Name: H5Fcreate
    Signature:
    hid_t H5Fcreate(const char *name, unsigned flags, hid_t create_id, hid_t access_id )
    Purpose:
    Creates HDF5 files.
    Description:
    H5Fcreate is the primary function for creating HDF5 files .

    The flags parameter determines whether an existing file will be overwritten. All newly created files are opened for both reading and writing. All flags may be combined with the bit-wise OR operator (`|') to change the behavior of the H5Fcreate call.

    The more complex behaviors of file creation and access are controlled through the file-creation and file-access property lists. The value of H5P_DEFAULT for a property list value indicates that the library should use the default values for the appropriate property list.

    Parameters:
    const char *name
    Name of the file to access.
    uintn flags
    File access flags. Allowable values are:
      H5F_ACC_TRUNC
      Truncate file, if it already exists, erasing all data previously stored in the file.
      H5F_ACC_EXCL
      Fail 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 is used only by HDF5 library developers; it is neither tested nor supported for use in applications.
    hid_t create_id
    File creation property list identifier, used when modifying default file meta-data. Use H5P_DEFAULT for default file creation properties.
    hid_t access_id
    File access property list identifier. If parallel file access is desired, this is a collective call according to the communicator stored in the access_id. Use H5P_DEFAULT for default file access properties.
  • Returns:
    Returns a file identifier if successful; otherwise returns a negative value.
    Non-C API(s):

    Name: H5Fflush
    Signature:
    herr_t H5Fflush(hid_t object_id, H5F_scope_t scope )
    Purpose:
    Flushes all buffers associated with a file to disk.
    Description:
    H5Fflush causes all buffers associated with a file to be immediately flushed to disk without removing the data from the cache.

    object_id can be any object associated with the file, including the file itself, a dataset, a group, an attribute, or a named data type.

    scope specifies whether the scope of the flushing action is global or local. Valid values are

    H5F_SCOPE_GLOBAL      Flushes the entire virtual file.
    H5F_SCOPE_LOCAL Flushes only the specified file.
    Parameters:
    hid_t object_id
    Identifier of object used to identify the file.
    H5F_scope_t scope
    Specifies the scope of the flushing action.
    Returns:
    Returns a non-negative value if successful; otherwise returns a negative value.

    Name: H5Fis_hdf5
    Signature:
    htri_t H5Fis_hdf5(const char *name )
    Purpose:
    Determines whether a file is in the HDF5 format.
    Description:
    H5Fis_hdf5 determines whether a file is in the HDF5 format.
    Parameters:
    const char *name
    File name to check format.
    Returns:
    When successful, returns a positive value, for TRUE, or 0 (zero), for FALSE. Otherwise returns a negative value.
    Non-C API(s):

    Name: H5Fget_create_plist
    Signature:
    hid_t H5Fget_create_plist(hid_t file_id )
    Purpose:
    Returns a file creation property list identifier.
    Description:
    H5Fget_create_plist returns a file creation property list identifier identifying the creation properties used to create this file. This function is useful for duplicating properties when creating another file.

    See "File Creation Properties" in H5P: Property List Interface in this reference manual and "File Creation Properties" in Files in the HDF5 User's Guide for additional information and related functions.

    Parameters:
    hid_t file_id
    Identifier of the file to get creation property list of
    Returns:
    Returns a file creation property list identifier if successful; otherwise returns a negative value.

    Name: H5Fget_access_plist
    Signature:
    hid_t H5Fget_access_plist(hid_t file_id)
    Purpose:
    Returns a file access property list identifier.
    Description:
    H5Fget_access_plist returns the file access property list identifier of the specified file.

    See "File Access Properties" in H5P: Property List Interface in this reference manual and "File Access Property Lists" in Files in the HDF5 User's Guide for additional information and related functions.

    Parameters:
    hid_t file_id
    Identifier of file to get access property list of
    Returns:
    Returns a file access property list identifier if successful; otherwise returns a negative value.

    Name: H5Fclose
    Signature:
    herr_t H5Fclose(hid_t file_id )
    Purpose:
    Terminates access to an HDF5 file.
    Description:
    H5Fclose terminates access to an HDF5 file by flushing all data to storage and terminating access to the file through file_id.

    If this is the last file identifier open for the file and no other access identifier is open (e.g., a dataset identifier, group identifier, or shared datatype identifier), the file will be fully closed and access will end.

    If this is the last file identifier open for the file and other access identifiers are still in use, those access identifiers remain valid until separately closed and can still be used. (But the file identifier is no longer valid and cannot be used.) Once all of the remaining access identifiers are closed, the file will be fully closed and access will end.

    Parameters:
    hid_t file_id
    Identifier of a file to terminate access to.
    Returns:
    Returns a non-negative value if successful; otherwise returns a negative value.
    Non-C API(s):

    Name: H5Fmount
    Signature:
    herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id )
    Purpose:
    Mounts a file.
    Description:
    H5Fmount mounts the file specified by child_id onto the group specified by loc_id and name using the mount properties plist_id.

    Note that loc_id is either a file or group identifier and name is relative to loc_id.

    Parameters:
    hid_t loc_id
    The identifier for of file or group in which name is defined.
    const char *name
    The name of the group onto which the file specified by child_id is to be mounted.
    hid_t child_id
    The identifier of the file to be mounted.
    hid_t plist_id
    The identifier of the property list to be used.
    Returns:
    Returns a non-negative value if successful; otherwise returns a negative value.

    Name: H5Funmount
    Signature:
    herr_t H5Funmount(hid_t loc_id, const char *name )
    Purpose:
    Unmounts a file.
    Description:
    Given a mount point, H5Funmount dissassociates the mount point's file from the file mounted there. This function does not close either file.

    The mount point can be either the group in the parent or the root group of the mounted file (both groups have the same name). If the mount point was opened before the mount then it is the group in the parent; if it was opened after the mount then it is the root group of the child.

    Note that loc_id is either a file or group identifier and name is relative to loc_id.

    Parameters:
    hid_t loc_id
    The file or group identifier for the location at which the specified file is to be unmounted.
    const char *name
    The name of the mount point.
    Returns:
    Returns a non-negative value if successful; otherwise returns a negative value.

    Name: H5Freopen
    Signature:
    hid_t H5Freopen(hid_t file_id )
    Purpose:
    Returns a new identifier for a previously-opened HDF5 file.
    Description:
    H5Freopen returns a new file identifier for an already-open HDF5 file, as specified by file_id. Both identifiers share caches and other information. The only difference between the identifiers is that the new identifier is not mounted anywhere and no files are mounted on it.

    Note that there is no circumstance under which H5Freopen can actually open a closed file; the file must already be open and have an active file_id. E.g., one cannot close a file with H5Fclose (file_id) then use H5Freopen (file_id) to reopen it.

    The new file identifier should be closed by calling H5Fclose() when it is no longer needed.

    Parameters:
    hid_t file_id
    Identifier of a file for which an additional identifier is required.
    Returns:
    Returns a new file identifier if successful; otherwise returns a negative value.

    Introduction to HDF5 
    HDF5 User Guide 
    Other HDF5 documents and links 
    And in this document, the HDF5 Reference Manual  
    H5   H5A   H5D   H5E   H5F   H5G   H5I  
    H5P   H5R   H5RA   H5S   H5T   H5Z   Tools  

    HDF Help Desk
    Last modified: 11 May 2000
    Describes HDF5 Version 1.3 (Unrelased development version. Dynamic.)