Skip to content

Commit 2304f0b

Browse files
committed
v2.11.0
1 parent 2d5ff03 commit 2304f0b

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if(NOT CMAKE_BUILD_TYPE)
44
endif()
55
project(h5fortran
66
LANGUAGES C Fortran
7-
VERSION 2.10.5
7+
VERSION 2.11.0
88
DESCRIPTION "thin, light object-oriented HDF5 Fortran interface"
99
HOMEPAGE_URL https://github.com/geospace-code/h5fortran)
1010
enable_testing()

Examples.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,40 @@ The flush request is on a per-file basis, so if multiple files are open, flush e
5050
call h5f%flush()
5151
```
5252

53+
## rad / write attributes to variable
54+
55+
Note that HDF5 character attributes are scalar while int32, real32, real64 attributes are 1D vectors.
56+
57+
Assume variable "/x" exists and then see these examples:
58+
59+
### write attributes
60+
61+
```fortran
62+
call h%writeattr('/x', 'note','this is just a little number')
63+
call h%writeattr('/x', 'hello', 'hi')
64+
call h%writeattr('/x', 'life', [42])
65+
call h%writeattr('/x', 'life_float', [42._real32, 84._real32])
66+
call h%writeattr('/x', 'life_double', [42._real64])
67+
```
68+
69+
### read attributes
70+
71+
For attributes, HDF5 character values are *space-terminated* instead of null terminated.
72+
73+
```fortran
74+
character(1024) :: attr_str
75+
integer :: attr_int(1)
76+
real(real32) :: attr32(2)
77+
real(real64) :: attr64(1)
78+
79+
call h%readattr('/x', 'note', attr_str)
80+
if (attr_str /= 'this is just a little number') error stop 'readattr value note'
81+
82+
call h%readattr('/x', 'life', attr_int)
83+
call h%readattr('/x', 'life_float', attr32)
84+
call h%readattr('/x', 'life_double', attr64)
85+
```
86+
5387
## create temporary "scratch" file
5488

5589
Analogous to regular Fortran `open(status='scratch')`, the file created will attempt to be deleted.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Polymorphic API with read/write for types int32, real32, real64 with rank:
3232
* scalar (0-D)
3333
* 1-D .. 7-D
3434

35-
as well as character (string) variables and attributes.
35+
as well as **character (string)**
36+
37+
HDF5 **attributes** are also supported for read/write with type character, int32, real32, real64.
3638

3739
Array slicing on read is supported, that is, reading part of a disk HDF5 array into a variable of matching shape.
3840

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project('h5fortran', 'fortran',
22
meson_version : '>=0.52.0',
3-
version : '2.10.5',
3+
version : '2.11.0',
44
default_options : ['default_library=static', 'buildtype=release', 'warning_level=3'])
55

66
subdir('meson')

0 commit comments

Comments
 (0)