Skip to content

Commit

Permalink
v2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jul 31, 2020
1 parent 2d5ff03 commit 2304f0b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
34 changes: 34 additions & 0 deletions Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -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')
Expand Down

0 comments on commit 2304f0b

Please sign in to comment.