From 2304f0b51a369e6030623e135e6ef8bf1ee6fed9 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Fri, 31 Jul 2020 14:56:38 -0400 Subject: [PATCH] v2.11.0 --- CMakeLists.txt | 2 +- Examples.md | 34 ++++++++++++++++++++++++++++++++++ README.md | 4 +++- meson.build | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d9cd86d..bd4d9a3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ if(NOT CMAKE_BUILD_TYPE) endif() project(h5fortran LANGUAGES C Fortran - VERSION 2.10.5 + VERSION 2.11.0 DESCRIPTION "thin, light object-oriented HDF5 Fortran interface" HOMEPAGE_URL https://github.com/geospace-code/h5fortran) enable_testing() diff --git a/Examples.md b/Examples.md index 67ecf32c..59759f11 100644 --- a/Examples.md +++ b/Examples.md @@ -50,6 +50,40 @@ The flush request is on a per-file basis, so if multiple files are open, flush e call h5f%flush() ``` +## rad / write attributes to variable + +Note that HDF5 character attributes are scalar while int32, real32, real64 attributes are 1D vectors. + +Assume variable "/x" exists and then see these examples: + +### write attributes + +```fortran +call h%writeattr('/x', 'note','this is just a little number') +call h%writeattr('/x', 'hello', 'hi') +call h%writeattr('/x', 'life', [42]) +call h%writeattr('/x', 'life_float', [42._real32, 84._real32]) +call h%writeattr('/x', 'life_double', [42._real64]) +``` + +### read attributes + +For attributes, HDF5 character values are *space-terminated* instead of null terminated. + +```fortran +character(1024) :: attr_str +integer :: attr_int(1) +real(real32) :: attr32(2) +real(real64) :: attr64(1) + +call h%readattr('/x', 'note', attr_str) +if (attr_str /= 'this is just a little number') error stop 'readattr value note' + +call h%readattr('/x', 'life', attr_int) +call h%readattr('/x', 'life_float', attr32) +call h%readattr('/x', 'life_double', attr64) +``` + ## create temporary "scratch" file Analogous to regular Fortran `open(status='scratch')`, the file created will attempt to be deleted. diff --git a/README.md b/README.md index fd0bba74..4de889e1 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,9 @@ Polymorphic API with read/write for types int32, real32, real64 with rank: * scalar (0-D) * 1-D .. 7-D -as well as character (string) variables and attributes. +as well as **character (string)** + +HDF5 **attributes** are also supported for read/write with type character, int32, real32, real64. Array slicing on read is supported, that is, reading part of a disk HDF5 array into a variable of matching shape. diff --git a/meson.build b/meson.build index bc9924d7..eb2df961 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('h5fortran', 'fortran', meson_version : '>=0.52.0', - version : '2.10.5', + version : '2.11.0', default_options : ['default_library=static', 'buildtype=release', 'warning_level=3']) subdir('meson')