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
|
<!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.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>HDF5: Dataspaces and Partial I/O</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>
<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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(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>
 <span id="projectnumber">1.15.0.207d749</span>
</div>
<div id="projectbrief">API Reference</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.svg"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="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.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_h5_s__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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Dataspaces and Partial I/O </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="sec_dataspace"></a>
HDF5 Dataspaces and Partial I/O</h1>
<p>HDF5 dataspaces describe the <em>shape</em> of datasets in memory or in HDF5 files. Dataspaces can be empty (<a class="el" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aa3d83ec70c1a824a2d821bf8464488bc5">H5S_NULL</a>), a singleton (<a class="el" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aaf6a34a2439db8aa7bb63ed0c4aaa5eb8">H5S_SCALAR</a>), or a multi-dimensional, regular grid (<a class="el" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aac4ee937dcccfd99f885626983e7d2750">H5S_SIMPLE</a>). Dataspaces can be re-shaped.</p>
<p>Subsets of dataspaces can be "book-marked" or used to restrict I/O operations using <em>selections</em>. Furthermore, certain set operations are supported for selections.</p>
<h2><a class="anchor" id="subsec_dataspace_intro"></a>
Introduction</h2>
<p>The HDF5 <em>dataspace</em> is a required component of an HDF5 dataset or attribute definition. The dataspace defines the size and shape of the dataset or attribute raw data. In other words, a dataspace defines the number of dimensions and the size of each dimension of the multidimensional array in which the raw data is represented. The dataspace must be defined when the dataset or attribute is created.</p>
<p>The <em>dataspace</em> is also used during dataset I/O operations, defining the elements of the dataset that participate in the I/O operation.</p>
<p>This chapter explains the <em>dataspace</em> object and its use in dataset and attribute creation and data transfer. It also describes selection operations on a dataspace used to implement sub‐setting, sub‐sampling, and scatter‐gather access to datasets.</p>
<h2><a class="anchor" id="subsec_dataspace_function"></a>
Dataspace Function Summaries</h2>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group___h5_s.html">Dataspaces (H5S)</a> reference manual provides a reference list of dataspace functions, the <a class="el" href="group___h5_s.html">Dataspaces (H5S)</a> APIs.</dd></dl>
<h2><a class="anchor" id="subsec_dataspace_program"></a>
Definition of Dataspace Objects and the Dataspace Programming Model</h2>
<p>This section introduces the notion of the HDF5 dataspace object and a programming model for creating and working with dataspaces.</p>
<h3><a class="anchor" id="subsubsec_dataspace_program_object"></a>
Dataspace Objects</h3>
<p>An HDF5 dataspace is a required component of an HDF5 dataset or attribute. A dataspace defines the size and the shape of a dataset's or an attribute's raw data. Currently, HDF5 supports the following types of the dataspaces: </p><ul>
<li>Scalar dataspaces </li>
<li>Simple dataspaces </li>
<li>Null dataspaces</li>
</ul>
<p>A scalar dataspace, <a class="el" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aaf6a34a2439db8aa7bb63ed0c4aaa5eb8">H5S_SCALAR</a>, represents just one element, a scalar. Note that the datatype of this one element may be very complex; example would be a compound structure with members being of any allowed HDF5 datatype, including multidimensional arrays, strings, and nested compound structures. By convention, the rank of a scalar dataspace is always 0 (zero); think of it geometrically as a single, dimensionless point, though that point may be complex.</p>
<p>A simple dataspace, <a class="el" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aac4ee937dcccfd99f885626983e7d2750">H5S_SIMPLE</a> , is a multidimensional array of elements. The dimensionality of the dataspace (or the rank of the array) is fixed and is defined at creation time. The size of each dimension can grow during the life time of the dataspace from the current size up to the maximum size. Both the current size and the maximum size are specified at creation time. The sizes of dimensions at any particular time in the life of a dataspace are called the current dimensions, or the dataspace extent. They can be queried along with the maximum sizes.</p>
<p>A null dataspace, <a class="el" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aa3d83ec70c1a824a2d821bf8464488bc5">H5S_NULL</a>, contains no data elements. Note that no selections can be applied to a null dataset as there is nothing to select.</p>
<p>As shown in the UML diagram in the figure below, an HDF5 simple dataspace object has three attributes: the rank or number of dimensions; the current sizes, expressed as an array of length rank with each element of the array denoting the current size of the corresponding dimension; and the maximum sizes, expressed as an array of length rank with each element of the array denoting the maximum size of the corresponding dimension.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_simple.gif" alt=""/>
<div class="caption">
A simple dataspace</div></div>
</td></tr>
</table>
<p><em>Note:</em> A simple dataspace is defined by its rank, the current size of each dimension, and the maximum size of each dimension.</p>
<p>The size of a current dimension cannot be greater than the maximum size, which can be unlimited, specified as <a class="el" href="_h5_spublic_8h.html#a5af9ab788797b2ea9a4843857674ac18">H5S_UNLIMITED</a>. Note that while the HDF5 file format and library impose no maximum size on an unlimited dimension, practically speaking its size will always be limited to the biggest integer available on the particular system being used.</p>
<p>Dataspace rank is restricted to 32, the standard limit in C on the rank of an array, in the current implementation of the HDF5 Library. The HDF5 file format, on the other hand, allows any rank up to the maximum integer value on the system, so the library restriction can be raised in the future if higher dimensionality is required.</p>
<p>Note that most of the time Fortran applications calling HDF5 will work with dataspaces of rank less than or equal to seven, since seven is the maximum number of dimensions in a Fortran array. But dataspace rank is not limited to seven for Fortran applications.</p>
<p>The current dimensions of a dataspace, also referred to as the dataspace extent, define the bounding box for dataset elements that can participate in I/O operations.</p>
<h3><a class="anchor" id="subsubsec_dataspace_program_model"></a>
Dataspace Programming Model</h3>
<p>The programming model for creating and working with HDF5 dataspaces can be summarized as follows: </p><ul>
<li>1. Create a dataspace </li>
<li>2. Use the dataspace to create a dataset in the file or to describe a data array in memory </li>
<li>3. Modify the dataspace to define dataset elements that will participate in I/O operations </li>
<li>4. Use the modified dataspace while reading/writing dataset raw data or to create a region reference </li>
<li>5. Close the dataspace when no longer needed</li>
</ul>
<p>The rest of this section will address steps 1, 2, and 5 of the programming model; steps 3 and 4 will be discussed in later sections of this chapter.</p>
<h4>Creating a Dataspace</h4>
<p>A dataspace can be created by calling the <a class="el" href="group___h5_s.html#gabee514327cba34ca9951b24fa14fb083">H5Screate</a> function. Since the definition of a simple dataspace requires the specification of dimensionality (or rank) and initial and maximum dimension sizes, the HDF5 Library provides a convenience API, <a class="el" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a> to create a simple dataspace in one step.</p>
<p>The following examples illustrate the usage of these APIs.</p>
<h4>Creating a Scalar Dataspace</h4>
<p>Creating a Scalar Dataspace </p><div class="fragment"><div class="line"><a class="code" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> space_id;</div>
<div class="line">. . .</div>
<div class="line">space_id = <a class="code" href="group___h5_s.html#gabee514327cba34ca9951b24fa14fb083">H5Screate</a>(<a class="code" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aaf6a34a2439db8aa7bb63ed0c4aaa5eb8">H5S_SCALAR</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_spublic_8h_html_ae53f3c6a52563646fbac9ead8ecdbf0aaf6a34a2439db8aa7bb63ed0c4aaa5eb8"><div class="ttname"><a href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aaf6a34a2439db8aa7bb63ed0c4aaa5eb8">H5S_SCALAR</a></div><div class="ttdeci">@ H5S_SCALAR</div><div class="ttdef"><b>Definition:</b> H5Spublic.h:77</div></div>
<div class="ttc" id="agroup___h5_s_html_gabee514327cba34ca9951b24fa14fb083"><div class="ttname"><a href="group___h5_s.html#gabee514327cba34ca9951b24fa14fb083">H5Screate</a></div><div class="ttdeci">hid_t H5Screate(H5S_class_t type)</div><div class="ttdoc">Creates a new dataspace of a specified type.</div></div>
</div><!-- fragment --><p> As mentioned above, the dataspace will contain only one element. Scalar dataspaces are used more often for describing attributes that have just one value. For example, the attribute temperature with the value Celsius is used to indicate that the dataset with this attribute stores temperature values using the Celsius scale.</p>
<h4>Creating a Null Dataspace</h4>
<p>A null dataspace is created with the <a class="el" href="group___h5_s.html#gabee514327cba34ca9951b24fa14fb083">H5Screate</a> function. </p><div class="fragment"><div class="line"><a class="code" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> space_id;</div>
<div class="line">. . .</div>
<div class="line">space_id = <a class="code" href="group___h5_s.html#gabee514327cba34ca9951b24fa14fb083">H5Screate</a>(<a class="code" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aa3d83ec70c1a824a2d821bf8464488bc5">H5S_NULL</a>);</div>
<div class="ttc" id="a_h5_spublic_8h_html_ae53f3c6a52563646fbac9ead8ecdbf0aa3d83ec70c1a824a2d821bf8464488bc5"><div class="ttname"><a href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aa3d83ec70c1a824a2d821bf8464488bc5">H5S_NULL</a></div><div class="ttdeci">@ H5S_NULL</div><div class="ttdef"><b>Definition:</b> H5Spublic.h:79</div></div>
</div><!-- fragment --><p> As mentioned above, the dataspace will contain no elements.</p>
<h4>Creating a Simple Dataspace</h4>
<p>Let's assume that an application wants to store a two‐dimensional array of data, A(20,100). During the life of the application, the first dimension of the array can grow up to 30; there is no restriction on the size of the second dimension. The following steps are used to declare a dataspace for the dataset in which the array data will be stored. </p><div class="fragment"><div class="line"><a class="code" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> space_id;</div>
<div class="line"><span class="keywordtype">int</span> rank = 2;</div>
<div class="line"><a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> current_dims[2] = {20, 100};</div>
<div class="line"><a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> max_dims[2] = {30, <a class="code" href="_h5_spublic_8h.html#a5af9ab788797b2ea9a4843857674ac18">H5S_UNLIMITED</a>};</div>
<div class="line">. . .</div>
<div class="line">space_id = <a class="code" href="group___h5_s.html#gabee514327cba34ca9951b24fa14fb083">H5Screate</a>(<a class="code" href="_h5_spublic_8h.html#ae53f3c6a52563646fbac9ead8ecdbf0aa3d83ec70c1a824a2d821bf8464488bc5">H5S_NULL</a>);</div>
<div class="line"><a class="code" href="group___h5_s.html#gaf2526a41d2f4506e2c52098510517343">H5Sset_extent_simple</a>(space_id, rank, current_dims, max_dims);</div>
<div class="ttc" id="a_h5_spublic_8h_html_a5af9ab788797b2ea9a4843857674ac18"><div class="ttname"><a href="_h5_spublic_8h.html#a5af9ab788797b2ea9a4843857674ac18">H5S_UNLIMITED</a></div><div class="ttdeci">#define H5S_UNLIMITED</div><div class="ttdef"><b>Definition:</b> H5Spublic.h:48</div></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___h5_s_html_gaf2526a41d2f4506e2c52098510517343"><div class="ttname"><a href="group___h5_s.html#gaf2526a41d2f4506e2c52098510517343">H5Sset_extent_simple</a></div><div class="ttdeci">herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[], const hsize_t max[])</div><div class="ttdoc">Sets or resets the size of an existing dataspace.</div></div>
</div><!-- fragment --><p>Alternatively, the convenience APIs H5Screate_simple/h5screate_simple_f can replace the H5Screate/h5screate_f and H5Sset_extent_simple/h5sset_extent_simple_f calls. </p><div class="fragment"><div class="line">space_id = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(rank, current_dims, max_dims);</div>
<div class="ttc" id="agroup___h5_s_html_ga8e35eea5738b4805856eac7d595254ae"><div class="ttname"><a href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a></div><div class="ttdeci">hid_t H5Screate_simple(int rank, const hsize_t dims[], const hsize_t maxdims[])</div><div class="ttdoc">Creates a new simple dataspace and opens it for access.</div></div>
</div><!-- fragment --><p>In this example, a dataspace with current dimensions of 20 by 100 is created. The first dimension can be extended only up to 30. The second dimension, however, is declared unlimited; it can be extended up to the largest available integer value on the system.</p>
<p>Note that when there is a difference between the current dimensions and the maximum dimensions of an array, then chunking storage must be used. In other words, if the number of dimensions may change over the life of the dataset, then chunking must be used. If the array dimensions are fixed (if the number of current dimensions is equal to the maximum number of dimensions when the dataset is created), then contiguous storage can be used. For more information, see "Data Transfer".</p>
<p>Maximum dimensions can be the same as current dimensions. In such a case, the sizes of dimensions cannot be changed during the life of the dataspace object. In C, <code>NULL</code> can be used to indicate to the <a class="el" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a> and <a class="el" href="group___h5_s.html#gaf2526a41d2f4506e2c52098510517343">H5Sset_extent_simple</a> functions that the maximum sizes of all dimensions are the same as the current sizes. </p><div class="fragment"><div class="line">space_id = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(rank, current_dims, NULL);</div>
</div><!-- fragment --><p> The created dataspace will have current and maximum dimensions of 20 and 100 correspondingly, and the sizes of those dimensions cannot be changed.</p>
<h4>C versus Fortran Dataspaces</h4>
<p>Dataspace dimensions are numbered from 1 to rank. HDF5 uses C storage conventions, assuming that the last listed dimension is the fastest‐changing dimension and the first‐listed dimension is the slowest changing. The HDF5 file format storage layout specification adheres to the C convention and the HDF5 Library adheres to the same convention when storing dataspace dimensions in the file. This affects how C programs and tools interpret data written from Fortran programs and vice versa. The example below illustrates the issue.</p>
<p>When a Fortran application describes a dataspace to store an array as A(20,100), it specifies the value of the first dimension to be 20 and the second to be 100. Since Fortran stores data by columns, the first‐listed dimension with the value 20 is the fastest‐changing dimension and the last‐listed dimension with the value 100 is the slowest‐changing. In order to adhere to the HDF5 storage convention, the HDF5 Fortran wrapper transposes dimensions, so the first dimension becomes the last. The dataspace dimensions stored in the file will be 100,20 instead of 20,100 in order to correctly describe the Fortran data that is stored in 100 columns, each containing 20 elements.</p>
<p>When a Fortran application reads the data back, the HDF5 Fortran wrapper transposes the dimensions once more, returning the first dimension to be 20 and the second to be 100, describing correctly the sizes of the array that should be used to read data in the Fortran array A(20,100).</p>
<p>When a C application reads data back, the dimensions will come out as 100 and 20, correctly describing the size of the array to read data into, since the data was written as 100 records of 20 elements each. Therefore C tools such as h5dump and h5ls always display transposed dimensions and values for the data written by a Fortran application.</p>
<p>Consider the following simple example of equivalent C 3 x 5 and Fortran 5 x 3 arrays. As illustrated in the figure below, a C application will store a 3 x 5 2‐dimensional array as three 5‐element rows. In order to store the same data in the same order, a Fortran application must view the array as a 5 x 3 array with three 5‐element columns. The dataspace of this dataset, as written from Fortran, will therefore be described as 5 x 3 in the application but stored and described in the file according to the C convention as a 3 x 5 array. This ensures that C and Fortran applications will always read the data in the order in which it was written. The HDF5 Fortran interface handles this transposition automatically. </p><div class="fragment"><div class="line"><span class="comment">// C</span></div>
<div class="line"> \#define NX 3 <span class="comment">// dataset dimensions</span></div>
<div class="line"> \#define NY 5</div>
<div class="line"> . . .</div>
<div class="line"> <span class="keywordtype">int</span> data[NX][NY]; <span class="comment">// data to write</span></div>
<div class="line"> . . .</div>
<div class="line"> <span class="comment">// Data and output buffer initialization.</span></div>
<div class="line"> <span class="keywordflow">for</span> (j = 0; j < NX; j++)</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < NY; i++)</div>
<div class="line"> data[j][i] = i + j;</div>
<div class="line"> <span class="comment">//</span></div>
<div class="line"> <span class="comment">// 1 2 3 4 5</span></div>
<div class="line"> <span class="comment">// 6 7 8 9 10</span></div>
<div class="line"> <span class="comment">// 11 12 13 14 15</span></div>
<div class="line"> <span class="comment">//</span></div>
<div class="line"> . . .</div>
<div class="line"> dims[0] = NX;</div>
<div class="line"> dims[1] = NY;</div>
<div class="line"> dataspace = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(RANK, dims, NULL);</div>
</div><!-- fragment --><div class="fragment"><div class="line">! Fortran</div>
<div class="line"> INTEGER, PARAMETER :: NX = 3</div>
<div class="line"> INTEGER, PARAMETER :: NX = 5</div>
<div class="line"> . . .</div>
<div class="line"> INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/NY, NX/) ! Dataset dimensions</div>
<div class="line"> . . .</div>
<div class="line"> !</div>
<div class="line"> ! Initialize data</div>
<div class="line"> !</div>
<div class="line"> do i = 1, NY</div>
<div class="line"> do j = 1, NX</div>
<div class="line"> data(i,j) = i + (j-1)*NY</div>
<div class="line"> enddo</div>
<div class="line"> enddo</div>
<div class="line"> !</div>
<div class="line"> ! Data</div>
<div class="line"> !</div>
<div class="line"> ! 1 6 11</div>
<div class="line"> ! 2 7 12</div>
<div class="line"> ! 3 8 13</div>
<div class="line"> ! 4 9 14</div>
<div class="line"> ! 5 10 15</div>
<div class="line"> . . .</div>
<div class="line"> CALL <a class="code" href="group___f_h5_s.html#ga54083c84fd4be392ac770cf223cd6cf4">h5screate_simple_f</a>(rank, dims, dspace_id, error)</div>
<div class="ttc" id="agroup___f_h5_s_html_ga54083c84fd4be392ac770cf223cd6cf4"><div class="ttname"><a href="group___f_h5_s.html#ga54083c84fd4be392ac770cf223cd6cf4">h5s::h5screate_simple_f</a></div><div class="ttdeci">subroutine h5screate_simple_f(rank, dims, space_id, hdferr, maxdims)</div><div class="ttdoc">Creates a new simple data space and opens it for access.</div><div class="ttdef"><b>Definition:</b> H5Sff.F90:59</div></div>
</div><!-- fragment --><table class="doxtable">
<caption align="top">Comparing C and Fortran dataspaces</caption>
<tr>
<td>A dataset stored by a C program in a 3 x 5 array: </td></tr>
<tr>
<td><div class="image">
<img src="Dspace_CvsF1.gif" alt=""/>
</div>
</td></tr>
<tr>
<td>The same dataset stored by a Fortran program in a 5 x 3 array: </td></tr>
<tr>
<td><div class="image">
<img src="Dspace_CvsF2.gif" alt=""/>
</div>
</td></tr>
<tr>
<td>The first dataset above as written to an HDF5 file from C or the second dataset above as written from Fortran: </td></tr>
<tr>
<td><div class="image">
<img src="Dspace_CvsF3.gif" alt=""/>
</div>
</td></tr>
<tr>
<td>The first dataset above as written to an HDF5 file from Fortran: </td></tr>
<tr>
<td><div class="image">
<img src="Dspace_CvsF4.gif" alt=""/>
</div>
</td></tr>
</table>
<p><em>Note: The HDF5 Library stores arrays along the fastest‐changing dimension. This approach is often referred to as being “in C order.” C, C++, and Java work with arrays in row‐major order. In other words, the row, or the last dimension, is the fastest‐changing dimension. Fortran, on the other hand, handles arrays in column‐major order making the column, or the first dimension, the fastest‐changing dimension. Therefore, the C and Fortran arrays illustrated in the top portion of this figure are stored identically in an HDF5 file. This ensures that data written by any language can be meaningfully read, interpreted, and manipulated by any other.</em></p>
<h4>Finding Dataspace Characteristics</h4>
<p>The HDF5 Library provides several APIs designed to query the characteristics of a dataspace.</p>
<p>The function <a class="el" href="group___h5_s.html#gab0b1560f7c8402986f332522e2adae1d">H5Sis_simple</a> returns information about the type of a dataspace. This function is rarely used and currently supports only simple and scalar dataspaces.</p>
<p>To find out the dimensionality, or rank, of a dataspace, use <a class="el" href="group___h5_s.html#gae5282a81692b80b5b19dd12d05b9b28e">H5Sget_simple_extent_ndims</a>. <a class="el" href="group___h5_s.html#gac494409b615d8e67c5edd9eb2848b2f3">H5Sget_simple_extent_dims</a> can also be used to find out the rank. See the example below. If both functions return 0 for the value of rank, then the dataspace is scalar.</p>
<p>To query the sizes of the current and maximum dimensions, use <a class="el" href="group___h5_s.html#gac494409b615d8e67c5edd9eb2848b2f3">H5Sget_simple_extent_dims</a>.</p>
<p>The following example illustrates querying the rank and dimensions of a dataspace using these functions. </p><div class="fragment"><div class="line"><a class="code" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> space_id;</div>
<div class="line"><span class="keywordtype">int</span> rank;</div>
<div class="line"><a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> *current_dims;</div>
<div class="line"><a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> *max_dims;</div>
<div class="line">. . .</div>
<div class="line">rank = <a class="code" href="group___h5_s.html#gae5282a81692b80b5b19dd12d05b9b28e">H5Sget_simple_extent_ndims</a>(space_id);</div>
<div class="line"><span class="comment">// (or rank = H5Sget_simple_extent_dims(space_id, NULL, NULL);)</span></div>
<div class="line">current_dims = (<a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a>)malloc(rank * <span class="keyword">sizeof</span>(<a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a>));</div>
<div class="line">max_dims = (<a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a>)malloc(rank * <span class="keyword">sizeof</span>(<a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a>));</div>
<div class="line"><a class="code" href="group___h5_s.html#gac494409b615d8e67c5edd9eb2848b2f3">H5Sget_simple_extent_dims</a>(space_id, current_dims, max_dims);</div>
<div class="line"><span class="comment">// Print values here</span></div>
<div class="ttc" id="agroup___h5_s_html_gac494409b615d8e67c5edd9eb2848b2f3"><div class="ttname"><a href="group___h5_s.html#gac494409b615d8e67c5edd9eb2848b2f3">H5Sget_simple_extent_dims</a></div><div class="ttdeci">int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], hsize_t maxdims[])</div><div class="ttdoc">Retrieves dataspace dimension size and maximum size.</div></div>
<div class="ttc" id="agroup___h5_s_html_gae5282a81692b80b5b19dd12d05b9b28e"><div class="ttname"><a href="group___h5_s.html#gae5282a81692b80b5b19dd12d05b9b28e">H5Sget_simple_extent_ndims</a></div><div class="ttdeci">int H5Sget_simple_extent_ndims(hid_t space_id)</div><div class="ttdoc">Determines the dimensionality of a dataspace.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsec_dataspace_transfer"></a>
Dataspaces and Data Transfer</h2>
<p>Read and write operations transfer data between an HDF5 file on disk and in memory. The shape that the array data takes in the file and in memory may be the same, but HDF5 also allows users the ability to represent data in memory in a different shape than in the file. If the shape of an array in the file and in memory will be the same, then the same dataspace definition can be used for both. If the shape of an array in memory needs to be different than the shape in the file, then the dataspace definition for the shape of the array in memory can be changed. During a read operation, the array will be read into the different shape in memory, and during a write operation, the array will be written to the file in the shape specified by the dataspace in the file. The only qualification is that the number of elements read or written must be the same in both the source and the destination dataspaces.</p>
<p>Item a in the figure below shows a simple example of a read operation in which the data is stored as a 3 by 4 array in the file (item b) on disk, but the program wants it to be a 4 by 3 array in memory. This is accomplished by setting the memory dataspace to describe the desired memory layout, as in item c. The read operation reads the data in the file array into the memory array.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_read.gif" alt=""/>
<div class="caption">
Data layout before and after a read operation</div></div>
</td></tr>
</table>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_move.gif" alt=""/>
<div class="caption">
Moving data from disk to memory</div></div>
</td></tr>
</table>
<p>Both the source and destination are stored as contiguous blocks of storage with the elements in the order specified by the dataspace. The figure above shows one way the elements might be organized. In item a, the elements are stored as 3 blocks of 4 elements. The destination is an array of 12 elements in memory (see item c). As the figure suggests, the transfer reads the disk blocks into a memory buffer (see item b), and then writes the elements to the correct locations in memory. A similar process occurs in reverse when data is written to disk.</p>
<h3><a class="anchor" id="subsubsec_dataspace_transfer_select"></a>
Data Selection</h3>
<p>In addition to rearranging data, the transfer may select the data elements from the source and destination.</p>
<p>Data selection is implemented by creating a dataspace object that describes the selected elements (within the hyper rectangle) rather than the whole array. Two dataspace objects with selections can be used in data transfers to read selected elements from the source and write selected elements to the destination. When data is transferred using the dataspace object, only the selected elements will be transferred.</p>
<p>This can be used to implement partial I/O, including: </p><ul>
<li>Sub‐setting ‐ reading part of a large dataset </li>
<li>Sampling ‐ reading selected elements (for example, every second element) of a dataset </li>
<li>Scatter‐gather ‐ read non‐contiguous elements into contiguous locations (gather) or read contiguous elements into non‐contiguous locations (scatter) or both</li>
</ul>
<p>To use selections, the following steps are followed: </p><ul>
<li>1. Get or define the dataspace for the source and destination </li>
<li>2. Specify one or more selections for source and destination dataspaces </li>
<li>3. Transfer data using the dataspaces with selections</li>
</ul>
<p>A selection is created by applying one or more selections to a dataspace. A selection may override any other selections (<a class="el" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>) or may be “Ored” with previous selections on the same dataspace (<a class="el" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8">H5S_SELECT_OR</a>). In the latter case, the resulting selection is the union of the selection and all previously selected selections. Arbitrary sets of points from a dataspace can be selected by specifying an appropriate set of selections.</p>
<p>Two selections are used in data transfer, so the source and destination must be compatible, as described below.</p>
<p>There are two forms of selection, hyperslab and point. A selection must be either a point selection or a set of hyperslab selections. Selections cannot be mixed.</p>
<p>The definition of a selection within a dataspace, not the data in the selection, cannot be saved to the file unless the selection definition is saved as a region reference. For more information, see <a class="el" href="_h5_s__u_g.html#subsec_dataspace_refer">References to Dataset Regions</a>.</p>
<h4>Hyperslab Selection</h4>
<p>A hyperslab is a selection of elements from a hyper rectangle. An HDF5 hyperslab is a rectangular pattern defined by four arrays. The four arrays are summarized in the table below.</p>
<p>The offset defines the origin of the hyperslab in the original dataspace.</p>
<p>The stride is the number of elements to increment between selected elements. A stride of ‘1’ is every element, a stride of ‘2’ is every second element, etc. Note that there may be a different stride for each dimen‐sion of the dataspace. The default stride is 1.</p>
<p>The count is the number of elements in the hyperslab selection. When the stride is 1, the selection is a hyper rectangle with a corner at the offset and size count[0] by count[1] by.... When stride is greater than one, the hyperslab bounded by the offset and the corners defined by stride[n] * count[n].</p>
<table class="doxtable">
<caption align="top">Hyperslab elements</caption>
<tr>
<th>Parameter </th><th>Description </th></tr>
<tr>
<td>Offset </td><td>The starting location for the hyperslab. </td></tr>
<tr>
<td>Stride </td><td>The number of elements to separate each element or block to be selected. </td></tr>
<tr>
<td>Count </td><td>The number of elements or blocks to select along each dimension. </td></tr>
<tr>
<td>Block </td><td>The size of the block selected from the dataspace. </td></tr>
</table>
<p>The block is a count on the number of repetitions of the hyperslab. The default block size is '1', which is one hyperslab. A block of 2 would be two hyperslabs in that dimension, with the second starting at offset[n] + (count[n] * stride[n]) + 1.</p>
<p>A hyperslab can be used to access a sub‐set of a large dataset. The figure below shows an example of a hyperslab that reads a rectangle from the middle of a larger two dimensional array. The destination is the same shape as the source.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_subset.gif" alt=""/>
<div class="caption">
Access a sub‐set of data with a hyperslab</div></div>
</td></tr>
</table>
<p>Hyperslabs can be combined to select complex regions of the source and destination. The figure below shows an example of a transfer from one non‐rectangular region into another non‐rectangular region. The source is defined as the union of two hyperslabs, and the destination is the union of three hyperslabs.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_complex.gif" alt=""/>
<div class="caption">
Build complex regions with hyperslab unions</div></div>
</td></tr>
</table>
<p>Hyperslabs may also be used to collect or scatter data from regular patterns. The figure below shows an example where the source is a repeating pattern of blocks, and the destination is a single, one dimensional array.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_combine.gif" alt=""/>
<div class="caption">
Use hyperslabs to combine or disperse data</div></div>
</td></tr>
</table>
<h4>Select Points</h4>
<p>The second type of selection is an array of points such as coordinates. Essentially, this selection is a list of all the points to include. The figure below shows an example of a transfer of seven elements from a two dimensional dataspace to a three dimensional dataspace using a point selection to specify the points.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_point.gif" alt=""/>
<div class="caption">
Point selection</div></div>
</td></tr>
</table>
<h4>Rules for Defining Selections</h4>
<p>A selection must have the same number of dimensions (rank) as the dataspace it is applied to, although it may select from only a small region such as a plane from a 3D dataspace. Selections do not affect the extent of the dataspace, the selection may be larger than the dataspace. The boundaries of selections are reconciled with the extent at the time of the data transfer.</p>
<h4>Data Transfer with Selections</h4>
<p>A data transfer (read or write) with selections is the same as any read or write, except the source and destination dataspace have compatible selections.</p>
<p>During the data transfer, the following steps are executed by the library: </p><ul>
<li>The source and destination dataspaces are checked to assure that the selections are compatible. <ul>
<li>
Each selection must be within the current extent of the dataspace. A selection may be defined to extend outside the current extent of the dataspace, but the dataspace cannot be accessed if the selection is not valid at the time of the access. </li>
<li>
The total number of points selected in the source and destination must be the same. Note that the dimensionality of the source and destination can be different (for example, the source could be 2D, the destination 1D or 3D), and the shape can be different, but the number of elements selected must be the same.</li>
</ul>
</li>
<li>The data is transferred, element by element.</li>
</ul>
<p>Selections have an iteration order for the points selected, which can be any permutation of the dimensions involved (defaulting to 'C' array order) or a specific order for the selected points, for selections composed of single array elements with <a class="el" href="group___h5_s.html#ga2f4407dd73d0ec37e5d9e80e4382483d">H5Sselect_elements</a>.</p>
<p>The elements of the selections are transferred in row‐major, or C order. That is, it is assumed that the first dimension varies slowest, the second next slowest, and so forth. For hyperslab selections, the order can be any permutation of the dimensions involved (defaulting to ‘C’ array order). When multiple hyperslabs are combined, the hyperslabs are coalesced into contiguous reads and writes.</p>
<p>In the case of point selections, the points are read and written in the order specified.</p>
<h3><a class="anchor" id="subsubsec_dataspace_transfer_model"></a>
Programming Model</h3>
<h4>Selecting Hyperslabs</h4>
<p>Suppose we want to read a 3x4 hyperslab from a dataset in a file beginning at the element <1,2> in the dataset, and read it into a 7 x 7 x 3 array in memory. See the figure below. 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.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_select.gif" alt=""/>
<div class="caption">
Selecting a hyperslab</div></div>
</td></tr>
</table>
<p>The code in the first example below illustrates the selection of the hyperslab in the file dataspace. The second example below shows the definition of the destination dataspace in memory. Since the in‐memory dataspace has three dimensions, the hyperslab is an array with three dimensions with the last dimension being 1: <3,4,1>. The third example below shows the read using the source and destination dataspaces with selections.</p>
<p><em>Selecting a hyperslab</em> </p><div class="fragment"><div class="line"><span class="comment">//get the file dataspace.</span></div>
<div class="line">dataspace = <a class="code" href="group___h5_d.html#gad42a46be153d895d8c28a11ebf5a0d0a">H5Dget_space</a>(dataset); <span class="comment">// dataspace identifier</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Define hyperslab in the dataset.</span></div>
<div class="line">offset[0] = 1;</div>
<div class="line">offset[1] = 2;</div>
<div class="line">count[0] = 3;</div>
<div class="line">count[1] = 4;</div>
<div class="line">status = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(dataspace, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, NULL, count, NULL);</div>
<div class="ttc" id="a_h5_spublic_8h_html_a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550"><div class="ttname"><a href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a></div><div class="ttdeci">@ H5S_SELECT_SET</div><div class="ttdef"><b>Definition:</b> H5Spublic.h:87</div></div>
<div class="ttc" id="agroup___h5_d_html_gad42a46be153d895d8c28a11ebf5a0d0a"><div class="ttname"><a href="group___h5_d.html#gad42a46be153d895d8c28a11ebf5a0d0a">H5Dget_space</a></div><div class="ttdeci">hid_t H5Dget_space(hid_t dset_id)</div><div class="ttdoc">Returns an identifier for a copy of the dataspace for a dataset.</div></div>
<div class="ttc" id="agroup___h5_s_html_ga6adfdf1b95dc108a65bf66e97d38536d"><div class="ttname"><a href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a></div><div class="ttdeci">herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], const hsize_t count[], const hsize_t block[])</div><div class="ttdoc">Selects a hyperslab region to add to the current selected region.</div></div>
</div><!-- fragment --><p><em>Defining the destination memory</em> </p><div class="fragment"><div class="line"><span class="comment">// Define memory dataspace.</span></div>
<div class="line">dimsm[0] = 7;</div>
<div class="line">dimsm[1] = 7;</div>
<div class="line">dimsm[2] = 3;</div>
<div class="line">memspace = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(3,dimsm,NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Define memory hyperslab.</span></div>
<div class="line">offset_out[0] = 3;</div>
<div class="line">offset_out[1] = 0;</div>
<div class="line">offset_out[2] = 0;</div>
<div class="line">count_out[0] = 3;</div>
<div class="line">count_out[1] = 4;</div>
<div class="line">count_out[2] = 1;</div>
<div class="line">status = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(memspace, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset_out, NULL, count_out, NULL);</div>
</div><!-- fragment --><p><em>A sample read specifying source and destination dataspaces</em> </p><div class="fragment"><div class="line">ret = <a class="code" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset, <a class="code" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, memspace,dataspace, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data);</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_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 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 --><h4>Example with Strides and Blocks</h4>
<p>Consider an 8 x 12 dataspace into which we want to write eight 3 x 2 blocks in a two dimensional array from a source dataspace in memory that is a 50‐element one dimensional array. See the figure below.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_write1to2.gif" alt=""/>
<div class="caption">
Write from a one dimensional array to a two dimensional array</div></div>
</td></tr>
</table>
<p>The example below shows code to write 48 elements from the one dimensional array to the file dataset starting with the second element in vector. The destination hyperslab has the following parameters: offset=(0,1), stride=(4,3), count=(2,4), block=(3,2). The source has the parameters: offset=(1), stride=(1), count=(48), block=(1). After these operations, the file dataspace will have the values shown in item b in the figure above. Notice that the values are inserted in the file dataset in row‐major order.</p>
<p><em>Write from a one dimensional array to a two dimensional array</em> </p><div class="fragment"><div class="line"><span class="comment">// Select hyperslab for the dataset in the file, using 3 x 2 blocks, (4,3) stride (2,4)</span></div>
<div class="line"><span class="comment">// count starting at the position (0,1).</span></div>
<div class="line">offset[0] = 0; offset[1] = 1;</div>
<div class="line">stride[0] = 4; stride[1] = 3;</div>
<div class="line">count[0] = 2; count[1] = 4;</div>
<div class="line">block[0] = 3; block[1] = 2;</div>
<div class="line">ret = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(fid, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, stride, count, block);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create dataspace for the first dataset.</span></div>
<div class="line">mid1 = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(MSPACE1_RANK, dim1, NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Select hyperslab.</span></div>
<div class="line"><span class="comment">// We will use 48 elements of the vector buffer starting</span></div>
<div class="line"><span class="comment">// at the second element. Selected elements are</span></div>
<div class="line"><span class="comment">// 1 2 3 . . . 48</span></div>
<div class="line">offset[0] = 1;</div>
<div class="line">stride[0] = 1;</div>
<div class="line">count[0] = 48;</div>
<div class="line">block[0] = 1;</div>
<div class="line">ret = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(mid1, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, stride, count, block);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Write selection from the vector buffer to the dataset in the file.</span></div>
<div class="line">ret = <a class="code" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>(dataset, <a class="code" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, midd1, fid, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, vector)</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><!-- fragment --><h4>Selecting a Union of Hyperslabs</h4>
<p>The HDF5 Library allows the user to select a union of hyperslabs and write or read the selection into another selection. The shapes of the two selections may differ, but the number of elements must be equal.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_transfer.gif" alt=""/>
<div class="caption">
Transferring hyperslab unions</div></div>
</td></tr>
</table>
<p>The figure above shows the transfer of a selection that is two overlapping hyperslabs from the dataset into a union of hyperslabs in the memory dataset. Note that the destination dataset has a different shape from the source dataset. Similarly, the selection in the memory dataset could have a different shape than the selected union of hyperslabs in the original file. For simplicity, the selection is that same shape at the destination.</p>
<p>To implement this transfer, it is necessary to: </p><ul>
<li>1. Get the source dataspace </li>
<li>2. Define one hyperslab selection for the source </li>
<li>3. Define a second hyperslab selection, unioned with the first </li>
<li>4. Get the destination dataspace </li>
<li>5. Define one hyperslab selection for the destination </li>
<li>6. Define a second hyperslab selection, unioned with the first </li>
<li>7. Execute the data transfer (H5Dread or H5Dwrite) using the source and destination dataspaces</li>
</ul>
<p>The example below shows example code to create the selections for the source dataspace (the file). The first hyperslab is size 3 x 4 and the left upper corner at the position (1,2). The hyperslab is a simple rectangle, so the stride and block are 1. The second hyperslab is 6 x 5 at the position (2,4). The second selection is a union with the first hyperslab (<a class="el" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8">H5S_SELECT_OR</a>).</p>
<p><em> Select source hyperslabs</em> </p><div class="fragment"><div class="line">fid = <a class="code" href="group___h5_d.html#gad42a46be153d895d8c28a11ebf5a0d0a">H5Dget_space</a>(dataset);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Select first hyperslab for the dataset in the file.</span></div>
<div class="line">offset[0] = 1; offset[1] = 2;</div>
<div class="line">block[0] = 1; block[1] = 1;</div>
<div class="line">stride[0] = 1; stride[1] = 1;</div>
<div class="line">count[0] = 3; count[1] = 4;</div>
<div class="line">ret = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(fid, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, stride, count, block);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Add second selected hyperslab to the selection.</span></div>
<div class="line">offset[0] = 2; offset[1] = 4;</div>
<div class="line">block[0] = 1; block[1] = 1;</div>
<div class="line">stride[0] = 1; stride[1] = 1;</div>
<div class="line">count[0] = 6; count[1] = 5;</div>
<div class="line">ret = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(fid, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8">H5S_SELECT_OR</a>, offset, stride, count, block);</div>
<div class="ttc" id="a_h5_spublic_8h_html_a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8"><div class="ttname"><a href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8">H5S_SELECT_OR</a></div><div class="ttdeci">@ H5S_SELECT_OR</div><div class="ttdef"><b>Definition:</b> H5Spublic.h:88</div></div>
</div><!-- fragment --><p>The example below shows example code to create the selection for the destination in memory. The steps are similar. In this example, the hyperslabs are the same shape, but located in different positions in the dataspace. The first hyperslab is 3 x 4 and starts at (0,0), and the second is 6 x 5 and starts at (1,2). Finally, the H5Dread call transfers the selected data from the file dataspace to the selection in memory. In this example, the source and destination selections are two overlapping rectangles. In general, any number of rectangles can be OR’ed, and they do not have to be contiguous. The order of the selections does not matter, but the first should use <a class="el" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a> ; subsequent selections are unioned using <a class="el" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8">H5S_SELECT_OR</a>.</p>
<p>It is important to emphasize that the source and destination do not have to be the same shape (or number of rectangles). As long as the two selections have the same number of elements, the data can be transferred.</p>
<p><em>Select destination hyperslabs</em> </p><div class="fragment"><div class="line"><span class="comment">// Create memory dataspace.</span></div>
<div class="line">mid = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(MSPACE_RANK, mdim, NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Select two hyperslabs in memory. Hyperslabs has the</span></div>
<div class="line"><span class="comment">// same size and shape as the selected hyperslabs for</span></div>
<div class="line"><span class="comment">// the file dataspace.</span></div>
<div class="line">offset[0] = 0; offset[1] = 0;</div>
<div class="line">block[0] = 1; block[1] = 1;</div>
<div class="line">stride[0] = 1; stride[1] = 1;</div>
<div class="line">count[0] = 3; count[1] = 4;</div>
<div class="line">ret = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(mid, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, stride, count, block);</div>
<div class="line"> </div>
<div class="line">offset[0] = 1; offset[1] = 2;</div>
<div class="line">block[0] = 1; block[1] = 1;</div>
<div class="line">stride[0] = 1; stride[1] = 1;</div>
<div class="line">count[0] = 6; count[1] = 5;</div>
<div class="line">ret = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(mid, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8">H5S_SELECT_OR</a>, offset, stride, count, block);</div>
<div class="line"> </div>
<div class="line">ret = <a class="code" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset, <a class="code" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, mid, fid, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, matrix_out);</div>
</div><!-- fragment --><h4>Selecting a List of Independent Points</h4>
<p>It is also possible to specify a list of elements to read or write using the function H5Sselect_elements.</p>
<p>The procedure is similar to hyperslab selections. </p><ul>
<li>1. Get the source dataspace </li>
<li>2. Set the selected points </li>
<li>3. Get the destination dataspace </li>
<li>4. Set the selected points </li>
<li>5. Transfer the data using the source and destination dataspaces</li>
</ul>
<p>The figure below shows an example where four values are to be written to four separate points in a two dimensional dataspace. The source dataspace is a one dimensional array with the values 53, 59, 61, 67. The destination dataspace is an 8 x 12 array. The elements are to be written to the points (0,0), (3,3), (3,5), and (5,6). In this example, the source does not require a selection. The example below the figure shows example code to implement this transfer.</p>
<p>A point selection lists the exact points to be transferred and the order they will be transferred. The source and destination are required to have the same number of elements. A point selection can be used with a hyperslab (for example, the source could be a point selection and the destination a hyperslab, or vice versa), so long as the number of elements selected are the same.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_separate.gif" alt=""/>
<div class="caption">
Write data to separate points</div></div>
</td></tr>
</table>
<p><em>Write data to separate points</em> </p><div class="fragment"><div class="line"><a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> dim2[] = {4};</div>
<div class="line"><span class="keywordtype">int</span> values[] = {53, 59, 61, 67};</div>
<div class="line"> </div>
<div class="line"><span class="comment">// file dataspace</span></div>
<div class="line"><a class="code" href="_h5public_8h.html#a7d9d4293176a8d7535ea6d4038235280">hssize_t</a> coord[4][2];</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create dataspace for the second dataset.</span></div>
<div class="line">mid2 = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(1, dim2, NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Select sequence of NPOINTS points in the file dataspace.</span></div>
<div class="line">coord[0][0] = 0; coord[0][1] = 0;</div>
<div class="line">coord[1][0] = 3; coord[1][1] = 3;</div>
<div class="line">coord[2][0] = 3; coord[2][1] = 5;</div>
<div class="line">coord[3][0] = 5; coord[3][1] = 6;</div>
<div class="line"> </div>
<div class="line">ret = <a class="code" href="group___h5_s.html#ga2f4407dd73d0ec37e5d9e80e4382483d">H5Sselect_elements</a>(fid, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, NPOINTS, (<span class="keyword">const</span> <a class="code" href="_h5public_8h.html#a7d9d4293176a8d7535ea6d4038235280">hssize_t</a> **)coord);</div>
<div class="line"> </div>
<div class="line">ret = <a class="code" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>(dataset, <a class="code" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, mid2, fid, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, values);</div>
<div class="ttc" id="a_h5public_8h_html_a7d9d4293176a8d7535ea6d4038235280"><div class="ttname"><a href="_h5public_8h.html#a7d9d4293176a8d7535ea6d4038235280">hssize_t</a></div><div class="ttdeci">int64_t hssize_t</div><div class="ttdef"><b>Definition:</b> H5public.h:309</div></div>
<div class="ttc" id="agroup___h5_s_html_ga2f4407dd73d0ec37e5d9e80e4382483d"><div class="ttname"><a href="group___h5_s.html#ga2f4407dd73d0ec37e5d9e80e4382483d">H5Sselect_elements</a></div><div class="ttdeci">herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, size_t num_elem, const hsize_t *coord)</div><div class="ttdoc">Selects array elements to be included in the selection for a dataspace.</div></div>
</div><!-- fragment --><h4>Combinations of Selections</h4>
<p>Selections are a very flexible mechanism for reorganizing data during a data transfer. With different combinations of dataspaces and selections, it is possible to implement many kinds of data transfers including sub‐setting, sampling, and reorganizing the data. The table below gives some example combinations of source and destination, and the operations they implement.</p>
<table class="doxtable">
<caption>Selection operations</caption>
<tr>
<th><p class="starttd"></p>
<p class="intertd">Source</p>
<p class="endtd"></p>
</th><th><p class="starttd"></p>
<p class="intertd">Destination</p>
<p class="endtd"></p>
</th><th><p class="starttd"></p>
<p class="intertd">Operation</p>
<p class="endtd"></p>
</th></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">All</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">All</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Copy whole array</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">All</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">All (different shape)</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Copy and reorganize array</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Hyperslab</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">All</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Sub-set</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Hyperslab</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Hyperslab (same shape)</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Selection</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Hyperslab</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Hyperslab (different shape)</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Select and rearrange</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Hyperslab with stride or block</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">All or hyperslab with stride 1</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Sub-sample, scatter</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Hyperslab</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Points</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Scatter</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Points</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Hyperslab or all</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Gather</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Points</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Points (same)</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Selection</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><p class="starttd"></p>
<p class="intertd">Points</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Points (different)</p>
<p class="endtd"></p>
</td><td><p class="starttd"></p>
<p class="intertd">Reorder points</p>
<p class="endtd"></p>
</td></tr>
</table>
<h2><a class="anchor" id="subsec_dataspace_select"></a>
Dataspace Selection Operations and Data Transfer</h2>
<p>This section is under construction.</p>
<h2><a class="anchor" id="subsec_dataspace_refer"></a>
References to Dataset Regions</h2>
<p>Another use of selections is to store a reference to a region of a dataset. An HDF5 object reference object is a pointer to an object (dataset, group, or committed datatype) in the file. A selection can be used to create a pointer to a set of selected elements of a dataset, called a region reference. The selection can be either a point selection or a hyperslab selection.</p>
<p>A region reference is an object maintained by the HDF5 Library. The region reference can be stored in a dataset or attribute, and then read. The dataset or attribute is defined to have the special datatype, <a class="el" href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a>.</p>
<p>To discover the elements and/or read the data, the region reference can be dereferenced. The <a class="el" href="group___h5_r.html#ga5dc19b9d1833af66c5e1f819f2c05c4a">H5Rdereference</a> call returns an identifier for the dataset, and then the selected dataspace can be retrieved with a call to <a class="el" href="group___h5_r.html#ga1702d609e85b9edd3d1e526a0276484f" title="Sets up a dataspace and selection as specified by a region reference.">H5Rget_region()</a>. The selected dataspace can be used to read the selected data elements.</p>
<p>For more information, </p><dl class="section see"><dt>See also</dt><dd>subsubsec_datatype_other_refs.</dd></dl>
<h3><a class="anchor" id="subsubsec_dataspace_refer_use"></a>
Example Uses for Region References</h3>
<p>Region references are used to implement stored pointers to data within a dataset. For example, features in a large dataset might be indexed by a table. See the figure below. This table could be stored as an HDF5 dataset with a compound datatype, for example, with a field for the name of the feature and a region reference to point to the feature in the dataset. See the second figure below.</p>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_features.gif" alt=""/>
<div class="caption">
Features indexed by a table</div></div>
</td></tr>
</table>
<table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_features_cmpd.gif" alt=""/>
<div class="caption">
Storing the table with a compound datatype</div></div>
</td></tr>
</table>
<h3><a class="anchor" id="subsubsec_dataspace_refer_create"></a>
Creating References to Regions</h3>
<p>To create a region reference: </p><ul>
<li>1. Create or open the dataset that contains the region </li>
<li>2. Get the dataspace for the dataset </li>
<li>3. Define a selection that specifies the region </li>
<li>4. Create a region reference using the dataset and dataspace with selection </li>
<li>5. Write the region reference(s) to the desired dataset or attribute</li>
</ul>
<p>The figure below shows a diagram of a file with three datasets. Dataset D1 and D2 are two dimensional arrays of integers. Dataset R1 is a one dimensional array of references to regions in D1 and D2. The regions can be any valid selection of the dataspace of the target dataset. </p><table class="doxtable">
<tr>
<td><div class="image">
<img src="Dspace_three_datasets.gif" alt=""/>
<div class="caption">
A file with three datasets</div></div>
</td></tr>
</table>
<p><em>Note: In the figure above, R1 is a 1 D array of region pointers; each pointer refers to a selection in one dataset.</em></p>
<p>The example below shows code to create the array of region references. The references are created in an array of type <a class="el" href="structhdset__reg__ref__t.html">hdset_reg_ref_t</a>. Each region is defined as a selection on the dataspace of the dataset, and a reference is created using <a class="el" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate()</a>. The call to <a class="el" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate()</a> specifies the file, dataset, and the dataspace with selection.</p>
<p><em>Create an array of region references</em> </p><div class="fragment"><div class="line"><span class="comment">// create an array of 4 region references</span></div>
<div class="line"><a class="code" href="structhdset__reg__ref__t.html">hdset_reg_ref_t</a> ref[4];</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Create a reference to the first hyperslab in the first Dataset.</span></div>
<div class="line">offset[0] = 1; offset[1] = 1;</div>
<div class="line">count[0] = 3; count[1] = 2;</div>
<div class="line">status = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(space_id, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, NULL, count, NULL);</div>
<div class="line">status = <a class="code" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&ref[0], file_id, <span class="stringliteral">"D1"</span>, <a class="code" href="_h5_rpublic_8h.html#a2a28c48c03a4616a02f9157fca4b2df0">H5R_DATASET_REGION</a>, space_id);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// The second reference is to a union of hyperslabs in the first Dataset</span></div>
<div class="line">offset[0] = 5; offset[1] = 3;</div>
<div class="line">count[0] = 1; count[1] = 4;</div>
<div class="line">status = <a class="code" href="group___h5_s.html#gac59773d4a0953cb2db0ed57a05699095">H5Sselect_none</a>(space_id);</div>
<div class="line">status = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(space_id, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, NULL, count, NULL);</div>
<div class="line">offset[0] = 6; offset[1] = 5;</div>
<div class="line">count[0] = 1; count[1] = 2;</div>
<div class="line">status = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(space_id, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fa1a8dc2bbb8d8268d6e7665a4664b9ad8">H5S_SELECT_OR</a>, offset, NULL, count, NULL);</div>
<div class="line">status = <a class="code" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&ref[1], file_id, <span class="stringliteral">"D1"</span>, <a class="code" href="_h5_rpublic_8h.html#a2a28c48c03a4616a02f9157fca4b2df0">H5R_DATASET_REGION</a>, space_id);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// the fourth reference is to a selection of points in the first Dataset</span></div>
<div class="line">status = <a class="code" href="group___h5_s.html#gac59773d4a0953cb2db0ed57a05699095">H5Sselect_none</a>(space_id);</div>
<div class="line">coord[0][0] = 4; coord[0][1] = 4;</div>
<div class="line">coord[1][0] = 2; coord[1][1] = 6;</div>
<div class="line">coord[2][0] = 3; coord[2][1] = 7;</div>
<div class="line">coord[3][0] = 1; coord[3][1] = 5;</div>
<div class="line">coord[4][0] = 5; coord[4][1] = 8;</div>
<div class="line"> </div>
<div class="line">status = <a class="code" href="group___h5_s.html#ga2f4407dd73d0ec37e5d9e80e4382483d">H5Sselect_elements</a>(space_id, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, num_points, (<span class="keyword">const</span> <a class="code" href="_h5public_8h.html#a7d9d4293176a8d7535ea6d4038235280">hssize_t</a> **)coord);</div>
<div class="line">status = <a class="code" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&ref[3], file_id, <span class="stringliteral">"D1"</span>, <a class="code" href="_h5_rpublic_8h.html#a2a28c48c03a4616a02f9157fca4b2df0">H5R_DATASET_REGION</a>, space_id);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// the third reference is to a hyperslab in the second Dataset</span></div>
<div class="line">offset[0] = 0; offset[1] = 0;</div>
<div class="line">count[0] = 4; count[1] = 6;</div>
<div class="line">status = <a class="code" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d">H5Sselect_hyperslab</a>(space_id2, <a class="code" href="_h5_spublic_8h.html#a10093bab27cc5720efdab3186993da0fab90faf3dc59ecf6f28197ef471141550">H5S_SELECT_SET</a>, offset, NULL, count, NULL);</div>
<div class="line">status = <a class="code" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d">H5Rcreate</a>(&ref[2], file_id, <span class="stringliteral">"D2"</span>, <a class="code" href="_h5_rpublic_8h.html#a2a28c48c03a4616a02f9157fca4b2df0">H5R_DATASET_REGION</a>, space_id2);</div>
<div class="ttc" id="a_h5_rpublic_8h_html_a2a28c48c03a4616a02f9157fca4b2df0"><div class="ttname"><a href="_h5_rpublic_8h.html#a2a28c48c03a4616a02f9157fca4b2df0">H5R_DATASET_REGION</a></div><div class="ttdeci">#define H5R_DATASET_REGION</div><div class="ttdef"><b>Definition:</b> H5Rpublic.h:603</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___h5_s_html_gac59773d4a0953cb2db0ed57a05699095"><div class="ttname"><a href="group___h5_s.html#gac59773d4a0953cb2db0ed57a05699095">H5Sselect_none</a></div><div class="ttdeci">herr_t H5Sselect_none(hid_t spaceid)</div><div class="ttdoc">Resets the selection region to include no elements.</div></div>
<div class="ttc" id="astructhdset__reg__ref__t_html"><div class="ttname"><a href="structhdset__reg__ref__t.html">hdset_reg_ref_t</a></div><div class="ttdef"><b>Definition:</b> H5Rpublic.h:86</div></div>
</div><!-- fragment --><p>When all the references are created, the array of references is written to the dataset R1. The dataset is declared to have datatype <a class="el" href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a>. See the example below.</p>
<p><em>Write the array of references to a dataset</em> </p><div class="fragment"><div class="line">Hsize_t dimsr[1];</div>
<div class="line">dimsr[0] = 4;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Dataset with references.</span></div>
<div class="line">spacer_id = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(1, dimsr, NULL);</div>
<div class="line">dsetr_id = <a class="code" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file_id, <span class="stringliteral">"R1"</span>, <a class="code" href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a>, spacer_id, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>,</div>
<div class="line"><a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Write dataset with the references.</span></div>
<div class="line">status = <a class="code" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>(dsetr_id, <a class="code" href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a>, <a class="code" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, ref);</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_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___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><!-- fragment --><p>When creating region references, the following rules are enforced. </p><ul>
<li>The selection must be a valid selection for the target dataset, just as when transferring data </li>
<li>The dataset must exist in the file when the reference is created; <a class="el" href="group___h5_r.html#ga0ac6997b5de26b11d91a95de2869950d" title="Creates a reference.">H5Rcreate</a> </li>
<li>The target dataset must be in the same file as the stored reference</li>
</ul>
<h3><a class="anchor" id="subsubsec_dataspace_refer_read"></a>
Reading References to Regions</h3>
<p>To retrieve data from a region reference, the reference must be read from the file, and then the data can be retrieved. The steps are: </p><ul>
<li>1. Open the dataset or attribute containing the reference objects </li>
<li>2. Read the reference object(s) </li>
<li>3. For each region reference, get the dataset (<a class="el" href="group___h5_r.html#ga5dc19b9d1833af66c5e1f819f2c05c4a">H5Rdereference</a>) and dataspace (<a class="el" href="group___h5_r.html#ga1702d609e85b9edd3d1e526a0276484f" title="Sets up a dataspace and selection as specified by a region reference.">H5Rget_region</a>) </li>
<li>4. Use the dataspace and datatype to discover what space is needed to store the data, allocate the correct storage and create a dataspace and datatype to define the memory data layout</li>
</ul>
<p>The example below shows code to read an array of region references from a dataset, and then read the data from the first selected region. Note that the region reference has information that records the dataset (within the file) and the selection on the dataspace of the dataset. After dereferencing the regions reference, the datatype, number of points, and some aspects of the selection can be discovered. (For a union of hyperslabs, it may not be possible to determine the exact set of hyperslabs that has been combined.) The table below the code example shows the inquiry functions.</p>
<p>When reading data from a region reference, the following rules are enforced: </p><ul>
<li>The target dataset must be present and accessible in the file </li>
<li>The selection must be a valid selection for the dataset</li>
</ul>
<p><em>Read an array of region references; read from the first selection</em> </p><div class="fragment"><div class="line">dsetr_id = <a class="code" href="_h5version_8h.html#a7dba2e5b2045f31c0932123ffb54f7a3">H5Dopen</a> (file_id, <span class="stringliteral">"R1"</span>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line">status = <a class="code" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dsetr_id, <a class="code" href="group___p_d_t_s_t_d.html#gaf5cb0d5cec3d40d8b3ac27512f86895e">H5T_STD_REF_DSETREG</a>, <a class="code" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, ref_out);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Dereference the first reference.</span></div>
<div class="line"><span class="comment">// 1) get the dataset (H5Rdereference)</span></div>
<div class="line"><span class="comment">// 2) get the selected dataspace (H5Rget_region)</span></div>
<div class="line"> </div>
<div class="line">dsetv_id = <a class="code" href="group___h5_r.html#ga5dc19b9d1833af66c5e1f819f2c05c4a">H5Rdereference</a>(dsetr_id, <a class="code" href="_h5_rpublic_8h.html#a2a28c48c03a4616a02f9157fca4b2df0">H5R_DATASET_REGION</a>, &ref_out[0]);</div>
<div class="line">space_id = <a class="code" href="group___h5_r.html#ga1702d609e85b9edd3d1e526a0276484f">H5Rget_region</a>(dsetr_id, <a class="code" href="_h5_rpublic_8h.html#a2a28c48c03a4616a02f9157fca4b2df0">H5R_DATASET_REGION</a>, &ref_out[0]);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Discover how many points and shape of the data</span></div>
<div class="line">ndims = <a class="code" href="group___h5_s.html#gae5282a81692b80b5b19dd12d05b9b28e">H5Sget_simple_extent_ndims</a>(space_id);</div>
<div class="line"><a class="code" href="group___h5_s.html#gac494409b615d8e67c5edd9eb2848b2f3">H5Sget_simple_extent_dims</a>(space_id,dimsx,NULL);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Read and display hyperslab selection from the dataset.</span></div>
<div class="line">dimsy[0] = <a class="code" href="group___h5_s.html#ga1a44dde97206f40f366f99d9c39b6046">H5Sget_select_npoints</a>(space_id);</div>
<div class="line">spacex_id = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(1, dimsy, NULL);</div>
<div class="line"> </div>
<div class="line">status = <a class="code" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dsetv_id, <a class="code" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, <a class="code" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, space_id, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data_out);</div>
<div class="line">printf(<span class="stringliteral">"Selected hyperslab: "</span>);</div>
<div class="line"><span class="keywordflow">for</span> (i = 0; i < 8; i++) {</div>
<div class="line"> printf(<span class="stringliteral">"\n"</span>);</div>
<div class="line"> <span class="keywordflow">for</span> (j = 0; j < 10; j++)</div>
<div class="line"> printf(<span class="stringliteral">"%d "</span>, data_out[i][j]);</div>
<div class="line">}</div>
<div class="line">printf(<span class="stringliteral">"\n"</span>);</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 class="ttc" id="agroup___h5_r_html_ga1702d609e85b9edd3d1e526a0276484f"><div class="ttname"><a href="group___h5_r.html#ga1702d609e85b9edd3d1e526a0276484f">H5Rget_region</a></div><div class="ttdeci">hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref)</div><div class="ttdoc">Sets up a dataspace and selection as specified by a region reference.</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 class="ttc" id="agroup___h5_s_html_ga1a44dde97206f40f366f99d9c39b6046"><div class="ttname"><a href="group___h5_s.html#ga1a44dde97206f40f366f99d9c39b6046">H5Sget_select_npoints</a></div><div class="ttdeci">hssize_t H5Sget_select_npoints(hid_t spaceid)</div><div class="ttdoc">Determines the number of elements in a dataspace selection.</div></div>
</div><!-- fragment --><table class="doxtable">
<caption>The inquiry functions</caption>
<tr>
<th><p class="starttd"></p>
<p class="intertd">Function</p>
<p class="endtd"></p>
</th><th><p class="starttd"></p>
<p class="intertd">Information</p>
<p class="endtd"></p>
</th></tr>
<tr>
<td><a class="el" href="group___h5_s.html#ga1a44dde97206f40f366f99d9c39b6046">H5Sget_select_npoints</a> </td><td><p class="starttd"></p>
<p class="intertd">The number of elements in the selection (hyperslab or point selection).</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><a class="el" href="group___h5_s.html#ga645591ec939b89732c10efd5867a6205">H5Sget_select_bounds</a> </td><td><p class="starttd"></p>
<p class="intertd">The bounding box that encloses the selected points (hyperslab or point selection).</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><a class="el" href="group___h5_s.html#gad873b2f3b82ee8c426c26ceeb1c67f86">H5Sget_select_hyper_nblocks</a> </td><td><p class="starttd"></p>
<p class="intertd">The number of blocks in the selection.</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><a class="el" href="group___h5_s.html#ga8534829a8db2eca8e987bb9fe8a3d628">H5Sget_select_hyper_blocklist</a> </td><td><p class="starttd"></p>
<p class="intertd">A list of the blocks in the selection.</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><a class="el" href="group___h5_s.html#ga217b839584cd7c7995b47fc30fe92f4c">H5Sget_select_elem_npoints</a> </td><td><p class="starttd"></p>
<p class="intertd">The number of points in the selection.</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><a class="el" href="group___h5_s.html#ga61459c488147254d1d06537a9ab6e2d4">H5Sget_select_elem_pointlist</a> </td><td><p class="starttd"></p>
<p class="intertd">The points.</p>
<p class="endtd"></p>
</td></tr>
</table>
<h2><a class="anchor" id="subsec_dataspace_sample"></a>
Sample Programs</h2>
<p>This section contains the full programs from which several of the code examples in this chapter were derived. The h5dump output from the program's output file immediately follows each program.</p>
<p><em>h5_write.c</em> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "hdf5.h"</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#define H5FILE_NAME "SDS.h5"</span></div>
<div class="line"><span class="preprocessor">#define DATASETNAME "C Matrix"</span></div>
<div class="line"><span class="preprocessor">#define NX 3</span></div>
<div class="line"><span class="preprocessor">#define NY 5</span></div>
<div class="line"><span class="preprocessor">#define RANK 2 </span><span class="comment">// dataset dimensions</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span></div>
<div class="line">main (<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> file, dataset; <span class="comment">// file and dataset identifiers</span></div>
<div class="line"> <a class="code" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> datatype, dataspace; <span class="comment">// identifiers</span></div>
<div class="line"> <a class="code" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> dims[2]; <span class="comment">// dataset dimensions</span></div>
<div class="line"> <a class="code" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> status;</div>
<div class="line"> <span class="keywordtype">int</span> data[NX][NY]; <span class="comment">// data to write</span></div>
<div class="line"> <span class="keywordtype">int</span> i, j;</div>
<div class="line"> </div>
<div class="line"> <span class="comment">//</span></div>
<div class="line"> <span class="comment">// Data and output buffer initialization.</span></div>
<div class="line"> <span class="keywordflow">for</span> (j = 0; j < NX; j++) {</div>
<div class="line"> <span class="keywordflow">for</span> (i = 0; i < NY; i++)</div>
<div class="line"> data[j][i] = i + 1 + j*NY;</div>
<div class="line"> }</div>
<div class="line"> <span class="comment">// 1 2 3 4 5</span></div>
<div class="line"> <span class="comment">// 6 7 8 9 10</span></div>
<div class="line"> <span class="comment">// 11 12 13 14 15</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Create a new file using H5F_ACC_TRUNC access,</span></div>
<div class="line"> <span class="comment">// default file creation properties, and default file</span></div>
<div class="line"> <span class="comment">// access properties.</span></div>
<div class="line"> file = <a class="code" href="group___h5_f.html#gae64b51ee9ac0781bc4ccc599d98387f4">H5Fcreate</a>(H5FILE_NAME, <a class="code" href="_h5_fpublic_8h.html#a5a2d6726f9ad8d2bca8df2b817e5ad6a">H5F_ACC_TRUNC</a>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Describe the size of the array and create the data space for fixed</span></div>
<div class="line"> <span class="comment">// size dataset.</span></div>
<div class="line"> dims[0] = NX;</div>
<div class="line"> dims[1] = NY;</div>
<div class="line"> dataspace = <a class="code" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(RANK, dims, NULL);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Create a new dataset within the file using defined dataspace and</span></div>
<div class="line"> <span class="comment">// datatype and default dataset creation properties.</span></div>
<div class="line"> dataset = <a class="code" href="group___h5_d.html#ga0647ba4bbd26d5230cc07f3a5685b2cf">H5Dcreate</a>(file, DATASETNAME, <a class="code" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, dataspace, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>,</div>
<div class="line"> <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Write the data to the dataset using default transfer properties.</span></div>
<div class="line"> status = <a class="code" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906">H5Dwrite</a>(dataset, <a class="code" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, <a class="code" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, data);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Close/release resources.</span></div>
<div class="line"> <a class="code" href="group___h5_s.html#ga2b53128a39c8f104c1c9c2a91590fcc1">H5Sclose</a>(dataspace);</div>
<div class="line"> <a class="code" href="group___h5_d.html#gae47c3f38db49db127faf221624c30609">H5Dclose</a>(dataset);</div>
<div class="line"> <a class="code" href="group___h5_f.html#gac55cd91d80822e4f8c2a7f04ea71b124">H5Fclose</a>(file);</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">SDS.out</div>
<div class="line">-------</div>
<div class="line">HDF5 <span class="stringliteral">"SDS.h5"</span> {</div>
<div class="line">GROUP <span class="stringliteral">"/"</span> {</div>
<div class="line"> DATASET <span class="stringliteral">"C Matrix"</span> {</div>
<div class="line"> DATATYPE <a class="code" href="group___p_d_t_s_t_d.html#ga37e8a6be7ee64587c2a282b965019bb8">H5T_STD_I32BE</a></div>
<div class="line"> DATASPACE SIMPLE { ( 3, 5 ) / ( 3, 5 ) }</div>
<div class="line"> DATA {</div>
<div class="line"> 1, 2, 3, 4, 5,</div>
<div class="line"> 6, 7, 8, 9, 10,</div>
<div class="line"> 11, 12, 13, 14, 15</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="ttc" id="a_h5_fpublic_8h_html_a5a2d6726f9ad8d2bca8df2b817e5ad6a"><div class="ttname"><a href="_h5_fpublic_8h.html#a5a2d6726f9ad8d2bca8df2b817e5ad6a">H5F_ACC_TRUNC</a></div><div class="ttdeci">#define H5F_ACC_TRUNC</div><div class="ttdef"><b>Definition:</b> H5Fpublic.h:50</div></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 class="ttc" id="agroup___h5_d_html_gae47c3f38db49db127faf221624c30609"><div class="ttname"><a href="group___h5_d.html#gae47c3f38db49db127faf221624c30609">H5Dclose</a></div><div class="ttdeci">herr_t H5Dclose(hid_t dset_id)</div><div class="ttdoc">Closes the specified dataset.</div></div>
<div class="ttc" id="agroup___h5_f_html_gac55cd91d80822e4f8c2a7f04ea71b124"><div class="ttname"><a href="group___h5_f.html#gac55cd91d80822e4f8c2a7f04ea71b124">H5Fclose</a></div><div class="ttdeci">herr_t H5Fclose(hid_t file_id)</div><div class="ttdoc">Terminates access to an HDF5 file.</div></div>
<div class="ttc" id="agroup___h5_f_html_gae64b51ee9ac0781bc4ccc599d98387f4"><div class="ttname"><a href="group___h5_f.html#gae64b51ee9ac0781bc4ccc599d98387f4">H5Fcreate</a></div><div class="ttdeci">hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)</div><div class="ttdoc">Creates an HDF5 file.</div></div>
<div class="ttc" id="agroup___h5_s_html_ga2b53128a39c8f104c1c9c2a91590fcc1"><div class="ttname"><a href="group___h5_s.html#ga2b53128a39c8f104c1c9c2a91590fcc1">H5Sclose</a></div><div class="ttdeci">herr_t H5Sclose(hid_t space_id)</div><div class="ttdoc">Releases and terminates access to a dataspace.</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 --><p><em>h5_write.f90</em> </p><div class="fragment"><div class="line">----------</div>
<div class="line">PROGRAM DSETEXAMPLE</div>
<div class="line"> </div>
<div class="line">USE HDF5 ! This module contains all necessary modules</div>
<div class="line"> </div>
<div class="line">IMPLICIT NONE</div>
<div class="line"> </div>
<div class="line">CHARACTER(LEN=7), PARAMETER :: filename = <span class="stringliteral">"SDSf.h5"</span> ! File name</div>
<div class="line">CHARACTER(LEN=14), PARAMETER :: dsetname = <span class="stringliteral">"Fortran Matrix"</span> ! Dataset name</div>
<div class="line">INTEGER, PARAMETER :: NX = 3</div>
<div class="line">INTEGER, PARAMETER :: NY = 5</div>
<div class="line"> </div>
<div class="line">INTEGER(HID_T) :: file_id ! File identifier</div>
<div class="line">INTEGER(HID_T) :: dset_id ! Dataset identifier</div>
<div class="line">INTEGER(HID_T) :: dspace_id ! Dataspace identifier</div>
<div class="line"> </div>
<div class="line">INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/3,5/) ! Dataset dimensions</div>
<div class="line">INTEGER :: rank = 2 ! Dataset rank</div>
<div class="line">INTEGER :: data(NX,NY)</div>
<div class="line">INTEGER :: error ! Error flag</div>
<div class="line">INTEGER :: i, j</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Initialize data</div>
<div class="line">!</div>
<div class="line"> do i = 1, NX</div>
<div class="line"> do j = 1, NY</div>
<div class="line"> data(i,j) = j + (i-1)*NY</div>
<div class="line"> enddo</div>
<div class="line"> enddo</div>
<div class="line">!</div>
<div class="line">! Data</div>
<div class="line">!</div>
<div class="line">! 1 2 3 4 5</div>
<div class="line">! 6 7 8 9 10</div>
<div class="line">! 11 12 13 14 15</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Initialize FORTRAN interface.</div>
<div class="line">!</div>
<div class="line">CALLh5open_f(error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Create a new file using default properties.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_f.html#ga001b302ac81b358cc6dc69fb15953080">h5fcreate_f</a>(filename, H5F_ACC_TRUNC_F, file_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Create the dataspace.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_s.html#ga54083c84fd4be392ac770cf223cd6cf4">h5screate_simple_f</a>(rank, dims, dspace_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Create and write dataset using default properties.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_d.html#ga5cb1ac0f28ebc68918e37b282c40f302">h5dcreate_f</a>(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, &</div>
<div class="line"> dset_id, error, H5P_DEFAULT_F, H5P_DEFAULT_F, &</div>
<div class="line"> H5P_DEFAULT_F)</div>
<div class="line"> </div>
<div class="line">CALL <a class="code" href="group___f_h5_d.html#ga474d18ed38c193fd1eb36b1b73f65ea8">h5dwrite_f</a>(dset_id, H5T_NATIVE_INTEGER, data, dims, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! End access to the dataset and release resources used by it.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_d.html#ga2ffabd12a26d5afcafba44240df62f33">h5dclose_f</a>(dset_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Terminate access to the data space.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_s.html#gaf06283f60395d8fa6806b6c1136ad700">h5sclose_f</a>(dspace_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Close the file.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_f.html#gae682d2e7f7dd97a9df9ea2d04d8d6350">h5fclose_f</a>(file_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Close FORTRAN interface.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5.html#ga44774afab361ee25be7eda5b6fc86374">h5close_f</a>(error)</div>
<div class="line"> </div>
<div class="line">END PROGRAM DSETEXAMPLE</div>
<div class="line"> </div>
<div class="line">SDSf.out</div>
<div class="line">--------</div>
<div class="line">HDF5 <span class="stringliteral">"SDSf.h5"</span> {</div>
<div class="line">GROUP <span class="stringliteral">"/"</span> {</div>
<div class="line"> DATASET <span class="stringliteral">"Fortran Matrix"</span> {</div>
<div class="line"> DATATYPE <a class="code" href="group___p_d_t_s_t_d.html#ga37e8a6be7ee64587c2a282b965019bb8">H5T_STD_I32BE</a></div>
<div class="line"> DATASPACE SIMPLE { ( 5, 3 ) / ( 5, 3 ) }</div>
<div class="line"> DATA {</div>
<div class="line"> 1, 6, 11,</div>
<div class="line"> 2, 7, 12,</div>
<div class="line"> 3, 8, 13,</div>
<div class="line"> 4, 9, 14,</div>
<div class="line"> 5, 10, 15</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line">}</div>
<div class="ttc" id="agroup___f_h5_d_html_ga2ffabd12a26d5afcafba44240df62f33"><div class="ttname"><a href="group___f_h5_d.html#ga2ffabd12a26d5afcafba44240df62f33">h5d::h5dclose_f</a></div><div class="ttdeci">subroutine h5dclose_f(dset_id, hdferr)</div><div class="ttdoc">Closes a dataset.</div><div class="ttdef"><b>Definition:</b> H5Dff.F90:495</div></div>
<div class="ttc" id="agroup___f_h5_d_html_ga474d18ed38c193fd1eb36b1b73f65ea8"><div class="ttname"><a href="group___f_h5_d.html#ga474d18ed38c193fd1eb36b1b73f65ea8">h5d::h5dwrite_f</a></div><div class="ttdeci">subroutine h5dwrite_f(dset_id, mem_type_id, buf, hdferr, mem_space_id, file_space_id, xfer_prp)</div><div class="ttdoc">Writes raw data from a buffer to a dataset.</div><div class="ttdef"><b>Definition:</b> H5Dff.F90:1633</div></div>
<div class="ttc" id="agroup___f_h5_d_html_ga5cb1ac0f28ebc68918e37b282c40f302"><div class="ttname"><a href="group___f_h5_d.html#ga5cb1ac0f28ebc68918e37b282c40f302">h5d::h5dcreate_f</a></div><div class="ttdeci">subroutine h5dcreate_f(loc_id, name, type_id, space_id, dset_id, hdferr, dcpl_id, lcpl_id, dapl_id)</div><div class="ttdoc">Creates a dataset at the specified location.</div><div class="ttdef"><b>Definition:</b> H5Dff.F90:229</div></div>
<div class="ttc" id="agroup___f_h5_f_html_ga001b302ac81b358cc6dc69fb15953080"><div class="ttname"><a href="group___f_h5_f.html#ga001b302ac81b358cc6dc69fb15953080">h5f::h5fcreate_f</a></div><div class="ttdeci">subroutine h5fcreate_f(name, access_flags, file_id, hdferr, creation_prp, access_prp)</div><div class="ttdoc">Creates HDF5 files.</div><div class="ttdef"><b>Definition:</b> H5Fff.F90:108</div></div>
<div class="ttc" id="agroup___f_h5_f_html_gae682d2e7f7dd97a9df9ea2d04d8d6350"><div class="ttname"><a href="group___f_h5_f.html#gae682d2e7f7dd97a9df9ea2d04d8d6350">h5f::h5fclose_f</a></div><div class="ttdeci">subroutine h5fclose_f(file_id, hdferr)</div><div class="ttdoc">Closes HDF5 file.</div><div class="ttdef"><b>Definition:</b> H5Fff.F90:733</div></div>
<div class="ttc" id="agroup___f_h5_html_ga44774afab361ee25be7eda5b6fc86374"><div class="ttname"><a href="group___f_h5.html#ga44774afab361ee25be7eda5b6fc86374">h5lib::h5close_f</a></div><div class="ttdeci">subroutine, public h5close_f(error)</div><div class="ttdoc">Closes HDF5 Fortran interface.</div><div class="ttdef"><b>Definition:</b> H5_ff.F90:795</div></div>
<div class="ttc" id="agroup___f_h5_s_html_gaf06283f60395d8fa6806b6c1136ad700"><div class="ttname"><a href="group___f_h5_s.html#gaf06283f60395d8fa6806b6c1136ad700">h5s::h5sclose_f</a></div><div class="ttdeci">subroutine h5sclose_f(space_id, hdferr)</div><div class="ttdoc">Releases and terminates access to a dataspace.</div><div class="ttdef"><b>Definition:</b> H5Sff.F90:105</div></div>
</div><!-- fragment --><p><em>h5_write_tr.f90</em> </p><div class="fragment"><div class="line">PROGRAM DSETEXAMPLE</div>
<div class="line"> </div>
<div class="line">USE HDF5 ! This module contains all necessary modules</div>
<div class="line"> </div>
<div class="line">IMPLICIT NONE</div>
<div class="line"> </div>
<div class="line">CHARACTER(LEN=10), PARAMETER :: filename = <span class="stringliteral">"SDSf_tr.h5"</span> ! File name</div>
<div class="line">CHARACTER(LEN=24), PARAMETER :: dsetname = <span class="stringliteral">"Fortran Transpose Matrix"</span>! Dataset name</div>
<div class="line"> </div>
<div class="line">INTEGER, PARAMETER :: NX = 3</div>
<div class="line">INTEGER, PARAMETER :: NY = 5</div>
<div class="line"> </div>
<div class="line">INTEGER(HID_T) :: file_id ! File identifier</div>
<div class="line">INTEGER(HID_T) :: dset_id ! Dataset identifier</div>
<div class="line">INTEGER(HID_T) :: dspace_id ! Dataspace identifier</div>
<div class="line"> </div>
<div class="line">INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/NY, NX/) ! Dataset dimensions</div>
<div class="line">INTEGER :: rank = 2 ! Dataset rank</div>
<div class="line">INTEGER :: data(NY,NX)</div>
<div class="line"> </div>
<div class="line">INTEGER :: error ! Error flag</div>
<div class="line">INTEGER :: i, j</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Initialize data</div>
<div class="line">!</div>
<div class="line"> do i = 1, NY</div>
<div class="line"> do j = 1, NX</div>
<div class="line"> data(i,j) = i + (j-1)*NY</div>
<div class="line"> enddo</div>
<div class="line"> enddo</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Data</div>
<div class="line">!</div>
<div class="line">! 1 6 11</div>
<div class="line">! 2 7 12</div>
<div class="line">! 3 8 13</div>
<div class="line">! 4 9 14</div>
<div class="line">! 5 10 15</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Initialize FORTRAN interface.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5.html#ga041e8ea7a216ab58ddc59bf6751393d6">h5open_f</a>(error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Create a new file using default properties.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_f.html#ga001b302ac81b358cc6dc69fb15953080">h5fcreate_f</a>(filename, H5F_ACC_TRUNC_F, file_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Create the dataspace.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_s.html#ga54083c84fd4be392ac770cf223cd6cf4">h5screate_simple_f</a>(rank, dims, dspace_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Create and write dataset using default properties.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_d.html#ga5cb1ac0f28ebc68918e37b282c40f302">h5dcreate_f</a>(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, &</div>
<div class="line"> dset_id, error, H5P_DEFAULT_F, H5P_DEFAULT_F, &</div>
<div class="line"> H5P_DEFAULT_F)</div>
<div class="line">CALL <a class="code" href="group___f_h5_d.html#ga474d18ed38c193fd1eb36b1b73f65ea8">h5dwrite_f</a>(dset_id, H5T_NATIVE_INTEGER, data, dims, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! End access to the dataset and release resources used by it.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_d.html#ga2ffabd12a26d5afcafba44240df62f33">h5dclose_f</a>(dset_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Terminate access to the data space.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_s.html#gaf06283f60395d8fa6806b6c1136ad700">h5sclose_f</a>(dspace_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Close the file.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5_f.html#gae682d2e7f7dd97a9df9ea2d04d8d6350">h5fclose_f</a>(file_id, error)</div>
<div class="line"> </div>
<div class="line">!</div>
<div class="line">! Close FORTRAN interface.</div>
<div class="line">!</div>
<div class="line">CALL <a class="code" href="group___f_h5.html#ga44774afab361ee25be7eda5b6fc86374">h5close_f</a>(error)</div>
<div class="line"> </div>
<div class="line">END PROGRAM DSETEXAMPLE</div>
<div class="line"> </div>
<div class="line">SDSf_tr.out</div>
<div class="line">-----------</div>
<div class="line">HDF5 <span class="stringliteral">"SDSf_tr.h5"</span> {</div>
<div class="line">GROUP <span class="stringliteral">"/"</span> {</div>
<div class="line"> DATASET <span class="stringliteral">"Fortran Transpose Matrix"</span> {</div>
<div class="line"> DATATYPE <a class="code" href="group___p_d_t_s_t_d.html#ga8db8c9c2bcc457f9f8526c8fcb81218b">H5T_STD_I32LE</a></div>
<div class="line"> DATASPACE SIMPLE { ( 3, 5 ) / ( 3, 5 ) }</div>
<div class="line"> DATA {</div>
<div class="line"> 1, 2, 3, 4, 5,</div>
<div class="line"> 6, 7, 8, 9, 10,</div>
<div class="line"> 11, 12, 13, 14, 15</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line">}</div>
<div class="ttc" id="agroup___f_h5_html_ga041e8ea7a216ab58ddc59bf6751393d6"><div class="ttname"><a href="group___f_h5.html#ga041e8ea7a216ab58ddc59bf6751393d6">h5lib::h5open_f</a></div><div class="ttdeci">subroutine, public h5open_f(error)</div><div class="ttdoc">Initializes HDF5 Fortran interface.</div><div class="ttdef"><b>Definition:</b> H5_ff.F90:180</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>Previous Chapter <a class="el" href="_h5_t__u_g.html#sec_datatype">HDF5 Datatypes</a> - Next Chapter <a class="el" href="_h5_a__u_g.html#sec_attribute">HDF5 Attributes</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.9.1 </li>
</ul>
</div>
</body>
</html>
|