You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this would avoid implied temporary array casts in user code, if it works
test:lt: more robust
% write(): add datatype= optional parameter
test:cast: check other arrays, print class
test: print cast details
The "datatype" parameter is optional and defaults to the native type of the input array A.
229
+
Rather than implicitly cast with array temporaries in end-user code, which can be slow and trigger memory issues or compiler bugs (like GCC 9.5.0), instead use the "datatype" parameter to specify the HDF5 datatype explicitly.
230
+
For example, if the data in memory is real64, but it's desired to write real32 to disk to save disk space, do like:
231
+
232
+
```fortran
233
+
real(real64) :: darr(3,4,5)
234
+
type(h5fortran) :: h
235
+
236
+
call h % open("myfile.h5", action="w")
237
+
238
+
call h % write("/my_3d_data", darr, datatype=H5T_NATIVE_REAL)
To be explicit about the datatype, one can use the following HDF5 datatypes:
251
+
252
+
* H5T_STD_F32LE: real floating (32-bit, little-endian)
253
+
* H5T_STD_F64LE: real floating (64-bit, little-endian)
254
+
* H5T_STD_I32LE: integer (32-bit, little-endian)
255
+
* H5T_STD_I64LE: integer (64-bit, little-endian)
256
+
257
+
Of course, part of the beauty of HDF5 is the computer reading the HDF5 will automatically coerce the data to the native type of the host machine, so the end-user does not need to worry about this in most cases.
258
+
259
+
---
260
+
261
+
227
262
Write dataset attribute (e.g. units or instrument)
0 commit comments