summaryrefslogtreecommitdiffstats
path: root/develop/_h5_t__u_g.html
blob: 176073031035e9906a31d84c2789a5d8e63c5710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>HDF5: HDF5 Datatypes</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  $(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="hdf5doxy.css" rel="stylesheet" type="text/css">
<!-- <link href="hdf5doxy.css" rel="stylesheet" type="text/css"/>
 -->
<script type="text/javascript" src="hdf5_navtree_hacks.js"></script>
</head>
<body>
<div style="background:#FFDDDD;font-size:120%;text-align:center;margin:0;padding:5px">Please, help us to better serve our user community by answering the following short survey:  <a href="https://www.hdfgroup.org/website-survey/">https://www.hdfgroup.org/website-survey/</a></div>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="HDFG-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="https://www.hdfgroup.org">HDF5</a>
   &#160;<span id="projectnumber">1.15.0.68e8c0e</span>
   </div>
   <div id="projectbrief">API Reference</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
          <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('_h5_t__u_g.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">HDF5 Datatypes</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="sec_datatype"></a>
HDF5 Datatypes</h1>
<p>HDF5 datatypes describe the element type of HDF5 datasets and attributes. There's a large set of predefined datatypes, but users may find it useful to define new datatypes through a process called <em>derivation</em>.</p>
<p>The element type is automatically persisted as part of the HDF5 metadata of attributes and datasets. Additionally, datatype definitions can be persisted to HDF5 files and linked to groups as HDF5 datatype objects or so-called <em>committed datatypes</em>.</p>
<h2><a class="anchor" id="subsec_datatype_intro"></a>
Introduction and Definitions</h2>
<p>An HDF5 dataset is an array of data elements, arranged according to the specifications of the dataspace. In general, a data element is the smallest addressable unit of storage in the HDF5 file. (Compound datatypes are the exception to this rule.) The HDF5 datatype defines the storage format for a single data element. See the figure below.</p>
<p>The model for HDF5 attributes is extremely similar to datasets: an attribute has a dataspace and a data type, as shown in the figure below. The information in this chapter applies to both datasets and attributes.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig1.gif" alt=""/>
<div class="caption">
Datatypes, dataspaces, and datasets</div></div>
   </td></tr>
</table>
<p>Abstractly, each data element within the dataset is a sequence of bits, interpreted as a single value from a set of values (for example, a number or a character). For a given datatype, there is a standard or convention for representing the values as bits, and when the bits are represented in a particular storage the bits are laid out in a specific storage scheme such as 8-bit bytes with a specific ordering and alignment of bytes within the storage array.</p>
<p>HDF5 datatypes implement a flexible, extensible, and portable mechanism for specifying and discovering the storage layout of the data elements, determining how to interpret the elements (for example, as floating point numbers), and for transferring data from different compatible layouts.</p>
<p>An HDF5 datatype describes one specific layout of bits. A dataset has a single datatype which applies to every data element. When a dataset is created, the storage datatype is defined. After the dataset or attribute is created, the datatype cannot be changed. </p><ul>
<li>The datatype describes the storage layout of a singledata element </li>
<li>All elements of the dataset must have the same type </li>
<li>The datatype of a dataset is immutable</li>
</ul>
<p>When data is transferred (for example, a read or write), each end point of the transfer has a datatype, which describes the correct storage for the elements. The source and destination may have different (but compatible) layouts, in which case the data elements are automatically transformed during the transfer.</p>
<p>HDF5 datatypes describe commonly used binary formats for numbers (integers and floating point) and characters (ASCII). A given computing architecture and programming language supports certain number and character representations. For example, a computer may support 8-, 16-, 32-, and 64-bit signed integers, stored in memory in little-endian byte order. These would presumably correspond to the C programming language types <em>char</em>, <em>short</em>, <em>int</em>, and <em>long</em>.</p>
<p>When reading and writing from memory, the HDF5 library must know the appropriate datatype that describes the architecture specific layout. The HDF5 library provides the platform independent <em>NATIVE</em> types, which are mapped to an appropriate datatype for each platform. So the type <a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a> is an alias for the appropriate descriptor for each platform.</p>
<p>Data in memory has a datatype: </p><ul>
<li>The storage layout in memory is architecture-specific </li>
<li>The HDF5 <em>NATIVE</em> types are predefined aliases for the architecture-specific memory layout </li>
<li>The memory datatype need not be the same as the stored datatype of the dataset</li>
</ul>
<p>In addition to numbers and characters, an HDF5 datatype can describe more abstract classes of types including enumerations, strings, bit strings, and references (pointers to objects in the HDF5 file). HDF5 supports several classes of composite datatypes which are combinations of one or more other datatypes. In addition to the standard predefined datatypes, users can define new datatypes within the datatype classes.</p>
<p>The HDF5 datatype model is very general and flexible: </p><ul>
<li>For common simple purposes, only predefined types will be needed </li>
<li>Datatypes can be combined to create complex structured datatypes </li>
<li>If needed, users can define custom atomic datatypes </li>
<li>Committed datatypes can be shared by datasets or attributes</li>
</ul>
<h2><a class="anchor" id="subsec_datatype_model"></a>
Datatype Model</h2>
<p>The HDF5 library implements an object-oriented model of datatypes. HDF5 datatypes are organized as a logical set of base types, or datatype classes. Each datatype class defines a format for representing logical values as a sequence of bits. For example the <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aba1fc36abc23f073912e337d2291b037">H5T_INTEGER</a> class is a format for representing twos complement integers of various sizes.</p>
<p>A datatype class is defined as a set of one or more datatype properties. A datatype property is a property of the bit string. The datatype properties are defined by the logical model of the datatype class. For example, the integer class (twos complement integers) has properties such as “signed or unsigned”, “length”, and “byte-order”. The float class (IEEE floating point numbers) has these properties, plus “exponent bits”, “exponent sign”, etc.</p>
<p>A datatype is derived from one datatype class: a given datatype has a specific value for the datatype properties defined by the class. For example, for 32-bit signed integers, stored big-endian, the HDF5 datatype is a sub-type of integer with the properties set to signed=1, size=4(bytes), and byte-order=BE.</p>
<p>The HDF5 datatype API (H5T functions) provides methods to create datatypes of different datatype classes, to set the datatype properties of a new datatype, and to discover the datatype properties of an existing datatype.</p>
<p>The datatype for a dataset is stored in the HDF5 file as part of the metadata for the dataset. A datatype can be shared by more than one dataset in the file if the datatype is saved to the file with a name. This shareable datatype is known as a committed datatype. In the past, this kind of datatype was called a named datatype.</p>
<p>When transferring data (for example, a read or write), the data elements of the source and destination storage must have compatible types. As a general rule, data elements with the same datatype class are compatible while elements from different datatype classes are not compatible. When transferring data of one datatype to another compatible datatype, the HDF5 Library uses the datatype properties of the source and destination to automatically transform each data element. For example, when reading from data stored as 32-bit signed integers, big endian into 32-bit signed integers, little-endian, the HDF5 Library will automatically swap the bytes.</p>
<p>Thus, data transfer operations (<a class="el" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>, <a class="el" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>, <a class="el" href="group___h5_a.html#gaacb27a997f7c98e8a833d0fd63b58f1c">H5Aread</a>, <a class="el" href="group___h5_a.html#gab70871e205d57450c83efd9912be2b5c">H5Awrite</a>) require a datatype for both the source and the destination.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig2.gif" alt=""/>
<div class="caption">
The datatype model</div></div>
   </td></tr>
</table>
<p>The HDF5 library defines a set of predefined datatypes, corresponding to commonly used storage formats, such as twos complement integers, IEEE Floating point numbers, etc., 4- and 8-byte sizes, big-endian and little-endian byte orders. In addition, a user can derive types with custom values for the properties. For example, a user program may create a datatype to describe a 6-bit integer, or a 600-bit floating point number.</p>
<p>In addition to atomic datatypes, the HDF5 library supports composite datatypes. A composite datatype is an aggregation of one or more datatypes. Each class of composite datatypes has properties that describe the organization of the composite datatype. See the figure below. Composite datatypes include: </p><ul>
<li>Compound datatypes: structured records </li>
<li>Array: a multidimensional array of a datatype </li>
<li>Variable-length: a one-dimensional array of a datatype</li>
</ul>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig3.gif" alt=""/>
<div class="caption">
Composite datatypes</div></div>
   </td></tr>
</table>
<h3><a class="anchor" id="subsubsec_datatype_model_class"></a>
Datatype Classes and Properties</h3>
<p>The figure below shows the HDF5 datatype classes. Each class is defined to have a set of properties which describe the layout of the data element and the interpretation of the bits. The table below lists the properties for the datatype classes.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig4.gif" alt=""/>
<div class="caption">
Datatype classes</div></div>
   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Datatype classes and their properties</caption>
<tr>
<th>Class  </th><th>Description  </th><th>Properties  </th><th>Notes   </th></tr>
<tr>
<td>Integer  </td><td>Twos complement integers  </td><td>Size (bytes), precision (bits), offset (bits), pad, byte order, signed/unsigned  </td><td></td></tr>
<tr>
<td>Float  </td><td>Floating Point numbers  </td><td>Size (bytes), precision (bits), offset (bits), pad, byte order, sign position, exponent position, exponent size (bits), exponent sign, exponent bias, mantissa position, mantissa (size) bits, mantissa sign, mantissa normalization, internal padding  </td><td>See IEEE 754 for a definition of these properties. These properties describe non-IEEE 754 floating point formats as well.   </td></tr>
<tr>
<td>Character  </td><td>Array of 1-byte character encoding  </td><td>Size (characters), Character set, byte order, pad/no pad, pad character  </td><td>Currently, ASCII and UTF-8 are supported.   </td></tr>
<tr>
<td>Bitfield  </td><td>String of bits  </td><td>Size (bytes), precision (bits), offset (bits), pad, byte order  </td><td>A sequence of bit values packed into one or more bytes.   </td></tr>
<tr>
<td>Opaque  </td><td>Uninterpreted data  </td><td>Size (bytes), precision (bits), offset (bits), pad, byte order, tag  </td><td>A sequence of bytes, stored and retrieved as a block. The ‘tag’ is a string that can be used to label the value.   </td></tr>
<tr>
<td>Enumeration  </td><td>A list of discrete values, with symbolic names in the form of strings.  </td><td>Number of elements, element names, element values  </td><td>Enumeration is a list of pairs (name, value). The name is a string; the value is an unsigned integer.   </td></tr>
<tr>
<td>Reference  </td><td>Reference to object or region within the HDF5 file  </td><td><p class="starttd"></p>
<p class="endtd"></p>
</td><td><dl class="section see"><dt>See also</dt><dd><a class="el" href="group___h5_r.html">References (H5R)</a>   </dd></dl>
</td></tr>
<tr>
<td>Array  </td><td>Array (1-4 dimensions) of data elements  </td><td>Number of dimensions, dimension sizes, base datatype  </td><td>The array is accessed atomically: no selection or sub-setting.   </td></tr>
<tr>
<td>Variable-length  </td><td>A variable-length 1-dimensional array of data elements  </td><td>Current size, base type  </td><td><p class="starttd"></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Compound  </td><td>A Datatype of a sequence of Datatypes  </td><td>Number of members, member names, member types, member offset, member class, member size, byte order  </td><td><p class="starttd"></p>
<p class="endtd"></p>
</td></tr>
</table>
<h3><a class="anchor" id="subsubsec_datatype_model_predefine"></a>
Predefined Datatypes</h3>
<p>The HDF5 library predefines a modest number of commonly used datatypes. These types have standard symbolic names of the form H5T_arch_base where arch is an architecture name and base is a programming type name <b>Table 2</b>. New types can be derived from the predefined types by copying the predefined type <a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy()</a> and then modifying the result.</p>
<p>The base name of most types consists of a letter to indicate the class <b>Table 3</b>, a precision in bits, and an indication of the byte order <b>Table 4</b>.</p>
<p><b>Table 5</b> shows examples of predefined datatypes. The full list can be found in the <a class="el" href="group___p_d_t.html">Predefined Datatypes</a> section of the <a class="el" href="_r_m.html">HDF5 Reference Manual</a>.</p>
<table class="doxtable">
<caption align="top">Table 2. Architectures used in predefined datatypes</caption>
<tr>
<th>Architecture Name  </th><th span="3">Description   </th></tr>
<tr>
<td>IEEE  </td><td span="3">IEEE-754 standard floating point types in various byte orders.   </td></tr>
<tr>
<td>STD  </td><td span="3">This is an architecture that contains semi-standard datatypes like signed two's complement integers, unsigned integers, and bitfields in various byte orders.   </td></tr>
<tr>
<td>C &lt;br &gt; FORTRAN  </td><td span="3">Types which are specific to the C or Fortran programming languages are defined in these architectures. For instance, <a class="el" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a> defines a base string type with null termination which can be used to derive string types of other lengths.   </td></tr>
<tr>
<td>NATIVE  </td><td span="3">This architecture contains C-like datatypes for the machine for which the library was compiled. In order to be portable, applications should almost always use this architecture to describe things in memory.   </td></tr>
<tr>
<td>CRAY  </td><td span="3">Cray architectures. These are word-addressable, big-endian systems with non-IEEE floating point.   </td></tr>
<tr>
<td>INTEL  </td><td span="3">All Intel and compatible CPUs. These are little-endian systems with IEEE floating-point.   </td></tr>
<tr>
<td>MIPS  </td><td span="3">All MIPS CPUs commonly used in SGI systems. These are big-endian systems with IEEE floating-point.   </td></tr>
<tr>
<td>ALPHA  </td><td span="3">All DEC Alpha CPUs, little-endian systems with IEEE floating-point.   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 3. Base types</caption>
<tr>
<th>Base  </th><th span="3">Description   </th></tr>
<tr>
<td>B  </td><td span="3">Bitfield   </td></tr>
<tr>
<td>F  </td><td span="3">Floating point   </td></tr>
<tr>
<td>I  </td><td span="3">Signed integer   </td></tr>
<tr>
<td>R  </td><td span="3">References   </td></tr>
<tr>
<td>S  </td><td span="3">Character string   </td></tr>
<tr>
<td>U  </td><td span="3">Unsigned integer   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 4. Byte order</caption>
<tr>
<th>Order  </th><th span="3">Description   </th></tr>
<tr>
<td>BE  </td><td span="3">Big-endian   </td></tr>
<tr>
<td>LE  </td><td span="3">Little-endian   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 5. Some predefined datatypes</caption>
<tr>
<th>Example  </th><th span="3">Description   </th></tr>
<tr>
<td><a class="el" href="group___p_d_t_i_e_e_e.html#ga3f9c2185ec16632fab8c20ec7a63178e">H5T_IEEE_F64LE</a>  </td><td span="3">Eight-byte, little-endian, IEEE floating-point   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_i_e_e_e.html#ga71d24a7d4c373ed9a003d7a0d8133f1e">H5T_IEEE_F32BE</a>  </td><td span="3">Four-byte, big-endian, IEEE floating point   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a>  </td><td span="3">Four-byte, little-endian, signed two's complement integer   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_s_t_d.html#ga10e46ab72ac0330c51ed6cf709db4697">H5T_STD_U16BE</a>  </td><td span="3">Two-byte, big-endian, unsigned integer   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a>  </td><td span="3">One-byte,null-terminated string of eight-bit characters   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_x86.html#ga4eb389ac84af50af09998391169328bf">H5T_INTEL_B64</a>  </td><td span="3">Eight-byte bit field on an Intel CPU   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_s_t_d.html#gadc17e0960dc7ef08e029bf17201670e1">H5T_STD_REF_OBJ</a>  </td><td span="3">Reference to an entire object in a file   </td></tr>
</table>
<p>The HDF5 library predefines a set of <em>NATIVE</em> datatypes which are similar to C type names. The native types are set to be an alias for the appropriate HDF5 datatype for each platform. For example, <a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a> corresponds to a C int type. On an Intel based PC, this type is the same as <a class="el" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a>, while on a MIPS system this would be equivalent to <a class="el" href="group___p_d_t_s_t_d.html#ga37e8a6be7ee64587c2a282b965019bb8">H5T_STD_I32BE</a>. Table 6 shows examples of <em>NATIVE</em> types and corresponding C types for a common 32-bit workstation.</p>
<table class="doxtable">
<caption align="top">Table 6. Native and 32-bit C datatypes</caption>
<tr>
<th>Example  </th><th span="3">Corresponding C Type   </th></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a>  </td><td span="3">char   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga273ddc372a6d574c67415917bb5232e5">H5T_NATIVE_SCHAR</a>  </td><td span="3">signed char   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga39cadf50f1701a2af3afa86eba3c7cbd">H5T_NATIVE_UCHAR</a>  </td><td span="3">unsigned char   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#gae0625357fa121eca117f7fa9c4701810">H5T_NATIVE_SHORT</a>  </td><td span="3">short   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#gad0a240282e54647b83fe28ef65b40655">H5T_NATIVE_USHORT</a>  </td><td span="3">unsigned short   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>  </td><td span="3">int   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga904b507c7b8aa4838fbb7c6ce71a37c5">H5T_NATIVE_UINT</a>  </td><td span="3">unsigned   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga290b9655882754ee0ec9f31b42ac04f6">H5T_NATIVE_LONG</a>  </td><td span="3">long   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#gacaea6c2c381167bacf67f6d6c43eb718">H5T_NATIVE_ULONG</a>  </td><td span="3">unsigned long   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#gafb9c5d393d693869d7d21f71753a532c">H5T_NATIVE_LLONG</a>  </td><td span="3">long long   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga91ed0d2ce3289ef3707449cf5babe928">H5T_NATIVE_ULLONG</a>  </td><td span="3">unsigned long long   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>  </td><td span="3">float   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>  </td><td span="3">double   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga6b68c680440c463ce03c5efbf8cdf1c0">H5T_NATIVE_LDOUBLE</a>  </td><td span="3">long double   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga3a3d25a1c3ccc59534276c2634423965">H5T_NATIVE_HSIZE</a>  </td><td span="3">hsize_t   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga459210d1b4edad1f2b53c1b42ffb85e2">H5T_NATIVE_HSSIZE</a>  </td><td span="3">hssize_t   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga142d44a537dca7ec39da37bca48f7e40">H5T_NATIVE_HERR</a>  </td><td span="3">herr_t   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga8bd74ace7938e1732ad74d7332de3df2">H5T_NATIVE_HBOOL</a>  </td><td span="3">bool   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga2ed3827a2add0f6f2252c17e231b84b1">H5T_NATIVE_B8</a>  </td><td span="3">8-bit unsigned integer or 8-bit buffer in memory   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga81aba8febe34dc8ae2c9fa06aa4c4800">H5T_NATIVE_B16</a>  </td><td span="3">16-bit unsigned integer or 16-bit buffer in memory   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga87ec5cf19bdbf8203ca1e9a19bc59a9f">H5T_NATIVE_B32</a>  </td><td span="3">32-bit unsigned integer or 32-bit buffer in memory   </td></tr>
<tr>
<td><a class="el" href="group___p_d_t_n_a_t.html#ga4fe14f1ec3a8bd68112df6859e2db783">H5T_NATIVE_B64</a>  </td><td span="3">64-bit unsigned integer or 64-bit buffer in memory   </td></tr>
</table>
<h2><a class="anchor" id="subsec_datatype_usage"></a>
How Datatypes are Used</h2>
<h3><a class="anchor" id="subsubsec_datatype_usage_object"></a>
The Datatype Object and the HDF5 Datatype API</h3>
<p>The HDF5 library manages datatypes as objects. The HDF5 datatype API manipulates the datatype objects through C function calls. New datatypes can be created from scratch or copied from existing datatypes. When a datatype is no longer needed its resources should be released by calling <a class="el" href="group___h5_t.html#gafcba4db244f6a4d71e99c6e72b8678f0">H5Tclose()</a>.</p>
<p>The datatype object is used in several roles in the HDF5 data model and library. Essentially, a datatype is used whenever the form at of data elements is needed. There are four major uses of datatypes in the HDF5 library: at dataset creation, during data transfers, when discovering the contents of a file, and for specifying user-defined datatypes. See the table below.</p>
<table class="doxtable">
<caption align="top">Table 7. Datatype uses</caption>
<tr>
<th>Use  </th><th span="2">Description   </th></tr>
<tr>
<td>Dataset creation  </td><td span="2">The datatype of the data elements must be declared when the dataset is created.   </td></tr>
<tr>
<td>Dataset transfer  </td><td span="2">The datatype (format) of the data elements must be defined for both the source and destination.   </td></tr>
<tr>
<td>Discovery  </td><td span="2">The datatype of a dataset can be interrogated to retrieve a complete description of the storage layout.   </td></tr>
<tr>
<td>Creating user-defined datatypes  </td><td span="2">Users can define their own datatypes by creating datatype objects and setting their properties.   </td></tr>
</table>
<h3><a class="anchor" id="subsubsec_datatype_usage_create"></a>
Dataset Creation</h3>
<p>All the data elements of a dataset have the same datatype. When a dataset is created, the datatype for the data elements must be specified. The datatype of a dataset can never be changed. The example below shows the use of a datatype to create a dataset called “/dset”. In this example, the dataset will be stored as 32-bit signed integers in big-endian order.</p>
<p><em> Using a datatype to create a dataset </em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dt;</div>
<div class="line"> </div>
<div class="line">dt = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>(<a class="code hl_define" href="group___p_d_t_s_t_d.html#ga37e8a6be7ee64587c2a282b965019bb8">H5T_STD_I32BE</a>);</div>
<div class="line">dataset_id = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file_id, “/dset”, dt, dataspace_id, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="ttc" id="a_h5_ipublic_8h_html_a0045db7ff9c22ad35db6ae91662e1943"><div class="ttname"><a href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></div><div class="ttdeci">int64_t hid_t</div><div class="ttdef"><b>Definition</b> H5Ipublic.h:60</div></div>
<div class="ttc" id="a_h5_ppublic_8h_html_afa85e97bfbf9bf1c58e39263846c568f"><div class="ttname"><a href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a></div><div class="ttdeci">#define H5P_DEFAULT</div><div class="ttdef"><b>Definition</b> H5Ppublic.h:102</div></div>
<div class="ttc" id="agroup___h5_d_html_ga0647ba4bbd26d5230cc07f3a5685b2cf"><div class="ttname"><a href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a></div><div class="ttdeci">#define H5Dcreate</div><div class="ttdef"><b>Definition</b> H5version.h:892</div></div>
<div class="ttc" id="agroup___h5_t_html_gaec07efbab84f4e5b4ed22f010786be8e"><div class="ttname"><a href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a></div><div class="ttdeci">hid_t H5Tcopy(hid_t type_id)</div><div class="ttdoc">Copies an existing datatype.</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga37e8a6be7ee64587c2a282b965019bb8"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga37e8a6be7ee64587c2a282b965019bb8">H5T_STD_I32BE</a></div><div class="ttdeci">#define H5T_STD_I32BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:305</div></div>
</div><!-- fragment --><h3><a class="anchor" id="subsubsec_datatype_usage_transfer"></a>
Data Transfer (Read and Write)</h3>
<p>Probably the most common use of datatypes is to write or read data from a dataset or attribute. In these operations, each data element is transferred from the source to the destination (possibly rearranging the order of the elements). Since the source and destination do not need to be identical (in other words, one is disk and the other is memory), the transfer requires both the format of the source element and the destination element. Therefore, data transfers use two datatype objects, for the source and destination.</p>
<p>When data is written, the source is memory and the destination is disk (file). The memory datatype describes the format of the data element in the machine memory, and the file datatype describes the desired format of the data element on disk. Similarly, when reading, the source datatype describes the format of the data element on disk, and the destination datatype describes the format in memory.</p>
<p>In the most common cases, the file datatype is the datatype specified when the dataset was created, and the memory datatype should be the appropriate <em>NATIVE</em> type. The examples below show samples of writing data to and reading data from a dataset. The data in memory is declared C type ‘int’, and the datatype <a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a> corresponds to this type. The datatype of the dataset should be of datatype class <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aba1fc36abc23f073912e337d2291b037">H5T_INTEGER</a>.</p>
<p><em> Writing to a dataset </em> </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> dset_data[DATA_SIZE];</div>
<div class="line"> </div>
<div class="line">status = <a class="code hl_function" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>(dataset_id, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, dset_data);</div>
<div class="ttc" id="a_h5_spublic_8h_html_a5f96eeee84b987f18470737f85af0484"><div class="ttname"><a href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a></div><div class="ttdeci">#define H5S_ALL</div><div class="ttdef"><b>Definition</b> H5Spublic.h:32</div></div>
<div class="ttc" id="agroup___h5_d_html_ga98f44998b67587662af8b0d8a0a75906"><div class="ttname"><a href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a></div><div class="ttdeci">herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf)</div><div class="ttdoc">Writes raw data from a buffer to a dataset.</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga3cf93ffc6782be68070ef8e00f219ec2"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a></div><div class="ttdeci">#define H5T_NATIVE_INT</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:767</div></div>
</div><!-- fragment --><p><em> Reading from a dataset </em> </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> dset_data[DATA_SIZE];</div>
<div class="line"> </div>
<div class="line">status = <a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset_id, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, dset_data);</div>
<div class="ttc" id="agroup___h5_d_html_ga8287d5a7be7b8e55ffeff68f7d26811c"><div class="ttname"><a href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a></div><div class="ttdeci">herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf)</div><div class="ttdoc">Reads raw data from a dataset into a provided buffer.</div></div>
</div><!-- fragment --><h3><a class="anchor" id="subsubsec_datatype_usage_discover"></a>
Discovery of Data Format</h3>
<p>The HDF5 Library enables a program to determine the datatype class and properties for any datatype. In order to discover the storage format of data in a dataset, the datatype is obtained, and the properties are determined by queries to the datatype object. The example below shows code that analyzes the datatype for an integer and prints out a description of its storage properties (byte order, signed, size).</p>
<p><em> Discovering datatype properties </em> </p><div class="fragment"><div class="line"><span class="keywordflow">switch</span> (<a class="code hl_function" href="group___h5_t.html#ga364545c053f925fec65880b235e37898">H5Tget_class</a>(type)) {</div>
<div class="line">  <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aba1fc36abc23f073912e337d2291b037">H5T_INTEGER</a>:</div>
<div class="line">    ord = <a class="code hl_function" href="group___a_t_o_m.html#gaeb5bd7ec46787a4b6d33947dc73c2a5f">H5Tget_order</a>(type);</div>
<div class="line">    sgn = <a class="code hl_function" href="group___a_t_o_m.html#ga636f7655e706ccf7a3f23566ca561e90">H5Tget_sign</a>(type);</div>
<div class="line">    printf(“Integer ByteOrder= ”);</div>
<div class="line">    <span class="keywordflow">switch</span> (ord) {</div>
<div class="line">      <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0ae5668f73f6c28feddb7af175ac53012d">H5T_ORDER_LE</a>:</div>
<div class="line">        printf(“LE”);</div>
<div class="line">        <span class="keywordflow">break</span>;</div>
<div class="line">      <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0acb00548c30987f873e6836c16dbccec2">H5T_ORDER_BE</a>:</div>
<div class="line">        printf(“BE”);</div>
<div class="line">        <span class="keywordflow">break</span>;</div>
<div class="line">    }</div>
<div class="line">    printf(“ Sign= ”);</div>
<div class="line">    <span class="keywordflow">switch</span> (sgn) {</div>
<div class="line">      <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71aca59fce1697506dd3cbc7955eca77a12">H5T_SGN_NONE</a>:</div>
<div class="line">        printf(“false”);</div>
<div class="line">        <span class="keywordflow">break</span>;</div>
<div class="line">      <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71a1152d5238ff7af5c9d50edfea1ed1357">H5T_SGN_2</a>:</div>
<div class="line">        printf(“true”);</div>
<div class="line">        <span class="keywordflow">break</span>;</div>
<div class="line">    }</div>
<div class="line">    printf(“ Size= ”);</div>
<div class="line">    sz = <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(type);</div>
<div class="line">    printf(“%d”, sz);</div>
<div class="line">    printf(“\n”);</div>
<div class="line">    <span class="keywordflow">break</span>;</div>
<div class="line">  <span class="keywordflow">case</span> H5T_????</div>
<div class="line">    ...</div>
<div class="line">    <span class="keywordflow">break</span>;</div>
<div class="line">}</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2aba1fc36abc23f073912e337d2291b037"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aba1fc36abc23f073912e337d2291b037">H5T_INTEGER</a></div><div class="ttdeci">@ H5T_INTEGER</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:32</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a2a6a8eb856a0829fecaac60f803c9fd0acb00548c30987f873e6836c16dbccec2"><div class="ttname"><a href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0acb00548c30987f873e6836c16dbccec2">H5T_ORDER_BE</a></div><div class="ttdeci">@ H5T_ORDER_BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:55</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a2a6a8eb856a0829fecaac60f803c9fd0ae5668f73f6c28feddb7af175ac53012d"><div class="ttname"><a href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0ae5668f73f6c28feddb7af175ac53012d">H5T_ORDER_LE</a></div><div class="ttdeci">@ H5T_ORDER_LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:54</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_af7bfee2db210a12b9290eba85d730a71a1152d5238ff7af5c9d50edfea1ed1357"><div class="ttname"><a href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71a1152d5238ff7af5c9d50edfea1ed1357">H5T_SGN_2</a></div><div class="ttdeci">@ H5T_SGN_2</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:70</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_af7bfee2db210a12b9290eba85d730a71aca59fce1697506dd3cbc7955eca77a12"><div class="ttname"><a href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71aca59fce1697506dd3cbc7955eca77a12">H5T_SGN_NONE</a></div><div class="ttdeci">@ H5T_SGN_NONE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:69</div></div>
<div class="ttc" id="agroup___a_t_o_m_html_ga636f7655e706ccf7a3f23566ca561e90"><div class="ttname"><a href="group___a_t_o_m.html#ga636f7655e706ccf7a3f23566ca561e90">H5Tget_sign</a></div><div class="ttdeci">H5T_sign_t H5Tget_sign(hid_t type_id)</div><div class="ttdoc">Retrieves the sign type for an integer type.</div></div>
<div class="ttc" id="agroup___a_t_o_m_html_gaeb5bd7ec46787a4b6d33947dc73c2a5f"><div class="ttname"><a href="group___a_t_o_m.html#gaeb5bd7ec46787a4b6d33947dc73c2a5f">H5Tget_order</a></div><div class="ttdeci">H5T_order_t H5Tget_order(hid_t type_id)</div><div class="ttdoc">Returns the byte order of an atomic datatype.</div></div>
<div class="ttc" id="agroup___h5_t_html_ga1b971589cd7a86f3e84affdee455564e"><div class="ttname"><a href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a></div><div class="ttdeci">size_t H5Tget_size(hid_t type_id)</div><div class="ttdoc">Returns the size of a datatype.</div></div>
<div class="ttc" id="agroup___h5_t_html_ga364545c053f925fec65880b235e37898"><div class="ttname"><a href="group___h5_t.html#ga364545c053f925fec65880b235e37898">H5Tget_class</a></div><div class="ttdeci">H5T_class_t H5Tget_class(hid_t type_id)</div><div class="ttdoc">Returns a datatype class.</div></div>
</div><!-- fragment --><h3><a class="anchor" id="subsubsec_datatype_usage_user"></a>
Creating and Using User‐defined Datatypes</h3>
<p>Most programs will primarily use the predefined datatypes described above, possibly in composite data types such as compound or array datatypes. However, the HDF5 datatype model is extremely general; a user program can define a great variety of atomic datatypes (storage layouts). In particular, the datatype properties can define signed and unsigned integers of any size and byte order, and floating point numbers with different formats, size, and byte order. The HDF5 datatype API provides methods to set these properties.</p>
<p>User-defined types can be used to define the layout of data in memory; examples might match some platform specific number format or application defined bit-field. The user-defined type can also describe data in the file such as an application-defined format. The user-defined types can be translated to and from standard types of the same class, as described above.</p>
<h2><a class="anchor" id="subsec_datatype_function"></a>
Datatype Function Summaries</h2>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group___h5_t.html">Datatypes (H5T)</a> reference manual provides a reference list of datatype functions, the <a class="el" href="group___h5_t.html">Datatypes (H5T)</a> APIs.</dd></dl>
<h2><a class="anchor" id="subsec_datatype_program"></a>
Programming Model for Datatypes</h2>
<p>The HDF5 Library implements an object-oriented model of datatypes. HDF5 datatypes are organized as a logical set of base types, or datatype classes. The HDF5 Library manages datatypes as objects. The HDF5 datatype API manipulates the datatype objects through C function calls. The figure below shows the abstract view of the datatype object. The table below shows the methods (C functions) that operate on datatype objects. New datatypes can be created from scratch or copied from existing datatypes.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig5.gif" alt=""/>
<div class="caption">
The datatype object</div></div>
   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 8. General operations on datatype objects</caption>
<tr>
<th>API Function  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> <a class="el" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2">H5T_class_t</a> class, size_t size)  </td><td>Create a new datatype object of datatype class . The following datatype classes care supported with this function: <ul>
<li><a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> </li>
<li><a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aaf11325a64ed5369e88d8d0d600b5cce">H5T_OPAQUE</a> </li>
<li><a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5ee305303f12787367ac271d8f28f2e6">H5T_ENUM</a> </li>
<li>Other datatypes are created with <a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy()</a>.   </li>
</ul>
</td></tr>
<tr>
<td><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> <a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>Obtain a modifiable transient datatype which is a copy of type. If type is a dataset identifier then the type returned is a modifiable transient copy of the datatype of the specified dataset.   </td></tr>
<tr>
<td><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> <a class="el" href="group___h5_t.html#ga1d14b407603fdcedfbed1f723784c209">H5Topen</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> location, const char *name, <a class="el" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)  </td><td>Open a committed datatype. The committed datatype returned by this function is read-only.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#aa8f6c28736dbd0f18388c67911d38aca">htri_t</a> <a class="el" href="group___h5_t.html#gaa92250f289b557b63cba974defa20b0f">H5Tequal</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type1, <a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type2)  </td><td>Determines if two types are equal.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___h5_t.html#gafcba4db244f6a4d71e99c6e72b8678f0">H5Tclose</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>Releases resources associated with a datatype obtained from <a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>, <a class="el" href="group___h5_t.html#ga1d14b407603fdcedfbed1f723784c209">H5Topen</a>, or <a class="el" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a>. It is illegal to close an immutable transient datatype (for example, predefined types).   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___h5_t.html#ga9a224eb59f0ba807789e3f8ba3a840cd">H5Tcommit</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> location, const char *name, hid_t type, <a class="el" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="el" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="el" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)  </td><td>Commit a transient datatype (not immutable) to a file to become a committed datatype. Committed datatypes can be shared.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#aa8f6c28736dbd0f18388c67911d38aca">htri_t</a> <a class="el" href="group___h5_t.html#ga0eba38d8c49784269e71ac9fa79b0f0a">H5Tcommitted</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>Test whether the datatype is transient or committed (named).   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___h5_t.html#ga523642dbf4c60a83127fff87664a965b">H5Tlock</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>Make a transient datatype immutable (read-only and not closable). Predefined types are locked.   </td></tr>
</table>
<p>In order to use a datatype, the object must be created (<a class="el" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a>), or a reference obtained by cloning from an existing type (<a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>), or opened (<a class="el" href="group___h5_t.html#ga1d14b407603fdcedfbed1f723784c209">H5Topen</a>). In addition, a reference to the datatype of a dataset or attribute can be obtained with <a class="el" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb">H5Dget_type</a> or <a class="el" href="group___h5_a.html#ga0b070b714b2e535df2e1cb3005026a44">H5Aget_type</a>. For composite datatypes a reference to the datatype for members or base types can be obtained (<a class="el" href="group___c_o_m_p_o_u_n_d.html#gaf5de0eabe28246f040342e275b9a63eb">H5Tget_member_type</a>, <a class="el" href="group___h5_t.html#ga331e8f7b388a50af77294018db788de3">H5Tget_super</a>). When the datatype object is no longer needed, the reference is discarded with <a class="el" href="group___h5_t.html#gafcba4db244f6a4d71e99c6e72b8678f0">H5Tclose</a>.</p>
<p>Two datatype objects can be tested to see if they are the same with <a class="el" href="group___h5_t.html#gaa92250f289b557b63cba974defa20b0f">H5Tequal</a>. This function returns true if the two datatype references refer to the same datatype object. However, if two datatype objects define equivalent datatypes (the same datatype class and datatype properties), they will not be considered ‘equal’.</p>
<p>A datatype can be written to the file as a first class object (<a class="el" href="group___h5_t.html#ga9a224eb59f0ba807789e3f8ba3a840cd">H5Tcommit</a>). This is a committed datatype and can be used in thesame way as any other datatype.</p>
<h3><a class="anchor" id="subsubsec_datatype_program_discover"></a>
Discovery of Datatype Properties</h3>
<p>Any HDF5 datatype object can be queried to discover all of its datatype properties. For each datatype class, there are a set of API functions to retrieve the datatype properties for this class.</p>
<h4>Properties of Atomic Datatypes</h4>
<p>Table 9 lists the functions to discover the properties of atomic datatypes. Table 10 lists the queries relevant to specific numeric types. Table 11 gives the properties for atomic string datatype, and Table 12 gives the property of the opaque datatype.</p>
<table class="doxtable">
<caption align="top">Table 9. Functions to discover properties of atomic datatypes</caption>
<tr>
<th>API Function  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2">H5T_class_t</a> <a class="el" href="group___h5_t.html#ga364545c053f925fec65880b235e37898">H5Tget_class</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>The datatype class: <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aba1fc36abc23f073912e337d2291b037">H5T_INTEGER</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2e92f1a42a19de186a139ab8ff0745a9">H5T_FLOAT</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2de5d7919fe54466b7cf6a6c0b4265fa">H5T_STRING</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aae32f37ec15a835aa08d9277ad7ffaa2">H5T_BITFIELD</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aaf11325a64ed5369e88d8d0d600b5cce">H5T_OPAQUE</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5850e0b9353a5e7aeb615fb943d4e9cd">H5T_REFERENCE</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5ee305303f12787367ac271d8f28f2e6">H5T_ENUM</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2ad8ff83b6b7ca22575263561221193028">H5T_VLEN</a>, <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a>   </td></tr>
<tr>
<td>size_t <a class="el" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>The total size of the element in bytes, including padding which may appear on either side of the actual value.   </td></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0">H5T_order_t</a> <a class="el" href="group___a_t_o_m.html#gaeb5bd7ec46787a4b6d33947dc73c2a5f">H5Tget_order</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>The byte order describes how the bytes of the datatype are laid out in memory. If the lowest memory address contains the least significant byte of the datum then it is said to be little-endian or <a class="el" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0ae5668f73f6c28feddb7af175ac53012d">H5T_ORDER_LE</a>. If the bytes are in the opposite order then they are said to be big-endianor <a class="el" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0acb00548c30987f873e6836c16dbccec2">H5T_ORDER_BE</a>.   </td></tr>
<tr>
<td>size_t <a class="el" href="group___a_t_o_m.html#gaac9f5410c8cf456f048011030b7f90f9">H5Tget_precision</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>The precision property identifies the number of significant bits of a datatype and the offset property (defined below) identifies its location. Some datatypes occupy more bytes than what is needed to store the value. For instance, a short on a Cray is 32 significant bits in an eight-byte field.   </td></tr>
<tr>
<td>int <a class="el" href="group___a_t_o_m.html#ga225f0b6d173f90d3696bb68b88ae07c1">H5Tget_offset</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>The offset property defines the bit location of the least significant bit of a bit field whose length is precision.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#ga26a22811b56f5a63b6cb638f6773d872">H5Tget_pad</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aa">H5T_pad_t</a> *lsb, <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aa">H5T_pad_t</a> *msb)  </td><td>Padding is the bits of a data element which are not significant as defined by the precision and offset properties. Padding in the low-numbered bits is lsb padding and padding in the high-numbered bits is msb padding. Padding bits can be set to zero (<a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a>) or one (<a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8">H5T_PAD_ONE</a>).   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 10. Functions to discover properties of atomic datatypes</caption>
<tr>
<th>API Function  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71">H5T_sign_t</a> <a class="el" href="group___a_t_o_m.html#ga636f7655e706ccf7a3f23566ca561e90">H5Tget_sign</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>(INTEGER)Integer data can be signed two's complement (<a class="el" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71a1152d5238ff7af5c9d50edfea1ed1357">H5T_SGN_2</a>) or unsigned (<a class="el" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71aca59fce1697506dd3cbc7955eca77a12">H5T_SGN_NONE</a>).   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#ga42e62cb497fdec8f08cb9ac3c6de0e14">H5Tget_fields</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t *spos, size_t *epos, size_t *esize, size_t*mpos, size_t *msize)  </td><td>(FLOAT)A floating-point data element has bit fields which are the exponent and mantissa as well as a mantissa sign bit. These properties define the location (bit position of least significant bit of the field) and size (in bits) of each field. The sign bit is always of length one and none of the fields are allowed to overlap.   </td></tr>
<tr>
<td>size_t <a class="el" href="group___a_t_o_m.html#ga302b1c22cc6007ca69724a9e387e3888">H5Tget_ebias</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>(FLOAT)A floating-point data element has bit fields which are the exponent and mantissa as well as a mantissa sign bit. These properties define the location (bit position of least significant bit of the field) and size (in bits) of each field. The sign bit is always of length one and none of the fields are allowed to overlap.   </td></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80">H5T_norm_t</a> <a class="el" href="group___a_t_o_m.html#gad43c79f15565465a3559f5faf2c87b75">H5Tget_norm</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>(FLOAT)This property describes the normalization method of the mantissa. <ul>
<li>
<a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80a9dc5e01d17abf41c619e154150de8dde">H5T_NORM_MSBSET</a>: the mantissa is shifted left (if non-zero) until the first bit after the radix point is set and the exponent is adjusted accordingly. All bits of the mantissa after the radix point are stored.  </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80a5b649062dea480101917cc2d6b58f65d">H5T_NORM_IMPLIED</a>: the mantissa is shifted left (if non-zero) until the first bit after the radix point is set and the exponent is adjusted accordingly. The first bit after the radix point is not stored since it's always set.  </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80ab1a219215c45144cf317f2ea846a861c">H5T_NORM_NONE</a>: the fractional part of the mantissa is stored without normalizing it.</li>
</ul>
</td></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aa">H5T_pad_t</a> <a class="el" href="group___a_t_o_m.html#gaaea02cfeb3e749d0983563b4d510a321">H5Tget_inpad</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>(FLOAT)If any internal bits (that is, bits between the sign bit, the mantissa field, and the exponent field but within the precision field) are unused, then they will be filled according to the value of this property. The padding can be: <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaac2ca8836f78fc3e7f524098857c42e64">H5T_PAD_BACKGROUND</a>, <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a>,or <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8">H5T_PAD_ONE</a>.   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 11. Functions to discover properties of atomic string datatypes</caption>
<tr>
<th>API Function  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71a">H5T_cset_t</a> <a class="el" href="group___a_t_o_m.html#ga5bc2f3e8f708f5bcdd0d8667950310c1">H5Tget_cset</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>Two character sets are currently supported: ASCII (<a class="el" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa27383e03d1cad9b4c32d8611a145d663">H5T_CSET_ASCII</a>) and UTF-8 (<a class="el" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa41685667f69bf81eb7de5dd5f452e658">H5T_CSET_UTF8</a>).   </td></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514">H5T_str_t</a> <a class="el" href="group___a_t_o_m.html#ga564b21cc269467c39f59462feb0d5903">H5Tget_strpad</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>The string datatype has a fixed length, but the string may be shorter than the length. This property defines the storage mechanism for the left over bytes. The options are: <ul>
<li><a class="el" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a23c685afc240bbac4da23b36d8fd7e13">H5T_STR_NULLTERM</a> </li>
<li><a class="el" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a128d51156e51b7a2c9db0fe8787b4547">H5T_STR_NULLPAD</a> </li>
<li><a class="el" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a3f73f8dae99444798f5efd7d2d2a5e5c">H5T_STR_SPACEPAD</a>.   </li>
</ul>
</td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 12. Functions to discover properties of atomic opaque datatypes</caption>
<tr>
<th>API Function  </th><th>Description   </th></tr>
<tr>
<td>char* <a class="el" href="group___o_p_a_q_u_e.html#gaf1d0f634ac1a3b4220b8fe0197b93832">H5Tget_tag</a>(<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id)  </td><td>A user-defined string.   </td></tr>
</table>
<h4>Properties of Composite Datatypes</h4>
<p>The composite datatype classes can also be analyzed to discover their datatype properties and the datatypes that are members or base types of the composite datatype. The member or base type can, in turn, be analyzed. The table below lists the functions that can access the datatype properties of the different composite datatypes.</p>
<table class="doxtable">
<caption align="top">Table 13. Functions to discover properties of composite datatypes</caption>
<tr>
<th>API Function  </th><th>Description   </th></tr>
<tr>
<td>int <a class="el" href="group___c_o_m_p_e_n_u_m.html#ga21bdfc706f71ebe298a433e74b5bc626">H5Tget_nmembers</a>(<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id)  </td><td>(COMPOUND)The number of fields in the compound datatype.   </td></tr>
<tr>
<td><a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2">H5T_class_t</a> <a class="el" href="group___c_o_m_p_o_u_n_d.html#gac8476d164fb972fbf7b8c4584b8e916b">H5Tget_member_class</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> cdtype_id, unsigned member_no)  </td><td>(COMPOUND)The datatype class of compound datatype member member_no.   </td></tr>
<tr>
<td>char* <a class="el" href="group___c_o_m_p_e_n_u_m.html#ga64d1d807464d2011192f28115580fb66">H5Tget_member_name</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id, unsigned field_idx)  </td><td>(COMPOUND)The name of field field_idx of a compound datatype.   </td></tr>
<tr>
<td>size_t <a class="el" href="group___c_o_m_p_o_u_n_d.html#ga46cf2a60b54a08695635749c215af4af">H5Tget_member_offset</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id, unsigned memb_no)  </td><td>(COMPOUND)The byte offset of the beginning of a field within a compound datatype.   </td></tr>
<tr>
<td><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> <a class="el" href="group___c_o_m_p_o_u_n_d.html#gaf5de0eabe28246f040342e275b9a63eb">H5Tget_member_type</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id, unsigned field_idx)  </td><td>(COMPOUND)The datatype of the specified member.   </td></tr>
<tr>
<td>int <a class="el" href="group___a_r_r_a_y.html#gadec89de23da8efaba4677abfd818a9c0">H5Tget_array_ndims</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> adtype_id)  </td><td>(ARRAY)The number of dimensions (rank) of the array datatype object.   </td></tr>
<tr>
<td>int <a class="el" href="group___a_r_r_a_y.html#ga2b4fecf95c9c16e4431d8aba60995473">H5Tget_array_dims</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> adtype_id, hsize_t *dims[])  </td><td>(ARRAY)The sizes of the dimensions and the dimension permutations of the array datatype object.   </td></tr>
<tr>
<td><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> <a class="el" href="group___h5_t.html#ga331e8f7b388a50af77294018db788de3">H5Tget_super</a>(<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)  </td><td>(ARRAY, VL, ENUM)The base datatype from which the datatype type is derived.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___e_n_u_m.html#gab45f148151595716006ad8b603d55623">H5Tenum_nameof</a>(<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, const void *value, char *name, size_t size)  </td><td>(ENUM)The symbol name that corresponds to the specified value of the enumeration datatype.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___e_n_u_m.html#ga5a50f4172640de713e16f0ecd12aeb30">H5Tenum_valueof</a>(<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, const char *name, void *value)  </td><td>(ENUM)The value that corresponds to the specified name of the enumeration datatype.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___e_n_u_m.html#ga4fc2d29dcde5af45b905bbc7355d2b76">H5Tget_member_value</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type unsigned memb_no, void *value)  </td><td>(ENUM)The value of the enumeration datatype member memb_no.   </td></tr>
</table>
<h3><a class="anchor" id="subsubsec_datatype_program_define"></a>
Definition of Datatypes</h3>
<p>The HDF5 library enables user programs to create and modify datatypes. The essential steps are: </p><ul>
<li>
1. Create a new datatype object of a specific composite datatype class, or copy an existing atomic datatype object </li>
<li>
2. Set properties of the datatype object </li>
<li>
3. Use the datatype object </li>
<li>
4. Close the datatype object</li>
</ul>
<p>To create a user-defined atomic datatype, the procedure is to clone a predefined datatype of the appropriate datatype class (<a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>), and then set the datatype properties appropriate to the datatype class. The table below shows how to create a datatype to describe a 1024-bit unsigned integer.</p>
<p><em>Create a new datatype</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> new_type = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a> (<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#gab0f4dccfc2fb47bf2c7e06c9bf84c1f7">H5Tset_precision</a>(new_type, 1024);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#ga3ac9a4781cd3c4a8b5df4ff549ec8aec">H5Tset_sign</a>(new_type, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71aca59fce1697506dd3cbc7955eca77a12">H5T_SGN_NONE</a>);</div>
<div class="ttc" id="agroup___a_t_o_m_html_ga3ac9a4781cd3c4a8b5df4ff549ec8aec"><div class="ttname"><a href="group___a_t_o_m.html#ga3ac9a4781cd3c4a8b5df4ff549ec8aec">H5Tset_sign</a></div><div class="ttdeci">herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign)</div><div class="ttdoc">Sets the sign property for an integer type.</div></div>
<div class="ttc" id="agroup___a_t_o_m_html_gab0f4dccfc2fb47bf2c7e06c9bf84c1f7"><div class="ttname"><a href="group___a_t_o_m.html#gab0f4dccfc2fb47bf2c7e06c9bf84c1f7">H5Tset_precision</a></div><div class="ttdeci">herr_t H5Tset_precision(hid_t type_id, size_t prec)</div><div class="ttdoc">Sets the precision of an atomic datatype.</div></div>
</div><!-- fragment --><p>Composite datatypes are created with a specific API call for each datatype class. The table below shows the creation method for each datatype class. A newly created datatype cannot be used until the datatype properties are set. For example, a newly created compound datatype has no members and cannot be used.</p>
<table class="doxtable">
<caption align="top">Table 14. Functions to create each datatype class</caption>
<tr>
<th>Datatype Class  </th><th>Function to Create   </th></tr>
<tr>
<td>COMPOUND  </td><td><a class="el" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65" title="Creates a new datatype.">H5Tcreate</a>   </td></tr>
<tr>
<td>OPAQUE  </td><td><a class="el" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65" title="Creates a new datatype.">H5Tcreate</a>   </td></tr>
<tr>
<td>ENUM  </td><td><a class="el" href="group___e_n_u_m.html#gafd8d8cfead535791b3f753d21e79991f" title="Creates a new enumeration datatype.">H5Tenum_create</a>   </td></tr>
<tr>
<td>ARRAY  </td><td><a class="el" href="group___a_r_r_a_y.html#ga39d41fdef06b3d7972ec2eab16ab5e96">H5Tarray_create</a>   </td></tr>
<tr>
<td>VL  </td><td><a class="el" href="group___v_l_e_n.html#ga6841355fa5b3c924876b121dedb8ed2f" title="Creates a new variable-length array datatype.">H5Tvlen_create</a>   </td></tr>
</table>
<p>Once the datatype is created and the datatype properties set, the datatype object can be used.</p>
<p>Predefined datatypes are defined by the library during initialization using the same mechanisms as described here. Each predefined datatype is locked (<a class="el" href="group___h5_t.html#ga523642dbf4c60a83127fff87664a965b">H5Tlock</a>), so that it cannot be changed or destroyed. User-defined datatypes may also be locked using <a class="el" href="group___h5_t.html#ga523642dbf4c60a83127fff87664a965b">H5Tlock</a>.</p>
<h4>User-defined Atomic Datatypes</h4>
<p>Table 15 summarizes the API methods that set properties of atomic types. Table 16 shows properties specific to numeric types, Table 17 shows properties specific to the string datatype class. Note that offset, pad, etc. do not apply to strings. Table 18 shows the specific property of the OPAQUE datatype class.</p>
<table class="doxtable">
<caption align="top">Table 15. API methods that set properties of atomic datatypes</caption>
<tr>
<th>Functions  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___h5_t.html#gae5f38bfd4a4c557496b3194b5180212c">H5Tset_size</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t size)  </td><td>Set the total size of the element in bytes. This includes padding which may appear on either side of the actual value. If this property is reset to a smaller value which would cause the significant part of the data to extend beyond the edge of the datatype, then the offset property is decremented a bit at a time. If the offset reaches zero and the significant part of the data still extends beyond the edge of the datatype then the precision property is decremented a bit at a time. Decreasing the size of a datatype may fail if the <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2e92f1a42a19de186a139ab8ff0745a9">H5T_FLOAT</a> bit fields would extend beyond the significant part of the type.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gab1aab76b1214a819281f2156c6d45d71">H5Tset_order</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, <a class="el" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0">H5T_order_t</a> order)  </td><td>Set the byte order to little-endian (<a class="el" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0ae5668f73f6c28feddb7af175ac53012d">H5T_ORDER_LE</a>) or big-endian (<a class="el" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0acb00548c30987f873e6836c16dbccec2">H5T_ORDER_BE</a>).   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gab0f4dccfc2fb47bf2c7e06c9bf84c1f7">H5Tset_precision</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t precision)  </td><td>Set the number of significant bits of a datatype. The offset property (defined below) identifies its location. The size property defined above represents the entire size (in bytes) of the datatype. If the precision is decreased then padding bits are inserted on the MSB side of the significant bits (this will fail for <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2e92f1a42a19de186a139ab8ff0745a9">H5T_FLOAT</a> types if it results in the sign,mantissa, or exponent bit field extending beyond the edge of the significant bit field). On the other hand, if the precision is increased so that it “hangs over” the edge of the total size then the offset property is decremented a bit at a time. If the offset reaches zero and the significant bits still hang over the edge, then the total size is increased a byte at a time.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gafd22e4b0aecbe6dad9a899c5bf567e2f">H5Tset_offset</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t offset)  </td><td>Set the bit location of the least significant bit of a bit field whose length is precision. The bits of the entire data are numbered beginning at zero at the least significant bit of the least significant byte (the byte at the lowest memory address for a little-endian type or the byte at the highest address for a big-endian type). The offset property defines the bit location of the least significant bit of a bit field whose length is precision. If the offset is increased so the significant bits “hang over” the edge of the datum, then the size property is automatically incremented.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#ga1089a9f454052d0038a06a432ce8e1e1">H5Tset_pad</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aa">H5T_pad_t</a> lsb, <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aa">H5T_pad_t</a> msb)  </td><td>Set the padding to zeros (<a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a>) or ones (<a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8">H5T_PAD_ONE</a>). Padding is the bits of a data element which are not significant as defined by the precision and offset properties. Padding in the low-numbered bits is lsb padding and padding in the high-numbered bits is msb padding.   </td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 16. API methods that set properties of numeric datatypes</caption>
<tr>
<th>Functions  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#ga3ac9a4781cd3c4a8b5df4ff549ec8aec">H5Tset_sign</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, <a class="el" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71">H5T_sign_t</a> sign)  </td><td>(INTEGER)Integer data can be signed two's complement (<a class="el" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71a1152d5238ff7af5c9d50edfea1ed1357">H5T_SGN_2</a>) or unsigned (<a class="el" href="_h5_tpublic_8h.html#af7bfee2db210a12b9290eba85d730a71aca59fce1697506dd3cbc7955eca77a12">H5T_SGN_NONE</a>).   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gafbdc98b45749e5cfbaf1a8689f3c403d">H5Tset_fields</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize)  </td><td>(FLOAT)Set the properties define the location (bit position of least significant bit of the field) and size (in bits) of each field. The sign bit is always of length one and none of the fields are allowed to overlap.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gad2c4a8f09672f4166f39efe83d44dba2">H5Tset_ebias</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t ebias)  </td><td>(FLOAT)The exponent is stored as a non-negative value which is ebias larger than the true exponent.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gaa415a17c98bf32c357f5a35ba657beab">H5Tset_norm</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, <a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80">H5T_norm_t</a> norm)  </td><td>(FLOAT)This property describes the normalization method of the mantissa. <ul>
<li>
<a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80a9dc5e01d17abf41c619e154150de8dde">H5T_NORM_MSBSET</a>: the mantissa is shifted left (if non-zero) until the first bit after theradix point is set and the exponent is adjusted accordingly. All bits of the mantissa after the radix point are stored.  </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80a5b649062dea480101917cc2d6b58f65d">H5T_NORM_IMPLIED</a>: the mantissa is shifted left (if non-zero) until the first bit after the radix point is set and the exponent is adjusted accordingly. The first bit after the radix point is not stored since it is always set.  </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a609b101af0343a4a76d8c3e182cdda80ab1a219215c45144cf317f2ea846a861c">H5T_NORM_NONE</a>: the fractional part of the mantissa is stored without normalizing it.</li>
</ul>
</td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#ga6dc8e6ba49a24f56f0912539cf9e0481">H5Tset_inpad</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, <a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aa">H5T_pad_t</a> inpad)  </td><td>(FLOAT) If any internal bits (that is, bits between the sign bit, the mantissa field, and the exponent field but within the precision field) are unused, then they will be filled according to the value of this property. The padding can be: <ul>
<li><a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaac2ca8836f78fc3e7f524098857c42e64">H5T_PAD_BACKGROUND</a> </li>
<li><a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a> </li>
<li><a class="el" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8">H5T_PAD_ONE</a>   </li>
</ul>
</td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 17. API methods that set properties of string datatypes</caption>
<tr>
<th>Functions  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___h5_t.html#gae5f38bfd4a4c557496b3194b5180212c">H5Tset_size</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t size)  </td><td>Set the length of the string, in bytes. The precision is automatically set to 8*size.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gab0f4dccfc2fb47bf2c7e06c9bf84c1f7">H5Tset_precision</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, size_t precision)  </td><td>The precision must be a multiple of 8.   </td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#ga4909c0c3d97c3d212fee032cc8dc031a">H5Tset_cset</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id, <a class="el" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71a">H5T_cset_t</a> cset)  </td><td>Two character sets are currently supported: <ul>
<li>ASCII (<a class="el" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa27383e03d1cad9b4c32d8611a145d663">H5T_CSET_ASCII</a>) </li>
<li>UTF-8 (<a class="el" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa41685667f69bf81eb7de5dd5f452e658">H5T_CSET_UTF8</a>).   </li>
</ul>
</td></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___a_t_o_m.html#gaec9ebf44e766cc5b932d0bf26dcf8700">H5Tset_strpad</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id, H5T_str_t strpad)  </td><td>The string datatype has a fixed length, but the string may be shorter than the length. This property defines the storage mechanism for the left over bytes. The method used to store character strings differs with the programming language: <ul>
<li>C usually null terminates strings </li>
<li>Fortran left-justifies and space-pads strings</li>
</ul>
Valid string padding values, as passed in the parameter strpad, are as follows: <ul>
<li><a class="el" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a23c685afc240bbac4da23b36d8fd7e13">H5T_STR_NULLTERM</a>: Null terminate (as C does) </li>
<li><a class="el" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a128d51156e51b7a2c9db0fe8787b4547">H5T_STR_NULLPAD</a>: Pad with zeros </li>
<li><a class="el" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a3f73f8dae99444798f5efd7d2d2a5e5c">H5T_STR_SPACEPAD</a>: Pad with spaces (as FORTRAN does)   </li>
</ul>
</td></tr>
</table>
<table class="doxtable">
<caption align="top">Table 18. API methods that set properties of opaque datatypes</caption>
<tr>
<th>Functions  </th><th>Description   </th></tr>
<tr>
<td><a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="el" href="group___o_p_a_q_u_e.html#ga3543ad909983a2a20e651d16502de43d">H5Tset_tag</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type_id, const char *tag)  </td><td>Tags the opaque datatype type_id with an ASCII identifier tag.   </td></tr>
</table>
<h4>Examples</h4>
<p>The example below shows how to create a 128-bit little-endian signed integer type. Increasing the precision of a type automatically increases the total size. Note that the proper procedure is to begin from a type of the intended datatype class which in this case is a NATIVE INT.</p>
<p><em>Create a new 128-bit little-endian signed integer datatype</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> new_type = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a> (<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#gab0f4dccfc2fb47bf2c7e06c9bf84c1f7">H5Tset_precision</a> (new_type, 128);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#gab1aab76b1214a819281f2156c6d45d71">H5Tset_order</a> (new_type, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a2a6a8eb856a0829fecaac60f803c9fd0ae5668f73f6c28feddb7af175ac53012d">H5T_ORDER_LE</a>);</div>
<div class="ttc" id="agroup___a_t_o_m_html_gab1aab76b1214a819281f2156c6d45d71"><div class="ttname"><a href="group___a_t_o_m.html#gab1aab76b1214a819281f2156c6d45d71">H5Tset_order</a></div><div class="ttdeci">herr_t H5Tset_order(hid_t type_id, H5T_order_t order)</div><div class="ttdoc">Sets the byte order of a datatype.</div></div>
</div><!-- fragment --><p>The figure below shows the storage layout as the type is defined. The <a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a> creates a datatype that is the same as <a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>. In this example, suppose this is a 32-bit big-endian number (Figure a). The precision is set to 128 bits, which automatically extends the size to 8 bytes (Figure b). Finally, the byte order is set to little-endian (Figure c).</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig6.gif" alt=""/>
<div class="caption">
The storage layout for a new 128-bit little-endian signed integer datatype</div></div>
   </td></tr>
</table>
<p>The significant bits of a data element can be offset from the beginning of the memory for that element by an amount of padding. The offset property specifies the number of bits of padding that appear to the “right of” the value. The table and figure below show how a 32-bit unsigned integer with 16-bits of precision having the value 0x1122 will be laid out in memory.</p>
<table class="doxtable">
<caption align="top">Table 19. Memory Layout for a 32-bit unsigned integer</caption>
<tr>
<th>Byte Position  </th><th>Big-Endian<br  />
Offset=0  </th><th>Big-Endian<br  />
Offset=16  </th><th>Little-Endian<br  />
Offset=0  </th><th>Little-Endian<br  />
Offset=16   </th></tr>
<tr>
<td>0:  </td><td>[pad]  </td><td>[0x11]  </td><td>[0x22]  </td><td>[pad]   </td></tr>
<tr>
<td>1:  </td><td>[pad]  </td><td>[0x22]  </td><td>[0x11]  </td><td>[pad]   </td></tr>
<tr>
<td>2:  </td><td>[0x11]  </td><td>[pad]  </td><td>[pad]  </td><td>[0x22]   </td></tr>
<tr>
<td>3:  </td><td>[0x22]  </td><td>[pad]  </td><td>[pad]  </td><td>[0x11]   </td></tr>
</table>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig7.gif" alt=""/>
<div class="caption">
Memory Layout for a 32-bit unsigned integer</div></div>
   </td></tr>
</table>
<p>If the offset is incremented then the total size is incremented also if necessary to prevent significant bits of the value from hanging over the edge of the datatype.</p>
<p>The bits of the entire data are numbered beginning at zero at the least significant bit of the least significant byte (the byte at the lowest memory address for a little-endian type or the byte at the highest address for a big-endian type). The offset property defines the bit location of the least significant bit of a bit field whose length is precision. If the offset is increased so the significant bits “hang over” the edge of the datum, then the size property is automatically incremented.</p>
<p>To illustrate the properties of the integer datatype class, the example below shows how to create a user-defined datatype that describes a 24-bit signed integer that starts on the third bit of a 32-bit word. The datatype is specialized from a 32-bit integer, the precision is set to 24 bits, and the offset is set to 3.</p>
<p><em>A user-defined datatype with a 24-bit signed integer</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dt;</div>
<div class="line"> </div>
<div class="line">dt = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>(H5T_SDT_I32LE);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#gab0f4dccfc2fb47bf2c7e06c9bf84c1f7">H5Tset_precision</a>(dt, 24);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#gafd22e4b0aecbe6dad9a899c5bf567e2f">H5Tset_offset</a>(dt,3);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#ga1089a9f454052d0038a06a432ce8e1e1">H5Tset_pad</a>(dt, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a>, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8">H5T_PAD_ONE</a>);</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8"><div class="ttname"><a href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8">H5T_PAD_ONE</a></div><div class="ttdeci">@ H5T_PAD_ONE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:146</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823"><div class="ttname"><a href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a></div><div class="ttdeci">@ H5T_PAD_ZERO</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:145</div></div>
<div class="ttc" id="agroup___a_t_o_m_html_ga1089a9f454052d0038a06a432ce8e1e1"><div class="ttname"><a href="group___a_t_o_m.html#ga1089a9f454052d0038a06a432ce8e1e1">H5Tset_pad</a></div><div class="ttdeci">herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)</div><div class="ttdoc">Sets the least and most-significant bits padding types.</div></div>
<div class="ttc" id="agroup___a_t_o_m_html_gafd22e4b0aecbe6dad9a899c5bf567e2f"><div class="ttname"><a href="group___a_t_o_m.html#gafd22e4b0aecbe6dad9a899c5bf567e2f">H5Tset_offset</a></div><div class="ttdeci">herr_t H5Tset_offset(hid_t type_id, size_t offset)</div><div class="ttdoc">Sets the bit offset of the first significant bit.</div></div>
</div><!-- fragment --><p>The figure below shows the storage layout for a data element. Note that the unused bits in the offset will be set to zero and the unused bits at the end will be set to one, as specified in the <a class="el" href="group___a_t_o_m.html#ga1089a9f454052d0038a06a432ce8e1e1">H5Tset_pad</a> call. </p><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig8.gif" alt=""/>
<div class="caption">
A user-defined integer datatype with a range of -1,048,583 to 1,048,584</div></div>
   </td></tr>
</table>
<p>To illustrate a user-defined floating point number, the example below shows how to create a 24-bit floating point number that starts 5 bits into a 4 byte word. The floating point number is defined to have a mantissa of 19 bits (bits 5-23), an exponent of 3 bits (25-27), and the sign bit is bit 28. (Note that this is an illustration of what can be done and is not necessarily a floating point format that a user would require.)</p>
<p><em>A user-defined datatype with a 24-bit floating point datatype</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dt;</div>
<div class="line"> </div>
<div class="line">dt = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>(H5T_SDT_F32LE);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#gab0f4dccfc2fb47bf2c7e06c9bf84c1f7">H5Tset_precision</a>(dt, 24);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#gafbdc98b45749e5cfbaf1a8689f3c403d">H5Tset_fields</a> (dt, 28, 25, 3, 5, 19);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#ga1089a9f454052d0038a06a432ce8e1e1">H5Tset_pad</a>(dt, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a>, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaa2020ae42345fc8236811593c59ac4fe8">H5T_PAD_ONE</a>);</div>
<div class="line"><a class="code hl_function" href="group___a_t_o_m.html#ga6dc8e6ba49a24f56f0912539cf9e0481">H5Tset_inpad</a>(dt, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a361ad902a75bcf442c17bf3d0bc103aaaed1384c65a60f4d623fe6bc852b72823">H5T_PAD_ZERO</a>);</div>
<div class="ttc" id="agroup___a_t_o_m_html_ga6dc8e6ba49a24f56f0912539cf9e0481"><div class="ttname"><a href="group___a_t_o_m.html#ga6dc8e6ba49a24f56f0912539cf9e0481">H5Tset_inpad</a></div><div class="ttdeci">herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad)</div><div class="ttdoc">Fills unused internal floating-point bits.</div></div>
<div class="ttc" id="agroup___a_t_o_m_html_gafbdc98b45749e5cfbaf1a8689f3c403d"><div class="ttname"><a href="group___a_t_o_m.html#gafbdc98b45749e5cfbaf1a8689f3c403d">H5Tset_fields</a></div><div class="ttdeci">herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize)</div><div class="ttdoc">Sets locations and sizes of floating point bit fields.</div></div>
</div><!-- fragment --><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig9.gif" alt=""/>
<div class="caption">
A user-defined floating point datatype</div></div>
   </td></tr>
</table>
<p>The figure above shows the storage layout of a data element for this datatype. Note that there is an unused bit (24) between the mantissa and the exponent. This bit is filled with the inpad value which in this case is 0.</p>
<p>The sign bit is always of length one and none of the fields are allowed to overlap. When expanding a floating-point type one should set the precision first; when decreasing the size one should set the field positions and sizes first.</p>
<h4>Composite Datatypes</h4>
<p>All composite datatypes must be user-defined; there are no predefined composite datatypes.</p>
<h4>Compound Datatypes</h4>
<p>The subsections below describe how to create a compound datatype and how to write and read data of a compound datatype.</p>
<h4>Defining Compound Datatypes</h4>
<p>Compound datatypes are conceptually similar to a C struct or Fortran derived types. The compound datatype defines a contiguous sequence of bytes, which are formatted using one up to 2^16 datatypes (members). A compound datatype may have any number of members, in any order, and the members may have any datatype, including compound. Thus, complex nested compound datatypes can be created. The total size of the compound datatype is greater than or equal to the sum of the size of its members, up to a maximum of 2^32 bytes. HDF5 does not support datatypes with distinguished records or the equivalent of C unions or Fortran EQUIVALENCE statements.</p>
<p>Usually a C struct or Fortran derived type will be defined to hold a data point in memory, and the offsets of the members in memory will be the offsets of the struct members from the beginning of an instance of the struct. The HDF5 C library provides a macro <a class="el" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a> (s,m)to calculate the member's offset. The HDF5 Fortran applications have to calculate offsets by using sizes of members datatypes and by taking in consideration the order of members in the Fortran derived type. </p><div class="fragment"><div class="line"><a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s,m)</div>
<div class="ttc" id="a_h5_tpublic_8h_html_af5242159129a7f37ab85d33d85a1ccac"><div class="ttname"><a href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a></div><div class="ttdeci">#define HOFFSET(S, M)</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:22</div></div>
</div><!-- fragment --><p> This macro computes the offset of member m within a struct s </p><div class="fragment"><div class="line">offsetof(s,m)</div>
</div><!-- fragment --><p> This macro defined in stddef.h does exactly the same thing as the <a class="el" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET()</a>macro.</p>
<p>Note for Fortran users: Offsets of Fortran structure members correspond to the offsets within a packed datatype (see explanation below) stored in an HDF5 file.</p>
<p>Each member of a compound datatype must have a descriptive name which is the key used to uniquely identify the member within the compound datatype. A member name in an HDF5 datatype does not necessarily have to be the same as the name of the member in the C struct or Fortran derived type, although this is often the case. Nor does one need to define all members of the C struct or Fortran derived type in the HDF5 compound datatype (or vice versa).</p>
<p>Unlike atomic datatypes which are derived from other atomic datatypes, compound datatypes are created from scratch. First, one creates an empty compound datatype and specifies its total size. Then members are added to the compound datatype in any order. Each member type is inserted at a designated offset. Each member has a name which is the key used to uniquely identify the member within the compound datatype.</p>
<p>The example below shows a way of creating an HDF5 C compound datatype to describe a complex number. This is a structure with two components, “real” and “imaginary”, and each component is a double. An equivalent C struct whose type is defined by the complex_tstruct is shown.</p>
<p><em>A compound datatype for complex numbers in C</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line">  <span class="keywordtype">double</span> re; <span class="comment">//real part</span></div>
<div class="line">  <span class="keywordtype">double</span> im; <span class="comment">//imaginary part</span></div>
<div class="line">} complex_t;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> complex_id = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span> (complex_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (complex_id, “real”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(complex_t,re),</div>
<div class="line"><a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (complex_id, “imaginary”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(complex_t,im),</div>
<div class="line"><a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a></div><div class="ttdeci">@ H5T_COMPOUND</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:38</div></div>
<div class="ttc" id="agroup___c_o_m_p_o_u_n_d_html_ga487d8f64a76f48b6eeb7f402d3b8b081"><div class="ttname"><a href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a></div><div class="ttdeci">herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id)</div><div class="ttdoc">Adds a new member to a compound datatype.</div></div>
<div class="ttc" id="agroup___h5_t_html_gaa9afc38e1a7d35e4d0bec24c569b3c65"><div class="ttname"><a href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a></div><div class="ttdeci">hid_t H5Tcreate(H5T_class_t type, size_t size)</div><div class="ttdoc">Creates a new datatype.</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga087f3b793a299e416bd68678c2ef7c09"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a></div><div class="ttdeci">#define H5T_NATIVE_DOUBLE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:802</div></div>
</div><!-- fragment --><p>The example below shows a way of creating an HDF5 Fortran compound datatype to describe a complex number. This is a Fortran derived type with two components, “real” and “imaginary”, and each component is DOUBLE PRECISION. An equivalent Fortran TYPE whose type is defined by the TYPE complex_t is shown.</p>
<p><em>A compound datatype for complex numbers in Fortran</em> </p><div class="fragment"><div class="line">TYPE complex_t</div>
<div class="line">    DOUBLE PRECISION re ! real part</div>
<div class="line">    DOUBLE PRECISION im; ! imaginary part</div>
<div class="line">END TYPE complex_t</div>
<div class="line"> </div>
<div class="line">CALL h5tget_size_f(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>, re_size, error)</div>
<div class="line">CALL h5tget_size_f(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>, im_size, error)</div>
<div class="line">complex_t_size = re_size + im_size</div>
<div class="line">CALL h5tcreate_f(H5T_COMPOUND_F, complex_t_size, type_id)</div>
<div class="line">offset = 0</div>
<div class="line">CALL h5tinsert_f(type_id, “real”, offset, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>, error)</div>
<div class="line">offset = offset + re_size</div>
<div class="line">CALL h5tinsert_f(type_id, “imaginary”, offset, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>, error)</div>
</div><!-- fragment --><p>Important Note: The compound datatype is created with a size sufficient to hold all its members. In the C example above, the size of the C struct and the <a class="el" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a> macro are used as a convenient mechanism to determine the appropriate size and offset. Alternatively, the size and offset could be manually determined: the size can be set to 16 with “real” at offset 0 and “imaginary” at offset 8. However, different platforms and compilers have different sizes for “double” and may have alignment restrictions which require additional padding within the structure. It is much more portable to use the <a class="el" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a> macro which assures that the values will be correct for any platform.</p>
<p>The figure below shows how the compound datatype would be laid out assuming that NATIVE_DOUBLE are 64-bit numbers and that there are no alignment requirements. The total size of the compound datatype will be 16 bytes, the “real” component will start at byte 0, and “imaginary” will start at byte 8.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig10.gif" alt=""/>
<div class="caption">
Layout of a compound datatype</div></div>
   </td></tr>
</table>
<p>The members of a compound datatype may be any HDF5 datatype including the compound, array, and variable-length (VL) types. The figure and example below show the memory layout and code which creates a compound datatype composed of two complex values, and each complex value is also a compound datatype as in the figure above.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig11.gif" alt=""/>
<div class="caption">
Layout of a compound datatype nested in a compound datatype</div></div>
   </td></tr>
</table>
<p><em>Code for a compound datatype nested in a compound datatype</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line">  complex_t x;</div>
<div class="line">  complex_t y;</div>
<div class="line">} surf_t;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> complex_id, surf_id; <span class="comment">// hdf5 datatypes</span></div>
<div class="line"> </div>
<div class="line">complex_id = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(complex_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (complex_id, “re”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(complex_t, re), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (complex_id, “im”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(complex_t, im), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"> </div>
<div class="line">surf_id = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(surf_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (surf_id, “x”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(surf_t, x), complex_id);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (surf_id, “y”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(surf_t, y), complex_id);</div>
</div><!-- fragment --><p>Note that a similar result could be accomplished by creating a compound datatype and inserting four fields. See the figure below. This results in the same layout as the figure above. The difference would be how the fields are addressed. In the first case, the real part of ‘y’ is called ‘y.re’; in the second case it is ‘y-re’.</p>
<p><em>Another compound datatype nested in a compound datatype</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line">  complex_t x;</div>
<div class="line">  complex_t y;</div>
<div class="line">} surf_t;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> surf_id = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(surf_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (surf_id, “x-re”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(surf_t, x.re), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (surf_id, “x-im”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(surf_t, x.im), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (surf_id, “y-re”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(surf_t, y.re), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (surf_id, “y-im”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(surf_t, y.im), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
</div><!-- fragment --><p>The members of a compound datatype do not always fill all the bytes. The <a class="el" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a> macro assures that the members will be laid out according to the requirements of the platform and language. The example below shows an example of a C struct which requires extra bytes of padding on many platforms. The second element, ‘b’, is a 1-byte character followed by an 8 byte double, ‘c’. On many systems, the 8-byte value must be stored on a 4-or 8-byte boundary. This requires the struct to be larger than the sum of the size of its elements.</p>
<p>In the example below, sizeof and <a class="el" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a> are used to assure that the members are inserted at the correct offset to match the memory conventions of the platform. The figure below shows how this data element would be stored in memory, assuming the double must start on a 4-byte boundary. Notice the extra bytes between ‘b’ and ‘c’.</p>
<p><em>A compound datatype that requires padding</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line">  <span class="keywordtype">int</span>    a;</div>
<div class="line">  <span class="keywordtype">char</span>   b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} s1_t;</div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> s1_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(s1_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (s1_tid, “x-im”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, a), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (s1_tid, “y-re”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a> (s1_tid, “y-im”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, c), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga7439560bc4ef6d995a4e35b30262e660"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a></div><div class="ttdeci">#define H5T_NATIVE_CHAR</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:742</div></div>
</div><!-- fragment --><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig12.gif" alt=""/>
<div class="caption">
Memory layout of a compound datatype that requires padding</div></div>
   </td></tr>
</table>
<p>However, data stored on disk does not require alignment, so unaligned versions of compound data structures can be created to improve space efficiency on disk. These unaligned compound datatypes can be created by computing offsets by hand to eliminate inter-member padding, or the members can be packed by calling <a class="el" href="group___c_o_m_p_o_u_n_d.html#ga1a28ac30f83a4920aba49bb1b0a6a0f3" title="Recursively removes padding from within a compound datatype.">H5Tpack</a> (which modifies a datatype directly, so it is usually preceded by a call to <a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e" title="Copies an existing datatype.">H5Tcopy</a>).</p>
<p>The example below shows how to create a disk version of the compound datatype from the figure above in order to store data on disk in as compact a form as possible. Packed compound datatypes should generally not be used to describe memory as they may violate alignment constraints for the architecture being used. Note also that using a packed datatype for disk storage may involve a higher data conversion cost.</p>
<p><em>Create a packed compound datatype in C</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> s2_tid = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a> (s1_tid);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga1a28ac30f83a4920aba49bb1b0a6a0f3">H5Tpack</a> (s2_tid);</div>
<div class="ttc" id="agroup___c_o_m_p_o_u_n_d_html_ga1a28ac30f83a4920aba49bb1b0a6a0f3"><div class="ttname"><a href="group___c_o_m_p_o_u_n_d.html#ga1a28ac30f83a4920aba49bb1b0a6a0f3">H5Tpack</a></div><div class="ttdeci">herr_t H5Tpack(hid_t type_id)</div><div class="ttdoc">Recursively removes padding from within a compound datatype.</div></div>
</div><!-- fragment --><p>The example below shows the sequence of Fortran calls to create a packed compound datatype. An HDF5 Fortran compound datatype never describes a compound datatype in memory and compound data is ALWAYS written by fields as described in the next section. Therefore packing is not needed unless the offset of each consecutive member is not equal to the sum of the sizes of the previous members.</p>
<p><em>Create a packed compound datatype in Fortran</em> </p><div class="fragment"><div class="line">CALL h5tcopy_f(s1_id, s2_id, error)</div>
<div class="line">CALL h5tpack_f(s2_id, error)</div>
</div><!-- fragment --><h4>Creating and Writing Datasets with Compound Datatypes</h4>
<p>Creating datasets with compound datatypes is similar to creating datasets with any other HDF5 datatypes. But writing and reading may be different since datasets that have compound datatypes can be written or read by a field (member) or subsets of fields (members). The compound datatype is the only composite datatype that supports “sub-setting” by the elements the datatype is built from.</p>
<p>The example below shows a C example of creating and writing a dataset with a compound datatype.</p>
<p><em>Create and write a dataset with a compound datatype in C</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>s1_t {</div>
<div class="line">  <span class="keywordtype">int</span> a;</div>
<div class="line">  <span class="keywordtype">float</span> b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} s1_t;</div>
<div class="line"> </div>
<div class="line">s1_t data[LENGTH];</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Initialize data</span></div>
<div class="line"><span class="keywordflow">for</span> (i = 0; i &lt; LENGTH; i++) {</div>
<div class="line">  data[i].a = i;</div>
<div class="line">  data[i].b = i*i;</div>
<div class="line">  data[i].c = 1./(i+1);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">s1_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(s1_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “a_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, a), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “b_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “c_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, c), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">dataset_id = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file_id, “SDScompound.h5”, s1_t,</div>
<div class="line">space_id, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"><a class="code hl_function" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a> (dataset_id, s1_tid, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data);</div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_gae2523b63144b498f555fa4d04f59ee1c"><div class="ttname"><a href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a></div><div class="ttdeci">#define H5T_NATIVE_FLOAT</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:797</div></div>
</div><!-- fragment --><p>The example below shows the content of the file written on a little-endian machine. <em>Create and write a little-endian dataset with a compound datatype in C</em> </p><div class="fragment"><div class="line">HDF5 “SDScompound.h5” {</div>
<div class="line">GROUP “/” {</div>
<div class="line">   DATASET “ArrayOfStructures” {</div>
<div class="line">      DATATYPE <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> {</div>
<div class="line">         <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a> “a_name”;</div>
<div class="line">         <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga994ce9ffdd2c77a9352b102a883503ea">H5T_IEEE_F32LE</a> “b_name”;</div>
<div class="line">         <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga3f9c2185ec16632fab8c20ec7a63178e">H5T_IEEE_F64LE</a> “c_name”;</div>
<div class="line">      }</div>
<div class="line">      DATASPACE SIMPLE { ( 3 ) / ( 3 ) }</div>
<div class="line">      DATA {</div>
<div class="line">      (0): {</div>
<div class="line">               0,</div>
<div class="line">               0,</div>
<div class="line">               1</div>
<div class="line">            },</div>
<div class="line">      (1): {</div>
<div class="line">               0,</div>
<div class="line">               1,</div>
<div class="line">               0.5</div>
<div class="line">            },</div>
<div class="line">      (2): {</div>
<div class="line">               0,</div>
<div class="line">               4,</div>
<div class="line">               0.333333</div>
<div class="line">            }</div>
<div class="line">         }</div>
<div class="line">      }</div>
<div class="line">}</div>
<div class="line">}</div>
<div class="ttc" id="agroup___p_d_t_i_e_e_e_html_ga3f9c2185ec16632fab8c20ec7a63178e"><div class="ttname"><a href="group___p_d_t_i_e_e_e.html#ga3f9c2185ec16632fab8c20ec7a63178e">H5T_IEEE_F64LE</a></div><div class="ttdeci">#define H5T_IEEE_F64LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:271</div></div>
<div class="ttc" id="agroup___p_d_t_i_e_e_e_html_ga994ce9ffdd2c77a9352b102a883503ea"><div class="ttname"><a href="group___p_d_t_i_e_e_e.html#ga994ce9ffdd2c77a9352b102a883503ea">H5T_IEEE_F32LE</a></div><div class="ttdeci">#define H5T_IEEE_F32LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:261</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga8db8c9c2bcc457f9f8526c8fcb81218b"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a></div><div class="ttdeci">#define H5T_STD_I32LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:310</div></div>
</div><!-- fragment --><p>It is not necessary to write the whole data at once. Datasets with compound datatypes can be written by field or by subsets of fields. In order to do this one has to remember to set the transfer property of the dataset using the H5Pset_preserve call and to define the memory datatype that corresponds to a field. The example below shows how float and double fields are written to the dataset.</p>
<p><em>Writing floats and doubles to a dataset</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>sb_t {</div>
<div class="line">  <span class="keywordtype">float</span> b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} sb_t;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>sc_t {</div>
<div class="line">  <span class="keywordtype">float</span> b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} sc_t;</div>
<div class="line">sb_t data1[LENGTH];</div>
<div class="line">sc_t data2[LENGTH];</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Initialize data</span></div>
<div class="line"><span class="keywordflow">for</span> (i = 0; i &lt; LENGTH; i++) {</div>
<div class="line">  data1.b = i * i;</div>
<div class="line">  data2.c = 1./(i + 1);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create dataset as in example 15</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create memory datatypes corresponding to float</span></div>
<div class="line"><span class="comment">// and double datatype fields</span></div>
<div class="line"> </div>
<div class="line">sb_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(sb_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(sb_tid, “b_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(sb_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>);</div>
<div class="line">sc_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(sc_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(sc_tid, “c_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(sc_t, c), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Set transfer property</span></div>
<div class="line">xfer_id = <a class="code hl_function" href="group___p_l_c_r.html#gaf1b11da01d4d45d788c45f8bc5f0cbfa">H5Pcreate</a>(<a class="code hl_define" href="_h5_ppublic_8h.html#a6f9c8a5aba72c0445fff384bf418a80d">H5P_DATASET_XFER</a>);</div>
<div class="line"><a class="code hl_function" href="group___d_x_p_l.html#gae8b87209ba6a3943eb614b6dfe55e588">H5Pset_preserve</a>(xfer_id, 1);</div>
<div class="line"><a class="code hl_function" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a> (dataset_id, sb_tid, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, xfer_id, data1);</div>
<div class="line"><a class="code hl_function" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a> (dataset_id, sc_tid, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, xfer_id, data2);</div>
<div class="ttc" id="a_h5_ppublic_8h_html_a6f9c8a5aba72c0445fff384bf418a80d"><div class="ttname"><a href="_h5_ppublic_8h.html#a6f9c8a5aba72c0445fff384bf418a80d">H5P_DATASET_XFER</a></div><div class="ttdeci">#define H5P_DATASET_XFER</div><div class="ttdef"><b>Definition</b> H5Ppublic.h:55</div></div>
<div class="ttc" id="agroup___d_x_p_l_html_gae8b87209ba6a3943eb614b6dfe55e588"><div class="ttname"><a href="group___d_x_p_l.html#gae8b87209ba6a3943eb614b6dfe55e588">H5Pset_preserve</a></div><div class="ttdeci">herr_t H5Pset_preserve(hid_t plist_id, hbool_t status)</div><div class="ttdoc">Sets the dataset transfer property list status.</div></div>
<div class="ttc" id="agroup___p_l_c_r_html_gaf1b11da01d4d45d788c45f8bc5f0cbfa"><div class="ttname"><a href="group___p_l_c_r.html#gaf1b11da01d4d45d788c45f8bc5f0cbfa">H5Pcreate</a></div><div class="ttdeci">hid_t H5Pcreate(hid_t cls_id)</div><div class="ttdoc">Creates a new property list as an instance of a property list class.</div></div>
</div><!-- fragment --><p>The figure below shows the content of the file written on a little-endian machine. Only float and double fields are written. The default fill value is used to initialize the unwritten integer field. <em>Writing floats and doubles to a dataset on a little-endian system</em> </p><div class="fragment"><div class="line">HDF5 “SDScompound.h5” {</div>
<div class="line">GROUP “/” {</div>
<div class="line">   DATASET “ArrayOfStructures” {</div>
<div class="line">      DATATYPE <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> {</div>
<div class="line">         <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a> “a_name”;</div>
<div class="line">         <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga994ce9ffdd2c77a9352b102a883503ea">H5T_IEEE_F32LE</a> “b_name”;</div>
<div class="line">         <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga3f9c2185ec16632fab8c20ec7a63178e">H5T_IEEE_F64LE</a> “c_name”;</div>
<div class="line">      }</div>
<div class="line">      DATASPACE SIMPLE { ( 3 ) / ( 3 ) }</div>
<div class="line">      DATA {</div>
<div class="line">      (0): {</div>
<div class="line">               0,</div>
<div class="line">               0,</div>
<div class="line">               1</div>
<div class="line">            },</div>
<div class="line">      (1): {</div>
<div class="line">               0,</div>
<div class="line">               1,</div>
<div class="line">               0.5</div>
<div class="line">            },</div>
<div class="line">      (2): {</div>
<div class="line">               0,</div>
<div class="line">               4,</div>
<div class="line">               0.333333</div>
<div class="line">            }</div>
<div class="line">         }</div>
<div class="line">      }</div>
<div class="line">}</div>
<div class="line">}</div>
</div><!-- fragment --><p>The example below contains a Fortran example that creates and writes a dataset with a compound datatype. As this example illustrates, writing and reading compound datatypes in Fortran is always done by fields. The content of the written file is the same as shown in the example above. <em>Create and write a dataset with a compound datatype in Fortran</em> </p><div class="fragment"><div class="line">! One cannot write an array of a derived datatype in</div>
<div class="line">! Fortran.</div>
<div class="line">TYPE s1_t</div>
<div class="line">  INTEGER a</div>
<div class="line">  REAL b</div>
<div class="line">  DOUBLE PRECISION c</div>
<div class="line">END TYPE s1_t</div>
<div class="line">TYPE(s1_t) d(LENGTH)</div>
<div class="line">! Therefore, the following code initializes an array</div>
<div class="line">! corresponding to each field in the derived datatype</div>
<div class="line">! and writesthose arrays to the dataset</div>
<div class="line"> </div>
<div class="line">INTEGER, DIMENSION(LENGTH) :: a</div>
<div class="line">REAL, DIMENSION(LENGTH) :: b</div>
<div class="line">DOUBLE PRECISION, DIMENSION(LENGTH) :: c</div>
<div class="line"> </div>
<div class="line">! Initialize data</div>
<div class="line">  do i = 1, LENGTH</div>
<div class="line">    a(i) = i-1</div>
<div class="line">    b(i) = (i-1) * (i-1)</div>
<div class="line">    c(i) = 1./i</div>
<div class="line">  enddo</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">! Set dataset transfer property to preserve partially</div>
<div class="line">! initialized fields during write/read to/from dataset</div>
<div class="line">! with compound datatype.</div>
<div class="line">!</div>
<div class="line">CALL h5pcreate_f(H5P_DATASET_XFER_F, plist_id, error)</div>
<div class="line">CALL h5pset_preserve_f(plist_id, .TRUE., error)</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Create compound datatype.</div>
<div class="line">!</div>
<div class="line">! First calculate total size by calculating sizes of</div>
<div class="line">! each member</div>
<div class="line">!</div>
<div class="line">CALL h5tget_size_f(H5T_NATIVE_INTEGER, type_sizei, error)</div>
<div class="line">CALL h5tget_size_f(H5T_NATIVE_REAL, type_sizer, error)</div>
<div class="line">CALL h5tget_size_f(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>, type_sized, error)</div>
<div class="line">type_size = type_sizei + type_sizer + type_sized</div>
<div class="line">CALL h5tcreate_f(H5T_COMPOUND_F, type_size, dtype_id, error)</div>
<div class="line">!</div>
<div class="line">! Insert members</div>
<div class="line">!</div>
<div class="line">!</div>
<div class="line">! INTEGER member</div>
<div class="line">!</div>
<div class="line">offset = 0</div>
<div class="line">CALL h5tinsert_f(dtype_id, “a_name”, offset, H5T_NATIVE_INTEGER, error)</div>
<div class="line">!</div>
<div class="line">! REAL member</div>
<div class="line">!</div>
<div class="line">offset = offset + type_sizei</div>
<div class="line">CALL h5tinsert_f(dtype_id, “b_name”, offset, H5T_NATIVE_REAL, error)</div>
<div class="line">!</div>
<div class="line">! DOUBLE PRECISION member</div>
<div class="line">!</div>
<div class="line">offset = offset + type_sizer</div>
<div class="line">CALL h5tinsert_f(dtype_id, “c_name”, offset, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>, error)</div>
<div class="line">!</div>
<div class="line">! Create the dataset with compound datatype.</div>
<div class="line">!</div>
<div class="line">CALL h5dcreate_f(file_id, dsetname, dtype_id, dspace_id, &amp;dset_id, error, H5P_DEFAULT_F,</div>
<div class="line">H5P_DEFAULT_F, H5P_DEFAULT_F)</div>
<div class="line">!</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">! Create memory types. We have to create a compound</div>
<div class="line">! datatype for each member we want to write.</div>
<div class="line">!</div>
<div class="line">CALL h5tcreate_f(H5T_COMPOUND_F, type_sizei, dt1_id, error)</div>
<div class="line">offset = 0</div>
<div class="line">CALL h5tinsert_f(dt1_id, “a_name”, offset, H5T_NATIVE_INTEGER, error)</div>
<div class="line">!</div>
<div class="line">CALL h5tcreate_f(H5T_COMPOUND_F, type_sizer, dt2_id, error)</div>
<div class="line">offset = 0</div>
<div class="line">CALL h5tinsert_f(dt2_id, “b_name”, offset, H5T_NATIVE_REAL, error)</div>
<div class="line">!</div>
<div class="line">CALL h5tcreate_f(H5T_COMPOUND_F, type_sized, dt3_id, error)</div>
<div class="line">offset = 0</div>
<div class="line">CALL h5tinsert_f(dt3_id, “c_name”, offset, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>, error)</div>
<div class="line">!</div>
<div class="line">! Write data by fields in the datatype. Fields order</div>
<div class="line">! is not important.</div>
<div class="line">!</div>
<div class="line">CALL h5dwrite_f(dset_id, dt3_id, c, data_dims, error, xfer_prp = plist_id)</div>
<div class="line">CALL h5dwrite_f(dset_id, dt2_id, b, data_dims, error, xfer_prp = plist_id)</div>
<div class="line">CALL h5dwrite_f(dset_id, dt1_id, a, data_dims, error, xfer_prp = plist_id)</div>
</div><!-- fragment --><h4>Reading Datasets with Compound Datatypes</h4>
<p>Reading datasets with compound datatypes may be a challenge. For general applications there is no way to know a priori the corresponding C structure. Also, C structures cannot be allocated on the fly during discovery of the dataset's datatype. For general C, C++, Fortran and Java application the following steps will be required to read and to interpret data from the dataset with compound datatype: </p><ul>
<li>1. Get the identifier of the compound datatype in the file with the <a class="el" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb" title="Returns an identifier for a copy of the datatype for a dataset.">H5Dget_type</a> call </li>
<li>2. Find the number of the compound datatype members with the <a class="el" href="group___c_o_m_p_e_n_u_m.html#ga21bdfc706f71ebe298a433e74b5bc626" title="Retrieves the number of elements in a compound or enumeration datatype.">H5Tget_nmembers</a> call </li>
<li>3. Iterate through compound datatype members <ul>
<li>
Get member class with the <a class="el" href="group___c_o_m_p_o_u_n_d.html#gac8476d164fb972fbf7b8c4584b8e916b" title="Returns datatype class of compound datatype member.">H5Tget_member_class</a> call </li>
<li>
Get member name with the <a class="el" href="group___c_o_m_p_e_n_u_m.html#ga64d1d807464d2011192f28115580fb66" title="Retrieves the name of a compound or enumeration datatype member.">H5Tget_member_name</a> call </li>
<li>
Check class type against predefined classes <ul>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aba1fc36abc23f073912e337d2291b037">H5T_INTEGER</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2e92f1a42a19de186a139ab8ff0745a9">H5T_FLOAT</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2de5d7919fe54466b7cf6a6c0b4265fa">H5T_STRING</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aae32f37ec15a835aa08d9277ad7ffaa2">H5T_BITFIELD</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aaf11325a64ed5369e88d8d0d600b5cce">H5T_OPAQUE</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5850e0b9353a5e7aeb615fb943d4e9cd">H5T_REFERENCE</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5ee305303f12787367ac271d8f28f2e6">H5T_ENUM</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2ad8ff83b6b7ca22575263561221193028">H5T_VLEN</a> </li>
<li>
<a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a></li>
</ul>
</li>
<li>
If class is <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, then go to step 2 and repeat all steps under step 3. If class is not <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, then a member is of an atomic class and can be read to a corresponding buffer after discovering all necessary information specific to each atomic type (for example, size of the integer or floats, super class for enumerated and array datatype, and its sizes)</li>
</ul>
</li>
</ul>
<p>The examples below show how to read a dataset with a known compound datatype.</p>
<p>The first example below shows the steps needed to read data of a known structure. First, build a memory datatype the same way it was built when the dataset was created, and then second use the datatype in an <a class="el" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c" title="Reads raw data from a dataset into a provided buffer.">H5Dread</a> call.</p>
<p><em>Read a dataset using a memory datatype</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>s1_t {</div>
<div class="line">  <span class="keywordtype">int</span> a;</div>
<div class="line">  <span class="keywordtype">float</span> b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} s1_t;</div>
<div class="line"> </div>
<div class="line">s1_t *data;</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">s1_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a>(<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(s1_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “a_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, a), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “b_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “c_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, c), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">dataset_id = <a class="code hl_define" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a>(file_id, “SDScompound.h5”, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">data = (s1_t *) malloc (<span class="keyword">sizeof</span>(s1_t)*LENGTH);</div>
<div class="line"><a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset_id, s1_tid, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data);</div>
<div class="ttc" id="a_h5version_8h_html_a7dba2e5b2045f31c0932123ffb54f7a3"><div class="ttname"><a href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a></div><div class="ttdeci">#define H5Dopen</div><div class="ttdef"><b>Definition</b> H5version.h:903</div></div>
</div><!-- fragment --><p>Instead of building a memory datatype, the application could use the <a class="el" href="group___h5_t.html#ga05b99133058637e8daa5d745381ddd3d" title="Returns the native datatype identifier of a specified datatype.">H5Tget_native_type</a> function. See the example below.</p>
<p><em>Read a dataset using H5Tget_native_type</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>s1_t {</div>
<div class="line">  <span class="keywordtype">int</span> a;</div>
<div class="line">  <span class="keywordtype">float</span> b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} s1_t;</div>
<div class="line"> </div>
<div class="line">s1_t *data;</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> file_s1_t, mem_s1_t;</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">dataset_id = <a class="code hl_define" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a>(file_id, “SDScompound.h5”, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"><span class="comment">// Discover datatype in the file</span></div>
<div class="line">file_s1_t = <a class="code hl_function" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb">H5Dget_type</a>(dataset_id);</div>
<div class="line"><span class="comment">// Find corresponding memory datatype</span></div>
<div class="line">mem_s1_t = <a class="code hl_function" href="group___h5_t.html#ga05b99133058637e8daa5d745381ddd3d">H5Tget_native_type</a>(file_s1_t, <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a891787104495ea80c677ab7042bfc33da15b446e6a306e3824cf0003108d6b51c">H5T_DIR_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">data = (s1_t *) malloc (<span class="keyword">sizeof</span>(s1_t)*LENGTH);</div>
<div class="line"><a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a> (dataset_id,mem_s1_tid, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data);</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a891787104495ea80c677ab7042bfc33da15b446e6a306e3824cf0003108d6b51c"><div class="ttname"><a href="_h5_tpublic_8h.html#a891787104495ea80c677ab7042bfc33da15b446e6a306e3824cf0003108d6b51c">H5T_DIR_DEFAULT</a></div><div class="ttdeci">@ H5T_DIR_DEFAULT</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:158</div></div>
<div class="ttc" id="agroup___h5_d_html_ga7cd04b8332e8a0939b9973fbc500cadb"><div class="ttname"><a href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb">H5Dget_type</a></div><div class="ttdeci">hid_t H5Dget_type(hid_t dset_id)</div><div class="ttdoc">Returns an identifier for a copy of the datatype for a dataset.</div></div>
<div class="ttc" id="agroup___h5_t_html_ga05b99133058637e8daa5d745381ddd3d"><div class="ttname"><a href="group___h5_t.html#ga05b99133058637e8daa5d745381ddd3d">H5Tget_native_type</a></div><div class="ttdeci">hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction)</div><div class="ttdoc">Returns the native datatype identifier of a specified datatype.</div></div>
</div><!-- fragment --><p>The example below shows how to read just one float member of a compound datatype.</p>
<p><em>Read one floating point member of a compound datatype</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>sf_t {</div>
<div class="line">  <span class="keywordtype">float</span> b;</div>
<div class="line">} sf_t;</div>
<div class="line"> </div>
<div class="line">sf_t *data;</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">sf_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a>(<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(sf_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(sf_tid, “b_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(sf_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">dataset_id = <a class="code hl_define" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a>(file_id, “SDScompound.h5”, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">data = (sf_t *) malloc (<span class="keyword">sizeof</span>(sf_t) * LENGTH);</div>
<div class="line"><a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset_id, sf_tid, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data);</div>
</div><!-- fragment --><p>The example below shows how to read float and double members of a compound datatype into a structure that has those fields in a different order. Please notice that <a class="el" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081" title="Adds a new member to a compound datatype.">H5Tinsert</a> calls can be used in an order different from the order of the structure's members.</p>
<p><em>Read float and double members of a compound datatype</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>sdf_t {</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">  <span class="keywordtype">float</span> b;</div>
<div class="line">} sdf_t;</div>
<div class="line"> </div>
<div class="line">sdf_t *data;</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">sdf_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a>(<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(sdf_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(sdf_tid, “b_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(sdf_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(sdf_tid, “c_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(sdf_t, c), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">dataset_id = <a class="code hl_define" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a>(file_id, “SDScompound.h5”, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">data = (sdf_t *) malloc (<span class="keyword">sizeof</span>(sdf_t) * LENGTH);</div>
<div class="line"><a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset_id, sdf_tid, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data);</div>
</div><!-- fragment --><h4>Array</h4>
<p>Many scientific datasets have multiple measurements for each point in a space. There are several natural ways to represent this data, depending on the variables and how they are used in computation. See the table and the figure below.</p>
<table class="doxtable">
<caption>Representing data with multiple measurements</caption>
<tr>
<th><p class="starttd"></p>
<p class="intertd">Storage Strategy</p>
<p class="endtd"></p>
</th><th><p class="starttd"></p>
<p class="intertd">Stored as</p>
<p class="endtd"></p>
</th><th><p class="starttd"></p>
<p class="intertd">Remarks</p>
<p class="endtd"></p>
</th></tr>
<tr>
<td>Multiple planes  </td><td>Several datasets with identical dataspaces  </td><td>This is optimal when variables are accessed individually, or when often uses only selected variables.   </td></tr>
<tr>
<td>Additional dimension  </td><td>One dataset, the last “dimension” is a vec-tor of variables  </td><td>This can give good performance, although selecting only a few variables may be slow. This may not reflect the science.   </td></tr>
<tr>
<td>Record with multiple values  </td><td>One dataset with compound datatype  </td><td>This enables the variables to be read all together or selected. Also handles “vectors” of heterogeneous data.   </td></tr>
<tr>
<td>Vector or Tensor value  </td><td>One dataset, each data element is a small array of values.  </td><td>This uses the same amount of space as the previous two, and may represent the science model better.   </td></tr>
</table>
<table class="doxtable">
<caption>Figure 13 Representing data with multiple measurements</caption>
<tr>
<td><div class="image">
<img src="Dtypes_fig13a.gif" alt=""/>
</div>
  </td><td><div class="image">
<img src="Dtypes_fig13b.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig13c.gif" alt=""/>
</div>
  </td><td><div class="image">
<img src="Dtypes_fig13d.gif" alt=""/>
</div>
   </td></tr>
</table>
<p>The HDF5 <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a> datatype defines the data element to be a homogeneous, multi-dimensional array. See Figure 13 above. The elements of the array can be any HDF5 datatype (including compound and array), and the size of the datatype is the total size of the array. A dataset of array datatype cannot be subdivided for I/O within the data element: the entire array of the data element must be transferred. If the data elements need to be accessed separately, for example, by plane, then the array datatype should not be used. The table below shows advantages and disadvantages of various storage methods.</p>
<table class="doxtable">
<caption>Storage method advantages and disadvantages</caption>
<tr>
<th><p class="starttd"></p>
<p class="intertd">Method</p>
<p class="endtd"></p>
</th><th><p class="starttd"></p>
<p class="intertd">Advantages</p>
<p class="endtd"></p>
</th><th><p class="starttd"></p>
<p class="intertd">Disadvantages</p>
<p class="endtd"></p>
</th></tr>
<tr>
<td>Multiple Datasets  </td><td>Easy to access each plane, can select any plane(s)  </td><td>Less efficient to access a ‘column’ through the planes    </td></tr>
<tr>
<td>N+1 Dimension  </td><td>All access patterns supported  </td><td>Must be homogeneous datatype<br  />
 The added dimension may not make sense in the scientific model    </td></tr>
<tr>
<td>Compound Datatype  </td><td>Can be heterogeneous datatype  </td><td>Planes must be named, selection is by plane<br  />
 Not a natural representation for a matrix    </td></tr>
<tr>
<td>Array  </td><td>A natural representation for vector or tensor data  </td><td>Cannot access elements separately (no access by plane)   </td></tr>
</table>
<p>An array datatype may be multi-dimensional with 1 to <a class="el" href="_h5_spublic_8h.html#a265cb2343f05cb71831119c90de31a8f">H5S_MAX_RANK(the maximum rank
   of a dataset is currently 32)</a> dimensions. The dimensions can be any size greater than 0, but unlimited dimensions are not supported (although the datatype can be a variable-length datatype).</p>
<p>An array datatype is created with the <a class="el" href="group___a_r_r_a_y.html#ga39d41fdef06b3d7972ec2eab16ab5e96">H5Tarray_create</a> call, which specifies the number of dimensions, the size of each dimension, and the base type of the array. The array datatype can then be used in any way that any datatype object is used. The example below shows the creation of a datatype that is a two-dimensional array of native integers, and this is then used to create a dataset. Note that the dataset can be a dataspace that is any number and size of dimensions. The figure below shows the layout in memory assuming that the native integers are 4 bytes. Each data element has 6 elements, for a total of 24 bytes.</p>
<p><em>Create a two-dimensional array datatype</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> file, dataset;</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> datatype, dataspace;</div>
<div class="line"><a class="code hl_typedef" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> adims[] = {3, 2};</div>
<div class="line"> </div>
<div class="line">datatype = <a class="code hl_define" href="group___a_r_r_a_y.html#ga39d41fdef06b3d7972ec2eab16ab5e96">H5Tarray_create</a>(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, 2, adims, NULL);</div>
<div class="line"> </div>
<div class="line">dataset = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file, datasetname, datatype,</div>
<div class="line">dataspace, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="ttc" id="a_h5public_8h_html_a7f81cce70fb546af88da24d9285d3c1c"><div class="ttname"><a href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a></div><div class="ttdeci">uint64_t hsize_t</div><div class="ttdef"><b>Definition</b> H5public.h:297</div></div>
<div class="ttc" id="agroup___a_r_r_a_y_html_ga39d41fdef06b3d7972ec2eab16ab5e96"><div class="ttname"><a href="group___a_r_r_a_y.html#ga39d41fdef06b3d7972ec2eab16ab5e96">H5Tarray_create</a></div><div class="ttdeci">#define H5Tarray_create</div><div class="ttdef"><b>Definition</b> H5version.h:1250</div></div>
</div><!-- fragment --><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig14.gif" alt=""/>
<div class="caption">
Memory layout of a two-dimensional array datatype</div></div>
   </td></tr>
</table>
<p><a class="anchor" id="h4_vlen_datatype"></a></p><h4>Variable-length Datatypes</h4>
<p>A variable-length (VL) datatype is a one-dimensional sequence of a datatype which are not fixed in length from one dataset location to another. In other words, each data element may have a different number of members. Variable-length datatypes cannot be divided;the entire data element must be transferred.</p>
<p>VL datatypes are useful to the scientific community in many different ways, possibly including: </p><ul>
<li>
Ragged arrays: Multi-dimensional ragged arrays can be implemented with the last (fastest changing) dimension being ragged by using a VL datatype as the type of the element stored.  </li>
<li>
Fractal arrays: A nested VL datatype can be used to implement ragged arrays of ragged arrays, to whatever nesting depth is required for the user.  </li>
<li>
Polygon lists: A common storage requirement is to efficiently store arrays of polygons with different numbers of vertices. A VL datatype can be used to efficiently and succinctly describe an array of polygons with different numbers of vertices.  </li>
<li>
Character strings: Perhaps the most common use of VL datatypes will be to store C-like VL character strings in dataset elements or as attributes of objects.  </li>
<li>
Indices (for example, of objects within a file): An array of VL object references could be used as an index to all the objects in a file which contain a particular sequence of dataset values.  </li>
<li>
Object Tracking: An array of VL dataset region references can be used as a method of tracking objects or features appearing in a sequence of datasets.  </li>
</ul>
<p>A VL datatype is created by calling <a class="el" href="group___v_l_e_n.html#ga6841355fa5b3c924876b121dedb8ed2f" title="Creates a new variable-length array datatype.">H5Tvlen_create</a> which specifies the base datatype. The first example below shows an example of code that creates a VL datatype of unsigned integers. Each data element is a one-dimensional array of zero or more members and is stored in the <a class="el" href="structhvl__t.html">hvl_t</a> structure. See the second example below.</p>
<p><em>Create a variable-length datatype of unsigned integers</em> </p><div class="fragment"><div class="line">tid1 = <a class="code hl_function" href="group___v_l_e_n.html#ga6841355fa5b3c924876b121dedb8ed2f">H5Tvlen_create</a> (<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga904b507c7b8aa4838fbb7c6ce71a37c5">H5T_NATIVE_UINT</a>);</div>
<div class="line"> </div>
<div class="line">dataset=<a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(fid1,“Dataset1”, tid1, sid1, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga904b507c7b8aa4838fbb7c6ce71a37c5"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga904b507c7b8aa4838fbb7c6ce71a37c5">H5T_NATIVE_UINT</a></div><div class="ttdeci">#define H5T_NATIVE_UINT</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:772</div></div>
<div class="ttc" id="agroup___v_l_e_n_html_ga6841355fa5b3c924876b121dedb8ed2f"><div class="ttname"><a href="group___v_l_e_n.html#ga6841355fa5b3c924876b121dedb8ed2f">H5Tvlen_create</a></div><div class="ttdeci">hid_t H5Tvlen_create(hid_t base_id)</div><div class="ttdoc">Creates a new variable-length array datatype.</div></div>
</div><!-- fragment --><p><em>Data element storage for members of the VL datatype</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line">{</div>
<div class="line">  <span class="keywordtype">size_t</span> len; <span class="comment">// Length of VL data</span></div>
<div class="line">              <span class="comment">//(in base type units)</span></div>
<div class="line">  <span class="keywordtype">void</span> *p;    <span class="comment">// Pointer to VL data</span></div>
<div class="line">} <a class="code hl_struct" href="structhvl__t.html">hvl_t</a>;</div>
<div class="ttc" id="astructhvl__t_html"><div class="ttname"><a href="structhvl__t.html">hvl_t</a></div><div class="ttdef"><b>Definition</b> H5Tpublic.h:197</div></div>
</div><!-- fragment --><p>The first example below shows how the VL data is written. For each of the 10 data elements, a length and data buffer must be allocated. Below the two examples is a figure that shows how the data is laid out in memory.</p>
<p>An analogous procedure must be used to read the data. See the second example below. An appropriate array of vl_t must be allocated, and the data read. It is then traversed one data element at a time. The <a class="el" href="group___h5_d.html#ga222a2fd93868e2524b2e42c3c6146119" title="Reclaims variable-length (VL) datatype memory buffers.">H5Dvlen_reclaim</a> call frees the data buffer for the buffer. With each element possibly being of different sequence lengths for a dataset with a VL datatype, the memory for the VL datatype must be dynamically allocated. Currently there are two methods of managing the memory for VL datatypes: the standard C malloc/free memory allocation routines or a method of calling user-defined memory management routines to allocate or free memory (set with <a class="el" href="group___d_x_p_l.html#ga2220ab75de470b6a6d5b1173d12aa0cf" title="Sets the memory manager for variable-length datatype allocation in H5Dread() and H5Dvlen_reclaim()">H5Pset_vlen_mem_manager</a>). Since the memory allocated when reading (or writing) may be complicated to release, the <a class="el" href="group___h5_d.html#ga222a2fd93868e2524b2e42c3c6146119" title="Reclaims variable-length (VL) datatype memory buffers.">H5Dvlen_reclaim</a> function is provided to traverse a memory buffer and free the VL datatype information without leaking memory.</p>
<p><em>Write VL data</em> </p><div class="fragment"><div class="line"><a class="code hl_struct" href="structhvl__t.html">hvl_t</a> wdata[10];  <span class="comment">// Information to write</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Allocate and initialize VL data to write</span></div>
<div class="line"><span class="keywordflow">for</span>(i = 0; i &lt; 10; i++) {</div>
<div class="line">  wdata[i].<a class="code hl_variable" href="structhvl__t.html#a117104b82864d3b23ec174af6d392709">p</a> = malloc((i + 1) * <span class="keyword">sizeof</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>));</div>
<div class="line">  wdata[i].<a class="code hl_variable" href="structhvl__t.html#a7360b55975153b822efc5217b7734e6a">len</a> = i + 1;</div>
<div class="line">  <span class="keywordflow">for</span>(j = 0; j &lt; (i + 1); j++)</div>
<div class="line">    ((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *)wdata[i].<a class="code hl_variable" href="structhvl__t.html#a117104b82864d3b23ec174af6d392709">p</a>)[j]=i * 10 + j;</div>
<div class="line">}</div>
<div class="line">ret = <a class="code hl_function" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>(dataset, tid1, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, wdata);</div>
<div class="ttc" id="astructhvl__t_html_a117104b82864d3b23ec174af6d392709"><div class="ttname"><a href="structhvl__t.html#a117104b82864d3b23ec174af6d392709">hvl_t::p</a></div><div class="ttdeci">void * p</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:199</div></div>
<div class="ttc" id="astructhvl__t_html_a7360b55975153b822efc5217b7734e6a"><div class="ttname"><a href="structhvl__t.html#a7360b55975153b822efc5217b7734e6a">hvl_t::len</a></div><div class="ttdeci">size_t len</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:198</div></div>
</div><!-- fragment --><p><em>Read VL data</em> </p><div class="fragment"><div class="line"><a class="code hl_struct" href="structhvl__t.html">hvl_t</a> rdata[SPACE1_DIM1];</div>
<div class="line">ret = <a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset, tid1, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, xfer_pid, rdata);</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">for</span>(i = 0; i &lt; SPACE1_DIM1; i++) {</div>
<div class="line">  printf(“%d: len %d ”,rdata[i].len);</div>
<div class="line">  <span class="keywordflow">for</span>(j = 0; j &lt; rdata[i].<a class="code hl_variable" href="structhvl__t.html#a7360b55975153b822efc5217b7734e6a">len</a>; j++) {</div>
<div class="line">    printf(“ value: %u\n”,((unsigned int *)rdata[i].p)[j]);</div>
<div class="line">  }</div>
<div class="line">}</div>
<div class="line">ret = <a class="code hl_function" href="group___h5_d.html#ga222a2fd93868e2524b2e42c3c6146119">H5Dvlen_reclaim</a>(tid1, sid1, xfer_pid, rdata);</div>
<div class="ttc" id="agroup___h5_d_html_ga222a2fd93868e2524b2e42c3c6146119"><div class="ttname"><a href="group___h5_d.html#ga222a2fd93868e2524b2e42c3c6146119">H5Dvlen_reclaim</a></div><div class="ttdeci">herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf)</div><div class="ttdoc">Reclaims variable-length (VL) datatype memory buffers.</div></div>
</div><!-- fragment --><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig15.gif" alt=""/>
<div class="caption">
Memory layout of a VL datatype</div></div>
   </td></tr>
</table>
<p>The user program must carefully manage these relatively complex data structures. The <a class="el" href="group___h5_d.html#ga222a2fd93868e2524b2e42c3c6146119" title="Reclaims variable-length (VL) datatype memory buffers.">H5Dvlen_reclaim</a> function performs a standard traversal, freeing all the data. This function analyzes the datatype and dataspace objects, and visits each VL data element, recursing through nested types. By default, the system free is called for the pointer in each vl_t. Obviously, this call assumes that all of this memory was allocated with the system malloc.</p>
<p>The user program may specify custom memory manager routines, one for allocating and one for freeing. These may be set with the <a class="el" href="group___d_x_p_l.html#ga2220ab75de470b6a6d5b1173d12aa0cf" title="Sets the memory manager for variable-length datatype allocation in H5Dread() and H5Dvlen_reclaim()">H5Pset_vlen_mem_manager</a>, and must have the following prototypes: </p><ul>
<li>
<div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keywordtype">void</span> *(*H5MM_allocate_t)(<span class="keywordtype">size_t</span> size, <span class="keywordtype">void</span> *info);</div>
</div><!-- fragment -->  </li>
<li>
<div class="fragment"><div class="line"><span class="keyword">typedef</span> void (*<a class="code hl_typedef" href="_h5_m_mpublic_8h.html#aa34c7616be59673cfc3d63fa7d960f25">H5MM_free_t</a>)(<span class="keywordtype">void</span> *mem, <span class="keywordtype">void</span> *free_info);</div>
<div class="ttc" id="a_h5_m_mpublic_8h_html_aa34c7616be59673cfc3d63fa7d960f25"><div class="ttname"><a href="_h5_m_mpublic_8h.html#aa34c7616be59673cfc3d63fa7d960f25">H5MM_free_t</a></div><div class="ttdeci">void(* H5MM_free_t)(void *mem, void *free_info)</div><div class="ttdef"><b>Definition</b> H5MMpublic.h:33</div></div>
</div><!-- fragment -->  </li>
</ul>
<p>The utility function <a class="el" href="group___h5_d.html#ga0e97bbd8a8ee4a8b5b78ccce8547ce76" title="Determines the number of bytes required to store variable-length (VL) data.">H5Dvlen_get_buf_size</a> checks the number of bytes required to store the VL data from the dataset. This function analyzes the datatype and dataspace object to visit all the VL data elements, to determine the number of bytes required to store the data for the in the destination storage (memory). The size value is adjusted for data conversion and alignment in the destination.</p>
<h2><a class="anchor" id="subsec_datatype_other"></a>
Other Non-numeric Datatypes</h2>
<p>Several datatype classes define special types of objects.</p>
<h3><a class="anchor" id="subsubsec_datatype_other_strings"></a>
Strings</h3>
<p>Text data is represented by arrays of characters, called strings. Many programming languages support different conventions for storing strings, which may be fixed or variable-length, and may have different rules for padding unused storage. HDF5 can represent strings in several ways. See the figure below.</p>
<p>The strings to store are “Four score” and “lazy programmers.” </p><table class="doxtable">
<caption>A string stored as one-character elements in a one-dimensional array</caption>
<tr>
<td>a) <a class="el" href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a>: The dataset is a one-dimensional array with 29 elements, and each element is a single character.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig16a.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td>b) Fixed-length string: The dataset is a one-dimensional array with two elements, and each element is 20 characters.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig16b.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td>c) Variable-length string: The dataset is a one-dimensional array with two elements, and each element is a variable-length string. This is the same result when stored as a fixed-length string except that the first element of the array will need only 11 bytes for storage instead of 20.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig16c.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig16d.gif" alt=""/>
</div>
   </td></tr>
</table>
<p>First, a dataset may have a dataset with datatype <a class="el" href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a> with each character of the string as an element of the dataset. This will store an unstructured block of text data, but gives little indication of any structure in the text. See item a in the figure above.</p>
<p>A second alternative is to store the data using the datatype class <a class="el" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2de5d7919fe54466b7cf6a6c0b4265fa">H5T_STRING</a> with each element a fixed length. See item b in the figure above. In this approach, each element might be a word or a sentence, addressed by the dataspace. The dataset reserves space for the specified number of characters, although some strings may be shorter. This approach is simple and usually is fast to access, but can waste storage space if the length of the Strings varies.</p>
<p>A third alternative is to use a variable-length datatype. See item c in the figure above. This can be done using the standard mechanisms described above. The program would use vl_t structures to write and read the data.</p>
<p>A fourth alternative is to use a special feature of the string datatype class to set the size of the datatype to <a class="el" href="_h5_tpublic_8h.html#a5185e14efde13b48249fe391324331bc">H5T_VARIABLE</a>. See item c in the figure above. The example below shows a declaration of a datatype of type <a class="el" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a> which is set to <a class="el" href="_h5_tpublic_8h.html#a5185e14efde13b48249fe391324331bc">H5T_VARIABLE</a>. The HDF5 Library automatically translates between this and the vl_t structure. Note: the <a class="el" href="_h5_tpublic_8h.html#a5185e14efde13b48249fe391324331bc">H5T_VARIABLE</a> size can only be used with string datatypes. <em>Set the string datatype size to H5T_VARIABLE</em> </p><div class="fragment"><div class="line">tid1 = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a> (<a class="code hl_define" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a>);</div>
<div class="line">ret = <a class="code hl_function" href="group___h5_t.html#gae5f38bfd4a4c557496b3194b5180212c">H5Tset_size</a> (tid1, <a class="code hl_define" href="_h5_tpublic_8h.html#a5185e14efde13b48249fe391324331bc">H5T_VARIABLE</a>);</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a5185e14efde13b48249fe391324331bc"><div class="ttname"><a href="_h5_tpublic_8h.html#a5185e14efde13b48249fe391324331bc">H5T_VARIABLE</a></div><div class="ttdeci">#define H5T_VARIABLE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:207</div></div>
<div class="ttc" id="agroup___h5_t_html_gae5f38bfd4a4c557496b3194b5180212c"><div class="ttname"><a href="group___h5_t.html#gae5f38bfd4a4c557496b3194b5180212c">H5Tset_size</a></div><div class="ttdeci">herr_t H5Tset_size(hid_t type_id, size_t size)</div><div class="ttdoc">Sets size for a datatype.</div></div>
<div class="ttc" id="agroup___p_d_t_s_html_ga7f6b6959fefe56d2e871659110936d2d"><div class="ttname"><a href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a></div><div class="ttdeci">#define H5T_C_S1</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:476</div></div>
</div><!-- fragment --><p>Variable-length strings can be read into C strings (in other words, pointers to zero terminated arrays of char). See the example below. <em>Read variable-length strings into C strings</em> </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> *rdata[SPACE1_DIM1];</div>
<div class="line"> </div>
<div class="line">ret = <a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset, tid1, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, xfer_pid, rdata);</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">for</span>(i = 0; i &lt; SPACE1_DIM1; i++) {</div>
<div class="line">  printf(“%d: len: %d, str is: %s\n”, i, strlen(rdata[i]), rdata[i]);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">ret = <a class="code hl_function" href="group___h5_d.html#ga222a2fd93868e2524b2e42c3c6146119">H5Dvlen_reclaim</a>(tid1, sid1, xfer_pid, rdata);</div>
</div><!-- fragment --><h3><a class="anchor" id="subsubsec_datatype_other_refs"></a>
Reference</h3>
<p>In HDF5, objects (groups, datasets, and committed datatypes) are usually accessed by name. There is another way to access stored objects - by reference. There are two reference datatypes: object reference and region reference. Object reference objects are created with <a class="el" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d" title="Creates a reference.">H5Rcreate</a> and other calls (cross reference). These objects can be stored and retrieved in a dataset as elements with reference datatype. The first example below shows an example of code that creates references to four objects, and then writes the array of object references to a dataset. The second example below shows a dataset of datatype reference being read and one of the reference objects being dereferenced to obtain an object pointer.</p>
<p>In order to store references to regions of a dataset, the datatype should be <a class="el" href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a>. Note that a data element must be either an object reference or a region reference: these are different types and cannot be mixed within a single array.</p>
<p>A reference datatype cannot be divided for I/O: an element is read or written completely.</p>
<p><em>Create object references and write to a dataset</em> </p><div class="fragment"><div class="line">dataset= <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> (fid1, “Dataset3”, <a class="code hl_define" href="group___p_d_t_s_t_d.html#gadc17e0960dc7ef08e029bf17201670e1">H5T_STD_REF_OBJ</a>, sid1, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create reference to dataset</span></div>
<div class="line">ret = <a class="code hl_function" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&amp;wbuf[0], fid1,“/Group1/Dataset1”, <a class="code hl_define" href="_h5_rpublic_8h.html#ae1ffa09875ca6778df3a577592dacbd2">H5R_OBJECT</a>, -1);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create reference to dataset</span></div>
<div class="line">ret = <a class="code hl_function" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&amp;wbuf[1], fid1, “/Group1/Dataset2”, <a class="code hl_define" href="_h5_rpublic_8h.html#ae1ffa09875ca6778df3a577592dacbd2">H5R_OBJECT</a>, -1);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create reference to group</span></div>
<div class="line">ret = <a class="code hl_function" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&amp;wbuf[2], fid1, “/Group1”, <a class="code hl_define" href="_h5_rpublic_8h.html#ae1ffa09875ca6778df3a577592dacbd2">H5R_OBJECT</a>, -1);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create reference to committed datatype</span></div>
<div class="line">ret = <a class="code hl_function" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&amp;wbuf[3], fid1, “/Group1/Datatype1”, <a class="code hl_define" href="_h5_rpublic_8h.html#ae1ffa09875ca6778df3a577592dacbd2">H5R_OBJECT</a>, -1);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Write selection to disk</span></div>
<div class="line">ret=<a class="code hl_function" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>(dataset, <a class="code hl_define" href="group___p_d_t_s_t_d.html#gadc17e0960dc7ef08e029bf17201670e1">H5T_STD_REF_OBJ</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, wbuf);</div>
<div class="ttc" id="a_h5_rpublic_8h_html_ae1ffa09875ca6778df3a577592dacbd2"><div class="ttname"><a href="_h5_rpublic_8h.html#ae1ffa09875ca6778df3a577592dacbd2">H5R_OBJECT</a></div><div class="ttdeci">#define H5R_OBJECT</div><div class="ttdef"><b>Definition</b> H5Rpublic.h:638</div></div>
<div class="ttc" id="agroup___h5_r_html_ga0ac6997b5de26b11d91a95de2869950d"><div class="ttname"><a href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a></div><div class="ttdeci">herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id)</div><div class="ttdoc">Creates a reference.</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gadc17e0960dc7ef08e029bf17201670e1"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gadc17e0960dc7ef08e029bf17201670e1">H5T_STD_REF_OBJ</a></div><div class="ttdeci">#define H5T_STD_REF_OBJ</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:405</div></div>
</div><!-- fragment --><p><em>Read a dataset with a reference datatype</em> </p><div class="fragment"><div class="line">rbuf = malloc(<span class="keyword">sizeof</span>(<a class="code hl_typedef" href="_h5_rpublic_8h.html#af1f69150fc8b3d6bf182da39dc0fe081">hobj_ref_t</a>)*SPACE1_DIM1);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Read selection from disk</span></div>
<div class="line">ret=<a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset, <a class="code hl_define" href="group___p_d_t_s_t_d.html#gadc17e0960dc7ef08e029bf17201670e1">H5T_STD_REF_OBJ</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, rbuf);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Open dataset object</span></div>
<div class="line">dset2 = <a class="code hl_define" href="group___h5_r.html#ga5dc19b9d1833af66c5e1f819f2c05c4a">H5Rdereference</a>(dataset, <a class="code hl_define" href="_h5_rpublic_8h.html#ae1ffa09875ca6778df3a577592dacbd2">H5R_OBJECT</a>, &amp;rbuf[0]);</div>
<div class="ttc" id="a_h5_rpublic_8h_html_af1f69150fc8b3d6bf182da39dc0fe081"><div class="ttname"><a href="_h5_rpublic_8h.html#af1f69150fc8b3d6bf182da39dc0fe081">hobj_ref_t</a></div><div class="ttdeci">haddr_t hobj_ref_t</div><div class="ttdef"><b>Definition</b> H5Rpublic.h:71</div></div>
<div class="ttc" id="agroup___h5_r_html_ga5dc19b9d1833af66c5e1f819f2c05c4a"><div class="ttname"><a href="group___h5_r.html#ga5dc19b9d1833af66c5e1f819f2c05c4a">H5Rdereference</a></div><div class="ttdeci">#define H5Rdereference</div><div class="ttdef"><b>Definition</b> H5version.h:1217</div></div>
</div><!-- fragment --><h3><a class="anchor" id="subsubsec_datatype_other_enum"></a>
ENUM</h3>
<p>The enum datatype implements a set of (name, value) pairs, similar to C/C++ enum. The values are currently limited to native integer datatypes. Each name can be the name of only one value, and each value can have only one name.</p>
<p>The data elements of the ENUMERATION are stored according to the datatype. An example would be as an array of integers. The example below shows an example of how to create an enumeration with five elements. The elements map symbolic names to 2-byte integers. See the table below. <em>Create an enumeration with five elements</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> hdf_en_colors;</div>
<div class="line"><span class="keywordtype">short</span> val;</div>
<div class="line"> </div>
<div class="line">hdf_en_colors = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a>(<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5ee305303f12787367ac271d8f28f2e6">H5T_ENUM</a>, <span class="keyword">sizeof</span>(<span class="keywordtype">short</span>));</div>
<div class="line"><a class="code hl_function" href="group___e_n_u_m.html#ga7bbddcff3a5d18ee983fbe5654fdc41f">H5Tenum_insert</a>(hdf_en_colors, “RED”, (val=0, &amp;val));</div>
<div class="line"><a class="code hl_function" href="group___e_n_u_m.html#ga7bbddcff3a5d18ee983fbe5654fdc41f">H5Tenum_insert</a>(hdf_en_colors, “GREEN”, (val=1, &amp;val));</div>
<div class="line"><a class="code hl_function" href="group___e_n_u_m.html#ga7bbddcff3a5d18ee983fbe5654fdc41f">H5Tenum_insert</a>(hdf_en_colors, “BLUE”, (val=2, &amp;val));</div>
<div class="line"><a class="code hl_function" href="group___e_n_u_m.html#ga7bbddcff3a5d18ee983fbe5654fdc41f">H5Tenum_insert</a>(hdf_en_colors, “WHITE”, (val=3, &amp;val));</div>
<div class="line"><a class="code hl_function" href="group___e_n_u_m.html#ga7bbddcff3a5d18ee983fbe5654fdc41f">H5Tenum_insert</a>(hdf_en_colors, “BLACK”, (val=4, &amp;val));</div>
<div class="line"><a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(fileid, datasetname, hdf_en_colors, spaceid, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2a5ee305303f12787367ac271d8f28f2e6"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5ee305303f12787367ac271d8f28f2e6">H5T_ENUM</a></div><div class="ttdeci">@ H5T_ENUM</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:40</div></div>
<div class="ttc" id="agroup___e_n_u_m_html_ga7bbddcff3a5d18ee983fbe5654fdc41f"><div class="ttname"><a href="group___e_n_u_m.html#ga7bbddcff3a5d18ee983fbe5654fdc41f">H5Tenum_insert</a></div><div class="ttdeci">herr_t H5Tenum_insert(hid_t type, const char *name, const void *value)</div><div class="ttdoc">Inserts a new enumeration datatype member.</div></div>
</div><!-- fragment --><table class="doxtable">
<caption>An enumeration with five elements</caption>
<tr>
<th>Name </th><th>Value  </th></tr>
<tr>
<td>RED </td><td>0  </td></tr>
<tr>
<td>GREEN </td><td>1  </td></tr>
<tr>
<td>BLUE </td><td>2  </td></tr>
<tr>
<td>WHITE </td><td>3  </td></tr>
<tr>
<td>BLACK </td><td>4  </td></tr>
</table>
<p>The figure below shows how an array of eight values might be stored. Conceptually, the array is an array of symbolic names [BLACK, RED, WHITE, BLUE, ...] See item a in the figure below. These are stored as the values and are short integers. So, the first 2 bytes are the value associated with “BLACK”, which is the number 4, and so on. See item b in the figure below. </p><table class="doxtable">
<caption>Storing an enum array</caption>
<tr>
<td>a) Logical data to be written - eight elements   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig17a.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td>b) The storage layout. Total size of the array is 16 bytes, 2 bytes per element.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig17b.gif" alt=""/>
</div>
   </td></tr>
</table>
<p>The order that members are inserted into an enumeration type is unimportant; the important part is the associations between the symbol names and the values. Thus, two enumeration datatypes will be considered equal if and only if both types have the same symbol/value associations and both have equal underlying integer datatypes. Type equality is tested with the H5Tequal function.</p>
<p>If a particular architecture type is required, a little-endian or big-endian datatype for example, use a native integer datatype as the ENUM base datatype and use <a class="el" href="group___c_o_n_v.html#ga9442478475a03357ee47fa035df0228a" title="Converts data from one specified datatype to another.">H5Tconvert</a> on values as they are read from or written to a dataset.</p>
<h3><a class="anchor" id="subsubsec_datatype_other_opaque"></a>
Opaque</h3>
<p>In some cases, a user may have data objects that should be stored and retrieved as blobs with no attempt to interpret them. For example, an application might wish to store an array of encrypted certificates which are 100 bytes long.</p>
<p>While an arbitrary block of data may always be stored as bytes, characters, integers, or whatever, this might mislead programs about the meaning of the data. The opaque datatype defines data elements which are uninterpreted by HDF5. The opaque data may be labeled with <a class="el" href="group___o_p_a_q_u_e.html#ga3543ad909983a2a20e651d16502de43d" title="Tags an opaque datatype.">H5Tset_tag</a> with a string that might be used by an application. For example, the encrypted certificates might have a tag to indicate the encryption and the certificate standard.</p>
<h3><a class="anchor" id="subsubsec_datatype_other_bitfield"></a>
Bitfield</h3>
<p>Some data is represented as bits, where the number of bits is not an integral byte and the bits are not necessarily interpreted as a standard type. Some examples might include readings from machine registers (for example, switch positions), a cloud mask, or data structures with several small integers that should be store in a single byte.</p>
<p>This data could be stored as integers, strings, or enumerations. However, these storage methods would likely result in considerable wasted space. For example, storing a cloud mask with one byte per value would use up to eight times the space of a packed array of bits.</p>
<p>The HDF5 bitfield datatype class defines a data element that is a contiguous sequence of bits, which are stored on disk in a packed array. The programming model is the same as for unsigned integers: the datatype object is created by copying a predefined datatype, and then the precision, offset, and padding are set.</p>
<p>While the use of the bitfield datatype will reduce storage space substantially, there will still be wasted space if the bitfield as a whole does not match the 1-, 2-, 4-, or 8-byte unit in which it is written. The remaining unused space can be removed by applying the N-bit filter to the dataset containing the bitfield data. For more information, see "Using the N-bit Filter."</p>
<h2><a class="anchor" id="subsec_datatype_fill"></a>
Fill Values</h2>
<p>The “fill value” for a dataset is the specification of the default value assigned to data elements that have not yet been written. In the case of a dataset with an atomic datatype, the fill value is a single value of the appropriate datatype, such as ‘0’ or ‘-1.0’. In the case of a dataset with a composite datatype, the fill value is a single data element of the appropriate type. For example, for an array or compound datatype, the fill value is a single data element with values for all the component elements of the array or compound datatype.</p>
<p>The fill value is set (permanently) when the dataset is created. The fill value is set in the dataset creation properties in the <a class="el" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> call. Note that the <a class="el" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> call must also include the datatype of the dataset, and the value provided for the fill value will be interpreted as a single element of this datatype. The example below shows code which creates a dataset of integers with fill value -1. Any unwritten data elements will be set to -1.</p>
<p><em>Create a dataset with a fill value of -1</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> plist_id;</div>
<div class="line"><span class="keywordtype">int</span>   filler;</div>
<div class="line"> </div>
<div class="line">filler = -1;</div>
<div class="line">plist_id = <a class="code hl_function" href="group___p_l_c_r.html#gaf1b11da01d4d45d788c45f8bc5f0cbfa">H5Pcreate</a>(<a class="code hl_define" href="_h5_ppublic_8h.html#afcd7f8186c404f3a1d768632eacba102">H5P_DATASET_CREATE</a>);</div>
<div class="line"><a class="code hl_function" href="group___d_c_p_l.html#ga4335bb45b35386daa837b4ff1b9cd4a4">H5Pset_fill_value</a>(plist_id, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, &amp;filler);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create the dataset with fill value ‘-1’.</span></div>
<div class="line">dataset_id = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file_id, “/dset”, <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga37e8a6be7ee64587c2a282b965019bb8">H5T_STD_I32BE</a>, dataspace_id, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, plist_id,</div>
<div class="line">                       <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="ttc" id="a_h5_ppublic_8h_html_afcd7f8186c404f3a1d768632eacba102"><div class="ttname"><a href="_h5_ppublic_8h.html#afcd7f8186c404f3a1d768632eacba102">H5P_DATASET_CREATE</a></div><div class="ttdeci">#define H5P_DATASET_CREATE</div><div class="ttdef"><b>Definition</b> H5Ppublic.h:53</div></div>
<div class="ttc" id="agroup___d_c_p_l_html_ga4335bb45b35386daa837b4ff1b9cd4a4"><div class="ttname"><a href="group___d_c_p_l.html#ga4335bb45b35386daa837b4ff1b9cd4a4">H5Pset_fill_value</a></div><div class="ttdeci">herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value)</div><div class="ttdoc">Sets the fill value for a dataset.</div></div>
</div><!-- fragment --><p><em>Create a fill value for a compound datatype</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>s1_t {</div>
<div class="line">  <span class="keywordtype">int</span> a;</div>
<div class="line">  <span class="keywordtype">char</span> b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} s1_t;</div>
<div class="line">s1_t filler;</div>
<div class="line"> </div>
<div class="line">s1_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(s1_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “a_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, a), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “b_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “c_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, c), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"> </div>
<div class="line">filler.a = -1;</div>
<div class="line">filler.b = ‘*’;</div>
<div class="line">filler.c = -2.0;</div>
<div class="line">plist_id = <a class="code hl_function" href="group___p_l_c_r.html#gaf1b11da01d4d45d788c45f8bc5f0cbfa">H5Pcreate</a>(<a class="code hl_define" href="_h5_ppublic_8h.html#afcd7f8186c404f3a1d768632eacba102">H5P_DATASET_CREATE</a>);</div>
<div class="line"><a class="code hl_function" href="group___d_c_p_l.html#ga4335bb45b35386daa837b4ff1b9cd4a4">H5Pset_fill_value</a>(plist_id, s1_tid, &amp;filler);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create the dataset with fill value</span></div>
<div class="line"><span class="comment">// (-1, ‘*’, -2.0).</span></div>
<div class="line">dataset = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file, datasetname, s1_tid, space, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, plist_id, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
</div><!-- fragment --><p>The code above shows how to create a fill value for a compound datatype. The procedure is the same as the previous example except the filler must be a structure with the correct fields. Each field is initialized to the desired fill value.</p>
<p>The fill value for a dataset can be retrieved by reading the dataset creation properties of the dataset and then by reading the fill value with <a class="el" href="group___d_c_p_l.html#ga82bbe8c77c7eb9c460bfd1eb26881355" title="Retrieves a dataset fill value.">H5Pget_fill_value</a>. The data will be read into memory using the storage layout specified by the datatype. This transfer will convert data in the same way as <a class="el" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c" title="Reads raw data from a dataset into a provided buffer.">H5Dread</a>. The example below shows how to get the fill value from the dataset created in the example "Create a dataset with a fill value of -1".</p>
<p><em>Retrieve a fill value</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> plist2;</div>
<div class="line"><span class="keywordtype">int</span>   filler;</div>
<div class="line"> </div>
<div class="line">dataset_id = <a class="code hl_define" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a>(file_id, “/dset”, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line">plist2 = <a class="code hl_function" href="group___h5_d.html#ga8848f14f4aba8e6160c3d8bb7f1be163">H5Dget_create_plist</a>(dataset_id);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="group___d_c_p_l.html#ga82bbe8c77c7eb9c460bfd1eb26881355">H5Pget_fill_value</a>(plist2, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, &amp;filler);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// filler has the fill value, ‘-1</span></div>
<div class="ttc" id="agroup___d_c_p_l_html_ga82bbe8c77c7eb9c460bfd1eb26881355"><div class="ttname"><a href="group___d_c_p_l.html#ga82bbe8c77c7eb9c460bfd1eb26881355">H5Pget_fill_value</a></div><div class="ttdeci">herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value)</div><div class="ttdoc">Retrieves a dataset fill value.</div></div>
<div class="ttc" id="agroup___h5_d_html_ga8848f14f4aba8e6160c3d8bb7f1be163"><div class="ttname"><a href="group___h5_d.html#ga8848f14f4aba8e6160c3d8bb7f1be163">H5Dget_create_plist</a></div><div class="ttdeci">hid_t H5Dget_create_plist(hid_t dset_id)</div><div class="ttdoc">Returns an identifier for a copy of the dataset creation property list for a dataset.</div></div>
</div><!-- fragment --><p>A similar procedure is followed for any datatype. The example below shows how to read the fill value for the compound datatype created in an example above. Note that the program must pass an element large enough to hold a fill value of the datatype indicated by the argument to <a class="el" href="group___d_c_p_l.html#ga82bbe8c77c7eb9c460bfd1eb26881355" title="Retrieves a dataset fill value.">H5Pget_fill_value</a>. Also, the program must understand the datatype in order to interpret its components. This may be difficult to determine without knowledge of the application that created the dataset.</p>
<p><em>Read the fill value for a compound datatype</em> </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> *fillbuf;</div>
<div class="line"><span class="keywordtype">int</span>   sz;</div>
<div class="line"> </div>
<div class="line">dataset = <a class="code hl_define" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a>( file, DATASETNAME, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line">s1_tid = <a class="code hl_function" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb">H5Dget_type</a>(dataset);</div>
<div class="line"> </div>
<div class="line">sz = <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s1_tid);</div>
<div class="line"> </div>
<div class="line">fillbuf = (<span class="keywordtype">char</span> *)malloc(sz);</div>
<div class="line"> </div>
<div class="line">plist_id = <a class="code hl_function" href="group___h5_d.html#ga8848f14f4aba8e6160c3d8bb7f1be163">H5Dget_create_plist</a>(dataset);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_function" href="group___d_c_p_l.html#ga82bbe8c77c7eb9c460bfd1eb26881355">H5Pget_fill_value</a>(plist_id, s1_tid, fillbuf);</div>
<div class="line"> </div>
<div class="line">printf(“filler.a: %d\n”,((s1_t *) fillbuf)-&gt;a);</div>
<div class="line">printf(“filler.b: %c\n”,((s1_t *) fillbuf)-&gt;b);</div>
<div class="line">printf(“filler.c: %f\n”,((s1_t *) fillbuf)-&gt;c);</div>
</div><!-- fragment --><h2><a class="anchor" id="subsec_datatype_complex"></a>
Complex Combinations of Datatypes</h2>
<p>Several composite datatype classes define collections of other datatypes, including other composite datatypes. In general, a datatype can be nested to any depth, with any combination of datatypes.</p>
<p>For example, a compound datatype can have members that are other compound datatypes, arrays, VL datatypes. An array can be an array of array, an array of compound, or an array of VL. And a VL datatype can be a variable-length array of compound, array, or VL datatypes.</p>
<p>These complicated combinations of datatypes form a logical tree, with a single root datatype, and leaves which must be atomic datatypes (predefined or user-defined). The figure below shows an example of a logical tree describing a compound datatype constructed from different datatypes.</p>
<p>Recall that the datatype is a description of the layout of storage. The complicated compound datatype is constructed from component datatypes, each of which describes the layout of part of the storage. Any datatype can be used as a component of a compound datatype, with the following restrictions: </p><ul>
<li>
1. No byte can be part of more than one component datatype (in other words, the fields cannot overlap within the compound datatype) </li>
<li>
2. The total size of the components must be less than or equal to the total size of the compound datatype</li>
</ul>
<p>These restrictions are essentially the rules for C structures and similar record types familiar from programming languages. Multiple typing, such as a C union, is not allowed in HDF5 datatypes.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig18.gif" alt=""/>
<div class="caption">
A compound datatype built with different datatypes</div></div>
   </td></tr>
</table>
<h3><a class="anchor" id="subsubsec_datatype_complex_create"></a>
Creating a Complicated Compound Datatype</h3>
<p>To construct a complicated compound datatype, each component is constructed, and then added to the enclosing datatype description. The example below shows how to create a compound datatype with four members: </p><ul>
<li>“T1”, a compound datatype with three members </li>
<li>“T2”, a compound datatype with two members </li>
<li>“T3”, a one-dimensional array of integers </li>
<li>“T4”, a string</li>
</ul>
<p>Below the example code is a figure that shows this datatype as a logical tree. The output of the h5dump utility is shown in the example below the figure.</p>
<p>Each datatype is created as a separate datatype object. Figure "The storage layout for the
   four member datatypes" below shows the storage layout for the four individual datatypes. Then the datatypes are inserted into the outer datatype at an appropriate offset. Figure "The storage layout of the combined four members" below shows the resulting storage layout. The combined record is 89 bytes long.</p>
<p>The Dataset is created using the combined compound datatype. The dataset is declared to be a 4 by 3 array of compound data. Each data element is an instance of the 89-byte compound datatype. Figure "The layout of the dataset" below shows the layout of the dataset, and expands one of the elements to show the relative position of the component data elements.</p>
<p>Each data element is a compound datatype, which can be written or read as a record, or each field may be read or written individually. The first field (“T1”) is itself a compound datatype with three fields (“T1.a”, “T1.b”, and “T1.c”). “T1” can be read or written as a record, or individual fields can be accessed. Similarly, the second filed is a compound datatype with two fields (“T2.f1”, “T2.f2”).</p>
<p>The third field (“T3”) is an array datatype. Thus, “T3” should be accessed as an array of 40 integers. Array data can only be read or written as a single element, so all 40 integers must be read or written to the third field. The fourth field (“T4”) is a single string of length 25.</p>
<p><em>Create a compound datatype with four members</em> </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>s1_t {</div>
<div class="line">  <span class="keywordtype">int</span> a;</div>
<div class="line">  <span class="keywordtype">char</span> b;</div>
<div class="line">  <span class="keywordtype">double</span> c;</div>
<div class="line">} s1_t;</div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>s2_t {</div>
<div class="line">  <span class="keywordtype">float</span> f1;</div>
<div class="line">  <span class="keywordtype">float</span> f2;</div>
<div class="line">} s2_t;</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> s1_tid, s2_tid, s3_tid, s4_tid, s5_tid;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a datatype for s1</span></div>
<div class="line">s1_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(s1_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “a_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, a), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “b_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, b), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s1_tid, “c_name”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s1_t, c), <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a datatype for s2.</span></div>
<div class="line">s2_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, <span class="keyword">sizeof</span>(s2_t));</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s2_tid, “f1”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s2_t, f1), <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s2_tid, “f2”, <a class="code hl_define" href="_h5_tpublic_8h.html#af5242159129a7f37ab85d33d85a1ccac">HOFFSET</a>(s2_t, f2), <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a datatype for an Array of integers</span></div>
<div class="line">s3_tid = <a class="code hl_define" href="group___a_r_r_a_y.html#ga39d41fdef06b3d7972ec2eab16ab5e96">H5Tarray_create</a>(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, RANK, dim);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a datatype for a String of 25 characters</span></div>
<div class="line">s4_tid = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>(<a class="code hl_define" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a>);</div>
<div class="line"><a class="code hl_function" href="group___h5_t.html#gae5f38bfd4a4c557496b3194b5180212c">H5Tset_size</a>(s4_tid, 25);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a compound datatype composed of one of each of these types.</span></div>
<div class="line"><span class="comment">// The total size is the sum of the size of each.</span></div>
<div class="line">sz = <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s1_tid) + <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s2_tid) + <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s3_tid) + <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s4_tid);</div>
<div class="line">s5_tid = <a class="code hl_function" href="group___h5_t.html#gaa9afc38e1a7d35e4d0bec24c569b3c65">H5Tcreate</a> (<a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>, sz);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Insert the component types at the appropriate offsets.</span></div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s5_tid, “T1”, 0, s1_tid);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s5_tid, “T2”, <span class="keyword">sizeof</span>(s1_t), s2_tid);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s5_tid, “T3”, <span class="keyword">sizeof</span>(s1_t) + <span class="keyword">sizeof</span>(s2_t), s3_tid);</div>
<div class="line"><a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga487d8f64a76f48b6eeb7f402d3b8b081">H5Tinsert</a>(s5_tid, “T4”, (<span class="keyword">sizeof</span>(s1_t) + <span class="keyword">sizeof</span>(s2_t) + <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s3_tid)), s4_tid);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create the dataset with this datatype.</span></div>
<div class="line">dataset = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file, DATASETNAME, s5_tid, space, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
</div><!-- fragment --><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig19.gif" alt=""/>
<div class="caption">
Logical tree for the compound datatype with four members</div></div>
   </td></tr>
</table>
<p><em> Output from h5dump for the compound datatype</em> </p><div class="fragment"><div class="line">DATATYPE <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> {</div>
<div class="line">   <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> {</div>
<div class="line">      <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a> “a_name”;</div>
<div class="line">      <a class="code hl_define" href="group___p_d_t_s_t_d.html#gaeaa5eb139424ba27d5af8925f1aa9593">H5T_STD_I8LE</a> “b_name”;</div>
<div class="line">      <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga3f9c2185ec16632fab8c20ec7a63178e">H5T_IEEE_F64LE</a> “c_name”;</div>
<div class="line">   } “T1”;</div>
<div class="line">   <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> {</div>
<div class="line">      <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga994ce9ffdd2c77a9352b102a883503ea">H5T_IEEE_F32LE</a> “f1”;</div>
<div class="line">      <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga994ce9ffdd2c77a9352b102a883503ea">H5T_IEEE_F32LE</a> “f2”;</div>
<div class="line">   } “T2”;</div>
<div class="line">   <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a> { [10] <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a> } “T3”;</div>
<div class="line">   <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2de5d7919fe54466b7cf6a6c0b4265fa">H5T_STRING</a> {</div>
<div class="line">      STRSIZE 25;</div>
<div class="line">      STRPAD <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a23c685afc240bbac4da23b36d8fd7e13">H5T_STR_NULLTERM</a>;</div>
<div class="line">      CSET <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa27383e03d1cad9b4c32d8611a145d663">H5T_CSET_ASCII</a>;</div>
<div class="line">      CTYPE <a class="code hl_define" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a>;</div>
<div class="line">   } “T4”;</div>
<div class="line">}</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a03755b8370672668ddc7063add28e71aa27383e03d1cad9b4c32d8611a145d663"><div class="ttname"><a href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa27383e03d1cad9b4c32d8611a145d663">H5T_CSET_ASCII</a></div><div class="ttdeci">@ H5T_CSET_ASCII</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:95</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2a2de5d7919fe54466b7cf6a6c0b4265fa"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2de5d7919fe54466b7cf6a6c0b4265fa">H5T_STRING</a></div><div class="ttdeci">@ H5T_STRING</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:35</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a></div><div class="ttdeci">@ H5T_ARRAY</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:42</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_ad2ab726f3bd28222a2ffb91c6bbc3514a23c685afc240bbac4da23b36d8fd7e13"><div class="ttname"><a href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a23c685afc240bbac4da23b36d8fd7e13">H5T_STR_NULLTERM</a></div><div class="ttdeci">@ H5T_STR_NULLTERM</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:120</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gaeaa5eb139424ba27d5af8925f1aa9593"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gaeaa5eb139424ba27d5af8925f1aa9593">H5T_STD_I8LE</a></div><div class="ttdeci">#define H5T_STD_I8LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:290</div></div>
</div><!-- fragment --><table class="doxtable">
<caption>The storage layout for the four member datatypes</caption>
<tr>
<td>a) Compound type ‘s1_t’, size 16 bytes.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig20a.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td>b) Compound type ‘s2_t’, size 8 bytes.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig20b.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td>c) Array type ‘s3_tid’, 40 integers, total size 40 bytes.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig20c.gif" alt=""/>
</div>
   </td></tr>
<tr>
<td>d) String type ‘s4_tid’, size 25 bytes.   </td></tr>
<tr>
<td><div class="image">
<img src="Dtypes_fig20d.gif" alt=""/>
</div>
   </td></tr>
</table>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig21.gif" alt=""/>
<div class="caption">
The storage layout of the combined four members</div></div>
   </td></tr>
</table>
<ul>
<li>A 4 x 3 array of Compound Datatype </li>
<li>Element [1,1] expanded <table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig22.gif" alt=""/>
<div class="caption">
The layout of the dataset</div></div>
   </td></tr>
</table>
</li>
</ul>
<h3><a class="anchor" id="subsubsec_datatype_complex_analyze"></a>
Analyzing and Navigating a Compound Datatype</h3>
<p>A complicated compound datatype can be analyzed piece by piece to discover the exact storage layout. In the example above, the outer datatype is analyzed to discover that it is a compound datatype with four members. Each member is analyzed in turn to construct a complete map of the storage layout.</p>
<p>The example below shows an example of code that partially analyzes a nested compound datatype. The name and overall offset and size of the component datatype is discovered, and then its type is analyzed depending on the datatype class. Through this method, the complete storage layout can be discovered.</p>
<p><em> Output from h5dump for the compound datatype</em> </p><div class="fragment"><div class="line">s1_tid = <a class="code hl_function" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb">H5Dget_type</a>(dataset);</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">if</span> (<a class="code hl_function" href="group___h5_t.html#ga364545c053f925fec65880b235e37898">H5Tget_class</a>(s1_tid) == <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>) {</div>
<div class="line">  printf(“COMPOUND DATATYPE {\n”);</div>
<div class="line">  sz = <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s1_tid);</div>
<div class="line">  nmemb = <a class="code hl_function" href="group___c_o_m_p_e_n_u_m.html#ga21bdfc706f71ebe298a433e74b5bc626">H5Tget_nmembers</a>(s1_tid);</div>
<div class="line">  printf(“ %d bytes\n”,sz);</div>
<div class="line">  printf(“ %d members\n”,nmemb);</div>
<div class="line">  <span class="keywordflow">for</span> (i =0; i &lt; nmemb; i++) {</div>
<div class="line">    s2_tid = <a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#gaf5de0eabe28246f040342e275b9a63eb">H5Tget_member_type</a>(s1_tid, i);</div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_function" href="group___h5_t.html#ga364545c053f925fec65880b235e37898">H5Tget_class</a>(s2_tid) == <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a>) {</div>
<div class="line">      <span class="comment">// recursively analyze the nested type.</span></div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="group___h5_t.html#ga364545c053f925fec65880b235e37898">H5Tget_class</a>(s2_tid) == <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a>) {</div>
<div class="line">      sz2 = <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s2_tid);</div>
<div class="line">      printf(“ %s: NESTED ARRAY DATATYPE offset %d size %d</div>
<div class="line">             {\n”, <a class="code hl_function" href="group___c_o_m_p_e_n_u_m.html#ga64d1d807464d2011192f28115580fb66">H5Tget_member_name</a>(s1_tid, i), <a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga46cf2a60b54a08695635749c215af4af">H5Tget_member_offset</a>(s1_tid, i), sz2);</div>
<div class="line">      <a class="code hl_define" href="group___a_r_r_a_y.html#ga2b4fecf95c9c16e4431d8aba60995473">H5Tget_array_dims</a>(s2_tid, dim);</div>
<div class="line">      s3_tid = <a class="code hl_function" href="group___h5_t.html#ga331e8f7b388a50af77294018db788de3">H5Tget_super</a>(s2_tid);</div>
<div class="line">      <span class="comment">// Etc., analyze the base type of the array</span></div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> {</div>
<div class="line">      <span class="comment">// analyze a simple type</span></div>
<div class="line">      printf(“ %s: type code %d offset %d size %d\n”, <a class="code hl_function" href="group___c_o_m_p_e_n_u_m.html#ga64d1d807464d2011192f28115580fb66">H5Tget_member_name</a>(s1_tid, i),</div>
<div class="line">             <a class="code hl_function" href="group___h5_t.html#ga364545c053f925fec65880b235e37898">H5Tget_class</a>(s2_tid), <a class="code hl_function" href="group___c_o_m_p_o_u_n_d.html#ga46cf2a60b54a08695635749c215af4af">H5Tget_member_offset</a>(s1_tid, i), <a class="code hl_function" href="group___h5_t.html#ga1b971589cd7a86f3e84affdee455564e">H5Tget_size</a>(s2_tid));</div>
<div class="line">    }</div>
<div class="line">    <span class="comment">// and so on....</span></div>
<div class="ttc" id="agroup___a_r_r_a_y_html_ga2b4fecf95c9c16e4431d8aba60995473"><div class="ttname"><a href="group___a_r_r_a_y.html#ga2b4fecf95c9c16e4431d8aba60995473">H5Tget_array_dims</a></div><div class="ttdeci">#define H5Tget_array_dims</div><div class="ttdef"><b>Definition</b> H5version.h:1272</div></div>
<div class="ttc" id="agroup___c_o_m_p_e_n_u_m_html_ga21bdfc706f71ebe298a433e74b5bc626"><div class="ttname"><a href="group___c_o_m_p_e_n_u_m.html#ga21bdfc706f71ebe298a433e74b5bc626">H5Tget_nmembers</a></div><div class="ttdeci">int H5Tget_nmembers(hid_t type_id)</div><div class="ttdoc">Retrieves the number of elements in a compound or enumeration datatype.</div></div>
<div class="ttc" id="agroup___c_o_m_p_e_n_u_m_html_ga64d1d807464d2011192f28115580fb66"><div class="ttname"><a href="group___c_o_m_p_e_n_u_m.html#ga64d1d807464d2011192f28115580fb66">H5Tget_member_name</a></div><div class="ttdeci">char * H5Tget_member_name(hid_t type_id, unsigned membno)</div><div class="ttdoc">Retrieves the name of a compound or enumeration datatype member.</div></div>
<div class="ttc" id="agroup___c_o_m_p_o_u_n_d_html_ga46cf2a60b54a08695635749c215af4af"><div class="ttname"><a href="group___c_o_m_p_o_u_n_d.html#ga46cf2a60b54a08695635749c215af4af">H5Tget_member_offset</a></div><div class="ttdeci">size_t H5Tget_member_offset(hid_t type_id, unsigned membno)</div><div class="ttdoc">Retrieves the offset of a field of a compound datatype.</div></div>
<div class="ttc" id="agroup___c_o_m_p_o_u_n_d_html_gaf5de0eabe28246f040342e275b9a63eb"><div class="ttname"><a href="group___c_o_m_p_o_u_n_d.html#gaf5de0eabe28246f040342e275b9a63eb">H5Tget_member_type</a></div><div class="ttdeci">hid_t H5Tget_member_type(hid_t type_id, unsigned membno)</div><div class="ttdoc">Returns the datatype of the specified member.</div></div>
<div class="ttc" id="agroup___h5_t_html_ga331e8f7b388a50af77294018db788de3"><div class="ttname"><a href="group___h5_t.html#ga331e8f7b388a50af77294018db788de3">H5Tget_super</a></div><div class="ttdeci">hid_t H5Tget_super(hid_t type)</div><div class="ttdoc">Returns the base datatype from which a datatype is derived.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsec_datatype_life"></a>
Life Cycle of the Datatype Object</h2>
<p>Application programs access HDF5 datatypes through identifiers. Identifiers are obtained by creating a new datatype or by copying or opening an existing datatype. The identifier can be used until it is closed or until the library shuts down. See items a and b in the figure below. By default, a datatype is transient, and it disappears when it is closed.</p>
<p>When a dataset or attribute is created (<a class="el" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> or <a class="el" href="group___h5_a.html#ga4a76e4e5ab6eb0fd2aa7990d38d55f24">H5Acreate</a>), its datatype is stored in the HDF5 file as part of the dataset or attribute object. See item c in the figure below. Once an object created, its datatype cannot be changed or deleted. The datatype can be accessed by calling <a class="el" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb" title="Returns an identifier for a copy of the datatype for a dataset.">H5Dget_type</a>, <a class="el" href="group___h5_a.html#ga0b070b714b2e535df2e1cb3005026a44" title="Gets an attribute&#39;s datatype.">H5Aget_type</a>, <a class="el" href="group___h5_t.html#ga331e8f7b388a50af77294018db788de3" title="Returns the base datatype from which a datatype is derived.">H5Tget_super</a>, or <a class="el" href="group___c_o_m_p_o_u_n_d.html#gaf5de0eabe28246f040342e275b9a63eb" title="Returns the datatype of the specified member.">H5Tget_member_type</a>. See item d in the figure below. These calls return an identifier to a transient copy of the datatype of the dataset or attribute unless the datatype is a committed datatype. Note that when an object is created, the stored datatype is a copy of the transient datatype. If two objects are created with the same datatype, the information is stored in each object with the same effect as if two different datatypes were created and used.</p>
<p>A transient datatype can be stored using <a class="el" href="group___h5_t.html#ga9a224eb59f0ba807789e3f8ba3a840cd">H5Tcommit</a> in the HDF5 file as an independent, named object, called a committed datatype. Committed datatypes were formerly known as named datatypes. See item e in the figure below. Subsequently, when a committed datatype is opened with <a class="el" href="group___h5_t.html#ga1d14b407603fdcedfbed1f723784c209">H5Topen</a> (item f), or is obtained with <a class="el" href="group___c_o_m_p_o_u_n_d.html#gaf5de0eabe28246f040342e275b9a63eb" title="Returns the datatype of the specified member.">H5Tget_member_type</a> or similar call (item k), the return is an identifier to a transient copy of the stored datatype. The identifier can be used in the same way as other datatype identifiers except that the committed datatype cannot be modified. When a committed datatype is copied with <a class="el" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e" title="Copies an existing datatype.">H5Tcopy</a>, the return is a new, modifiable, transient datatype object (item f).</p>
<p>When an object is created using a committed datatype (<a class="el" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>, <a class="el" href="group___h5_a.html#ga4a76e4e5ab6eb0fd2aa7990d38d55f24">H5Acreate</a>), the stored datatype is used without copying it to the object. See item j in the figure below. In this case, if multiple objects are created using the same committed datatype, they all share the exact same datatype object. This saves space and makes clear that the datatype is shared. Note that a committed datatype can be shared by objects within the same HDF5 file, but not by objects in other files. For more information on copying committed datatypes to other HDF5 files, see the “Copying Committed Datatypes with H5Ocopy” topic in the “Additional Resources” chapter.</p>
<p>A committed datatype can be deleted from the file by calling <a class="el" href="group___h5_l.html#ga5b4e7f59f5d4bdae94fd8ce6875295cf" title="Removes a link from a group.">H5Ldelete</a> which replaces <a class="el" href="group___h5_g.html#gacb843cbd5bbb816cfa9c855463d1e51c" title="Removes the link to an object from a group.">H5Gunlink</a>. See item i in the figure below. If one or more objects are still using the datatype, the committed datatype cannot be accessed with <a class="el" href="group___h5_t.html#ga1d14b407603fdcedfbed1f723784c209">H5Topen</a>, but will not be removed from the file until it is no longer used. <a class="el" href="group___c_o_m_p_o_u_n_d.html#gaf5de0eabe28246f040342e275b9a63eb" title="Returns the datatype of the specified member.">H5Tget_member_type</a> and similar calls will return a transient copy of the datatype.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig23.gif" alt=""/>
<div class="caption">
Life cycle of a datatype</div></div>
   </td></tr>
</table>
<p>Transient datatypes are initially modifiable. Note that when a datatype is copied or when it is written to the file (when an object is created) or the datatype is used to create a composite datatype, a copy of the current state of the datatype is used. If the datatype is then modified, the changes have no effect on datasets, attributes, or datatypes that have already been created. See the figure below.</p>
<p>A transient datatype can be made read-only (<a class="el" href="group___h5_t.html#ga523642dbf4c60a83127fff87664a965b" title="Locks a datatype.">H5Tlock</a>). Note that the datatype is still transient, and otherwise does not change. A datatype that is immutable is read-only but cannot be closed except when the entire library is closed. The predefined types such as <a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a> are immutable transient types.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig24.gif" alt=""/>
<div class="caption">
Transient datatype states: modifiable, read-only, and immutable</div></div>
   </td></tr>
</table>
<p>To create two or more datasets that share a common datatype, first commit the datatype, and then use that datatype to create the datasets. See the example below. <em> Create a shareable datatype</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> t1 = ...some transient type...;</div>
<div class="line"><a class="code hl_define" href="group___h5_t.html#ga9a224eb59f0ba807789e3f8ba3a840cd">H5Tcommit</a> (file, “shared_type”, t1, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset1 = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> (file, “dset1”, t1, space, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset2 = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> (file, “dset2”, t1, space, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset1 = <a class="code hl_define" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a> (file, “dset1”, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> t2 = <a class="code hl_function" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb">H5Dget_type</a> (dset1);</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset3 = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> (file, “dset3”, t2, space, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset4 = <a class="code hl_define" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a> (file, “dset4”, t2, space, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="ttc" id="agroup___h5_t_html_ga9a224eb59f0ba807789e3f8ba3a840cd"><div class="ttname"><a href="group___h5_t.html#ga9a224eb59f0ba807789e3f8ba3a840cd">H5Tcommit</a></div><div class="ttdeci">#define H5Tcommit</div><div class="ttdef"><b>Definition</b> H5version.h:1261</div></div>
</div><!-- fragment --><table class="doxtable">
<caption>Datatype APIs</caption>
<tr>
<th>Function </th><th>Description  </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> <a class="code hl_define" href="group___h5_t.html#ga1d14b407603fdcedfbed1f723784c209">H5Topen</a> (<a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> location, <span class="keyword">const</span> <span class="keywordtype">char</span> *name)</div>
<div class="ttc" id="agroup___h5_t_html_ga1d14b407603fdcedfbed1f723784c209"><div class="ttname"><a href="group___h5_t.html#ga1d14b407603fdcedfbed1f723784c209">H5Topen</a></div><div class="ttdeci">#define H5Topen</div><div class="ttdef"><b>Definition</b> H5version.h:1283</div></div>
</div><!-- fragment -->  </td><td>A committed datatype can be opened by calling this function, which returns a datatype identifier. The identifier should eventually be released by calling <a class="el" href="group___h5_t.html#gafcba4db244f6a4d71e99c6e72b8678f0" title="Releases a datatype.">H5Tclose()</a> to release resources. The committed datatype returned by this function is read-only or a negative value is returned for failure. The location is either a file or group identifier.   </td></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> <a class="code hl_define" href="group___h5_t.html#ga9a224eb59f0ba807789e3f8ba3a840cd">H5Tcommit</a> (<a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> location, <span class="keyword">const</span> <span class="keywordtype">char</span> *name, <a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)</div>
<div class="ttc" id="a_h5public_8h_html_a3b079ecf932a5c599499cf7e298af160"><div class="ttname"><a href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a></div><div class="ttdeci">int herr_t</div><div class="ttdef"><b>Definition</b> H5public.h:235</div></div>
</div><!-- fragment -->  </td><td>A transient datatype (not immutable) can be written to a file and turned into a committed datatype by calling this function. The location is either a file or group identifier and when combined with name refers to a new committed datatype.   </td></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5public_8h.html#aa8f6c28736dbd0f18388c67911d38aca">htri_t</a> <a class="code hl_function" href="group___h5_t.html#ga0eba38d8c49784269e71ac9fa79b0f0a">H5Tcommitted</a> (<a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> type)</div>
<div class="ttc" id="a_h5public_8h_html_aa8f6c28736dbd0f18388c67911d38aca"><div class="ttname"><a href="_h5public_8h.html#aa8f6c28736dbd0f18388c67911d38aca">htri_t</a></div><div class="ttdeci">int htri_t</div><div class="ttdef"><b>Definition</b> H5public.h:265</div></div>
<div class="ttc" id="agroup___h5_t_html_ga0eba38d8c49784269e71ac9fa79b0f0a"><div class="ttname"><a href="group___h5_t.html#ga0eba38d8c49784269e71ac9fa79b0f0a">H5Tcommitted</a></div><div class="ttdeci">htri_t H5Tcommitted(hid_t type_id)</div><div class="ttdoc">Determines whether a datatype is a committed type or a transient type.</div></div>
</div><!-- fragment -->  </td><td>A type can be queried to determine if it is a committed type or a transient type. If this function returns a positive value then the type is committed. Datasets which return committed datatypes with <a class="el" href="group___h5_d.html#ga7cd04b8332e8a0939b9973fbc500cadb" title="Returns an identifier for a copy of the datatype for a dataset.">H5Dget_type()</a> are able to share the datatype with other datasets in the same file.   </td></tr>
</table>
<h2><a class="anchor" id="subsec_datatype_transfer"></a>
Data Transfer: Datatype Conversion and Selection</h2>
<p>When data is transferred (write or read), the storage layout of the data elements may be different. For example, an integer might be stored on disk in big-endian byte order and read into memory with little-endian byte order. In this case, each data element will be transformed by the HDF5 Library during the data transfer.</p>
<p>The conversion of data elements is controlled by specifying the datatype of the source and specifying the intended datatype of the destination. The storage format on disk is the datatype specified when the dataset is created. The datatype of memory must be specified in the library call.</p>
<p>In order to be convertible, the datatype of the source and destination must have the same datatype class (with the exception of enumeration type). Thus, integers can be converted to other integers, and floats to other floats, but integers cannot (yet) be converted to floats. For each atomic datatype class, the possible conversions are defined. An enumeration datatype can be converted to an integer or a floating-point number datatype.</p>
<p>Basically, any datatype can be converted to another datatype of the same datatype class. The HDF5 Library automatically converts all properties. If the destination is too small to hold the source value then an overflow or underflow exception occurs. If a handler is defined with the <a class="el" href="group___d_x_p_l.html#ga10a80b29444d933da1aa2003f46cf003" title="Sets user-defined datatype conversion callback function.">H5Pset_type_conv_cb</a> function, it will be called. Otherwise, a default action will be performed. The table below summarizes the default actions.</p>
<table class="doxtable">
<caption>Default actions for datatype conversion exceptions</caption>
<tr>
<th>Datatype Class </th><th>Possible Exceptions </th><th>Default Action  </th></tr>
<tr>
<td>Integer </td><td>Size, offset, pad </td><td></td></tr>
<tr>
<td>Float </td><td>Size, offset, pad, ebits </td><td></td></tr>
<tr>
<td>String </td><td>Size </td><td>Truncates, zero terminate if required.  </td></tr>
<tr>
<td>Enumeration </td><td>No field </td><td>All bits set  </td></tr>
</table>
<p>For example, when reading data from a dataset, the source datatype is the datatype set when the dataset was created, and the destination datatype is the description of the storage layout in memory. The destination datatype must be specified in the <a class="el" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c" title="Reads raw data from a dataset into a provided buffer.">H5Dread</a> call. The example below shows an example of reading a dataset of 32-bit integers. The figure below the example shows the data transformation that is performed. <em>Specify the destination datatype with H5Dread</em> </p><div class="fragment"><div class="line"><span class="comment">// Stored as H5T_STD_BE32</span></div>
<div class="line"><span class="comment">// Use the native memory order in the destination</span></div>
<div class="line">mem_type_id = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line">status = <a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf);</div>
</div><!-- fragment --><table class="doxtable">
<caption>Layout of a datatype conversion</caption>
<tr>
<td><div class="image">
<img src="Dtypes_fig25a.gif" alt=""/>
</div>
<br  />
 <div class="image">
<img src="Dtypes_fig25b.gif" alt=""/>
</div>
<br  />
 <div class="image">
<img src="Dtypes_fig25c.gif" alt=""/>
</div>
   </td></tr>
</table>
<p>One thing to note in the example above is the use of the predefined native datatype <a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>. Recall that in this example, the data was stored as a 4-bytes in big-endian order. The application wants to read this data into an array of integers in memory. Depending on the system, the storage layout of memory might be either big or little-endian, so the data may need to be transformed on some platforms and not on others. The <a class="el" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a> type is set by the HDF5 Library to be the correct type to describe the storage layout of the memory on the system. Thus, the code in the example above will work correctly on any platform, performing a transformation when needed.</p>
<p>There are predefined native types for most atomic datatypes, and these can be combined in composite datatypes. In general, the predefined native datatypes should always be used for data stored in memory. Predefined native datatypes describe the storage properties of memory.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig26.gif" alt=""/>
<div class="caption">
An enum datatype conversion</div></div>
   </td></tr>
</table>
<p><em>Create an aligned and packed compound datatype</em> </p><div class="fragment"><div class="line"><span class="comment">// Stored as H5T_STD_BE32</span></div>
<div class="line"><span class="comment">// Use the native memory order in the destination</span></div>
<div class="line">mem_type_id = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line">status = <a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf);</div>
</div><!-- fragment --><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig27.gif" alt=""/>
<div class="caption">
Alignment of a compound datatype</div></div>
   </td></tr>
</table>
<p><em>Transfer some fields of a compound datatype</em> </p><div class="fragment"><div class="line"><span class="comment">// Stored as H5T_STD_BE32</span></div>
<div class="line"><span class="comment">// Use the native memory order in the destination</span></div>
<div class="line">mem_type_id = <a class="code hl_function" href="group___h5_t.html#gaec07efbab84f4e5b4ed22f010786be8e">H5Tcopy</a>(<a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>);</div>
<div class="line">status = <a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf);</div>
</div><!-- fragment --><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dtypes_fig28.gif" alt=""/>
<div class="caption">
Layout when an element is skipped</div></div>
   </td></tr>
</table>
<h2><a class="anchor" id="subsec_datatype_text"></a>
Text Descriptions of Datatypes: Conversion to and from</h2>
<p>HDF5 provides a means for generating a portable and human-readable text description of a datatype and for generating a datatype from such a text description. This capability is particularly useful for creating complex datatypes in a single step, for creating a text description of a datatype for debugging purposes, and for creating a portable datatype definition that can then be used to recreate the datatype on many platforms or in other applications.</p>
<p>These tasks are handled by two functions provided in the HDF5 Lite high-level library: </p><ul>
<li><a class="el" href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd" title="Creates an HDF5 datatype given a text description.">H5LTtext_to_dtype</a> Creates an HDF5 datatype in a single step. </li>
<li><a class="el" href="group___h5_l_t.html#ga6ec5b6204c4cddc5bd323918e51755dc" title="Creates a text description of an HDF5 datatype.">H5LTdtype_to_text</a> Translates an HDF5 datatype into a text description.</li>
</ul>
<p>Note that this functionality requires that the HDF5 High-Level Library (H5LT) be installed.</p>
<p>While <a class="el" href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd" title="Creates an HDF5 datatype given a text description.">H5LTtext_to_dtype</a> can be used to generate any sort of datatype, it is particularly useful for complex datatypes.</p>
<p><a class="el" href="group___h5_l_t.html#ga6ec5b6204c4cddc5bd323918e51755dc" title="Creates a text description of an HDF5 datatype.">H5LTdtype_to_text</a> is most likely to be used in two sorts of situations: when a datatype must be closely examined for debugging purpose or to create a portable text description of the datatype that can then be used to recreate the datatype on other platforms or in other applications.</p>
<p>These two functions work for all valid HDF5 datatypes except time, bitfield, and reference datatypes.</p>
<p>The currently supported text format used by <a class="el" href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd" title="Creates an HDF5 datatype given a text description.">H5LTtext_to_dtype</a> and <a class="el" href="group___h5_l_t.html#ga6ec5b6204c4cddc5bd323918e51755dc" title="Creates a text description of an HDF5 datatype.">H5LTdtype_to_text</a> is the data description language (DDL) and conforms to the <a class="el" href="_d_d_l_b_n_f110.html">DDL in BNF through HDF5 1.10</a>. The portion of the <a class="el" href="_d_d_l_b_n_f110.html">DDL in BNF through HDF5 1.10</a> that defines HDF5 datatypes appears below. <em>The definition of HDF5 datatypes from the HDF5 DDL</em> </p><div class="fragment"><div class="line">&lt;datatype&gt; ::= &lt;atomic_type&gt; | &lt;compound_type&gt; | &lt;variable_length_type&gt; | &lt;array_type&gt;</div>
<div class="line"> </div>
<div class="line">&lt;atomic_type&gt; ::= &lt;integer&gt; | &lt;<span class="keywordtype">float</span>&gt; | &lt;time&gt; | &lt;<span class="keywordtype">string</span>&gt; |</div>
<div class="line">                  &lt;bitfield&gt; | &lt;opaque&gt; | &lt;reference&gt; | &lt;<span class="keyword">enum</span>&gt;</div>
<div class="line">&lt;integer&gt; ::= <a class="code hl_define" href="group___p_d_t_s_t_d.html#gafc97668c32b74f7d20dec0d0d2f47e4f">H5T_STD_I8BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#gaeaa5eb139424ba27d5af8925f1aa9593">H5T_STD_I8LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_s_t_d.html#gadc0ccea703096e20a4c3e51e858836dd">H5T_STD_I16BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#gaf88985315398de5fc4a716707b5c7694">H5T_STD_I16LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga37e8a6be7ee64587c2a282b965019bb8">H5T_STD_I32BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga7a14305593830bbe08a622642eae928c">H5T_STD_I64BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga591a85b894eab3e3ab1a2ccd9b3be565">H5T_STD_I64LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga10b5774adca6e8432615dac892e13ed9">H5T_STD_U8BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#gae641eb8f98d930fe5ddd3a04adb98383">H5T_STD_U8LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga10e46ab72ac0330c51ed6cf709db4697">H5T_STD_U16BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga4c2494c16f3e9443af1d56a078e0db3c">H5T_STD_U16LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga320fc4cfe8e4a3d1ab9997c8e342780b">H5T_STD_U32BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#gaa03600cecf2cd9063346084e41eb82a3">H5T_STD_U32LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga417489ff74b1cc52d25259c6357dcc6b">H5T_STD_U64BE</a> | <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga3a38267be678af40576a380617e3fff9">H5T_STD_U64LE</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga7439560bc4ef6d995a4e35b30262e660">H5T_NATIVE_CHAR</a> | <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga39cadf50f1701a2af3afa86eba3c7cbd">H5T_NATIVE_UCHAR</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae0625357fa121eca117f7fa9c4701810">H5T_NATIVE_SHORT</a> | <a class="code hl_define" href="group___p_d_t_n_a_t.html#gad0a240282e54647b83fe28ef65b40655">H5T_NATIVE_USHORT</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a> | <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga904b507c7b8aa4838fbb7c6ce71a37c5">H5T_NATIVE_UINT</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga290b9655882754ee0ec9f31b42ac04f6">H5T_NATIVE_LONG</a> | <a class="code hl_define" href="group___p_d_t_n_a_t.html#gacaea6c2c381167bacf67f6d6c43eb718">H5T_NATIVE_ULONG</a> |</div>
<div class="line">              <a class="code hl_define" href="group___p_d_t_n_a_t.html#gafb9c5d393d693869d7d21f71753a532c">H5T_NATIVE_LLONG</a> | <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga91ed0d2ce3289ef3707449cf5babe928">H5T_NATIVE_ULLONG</a></div>
<div class="line">&lt;<span class="keywordtype">float</span>&gt; ::= <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga71d24a7d4c373ed9a003d7a0d8133f1e">H5T_IEEE_F32BE</a> | <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga994ce9ffdd2c77a9352b102a883503ea">H5T_IEEE_F32LE</a> |</div>
<div class="line">            <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#gaf5064f4498d92e5992a5a0564d026d35">H5T_IEEE_F64BE</a> | <a class="code hl_define" href="group___p_d_t_i_e_e_e.html#ga3f9c2185ec16632fab8c20ec7a63178e">H5T_IEEE_F64LE</a> |</div>
<div class="line">            <a class="code hl_define" href="group___p_d_t_n_a_t.html#gae2523b63144b498f555fa4d04f59ee1c">H5T_NATIVE_FLOAT</a> | <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga087f3b793a299e416bd68678c2ef7c09">H5T_NATIVE_DOUBLE</a> |</div>
<div class="line">            <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga6b68c680440c463ce03c5efbf8cdf1c0">H5T_NATIVE_LDOUBLE</a></div>
<div class="line">&lt;time&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a8d3af61b1a73c5682f7f9b131754f6e3">H5T_TIME</a>: not yet implemented</div>
<div class="line">&lt;<span class="keywordtype">string</span>&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a2de5d7919fe54466b7cf6a6c0b4265fa">H5T_STRING</a> {</div>
<div class="line">                 STRSIZE &lt;strsize&gt; ;</div>
<div class="line">                 STRPAD &lt;strpad&gt; ;</div>
<div class="line">                 CSET &lt;cset&gt; ;</div>
<div class="line">                 CTYPE &lt;ctype&gt; ;</div>
<div class="line">             }</div>
<div class="line">&lt;strsize&gt; ::= &lt;int_value&gt;</div>
<div class="line">&lt;strpad&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a23c685afc240bbac4da23b36d8fd7e13">H5T_STR_NULLTERM</a> | <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a128d51156e51b7a2c9db0fe8787b4547">H5T_STR_NULLPAD</a> | <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a3f73f8dae99444798f5efd7d2d2a5e5c">H5T_STR_SPACEPAD</a></div>
<div class="line">&lt;cset&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa27383e03d1cad9b4c32d8611a145d663">H5T_CSET_ASCII</a> | <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa41685667f69bf81eb7de5dd5f452e658">H5T_CSET_UTF8</a></div>
<div class="line">&lt;ctype&gt; ::= <a class="code hl_define" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a> | <a class="code hl_define" href="group___p_d_t_s.html#ga62335f6f57c2809fa1b3b1f9472eb2f6">H5T_FORTRAN_S1</a></div>
<div class="line"> </div>
<div class="line">&lt;bitfield&gt; ::= <a class="code hl_define" href="group___p_d_t_s_t_d.html#gaaa2c22c363edaa8587e954d88cc67f2a">H5T_STD_B8BE</a>     | <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga8ecfe3ba07af971949a94b157f518940">H5T_STD_B8LE</a>      |</div>
<div class="line">               <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga1eadeed01d1dfee62689a51acac1a159">H5T_STD_B16BE</a>    | <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga61fa8825fb07bcdaa285967fa3f3bcb9">H5T_STD_B16LE</a>     |</div>
<div class="line">               <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga556365dedd52e74e13d198071d47da1d">H5T_STD_B32BE</a>    | <a class="code hl_define" href="group___p_d_t_s_t_d.html#gad166a8c49ae8af0ce1fe7812bdb90e19">H5T_STD_B32LE</a>     |</div>
<div class="line">               <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga56eb9e49fe4ea45dc80ee6bbe0880625">H5T_STD_B64BE</a>    | <a class="code hl_define" href="group___p_d_t_s_t_d.html#ga195cc861daefb50256990b68545444d8">H5T_STD_B64LE</a></div>
<div class="line"> </div>
<div class="line">&lt;opaque&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aaf11325a64ed5369e88d8d0d600b5cce">H5T_OPAQUE</a> {</div>
<div class="line">                 OPAQUE_TAG &lt;identifier&gt;;</div>
<div class="line">                 OPAQUE_SIZE &lt;int_value&gt;;opt</div>
<div class="line">             }</div>
<div class="line"> </div>
<div class="line">&lt;reference&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5850e0b9353a5e7aeb615fb943d4e9cd">H5T_REFERENCE</a> { &lt;ref_type&gt; }</div>
<div class="line">&lt;ref_type&gt; ::= H5T_STD_REF_OBJECT | <a class="code hl_define" href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a></div>
<div class="line"> </div>
<div class="line">&lt;compound_type&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> {</div>
<div class="line">                        &lt;member_type_def&gt;+</div>
<div class="line">                    }</div>
<div class="line">&lt;member_type_def&gt; ::= &lt;datatype&gt; &lt;field_name&gt;;</div>
<div class="line">&lt;field_name&gt; ::= &lt;identifier&gt;</div>
<div class="line"> </div>
<div class="line">&lt;variable_length_type&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2ad8ff83b6b7ca22575263561221193028">H5T_VLEN</a> { &lt;datatype&gt; }</div>
<div class="line"> </div>
<div class="line">&lt;array_type&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a> { &lt;dim_sizes&gt; &lt;datatype&gt; }</div>
<div class="line">&lt;dim_sizes&gt; ::= <span class="charliteral">&#39;[&#39;</span>&lt;dimsize&gt;<span class="charliteral">&#39;]&#39;</span> | <span class="charliteral">&#39;[&#39;</span>&lt;dimsize&gt;<span class="charliteral">&#39;]&#39;</span>&lt;dim_sizes&gt;</div>
<div class="line">&lt;dimsize&gt; ::= &lt;int_value&gt;</div>
<div class="line"> </div>
<div class="line">&lt;<span class="keyword">enum</span>&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5ee305303f12787367ac271d8f28f2e6">H5T_ENUM</a> {</div>
<div class="line">               &lt;enum_base_type&gt; &lt;enum_def&gt;+</div>
<div class="line">           }</div>
<div class="line">&lt;enum_base_type&gt; ::= &lt;integer&gt;</div>
<div class="line"><span class="comment">// Currently enums can only hold integer type data, but they may be expanded</span></div>
<div class="line"><span class="comment">// in the future to hold any datatype</span></div>
<div class="line">&lt;enum_def&gt; ::= &lt;enum_symbol&gt; &lt;enum_val&gt;;</div>
<div class="line">&lt;enum_symbol&gt; ::= &lt;identifier&gt;</div>
<div class="line">&lt;enum_val&gt; ::= &lt;int_value&gt;</div>
<div class="ttc" id="a_h5_tpublic_8h_html_a03755b8370672668ddc7063add28e71aa41685667f69bf81eb7de5dd5f452e658"><div class="ttname"><a href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa41685667f69bf81eb7de5dd5f452e658">H5T_CSET_UTF8</a></div><div class="ttdeci">@ H5T_CSET_UTF8</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:96</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2a5850e0b9353a5e7aeb615fb943d4e9cd"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a5850e0b9353a5e7aeb615fb943d4e9cd">H5T_REFERENCE</a></div><div class="ttdeci">@ H5T_REFERENCE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:39</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2a8d3af61b1a73c5682f7f9b131754f6e3"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a8d3af61b1a73c5682f7f9b131754f6e3">H5T_TIME</a></div><div class="ttdeci">@ H5T_TIME</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:34</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2aaf11325a64ed5369e88d8d0d600b5cce"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aaf11325a64ed5369e88d8d0d600b5cce">H5T_OPAQUE</a></div><div class="ttdeci">@ H5T_OPAQUE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:37</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_a071841985f647f69516dbe77d93167f2ad8ff83b6b7ca22575263561221193028"><div class="ttname"><a href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2ad8ff83b6b7ca22575263561221193028">H5T_VLEN</a></div><div class="ttdeci">@ H5T_VLEN</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:41</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_ad2ab726f3bd28222a2ffb91c6bbc3514a128d51156e51b7a2c9db0fe8787b4547"><div class="ttname"><a href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a128d51156e51b7a2c9db0fe8787b4547">H5T_STR_NULLPAD</a></div><div class="ttdeci">@ H5T_STR_NULLPAD</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:121</div></div>
<div class="ttc" id="a_h5_tpublic_8h_html_ad2ab726f3bd28222a2ffb91c6bbc3514a3f73f8dae99444798f5efd7d2d2a5e5c"><div class="ttname"><a href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a3f73f8dae99444798f5efd7d2d2a5e5c">H5T_STR_SPACEPAD</a></div><div class="ttdeci">@ H5T_STR_SPACEPAD</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:122</div></div>
<div class="ttc" id="agroup___p_d_t_i_e_e_e_html_ga71d24a7d4c373ed9a003d7a0d8133f1e"><div class="ttname"><a href="group___p_d_t_i_e_e_e.html#ga71d24a7d4c373ed9a003d7a0d8133f1e">H5T_IEEE_F32BE</a></div><div class="ttdeci">#define H5T_IEEE_F32BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:256</div></div>
<div class="ttc" id="agroup___p_d_t_i_e_e_e_html_gaf5064f4498d92e5992a5a0564d026d35"><div class="ttname"><a href="group___p_d_t_i_e_e_e.html#gaf5064f4498d92e5992a5a0564d026d35">H5T_IEEE_F64BE</a></div><div class="ttdeci">#define H5T_IEEE_F64BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:266</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga290b9655882754ee0ec9f31b42ac04f6"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga290b9655882754ee0ec9f31b42ac04f6">H5T_NATIVE_LONG</a></div><div class="ttdeci">#define H5T_NATIVE_LONG</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:777</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga39cadf50f1701a2af3afa86eba3c7cbd"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga39cadf50f1701a2af3afa86eba3c7cbd">H5T_NATIVE_UCHAR</a></div><div class="ttdeci">#define H5T_NATIVE_UCHAR</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:752</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga6b68c680440c463ce03c5efbf8cdf1c0"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga6b68c680440c463ce03c5efbf8cdf1c0">H5T_NATIVE_LDOUBLE</a></div><div class="ttdeci">#define H5T_NATIVE_LDOUBLE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:807</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga91ed0d2ce3289ef3707449cf5babe928"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga91ed0d2ce3289ef3707449cf5babe928">H5T_NATIVE_ULLONG</a></div><div class="ttdeci">#define H5T_NATIVE_ULLONG</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:792</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_gacaea6c2c381167bacf67f6d6c43eb718"><div class="ttname"><a href="group___p_d_t_n_a_t.html#gacaea6c2c381167bacf67f6d6c43eb718">H5T_NATIVE_ULONG</a></div><div class="ttdeci">#define H5T_NATIVE_ULONG</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:782</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_gad0a240282e54647b83fe28ef65b40655"><div class="ttname"><a href="group___p_d_t_n_a_t.html#gad0a240282e54647b83fe28ef65b40655">H5T_NATIVE_USHORT</a></div><div class="ttdeci">#define H5T_NATIVE_USHORT</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:762</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_gae0625357fa121eca117f7fa9c4701810"><div class="ttname"><a href="group___p_d_t_n_a_t.html#gae0625357fa121eca117f7fa9c4701810">H5T_NATIVE_SHORT</a></div><div class="ttdeci">#define H5T_NATIVE_SHORT</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:757</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_gafb9c5d393d693869d7d21f71753a532c"><div class="ttname"><a href="group___p_d_t_n_a_t.html#gafb9c5d393d693869d7d21f71753a532c">H5T_NATIVE_LLONG</a></div><div class="ttdeci">#define H5T_NATIVE_LLONG</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:787</div></div>
<div class="ttc" id="agroup___p_d_t_s_html_ga62335f6f57c2809fa1b3b1f9472eb2f6"><div class="ttname"><a href="group___p_d_t_s.html#ga62335f6f57c2809fa1b3b1f9472eb2f6">H5T_FORTRAN_S1</a></div><div class="ttdeci">#define H5T_FORTRAN_S1</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:486</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga10b5774adca6e8432615dac892e13ed9"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga10b5774adca6e8432615dac892e13ed9">H5T_STD_U8BE</a></div><div class="ttdeci">#define H5T_STD_U8BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:325</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga10e46ab72ac0330c51ed6cf709db4697"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga10e46ab72ac0330c51ed6cf709db4697">H5T_STD_U16BE</a></div><div class="ttdeci">#define H5T_STD_U16BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:335</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga195cc861daefb50256990b68545444d8"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga195cc861daefb50256990b68545444d8">H5T_STD_B64LE</a></div><div class="ttdeci">#define H5T_STD_B64LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:400</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga1eadeed01d1dfee62689a51acac1a159"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga1eadeed01d1dfee62689a51acac1a159">H5T_STD_B16BE</a></div><div class="ttdeci">#define H5T_STD_B16BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:375</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga320fc4cfe8e4a3d1ab9997c8e342780b"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga320fc4cfe8e4a3d1ab9997c8e342780b">H5T_STD_U32BE</a></div><div class="ttdeci">#define H5T_STD_U32BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:345</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga3a38267be678af40576a380617e3fff9"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga3a38267be678af40576a380617e3fff9">H5T_STD_U64LE</a></div><div class="ttdeci">#define H5T_STD_U64LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:360</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga417489ff74b1cc52d25259c6357dcc6b"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga417489ff74b1cc52d25259c6357dcc6b">H5T_STD_U64BE</a></div><div class="ttdeci">#define H5T_STD_U64BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:355</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga4c2494c16f3e9443af1d56a078e0db3c"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga4c2494c16f3e9443af1d56a078e0db3c">H5T_STD_U16LE</a></div><div class="ttdeci">#define H5T_STD_U16LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:340</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga556365dedd52e74e13d198071d47da1d"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga556365dedd52e74e13d198071d47da1d">H5T_STD_B32BE</a></div><div class="ttdeci">#define H5T_STD_B32BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:385</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga56eb9e49fe4ea45dc80ee6bbe0880625"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga56eb9e49fe4ea45dc80ee6bbe0880625">H5T_STD_B64BE</a></div><div class="ttdeci">#define H5T_STD_B64BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:395</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga591a85b894eab3e3ab1a2ccd9b3be565"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga591a85b894eab3e3ab1a2ccd9b3be565">H5T_STD_I64LE</a></div><div class="ttdeci">#define H5T_STD_I64LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:320</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga61fa8825fb07bcdaa285967fa3f3bcb9"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga61fa8825fb07bcdaa285967fa3f3bcb9">H5T_STD_B16LE</a></div><div class="ttdeci">#define H5T_STD_B16LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:380</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga7a14305593830bbe08a622642eae928c"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga7a14305593830bbe08a622642eae928c">H5T_STD_I64BE</a></div><div class="ttdeci">#define H5T_STD_I64BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:315</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_ga8ecfe3ba07af971949a94b157f518940"><div class="ttname"><a href="group___p_d_t_s_t_d.html#ga8ecfe3ba07af971949a94b157f518940">H5T_STD_B8LE</a></div><div class="ttdeci">#define H5T_STD_B8LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:370</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gaa03600cecf2cd9063346084e41eb82a3"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gaa03600cecf2cd9063346084e41eb82a3">H5T_STD_U32LE</a></div><div class="ttdeci">#define H5T_STD_U32LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:350</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gaaa2c22c363edaa8587e954d88cc67f2a"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gaaa2c22c363edaa8587e954d88cc67f2a">H5T_STD_B8BE</a></div><div class="ttdeci">#define H5T_STD_B8BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:365</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gad166a8c49ae8af0ce1fe7812bdb90e19"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gad166a8c49ae8af0ce1fe7812bdb90e19">H5T_STD_B32LE</a></div><div class="ttdeci">#define H5T_STD_B32LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:390</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gadc0ccea703096e20a4c3e51e858836dd"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gadc0ccea703096e20a4c3e51e858836dd">H5T_STD_I16BE</a></div><div class="ttdeci">#define H5T_STD_I16BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:295</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gae641eb8f98d930fe5ddd3a04adb98383"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gae641eb8f98d930fe5ddd3a04adb98383">H5T_STD_U8LE</a></div><div class="ttdeci">#define H5T_STD_U8LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:330</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gaf5cb0d5cec3d40d8b3ac27512f86895e"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a></div><div class="ttdeci">#define H5T_STD_REF_DSETREG</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:410</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gaf88985315398de5fc4a716707b5c7694"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gaf88985315398de5fc4a716707b5c7694">H5T_STD_I16LE</a></div><div class="ttdeci">#define H5T_STD_I16LE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:300</div></div>
<div class="ttc" id="agroup___p_d_t_s_t_d_html_gafc97668c32b74f7d20dec0d0d2f47e4f"><div class="ttname"><a href="group___p_d_t_s_t_d.html#gafc97668c32b74f7d20dec0d0d2f47e4f">H5T_STD_I8BE</a></div><div class="ttdeci">#define H5T_STD_I8BE</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:285</div></div>
</div><!-- fragment --><p><em> Old definitions of the opaque and compound datatypes</em> </p><div class="fragment"><div class="line">&lt;opaque&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2aaf11325a64ed5369e88d8d0d600b5cce">H5T_OPAQUE</a> { &lt;identifier&gt; }</div>
<div class="line">&lt;compound_type&gt; ::= <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a> { &lt;member_type_def&gt;+ }</div>
<div class="line">&lt;member_type_def&gt; ::= &lt;datatype&gt; &lt;field_name&gt; ;</div>
<div class="line">&lt;field_name&gt; ::= &lt;identifier&gt;</div>
</div><!-- fragment --><h4>Examples</h4>
<p>The code sample below illustrates the use of <a class="el" href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd" title="Creates an HDF5 datatype given a text description.">H5LTtext_to_dtype</a> to generate a variable-length string datatype.</p>
<p><em>Creating a variable-length string datatype from a text description</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dtype;</div>
<div class="line"><span class="keywordflow">if</span>((dtype = <a class="code hl_function" href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd">H5LTtext_to_dtype</a>(</div>
<div class="line">   “H5T_STRING {</div>
<div class="line">      STRSIZE <a class="code hl_define" href="_h5_tpublic_8h.html#a5185e14efde13b48249fe391324331bc">H5T_VARIABLE</a>;</div>
<div class="line">      STRPAD <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#ad2ab726f3bd28222a2ffb91c6bbc3514a128d51156e51b7a2c9db0fe8787b4547">H5T_STR_NULLPAD</a>;</div>
<div class="line">      CSET <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a03755b8370672668ddc7063add28e71aa27383e03d1cad9b4c32d8611a145d663">H5T_CSET_ASCII</a>;</div>
<div class="line">      CTYPE <a class="code hl_define" href="group___p_d_t_s.html#ga7f6b6959fefe56d2e871659110936d2d">H5T_C_S1</a>;</div>
<div class="line">   }”, <a class="code hl_enumvalue" href="_h5_l_tpublic_8h.html#afe4d47e38833b425f23f15bdbd14fd63a158bbaa59144a89547203f8e95421911">H5LT_DDL</a>)) &lt; 0)</div>
<div class="line"><span class="keywordflow">goto</span> out;</div>
<div class="ttc" id="a_h5_l_tpublic_8h_html_afe4d47e38833b425f23f15bdbd14fd63a158bbaa59144a89547203f8e95421911"><div class="ttname"><a href="_h5_l_tpublic_8h.html#afe4d47e38833b425f23f15bdbd14fd63a158bbaa59144a89547203f8e95421911">H5LT_DDL</a></div><div class="ttdeci">@ H5LT_DDL</div><div class="ttdef"><b>Definition</b> H5LTpublic.h:27</div></div>
<div class="ttc" id="agroup___h5_l_t_html_ga107d1c8619493704ae501e55dd669efd"><div class="ttname"><a href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd">H5LTtext_to_dtype</a></div><div class="ttdeci">H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type)</div><div class="ttdoc">Creates an HDF5 datatype given a text description.</div></div>
</div><!-- fragment --><p>The code sample below illustrates the use of <a class="el" href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd" title="Creates an HDF5 datatype given a text description.">H5LTtext_to_dtype</a> to generate a complex array datatype.</p>
<p><em>Creating a complex array datatype from a text description</em> </p><div class="fragment"><div class="line"><a class="code hl_typedef" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dtype;</div>
<div class="line"><span class="keywordflow">if</span>((dtype = <a class="code hl_function" href="group___h5_l_t.html#ga107d1c8619493704ae501e55dd669efd">H5LTtext_to_dtype</a>(</div>
<div class="line">   “H5T_ARRAY { [5][7][13] <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a547a4451911e912127f300ab15113854">H5T_ARRAY</a></div>
<div class="line">      { [17][19] <a class="code hl_enumvalue" href="_h5_tpublic_8h.html#a071841985f647f69516dbe77d93167f2a7a401c61604dc846dbd3f9eb6fcb0fe6">H5T_COMPOUND</a></div>
<div class="line">         {</div>
<div class="line">            H5T_STD_I8BE \“arr_compound_1\”;</div>
<div class="line">            H5T_STD_I32BE \“arr_compound_2\”;</div>
<div class="line">         }</div>
<div class="line">      }</div>
<div class="line">   }”, <a class="code hl_enumvalue" href="_h5_l_tpublic_8h.html#afe4d47e38833b425f23f15bdbd14fd63a158bbaa59144a89547203f8e95421911">H5LT_DDL</a>))&lt;0)</div>
<div class="line"><span class="keywordflow">goto</span> out;</div>
</div><!-- fragment --><p>Previous Chapter <a class="el" href="_h5_d__u_g.html#sec_dataset">HDF5 Datasets</a> - Next Chapter <a class="el" href="_h5_s__u_g.html#sec_dataspace">HDF5 Dataspaces and Partial I/O</a> </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.10.0 </li>
  </ul>
</div>
</body>
</html>