summaryrefslogtreecommitdiffstats
path: root/develop/group___h5_d_o.html
blob: 9568e49ab7151ef43ed6c57bfbdf1e3389e674c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>HDF5: HDF5 Optimizations APIs (H5DO)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  $(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="hdf5doxy.css" rel="stylesheet" type="text/css">
<!-- <link href="hdf5doxy.css" rel="stylesheet" type="text/css"/>
 -->
<script type="text/javascript" src="hdf5_navtree_hacks.js"></script>
</head>
<body>
<div style="background:#FFDDDD;font-size:120%;text-align:center;margin:0;padding:5px">Please, help us to better serve our user community by answering the following short survey:  <a href="https://www.hdfgroup.org/website-survey/">https://www.hdfgroup.org/website-survey/</a></div>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="HDFG-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="https://www.hdfgroup.org">HDF5</a>
   &#160;<span id="projectnumber">1.15.0.112f445</span>
   </div>
   <div id="projectbrief">API Reference</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
          <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('group___h5_d_o.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

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

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">HDF5 Optimizations APIs (H5DO)</div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p><em>Bypassing default HDF5 behavior in order to optimize for specific use cases (H5DO)</em></p>
<p>HDF5 functions described is this section are implemented in the HDF5 High-level library as optimized functions. These functions generally require careful setup and testing as they enable an application to bypass portions of the HDF5 library's I/O pipeline for performance purposes.</p>
<p>These functions are distributed in the standard HDF5 distribution and are available any time the HDF5 High-level library is available.</p>
<ul>
<li><a class="el" href="#ga316caac160af15192e0c78228667341e">H5DOappend</a> <br  />
 Appends data to a dataset along a specified dimension.</li>
<li><a class="el" href="#gaaf8ec5a5623f93549e49c39f95c4abab">H5DOread_chunk</a> <br  />
 Reads a raw data chunk directly from a dataset in a file into a buffer (DEPRECATED)</li>
<li><a class="el" href="#gabc3c07ed2cf29dd34035194919fbeb31">H5DOwrite_chunk</a> <br  />
 Writes a raw data chunk from a buffer directly to a dataset in a file (DEPRECATED) </li>
</ul>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga316caac160af15192e0c78228667341e" id="r_ga316caac160af15192e0c78228667341e"><td class="memItemLeft" align="right" valign="top">H5_HLDLL <a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ga316caac160af15192e0c78228667341e">H5DOappend</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset_id, <a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dxpl_id, unsigned axis, size_t extension, <a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> memtype, const void *buf)</td></tr>
<tr class="memdesc:ga316caac160af15192e0c78228667341e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends data to a dataset along a specified dimension.  <br /></td></tr>
<tr class="separator:ga316caac160af15192e0c78228667341e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabc3c07ed2cf29dd34035194919fbeb31" id="r_gabc3c07ed2cf29dd34035194919fbeb31"><td class="memItemLeft" align="right" valign="top">H5_HLDLL <a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#gabc3c07ed2cf29dd34035194919fbeb31">H5DOwrite_chunk</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset_id, <a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dxpl_id, uint32_t filters, const <a class="el" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> *offset, size_t data_size, const void *buf)</td></tr>
<tr class="memdesc:gabc3c07ed2cf29dd34035194919fbeb31"><td class="mdescLeft">&#160;</td><td class="mdescRight">Writes a raw data chunk from a buffer directly to a dataset in a file.  <br /></td></tr>
<tr class="separator:gabc3c07ed2cf29dd34035194919fbeb31"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaf8ec5a5623f93549e49c39f95c4abab" id="r_gaaf8ec5a5623f93549e49c39f95c4abab"><td class="memItemLeft" align="right" valign="top">H5_HLDLL <a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#gaaf8ec5a5623f93549e49c39f95c4abab">H5DOread_chunk</a> (<a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dset_id, <a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a> dxpl_id, const <a class="el" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> *offset, uint32_t *filters, void *buf)</td></tr>
<tr class="memdesc:gaaf8ec5a5623f93549e49c39f95c4abab"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads a raw data chunk directly from a dataset in a file into a buffer.  <br /></td></tr>
<tr class="separator:gaaf8ec5a5623f93549e49c39f95c4abab"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga316caac160af15192e0c78228667341e" name="ga316caac160af15192e0c78228667341e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga316caac160af15192e0c78228667341e">&#9670;&#160;</a></span>H5DOappend()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">H5_HLDLL <a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> H5DOappend </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></td>          <td class="paramname"><span class="paramname"><em>dset_id</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></td>          <td class="paramname"><span class="paramname"><em>dxpl_id</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned</td>          <td class="paramname"><span class="paramname"><em>axis</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>extension</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></td>          <td class="paramname"><span class="paramname"><em>memtype</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *</td>          <td class="paramname"><span class="paramname"><em>buf</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Appends data to a dataset along a specified dimension. </p>
<hr  />
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">dset_id</td><td>Dataset identifier </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dxpl_id</td><td>Dataset transfer property list identifier </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">axis</td><td>Dataset Dimension (0-based) for the append </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">extension</td><td>Number of elements to append for the axis-th dimension </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">memtype</td><td>The memory datatype identifier </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>Buffer with data for the append</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns a non-negative value if successful; otherwise, returns a negative value.</dd></dl>
<p>The <a class="el" href="#ga316caac160af15192e0c78228667341e" title="Appends data to a dataset along a specified dimension.">H5DOappend()</a> routine extends a dataset by <code>extension</code> number of elements along a dimension specified by a dimension <code>axis</code> and writes <code>buf</code> of elements to the dataset. Dimension <code>axis</code> is 0-based. Elements’ type is described by <code>memtype</code>.</p>
<p>This routine combines calling <a class="el" href="group___h5_d.html#gad31e1e0129f4520c531ce524de2a056f" title="Changes the sizes of a dataset&#39;s dimensions.">H5Dset_extent()</a>, <a class="el" href="group___h5_s.html#ga6adfdf1b95dc108a65bf66e97d38536d" title="Selects a hyperslab region to add to the current selected region.">H5Sselect_hyperslab()</a>, and <a class="el" href="group___h5_d.html#ga98f44998b67587662af8b0d8a0a75906" title="Writes raw data from a buffer to a dataset.">H5Dwrite()</a> into a single routine that simplifies application development for the common case of appending elements to an existing dataset.</p>
<p>For a multi-dimensional dataset, appending to one dimension will write a contiguous hyperslab over the other dimensions. For example, if a 3-D dataset has dimension sizes (3, 5, 8), extending the 0th dimension (currently of size 3) by 3 will append 3*5*8 = 120 elements (which must be pointed to by the <code>buffer</code> parameter) to the dataset, making its final dimension sizes (6, 5, 8).</p>
<p>If a dataset has more than one unlimited dimension, any of those dimensions may be appended to, although only along one dimension per call to <a class="el" href="#ga316caac160af15192e0c78228667341e" title="Appends data to a dataset along a specified dimension.">H5DOappend()</a>.</p>
<dl class="section since"><dt>Since</dt><dd>1.10.0 </dd></dl>

</div>
</div>
<a id="gaaf8ec5a5623f93549e49c39f95c4abab" name="gaaf8ec5a5623f93549e49c39f95c4abab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaaf8ec5a5623f93549e49c39f95c4abab">&#9670;&#160;</a></span>H5DOread_chunk()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">H5_HLDLL <a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> H5DOread_chunk </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></td>          <td class="paramname"><span class="paramname"><em>dset_id</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></td>          <td class="paramname"><span class="paramname"><em>dxpl_id</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> *</td>          <td class="paramname"><span class="paramname"><em>offset</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *</td>          <td class="paramname"><span class="paramname"><em>filters</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *</td>          <td class="paramname"><span class="paramname"><em>buf</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reads a raw data chunk directly from a dataset in a file into a buffer. </p>
<hr  />
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">dset_id</td><td>Identifier for the dataset to be read </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dxpl_id</td><td>Transfer property list identifier for this I/O operation </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">offset</td><td>Logical position of the chunk's first element in the dataspace </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">filters</td><td>Mask for identifying the filters used with the chunk </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>Buffer containing the chunk read from the dataset</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns a non-negative value if successful; otherwise, returns a negative value.</dd></dl>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000003">Deprecated</a></b></dt><dd><p class="startdd">This function was deprecated in favor of the function <a class="el" href="group___h5_d.html#gac1092a63b718ec949d6539590a914b60" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5Dread_chunk()</a> as of HDF5-1.10.3. In HDF5 1.10.3, the functionality of <a class="el" href="#gaaf8ec5a5623f93549e49c39f95c4abab" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5DOread_chunk()</a> was moved to <a class="el" href="group___h5_d.html#gac1092a63b718ec949d6539590a914b60" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5Dread_chunk()</a>. </p>
<p class="enddd">For compatibility, this API call has been left as a stub which simply calls <a class="el" href="group___h5_d.html#gac1092a63b718ec949d6539590a914b60" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5Dread_chunk()</a>. New code should use <a class="el" href="group___h5_d.html#gac1092a63b718ec949d6539590a914b60" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5Dread_chunk()</a>.</p>
</dd></dl>
<p>The <a class="el" href="#gaaf8ec5a5623f93549e49c39f95c4abab" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5DOread_chunk()</a> reads a raw data chunk as specified by its logical <code>offset</code> in a chunked dataset <code>dset_id</code> from the dataset in the file into the application memory buffer <code>buf</code>. The data in <code>buf</code> is read directly from the file bypassing the library's internal data transfer pipeline, including filters.</p>
<p><code>dxpl_id</code> is a data transfer property list identifier.</p>
<p>The mask <code>filters</code> indicates which filters are used with the chunk when written. A zero value indicates that all enabled filters are applied on the chunk. A filter is skipped if the bit corresponding to the filter's position in the pipeline (<code>0 ≤ position &lt; 32</code>) is turned on.</p>
<p><code>offset</code> is an array specifying the logical position of the first element of the chunk in the dataset's dataspace. The length of the offset array must equal the number of dimensions, or rank, of the dataspace. The values in <code>offset</code> must not exceed the dimension limits and must specify a point that falls on a dataset chunk boundary.</p>
<p><code>buf</code> is the memory buffer containing the chunk read from the dataset in the file.</p>
<dl class="section user"><dt>Example</dt><dd>The following code illustrates the use of <a class="el" href="#gaaf8ec5a5623f93549e49c39f95c4abab" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5DOread_chunk()</a> to read a chunk from a dataset: <div class="fragment"><div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;zlib.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;math.h&gt;</span></div>
<div class="line"><span class="preprocessor">#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12)</span></div>
<div class="line">                :</div>
<div class="line">                :</div>
<div class="line"><span class="keywordtype">size_t</span>       buf_size = CHUNK_NX*CHUNK_NY*<span class="keyword">sizeof</span>(int);</div>
<div class="line">            <span class="keyword">const</span> Bytef *z_src = (<span class="keyword">const</span> Bytef *)(direct_buf);</div>
<div class="line">            Bytef       *z_dst; <span class="comment">/* Destination buffer            */</span></div>
<div class="line">            uLongf       z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);</div>
<div class="line">            uLong        z_src_nbytes = (uLong)buf_size;</div>
<div class="line">            <span class="keywordtype">int</span>          aggression   = 9; <span class="comment">/* Compression aggression setting */</span></div>
<div class="line">            uint32_t     filter_mask  = 0;</div>
<div class="line">            <span class="keywordtype">size_t</span>       buf_size     = CHUNK_NX * CHUNK_NY * <span class="keyword">sizeof</span>(int);</div>
<div class="line">            <span class="comment">/* For H5DOread_chunk() */</span></div>
<div class="line">            <span class="keywordtype">void</span>        *readbuf = NULL;                   <span class="comment">/* Buffer for reading data */</span></div>
<div class="line">            <span class="keyword">const</span> Bytef *pt_readbuf;                       <span class="comment">/* Point to the buffer for data read */</span></div>
<div class="line">            <a class="code hl_typedef" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a>      read_chunk_nbytes;                <span class="comment">/* Size of chunk on disk */</span></div>
<div class="line">            <span class="keywordtype">int</span>          read_dst_buf[CHUNK_NX][CHUNK_NY]; <span class="comment">/* Buffer to hold un-compressed data */</span></div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Create the data space */</span></div>
<div class="line">            <span class="keywordflow">if</span> ((dataspace = <a class="code hl_function" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(RANK, dims, maxdims)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Create a new file */</span></div>
<div class="line">            <span class="keywordflow">if</span> ((file = <a class="code hl_function" href="group___h5_f.html#gae64b51ee9ac0781bc4ccc599d98387f4">H5Fcreate</a>(FILE_NAME5, <a class="code hl_define" href="_h5_fpublic_8h.html#a5a2d6726f9ad8d2bca8df2b817e5ad6a">H5F_ACC_TRUNC</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Modify dataset creation properties, i.e. enable chunking and compression */</span></div>
<div class="line">            <span class="keywordflow">if</span> ((cparms = <a class="code hl_function" href="group___p_l_c_r.html#gaf1b11da01d4d45d788c45f8bc5f0cbfa">H5Pcreate</a>(<a class="code hl_define" href="_h5_ppublic_8h.html#afcd7f8186c404f3a1d768632eacba102">H5P_DATASET_CREATE</a>)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span> ((status = <a class="code hl_function" href="group___d_c_p_l.html#ga3584d592e377da3604b7604e266dcf5b">H5Pset_chunk</a>(cparms, RANK, chunk_dims)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span> ((status = <a class="code hl_function" href="group___d_c_p_l.html#gaf1f569bfc54552bdb9317d2b63318a0d">H5Pset_deflate</a>(cparms, aggression)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Create a new dataset within the file using cparms creation properties */</span></div>
<div class="line">            <span class="keywordflow">if</span> ((dset_id = <a class="code hl_function" href="group___h5_d.html#gabf62045119f4e9c512d87d77f2f992df">H5Dcreate2</a>(file, DATASETNAME, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, dataspace, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, cparms,</div>
<div class="line">                                      <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Initialize data for one chunk */</span></div>
<div class="line">            <span class="keywordflow">for</span> (i = n = 0; i &lt; CHUNK_NX; i++)</div>
<div class="line">                <span class="keywordflow">for</span> (j = 0; j &lt; CHUNK_NY; j++)</div>
<div class="line">                    direct_buf[i][j] = n++;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Allocate output (compressed) buffer */</span></div>
<div class="line">            outbuf = malloc(z_dst_nbytes);</div>
<div class="line">            z_dst  = (Bytef *)outbuf;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Perform compression from the source to the destination buffer */</span></div>
<div class="line">            ret = compress2(z_dst, &amp;z_dst_nbytes, z_src, z_src_nbytes, aggression);</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Check for various zlib errors */</span></div>
<div class="line">            <span class="keywordflow">if</span> (Z_BUF_ERROR == ret) {</div>
<div class="line">                fprintf(stderr, <span class="stringliteral">&quot;overflow&quot;</span>);</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line">            }</div>
<div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Z_MEM_ERROR == ret) {</div>
<div class="line">                fprintf(stderr, <span class="stringliteral">&quot;deflate memory error&quot;</span>);</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line">            }</div>
<div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Z_OK != ret) {</div>
<div class="line">                fprintf(stderr, <span class="stringliteral">&quot;other deflate error&quot;</span>);</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line">            }</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Write the compressed chunk data repeatedly to cover all the</span></div>
<div class="line"><span class="comment">             *  * chunks in the dataset, using the direct write function.     */</span></div>
<div class="line">            <span class="keywordflow">for</span> (i = 0; i &lt; NX / CHUNK_NX; i++) {</div>
<div class="line">                <span class="keywordflow">for</span> (j = 0; j &lt; NY / CHUNK_NY; j++) {</div>
<div class="line">                    status = <a class="code hl_function" href="#gabc3c07ed2cf29dd34035194919fbeb31">H5DOwrite_chunk</a>(dset_id, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, filter_mask, offset, z_dst_nbytes, outbuf);</div>
<div class="line">                    offset[1] += CHUNK_NY;</div>
<div class="line">                }</div>
<div class="line">                offset[0] += CHUNK_NX;</div>
<div class="line">                offset[1] = 0;</div>
<div class="line">            }</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span> (<a class="code hl_function" href="group___h5_f.html#gae686870f0a276c4d06bbc667b2c24124">H5Fflush</a>(dataset, <a class="code hl_enumvalue" href="_h5_fpublic_8h.html#ac9db1b1211555797021daed9b54b8cdfa3d09ee2d1551f31b008a7dc7d80b42bd">H5F_SCOPE_LOCAL</a>) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span> (<a class="code hl_function" href="group___h5_d.html#gae47c3f38db49db127faf221624c30609">H5Dclose</a>(dataset) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span> ((dataset = <a class="code hl_function" href="group___h5_d.html#ga04198c4cf0b849ed3a8921f6c7169ee2">H5Dopen2</a>(file, DATASETNAME1, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            offset[0] = CHUNK_NX;</div>
<div class="line">            offset[1] = CHUNK_NY;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Get the size of the compressed chunk */</span></div>
<div class="line">            ret = <a class="code hl_function" href="group___h5_d.html#gaaeea958861de082db9051fc4bf215234">H5Dget_chunk_storage_size</a>(dataset, offset, &amp;read_chunk_nbytes);</div>
<div class="line"> </div>
<div class="line">            readbuf    = malloc(read_chunk_nbytes);</div>
<div class="line">            pt_readbuf = (<span class="keyword">const</span> Bytef *)readbuf;</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Use H5DOread_chunk() to read the chunk back */</span></div>
<div class="line">            <span class="keywordflow">if</span> ((status = <a class="code hl_function" href="#gaaf8ec5a5623f93549e49c39f95c4abab">H5DOread_chunk</a>(dataset, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, offset, &amp;read_filter_mask, readbuf)) &lt; 0)</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">            ret =</div>
<div class="line">                uncompress((Bytef *)read_dst_buf, (uLongf *)&amp;buf_size, pt_readbuf, (uLong)read_chunk_nbytes);</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Check for various zlib errors */</span></div>
<div class="line">            <span class="keywordflow">if</span> (Z_BUF_ERROR == ret) {</div>
<div class="line">                fprintf(stderr, <span class="stringliteral">&quot;error: not enough room in output buffer&quot;</span>);</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line">            }</div>
<div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Z_MEM_ERROR == ret) {</div>
<div class="line">                fprintf(stderr, <span class="stringliteral">&quot;error: not enough memory&quot;</span>);</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line">            }</div>
<div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Z_OK != ret) {</div>
<div class="line">                fprintf(stderr, <span class="stringliteral">&quot;error: corrupted input data&quot;</span>);</div>
<div class="line">                <span class="keywordflow">goto</span> error;</div>
<div class="line">            }</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Data verification here */</span></div>
<div class="line">            :</div>
<div class="line">            :</div>
<div class="ttc" id="a_h5_ppublic_8h_html_afcd7f8186c404f3a1d768632eacba102"><div class="ttname"><a href="_h5_ppublic_8h.html#afcd7f8186c404f3a1d768632eacba102">H5P_DATASET_CREATE</a></div><div class="ttdeci">#define H5P_DATASET_CREATE</div><div class="ttdef"><b>Definition</b> H5Ppublic.h:53</div></div>
<div class="ttc" id="agroup___h5_d_o_html_gaaf8ec5a5623f93549e49c39f95c4abab"><div class="ttname"><a href="#gaaf8ec5a5623f93549e49c39f95c4abab">H5DOread_chunk</a></div><div class="ttdeci">H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf)</div><div class="ttdoc">Reads a raw data chunk directly from a dataset in a file into a buffer.</div></div>
<div class="ttc" id="agroup___h5_d_o_html_gabc3c07ed2cf29dd34035194919fbeb31"><div class="ttname"><a href="#gabc3c07ed2cf29dd34035194919fbeb31">H5DOwrite_chunk</a></div><div class="ttdeci">H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size, const void *buf)</div><div class="ttdoc">Writes a raw data chunk from a buffer directly to a dataset in a file.</div></div>
<div class="ttc" id="agroup___p_d_t_n_a_t_html_ga290b9655882754ee0ec9f31b42ac04f6"><div class="ttname"><a href="group___p_d_t_n_a_t.html#ga290b9655882754ee0ec9f31b42ac04f6">H5T_NATIVE_LONG</a></div><div class="ttdeci">#define H5T_NATIVE_LONG</div><div class="ttdef"><b>Definition</b> H5Tpublic.h:777</div></div>
</div><!-- fragment --></dd></dl>
<dl class="section version"><dt>Version</dt><dd>1.10.3 Function deprecated in favor of H5Dread_chunk.</dd></dl>
<dl class="section since"><dt>Since</dt><dd>1.10.2, 1.8.19 </dd></dl>

</div>
</div>
<a id="gabc3c07ed2cf29dd34035194919fbeb31" name="gabc3c07ed2cf29dd34035194919fbeb31"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabc3c07ed2cf29dd34035194919fbeb31">&#9670;&#160;</a></span>H5DOwrite_chunk()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">H5_HLDLL <a class="el" href="_h5public_8h.html#a3b079ecf932a5c599499cf7e298af160">herr_t</a> H5DOwrite_chunk </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></td>          <td class="paramname"><span class="paramname"><em>dset_id</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_h5_ipublic_8h.html#a0045db7ff9c22ad35db6ae91662e1943">hid_t</a></td>          <td class="paramname"><span class="paramname"><em>dxpl_id</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t</td>          <td class="paramname"><span class="paramname"><em>filters</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="_h5public_8h.html#a7f81cce70fb546af88da24d9285d3c1c">hsize_t</a> *</td>          <td class="paramname"><span class="paramname"><em>offset</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>data_size</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *</td>          <td class="paramname"><span class="paramname"><em>buf</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Writes a raw data chunk from a buffer directly to a dataset in a file. </p>
<hr  />
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">dset_id</td><td>Identifier for the dataset to write to </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dxpl_id</td><td>Transfer property list identifier for this I/O operation </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">filters</td><td>Mask for identifying the filters in use </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">offset</td><td>Logical position of the chunk's first element in the dataspace </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data_size</td><td>Size of the actual data to be written in bytes </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">buf</td><td>Buffer containing data to be written to the chunk</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns a non-negative value if successful; otherwise, returns a negative value.</dd></dl>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000002">Deprecated</a></b></dt><dd><p class="startdd">This function was deprecated in favor of the function <a class="el" href="group___h5_d.html#ga416ccd200929b11386a10e9024977109" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5Dwrite_chunk()</a> of HDF5-1.10.3. The functionality of <a class="el" href="#gabc3c07ed2cf29dd34035194919fbeb31" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5DOwrite_chunk()</a> was moved to <a class="el" href="group___h5_d.html#ga416ccd200929b11386a10e9024977109" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5Dwrite_chunk()</a>. </p>
<p class="enddd">For compatibility, this API call has been left as a stub which simply calls <a class="el" href="group___h5_d.html#ga416ccd200929b11386a10e9024977109" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5Dwrite_chunk()</a>. New code should use <a class="el" href="group___h5_d.html#ga416ccd200929b11386a10e9024977109" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5Dwrite_chunk()</a>.</p>
</dd></dl>
<p>The <a class="el" href="#gabc3c07ed2cf29dd34035194919fbeb31" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5DOwrite_chunk()</a> writes a raw data chunk as specified by its logical <code>offset</code> in a chunked dataset <code>dset_id</code> from the application memory buffer <code>buf</code> to the dataset in the file. Typically, the data in <code>buf</code> is preprocessed in memory by a custom transformation, such as compression. The chunk will bypass the library's internal data transfer pipeline, including filters, and will be written directly to the file.</p>
<p><code>dxpl_id</code> is a data transfer property list identifier.</p>
<p><code>filters</code> is a mask providing a record of which filters are used with the chunk. The default value of the mask is zero (<code>0</code>), indicating that all enabled filters are applied. A filter is skipped if the bit corresponding to the filter's position in the pipeline (<code>0 ≤ position &lt; 32</code>) is turned on. This mask is saved with the chunk in the file.</p>
<p><code>offset</code> is an array specifying the logical position of the first element of the chunk in the dataset's dataspace. The length of the offset array must equal the number of dimensions, or rank, of the dataspace. The values in <code>offset</code> must not exceed the dimension limits and must specify a point that falls on a dataset chunk boundary.</p>
<p><code>data_size</code> is the size in bytes of the chunk, representing the number of bytes to be read from the buffer <code>buf</code>. If the data chunk has been precompressed, <code>data_size</code> should be the size of the compressed data.</p>
<p><code>buf</code> is the memory buffer containing data to be written to the chunk in the file.</p>
<dl class="section attention"><dt>Attention</dt><dd>Exercise caution when using <a class="el" href="#gaaf8ec5a5623f93549e49c39f95c4abab" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5DOread_chunk()</a> and <a class="el" href="#gabc3c07ed2cf29dd34035194919fbeb31" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5DOwrite_chunk()</a>, as they read and write data chunks directly in a file. <a class="el" href="#gabc3c07ed2cf29dd34035194919fbeb31" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5DOwrite_chunk()</a> bypasses hyperslab selection, the conversion of data from one datatype to another, and the filter pipeline to write the chunk. Developers should have experience with these processes before using this function. Please see <a href="https://portal.hdfgroup.org/display/HDF5/Using+the+Direct+Chunk+Write+Function">Using the Direct Chunk Write Function</a> for more information.</dd></dl>
<dl class="section note"><dt>Note</dt><dd><a class="el" href="#gaaf8ec5a5623f93549e49c39f95c4abab" title="Reads a raw data chunk directly from a dataset in a file into a buffer.">H5DOread_chunk()</a> and <a class="el" href="#gabc3c07ed2cf29dd34035194919fbeb31" title="Writes a raw data chunk from a buffer directly to a dataset in a file.">H5DOwrite_chunk()</a> are not supported under parallel and do not support variable length types.</dd></dl>
<dl class="section user"><dt>Example</dt><dd>The following code illustrates the use of H5DOwrite_chunk to write an entire dataset, chunk by chunk: <div class="fragment"><div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;zlib.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;math.h&gt;</span></div>
<div class="line"><span class="preprocessor">#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12)</span></div>
<div class="line">                :</div>
<div class="line">                :</div>
<div class="line"><span class="keywordtype">size_t</span>       buf_size = CHUNK_NX*CHUNK_NY*<span class="keyword">sizeof</span>(int);</div>
<div class="line">                <span class="keyword">const</span> Bytef *z_src = (<span class="keyword">const</span> Bytef *)(direct_buf);</div>
<div class="line">                Bytef       *z_dst; <span class="comment">/* Destination buffer            */</span></div>
<div class="line">                uLongf       z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);</div>
<div class="line">                uLong        z_src_nbytes = (uLong)buf_size;</div>
<div class="line">                <span class="keywordtype">int</span>          aggression   = 9; <span class="comment">/* Compression aggression setting */</span></div>
<div class="line">                uint32_t     filter_mask  = 0;</div>
<div class="line">                <span class="keywordtype">size_t</span>       buf_size     = CHUNK_NX * CHUNK_NY * <span class="keyword">sizeof</span>(int);</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Create the data space */</span></div>
<div class="line">                <span class="keywordflow">if</span> ((dataspace = <a class="code hl_function" href="group___h5_s.html#ga8e35eea5738b4805856eac7d595254ae">H5Screate_simple</a>(RANK, dims, maxdims)) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Create a new file */</span></div>
<div class="line">                <span class="keywordflow">if</span> ((file = <a class="code hl_function" href="group___h5_f.html#gae64b51ee9ac0781bc4ccc599d98387f4">H5Fcreate</a>(FILE_NAME5, <a class="code hl_define" href="_h5_fpublic_8h.html#a5a2d6726f9ad8d2bca8df2b817e5ad6a">H5F_ACC_TRUNC</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Modify dataset creation properties, i.e. enable chunking and compression */</span></div>
<div class="line">                <span class="keywordflow">if</span> ((cparms = <a class="code hl_function" href="group___p_l_c_r.html#gaf1b11da01d4d45d788c45f8bc5f0cbfa">H5Pcreate</a>(<a class="code hl_define" href="_h5_ppublic_8h.html#afcd7f8186c404f3a1d768632eacba102">H5P_DATASET_CREATE</a>)) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="keywordflow">if</span> ((status = <a class="code hl_function" href="group___d_c_p_l.html#ga3584d592e377da3604b7604e266dcf5b">H5Pset_chunk</a>(cparms, RANK, chunk_dims)) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="keywordflow">if</span> ((status = <a class="code hl_function" href="group___d_c_p_l.html#gaf1f569bfc54552bdb9317d2b63318a0d">H5Pset_deflate</a>(cparms, aggression)) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Create a new dataset within the file using cparms creation properties */</span></div>
<div class="line">                <span class="keywordflow">if</span> ((dset_id = <a class="code hl_function" href="group___h5_d.html#gabf62045119f4e9c512d87d77f2f992df">H5Dcreate2</a>(file, DATASETNAME, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga3cf93ffc6782be68070ef8e00f219ec2">H5T_NATIVE_INT</a>, dataspace, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, cparms,</div>
<div class="line">                                          <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>)) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Initialize data for one chunk */</span></div>
<div class="line">                <span class="keywordflow">for</span> (i = n = 0; i &lt; CHUNK_NX; i++)</div>
<div class="line">                    <span class="keywordflow">for</span> (j = 0; j &lt; CHUNK_NY; j++)</div>
<div class="line">                        direct_buf[i][j] = n++;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Allocate output (compressed) buffer */</span></div>
<div class="line">                outbuf = malloc(z_dst_nbytes);</div>
<div class="line">                z_dst  = (Bytef *)outbuf;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Perform compression from the source to the destination buffer */</span></div>
<div class="line">                ret = compress2(z_dst, &amp;z_dst_nbytes, z_src, z_src_nbytes, aggression);</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Check for various zlib errors */</span></div>
<div class="line">                <span class="keywordflow">if</span> (Z_BUF_ERROR == ret) {</div>
<div class="line">                    fprintf(stderr, <span class="stringliteral">&quot;overflow&quot;</span>);</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line">                }</div>
<div class="line">                <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Z_MEM_ERROR == ret) {</div>
<div class="line">                    fprintf(stderr, <span class="stringliteral">&quot;deflate memory error&quot;</span>);</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line">                }</div>
<div class="line">                <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Z_OK != ret) {</div>
<div class="line">                    fprintf(stderr, <span class="stringliteral">&quot;other deflate error&quot;</span>);</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line">                }</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Write the compressed chunk data repeatedly to cover all the</span></div>
<div class="line"><span class="comment">                 *  * chunks in the dataset, using the direct write function.     */</span></div>
<div class="line">                <span class="keywordflow">for</span> (i = 0; i &lt; NX / CHUNK_NX; i++) {</div>
<div class="line">                    <span class="keywordflow">for</span> (j = 0; j &lt; NY / CHUNK_NY; j++) {</div>
<div class="line">                        status =</div>
<div class="line">                            <a class="code hl_function" href="#gabc3c07ed2cf29dd34035194919fbeb31">H5DOwrite_chunk</a>(dset_id, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, filter_mask, offset, z_dst_nbytes, outbuf);</div>
<div class="line">                        offset[1] += CHUNK_NY;</div>
<div class="line">                    }</div>
<div class="line">                    offset[0] += CHUNK_NX;</div>
<div class="line">                    offset[1] = 0;</div>
<div class="line">                }</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Overwrite the first chunk with uncompressed data.  Set the filter mask to</span></div>
<div class="line"><span class="comment">                 *  * indicate the compression filter is skipped */</span></div>
<div class="line">                filter_mask = 0x00000001;</div>
<div class="line">                offset[0] = offset[1] = 0;</div>
<div class="line">                <span class="keywordflow">if</span> (<a class="code hl_function" href="#gabc3c07ed2cf29dd34035194919fbeb31">H5DOwrite_chunk</a>(dset_id, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, filter_mask, offset, buf_size, direct_buf) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Read the entire dataset back for data verification converting ints to longs */</span></div>
<div class="line">                <span class="keywordflow">if</span> (<a class="code hl_function" href="group___h5_d.html#ga8287d5a7be7b8e55ffeff68f7d26811c">H5Dread</a>(dataset, <a class="code hl_define" href="group___p_d_t_n_a_t.html#ga290b9655882754ee0ec9f31b42ac04f6">H5T_NATIVE_LONG</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_spublic_8h.html#a5f96eeee84b987f18470737f85af0484">H5S_ALL</a>, <a class="code hl_define" href="_h5_ppublic_8h.html#afa85e97bfbf9bf1c58e39263846c568f">H5P_DEFAULT</a>, outbuf_long) &lt; 0)</div>
<div class="line">                    <span class="keywordflow">goto</span> error;</div>
<div class="line"> </div>
<div class="line">                <span class="comment">/* Data verification here */</span></div>
<div class="line">            :</div>
<div class="line">            :</div>
<div class="line"> </div>
</div><!-- fragment --></dd></dl>
<dl class="section version"><dt>Version</dt><dd>1.10.3 Function deprecated in favor of H5Dwrite_chunk.</dd></dl>
<dl class="section since"><dt>Since</dt><dd>1.8.11 </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.10.0 </li>
  </ul>
</div>
</body>
</html>