HDFql Reference Manual v2.6.0

6.8.2USE FILE

Syntax

USE [READONLY] FILE {{file_name [, file_name]*} | {[directory_name] LIKE regular_expression [DEEP {deep_value | {[deep_value] {, [deep_value]}+}} [SKIP]}} [IN [ATOMIC] PARALLEL [HINT {{hint_key hint_value [, hint_key hint_value]*} | DEFAULT}]]

[ALIGNMENT {[THRESHOLD {threshold_value | DEFAULT}] [ALIGNMENT {alignment_value | DEFAULT}] | DEFAULT}]

[LIBRARY BOUNDS {[FROM {EARLIEST | LATEST | V18 | V110 | DEFAULT}] [TO {LATEST | V18 | V110 | DEFAULT}] | DEFAULT}]

[CACHE {[SLOTS {slots_value | DEFAULT}] [SIZE {size_value | DEFAULT}] [PREEMPTION {preemption_value | DEFAULT}] | DEFAULT}]

Description

Use (i.e. open) an HDF5 file named file_name for subsequent operations. Multiple files can be opened at once by separating their names with a comma (,). If file_name was not found or could not be opened (due to unknown/unexpected reasons), no subsequent files are opened, and an error is raised. By default, the file is opened with read/write permissions. To open a file with read-only permission, the keyword READONLY should be specified (any subsequent attempt to write into this file will raise an error). In case the keyword LIKE is specified, only files with names complying with a regular expression named regular_expression will be opened (in HDFql, regular expressions are the ones specified by PCRE, which closely follows Perl 5 syntax – please refer to https://www.pcre.org and https://perldoc.perl.org/perlre for additional information). As a general rule, in case regular_expression contains spaces or special characters, it should be enclosed in double quotes (“). Otherwise, if it is not enclosed in double quotes, files will not be opened, and an error is raised. If regular_expression includes “**”, a recursive search is performed (i.e. HDFql will search in all existing directories and subdirectories for files to open). If directory_name is specified, the recursive search starts from within directory_name, which is assumed to be a directory. To limit the recursiveness, the keyword DEEP may be specified along with a value deep_value that represents the maximum recursiveness limit. In case the keyword SKIP is specified, HDFql will skip (i.e. ignore) a directory that cannot be opened (due to, e.g., permission restrictions) or a file that cannot be opened (due to, e.g., not being a valid HDF5 file) and continue searching (instead of stopping and raising an error). HDFql tracks opened files in a stack fashion (i.e. LIFO), meaning that the most recently opened file is the one currently in use. In case the keyword IN PARALLEL47 is specified, HDFql opens the file in parallel using all the processes associated with the default MPI communicator (MPI_COMM_WORLD) or with a user-defined MPI communicator (that may have been set through the function hdfql_mpi_use_communicator). In case the keyword ATOMIC is specified, all file access operations will appear atomic, guaranteeing sequential consistency in an MPI environment (i.e. the operations will behave as though they were performed in a serial order consistent with the program order). In case the keyword LIBRARY BOUNDS is specified, HDFql opens the file using these bounds (instead of the library bounds that may have been set through the operation SET LIBRARY BOUNDS). In case the keyword CACHE is specified, HDFql opens the file using a cache parameterized with the slots_value, size_value, and preemption_value values (instead of the file cache parameters that may have been set through the operation SET CACHE).

Parameter(s)

file_name – optional string that specifies the name of the HDF5 file to use (i.e. open) for subsequent operations.

directory_name – optional string that specifies the name of the directory where to search for HDF5 files to be used (i.e. opened) for subsequent operations. If directory_name is not specified, the working directory currently in use is used to search for HDF5 files.

regular_expression – optional string that specifies the regular expression with which the names of files must comply for those files to be used (i.e. opened). If regular_expression includes “**”, a recursive search is performed.

deep_value – optional integer that specifies the maximum recursiveness limit (i.e. how deep the recursive search is performed). If deep_value is specified, it must be equal to or greater than 0 (otherwise an error is raised).

slots_value – optional integer that specifies the number of chunk slots in the raw data chunk cache for accessing the HDF5 file. If slots_value is specified, it must be equal to or greater than zero (otherwise an error is raised). Due to the hashing strategy, its value should ideally be a prime number. In case the keyword DEFAULT is specified, its value is 521 (i.e. default value defined by the HDF5 library). In case the keyword SLOTS is not specified, its current value remains intact.

size_value – optional integer that specifies the total size of the raw data chunk cache in bytes for accessing the HDF5 file. If size_value is specified, it must be equal to or greater than zero (otherwise an error is raised). In case the keyword DEFAULT is specified, its value is 1048576 (i.e. 1 MB – default value defined by the HDF5 library). In case the keyword SIZE is not specified, its current value remains intact.

preemption_value – optional float that specifies the chunk preemption policy for accessing the HDF5 file. If preemption_value is specified, it must be between 0 and 1 (otherwise an error is raised). It indicates the weighting according to which chunks that have been fully read or written are penalized when determining which chunks to flush from cache. In case the keyword DEFAULT is specified, its value is 0.75 (i.e. default value defined by the HDF5 library). In case the keyword PREEMPTION is not specified, its current value remains intact.

Return

Nothing

Example(s)

# use (i.e. open) an HDF5 file named "my_file0.h5" located in the working directory currently in use
USE FILE my_file0.h5

# use (i.e. open) an HDF5 file named "my_file1.h5" located in a root directory named "data" 
USE FILE /data/my_file1.h5

# use (i.e. open) two HDF5 files named "my_file2.h5" and "my_file3.h5" with read only permissions (both files are located in the working directory currently in use)
USE READONLY FILE my_file2.h5, my_file3.h5

# use (i.e. open) an HDF5 file named "my_file4.h5" located in the parent directory with the latest version of the HDF5 library
USE FILE ../my_file4.h5 LIBRARY BOUNDS FROM LATEST TO LATEST

# use (i.e. open) an HDF5 file named "my_file5.h5" located in the working directory currently in use with cache slots, size, and preemption values of 1523, 262144, and 0.6, respectively
USE FILE my_file5.h5 CACHE SLOTS 1523 SIZE 262144 PREEMPTION 0.6 

# use (i.e. open) an HDF5 file named "my_file6.h5" located in the working directory currently in use with the earliest version of the HDF5 library and a cache preemption value of 0.9
USE FILE my_file6.h5 LIBRARY BOUNDS FROM EARLIEST CACHE PREEMPTION 0.9 

# use (i.e. open) an HDF5 file named "my_file7.h5" located in the working directory currently in use in parallel (i.e. if the program (that employs HDFql) is launched as, e.g., "mpiexec -n 4 ./my_program", all the four MPI processes will participate in the opening of the file)
USE FILE my_file7.h5 IN PARALLEL

# use (i.e. open) an HDF5 file named "my_file8.h5" located in the working directory currently in use in parallel with atomicity when accessing it
USE FILE my_file8.h5 IN ATOMIC PARALLEL

Notes

  1. This option is not allowed on Windows as HDFql does not currently support the parallel HDF5 (PHDF5) library on this platform. ↩