cbusta / hdf5-wrapper

Provides a Fortran wrapper for HDF5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HDF5 Fortran Wrapper

By: Christian Bustamante
https://cbustamante.co/
GitHub all releases GitHub GitHub last commit
GitHub forks GitHub Repo stars
follow on Twitter

Table of Contents

  1. About the package
  2. Requirements
  3. Package contents
  4. Usage
  5. License

About

This package provides a Fortran wrapper for HDF5 (.h5 files). It provides a simpler interface that allows easy writing and reading of h5 files for double precision and integer arrays of up to six dimensions. On top of the Fortran wrapper, the package provides a Matlab function that simplifies the process of reading entire h5 files. As opposed to having to read variable by variables, this function reads all variables and put them in a Matlab structure.

Requirements

Using this package requires a Fortran compiler and the HDF5 library.

  • Fortran compiler: tested and built with ifort version 19.0.5.281 for Linux and Windows. It has also been tested in gfortran.
  • HDF5 libraries: tested and built using HDF5 1.10.5, but it has also been used with other library versions.

Contents

The following source files are provided with the package:

  • Lib_Rwhdf5.f90: Fortran wrapper that defines interfaces for reading and writing h5 files.
  • Lib_Kind.f90: declares double precision and integer types.
  • exampleh5.f90: example that illustrates the usage of the package. It writes two arrays into data.h5.
  • Makefile: used to build exampleh5.f90. It depends on tree.dep that specifies the compilation order.
  • Read_HDF5.m: Matlab function that reads and h5 file.
  • example_readh5.m: example that illustrates how to use the function Read_HDF5.m to read data.h5.

Usage

After having the HDF5 library installed, load the two provided Fortran modules into your program.

use lib_kind
use lib_rwhdf5
implicit none

The Fortran wrapper provides four major subroutines and one integer type:

  • Subroutines hdf5_openf and hdf5_closef are used to open and close an h5 file. These are only needed when writing into an h5 file (not when reading).
  • Subroutines hdf5_read and hdf5_write are used to read and write data into an h5 file. The write subroutine should be used after an h5 file has been created with hdf5_openf. The file should be closed after all variables have been written to it.
  • Integer type hid_t: needed to "label" an h5 file when opened.

Finally, note that the Makefile specifies the HDF5_PATH variable that needs to be adjusted depending on where the include and lib folders of the HDF5 library have been installed.

License

MIT license.

About

Provides a Fortran wrapper for HDF5

License:MIT License


Languages

Language:Fortran 92.9%Language:MATLAB 4.7%Language:Makefile 2.3%