Files
hdf5/doc/html/cpplus_RM/writedata_8cpp-example.html
Frank Baker c17fb6fa1d [svn-r9028]
Purpose:
    Adding C++ Reference Manual to 1.6 release branch.
    This manual is automatically generated
    by doxygen from the C++ source code.
Platforms tested:
    Mozilla, Safari, IE 5
2004-08-05 16:22:19 -05:00

579 lines
25 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="header_files/filelist.xml">
<link rel=Edit-Time-Data href="header_files/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Main Page</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>Randy Ribler</o:Author>
<o:Template>Normal</o:Template>
<o:LastAuthor>Randy Ribler</o:LastAuthor>
<o:Revision>6</o:Revision>
<o:TotalTime>16</o:TotalTime>
<o:Created>2004-07-23T05:34:00Z</o:Created>
<o:LastSaved>2004-07-23T06:03:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>5</o:Words>
<o:Characters>32</o:Characters>
<o:Company>LC</o:Company>
<o:Lines>1</o:Lines>
<o:Paragraphs>1</o:Paragraphs>
<o:CharactersWithSpaces>36</o:CharactersWithSpaces>
<o:Version>10.2625</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<link rel=Stylesheet type="text/css" media=all href=doxygen.css>
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-believe-normal-left:yes;}
h1
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
text-align:center;
mso-pagination:widow-orphan;
mso-outline-level:1;
font-size:24.0pt;
font-family:"Times New Roman";
font-weight:bold;}
h2
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
mso-outline-level:2;
font-size:18.0pt;
font-family:"Times New Roman";
font-weight:bold;}
a:link, span.MsoHyperlink
{color:#252E78;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:#3D2185;
text-decoration:underline;
text-underline:single;}
p
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
address
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
font-style:italic;}
pre
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-font-family:"Times New Roman";}
p.formuladsp, li.formuladsp, div.formuladsp
{mso-style-name:formuladsp;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
text-align:center;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.mdtable, li.mdtable, div.mdtable
{mso-style-name:mdtable;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
background:#F4F4FB;
border:none;
mso-border-alt:solid #868686 .75pt;
padding:0in;
mso-padding-alt:0in 0in 0in 0in;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.mdrow, li.mdrow, div.mdrow
{mso-style-name:mdrow;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.mdescleft, li.mdescleft, div.mdescleft
{mso-style-name:mdescleft;
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
background:#FAFAFA;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
font-style:italic;}
p.mdescright, li.mdescright, div.mdescright
{mso-style-name:mdescright;
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
background:#FAFAFA;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
font-style:italic;}
p.memitemleft, li.memitemleft, div.memitemleft
{mso-style-name:memitemleft;
margin:3.0pt;
mso-pagination:widow-orphan;
background:#FAFAFA;
border:none;
mso-border-top-alt:solid #E0E0E0 .75pt;
padding:0in;
mso-padding-alt:1.0pt 0in 0in 0in;
font-size:9.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.memitemright, li.memitemright, div.memitemright
{mso-style-name:memitemright;
margin:3.0pt;
mso-pagination:widow-orphan;
background:#FAFAFA;
border:none;
mso-border-top-alt:solid #E0E0E0 .75pt;
padding:0in;
mso-padding-alt:1.0pt 0in 0in 0in;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.search, li.search, div.search
{mso-style-name:search;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
font-weight:bold;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
table.MsoTableGrid
{mso-style-name:"Table Grid";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-border-insideh:.5pt solid windowtext;
mso-border-insidev:.5pt solid windowtext;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]--><![if mso 9]>
<style>
p.MsoNormal
{margin-left:15.0pt;}
</style>
<![endif]><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="4098">
<o:colormru v:ext="edit" colors="#060"/>
<o:colormenu v:ext="edit" strokecolor="#060"/>
</o:shapedefaults></xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=white lang=EN-US link="#252E78" vlink="#3D2185" style='tab-interval:
.5in;margin-left:15.0pt;margin-right:15.0pt'>
<div class=Section1>
<p class=MsoNormal style='margin-top:0in;margin-right:15.0pt;margin-bottom:
0in;margin-left:15.0pt;margin-bottom:.0001pt'><!--[if gte vml 1]><v:shapetype
id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_s1026" type="#_x0000_t75" style='position:absolute;
left:0;text-align:left;margin-left:30pt;margin-top:9pt;width:72.75pt;height:57.75pt;
z-index:1'>
<v:imagedata src="header_files/image001.jpg" o:title="NCSAlogo"/>
</v:shape><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:1;left:0px;margin-left:40px;margin-top:12px;width:97px;
height:77px'><img width=97 height=77 src="header_files/image002.jpg" v:shapes="_x0000_s1026"></span><![endif]><span
style='mso-spacerun:yes'> </span><b style='mso-bidi-font-weight:normal'><span
style='font-size:22.0pt'><o:p></o:p></span></b></p>
<div align=center>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0
style='margin-left:103.45pt;border-collapse:collapse;border:none;mso-border-bottom-alt:
solid #006600 2.25pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt'>
<tr style='mso-yfti-irow:0;mso-yfti-lastrow:yes;height:29.25pt'>
<td width=443 valign=top style='width:332.6pt;border:none;border-bottom:solid #006600 2.25pt;
padding:0in 5.4pt 0in 5.4pt;height:29.25pt'>
<p class=MsoNormal><b style='mso-bidi-font-weight:normal'><span
style='font-size:22.0pt'>HDF5 C++ API Reference Manual</span></b></p>
</td>
</tr>
</table>
</div>
<p class=MsoNormal><o:p>&nbsp;</o:p></p>
<p class=MsoNormal><o:p>&nbsp;</o:p></p>
<p class=MsoNormal><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>
<!-- Generated by Doxygen 1.3.7-20040718 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="examples.html">Examples</a></div>
<h1>writedata.cpp</h1><dl compact><dt><b>Another example:</b></dt><dd>This example shows how to write datasets. <div class="fragment"><pre><span class="comment">/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *</span>
<span class="comment"> * Copyright by the Board of Trustees of the University of Illinois. *</span>
<span class="comment"> * All rights reserved. *</span>
<span class="comment"> * *</span>
<span class="comment"> * This file is part of HDF5. The full HDF5 copyright notice, including *</span>
<span class="comment"> * terms governing use, modification, and redistribution, is contained in *</span>
<span class="comment"> * the files COPYING and Copyright.html. COPYING can be found at the root *</span>
<span class="comment"> * of the source code distribution tree; Copyright.html can be found at the *</span>
<span class="comment"> * root level of an installed copy of the electronic HDF5 document set and *</span>
<span class="comment"> * is linked from the top-level documents page. It can also be found at *</span>
<span class="comment"> * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *</span>
<span class="comment"> * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *</span>
<span class="comment"> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */</span>
<span class="comment">/* </span>
<span class="comment"> * This program shows how the select_hyperslab and select_elements</span>
<span class="comment"> * functions are used to write selected data from memory to the file.</span>
<span class="comment"> * Program takes 48 elements from the linear buffer and writes them into</span>
<span class="comment"> * the matrix using 3x2 blocks, (4,3) stride and (2,4) count. </span>
<span class="comment"> * Then four elements of the matrix are overwritten with the new values and </span>
<span class="comment"> * file is closed. Program reopens the file and reads and displays the result.</span>
<span class="comment"> */</span>
<span class="preprocessor">#include &lt;string&gt;</span>
<span class="preprocessor">#ifdef OLD_HEADER_FILENAME</span>
<span class="preprocessor"></span><span class="preprocessor">#include &lt;iostream.h&gt;</span>
<span class="preprocessor">#else</span>
<span class="preprocessor"></span><span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="H5Cpp_8h.html">H5Cpp.h</a>"</span>
<span class="preprocessor">#ifndef H5_NO_NAMESPACE</span>
<span class="preprocessor"></span><span class="keyword">using</span> <span class="keyword">namespace </span>H5;
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="keyword">const</span> string FILE_NAME( <span class="stringliteral">"Select.h5"</span> );
<span class="keyword">const</span> string DATASET_NAME( <span class="stringliteral">"Matrix in file"</span> );
<span class="keyword">const</span> <span class="keywordtype">int</span> MSPACE1_RANK = 1; <span class="comment">// Rank of the first dataset in memory</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> MSPACE1_DIM = 50; <span class="comment">// Dataset size in memory</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> MSPACE2_RANK = 1; <span class="comment">// Rank of the second dataset in memory</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> MSPACE2_DIM = 4; <span class="comment">// Dataset size in memory</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> FSPACE_RANK = 2; <span class="comment">// Dataset rank as it is stored in the file</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> FSPACE_DIM1 = 8; <span class="comment">// Dimension sizes of the dataset as it is...</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> FSPACE_DIM2 = 12; <span class="comment">// ...stored in the file </span>
<span class="keyword">const</span> <span class="keywordtype">int</span> MSPACE_DIM1 = 8; <span class="comment">// We will read dataset back from the file...</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> MSPACE_DIM2 = 12; <span class="comment">// ...to the dataset in memory with these ...</span>
<span class="comment">// ...dataspace parameters</span>
<span class="keyword">const</span> <span class="keywordtype">int</span> NPOINTS = 4; <span class="comment">// Number of points that will be selected...</span>
<span class="comment">// ...and overwritten</span>
<span class="keywordtype">int</span> main (<span class="keywordtype">void</span>)
{
<span class="comment">/*</span>
<span class="comment"> * Buffers' initialization.</span>
<span class="comment"> */</span>
uint i,j;
<span class="keywordtype">int</span> vector[MSPACE1_DIM];
vector[0] = vector[MSPACE1_DIM - 1] = -1;
<span class="keywordflow">for</span> (i = 1; i &lt; MSPACE1_DIM - 1; i++)
vector[i] = i;
<span class="keywordtype">int</span> matrix[MSPACE_DIM1][MSPACE_DIM2];
<span class="keywordflow">for</span> (i = 0; i &lt; MSPACE_DIM1; i++)
{
<span class="keywordflow">for</span> (j = 0; j &lt; MSPACE_DIM2; j++)
matrix[i][j] = 0;
}
<span class="comment">// Try block to detect exceptions raised by any of the calls inside it</span>
<span class="keywordflow">try</span>
{
<span class="comment">/*</span>
<span class="comment"> * Turn off the auto-printing when failure occurs so that we can</span>
<span class="comment"> * handle the errors appropriately</span>
<span class="comment"> */</span>
Exception::dontPrint();
<span class="comment">/*</span>
<span class="comment"> * Create a file.</span>
<span class="comment"> */</span>
H5File* file = <span class="keyword">new</span> H5File( FILE_NAME, H5F_ACC_TRUNC );
<span class="comment">/*</span>
<span class="comment"> * Create dataspace for the dataset in the file.</span>
<span class="comment"> */</span>
hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; <span class="comment">// dim sizes of ds (on disk)</span>
DataSpace fspace( FSPACE_RANK, fdim );
<span class="comment">/*</span>
<span class="comment"> * Create dataset and write it into the file.</span>
<span class="comment"> */</span>
DataSet* dataset = <span class="keyword">new</span> DataSet(
file-&gt;createDataSet( DATASET_NAME, PredType::NATIVE_INT, fspace ));
dataset-&gt;write( matrix, PredType::NATIVE_INT );
<span class="comment">/*</span>
<span class="comment"> * Select hyperslab for the dataset in the file, using 3x2 blocks, </span>
<span class="comment"> * (4,3) stride and (2,4) count starting at the position (0,1).</span>
<span class="comment"> */</span>
hssize_t start[2]; <span class="comment">// Start of hyperslab</span>
hsize_t stride[2]; <span class="comment">// Stride of hyperslab</span>
hsize_t count[2]; <span class="comment">// Block count</span>
hsize_t block[2]; <span class="comment">// Block sizes</span>
start[0] = 0; start[1] = 1;
stride[0] = 4; stride[1] = 3;
count[0] = 2; count[1] = 4;
block[0] = 3; block[1] = 2;
fspace.selectHyperslab( H5S_SELECT_SET, count, start, stride, block);
<span class="comment">/*</span>
<span class="comment"> * Create dataspace for the first dataset.</span>
<span class="comment"> */</span>
hsize_t dim1[] = {MSPACE1_DIM}; <span class="comment">/* Dimension size of the first dataset </span>
<span class="comment"> (in memory) */</span>
DataSpace mspace1( MSPACE1_RANK, dim1 );
<span class="comment">/*</span>
<span class="comment"> * Select hyperslab. </span>
<span class="comment"> * We will use 48 elements of the vector buffer starting at the </span>
<span class="comment"> * second element. Selected elements are 1 2 3 . . . 48</span>
<span class="comment"> */</span>
start[0] = 1;
stride[0] = 1;
count[0] = 48;
block[0] = 1;
mspace1.selectHyperslab( H5S_SELECT_SET, count, start, stride, block);
<span class="comment">/*</span>
<span class="comment"> * Write selection from the vector buffer to the dataset in the file.</span>
<span class="comment"> *</span>
<span class="comment"> * File dataset should look like this: </span>
<span class="comment"> * 0 1 2 0 3 4 0 5 6 0 7 8 </span>
<span class="comment"> * 0 9 10 0 11 12 0 13 14 0 15 16</span>
<span class="comment"> * 0 17 18 0 19 20 0 21 22 0 23 24</span>
<span class="comment"> * 0 0 0 0 0 0 0 0 0 0 0 0</span>
<span class="comment"> * 0 25 26 0 27 28 0 29 30 0 31 32</span>
<span class="comment"> * 0 33 34 0 35 36 0 37 38 0 39 40</span>
<span class="comment"> * 0 41 42 0 43 44 0 45 46 0 47 48</span>
<span class="comment"> * 0 0 0 0 0 0 0 0 0 0 0 0</span>
<span class="comment"> */</span>
dataset-&gt;write( vector, PredType::NATIVE_INT, mspace1, fspace );
<span class="comment">/*</span>
<span class="comment"> * Reset the selection for the file dataspace fid.</span>
<span class="comment"> */</span>
fspace.selectNone();
<span class="comment">/*</span>
<span class="comment"> * Create dataspace for the second dataset.</span>
<span class="comment"> */</span>
hsize_t dim2[] = {MSPACE2_DIM}; <span class="comment">/* Dimension size of the second dataset</span>
<span class="comment"> (in memory */</span>
DataSpace mspace2( MSPACE2_RANK, dim2 );
<span class="comment">/*</span>
<span class="comment"> * Select sequence of NPOINTS points in the file dataspace.</span>
<span class="comment"> */</span>
hssize_t coord[NPOINTS][FSPACE_RANK]; <span class="comment">/* Array to store selected points </span>
<span class="comment"> from the file dataspace */</span>
coord[0][0] = 0; coord[0][1] = 0;
coord[1][0] = 3; coord[1][1] = 3;
coord[2][0] = 3; coord[2][1] = 5;
coord[3][0] = 5; coord[3][1] = 6;
fspace.selectElements( H5S_SELECT_SET, NPOINTS, (<span class="keyword">const</span> hssize_t **)coord);
<span class="comment">/*</span>
<span class="comment"> * Write new selection of points to the dataset.</span>
<span class="comment"> */</span>
<span class="keywordtype">int</span> values[] = {53, 59, 61, 67}; <span class="comment">/* New values to be written */</span>
dataset-&gt;write( values, PredType::NATIVE_INT, mspace2, fspace );
<span class="comment">/*</span>
<span class="comment"> * File dataset should look like this: </span>
<span class="comment"> * 53 1 2 0 3 4 0 5 6 0 7 8 </span>
<span class="comment"> * 0 9 10 0 11 12 0 13 14 0 15 16</span>
<span class="comment"> * 0 17 18 0 19 20 0 21 22 0 23 24</span>
<span class="comment"> * 0 0 0 59 0 61 0 0 0 0 0 0</span>
<span class="comment"> * 0 25 26 0 27 28 0 29 30 0 31 32</span>
<span class="comment"> * 0 33 34 0 35 36 67 37 38 0 39 40</span>
<span class="comment"> * 0 41 42 0 43 44 0 45 46 0 47 48</span>
<span class="comment"> * 0 0 0 0 0 0 0 0 0 0 0 0</span>
<span class="comment"> * </span>
<span class="comment"> */</span>
<span class="comment">/*</span>
<span class="comment"> * Close the dataset and the file.</span>
<span class="comment"> */</span>
<span class="keyword">delete</span> dataset;
<span class="keyword">delete</span> file;
<span class="comment">/*</span>
<span class="comment"> * Open the file.</span>
<span class="comment"> */</span>
file = <span class="keyword">new</span> H5File( FILE_NAME, H5F_ACC_RDONLY );
<span class="comment">/*</span>
<span class="comment"> * Open the dataset.</span>
<span class="comment"> */</span>
dataset = <span class="keyword">new</span> DataSet( file-&gt;openDataSet( DATASET_NAME ));
<span class="comment">/*</span>
<span class="comment"> * Read data back to the buffer matrix.</span>
<span class="comment"> */</span>
dataset-&gt;read( matrix, PredType::NATIVE_INT );
<span class="comment">/*</span>
<span class="comment"> * Display the result.</span>
<span class="comment"> */</span>
<span class="keywordflow">for</span> (i=0; i &lt; MSPACE_DIM1; i++)
{
<span class="keywordflow">for</span>(j=0; j &lt; MSPACE_DIM2; j++)
cout &lt;&lt; matrix[i][j] &lt;&lt; <span class="stringliteral">" "</span>;
cout &lt;&lt; endl;
}
<span class="comment">/*</span>
<span class="comment"> * Close the dataset and the file.</span>
<span class="comment"> */</span>
<span class="keyword">delete</span> dataset;
<span class="keyword">delete</span> file;
} <span class="comment">// end of try block</span>
<span class="comment">// catch failure caused by the H5File operations</span>
<span class="keywordflow">catch</span>( FileIException error )
{
error.printError();
<span class="keywordflow">return</span> -1;
}
<span class="comment">// catch failure caused by the DataSet operations</span>
<span class="keywordflow">catch</span>( DataSetIException error )
{
error.printError();
<span class="keywordflow">return</span> -1;
}
<span class="comment">// catch failure caused by the DataSpace operations</span>
<span class="keywordflow">catch</span>( DataSpaceIException error )
{
error.printError();
<span class="keywordflow">return</span> -1;
}
<span class="keywordflow">return</span> 0;
}
</pre></div> </dd></dl>
<hr size="1"><address style="align: right;"><small>Generated on Thu Aug 5 00:22:37 2004 by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7-20040718 </small></address>
</body>
</html>