This file is indexed.

/usr/share/doc/netCDF/html/examples1.html is in netcdf-doc 1:4.4.1.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
<!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.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NetCDF: NetCDF Example Programs</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">
  $(document).ready(initResizable);
</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>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<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="netcdf-50x50.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">NetCDF
   &#160;<span id="projectnumber">4.4.1.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</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">
$(document).ready(function(){initNavTree('examples1.html','');});
</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="header">
  <div class="headertitle">
<div class="title">NetCDF Example Programs </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#example_simple_xy">The simple_xy Example</a></li>
<li class="level1"><a href="#example_sfc_pres_temp">The sfc_pres_temp Example</a></li>
<li class="level1"><a href="#example_pres_temp_4D">The pres_temp_4D Example</a></li>
<li class="level1"><a href="#example_simple_nc4">The simple_nc4 Example</a></li>
<li class="level1"><a href="#example_simple_xy_nc4">The simple_xy_nc4 Example</a></li>
</ul>
</div>
<div class="textblock"><p>The netCDF example programs show how to use netCDF.</p>
<p>In the netCDF distribution, the “examples” directory contains examples in C and CDL. The examples create, and then read, example data files of increasing complexity.</p>
<p>There are three sets of netCDF classic example programs; corresponding examples are included with the netCDF Fortran and C++ APIs.</p><ul>
<li><a class="el" href="examples1.html#example_simple_xy">The simple_xy Example</a></li>
<li><a class="el" href="examples1.html#example_sfc_pres_temp">The sfc_pres_temp Example</a></li>
<li><a class="el" href="examples1.html#example_pres_temp_4D">The pres_temp_4D Example</a></li>
</ul>
<p>Any existing netCDF applications can be converted to generate netCDF-4/HDF5 files. Simply change the file creation call to include the correct mode flag.</p>
<p>In one of the netCDF classic examples which write a data file, change the <a class="el" href="group__datasets.html#ga427f5a0b24f1d426a99bcc37b8a39cac" title="Create a new netCDF file. ">nc_create()</a> call so that <a class="el" href="netcdf_8h.html#a0d505827d0bdef8a011faf73c5331b9b" title="Use netCDF-4/HDF5 format. ">NC_NETCDF4</a> is one of the flags set on the create.</p>
<p>The corresponding read example will work without modification; netCDF will notice that the file is a NetCDF-4/HDF5 file, and will read it automatically, just as if it were a netCDF classic format file.</p>
<p>In the example in this section we show some of the advanced features of netCDF-4.</p><ul>
<li><a class="el" href="examples1.html#example_simple_nc4">The simple_nc4 Example</a></li>
<li><a class="el" href="examples1.html#example_simple_xy_nc4">The simple_xy_nc4 Example</a></li>
</ul>
<p>The examples are built and run with the “make check” command. (See <a class="el" href="getting_and_building_netcdf.html#building">Building netCDF-C </a>).</p>
<p>The corresponding examples in each language create identical netCDF data files. For example, the C program <a class="el" href="sfc__pres__temp__wr_8c.html" title="A simple example of writing a netCDF file. ">sfc_pres_temp_wr.c</a> produces the same data file as the Fortran 77 program sfc_pres_temp_wr.f.</p>
<h1><a class="anchor" id="example_simple_xy"></a>
The simple_xy Example</h1>
<p>This example is an unrealistically simple netCDF file, to demonstrate the minimum operation of the netCDF APIs. Users should seek to make their netCDF files more self-describing than this primitive example.</p><ul>
<li><a class="el" href="simple__xy__wr_8c.html" title="An example program demonstrating a simple 2D write. ">simple_xy_wr.c</a></li>
<li><a class="el" href="simple__xy__rd_8c.html" title="Write a file demonstrating some of the features of netCDF-4. ">simple_xy_rd.c</a></li>
</ul>
<p>As in all the netCDF tutorial examples, this example file can be created by C and by ncgen, which creates it from a CDL script. Both ncgen and the C example create identical files, “simple_xy.nc.”</p>
<p>The simple_xy.nc data file contains two dimensions, “x” and “y”, and one netCDF variable, “data.”</p>
<p>The CDL for this example is shown below. For more information on ncdump and ncgen see NetCDF Utilities.</p>
<div class="fragment"><div class="line">netcdf simple_xy {</div><div class="line">dimensions:</div><div class="line">   x = 6 ;</div><div class="line">   y = 12 ;</div><div class="line">variables:</div><div class="line">   <span class="keywordtype">int</span> data(x, y) ;</div><div class="line">data:</div><div class="line"></div><div class="line"> data =</div><div class="line">  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,</div><div class="line">  12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,</div><div class="line">  24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,</div><div class="line">  36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,</div><div class="line">  48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,</div><div class="line">  60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71 ;</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="example_sfc_pres_temp"></a>
The sfc_pres_temp Example</h1>
<p>This example has been constructed for the meteorological mind.</p>
<p>Suppose you have some data you want to write to a netCDF file. For example, you have one time step of surface temperature and surface pressure, on a 6 x 12 latitude longitude grid.</p>
<p>To store this in netCDF, create a file, add two dimensions (latitude and longitude) and two variables (pressure and temperature).</p><ul>
<li><a class="el" href="sfc__pres__temp__wr_8c.html" title="A simple example of writing a netCDF file. ">sfc_pres_temp_wr.c</a></li>
<li><a class="el" href="sfc__pres__temp__rd_8c.html" title="A simple example of reading a netCDF file. ">sfc_pres_temp_rd.c</a></li>
</ul>
<p>In this example we add some netCDF attributes, as is typical in scientific applications, to further describe the data. In this case we add a units attribute to every netCDF variable.</p>
<p>In this example we also add additional netCDF variables to describe the coordinate system. These “coordinate variables” allow us to specify the latitudes and longitudes that describe the data grid.</p>
<p>The CDL version of the data file, generated by ncdump, is shown below (see <a class="el" href="netcdf_working_with_netcdf_files.html#netcdf_utilities">The NetCDF Utilities</a>).</p>
<div class="fragment"><div class="line">netcdf sfc_pres_temp {</div><div class="line">dimensions:</div><div class="line">   latitude = 6 ;</div><div class="line">   longitude = 12 ;</div><div class="line">variables:</div><div class="line">   <span class="keywordtype">float</span> latitude(latitude) ;</div><div class="line">       latitude:units = <span class="stringliteral">&quot;degrees_north&quot;</span> ;</div><div class="line">   <span class="keywordtype">float</span> longitude(longitude) ;</div><div class="line">       longitude:units = <span class="stringliteral">&quot;degrees_east&quot;</span> ;</div><div class="line">   <span class="keywordtype">float</span> pressure(latitude, longitude) ;</div><div class="line">       pressure:units = <span class="stringliteral">&quot;hPa&quot;</span> ;</div><div class="line">   <span class="keywordtype">float</span> temperature(latitude, longitude) ;</div><div class="line">       temperature:units = <span class="stringliteral">&quot;celsius&quot;</span> ;</div><div class="line">data:</div><div class="line"></div><div class="line"> latitude = 25, 30, 35, 40, 45, 50 ;</div><div class="line"></div><div class="line"> longitude = -125, -120, -115, -110, -105, -100, -95, -90, -85, -80, -75, -70 ;</div><div class="line"></div><div class="line"> pressure =</div><div class="line">  900, 906, 912, 918, 924, 930, 936, 942, 948, 954, 960, 966,</div><div class="line">  901, 907, 913, 919, 925, 931, 937, 943, 949, 955, 961, 967,</div><div class="line">  902, 908, 914, 920, 926, 932, 938, 944, 950, 956, 962, 968,</div><div class="line">  903, 909, 915, 921, 927, 933, 939, 945, 951, 957, 963, 969,</div><div class="line">  904, 910, 916, 922, 928, 934, 940, 946, 952, 958, 964, 970,</div><div class="line">  905, 911, 917, 923, 929, 935, 941, 947, 953, 959, 965, 971 ;</div><div class="line"></div><div class="line"> temperature =</div><div class="line">  9, 10.5, 12, 13.5, 15, 16.5, 18, 19.5, 21, 22.5, 24, 25.5,</div><div class="line">  9.25, 10.75, 12.25, 13.75, 15.25, 16.75, 18.25, 19.75, 21.25, 22.75, 24.25,</div><div class="line">    25.75,</div><div class="line">  9.5, 11, 12.5, 14, 15.5, 17, 18.5, 20, 21.5, 23, 24.5, 26,</div><div class="line">  9.75, 11.25, 12.75, 14.25, 15.75, 17.25, 18.75, 20.25, 21.75, 23.25, 24.75,</div><div class="line">    26.25,</div><div class="line">  10, 11.5, 13, 14.5, 16, 17.5, 19, 20.5, 22, 23.5, 25, 26.5,</div><div class="line">  10.25, 11.75, 13.25, 14.75, 16.25, 17.75, 19.25, 20.75, 22.25, 23.75,</div><div class="line">    25.25, 26.75 ;</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="example_pres_temp_4D"></a>
The pres_temp_4D Example</h1>
<p>This example expands on the previous example by making our two-dimensional data into four-dimensional data, adding a vertical level axis and an unlimited time step axis.</p><ul>
<li><a class="el" href="pres__temp__4D__wr_8c.html" title="A more complex example of writing a netCDF file. ">pres_temp_4D_wr.c</a></li>
<li><a class="el" href="pres__temp__4D__rd_8c.html" title="Example program for reading a 4D netCDF file. ">pres_temp_4D_rd.c</a></li>
</ul>
<p>Additionally, in this example the data are written and read one time step at a time, as is typical in scientific applications that use the unlimited dimension.</p>
<p>The sample data file created by pres_temp_4D_wr can be examined with the utility ncdump (see <a class="el" href="netcdf_working_with_netcdf_files.html#netcdf_utilities">The NetCDF Utilities</a>).</p>
<div class="fragment"><div class="line">netcdf pres_temp_4D {</div><div class="line">dimensions:</div><div class="line">   level = 2 ;</div><div class="line">   latitude = 6 ;</div><div class="line">   longitude = 12 ;</div><div class="line">   time = UNLIMITED ; <span class="comment">// (2 currently)</span></div><div class="line">variables:</div><div class="line">   <span class="keywordtype">float</span> latitude(latitude) ;</div><div class="line">       latitude:units = <span class="stringliteral">&quot;degrees_north&quot;</span> ;</div><div class="line">   <span class="keywordtype">float</span> longitude(longitude) ;</div><div class="line">       longitude:units = <span class="stringliteral">&quot;degrees_east&quot;</span> ;</div><div class="line">   <span class="keywordtype">float</span> pressure(time, level, latitude, longitude) ;</div><div class="line">       pressure:units = <span class="stringliteral">&quot;hPa&quot;</span> ;</div><div class="line">   <span class="keywordtype">float</span> temperature(time, level, latitude, longitude) ;</div><div class="line">       temperature:units = <span class="stringliteral">&quot;celsius&quot;</span> ;</div><div class="line">data:</div><div class="line"></div><div class="line"> latitude = 25, 30, 35, 40, 45, 50 ;</div><div class="line"></div><div class="line"> longitude = -125, -120, -115, -110, -105, -100, -95, -90, -85, -80, -75, -70 ;</div><div class="line"></div><div class="line"> pressure =</div><div class="line">  900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911,</div><div class="line">  912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923,</div><div class="line">  924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935,</div><div class="line">  936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947,</div><div class="line">  948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959,</div><div class="line">  960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971,</div><div class="line">  972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983,</div><div class="line">  984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995,</div><div class="line">  996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,</div><div class="line">  1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019,</div><div class="line">  1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031,</div><div class="line">  1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043,</div><div class="line">  900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911,</div><div class="line">  912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923,</div><div class="line">  924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935,</div><div class="line">  936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947,</div><div class="line">  948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959,</div><div class="line">  960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971,</div><div class="line">  972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983,</div><div class="line">  984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995,</div><div class="line">  996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,</div><div class="line">  1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019,</div><div class="line">  1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031,</div><div class="line">  1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043 ;</div><div class="line"></div><div class="line"> temperature =</div><div class="line">  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,</div><div class="line">  21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,</div><div class="line">  33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,</div><div class="line">  45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,</div><div class="line">  57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,</div><div class="line">  69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,</div><div class="line">  81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,</div><div class="line">  93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,</div><div class="line">  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,</div><div class="line">  117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,</div><div class="line">  129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,</div><div class="line">  141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,</div><div class="line">  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,</div><div class="line">  21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,</div><div class="line">  33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,</div><div class="line">  45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,</div><div class="line">  57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,</div><div class="line">  69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,</div><div class="line">  81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,</div><div class="line">  93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,</div><div class="line">  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,</div><div class="line">  117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,</div><div class="line">  129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,</div><div class="line">  141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152 ;</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="example_simple_nc4"></a>
The simple_nc4 Example</h1>
<p>This example, like the simple_xy netCDF-3 example above, is an overly simplified example which demonstrates how to use groups in a netCDF-4 file.</p>
<p>This example is only available in C for this version of netCDF-4. The example creates and then reads the file “simple_nc4.nc.”</p>
<p>The simple_xy.nc data file contains two dimensions, “x” and “y”, two groups, “grp1” and “grp2”, and two data variables, one in each group, both named: “data.” One data variable is an unsigned 64-bit integer, the other a user-defined compound type.</p>
<p>The example program <a class="el" href="simple__nc4__wr_8c.html" title="Write a file demonstrating some of the features of netCDF-4. ">simple_nc4_wr.c</a> creates the example data file simple_nc4.nc. The example program <a class="el" href="simple__nc4__rd_8c.html" title="Read a simple file, with some of the features of netCDF-4. ">simple_nc4_rd.c</a> reads the data file.</p><ul>
<li><a class="el" href="simple__nc4__wr_8c.html" title="Write a file demonstrating some of the features of netCDF-4. ">simple_nc4_wr.c</a></li>
<li><a class="el" href="simple__nc4__rd_8c.html" title="Read a simple file, with some of the features of netCDF-4. ">simple_nc4_rd.c</a></li>
</ul>
<h1><a class="anchor" id="example_simple_xy_nc4"></a>
The simple_xy_nc4 Example</h1>
<p>This example, like the simple_xy netCDF-3 example above, is an overly simplified example. It is based on the simple_xy example, but used data chunking, compression, and the fletcher32 filter.</p>
<p>(These are all HDF5 features. For more information see <a href="http://hdfgroup.org/HDF5/">http://hdfgroup.org/HDF5/</a>).</p>
<p>This example is not yet available in C++. We hope to have the C++ example in a future release of netCDF.</p>
<p>The example creates and then reads the file “simple_xy_nc4.nc.”</p>
<p>The example program <a class="el" href="simple__xy__nc4__wr_8c.html" title="Write the simple_xy file, with some of the features of netCDF-4. ">simple_xy_nc4_wr.c</a> creates the example data file simple_xy_nc4.nc. The example program <a class="el" href="simple__xy__nc4__rd_8c.html" title="Read the simple_xy file, with some of the features of netCDF-4. ">simple_xy_nc4_rd.c</a> reads the data file.</p><ul>
<li><a class="el" href="simple__xy__nc4__wr_8c.html" title="Write the simple_xy file, with some of the features of netCDF-4. ">simple_xy_nc4_wr.c</a></li>
<li><a class="el" href="simple__xy__nc4__rd_8c.html" title="Read the simple_xy file, with some of the features of netCDF-4. ">simple_xy_nc4_rd.c</a> </li>
</ul>
</div></div><!-- contents -->
</div><!-- doc-content -->
<hr size="2"/>
<address style="text-align: center;">
<a href="http://www.unidata.ucar.edu/software/netcdf/">Return to the Main Unidata NetCDF page.</a><br>
<img src="unidata_logo_cmyk.png">
<address style="text-align: right;"><small>
Generated on Tue Apr 4 2017 06:09:19 for NetCDF. NetCDF is
a <a href="http://www.unidata.ucar.edu/">Unidata</a> library.</small></address>
</body>
</html>