3.8MATLAB
HDFql can be used in the MATLAB programming language through a wrapper named “HDFql.m”, which is stored in the directory “MATLAB” found under the directory “wrapper”. The following short script illustrates how HDFql can be used in this language.
% display HDFql version in use
fprintf("HDFql version: %s\n", HDFql.VERSION);
% create an HDF5 file named "my_file.h5" and use (i.e. open) it
HDFql.execute("CREATE AND USE FILE my_file.h5");
% create an HDF5 dataset named "my_dataset" of data type int
HDFql.execute("CREATE DATASET my_dataset AS INT VALUES(10)");
% select (i.e. read) data from dataset "my_dataset" and populate cursor in use with it
HDFql.execute("SELECT FROM my_dataset");
% move cursor in use to the first position within the result set
HDFql.cursorFirst();
% display content of cursor in use
fprintf("Dataset value: %d\n", HDFql.cursorGetInt());Assuming that the script is stored in a file named “example.m”, it can be launched by executing the following command in a terminal:
matlab -batch "example"In case the script does not launch, it is most likely that either (1) MATLAB is not installed or (2) the HDFql MATLAB wrapper and/or the MPI shared library were not found (these are needed to launch the script). To fix the former issue, download and install MATLAB from the website https://mathworks.com/downloads. To fix the latter issue:
- On Windows, add the directory where the file “HDFql.m” (i.e. the wrapper) is located to the environment variable “PATH” by executing the following command in a terminal:
set PATH=<hdfql_matlab_wrapper_directory>;%PATH% - On Linux, add the directories where the files “HDFql.m” and (optionally) “libmpi.so” are located to the environment variable “LD_LIBRARY_PATH” by executing the following command in a terminal:
- With an HDFql non MPI-based distribution:
export LD_LIBRARY_PATH=<hdfql_matlab_wrapper_directory>:$LD_LIBRARY_PATH - With an HDFql MPI-based distribution:
export LD_LIBRARY_PATH=<hdfql_matlab_wrapper_directory>:<mpi_lib_directory>:$LD_LIBRARY_PATH
- With an HDFql non MPI-based distribution:
- On macOS, add the directories where the files “HDFql.m” and (optionally) “libmpi.dylib” are located to the environment variable “DYLD_LIBRARY_PATH”11 by executing the following command in a terminal:
- With an HDFql non MPI-based distribution:
export DYLD_LIBRARY_PATH=<hdfql_matlab_wrapper_directory>:$DYLD_LIBRARY_PATH - With an HDFql MPI-based distribution:
export DYLD_LIBRARY_PATH=<hdfql_matlab_wrapper_directory>:<mpi_lib_directory>:$DYLD_LIBRARY_PATH
- With an HDFql non MPI-based distribution:
Notes
- Starting with version 10.11 (i.e. El Capitan), Apple introduced a security feature named System Integrity Protection (SIP) that may prevent setting the environment variable “DYLD_LIBRARY_PATH” and, ultimately, launching the program. To overcome this, SIP should be disabled (please refer to https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html for additional information). ↩