summaryrefslogtreecommitdiffstats
path: root/doc/html/H5.intro.html
blob: c574af1a927d423d9fbede3b09930deaeb641a1a (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
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>H5introH</TITLE>
</HEAD>
<BODY LINK="#0000ff" VLINK="#800080">



<!--
                         SOURCE FILE FOR THIS DOCUMENT
                     ../src/H5intro.doc  -- Microsoft Word
                  -------------------------------------------
                  This HTML file is derived from that source.
                         Edit ONLY the source document.
-->




<H1>Introduction to HDF5 1.0 Alpha2.0</H1>

<FONT FACE="Times"><P>This is a brief introduction to the HDF5 data model 

and programming model.  Being a <I>Getting Started</I> or <I>QuickStart</I> 

document, this </FONT><I>Introduction to HDF5</I> <FONT FACE="Times">is 

intended to provide enough information for you to develop a basic 

understanding of how HDF5 works and is meant to be used. Knowledge of the 

current version of HDF, will make it easier to follow the text, but it is 

not required.  More complete information, of the sort you will need to 

actually use HDF5, is available in the 
<A HREF="index.html">HDF5 documentation</A>. </FONT>


<FONT FACE="Times">.  Available documents include the following:</P>



<UL>

</FONT>

<I><LI><a href="H5.user.html">HDF5 User’s Guide</a></I>.

Where appropriate, this <I>Introduction</I> will refer to specific sections 

of the <I>User’s Guide</I>.</LI>

<I><LI><a href="RM_H5Front.html">HDF5 Reference Manual</a></I>

</LI></UL>



<FONT FACE="Times"><P>Code examples, that have been tested and work with the 

HDF5 library, are available in the source code tree when you install HDF5.</P>



<UL>

</FONT><LI>The directory<FONT FACE="Courier New" SIZE=2> hdf5/examples</FONT> 

contains the examples used in this document.</LI>

<LI>The directory<FONT FACE="Courier" SIZE=2> hdf5/test</FONT> contains the 

development tests used by the HDF5 developers.  Since these codes are intended 

to fully exercise the system, they provide more diverse and sophisticated 

examples of what HDF5 can do.</LI></UL>



<H2>What is the HDF5 prototype?</H2>

<FONT FACE="Times"><P>HDF5 is a new, experimental version of HDF that is 

designed to address some of the limitations of the current version of 

HDF (HDF4.x) and to address current and anticipated requirements of modern 

systems and applications. </P>

<P>This HDF5 prototype is not complete, but it should be sufficient show the 

basic features of HDF5. We urge you to look at it and give us feedback on 

what you like or do not like about it, and what features you would like to 

see added to it.</P>

<B><P>Why HDF5?</B> The development of HDF5 is motivated by a number of 

limitations in the current HDF format, as well as limitations in the library. 

Some of these limitations are:</P>



<UL>

</FONT><LI>A single file cannot store more than 20,000 complex objects, and 

a single file cannot be larger than 2 gigabytes </LI>

<LI>The data models are less consistent than they should be, there are more 

object types than necessary, and datatypes are too restricted. </LI>

<LI>The library source is old and overly complex, does not support parallel I/O 

effectively, and is difficult to use in threaded applications.</LI></UL>



<FONT FACE="Times"><P>When complete HDF5 will include the following improvements.</P>



<UL>

</FONT><LI>A new file format designed to address some of the deficiencies of 

HDF4.x, particularly the need to store larger files and more objects per file. </LI>

<LI>A simpler, more comprehensive data model that includes only two basic 

structures: a multidimensional array of record structures, and a grouping 

structure. </LI>

<LI>A simpler, better-engineered library and API, with improved support for 

parallel i/o, threads, and other requirements imposed by modern systems and 

applications.</LI></UL>



<H2>Limitations of the current prototype</H2>

<FONT FACE="Times"><P>The prototype release includes most of the <I>basic</I> 

functionality that is planned for the HDF5 library. However, the library does 

not implement all of the features detailed in the format and API specifications. 

Here is a listing of some of the limitations of the current release: </P>



<UL>

</FONT><LI>Data compression is supported, though only GZIP is implemented.  

GZIP, or GNU Zip, is a compression function from the GNU Project.</LI>

<LI>Some functions for manipulating datasets, dataspaces, and groups have not 

been implemented.</LI>

<FONT FACE="Times"><LI>Some number types, including user-defined number types 

are not supported. Also number type conversion is limited.</LI></UL>


This is the second alpha release of HDF5.  
Highlights of the changes since the first alpha release include:
<ul>
<li> Compressed datasets are supported.
<li> An improved Group API has been implemented.
<li> Attributes are now supported for datasets.
<li> A revised and improved Dataspace API has been implemented.
<li> Datatype conversion support is improved, especially for floating-point types.
<li> Support has been implemented for datasets and files over 2GB in size.
<li> Dataset storage in external files is supported.
<li> Support for parallel I/O of chunked datasets has been implemented.
<li> (A more detailed listing appears in the file hdf5/RELEASE in the alpha code installation.)
</ul>



<P>See the</FONT><CITE> <a href="RM_H5Front.html>HDF5 Reference Manual</a></CITE>


<FONT FACE="Times"> for a complete listing of all routines that have been 

implemented.</P>

</FONT><H2>HDF5 file organization and data model.</H2>

<FONT FACE="Times"><P>HDF5 files are organized in a hierarchical structure, 

with two primary structures: "groups" and "datasets."</P>



<UL>

</FONT><I><LI>HDF5 group: </I>a grouping structure containing instances of 

zero or more groups or datasets, together with supporting metadata </LI>

<I><LI>HD5F dataset:</I> a multidimensional array of data elements, together 

with supporting metadata. </LI></UL>



<FONT FACE="Times"><P>Working with groups and group members is similar in 

many ways to working with directories and files in UNIX. 

As with UNIX directories and files, objects in an HDF5 file are often 

described by giving their full path names. </P>

</FONT><CODE><DL>

<DD>/</CODE> signifies the root group. </DD>

<CODE><DD>/foo</CODE> signifies a member of the root group called 

<CODE>foo</CODE>.</DD>

<CODE><DD>/foo/zoo</CODE> signifies a member of the group <CODE>foo</CODE>, 

which in turn is a member of the root group.</DD>

</DL>

<FONT FACE="Times"><P>Any HDF5 group, dataset, or named datatype may have an 

associated <I>attribute list.</I> An HDF5 <I>attribute</I> is a user-defined 

HDF5 structure that provides extra information about an HDF5 object. 

Attributes are described in more detail below. </P>

</FONT><H3>HDF5 Groups</H3>

<FONT FACE="Times"><P>An<I> HDF5 group</I> is a structure containing zero or 

more HDF5 objects. A group has two parts:</P>



<UL>

</FONT><LI>A <I>group header</I>, which contains a group name and a list of 

group attributes. </LI>

<LI>A group symbol table, which is a list of the HDF5 objects that belong to 

the group.</LI></UL>



<H3>HDF5 Datasets</H3>

<FONT FACE="Times"><P>A dataset is stored in a file in two parts: a header 

and a data array. </P>

<P>The header contains information that is needed to interpret the array portion 

of the dataset, as well as metadata, or pointers to metadata, that describes or 

annotates the dataset. Header information includes the name of the object, its 

dimensionality, its number-type, information about how the data itself is stored 

on disk, and other information used by the library to speed up access to the 

dataset or maintain the file's integrity.</P>

<P>There are four essential classes of information in any header: <I>name</I>, 

<I>datatype</I>, <I>dataspace</I>, and <I>storage layout</I>:</P>

</FONT><B><DFN><P>Name.</B></DFN><FONT FACE="Times"> A dataset <I>name</I> is 

a sequence of alphanumeric ASCII characters.</P>

</FONT><B><DFN><P>Datatype.</B></DFN><FONT FACE="Times"> HDF5 allows one to 

define many different kinds of <B>datatypes</B>. There are two basic categories 

of data types: "atomic" types and "compound" types. Atomic types are those that 

are not decomposed at the data type interface level, such as integers and floats. 

Compound types are made up of atomic types. </P>

<I><P>Atomic datatypes</I> include integers and floating-point numbers. Each 

atomic type belongs to a particular class and has several properties: size, 

order, precision, and offset. In this introduction, we consider only a few of 

these properties.</P>

<P>Atomic datatypes include integer, float, date and time, string, bit field, 

and opaque. <I>(Note: Only integer and float classes are available in the 

current implementation.)</P>

</I><P>Properties of integer types include size, order (endian-ness), and 

signed-ness (signed/unsigned).</P>

<P>Properties of float types include the size and location of the exponent 

and mantissa, and the location of the sign bit.</P>

<P>The datatypes that are supported in the current implementation are: </P>



<UL>

</FONT><LI>Integer datatypes: 8-bit, 16-bit, 32-bit, and 64-bit integers in 

both little and big-endian format. </LI>

<LI>Floating-point numbers: IEEE 32-bit and 64-bit floating-point numbers in 

both little and big-endian format.</LI></UL>



<FONT FACE="Times"><P>A <I>compound datatype</I> is one in which a collection 

of simple datatypes are represented as a single unit, similar to a "struct" in C. 

The parts of a compound datatype are called <I>members.</I> The members of a 

compound datatype may be of any datatype, including another compound datatype. 

It is possible to read members from a compound type without reading the whole 

type.</P>

<B><DFN><P>Dataspace.</B> </DFN>A dataset <I>dataspace </I>describes the 

dimensionality of the dataset. The dimensions of a dataset can be fixed 

(unchanging), or they may be <I>unlimited</I>, which means that they are 

extendible (i.e. they can grow larger). </P>

<P>Properties of a dataspace consist of the <I>rank </I>(number of dimensions) 

of the data array, and the <I>actual sizes of the dimensions</I> of the array, 

and the <I>maximum sizes of the dimensions </I>of the array. 

For a fixed-dimension dataset, the actual size is the same as the maximum size 

of a dimension. When a dimension is unlimited, the maximum size is set to the 

</FONT>value <CODE>H5P_UNLIMITED</CODE>.<FONT FACE="Times"> (An example below 

shows how to create extendible datasets.)</P>

<P>A dataspace can also describe portions of a dataset, making it possible to 

do partial I/O (hyperslab) operations.</P>

<P>Since I/O operations have two end-points, the raw data transfer functions 

require two dataspace arguments: one describes the application memory dataspace 

or subset thereof, and the other describes the file dataspace or subset thereof.</P>

<P>See <I><a href="Dataspaces.html">Dataspaces</a></I>

</FONT>

<FONT FACE="Times"> in the<I> HDF User’s Guide</I> for further information.</P>

</FONT><B><DFN><P>Storage layout.</B></DFN><FONT FACE="Times"> The HDF5 format 

makes it possible to store data in a variety of ways. The default storage 

layout format is <I>contiguous</I>, meaning that data is stored in the same 

linear way that it is organized in memory. Two other storage layout formats 

are currently defined for HDF5: <I>compact, </I>and<I> chunked. </I>In the 

future, other storage layouts may be added.<I> </P>

<P>Compact</I> storage is used when the amount of data is small and can be 

stored directly in the object header. <I>(Note: Compact storage is not supported 

in this prototype.)</I> </P>

<I><P>Chunked</I> storage involves dividing the dataset into equal-sized "chunks" 

that are stored separately. Chunking has three important benefits. </P>

<OL>



<LI>It makes it possible to achieve good performance when accessing subsets of 

the datasets, even when the subset to be chosen is orthogonal to the normal 

storage order of the dataset. </LI>

<LI>It makes it possible to compress large datasets and still achieve good 

performance when accessing subsets of the dataset. </LI>

<LI>It makes it possible efficiently to extend the dimensions of a dataset in 

any direction.</LI></OL>



<P>See <I><a href="Datasets.html">Datasets</a></I> </FONT>


<FONT FACE="Times"> in the<I> HDF User’s Guide</I> for further information.</P>

</FONT><H3>HDF5 attributes</H3>

<FONT FACE="Times"><P>The Attribute API (H5A) is primarily designed to easily 

allow small datasets to be attached to primary datasets as metadata information. 

Additional goals for the H5A interface include keeping storage requirement for 

each attribute to a minimum and easily sharing attributes among datasets. </P>

<P>Because attributes are intended to be small objects, large datasets intended 

as additional information for a primary dataset should be stored as supplemental 

datasets in a group with the primary dataset. Attributes can then be attached to 

the group containing everything to indicate a particular type of dataset with 

supplemental datasets is located in the group. How small is "small" is not 

defined by the library and is up to the user's interpretation. </P>

<P>Attributes are not seperate objects in the file, they are always contained 

in the object header of the object they are attached to. The I/O functions 

defined in the H5A interface are required to read or write attribute information, 

not the H5D I/O routines. </P>

<P>See <I><a href="Attributes.html">Attributes</a></I>

</FONT>

<FONT FACE="Times"> in the<I> HDF User’s Guide</I> for further information.</P>

</FONT><H2>The HDF5 Applications Programming Interface (API)</H2>

<FONT FACE="Times"><P>The current HDF5 API is implemented only in C. The API 

provides routines for creating HDF5 files, creating and writing groups, datasets, 

and their attributes to HDF5 files, and reading groups, datasets and their 

attributes from HDF5 files.</P>

</FONT><H3>Naming conventions</H3>

<FONT FACE="Times"><P>All C routines on the HDF 5 library begin with a prefix of 

the form "H5*", where "*" is a single letter indicating the object on which the 

operation is to be performed:</P>



<UL>

</FONT><B><LI>H5F</B>: <B>F</B>ile-level access routines. <BR>

Example: <CODE>H5Fopen</CODE>, which opens an HDF5 file. </LI>

<B><LI>H5G</B>: <B>G</B>roup functions, for creating and operating on physical 

groups of objects. <BR>

Example: <CODE>H5Gset</CODE><FONT FACE="Courier">,</FONT>which sets the working 

group to the specified group. </LI>

<B><LI>H5T: </B>Data<B>T</B>ype functions, for creating and operating on simple 

and compound datatypes to be used as the elements in data arrays.<B><BR>

</B>Example: <CODE>H5Tcopy</CODE><FONT FACE="Courier">,</FONT>which creates a 

copy of an existing data type. </LI>

<B><LI>H5S: </B>Data<B>S</B>pace functions, which create and manipulate the 

dataspace in which the elements of a data array are stored.<BR>

Example: <CODE>H5Screate_simple</CODE>, which creates simple dataspaces. </LI>

<B><LI>H5D: D</B>ataset functions, which manipulate the data within datasets and 

determine how the data is to be stored in the file. <BR>

Example: <CODE>H5Dread</CODE>, which reads all or part of a dataset into a 

buffer in memory. </LI>

<B><LI>H5P</B>: <B>P</B>roperty list functions, for manipulating object creation 

and access properties. <BR>

Example: <CODE>H5Pset_chunk</CODE>, which sets the number of dimensions and the 

size of a chunk.</LI>

<B><LI>H5A</B>: <B>A</B>ttribute access and manipulating routines. <BR>

Example: <CODE>H5Aget_name</CODE>, which retrieves name of an attribute.</LI>

<B><LI>H5SZ</B>: <B>C</B>ompression registration routine. <BR>

Example: <CODE>H5Zregister</CODE>, which registers new compression and 

uncompression functions for use with the HDF5 library.</LI>

<B><LI>H5E</B>: <B>E</B>rror handling routines. <BR>

Example: <CODE>H5Eprint</CODE>, which prints the current error stack.</LI></UL>



<H3>Include files </H3>

<FONT FACE="Times"><P>There are a number definitions and declarations that 

should be included with any HDF5 program. These definitions and declarations 

are contained in several <I>include</I> files. The main include </FONT>file is 

<CODE>hdf5.h</CODE>. This file<FONT FACE="Times"> includes all of the other 

files that your program is likely to need. <I>Be sure to include hdf5.h in 

any program that accesses HDF5.</P>

</I></FONT><H3>Predefined atomic datatypes</H3>

<P>The datatype interface provides a mechanism to describe the storage format 

of individual data points of a data set and is designed to allow new features 

to be easily added without disrupting applications that use the datatype 

interface.  A dataset (the H5D interface) is composed of a collection or raw 

data points of homogeneous type organized according to the dataspace (the H5S 

interface).</P>

<P>A <DFN>datatype</DFN> is a collection of data type properties, all of which 

can be stored on disk, and which when taken as a whole, provide complete 

information for data conversion to or from that data type.  The interface 

provides functions to set and query properties of a data type.</P>

<P>A <DFN>data point</DFN> is an instance of a <DFN>data type</DFN>, which 

is an instance of a <DFN>type class</DFN>.  We have defined a set of type 

classes and properties which can be extended at a later time.  The 

<DFN>atomic type classes</DFN> are those which describe types which cannot 

be decomposed at the data type interface  level; all other classes are 

<DFN>compound</DFN>.</P>

<P>To illustrate, let us consider a set of predefined atomic datatypes. 

The library predefines a modest number of data types having names like

<CODE> H5T_<I>arch</I>_<I>base</I></CODE> where <I><CODE>arch</I> </CODE>is 

an architecture name and <I><CODE>base</I></CODE> is a programming type name.  

New types can be derived from the predifined types by copying the predefined 

type (see <CODE>H5Tcopy()</CODE>) and then modifying the result.</P>

<P>The<CODE> NATIVE </CODE>architecture, for example, contains C-like data types 

for the machine on which the library was compiled.  The types were actually 

defined by running the<CODE> H5detect </CODE>program when the library was 

compiled. In order to be portable, applications should almost always use this 

architecture to describe things in memory.</P>

<P>The <CODE>NATIVE</CODE> architecture has base names which do not follow the 

same rules as the others.  Instead, native type names are similar to the C type 

names.  Here are some examples:</P>

<P ALIGN="CENTER"><CENTER><TABLE BORDER CELLSPACING=1 CELLPADDING=7 WIDTH=462>

<TR><TD WIDTH="49%" VALIGN="TOP">

<B><P ALIGN="CENTER">Example</B></TD>

<TD WIDTH="51%" VALIGN="TOP">

<B><P ALIGN="CENTER">Corresponding C Type</B></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_CHAR</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<PRE>signed char</PRE></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_UCHAR</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>unsigned char</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_SHORT</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>short</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_USHORT</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>unsigned short</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_INT</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>int</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_UINT</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>unsigned</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_LONG</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>long</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_ULONG</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>unsigned long</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_LLONG</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>long long</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_ULLONG</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>unsigned long long</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_FLOAT</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<PRE>float</PRE></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_DOUBLE</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>double</FONT></TD>

</TR>

<TR><TD WIDTH="49%" VALIGN="TOP">

<FONT FACE="Courier New" SIZE=2><P>H5T_NATIVE_LDOUBLE</FONT></TD>

<TD WIDTH="51%" VALIGN="TOP">

<FONT SIZE=2><P>long double</FONT></TD>

</TR>

</TABLE>

</CENTER></P>



<FONT FACE="Times"><P>See <I><a href="Datatypes.html">Datatypes</a></I> at 

</FONT>

in the<I> HDF User’s Guide</I> for further information.</P>

</FONT><H3>Programming models</H3>

<FONT FACE="Times"><P>In this section we describe how to program some basic 

operations on files, including how to</P>



<UL>

</FONT><LI>create a file </LI>

<LI>create and initialize a dataset </LI>

<LI>discard objects when they are no longer needed </LI>

<LI>write a dataset to a new file </LI>

<LI>obtain information about a dataset </LI>

<LI>read a portion of a dataset </LI>

<LI>create and write compound datatypes </LI>

<LI>create and write extendible datasets </LI>

<LI>create and populate groups </LI></UL>



<H4>How to create an HDF5 file</H4>

<P>This programming model shows how to create a file and also how to close the 

file.</P>

<OL>



<LI>Create the file using <CODE>H5Fcreate</CODE>. Obtain a file identifier.</LI>

<LI>Close the file with <CODE>H5Fclose</CODE>.</LI>

<P>The following code fragment implements the specified model. If there is a 

possibility that the file already exists, the user must add the flag 

<CODE>H5ACC_TRUNC</CODE> to the access mode to overwrite the previous file's 

information. </P>

<CODE><PRE>hid_t       file;                          /* handle */

/*

 * Create a new file using H5ACC_TRUNC access,

 * default file creation properties, and default file

 * access properties.

 * Then close the file.

 */

file = H5Fcreate(FILE, H5ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

status = H5Fclose(file); </PRE>

</CODE>
</OL>



<H4>How to create and initialize the essential components of a dataset for 

writing to a file.</H4>

<P>Recall that datatypes and dimensionality (dataspace) are independent objects, 

which are created separately from any dataset that they might be attached to. 

Because of this the creation of a dataset requires, at a minimum, separate 

definitions of datatype, dimensionality, and dataset. Hence, to create a dataset 

the following steps need to be taken:</P>

<ol>
<FONT FACE="Times"><LI VALUE=1>Create and initialize a dataspace for the 

dataset to be written.</LI>

<LI>Define the datatype for the dataset to be written. </LI>

<LI>Create and initialize the dataset itself.</LI></OL>



</FONT><FONT FACE="Courier New"><P>&nbsp;</P>

</FONT><FONT FACE="Times"><P>The following code illustrates the creation of 

these three components of a dataset object.</P>

</FONT><CODE><PRE>hid_t    dataset, datatype, dataspace;   /* declare handles */



/* 

 * 1. Create dataspace: Describe the size of the array and 

 * create the data space for fixed size dataset. 

 */

dimsf[0] = NX;

dimsf[1] = NY;

dataspace = H5Pcreate_simple(RANK, dimsf, NULL); 

/*

/* 

 * 2. Define datatype for the data in the file.

 * We will store little endian integer numbers.

 */

datatype = H5Tcopy(H5T_NATIVE_INT);

status = H5Tset_order(datatype, H5T_ORDER_LE);

/*

 * 3. Create a new dataset within the file using defined 

 * dataspace and datatype and default dataset creation

 * properties.

 * NOTE: H5T_NATIVE_INT can be used as datatype if conversion

 * to little endian is not needed.

 */

dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace, H5P_DEFAULT);</PRE>

</CODE><H4>How to discard objects when they are no longer needed</H4>

<FONT FACE="Times"><P>The type, dataspace and dataset objects should be released

once they are no longer needed by a program. Since each is an independent object, 

the must be released (or <I>closed</I>) separately. The following lines of code 

close the type, dataspace, datasets, and file that were created in the preceding 

section.</P>

</FONT><CODE><P>H5Tclose(datatype);</P>

<P>H5Dclose(dataset);</P>

<P>H5Sclose(dataspace);</P>

</CODE><H4>How to write a dataset to a new file</H4>

<FONT FACE="Times"><P>Having defined the datatype, dataset, and dataspace 

parameters, you write out the data with a call to 

</FONT><CODE>H5Dwrite</CODE><FONT FACE="Courier">.</P>

</FONT><CODE><PRE>/*

 * Write the data to the dataset using default transfer

 * properties.

 */

status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,

                  H5P_DEFAULT, data);</PRE>

</CODE><FONT FACE="Times"><P>The third and fourth parameters of 

</FONT><CODE>H5Dwrite</CODE><FONT FACE="Times"> in the example describe the 

dataspaces in memory and in the file, respectively. They are set to the value 

</FONT><CODE>H5S_ALL</CODE><FONT FACE="Times"> to indicate that an entire 

dataset is to be written. In a later section we look at how we would access 

a portion of a dataset.</P>

</FONT><P><A HREF="#CreateExample"><FONT FACE="Times">Example 1</FONT></A>

<FONT FACE="Times"> contains a program that creates a file and a dataset, and 

writes the dataset to the file. </P>

<P>Reading is analogous to writing. If, in the previous example, we wish to 

read an entire dataset, we would use the same basic calls with the same 

parameters. Of course, the routine </FONT><CODE>H5Dread</CODE><FONT FACE="Times"> 

would replace </FONT><CODE>H5Dwrite</CODE><FONT FACE="Courier">.

</FONT><FONT FACE="Times"> </P>

</FONT><H4>Getting information about a dataset</H4>

<FONT FACE="Times"><P>Although reading is analogous to writing, it is often 

necessary to query a file to obtain information about a dataset. For instance, 

we often need to know about the datatype associated with a dataset, as well 

dataspace information (e.g. rank and dimensions). There are several "get" 

routines for obtaining this information The following code segment illustrates 

how we would get this kind of information: </P>

</FONT><CODE><PRE>/*

 * Get datatype and dataspace handles and then query

 * dataset class, order, size, rank and dimensions.

 */



datatype  = H5Dget_type(dataset);     /* datatype handle */ 

class     = H5Tget_class(datatype);

if (class == H5T_INTEGER) printf("Data set has INTEGER type \n");

order     = H5Tget_order(datatype);

if (order == H5T_ORDER_LE) printf("Little endian order \n");



size  = H5Tget_size(datatype);

printf(" Data size is %d \n", size);



dataspace = H5Dget_space(dataset);    /* dataspace handle */

rank      = H5Sextent_ndims(dataspace);

status_n  = H5Sextent_dims(dataspace, dims_out);

printf("rank %d, dimensions %d x %d \n", rank, dims_out[0], dims_out[1]);</PRE>

</CODE><H4>Reading a portion of a dataset</H4>

<FONT FACE="Times"><P>In the previous discussion, we describe how to access an 

entire dataset with one write (or read) operation. To read or write a 

<I>portion</I> of a dataset, we need to provide more contextual information.</P>

<P>Consider the following example. Suppose there is 500x600 dataset in a file, 

and we wish to read from the dataset a 100x200 hyperslab located beginning at 

element </FONT><CODE>&lt;200,200&gt;</CODE><FONT FACE="Times">. In addition, 

suppose we wish to read the hyperslab into an 200x400 array in memory beginning 

at element </FONT><CODE>&lt;0,0&gt;</CODE><FONT FACE="Times"> in memory. 

Visually, the transfer looks something like this: </P>

</FONT><P ALIGN="CENTER"><IMG SRC="dataset_pl.gif" WIDTH=417 HEIGHT=337></P>

<FONT FACE="Times" SIZE=6><P ALIGN="CENTER">&nbsp;</P>

</FONT><FONT FACE="Times"><P>As the example illustrates, whenever we read part 

of a dataset from a file we must provide two dataspaces: the dataspace of the 

object in the file as well as the dataspace of the object in memory into which 

we read. There are dataspace routines (</FONT><CODE>H5S...</CODE>

<FONT FACE="Times">) for doing this. </P>

<P>For example, suppose we want to read a 3x4 hyperslab from a dataset in a 

file beginning at the element </FONT><CODE>&lt;1,2&gt;</CODE><FONT FACE="Times"> 

in the dataset. In order to do this, we must create a dataspace that describes 

the overall rank and dimensions of the dataset in the file, as well as the 

position and size of the hyperslab that we are extracting from that dataset. 

The following code illustrates how this would be done. </P>

</FONT><CODE><PRE>/* 

 * Get overall rank and dimensions of dataspace.

 */

dataspace = H5Dget_space(dataset);    /* get dataspace handle */

rank      = H5Pextent_ndims(dataspace);

status_n  = H5Pextent_dims(dataspace, dims_out);



/* 

 * Define hyperslab in the dataset. 

 */

offset[0] = 1;

offset[1] = 2;

count[0]  = 3;

count[1]  = 4;

status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);</PRE>

</CODE><FONT FACE="Times"><P>This describes the dataspace from which we wish 

to read. We need to define the dataspace in memory analogously. Suppose, for 

instance, that we have in memory a 3 dimensional 7x7x3 array into which we 

wish to read the 3x4 hyperslab described above beginning at the element 

</FONT><CODE>&lt;3,0,0&gt;</CODE><FONT FACE="Times">. Since the in-memory 

dataspace has three dimensions, we have to describe the hyperslab as an array 

with three dimensions, with the last dimension being 1: 

</FONT><CODE>&lt;3,4,1&gt;</CODE><FONT FACE="Times">.</P>

<P>Notice that now we must describe two things: the dimensions of the in-memory 

array, and the size and position of the hyperslab that we wish to read in. 

The following code illustrates how this would be done. </P>

</FONT><CODE><PRE>/*

 * Define the memory dataspace.

 */

dimsm[0] = 7;

dimsm[1] = 7;

dimsm[2] = 3;

memspace = H5Screate_simple(RANK_OUT,dimsm,NULL);   



/* 

 * Define memory hyperslab. 

 */

offset_out[0] = 3;

offset_out[1] = 0;

offset_out[2] = 0;

count_out[0]  = 3;

count_out[1]  = 4;

count_out[2]  = 1;

status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL, count_out, NULL);



/*</PRE>

</CODE><P><A HREF="#CheckAndReadExample"><FONT FACE="Times">Example 2</FONT></A>

<FONT FACE="Times"> contains a complete program that performs these operations.</P>

</FONT><H4>Creating compound datatypes</H4>

<B><P>Properties of compound datatypes. </B>A compound datatype is similar to 

a struct in C or a common block in Fortran. It is a collection of one or more 

atomic types or small arrays of such types. To create and use of a compound 

datatype requires you need to refer to various <DFN>properties</DFN> of the 

data compound datatype:</P>



<UL>

<LI>It is of class <DFN>compound</DFN><I>.</I> </LI>

<LI>It has a fixed total <DFN>size</DFN>, in bytes. </LI>

<LI>It consists of zero or more <DFN>members</DFN> (defined in any order) with 

unique names and which occupy non-overlapping regions within the datum. </LI>

<LI>Each member has its own <DFN>datatype</DFN>. </LI>

<LI>Each member is referenced by an <DFN>index number</DFN> between zero and N-1, 

where N is the number of members in the compound datatype. </LI>

<LI>Each member has a <DFN>name</DFN> which is unique among its siblings in a 

compound data type. </LI>

<LI>Each member has a fixed <DFN>byte offset</DFN>, which is the first byte 

(smallest byte address) of that member in a compound datatype. </LI>

<LI>Each member can be a small array of up to four dimensions.</LI></UL>



<FONT FACE="Times"><P>Properties of members of a compound data type are defined 

when the member is added to the compound type and cannot be subsequently 

modified.</P>

<B><P>Defining compound datatypes. </B>Compound datatypes must be built out of 

other datatypes. First, one creates an empty compound data type and specifies 

its total size. Then members are added to the compound data type in any order.</P>

<I><P>Member names. </I>Each member must have a descriptive name, which is the 

key used to uniquely identify the member within the compound data type. A member 

name in an HDF5 data type does not necessarily have to be the same as the name 

of the corresponding member in the C struct in memory, although this is often 

the case. Nor does one need to define all members of the C struct in the HDF5 

compound data type (or vice versa). </P>

<I><P>Offsets. </I>Usually a C struct 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 library 

defines the macro to compute the offset of a member within a struct:</P>

</FONT><CODE><P>HOFFSET(s,m)<FONT SIZE=5>. </FONT></CODE><FONT FACE="Times">This 

macro computes the offset of member </FONT><FONT FACE="Courier"><EM>m</EM> 

</FONT><FONT FACE="Times">within a struct variable <EM>s</EM>. </P>

<P>Here is an example in which a compound data type is created to describe 

complex numbers whose type is defined by the </FONT><CODE>complex_t</CODE>

<FONT FACE="Times" SIZE=2> </FONT><FONT FACE="Times">struct. </P>

</FONT><CODE><PRE>typedef struct {

   double re;   /*real part */

   double im;   /*imaginary part */

} complex_t;



complex_t tmp;  /*used only to compute offsets */

hid_t complex_id = H5Tcreate (H5T_COMPOUND, sizeof tmp);

H5Tinsert (complex_id, "real", HOFFSET(tmp,re),

           H5T_NATIVE_DOUBLE);

H5Tinsert (complex_id, "imaginary", HOFFSET(tmp,im),

           H5T_NATIVE_DOUBLE);</PRE>

</CODE><P><A HREF="#Compound">Example 3</A><FONT FACE="Times"> shows how to 

create a compound data type, write an array that has the compound data type 

to the file, and read back subsets of the members.</P>

</FONT><H4>Creating and writing extendible datasets</H4>

<FONT FACE="Times"><P>An <I>extendible</I> dataset is one whose dimensions 

can grow. In HDF5, it is possible to define a dataset to have certain initial 

dimensions, then later to increase the size of any of the initial dimensions. </P>

<P>For example, you can create and store the following 3x3 HDF5 dataset:</P>

</FONT><PRE>     1 1 1

     1 1 1 

     1 1 1 </PRE>

<FONT FACE="Times"><P>then later to extend this into a 10x3 dataset by adding 

7 rows, such as this:</P>

</FONT><PRE>     1 1 1 

     1 1 1 

     1 1 1 

     2 2 2

     2 2 2

     2 2 2

     2 2 2

     2 2 2

     2 2 2

     2 2 2</PRE>

<FONT FACE="Times"><P>then further extend it to a 10x5 dataset by adding two 

columns, such as this:</P>

</FONT><PRE>     1 1 1 3 3 

     1 1 1 3 3 

     1 1 1 3 3 

     2 2 2 3 3

     2 2 2 3 3

     2 2 2 3 3

     2 2 2 3 3

     2 2 2 3 3

     2 2 2 3 3

     2 2 2 3 3</PRE>

<FONT FACE="Times"><P>The current version of HDF 5 requires you to use 

<I>chunking</I> in order to define extendible datasets. Chunking makes 

it possible to extend datasets efficiently, without having to reorganize 

storage excessively. </P>

<P>Three operations are required in order to write an extendible dataset:</P>

<OL>



<LI>Declare the dataspace of the dataset to have <I>unlimited dimensions</I> 

for all dimensions that might eventually be extended.</LI>

<LI>When creating the dataset, set the storage layout for the dataset to 

<I>chunked</I>.</LI>

<LI>Extend the size of the dataset.</LI></OL>



<P>For example, suppose we wish to create a dataset similar to the one shown 

above. We want to start with a 3x3 dataset, then later extend it in both 

directions. </P>

<B><P>Declaring unlimited dimensions. </B>We could declare the dataspace 

to have unlimited dimensions with the following code, which uses the predefined 

constant </FONT><CODE>H5S_UNLIMITED</CODE><FONT FACE="Times"> to specify 

unlimited dimensions.</P>

</FONT><PRE>hsize_t dims[2] = { 3, 3}; /* dataset dimensions

at the creation time */ 

hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};

/*

* 1. Create the data space with unlimited dimensions. 

*/

dataspace = H5Screate_simple(RANK, dims, maxdims); </PRE>

<B><P>Enabling chunking.  </B>We can then modify the dataset storage layout 

properties to enable chunking.  We do this using the routine 

<CODE>H5Pset_chunk</CODE><FONT SIZE=4>:</P>

</FONT><PRE>hid_t cparms; 

hsize_t chunk_dims[2] ={2, 5};

/* 

* 2. Modify dataset creation properties to enable chunking.

*/

cparms = H5Pcreate (H5P_DATASET_CREATE);

status = H5Pset_chunk( cparms, RANK, chunk_dims);

</PRE>

<B><P>Extending dataset size.  </B>Finally, when we want to extend the size of 

the dataset, we invoke <CODE>H5Dextend </CODE>to extend the size of the dataset.  

In the following example, we extend the dataset along the first dimension, by 

seven rows, so that the new dimensions are <CODE>&lt;10,3&gt;</CODE>:</P>

<PRE>/*

* Extend the dataset. Dataset becomes 10 x 3.

*/

dims[0] = dims[0] + 7;

size[0] = dims[0]; 

size[1] = dims[1]; 

status = H5Dextend (dataset, size);</PRE>

<FONT FACE="Courier New" SIZE=2><P>&nbsp;</P>

</FONT><P><A HREF="#CreateExtendWrite">Example 4</A> shows how to create a 3x3 

extendible dataset, write the dataset, extend the dataset to 10x3, write the 

dataset again, extend it again to 10x5, write the dataset again.</P>

<P><A HREF="#ReadExtended">Example 5</A> shows how to read the data written by 

Example 4.  </P>

<H3>Working with groups in a file</H3>

<P>Groups provide a mechanism for organizing datasets in an HDF5 file extendable 

meaningful ways. The H5G API contains routines for working with groups. </P>

<B><P>To create a group</B>, use <CODE>H5Gcreate</CODE>.  For example, the 

following code creates two groups that are members of the root group.  They 

are called <CODE>/IntData</CODE> and <CODE>/FloatData</CODE>.  The return value 

(<CODE>dir</CODE>) is the group identifier.</P>

<CODE><PRE>/*

* Create two groups in a file.

*/

dir = H5Gcreate(file, "/IntData", 0);

status = H5Gclose(dir);

dir = H5Gcreate(file,"/FloatData", 0);

status = H5Gclose(dir);</PRE>

</CODE><P>The third parameter in <CODE>H5Gcreate</CODE> optionally specifies 

how much file space to reserve to store the names that will appear in this group. 

If a non-positive value is supplied then a default size is chosen.</P>

<CODE><P>H5Gclose</CODE> closes the group and releases the group identifier.</P>

<P>&nbsp;</P>

<B><P>Creating an object in a particular group. </B>Except for single-object 

HDF5 files, every object in an HDF5 file must belong to a group, and hence has 

a path name. Hence, we put an object in a particular group by giving its path 

name when we create it. For example, the following code creates a dataset 

<CODE>IntArray</CODE> in the group <CODE>/IntData</CODE>:</P>

<CODE><PRE>/*

 * Create dataset in the /IntData group by specifying full path.

 */

dims[0] = 2;

dims[1] = 3;

dataspace = H5Pcreate_simple(2, dims, NULL);

dataset = H5Dcreate(file, "/IntData/IntArray", H5T_NATIVE_INT, dataspace, H5C_DEFAULT); </PRE>

</CODE><B><P>Changing the current group. </B>The HDF5 Group API supports the 

idea of a <DFN>current group</DFN>. This is analogous to the 

<DFN>current working directory</DFN> idea in UNIX. You can set the current 

group in HDF5 with the routine <CODE>H5Gset</CODE>. The following code shows 

how to set a current group, then create a certain dataset (<CODE>FloatData</CODE>) 

in that group. </P>

<CODE><PRE>/*

 * Set current group to /FloatData.

 */

status = H5Gset (file, "/FloatData");



/* 

 * Create two datasets

 */



dims[0] = 5;

dims[1] = 10;

dataspace = H5Screate_simple(2, dims, NULL);

dataset = H5Dcreate(file, "FloatArray", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT); </PRE>

</CODE><P><A HREF="#CreateGroups">Example 6</A> shows how to create an 

HDF5 file with two group, and to place some datasets within those groups.</P>

<P>&nbsp;</P>

<H3>&nbsp;</H3>

<H3>Example code</H3>

<H4><A NAME="CreateExample">Example 1: How to create a homogeneous 

multi-dimensional dataset</A> and write it to a file.</H4>

<P>This example creates a 2-dimensional HDF 5 dataset of little endian 

32-bit integers.</P>

<PRE><A NAME="CheckAndReadExample">

/*  

 *  This example writes data to the HDF5 file.

 *  Data conversion is performed during write operation.  

 */

 

#include &lt;hdf5.h&gt;



#define FILE        "SDS.h5"

#define DATASETNAME "IntArray" 

#define NX     5                      /* dataset dimensions */

#define NY     6

#define RANK   2



main ()

{

   hid_t       file, dataset;         /* file and dataset handles */

   hid_t       datatype, dataspace;   /* handles */

   hsize_t     dimsf[2];              /* dataset dimensions */

   herr_t      status;                             

   int         data[NX][NY];          /* data to write */

   int         i, j;



/* 

 * Data  and output buffer initialization. 

 */



for (j = 0; j &lt; NX; j++) {

    for (i = 0; i &lt; NY; i++)

        data[j][i] = i + j;

}     

                                       /*  0 1 2 3 4 5 

                                           1 2 3 4 5 6

                                           2 3 4 5 6 7

                                           3 4 5 6 7 8

                                           4 5 6 7 8 9   */



/*

 * Create a new file using H5F_ACC_TRUNC access,

 * default file creation properties, and default file

 * access properties.

 */

file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);



/*

 * Describe the size of the array and create the data space for fixed

 * size dataset. 

 */

dimsf[0] = NX;

dimsf[1] = NY;

dataspace = H5Screate_simple(RANK, dimsf, NULL); 



/* 

 * Define datatype for the data in the file.

 * We will store little endian INT numbers.

 */

datatype = H5Tcopy(H5T_NATIVE_INT);

status = H5Tset_order(datatype, H5T_ORDER_LE);

/*

 * Create a new dataset within the file using defined dataspace and

 * datatype and default dataset creation properties.

 */

dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace,

                    H5P_DEFAULT);



/*

 * Write the data to the dataset using default transfer properties.

 */

status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,

                  H5P_DEFAULT, data);



/*

 * Close/release resources.

 */

H5Sclose(dataspace);

H5Tclose(datatype);

H5Dclose(dataset);

H5Fclose(file);

 

}     </PRE>

<FONT FACE="Courier New" SIZE=2><P>&nbsp;</P>

</FONT><H4>Example 2.</A> How to read a hyperslab from file into memory.</H4>

<P>This example reads a hyperslab from a 2-d HDF5 dataset into a 3-d dataset 

in memory.</P>

<PRE>

/*  

 *   This example reads hyperslab from the SDS.h5 file 

 *   created by h5_write.c program into two-dimensional

 *   plane of the tree-dimensional array. 

 *   Information about dataset in the SDS.h5 file is obtained. 

 */

 

#include "hdf5.h"



#define FILE        "SDS.h5"

#define DATASETNAME "IntArray" 

#define NX_SUB  3           /* hyperslab dimensions */ 

#define NY_SUB  4 

#define NX 7           /* output buffer dimensions */ 

#define NY 7 

#define NZ  3 

#define RANK         2

#define RANK_OUT     3



main ()

{

   hid_t       file, dataset;         /* handles */

   hid_t       datatype, dataspace;   

   hid_t       memspace; 

   H5T_class_t class;                 /* data type class */

   H5T_order_t order;                 /* data order */

   size_t      size;                  /* size of the data element

                                         stored in file */ 

   hsize_t     dimsm[3];              /* memory space dimensions */

   hsize_t     dims_out[2];           /* dataset dimensions */      

   herr_t      status;                             



   int         data_out[NX][NY][NZ ]; /* output buffer */

   

   hsize_t      count[2];              /* size of the hyperslab in the file */

   hsize_t      offset[2];             /* hyperslab offset in the file */

   hsize_t      count_out[3];          /* size of the hyperslab in memory */

   hsize_t      offset_out[3];         /* hyperslab offset in memory */

   int          i, j, k, status_n, rank;



for (j = 0; j &lt; NX; j++) {

    for (i = 0; i &lt; NY; i++) {

        for (k = 0; k &lt; NZ ; k++)

            data_out[j][i][k] = 0;

    }

} 

 

/*

 * Open the file and the dataset.

 */

file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT);

dataset = H5Dopen(file, DATASETNAME);



/*

 * Get datatype and dataspace handles and then query

 * dataset class, order, size, rank and dimensions.

 */



datatype  = H5Dget_type(dataset);     /* datatype handle */ 

class     = H5Tget_class(datatype);

if (class == H5T_INTEGER) printf("Data set has INTEGER type \n");

order     = H5Tget_order(datatype);

if (order == H5T_ORDER_LE) printf("Little endian order \n");



size  = H5Tget_size(datatype);

printf(" Data size is %d \n", size);



dataspace = H5Dget_space(dataset);    /* dataspace handle */

rank      = H5Sextent_ndims(dataspace);

status_n  = H5Sextent_dims(dataspace, dims_out, NULL);

printf("rank %d, dimensions %d x %d \n", rank, dims_out[0], dims_out[1]);



/* 

 * Define hyperslab in the datatset. 

 */

offset[0] = 1;

offset[1] = 2;

count[0]  = NX_SUB;

count[1]  = NY_SUB;

status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL, 

                             count, NULL);



/*

 * Define the memory dataspace.

 */

dimsm[0] = NX;

dimsm[1] = NY;

dimsm[2] = NZ ;

memspace = H5Screate_simple(RANK_OUT,dimsm,NULL);   



/* 

 * Define memory hyperslab. 

 */

offset_out[0] = 3;

offset_out[1] = 0;

offset_out[2] = 0;

count_out[0]  = NX_SUB;

count_out[1]  = NY_SUB;

count_out[2]  = 1;

status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL, 

                             count_out, NULL);



/*

 * Read data from hyperslab in the file into the hyperslab in 

 * memory and display.

 */

status = H5Dread(dataset, H5T_NATIVE_INT, memspace, dataspace,

                 H5P_DEFAULT, data_out);

for (j = 0; j &lt; NX; j++) {

    for (i = 0; i &lt; NY; i++) printf("%d ", data_out[j][i][0]);

    printf("\n");

}

                                         /*  0 0 0 0 0 0 0

                                             0 0 0 0 0 0 0

                                             0 0 0 0 0 0 0

                                             3 4 5 6 0 0 0  

                                             4 5 6 7 0 0 0

                                             5 6 7 8 0 0 0

                                             0 0 0 0 0 0 0 */



/*

 * Close/release resources.

 */

H5Tclose(datatype);

H5Dclose(dataset);

H5Sclose(dataspace);

H5Sclose(memspace);

H5Fclose(file);



}     </PRE>

<FONT FACE="Times" SIZE=2><P>&nbsp;</P>

</FONT><H4><A NAME="Compound"></A>Example 3. Working with compound datatypes.</H4>

<P>This example shows how to create a compound data type, write an array which 

has the compound data type to the file, and read back subsets of fields.</P>

<PRE>

/*

 * This example shows how to create a compound data type,

 * write an array which has the compound data type to the file,

 * and read back fields' subsets.

 */



#include "hdf5.h"



#define FILE          "SDScompound.h5"

#define DATASETNAME   "ArrayOfStructures"

#define LENGTH        10

#define RANK          1



main()



{



   

/* First structure  and dataset*/

typedef struct s1_t {

    int    a;

    float  b;

    double c; 

} s1_t;

s1_t       s1[LENGTH];

hid_t      s1_tid;     /* File datatype hadle */



/* Second structure (subset of s1_t)  and dataset*/

typedef struct s2_t {

    double c;

    int    a;

} s2_t;

s2_t       s2[LENGTH];

hid_t      s2_tid;    /* Memory datatype handle */



/* Third "structure" ( will be used to read float field of s1) */

hid_t      s3_tid;   /* Memory datatype handle */

float      s3[LENGTH];



int        i;

hid_t      file, datatype, dataset, space; /* Handles */

herr_t     status;

hsize_t    dim[] = {LENGTH};   /* Dataspace dimensions */





/*

 * Initialize the data

 */

   for (i = 0; i&lt; LENGTH; i++) {

        s1[i].a = i;

        s1[i].b = i*i;

        s1[i].c = 1./(i+1);

}



/*

 * Create the data space.

 */

space = H5Screate_simple(RANK, dim, NULL);



/*

 * Create the file.

 */

file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);



/*

 * Create the memory data type. 

 */

s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));

H5Tinsert(s1_tid, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT);

H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);

H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);



/* 

 * Create the dataset.

 */

dataset = H5Dcreate(file, DATASETNAME, s1_tid, space, H5P_DEFAULT);



/*

 * Wtite data to the dataset; 

 */

status = H5Dwrite(dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1);



/*

 * Release resources

 */

H5Tclose(s1_tid);

H5Sclose(space);

H5Dclose(dataset);

H5Fclose(file);

 

/*

 * Open the file and the dataset.

 */

file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT);

 

dataset = H5Dopen(file, DATASETNAME);



/* 

 * Create a data type for s2

 */

s2_tid = H5Tcreate(H5T_COMPOUND, sizeof(s2_t));



H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE);

H5Tinsert(s2_tid, "a_name", HOFFSET(s2_t, a), H5T_NATIVE_INT);



/*

 * Read two fields c and a from s1 dataset. Fields in the file

 * are found by their names "c_name" and "a_name".

 */

status = H5Dread(dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s2);



/*

 * Display the fields

 */

printf("\n");

printf("Field c : \n");

for( i = 0; i &lt; LENGTH; i++) printf("%.4f ", s2[i].c);

printf("\n");



printf("\n");

printf("Field a : \n");

for( i = 0; i &lt; LENGTH; i++) printf("%d ", s2[i].a);

printf("\n");



/* 

 * Create a data type for s3.

 */

s3_tid = H5Tcreate(H5T_COMPOUND, sizeof(float));



status = H5Tinsert(s3_tid, "b_name", 0, H5T_NATIVE_FLOAT);



/*

 * Read field b from s1 dataset. Field in the file is found by its name.

 */

status = H5Dread(dataset, s3_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s3);



/*

 * Display the field

 */

printf("\n");

printf("Field b : \n");

for( i = 0; i &lt; LENGTH; i++) printf("%.4f ", s3[i]);

printf("\n");



/*

 * Release resources

 */

H5Tclose(s2_tid);

H5Tclose(s3_tid);

H5Dclose(dataset);

H5Fclose(file);

}</PRE>

<FONT FACE="Times" SIZE=2><P>&nbsp;</P>

</FONT><H4><A NAME="CreateExtendWrite"></A>Example 4. Creating and writing an extendible dataset.</H4>

<P>This example shows how to create a 3x3 extendible dataset, to extend the 

dataset to 10x3, then to extend it again to 10x5.</P>

<PRE>

/*  

 *   This example shows how to work with extendible dataset.

 *   In the current version of the library dataset MUST be

 *   chunked.

 *   

 */

 

#include "hdf5.h"



#define FILE        "SDSextendible.h5"

#define DATASETNAME "ExtendibleArray" 

#define RANK         2

#define NX     10

#define NY     5 



main ()

{

   hid_t       file;                          /* handles */

   hid_t       datatype, dataspace, dataset;  

   hid_t       filespace;                   

   hid_t       cparms;                     

   hsize_t      dims[2]  = { 3, 3};            /* dataset dimensions

                                                 at the creation time  */ 

   hsize_t      dims1[2] = { 3, 3};            /* data1 dimensions */ 

   hsize_t      dims2[2] = { 7, 1};            /* data2 dimensions */  

   hsize_t      dims3[2] = { 2, 2};            /* data3 dimensions */ 



   hsize_t      maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};

   hsize_t      chunk_dims[2] ={2, 5};

   hsize_t      size[2];

   hssize_t     offset[2];



   herr_t      status;                             



   int         data1[3][3] = { 1, 1, 1,       /* data to write */

                               1, 1, 1,

                               1, 1, 1 };      



   int         data2[7]    = { 2, 2, 2, 2, 2, 2, 2};



   int         data3[2][2] = { 3, 3,

                               3, 3};



/*

 * Create the data space with ulimited dimensions. 

 */

dataspace = H5Screate_simple(RANK, dims, maxdims); 



/*

 * Create a new file. If file exists its contents will be overwritten.

 */

file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);



/* 

 * Modify dataset creation properties, i.e. enable chunking.

 */

cparms = H5Pcreate (H5P_DATASET_CREATE);

status = H5Pset_chunk( cparms, RANK, chunk_dims);



/*

 * Create a new dataset within the file using cparms

 * creation properties.

 */

dataset = H5Dcreate(file, DATASETNAME, H5T_NATIVE_INT, dataspace,

                 cparms);



/*

 * Extend the dataset. This call assures that dataset is at least 3 x 3.

 */

size[0]   = 3; 

size[1]   = 3; 

status = H5Dextend (dataset, size);



/*

 * Select a hyperslab.

 */

filespace = H5Dget_space (dataset);

offset[0] = 0;

offset[1] = 0;

status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,

                             dims1, NULL);  



/*

 * Write the data to the hyperslab.

 */

status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,

                  H5P_DEFAULT, data1);



/*

 * Extend the dataset. Dataset becomes 10 x 3.

 */

dims[0]   = dims1[0] + dims2[0];

size[0]   = dims[0];  

size[1]   = dims[1]; 

status = H5Dextend (dataset, size);



/*

 * Select a hyperslab.

 */

filespace = H5Dget_space (dataset);

offset[0] = 3;

offset[1] = 0;

status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,

                              dims2, NULL);  



/*

 * Define memory space

 */

dataspace = H5Screate_simple(RANK, dims2, NULL); 



/*

 * Write the data to the hyperslab.

 */

status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,

                  H5P_DEFAULT, data2);



/*

 * Extend the dataset. Dataset becomes 10 x 5.

 */

dims[1]   = dims1[1] + dims3[1];

size[0]   = dims[0];  

size[1]   = dims[1]; 

status = H5Dextend (dataset, size);



/*

 * Select a hyperslab

 */

filespace = H5Dget_space (dataset);

offset[0] = 0;

offset[1] = 3;

status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, 

                             dims3, NULL);  



/*

 * Define memory space.

 */

dataspace = H5Screate_simple(RANK, dims3, NULL); 



/*

 * Write the data to the hyperslab.

 */

status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace,

                  H5P_DEFAULT, data3);



/*

 * Resulting dataset

 *                 

         3 3 3 2 2

         3 3 3 2 2

         3 3 3 0 0

         2 0 0 0 0

         2 0 0 0 0

         2 0 0 0 0

         2 0 0 0 0

         2 0 0 0 0

         2 0 0 0 0

         2 0 0 0 0

 */ 

/*

 * Close/release resources.

 */

H5Dclose(dataset);

H5Sclose(dataspace);

H5Sclose(filespace);

H5Fclose(file);



}     </PRE>

<FONT FACE="Courier New" SIZE=2><P>&nbsp;</P>

</FONT><H4><A NAME="ReadExtended"></A>Example 5. Reading data.</H4>

<P>This example shows how to read information the chunked dataset written 

by <A HREF="#CreateExtendWrite">Example 4</A>.</P>

<PRE>

/*  

 *   This example shows how to read data from a chunked dataset.

 *   We will read from the file created by h5_extend_write.c 

 */

 

#include "hdf5.h"



#define FILE        "SDSextendible.h5"

#define DATASETNAME "ExtendibleArray" 

#define RANK         2

#define RANKC        1

#define NX           10

#define NY           5 



main ()

{

   hid_t       file;                        /* handles */

   hid_t       datatype, dataset;  

   hid_t       filespace;                   

   hid_t       memspace;                  

   hid_t       cparms;                   

   H5T_class_t class;                       /* data type class */

   size_t      elem_size;                   /* size of the data element

                                               stored in file */ 

   hsize_t     dims[2];                     /* dataset and chunk dimensions */ 

   hsize_t     chunk_dims[2];

   hsize_t     col_dims[1];

   size_t      size[2];

   hsize_t     count[2];

   hsize_t     offset[2];



   herr_t      status, status_n;                             



   int         data_out[NX][NY];  /* buffer for dataset to be read */

   int         chunk_out[2][5];   /* buffer for chunk to be read */

   int         column[10];        /* buffer for column to be read */

   int         i, j, rank, rank_chunk;



 

/*

 * Open the file and the dataset.

 */

file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT);

dataset = H5Dopen(file, DATASETNAME);

 

/*

 * Get dataset rank and dimension.

 */

 

filespace = H5Dget_space(dataset);    /* Get filespace handle first. */

rank      = H5Sextent_ndims(filespace);

status_n  = H5Sextent_dims(filespace, dims, NULL);

printf("dataset rank %d, dimensions %d x %d \n", rank, dims[0], dims[1]);



/*

 * Get creation properties list.

 */

cparms = H5Dget_create_plist(dataset); /* Get properties handle first. */



/* 

 * Check if dataset is chunked.

 */

 if (H5D_CHUNKED == H5Pget_layout(cparms))  {



/*

 * Get chunking information: rank and dimensions

 */

rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims);

printf("chunk rank %d, dimensions %d x %d \n", rank_chunk,

        chunk_dims[0], chunk_dims[1]);

} 

 

/*

 * Define the memory space to read dataset.

 */

memspace = H5Screate_simple(RANK,dims,NULL);

 

/*

 * Read dataset back and display.

 */

status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace,

                 H5P_DEFAULT, data_out);

    printf("\n");

    printf("Dataset: \n");

for (j = 0; j &lt; dims[0]; j++) {

    for (i = 0; i &lt; dims[1]; i++) printf("%d ", data_out[j][i]);

    printf("\n");

}     



/*

            dataset rank 2, dimensions 10 x 5 

            chunk rank 2, dimensions 2 x 5 



            Dataset:

            1 1 1 3 3 

            1 1 1 3 3 

            1 1 1 0 0 

            2 0 0 0 0 

            2 0 0 0 0 

            2 0 0 0 0 

            2 0 0 0 0 

            2 0 0 0 0 

            2 0 0 0 0 

            2 0 0 0 0 

*/



/*

 * Read the third column from the dataset.

 * First define memory dataspace, then define hyperslab

 * and read it into column array.

 */

col_dims[0] = 10;

memspace =  H5Screate_simple(RANKC, col_dims, NULL);



/*

 * Define the column (hyperslab) to read.

 */

offset[0] = 0;

offset[1] = 2;

count[0]  = 10;

count[1]  = 1;

status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,

                             count, NULL);

status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace,

                 H5P_DEFAULT, column);

printf("\n");

printf("Third column: \n");

for (i = 0; i &lt; 10; i++) {

     printf("%d \n", column[i]);

}



/*



            Third column: 

            1 

            1 

            1 

            0 

            0 

            0 

            0 

            0 

            0 

            0 

*/



/*

 * Define the memory space to read a chunk.

 */

memspace = H5Screate_simple(rank_chunk,chunk_dims,NULL);



/*

 * Define chunk in the file (hyperslab) to read.

 */

offset[0] = 2;

offset[1] = 0;

count[0]  = chunk_dims[0];

count[1]  = chunk_dims[1];

status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, 

                              count, NULL);



/*

 * Read chunk back and display.

 */

status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace,

                 H5P_DEFAULT, chunk_out);

    printf("\n");

    printf("Chunk: \n");

for (j = 0; j &lt; chunk_dims[0]; j++) {

    for (i = 0; i &lt; chunk_dims[1]; i++) printf("%d ", chunk_out[j][i]);

    printf("\n");

}     

/*

         Chunk: 

         1 1 1 0 0 

         2 0 0 0 0 

*/



/*

 * Close/release resources.

 */

H5Pclose(cparms);

H5Dclose(dataset);

H5Sclose(filespace);

H5Sclose(memspace);

H5Fclose(file);



}     </PRE>

<FONT FACE="Courier New" SIZE=2><P>&nbsp;</P>

</FONT><H4><A NAME="CreateGroups"></A>Example 6. Creating groups.</H4>

<P>This example shows how to create an HDF5 file with two groups, and to 

place some datasets within those groups.</P>

<PRE>

/*

 * This example shows how to create groups within the file and    

 * datasets within the file and groups.

 */ 





#include "hdf5.h"





#define FILE    "DIR.h5"

#define RANK    2



main()

{



   hid_t    file, dir;

   hid_t    dataset, dataspace;



   herr_t   status;

   hsize_t  dims[2];

   hsize_t  size[1];



/*

 * Create a file.

 */

file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);



/*

 * Create two groups in a file.

 */

dir = H5Gcreate(file, "/IntData", 0);

status = H5Gclose(dir);



dir = H5Gcreate(file,"/FloatData", 0);

status = H5Gclose(dir);



/* 

 * Create dataspace for the character string

 */

size[0] = 80;

dataspace = H5Screate_simple(1, size, NULL);



/*

 * Create dataset "String" in the root group.  

 */

dataset = H5Dcreate(file, "String", H5T_NATIVE_CHAR, dataspace, H5P_DEFAULT);

H5Dclose(dataset);



/*

 * Create dataset "String" in the /IntData group.  

 */

dataset = H5Dcreate(file, "/IntData/String", H5T_NATIVE_CHAR, dataspace,

                    H5P_DEFAULT);

H5Dclose(dataset);



/*

 * Create dataset "String" in the /FloatData group.  

 */

dataset = H5Dcreate(file, "/FloatData/String", H5T_NATIVE_CHAR, dataspace,

                    H5P_DEFAULT);

H5Sclose(dataspace);

H5Dclose(dataset);



/*

 * Create IntArray dataset in the /IntData group by specifying full path.

 */

dims[0] = 2;

dims[1] = 3;

dataspace = H5Screate_simple(RANK, dims, NULL);

dataset = H5Dcreate(file, "/IntData/IntArray", H5T_NATIVE_INT, dataspace,

                    H5P_DEFAULT); 

H5Sclose(dataspace);

H5Dclose(dataset);



/*

 * Set current group to /IntData and attach to the dataset String.

 */



status = H5Gset (file, "/IntData");

dataset = H5Dopen(file, "String");

if (dataset &gt; 0) printf("String dataset in /IntData group is found\n"); 

H5Dclose(dataset);



/*

 * Set current group to /FloatData.

 */

status = H5Gset (file, "/FloatData");



/* 

 * Create two datasets FlatArray and DoubleArray.

 */



dims[0] = 5;

dims[1] = 10;

dataspace = H5Screate_simple(RANK, dims, NULL);

dataset = H5Dcreate(file, "FloatArray", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT); 

H5Sclose(dataspace);

H5Dclose(dataset);



dims[0] = 4;

dims[1] = 6;

dataspace = H5Screate_simple(RANK, dims, NULL);

dataset = H5Dcreate(file, "DoubleArray", H5T_NATIVE_DOUBLE, dataspace,

                    H5P_DEFAULT); 

H5Sclose(dataspace);

H5Dclose(dataset);



/* 

 * Attach to /FloatData/String dataset.

 */



dataset = H5Dopen(file, "/FloatData/String");

if (dataset &gt; 0) printf("/FloatData/String dataset is found\n"); 

H5Dclose(dataset);

H5Fclose(file);



}</PRE>







<hr>

<address>

<a href="mailto:hdfhelp@ncsa.uiuc.edu">HDF Help Desk</a>

<br>

Last modified:  14 July 1998

</address>

<P>&nbsp;</P></BODY>

</HTML>