@@ -50,6 +50,40 @@ The flush request is on a per-file basis, so if multiple files are open, flush e
5050call 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
5589Analogous to regular Fortran ` open(status='scratch') ` , the file created will attempt to be deleted.
0 commit comments