Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2025-11-11 The HDF5 Field Guide

- Main Page
- Getting started
- User Guide
- Reference Manual
- Cookbook
- Technical Notes
- RFCs
- Specifications
- Glossary
- Full-Text Search
- About

Loading...
Searching...
No Matches
Examples by API

Navigate back: Main / Getting Started with HDF5

# Examples Description

The C, FORTRAN and Java examples below point to the examples in the hdf5-examples github repository. Examples for older versions of HDF5 are handled by setting the appropriate USE_API_xxx definition. HDF5-1.6 examples are in a "16"-named subdirectory.

The Java examples are in the develop source code, and the Java Object package examples are in the HDFView source. Please note that you must comment out the "package" statement at the top when downloading a Java Object example individually.

The MATLAB and Python examples were generously provided by a user and are not tested.

Languages are C, Fortran, Java (JHI5), Java Object Package, Python (High Level), and Python (Low Level APIs).

## Datasets

Feature | Languages | HDF5 File | Output | DDL
--- | --- | --- | --- | ---
Set Space Allocation Time for Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_alloc.h5 | h5ex_d_alloc.tst | h5ex_d_alloc.ddl
Read / Write Dataset using Fletcher32 Checksum Filter | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_checksum.h5 | h5ex_d_checksum.tst | h5ex_d_checksum.ddl
Read / Write Chunked Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_chunk.h5 | h5ex_d_chunk.tst | h5ex_d_chunk.ddl
Read / Write Compact Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_compact.h5 | h5ex_d_compact.tst | h5ex_d_compact.ddl
Read / Write to External Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_extern.h5 | h5ex_d_extern.tst | h5ex_d_extern.ddl
Read / Write Dataset w/ Fill Value | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_fillval.h5 | h5ex_d_fillval.tst | h5ex_d_fillval.ddl
Read / Write GZIP Compressed Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_gzip.h5 | h5ex_d_gzip.tst | h5ex_d_gzip.ddl
Read / Write Data by Hyperslabs | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_hyper.h5 | h5ex_d_hyper.tst | h5ex_d_hyper.ddl
Read / Write Dataset with n-bit Filter | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_nbit.h5 | h5ex_d_nbit.tst | h5ex_d_nbit.ddl
Read / Write Integer Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_rdwr.h5 | h5ex_d_rdwr.tst | h5ex_d_rdwr.ddl
Read / Write Dataset w/ Shuffle Filter and GZIP Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_shuffle.h5 | h5ex_d_shuffle.tst | h5ex_d_shuffle.ddl
Read / Write Dataset using Scale-Offset Filter (float) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_sofloat.h5 | h5ex_d_sofloat.tst | h5ex_d_sofloat.ddl
Read / Write Dataset using Scale-Offset Filter (integer) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_soint.h5 | h5ex_d_soint.tst | h5ex_d_soint.ddl
Read / Write Dataset using SZIP Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_szip.h5 | h5ex_d_szip.tst | h5ex_d_szip.ddl
Read / Write Dataset using Data Transform Expression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_transform.h5 | h5ex_d_transform.tst | h5ex_d_transform.ddl
Read / Write Unlimited Dimension Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_unlimadd.h5 | h5ex_d_unlimadd.tst | h5ex_d_unlimadd.ddl
Read / Write GZIP Compressed Unlimited Dimension Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_unlimgzip.h5 | h5ex_d_unlimgzip.tst | h5ex_d_unlimgzip.ddl
Read / Write / Edit Unlimited Dimension Dataset | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_unlimmod.h5 | h5ex_d_unlimmod.tst | h5ex_d_unlimmod.ddl

## Groups

Feature | Languages | HDF5 File | Output | DDL
--- | --- | --- | --- | ---
Create "compact-or-indexed" Format Groups | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_compact.h5 | h5ex_g_.tst | h5ex_g_compact1.ddl | h5ex_g_compact2.ddl
Track links in a Group by Creation Order | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_corder.h5 | h5ex_g_corder.tst | h5ex_g_corder.ddl
Create / Open / Close a Group | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_create.h5 | h5ex_g_create.tst | h5ex_g_create.ddl
Create Intermediate Groups | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_intermediate.h5 | h5ex_g_intermediate.tst | h5ex_g_intermediate.ddl
Iterate over Groups w/ H5Literate | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_iterate.h5 | h5ex_g_iterate.tst | h5ex_g_iterate.ddl
Set Conditions to Convert between Compact and Dense Groups | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_phase.h5 | h5ex_g_phase.tst | h5ex_g_phase.ddl
Recursively Traverse a File with H5Literate | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_traverse.h5 | h5ex_g_traverse.tst | h5ex_g_traverse.ddl
Recursively Traverse a File with H5Ovisit / H5Lvisit | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_g_visit.h5 | h5ex_g_visit.tst | h5ex_g_visit.ddl

## Datatypes

Feature | Languages | HDF5 File | Output | DDL
--- | --- | --- | --- | ---
Read / Write Array (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_arrayatt.h5 | h5ex_t_arrayatt.tst | h5ex_t_arrayatt.ddl
Read / Write Array (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_array.h5 | h5ex_t_array.tst | h5ex_t_array.ddl
Read / Write Bitfield (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_bitatt.h5 | h5ex_t_bitatt.tst | h5ex_t_bitatt.ddl
Read / Write Bitfield (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_bit.h5 | h5ex_t_bit.tst | h5ex_t_bit.ddl
Read / Write Compound (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_cmpdatt.h5 | h5ex_t_cmpdatt.tst | h5ex_t_cmpdatt.ddl
Read / Write Compound (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_cmpd.h5 | h5ex_t_cmpd.tst | h5ex_t_cmpd.ddl
Commit Named Datatype and Read Back | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_commit.h5 | h5ex_t_commit.tst | h5ex_t_commit.ddl
Convert Between Datatypes in Memory | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_convert.h5 | h5ex_t_convert.tst | h5ex_t_convert.ddl not applicable
Read / Write Complex Compound (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_cpxcmpdatt.h5 | h5ex_t_cpxcmpdatt.tst | h5ex_t_cpxcmpdatt.ddl
Read / Write Complex Compound (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_cpxcmpd.h5 | h5ex_t_cpxcmpd.tst | h5ex_t_cpxcmpd.ddl
Read / Write Enumerated (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_enumatt.h5 | h5ex_t_enumatt.tst | h5ex_t_enumatt.ddl
Read / Write Enumerated (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_enum.h5 | h5ex_t_enum.tst | h5ex_t_enum.ddl
Read / Write Floating Point (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_floatatt.h5 | h5ex_t_floatatt.tst | h5ex_t_floatatt.ddl
Read / Write Floating Point (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_float.h5 | h5ex_t_float.tst | h5ex_t_float.ddl
Read / Write Integer Datatype (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_intatt.h5 | h5ex_t_intatt.tst | h5ex_t_intatt.ddl
Read / Write Integer Datatype (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_int.h5 | h5ex_t_int.tst | h5ex_t_int.ddl
Read / Write Object References (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_objrefatt.h5 | h5ex_t_objrefatt.tst | h5ex_t_objrefatt.ddl
Read / Write Object References (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_objref.h5 | h5ex_t_objref.tst | h5ex_t_objref.ddl
Read / Write Opaque (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_opaqueatt.h5 | h5ex_t_opaqueatt.tst | h5ex_t_opaqueatt.ddl
Read / Write Opaque (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_opaque.h5 | h5ex_t_opaque.tst | h5ex_t_opaque.ddl
Read / Write Region References (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_regrefatt.h5 | h5ex_t_regrefatt.tst | h5ex_t_regrefatt.ddl
Read / Write Region References (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_regref.h5 | h5ex_t_regref.tst | h5ex_t_regref.ddl
Read / Write String (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_stringatt.h5 | h5ex_t_stringatt.tst | h5ex_t_stringatt.ddl
Read / Write String (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_string.h5 | h5ex_t_string.tst | h5ex_t_string.ddl
Read / Write Variable Length (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_vlenatt.h5 | h5ex_t_vlenatt.tst | h5ex_t_vlenatt.ddl
Read / Write Variable Length (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_vlen.h5 | h5ex_t_vlen.tst | h5ex_t_vlen.ddl
Read / Write Variable Length String (Attribute) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_vlstringatt.h5 | h5ex_t_vlstringatt.tst | h5ex_t_vlstringatt.ddl
Read / Write Variable Length String (Dataset) | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_t_vlstring.h5 | h5ex_t_vlstring.tst | h5ex_t_vlstring.ddl

## Filters

Feature | Languages | HDF5 File | Output | DDL
--- | --- | --- | --- | ---
Read / Write Dataset using Blosc Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_blosc.h5 | h5ex_d_blosc.tst | h5ex_d_blosc.ddl
Read / Write Dataset using Bit Shuffle Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_bshuf.h5 | h5ex_d_bshuf.tst | h5ex_d_bshuf.ddl
Read / Write Dataset using BZip2 Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_bzip2.h5 | h5ex_d_bzip2.tst | h5ex_d_bzip2.ddl
Read / Write Dataset using JPEG Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_jpeg.h5 | h5ex_d_jpeg.tst | h5ex_d_jpeg.ddl
Read / Write Dataset using LZ4 Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_lz4.h5 | h5ex_d_lz4.tst | h5ex_d_lz4.ddl
Read / Write Dataset using LZF Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_lzf.h5 | h5ex_d_lzf.tst | h5ex_d_lzf.ddl
Read / Write Dataset using ZFP Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_zfp.h5 | h5ex_d_zfp.tst | h5ex_d_zfp.ddl
Read / Write Dataset using ZStd Compression | C FORTRAN Java JavaObj MATLAB PyHigh PyLow | h5ex_d_zstd.h5 | h5ex_d_zstd.tst | h5ex_d_zstd.ddl

## Java General

Feature | Languages | Output
--- | --- | ---
Create/Read/Write an Attribute | Java JavaObj | HDF5AttributeCreate.txt
Create Datasets | Java JavaObj | HDF5DatasetCreate.txt
Read/Write Datasets | Java JavaObj | HDF5DatasetRead.txt
Create an Empty File | Java JavaObj | HDF5FileCreate.txt
Retrieve the File Structure | Java JavaObj | HDF5FileStructure.txt
Create Groups | Java JavaObj | HDF5GroupCreate.txt
Select a Subset of a Dataset | Java JavaObj | HDF5SubsetSelect.txt
Create Two Datasets Within Groups | Java JavaObj | HDF5GroupDatasetCreate.txt

## Parallel

Feature | Languages | HDF5 File | Output
--- | --- | --- | ---
Creating and Accessing a File | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Creating and Accessing a Dataset | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Writing and Reading Contiguous Hyperslabs | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Writing and Reading Regularly Spaced Data Hyperslabs | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Writing and Reading Pattern Hyperslabs | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Writing and Reading Chunk Hyperslabs | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Using the Subfiling VFD to Write a File Striped Across Multiple Subfiles | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Write to Datasets with Filters Applied | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst
Collectively Write Datasets with Filters and Not All Ranks have Data | C FORTRAN MATLAB PyHigh PyLow | ph5_.h5 | ph5_.tst

Navigate back: Main / Getting Started with HDF5