Coder Social home page Coder Social logo

bulrush2008 / oo_hdf5_fortran Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geospace-code/h5fortran

0.0 1.0 0.0 198 KB

Object-oriented, clean, simple HDF5 modern Fortran 2018 interface

License: BSD 3-Clause "New" or "Revised" License

CMake 4.88% Meson 2.03% Fortran 93.09%

oo_hdf5_fortran's Introduction

DOI Build Status Build status

Object-oriented Fortran 2018 HDF5 interface

Straightforward single-file/module access to HDF5. Uses Fortran 2008 submodule for clean, templatable structure. This thin object-oriented modern Fortran library abstracts away the messy parts of HDF5 so that you can read/write various types/ranks of data with a single command.

Polymorphic API with read/write for types integer, real32, real64 with rank:

  • scalar (0-D)
  • 1-D .. 7-D

as well as character (string) variables and attributes.

Tested on systems including

  • MacOS (via homebrew)
  • Ubuntu 16.04/18.04 (gfortran ≥ 5.4.1) with HDF5 1.8 and 1.10
  • Windows Subsystem for Linux.

Note: Currently, Cygwin does not have Fortran HDF5 libraries.

Build

Requirements:

  • modern Fortran 2008 compiler (such as gfortran ≥ 5.4.1, etc.)
  • HDF5 library (1.8 or 1.10)

Build this HDF5 OO Fortran interface with other Meson or CMake. The library libh5oo is built, link it into your program as usual.

Meson

meson build

ninja -C build

ninja test -C build

CMake

cd build
cmake ..

cmake --build .

ctest -V

If you need to specify a particular HDF5 library, use cmake -DHDF5_ROOT=/path/to/hdf5lib ..

Usage

All examples assume:

use hdf5_interface, only: hdf5_file
type(hdf5_file) :: h5f
  • gzip compression may be applied for rank ≥ 2 arrays by setting comp_lvl to a value betwen 1 and 9. Shuffle filter is automatically applied for better compression
  • string attributes may be applied to any variable at time of writing or later.
  • chunk_size option may be set for better compression

Create new HDF5 file, with variable "value1"

call h5f%initialize('test.h5',status='new',action='w')

call h5f%add('/value1', 123.)

call h5f%finalize()

Add variable "value1" to existing HDF5 file "test.h5"

call h5f%initialize('test.h5',status='old',action='rw')

call h5f%add('/value1', 123.)

call h5f%finalize()

Add gzip compressed 3-D array "value2" to existing HDF5 file "test.h5"

real :: val2(1000,1000,3) = 0.

call h5f%initialize('test.h5', comp_lvl=1)

call h5f%add('/value2', val2)

call h5f%finalize()

chunk_size may optionally be set in the %add() method.

Notes

The first character of the filename should be a character, NOT whitespace to avoid file open/creation errors.

Using compilers like PGI or Flang may require first compiling the HDF5 library yourself.

oo_hdf5_fortran's People

Contributors

scivision avatar fccf avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.