/usr/share/doc/netcdf-doc/ncgen-man-1.html is in netcdf-doc 1:4.1.3-7.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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 | <!-- Creator : groff version 1.20.1 -->
<!-- CreationDate: Thu Jun 30 17:23:46 2011 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
h1 { text-align: center }
</style>
<title>NCGEN</title>
</head>
<body>
<h1 align="center">NCGEN</h1>
<a href="#NAME">NAME</a><br>
<a href="#SYNOPSIS">SYNOPSIS</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#OPTIONS">OPTIONS</a><br>
<a href="#EXAMPLES">EXAMPLES</a><br>
<a href="#USAGE">USAGE</a><br>
<a href="#BUGS">BUGS</a><br>
<hr>
<h2>NAME
<a name="NAME"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">ncgen −
From a CDL file generate a netCDF-3 file, a netCDF-4 file or
a C program</p>
<h2>SYNOPSIS
<a name="SYNOPSIS"></a>
</h2>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="89%">
<p style="margin-top: 1em">ncgen [-b] [-c] [-f] [-k <i>file
format</i>] [-l <i>output language</i>] [-n] [-o
<i>netcdf_filename</i>] [-x] <i>input_file</i></p></td></tr>
</table>
<h2>DESCRIPTION
<a name="DESCRIPTION"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><i><b>ncgen</b></i>
generates either a netCDF-3 (i.e. classic) binary .nc file,
a netCDF-4 (i.e. enhanced) binary .nc file or a file in some
source language that when executed will construct the
corresponding binary .nc file. The input to <b>ncgen</b> is
a description of a netCDF file in a small language known as
CDL (network Common Data form Language), described below. If
no options are specified in invoking <b>ncgen</b>, it merely
checks the syntax of the input CDL file, producing error
messages for any violations of CDL syntax. Other options can
be used, for example, to create the corresponding netCDF
file, or to generate a C program that uses the netCDF C
interface to create the netCDF file.</p>
<p style="margin-left:11%; margin-top: 1em">Note that this
version of ncgen was originally called ncgen4. The older
ncgen program has been renamed to ncgen3.</p>
<p style="margin-left:11%; margin-top: 1em"><b>ncgen</b>
may be used with the companion program <b>ncdump</b> to
perform some simple operations on netCDF files. For example,
to rename a dimension in a netCDF file, use <b>ncdump</b> to
get a CDL version of the netCDF file, edit the CDL file to
change the name of the dimensions, and use <b>ncgen</b> to
generate the corresponding netCDF file from the edited CDL
file.</p>
<h2>OPTIONS
<a name="OPTIONS"></a>
</h2>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p style="margin-top: 1em"><b>-b</b></p></td>
<td width="8%"></td>
<td width="78%">
<p style="margin-top: 1em">Create a (binary) netCDF file.
If the <b>-o</b> option is absent, a default file name will
be constructed from the netCDF name (specified after the
<b>netcdf</b> keyword in the input) by appending the
‘.nc’ extension. If a file already exists with
the specified name, it will be overwritten.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p><b>-c</b></p></td>
<td width="8%"></td>
<td width="78%">
<p>Generate <b>C</b> source code that will create a netCDF
file matching the netCDF specification. The C source code is
written to standard output; equivalent to -lc.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p><b>-f</b></p></td>
<td width="8%"></td>
<td width="78%">
<p>Generate <b>FORTRAN 77</b> source code that will create
a netCDF file matching the netCDF specification. The source
code is written to standard output; equivalent to -lf77.</p></td></tr>
</table>
<p style="margin-left:11%;"><b>-o</b> netcdf_file</p>
<p style="margin-left:22%;">Name for the binary netCDF file
created. If this option is specified, it implies the
"<b>-b</b>" option. (This option is necessary
because netCDF files cannot be written directly to standard
output, since standard output is not seekable.)</p>
<p style="margin-left:11%;"><b>-k</b> file_format</p>
<p style="margin-left:22%;">The -k flag specifies the
format of the file to be created and, by inference, the data
model accepted by ncgen (i.e. netcdf-3 (classic) versus
netcdf-4). The possible arguments are as follows.</p>
<p style="margin-left:32%;">’1’,
’classic’ => netcdf classic file format,
netcdf-3 <br>
type model. <br>
’2’, ’64-bit-offset’, ’64-bit
offset’ => netcdf 64 bit <br>
classic file format, netcdf-3 type model. <br>
’3’, ’hdf5’, ’netCDF-4’,
’enhanced’ => netcdf-4 file <br>
format, netcdf-4 type model. <br>
’4’, ’hdf5-nc3’, ’netCDF-4
classic model’, ’enhanced-nc3’ <br>
=> netcdf-4 file format, netcdf-3 type model.</p>
<p style="margin-left:11%;">If no -k is specified then it
defaults to -k1 (i.e. classic). Note also that -v is
accepted to mean the same thing as -k for backward
compatibility, but -k is preferred, to match the
corresponding ncdump option.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p><b>-x</b></p></td>
<td width="8%"></td>
<td width="78%">
<p>Don’t initialize data with fill values. This can
speed up creation of large netCDF files greatly, but later
attempts to read unwritten data from the generated file will
not be easily detectable.</p></td></tr>
</table>
<p style="margin-left:11%;"><b>-l</b> output_language</p>
<p style="margin-left:22%;">The -l flag specifies the
output language to use when generating source code that will
create or define a netCDF file matching the netCDF
specification. The output is written to standard output. The
currently supported languages have the following flags.</p>
<p style="margin-left:32%;">c|C’ => C language
output. <br>
f77|fortran77’ => FORTRAN 77 language output</p>
<p style="margin-left:43%;">; note that currently only the
classic model is supported.</p>
<p style="margin-left:32%;">j|java’ =>
(experimental) Java language output</p>
<p style="margin-left:43%;">; targets the existing Unidata
Java interface, which means that only the classic model is
supported.</p>
<h2>EXAMPLES
<a name="EXAMPLES"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">Check the
syntax of the CDL file ‘<b>foo.cdl</b>’:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="20%">
<p style="margin-top: 1em">ncgen foo.cdl</p></td>
<td width="58%">
</td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em">From the CDL
file ‘<b>foo.cdl</b>’, generate an equivalent
binary netCDF file named ‘<b>x.nc</b>’:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="32%">
<p style="margin-top: 1em">ncgen -o x.nc foo.cdl</p></td>
<td width="46%">
</td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em">From the CDL
file ‘<b>foo.cdl</b>’, generate a C program
containing the netCDF function invocations necessary to
create an equivalent binary netCDF file named
‘<b>x.nc</b>’:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="36%">
<p style="margin-top: 1em">ncgen -c -o x.nc foo.cdl</p></td>
<td width="42%">
</td></tr>
</table>
<h2>USAGE
<a name="USAGE"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>CDL Syntax
Overview</b> <br>
Below is an example of CDL syntax, describing a netCDF file
with several named dimensions (lat, lon, and time),
variables (Z, t, p, rh, lat, lon, time), variable attributes
(units, long_name, valid_range, _FillValue), and some data.
CDL keywords are in boldface. (This example is intended to
illustrate the syntax; a real CDL file would have a more
complete set of attributes so that the data would be more
completely self-describing.)</p>
<p style="margin-left:22%;">netcdf foo { // an example
netCDF specification in CDL</p>
<p style="margin-left:22%; margin-top: 1em"><b>types</b>:
<i><br>
ubyte enum</i> enum_t {Clear = 0, Cumulonimbus = 1, Stratus
= 2}; <i><br>
opaque</i>(11) opaque_t; <i><br>
int</i>(*) vlen_t;</p>
<p style="margin-left:22%; margin-top: 1em"><b>dimensions</b>:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>lat = 10, lon = 5, time = <i>unlimited</i> ;</p></td></tr>
</table>
<p style="margin-left:22%; margin-top: 1em"><b>variables</b>:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>long</i> lat(lat), lon(lon), time(time);</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>float</i> Z(time,lat,lon), t(time,lat,lon);</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>double</i> p(time,lat,lon);</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>long</i> rh(time,lat,lon);</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>string</i> country(time,lat,lon);</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>ubyte</i> tag;</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>// variable attributes</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>lat:long_name = "latitude";</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>lat:units = "degrees_north";</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>lon:long_name = "longitude";</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>lon:units = "degrees_east";</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>time:units = "seconds since 1992-1-1
00:00:00";</p> </td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>// typed variable attributes</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>string</i> Z:units = "geopotential
meters";</p> </td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>float</i> Z:valid_range = 0., 5000.;</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>double</i> p:_FillValue = -9999.;</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>long</i> rh:_FillValue = -1;</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p><i>vlen_t</i> :globalatt = {17, 18, 19};</p></td></tr>
</table>
<p style="margin-left:22%;"><b>data</b>:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>lat = 0, 10, 20, 30, 40, 50, 60, 70, 80, 90;</p></td></tr>
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>lon = -140, -118, -96, -84, -52;</p></td></tr>
</table>
<p style="margin-left:22%;"><b>group</b>: g { <b><br>
types</b>: <i><br>
compound</i> cmpd_t { <i>vlen_t</i> f1; <i>enum_t</i> f2;};
<br>
} // group g <b><br>
group</b>: h { <b><br>
variables</b>:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="92%">
<p>/g/<i>cmpd_t</i> compoundvar;</p></td></tr>
</table>
<p style="margin-left:22%;"><b>data</b>: <br>
compoundvar = { {3,4,5}, Stratus } ; <br>
} // group h <br>
}</p>
<p style="margin-left:11%; margin-top: 1em">All CDL
statements are terminated by a semicolon. Spaces, tabs, and
newlines can be used freely for readability. Comments may
follow the characters ‘//’ on any line.</p>
<p style="margin-left:11%; margin-top: 1em">A CDL
description consists of five optional parts: <i>types</i>,
<i>dimensions</i>, <i>variables</i>, <i>data</i>, beginning
with the keyword <b>‘types:’</b>,
<b>‘dimensions:’</b>,
<b>‘variables:’</b>, and
<b>‘data:’,</b> respectively. Note several
things: (1) the keyword includes the trailing colon, so
there must not be any space before the colon character, and
(2) the keywords are required to be lower case.</p>
<p style="margin-left:11%; margin-top: 1em">The
<b>variables:</b> section may contain <i>variable
declarations</i> and <i>attribute assignments</i>. All
sections may contain global attribute assignments.</p>
<p style="margin-left:11%; margin-top: 1em">In addition,
after the <b>data:</b> section, the user may define a series
of groups (see the example above). Groups themselves can
contain types, dimensions, variables, data, and other
(nested) groups.</p>
<p style="margin-left:11%; margin-top: 1em">The netCDF
<b>types:</b> section declares the user defined types. These
may be constructed using any of the following types:
<b>enum</b>, <b>vlen</b>, <b>opaque</b>, or
<b>compound</b>.</p>
<p style="margin-left:11%; margin-top: 1em">A netCDF
<i>dimension</i> is used to define the shape of one or more
of the multidimensional variables contained in the netCDF
file. A netCDF dimension has a name and a size. A dimension
can have the <b>unlimited</b> size, which means a variable
using this dimension can grow to any length in that
dimension.</p>
<p style="margin-left:11%; margin-top: 1em">A
<i>variable</i> represents a multidimensional array of
values of the same type. A variable has a name, a data type,
and a shape described by its list of dimensions. Each
variable may also have associated <i>attributes</i> (see
below) as well as data values. The name, data type, and
shape of a variable are specified by its declaration in the
<i>variable</i> section of a CDL description. A variable may
have the same name as a dimension; by convention such a
variable is one-dimensional and contains coordinates of the
dimension it names. Dimensions need not have corresponding
variables.</p>
<p style="margin-left:11%; margin-top: 1em">A netCDF
<i>attribute</i> contains information about a netCDF
variable or about the whole netCDF dataset. Attributes are
used to specify such properties as units, special values,
maximum and minimum valid values, scaling factors, offsets,
and parameters. Attribute information is represented by
single values or arrays of values. For example,
"units" is an attribute represented by a character
array such as "celsius". An attribute has an
associated variable, a name, a data type, a length, and a
value. In contrast to variables that are intended for data,
attributes are intended for metadata (data about data).
Unlike netCDF-3, attribute types can be any user defined
type as well as the usual built-in types.</p>
<p style="margin-left:11%; margin-top: 1em">In CDL, an
attribute is designated by a a type, a variable, a
’:’, and then an attribute name. The type is
optional and if missing, it will be inferred from the values
assigned to the attribute. It is possible to assign
<i>global</i> attributes not associated with any variable to
the netCDF as a whole by omitting the variable name in the
attribute declaration. Notice that there is a potential
ambiguity in a specification such as <br>
x : a = ... <br>
In this situation, x could be either a type for a global
attribute, or the variable name for an attribute. Since
there could both be a type named x and a variable named x,
there is an ambiguity. The rule is that in this situation, x
will be interpreted as a type if possible, and otherwise as
a variable.</p>
<p style="margin-left:11%; margin-top: 1em">If not
specified, the data type of an attribute in CDL is derived
from the type of the value(s) assigned to it. The length of
an attribute is the number of data values assigned to it, or
the number of characters in the character string assigned to
it. Multiple values are assigned to non-character attributes
by separating the values with commas. All values assigned to
an attribute must be of the same type.</p>
<p style="margin-left:11%; margin-top: 1em">The names for
CDL dimensions, variables, attributes, types, and groups may
contain any non-control utf-8 character except the forward
slash character (‘/’). However, certain
characters must escaped if they are used in a name, where
the escape character is the backward slash ‘\’.
In particular, if the leading character off the name is a
digit (0-9), then it must be preceded by the escape
character. In addition, the characters ‘
!"#$%&()*,:;<=>?[]^‘´{}|~\’
must be escaped if they occur anywhere in a name.</p>
<p style="margin-left:11%; margin-top: 1em">Note also that
the words ‘variable’, ‘dimension’,
‘data’, ‘group’, and
‘types’ are legal CDL names, but be careful that
there is a space between them and any following colon
character. This is mostly an issue with attribute
declarations. For example, consider this.</p>
<p style="margin-left:22%; margin-top: 1em">netcdf ... {
<br>
variables: <br>
int dimensions; <br>
dimensions: attribute=0 ; // this will cause an error <br>
dimensions : attribute=0 ; // this is ok. <br>
}</p>
<p style="margin-left:11%; margin-top: 1em">The optional
<b>data:</b> section of a CDL specification is where netCDF
variables may be initialized. The syntax of an
initialization is simple: a variable name, an equals sign,
and a comma-delimited list of constants (possibly separated
by spaces, tabs and newlines) terminated with a semicolon.
For multi-dimensional arrays, the last dimension varies
fastest. Thus row-order rather than column order is used for
matrices. If fewer values are supplied than are needed to
fill a variable, it is extended with a type-dependent
‘fill value’, which can be overridden by
supplying a value for a distinguished variable attribute
named ‘_FillValue’. The types of constants need
not match the type declared for a variable; coercions are
done to convert integers to floating point, for example. The
constant ‘_’ can be used to designate the fill
value for a variable.</p>
<p><b>Primitive Data Types</b></p></table>
<p style="margin-left:22%;"><b>char</b> characters</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>byte</b></p></td>
<td width="8%">
<p>8-bit data</p></td>
<td width="66%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>short</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>16-bit signed integers</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>int</b></p></td>
<td width="8%">
<p>32-bit signed integers</p></td>
<td width="66%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>long</b></p></td>
<td width="8%">
<p>(synonymous with <b>int</b>)</p></td>
<td width="66%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>int64</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>64-bit signed integers</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>float</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>IEEE single precision floating point (32 bits)</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>real</b></p></td>
<td width="8%">
<p>(synonymous with <b>float</b>)</p></td>
<td width="66%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>double</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>IEEE double precision floating point (64 bits)</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>ubyte</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>unsigned 8-bit data</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>ushort</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>16-bit unsigned integers</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>uint</b></p></td>
<td width="8%">
<p>32-bit unsigned integers</p></td>
<td width="66%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>uint64</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>64-bit unsigned integers</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p><b>string</b></p></td>
<td width="8%"></td>
<td width="66%">
<p>arbitrary length strings</p></td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em">CDL supports a
superset of the primitive data types of C. The names for the
primitive data types are reserved words in CDL, so the names
of variables, dimensions, and attributes must not be
primitive type names. In declarations, type names may be
specified in either upper or lower case.</p>
<p style="margin-left:11%; margin-top: 1em">Bytes differ
from characters in that they are intended to hold a full
eight bits of data, and the zero byte has no special
significance, as it does for character data. <b>ncgen</b>
converts <b>byte</b> declarations to <b>char</b>
declarations in the output C code and to the nonstandard
<b>BYTE</b> declaration in output Fortran code.</p>
<p style="margin-left:11%; margin-top: 1em">Shorts can hold
values between -32768 and 32767. <b>ncgen</b> converts
<b>short</b> declarations to <b>short</b> declarations in
the output C code and to the nonstandard <b>INTEGER*2</b>
declaration in output Fortran code.</p>
<p style="margin-left:11%; margin-top: 1em">Ints can hold
values between -2147483648 and 2147483647. <b>ncgen</b>
converts <b>int</b> declarations to <b>int</b> declarations
in the output C code and to <b>INTEGER</b> declarations in
output Fortran code. <b>long</b> is accepted as a synonym
for <b>int</b> in CDL declarations, but is deprecated since
there are now platforms with 64-bit representations for C
longs.</p>
<p style="margin-left:11%; margin-top: 1em">Int64 can hold
values between -9223372036854775808 and 9223372036854775807.
<b>ncgen</b> converts <b>int64</b> declarations to
<b>longlong</b> declarations in the output C code.</p>
<p style="margin-left:11%; margin-top: 1em">Floats can hold
values between about -3.4+38 and 3.4+38. Their external
representation is as 32-bit IEEE normalized single-precision
floating point numbers. <b>ncgen</b> converts <b>float</b>
declarations to <b>float</b> declarations in the output C
code and to <b>REAL</b> declarations in output Fortran code.
<b>real</b> is accepted as a synonym for <b>float</b> in CDL
declarations.</p>
<p style="margin-left:11%; margin-top: 1em">Doubles can
hold values between about -1.7+308 and 1.7+308. Their
external representation is as 64-bit IEEE standard
normalized double-precision floating point numbers.
<b>ncgen</b> converts <b>double</b> declarations to
<b>double</b> declarations in the output C code and to
<b>DOUBLE PRECISION</b> declarations in output Fortran
code.</p>
<p style="margin-left:11%; margin-top: 1em">The unsigned
counterparts of the above integer types are mapped to the
corresponding unsigned C types. Their ranges are suitably
modified to start at zero.</p>
<p style="margin-left:11%; margin-top: 1em"><b>CDL
Constants</b> <br>
Constants assigned to attributes or variables may be of any
of the basic netCDF types. The syntax for constants is
similar to C syntax, except that type suffixes must be
appended to shorts and floats to distinguish them from longs
and doubles.</p>
<p style="margin-left:11%; margin-top: 1em">A <i>byte</i>
constant is represented by a single character or multiple
character escape sequence enclosed in single quotes. For
example,</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<p>’a’</p><td width="23%"></td>
<td width="-5%"></td>
<td width="8%"></td>
<td width="8%">
</td>
<td width="8%">
<p>// ASCII ‘a’ <br>
’\0’</p></td>
<td width="58%">
</td></tr>
<tr valign="top" align="left">
<td width="23%"></td>
<td width="-5%"></td>
<td width="8%"></td>
<td width="8%"></td>
<td width="8%">
</td>
<td width="58%">
<p>// a zero byte <br>
’\n’</p></td></tr>
<tr valign="top" align="left">
<td width="23%"></td>
<td width="-5%"></td>
<td width="8%"></td>
<td width="8%"></td>
<td width="8%">
</td>
<td width="58%">
<p>// ASCII newline character <br>
’\33’</p></td></tr>
<tr valign="top" align="left">
<td width="23%"></td>
<td width="-5%"></td>
<td width="8%"></td>
<td width="8%"></td>
<td width="8%">
</td>
<td width="58%">
<p>// ASCII escape character (33 octal) <br>
’\x2b’</p></td></tr>
<tr valign="top" align="left">
<td width="23%"></td>
<td width="-5%"></td>
<td width="8%"></td>
<td width="8%"></td>
<td width="8%">
<p>// ASCII plus (2b hex) <br>
’\377’</p></td>
<td width="58%">
</td></tr>
<tr valign="top" align="left">
<td width="23%"></td>
<td width="-5%"></td>
<td width="8%"></td>
<td width="8%"></td>
<td width="8%">
<p>// 377 octal = 255 decimal, non-ASCII</p></td>
<td width="58%">
</td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em">Character
constants are enclosed in double quotes. A character array
may be represented as a string enclosed in double quotes.
The usual C string escape conventions are honored. For
example</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>"a"</p></td>
<td width="8%">
</td>
<td width="8%">
<p>// ASCII ‘a’</p></td>
<td width="58%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>"Two\nlines\n"</p></td>
<td width="8%"></td>
<td width="8%"></td>
<td width="58%">
<p>// a 10-character string with two embedded newlines</p></td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>"a bell:\007"</p></td>
<td width="8%"></td>
<td width="8%"></td>
<td width="58%">
<p>// a string containing an ASCII bell</p></td></tr>
</table>
<p style="margin-left:11%;">Note that the netCDF character
array "a" would fit in a one-element variable,
since no terminating NULL character is assumed. However, a
zero byte in a character array is interpreted as the end of
the significant characters by the <b>ncdump</b> program,
following the C convention. Therefore, a NULL byte should
not be embedded in a character string unless at the end: use
the <i>byte</i> data type instead for byte arrays that
contain the zero byte.</p>
<p style="margin-left:11%; margin-top: 1em"><i>short</i>
integer constants are intended for representing 16-bit
signed quantities. The form of a <i>short</i> constant is an
integer constant with an ‘s’ or ‘S’
appended. If a <i>short</i> constant begins with
‘0’, it is interpreted as octal, except that if
it begins with ‘0x’, it is interpreted as a
hexadecimal constant. For example:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>-2s</p></td>
<td width="8%">
<p>// a short -2</p></td>
<td width="66%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>0123s</p></td>
<td width="8%"></td>
<td width="66%">
<p>// octal</p></td></tr>
</table>
<p style="margin-left:22%;">0x7ffs //hexadecimal</p>
<p style="margin-left:11%; margin-top: 1em"><i>int</i>
integer constants are intended for representing 32-bit
signed quantities. The form of an <i>int</i> constant is an
ordinary integer constant, although it is acceptable to
append an optional ‘l’ or ‘L’
(again, deprecated). If an <i>int</i> constant begins with
‘0’, it is interpreted as octal, except that if
it begins with ‘0x’, it is interpreted as a
hexadecimal constant (but see opaque constants below).
Examples of valid <i>int</i> constants include:</p>
<p style="margin-left:22%;">-2 <br>
1234567890L</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>0123</p></td>
<td width="8%">
</td>
<td width="8%">
<p>// octal</p></td>
<td width="58%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>0x7ff</p></td>
<td width="8%"></td>
<td width="8%">
</td>
<td width="58%">
<p>// hexadecimal</p></td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em"><i>int64</i>
integer constants are intended for representing 64-bit
signed quantities. The form of an <i>int64</i> constant is
an integer constant with an ‘ll’ or
‘LL’ appended. If an <i>int64</i> constant
begins with ‘0’, it is interpreted as octal,
except that if it begins with ‘0x’, it is
interpreted as a hexadecimal constant. For example:</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>-2ll</p></td>
<td width="8%">
<p>// an unsigned -2</p></td>
<td width="66%">
</td></tr>
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%"></td>
<td width="8%">
<p>0123LL</p></td>
<td width="8%"></td>
<td width="66%">
<p>// octal</p></td></tr>
</table>
<p style="margin-left:22%;">0x7ffLL //hexadecimal</p>
<p style="margin-left:11%; margin-top: 1em">Floating point
constants of type <i>float</i> are appropriate for
representing floating point data with about seven
significant digits of precision. The form of a <i>float</i>
constant is the same as a C floating point constant with an
‘f’ or ‘F’ appended. For example the
following are all acceptable <i>float</i> constants:</p>
<p style="margin-left:22%;">-2.0f</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="22%"></td>
<td width="-4%">
<p>3.14159265358979f</p></td>
<td width="24%"></td>
<td width="7%"></td>
<td width="51%">
<p>// will be truncated to less precision</p></td></tr>
</table>
<p style="margin-left:22%;">1.f</p>
<p style="margin-left:11%; margin-top: 1em">Floating point
constants of type <i>double</i> are appropriate for
representing floating point data with about sixteen
significant digits of precision. The form of a <i>double</i>
constant is the same as a C floating point constant. An
optional ‘d’ or ‘D’ may be appended.
For example the following are all acceptable <i>double</i>
constants:</p>
<p style="margin-left:22%;">-2.0 <br>
3.141592653589793 <br>
1.0e-20 <br>
1.d</p>
<p style="margin-left:11%; margin-top: 1em">Unsigned
integer constants can be created by appending the character
’U’ or ’u’ between the constant and
any trailing size specifier. Thus one could say 10U, 100us,
100000ul, or 1000000ull, for example.</p>
<p style="margin-left:11%; margin-top: 1em"><i>String</i>
constants are, like character constants, represented using
double quotes. This represents a potential ambiguity since a
multi-character string may also indicate a dimensioned
character value. Disambiguation usually occurs by context,
but care should be taken to specify the<i>string</i> type to
ensure the proper choice.</p>
<p style="margin-left:11%; margin-top: 1em"><i>Opaque</i>
constants are represented as sequences of hexadecimal digits
preceded by 0X or 0x: 0xaa34ffff, for example. These
constants can still be used as integer constants and will be
either truncated or extended as necessary.</p>
<p style="margin-left:11%; margin-top: 1em"><b>Compound
Constant Expressions</b> <br>
In order to assign values to variables (or attributes) whose
type is user-defined type, the constant notation has been
extended to include sequences of constants enclosed in curly
brackets (e.g. "{"..."}"). Such a
constant is called a compound constant, and compound
constants can be nested.</p>
<p style="margin-left:11%; margin-top: 1em">Given a type
"T(*) vlen_t", where T is some other arbitrary
base type, constants for this should be specified as
follows. <br>
vlen_t var[2] = {t11,t12,...t1N}, {t21,t22,...t2m}; <br>
The values tij, are assumed to be constants of type T.</p>
<p style="margin-left:11%; margin-top: 1em">Given a type
"compound cmpd_t {T1 f1; T2 f2...Tn fn}", where
the Ti are other arbitrary base types, constants for this
should be specified as follows. <br>
cmpd_t var[2] = {t11,t12,...t1N}, {t21,t22,...t2n}; <br>
The values tij, are assumed to be constants of type Ti. If
the fields are missing, then they will be set using any
specified or default fill value for the field’s base
type.</p>
<p style="margin-left:11%; margin-top: 1em">The general set
of rules for using braces are defined in the <b>Specifying
Datalists</b> section below.</p>
<p style="margin-left:11%; margin-top: 1em"><b>Scoping
Rules</b> <br>
With the addition of groups, the name space for defined
objects is no longer flat. References (names) of any type,
dimension, or variable may be prefixed with the absolute
path specifying a specific declaration. Thus one might say
<br>
variables: <br>
/g1/g2/t1 v1; <br>
The type being referenced (t1) is the one within group g2,
which in turn is nested in group g1. The similarity of this
notation to Unix file paths is deliberate, and one can
consider groups as a form of directory structure.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="89%">
<p style="margin-top: 1em">1. When name is not prefixed,
then scope rules are applied to locate the specified
declaration. Currently, there are three rules: one for
dimensions, one for types and enumeration constants, and one
for all others.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="89%">
<p style="margin-top: 1em">2. When an unprefixed name of a
dimension is used (as in a variable declaration), ncgen
first looks in the immediately enclosing group for the
dimension. If it is not found there, then it looks in the
group enclosing this group. This continues up the group
hierarchy until the dimension is found, or there are no more
groups to search.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="89%">
<p style="margin-top: 1em">3. For all other names, only the
immediately enclosing group is searched.</p></td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em">When an
unprefixed name of a type or an enumeration constant is
used, ncgen searches the group tree using a pre-order
depth-first search. This essentially means that it will find
the matching declaration that precedes the reference
textually in the cdl file and that is "highest" in
the group hierarchy.</p>
<p style="margin-left:11%; margin-top: 1em">One final note.
Forward references are not allowed. This means that
specifying, for example, /g1/g2/t1 will fail if this
reference occurs before g1 and/or g2 are defined.</p>
<p><b>Special Attributes</b></p></table>
<p style="margin-left:11%;">Special, virtual, attributes
can be specified to provide performance-related information
about the file format and about variable properties. The
file must be a netCDF-4 file for these to take effect.</p>
<p style="margin-left:11%; margin-top: 1em">These special
virtual attributes are not actually part of the file, they
are merely a convenient way to set miscellaneous properties
of the data in CDL</p>
<p style="margin-left:11%; margin-top: 1em">The special
attributes currently supported are as follows:
‘_Format’, ‘_Fletcher32,
‘_ChunkSizes’, ‘_Endianness’,
‘_DeflateLevel’, ‘_Shuffle’, and
‘_Storage’.</p>
<p style="margin-left:11%; margin-top: 1em">‘_Format’
is a global attribute specifying the netCDF format variant.
Its value must be a single string matching one of
‘classic’, ‘64-bit offset’,
‘netCDF-4’, or ‘netCDF-4 classic
model’.</p>
<p style="margin-left:11%; margin-top: 1em">The rest of the
special attributes are all variable attributes. Essentially
all of then map to some corresponding
‘nc_def_var_XXX’ function as defined in the
netCDF-4 API. For the atttributes that are essentially
boolean (_Fletcher32, _Shuffle, and _NOFILL), the value true
can be specified by using the strings ‘true’ or
‘1’, or by using the integer 1. The value false
expects either ‘false’, ‘0’, or the
integer 0. The actions associated with these attributes are
as follows.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>1.</p></td>
<td width="1%"></td>
<td width="85%">
<p>‘_Fletcher32 sets the ‘fletcher32’
property for a variable.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>2.</p></td>
<td width="1%"></td>
<td width="85%">
<p>‘_Endianness’ is either ‘little’
or ‘big’, depending on how the variable is
stored when first written.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>3.</p></td>
<td width="1%"></td>
<td width="85%">
<p>‘_DeflateLevel’ is an integer between 0 and
9 inclusive if compression has been specified for the
variable.</p> </td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>4.</p></td>
<td width="1%"></td>
<td width="85%">
<p>‘_Shuffle’ specifies if the the shuffle
filter should be used.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>5.</p></td>
<td width="1%"></td>
<td width="85%">
<p>‘_Storage’ is ‘contiguous’ or
‘chunked’.</p> </td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>6.</p></td>
<td width="1%"></td>
<td width="85%">
<p>‘_ChunkSizes’ is a list of chunk sizes for
each dimension of the variable</p></td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em"><b>Specifying
Datalists</b> <br>
Specifying datalists for variables in the
‘data:‘ section can be somewhat complicated.
There are some rules that must be followed to ensure that
datalists are parsed correctly by ncgen.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p style="margin-top: 1em">1.</p></td>
<td width="1%"></td>
<td width="85%">
<p style="margin-top: 1em">The top level is automatically
assumed to be a list of items, so it should not be inside
{...}.</p> </td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>2.</p></td>
<td width="1%"></td>
<td width="85%">
<p>Instances of UNLIMITED dimensions (other than the first
dimension) must be surrounded by {...} in order to specify
the size.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>3.</p></td>
<td width="1%"></td>
<td width="85%">
<p>Instances of vlens must be surrounded by {...} in order
to specify the size.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>4.</p></td>
<td width="1%"></td>
<td width="85%">
<p>Compound instances must be embedded in {...}</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>5.</p></td>
<td width="1%"></td>
<td width="85%">
<p>Non-scalar fields of compound instances must be embedded
in {...}.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>6.</p></td>
<td width="1%"></td>
<td width="85%">
<p>Datalists associated with attributes are implicitly a
vector (i.e., a list) of values of the type of the attribute
and the above rules must apply with that in mind.</p></td></tr>
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p>7.</p></td>
<td width="1%"></td>
<td width="85%">
<p>No other use of braces is allowed.</p></td></tr>
</table>
<p style="margin-left:11%; margin-top: 1em">Note that one
consequence of these rules is that arrays of values cannot
have subarrays within braces. Consider, for example, int
var(d1)(d2)...(dn), where none of d2...dn are unlimited. A
datalist for this variable must be a single list of
integers, where the number of integers is no more than
D=d1*d2*...dn values; note that the list can be less than D,
in which case fill values will be used to pad the list.</p>
<p style="margin-left:11%; margin-top: 1em">Rule 6 about
attribute datalist has the following consequence. If the
type of the attribute is a compound (or vlen) type, and if
the number of entries in the list is one, then the compound
instances must be enclosed in braces.</p>
<p style="margin-left:11%; margin-top: 1em"><b>Specifying
Character Datalists</b> <br>
Specifying datalists for variables of type char also has
some complications. consider, for example</p>
<p style="margin-left:22%;">dimensions: u=UNLIMITED; d1=1;
d2=2; d3=3; <br>
d4=4; d5=5; u2=UNLIMITED; <br>
variables: char var(d3,d4); <br>
datalist: var="1", "two",
"three";</p>
<p style="margin-left:11%; margin-top: 1em">We have twenty
elements of var to fill (d5 X d4) and we have three strings
of length 1, 3, 5. How do we assign the characters in the
strings to the twenty elements?</p>
<p style="margin-left:11%; margin-top: 1em">The basic rule
is "greedy" plus "right dimension
rules". By this we mean the following.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p style="margin-top: 1em">1.</p></td>
<td width="1%"></td>
<td width="85%">
<p style="margin-top: 1em">Use the size of the rightmost
dimension (d4=4) and modify the constant list so that every
string is less than or equal to this dimension size. Longer
strings are decomposed. For our example, we get this.</p></td></tr>
</table>
<p style="margin-left:23%;">datalist: var= "1",
"two", "thre", "e";</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p style="margin-top: 1em">2.</p></td>
<td width="1%"></td>
<td width="85%">
<p style="margin-top: 1em">Pad any short strings to the
length of the right dimension. This produces the
following.</p> </td></tr>
</table>
<p style="margin-left:23%;">datalist: var=
"1\0\0\0", "two\0", "thre",
"e\0\0\0";</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p style="margin-top: 1em">3.</p></td>
<td width="1%"></td>
<td width="85%">
<p style="margin-top: 1em">Move the the next to the
rightmost dimension (d5 in this case) and add fill values as
needed, producing this.</p></td></tr>
</table>
<p style="margin-left:23%;">datalist: var=
"1\0\0\0", "two\0", "thre",
"e\0\0\0", "\0\0\0\0";</p>
<p style="margin-left:15%; margin-top: 1em">4. Repeat step
3 for successively more left dimensions until the first
dimension is reached. If the first dimension is UNLIMITED,
and has not had any previous value assigned to it, then do
not pad, but instead use the length at that point as the
unlimited length. In all other cases, pad to the specified
length.</p>
<p style="margin-left:11%; margin-top: 1em">Note that the
term "greedy" is used because the above algorithm
causes the strings to be assigned to the "front"
of the variable and fill values to the end.</p>
<p style="margin-left:11%; margin-top: 1em">There are
several additional edge cases that must be dealt with.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p style="margin-top: 1em">1.</p></td>
<td width="1%"></td>
<td width="85%">
<p style="margin-top: 1em">Suppose we have only an
unlimited dimension such as this case.</p></td></tr>
</table>
<p style="margin-left:23%;">variables: char var(u); <br>
datalist: var="1", "two",
"three";</p>
<p style="margin-left:15%;">In this case, we treat it like
it was defined as this.</p>
<p style="margin-left:23%;">variables: char var(u,d1); <br>
datalist:
var="1","t","w","o","t","h","r","e","e";</p>
<p style="margin-left:15%;">This means that u will have the
length of nine.</p>
<table width="100%" border="0" rules="none" frame="void"
cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="11%"></td>
<td width="3%">
<p style="margin-top: 1em">2.</p></td>
<td width="1%"></td>
<td width="85%">
<p style="margin-top: 1em">In netcdf-4, dimensions other
than the first can be unlimited. Of course by the rules
above, the interior unlimited instances must be delimited by
{...}. For example.</p></td></tr>
</table>
<p style="margin-left:23%;">variables: char var(u,u2); <br>
datalist: var={"1", "two"},
{"three"};</p>
<p style="margin-left:15%; margin-top: 1em">In this case u
will have the effective length of two. Within each instance
of u2, the rules above will apply, leading to this.</p>
<p style="margin-left:23%;">datalist:
var={"1","t","w","o"},
{"t","h","r","e","e"};</p>
<p style="margin-left:15%; margin-top: 1em">The effective
size of u2 will be the max of the two instance lengths (five
in this case) and the shorter will be padded to produce
this.</p>
<p style="margin-left:23%;">datalist:
var={"1","t","w","o","\0"},
{"t","h","r","e","e"};</p>
<h2>BUGS
<a name="BUGS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">The programs
generated by <b>ncgen</b> when using the <b>-c</b> flag use
initialization statements to store data in variables, and
will fail to produce compilable programs if you try to use
them for large datasets, since the resulting statements may
exceed the line length or number of continuation statements
permitted by the compiler.</p>
<p style="margin-left:11%; margin-top: 1em">The CDL syntax
makes it easy to assign what looks like an array of
variable-length strings to a netCDF variable, but the
strings may simply be concatenated into a single array of
characters. Specific use of the <i>string</i> type specifier
may solve the problem</p>
<hr>
</body>
</html>
|