Very simple single-file/module access to HDF5. More advanced object-oriented Fortran HDF5 access also available, but not compatible with HDF5 1.10 like this program.
Read/write integer / real32/64:
- scalar
- 1-D
- 2-D
- 3-D
via polymorphism.
Tested on systems including Mac OS X (via homebrew), Ubuntu 16.04/18.04 (gfortran ≥ 5.4.1) with HDF5 1.8 and 1.10 and Windows Subsystem for Linux.
Requirements:
-
modern Fortran 2018 compiler (such as gfortran ≥ 5.4.1, etc.)
-
HDF5 library (1.8 or 1.10)
-
Mac:
brew install gcc hdf5
-
Linux:
apt install gfortran libhdf5-dev
-
Windows: at this time, Scoop didn't have HDF5, possibly due to difficulties with HDF5 and gfortran on Windows, so consider using Windows Subsystem for Linux
and then:
cd app
cmake ../src
make
make test
Here are a few examples. All of them assume:
use hdf5_interface, only: hdf5_file
type(hdf5_file) :: h5f
call h5f%initialize('test.h5',status='new',action='w')
call h5f%add('/value1', 123.)
call h5f%finalize()
call h5f%initialize('test.h5',status='old',action='rw')
call h5f%add('/value1', 123.)
call h5f%finalize()