This file is indexed.

/usr/share/doc/netcdf-doc/netcdf.html is in netcdf-doc 1:4.1.3-7ubuntu2.

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
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
<html lang="en">
<head>
<title>The NetCDF Users' Guide</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="The NetCDF Users' Guide">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="top" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 2005-2009 University Corporation for
Atmospheric Research


   Permission is granted to make and distribute verbatim copies of this
manual provided that the copyright notice and these paragraphs are
preserved on all copies.  The software and any accompanying written
materials are provided ``as is'' without warranty of any kind.  UCAR
expressly disclaims all warranties of any kind, either expressed or
implied, including but not limited to the implied warranties of
merchantability and fitness for a particular purpose.

The Unidata Program Center is managed by the University
Corporation for Atmospheric Research and sponsored by the National
Science Foundation.  Any opinions, findings, conclusions, or
recommendations expressed in this publication are those of the
author(s) and do not necessarily reflect the views of the National
Science Foundation.

Mention of any commercial company or product in this document
does not constitute an endorsement by the Unidata Program Center.
Unidata does not authorize any use of information from this
publication for advertising or publicity purposes.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<h1 class="settitle">The NetCDF Users' Guide</h1>
<div class="node">
<a name="Top"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Foreword">Foreword</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>

</div>

<h2 class="unnumbered">NetCDF Users Guide</h2>

<p><a name="index-C_002b_002b-API-1"></a><a name="index-Fortran-77-API-2"></a><a name="index-Fortran-90-API-3"></a><a name="index-C-API-4"></a><a name="index-API_002c-C_002b_002b-5"></a><a name="index-API_002c-Fortran-77-6"></a><a name="index-API_002c-Fortran-90-7"></a><a name="index-API_002c-C-8"></a><a name="index-Interface-Guide_002c-C-9"></a><a name="index-Interface-Guide_002c-C_002b_002b-10"></a><a name="index-Interface-Guide_002c-Fortran-77-11"></a><a name="index-Interface-Guide_002c-Fortran-90-12"></a>
This guide describes the netCDF object model. This document applies to
netCDF version 4.1.3, and was last updated on
30 June 2011.

   <p>Interface guides are available for C (see <a href="netcdf-c.html#Top">The NetCDF C Interface Guide</a>), C++ (see <a href="netcdf-cxx.html#Top">The NetCDF C++ Interface Guide</a>), Fortran 77 (see <a href="netcdf-f77.html#Top">The NetCDF Fortran 77 Interface Guide</a>), and Fortran 90
(see <a href="netcdf-f90.html#Top">The NetCDF Fortran 90 Interface Guide</a>).

   <p>Separate documentation for the netCDF Java library can be found at the
netCDF-Java website, <a href="http://www.unidata.ucar.edu/software/netcdf-java">http://www.unidata.ucar.edu/software/netcdf-java</a>.

   <p>For installation and porting information, see <a href="netcdf-install.html#Top">The NetCDF Installation and Porting Guide</a>.

<ul class="menu">
<li><a accesskey="1" href="#Foreword">Foreword</a>:                     Foreword from 1996 Manual
<li><a accesskey="2" href="#Summary">Summary</a>:                      Orientation
<li><a accesskey="3" href="#Introduction">Introduction</a>:                 What is NetCDF? 
<li><a accesskey="4" href="#Dataset-Components">Dataset Components</a>:           What's in a NetCDF File? 
<li><a accesskey="5" href="#Data">Data</a>:                         How to Store Data
<li><a accesskey="6" href="#Structure">Structure</a>:                    Behind the Scenes
<li><a accesskey="7" href="#NetCDF-Utilities">NetCDF Utilities</a>:             Ncdump, ncgen, and nccopy
<li><a accesskey="8" href="#Units">Units</a>:                        Using UDUNITS
<li><a accesskey="9" href="#Attribute-Conventions">Attribute Conventions</a>:        Creating Human-Readable Files
<li><a href="#File-Format">File Format</a>:                  Description of NetCDF Binary Formats
<li><a href="#Internal-Dispatch-Table">Internal Dispatch Table</a>:      Description of experimental dispatch mechanism
<li><a href="#Combined-Index">Combined Index</a>:               Index of Concepts and Functions

</li></ul>
<p>--- The Detailed Node Listing ---

<p>Introduction

</p>
<ul class="menu">
<li><a href="#Interface">Interface</a>:                    The NetCDF Interface
<li><a href="#Not-DBMS">Not DBMS</a>:                     NetCDF is not a Database
<li><a href="#Format">Format</a>:                       The NetCDF File Format
<li><a href="#Which-Format">Which Format</a>:                 Selecting the Underlying NetCDF Format
<li><a href="#Performance">Performance</a>:                  What about Performance? 
<li><a href="#Archival">Archival</a>:                     Is NetCDF a Good Archive Format? 
<li><a href="#Conventions">Conventions</a>:                  Creating Self-Describing Data Conforming to Conventions
<li><a href="#Background">Background</a>:                   The Evolution of the NetCDF Interface
<li><a href="#Whats-New">Whats New</a>:                    Latest Developments in NetCDF
<li><a href="#Limitations">Limitations</a>:                  Limitations of NetCDF
<li><a href="#Future">Future </a>:                      Plans for Future Development
<li><a href="#References">References</a>:                   Papers Relating to Scientific Data

</li></ul>
<p>Components of a NetCDF Dataset

</p>
<ul class="menu">
<li><a href="#Data-Model">Data Model</a>:                   How NetCDF Sees Data
<li><a href="#Dimensions">Dimensions</a>:                   Specifying Data Shape
<li><a href="#Variables">Variables</a>:                    Storing Data
<li><a href="#Attributes">Attributes</a>:                   Storing Metadata
<li><a href="#Attributes-and-Variables">Attributes and Variables</a>:     Attributes vs. Variables

</li></ul>
<p>Data

</p>
<ul class="menu">
<li><a href="#External-Types">External Types</a>:               Integers, Floats, and so on
<li><a href="#Classic-Data-Structures">Classic Data Structures</a>:      Complex Data in Classic Format
<li><a href="#User-Defined-Types">User Defined Types</a>:           Complex Data in NetCDF-4/HDF5 Format
<li><a href="#Data-Access">Data Access</a>:                  Reading and Writing Data
<li><a href="#Type-Conversion">Type Conversion</a>:              Changing Type of Numeric Data

</li></ul>
<p>Forms of Data Access

</p>
<ul class="menu">
<li><a href="#C-Section-Access">C Section Access</a>:             A C Example
<li><a href="#Fortran-Section-Access">Fortran Section Access</a>:       A Fortran Example

</li></ul>
<p>File Structure and Performance

</p>
<ul class="menu">
<li><a href="#Classic-File-Parts">Classic File Parts</a>:           The Classic and 64-bit Offset File
<li><a href="#NetCDF_002d4-File-Parts">NetCDF-4 File Parts</a>:          The NetCDF-4/HDF5 File
<li><a href="#XDR-Layer">XDR Layer</a>:                    Classic Machine Interoperability
<li><a href="#Large-File-Support">Large File Support</a>:           Files that Exceed 2 GiBytes
<li><a href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a>:    Limitations on File and Data Size
<li><a href="#Classic-Limitations">Classic Limitations</a>:          Limitations on File and Data Size
<li><a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a>:        Classic I/O Described
<li><a href="#UNICOS-Optimization">UNICOS Optimization</a>:          Some Cray Optimizations
<li><a href="#Chunking">Chunking</a>:                     NetCDF-4/HDF5 Files Read/Write Chunks
<li><a href="#Parallel-Access">Parallel Access</a>:              Parallel I/O with NetCDF-4
<li><a href="#Interoperability-with-HDF5">Interoperability with HDF5</a>:   Using HDF5 with NetCDF-4
<li><a href="#DAP-Support">DAP Support</a>

</li></ul>
<p>Improving Performance With Chunking

</p>
<ul class="menu">
<li><a href="#Chunk-Cache">Chunk Cache</a>
<li><a href="#Default-Chunking">Default Chunking</a>
<li><a href="#Default-Chunking-4_005f0_005f1">Default Chunking 4_0_1</a>
<li><a href="#Parallel-Chunking">Parallel Chunking</a>
<li><a href="#bm_005ffile">bm_file</a>

</li></ul>
<p>NetCDF Utilities

</p>
<ul class="menu">
<li><a href="#CDL-Syntax">CDL Syntax</a>:                   Creating a File without Code
<li><a href="#CDL-Data-Types">CDL Data Types</a>:               Describing Types in CDL
<li><a href="#CDL-Constants">CDL Constants</a>:                Constant Values in CDL
<li><a href="#ncgen">ncgen</a>:                        Turning CDL into Classic or Enhanced Data Files
<li><a href="#ncdump">ncdump</a>:                       Turning Data Files into CDL (or XML)
<li><a href="#nccopy">nccopy</a>:                       Copying, Converting, Compressing, and Chunking Data Files
<li><a href="#ncgen3">ncgen3</a>:                       Turning CDL into Classic Data Files

</li></ul>
<p>File Format Specification

</p>
<ul class="menu">
<li><a href="#NetCDF-Classic-Format">NetCDF Classic Format</a>:        The Original Binary Format
<li><a href="#g_t64_002dbit-Offset-Format">64-bit Offset Format</a>:         Supporting Larger Variables
<li><a href="#NetCDF_002d4-Format">NetCDF-4 Format</a>:              Uses HDF5
<li><a href="#NetCDF_002d4-Classic-Model-Format">NetCDF-4 Classic Model Format</a>:   HDF5 with NetCDF Limitations
<li><a href="#HDF4-SD-Format">HDF4 SD Format</a>

</li></ul>
<p>The NetCDF Classic Format Specification

</p>
<ul class="menu">
<li><a href="#Classic-Format-Spec">Classic Format Spec</a>:          Detailed Format Information
<li><a href="#Computing-Offsets">Computing Offsets</a>:            How to Get the Data You Want
<li><a href="#Examples">Examples</a>:                     The Binary Layout of some Simple Files

   </ul>

<div class="node">
<a name="Foreword"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Summary">Summary</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Top">Top</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Foreword</h2>

<p>Unidata (<a href="http://www.unidata.ucar.edu">http://www.unidata.ucar.edu</a>) is a National Science
Foundation-sponsored program empowering U.S. universities, through
innovative applications of computers and networks, to make the best
use of atmospheric and related data for enhancing education and
research. For analyzing and displaying such data, the Unidata Program
Center offers universities several supported software packages
developed by other organizations. Underlying these is a
Unidata-developed system for acquiring and managing data in real time,
making practical the Unidata principle that each university should
acquire and manage its own data holdings as local requirements
dictate. It is significant that the Unidata program has no data
center&ndash;the management of data is a "distributed" function.

   <p>The Network Common Data Form (netCDF) software described in this guide
was originally intended to provide a common data access method for the
various Unidata applications. These deal with a variety of data types
that encompass single-point observations, time series,
regularly-spaced grids, and satellite or radar images.

   <p>The netCDF software functions as an I/O library, callable from C,
FORTRAN, C++, Perl, or other language for which a netCDF library is
available. The library stores and retrieves data in self-describing,
machine-independent datasets. Each netCDF dataset can contain
multidimensional, named variables (with differing types that include
integers, reals, characters, bytes, etc.), and each variable may be
accompanied by ancillary data, such as units of measure or descriptive
text. The interface includes a method for appending data to existing
netCDF datasets in prescribed ways, functionality that is not unlike a
(fixed length) record structure. However, the netCDF library also
allows direct-access storage and retrieval of data by variable name
and index and therefore is useful only for disk-resident (or
memory-resident) datasets.

   <p>NetCDF access has been implemented in about half of Unidata's
software, so far, and it is planned that such commonality will extend
across all Unidata applications in order to:

     <ul>
<li>Facilitate the use of common datasets by distinct applications.

     <li>Permit datasets to be transported between or shared by dissimilar
computers transparently, i.e., without translation.

     <li>Reduce the programming effort usually spent interpreting formats.

     <li>Reduce errors arising from misinterpreting data and ancillary data.

     <li>Facilitate using output from one application as input to another.

     <li>Establish an interface standard which simplifies the inclusion of new
software into the Unidata system.

   </ul>

   <p>A measure of success has been achieved. NetCDF is now in use on
computing platforms that range from personal computers to
supercomputers and include most UNIX-based workstations. It can be
used to create a complex dataset on one computer (say in FORTRAN) and
retrieve that same self-describing dataset on another computer (say in
C) without intermediate translations&ndash;netCDF datasets can be
transferred across a network, or they can be accessed remotely using a
suitable network file system or remote access protocols.

   <p>Because we believe that the use of netCDF access in non-Unidata
software will benefit Unidata's primary constituency&ndash;such use may
result in more options for analyzing and displaying Unidata
information&ndash;the netCDF library is distributed without licensing or
other significant restrictions, and current versions can be obtained
via anonymous FTP. Apparently the software has been well received by a
wide range of institutions beyond the atmospheric science community,
and a substantial number of public domain and commercial data analysis
systems can now accept netCDF datasets as input.

   <p>Several organizations have adopted netCDF as a data access standard,
and there is an effort underway at the National Center for
Supercomputer Applications (NCSA, which is associated with the
University of Illinois at Urbana-Champaign) to support the netCDF
programming interfaces as a means to store and retrieve data in "HDF
files," i.e., in the format used by the popular NCSA tools. We have
encouraged and cooperated with these efforts.

   <p>Questions occasionally arise about the level of support provided for
the netCDF software. Unidata's formal position, stated in the
copyright notice which accompanies the netCDF library, is that the
software is provided "as is". In practice, the software is updated
from time to time, and Unidata intends to continue making improvements
for the foreseeable future. Because Unidata's mission is to serve
geoscientists at U.S. universities, problems reported by that
community necessarily receive the greatest attention.

   <p>We hope the reader will find the software useful and will give us
feedback on its application as well as suggestions for its
improvement.

   <p>David Fulker, 1996

   <p>Unidata Program Center Director,
University Corporation for Atmospheric Research

<div class="node">
<a name="Summary"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Introduction">Introduction</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Foreword">Foreword</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Summary</h2>

<p><a name="index-supported-programming-languages-13"></a><a name="index-API_002c-C-14"></a><a name="index-API_002c-Fortran-15"></a><a name="index-API_002c-F90-16"></a><a name="index-API_002c-C_002b_002b-17"></a><a name="index-API_002c-Java-18"></a><a name="index-C-API-19"></a><a name="index-Fortran-API-20"></a><a name="index-F90-API-21"></a><a name="index-C_002b_002b-API-22"></a><a name="index-Java-API-23"></a>
The purpose of the Network Common Data Form (netCDF) interface is to
allow you to create, access, and share array-oriented data in a form
that is self-describing and portable. "Self-describing" means that a
dataset includes information defining the data it contains. "Portable"
means that the data in a dataset is represented in a form that can be
accessed by computers with different ways of storing integers,
characters, and floating-point numbers. Using the netCDF interface for
creating new datasets makes the data portable. Using the netCDF
interface in software for data access, management, analysis, and
display can make the software more generally useful.

   <p>The netCDF software includes C, Fortran 77, Fortran 90, and C++
interfaces for accessing netCDF data. These libraries are available
for many common computing platforms.

   <p>The community of netCDF users has contributed ports of the software to
additional platforms and interfaces for other programming languages as
well. Source code for netCDF software libraries is freely available to
encourage the sharing of both array-oriented data and the software
that makes the data useful.

   <p>This User's Guide presents the netCDF data model. It explains how the
netCDF data model uses dimensions, variables, and attributes to store
data. Language specific programming guides are available for C
(see <a href="netcdf-c.html#Top">The NetCDF C Interface Guide</a>), C++
(see <a href="netcdf-cxx.html#Top">The NetCDF C++ Interface Guide</a>), Fortran
77 (see <a href="netcdf-f77.html#Top">The NetCDF Fortran 77 Interface Guide</a>), and
Fortran 90 (see <a href="netcdf-f90.html#Top">The NetCDF Fortran 90 Interface Guide</a>).

   <p>Reference documentation for UNIX systems, in the form of UNIX 'man'
pages for the C and FORTRAN interfaces is also available at the netCDF
web site (<a href="http://www.unidata.ucar.edu/netcdf">http://www.unidata.ucar.edu/netcdf</a>), and with the netCDF
distribution.

   <p>The latest version of this document, and the language specific guides,
can be found at the netCDF web site, <a href="http://www.unidata.ucar.edu/netcdf/docs">http://www.unidata.ucar.edu/netcdf/docs</a>, along
with extensive additional information about netCDF, including pointers
to other software that works with netCDF data.

   <p>Separate documentation of the Java netCDF library can be found at
<a href="http://www.unidata.ucar.edu/software/netcdf-java">http://www.unidata.ucar.edu/software/netcdf-java</a>.

   <p>For installation and porting information See <a href="netcdf-install.html#Top">The NetCDF Installation and Porting Guide</a>.

<div class="node">
<a name="Introduction"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Dataset-Components">Dataset Components</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Summary">Summary</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">1 Introduction</h2>

<ul class="menu">
<li><a accesskey="1" href="#Interface">Interface</a>:                    The NetCDF Interface
<li><a accesskey="2" href="#Not-DBMS">Not DBMS</a>:                     NetCDF is not a Database
<li><a accesskey="3" href="#Format">Format</a>:                       The NetCDF File Format
<li><a accesskey="4" href="#Which-Format">Which Format</a>:                 Selecting the Underlying NetCDF Format
<li><a accesskey="5" href="#Performance">Performance</a>:                  What about Performance? 
<li><a accesskey="6" href="#Archival">Archival</a>:                     Is NetCDF a Good Archive Format? 
<li><a accesskey="7" href="#Conventions">Conventions</a>:                  Creating Self-Describing Data Conforming to Conventions
<li><a accesskey="8" href="#Background">Background</a>:                   The Evolution of the NetCDF Interface
<li><a accesskey="9" href="#Whats-New">Whats New</a>:                    Latest Developments in NetCDF
<li><a href="#Limitations">Limitations</a>:                  Limitations of NetCDF
<li><a href="#Future">Future </a>:                      Plans for Future Development
<li><a href="#References">References</a>:                   Papers Relating to Scientific Data
</ul>

<div class="node">
<a name="Interface"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Not-DBMS">Not DBMS</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.1 The NetCDF Interface</h3>

<p>The Network Common Data Form, or netCDF, is an interface to a library
of data access functions for storing and retrieving data in the form
of arrays. An array is an n-dimensional (where n is 0, 1, 2, <small class="dots">...</small>)
rectangular structure containing items which all have the same data
type (e.g., 8-bit character, 32-bit integer). A <dfn>scalar</dfn> (simple
single value) is a 0-dimensional array.

   <p>NetCDF is an abstraction that supports a view of data as a collection
of self-describing, portable objects that can be accessed through a
simple interface. Array values may be accessed directly, without
knowing details of how the data are stored. Auxiliary information
about the data, such as what units are used, may be stored with the
data. Generic utilities and application programs can access netCDF
datasets and transform, combine, analyze, or display specified fields
of the data. The development of such applications has led to improved
accessibility of data and improved re-usability of software for
array-oriented data management, analysis, and display.

   <p>The netCDF software implements an abstract data type, which means that
all operations to access and manipulate data in a netCDF dataset must
use only the set of functions provided by the interface. The
representation of the data is hidden from applications that use the
interface, so that how the data are stored could be changed without
affecting existing programs. The physical representation of netCDF
data is designed to be independent of the computer on which the data
were written.

   <p>Unidata supports the netCDF interfaces for C, (see <a href="netcdf-c.html#Top">Top</a>), FORTRAN 77 (see <a href="netcdf-f77.html#Top">Top</a>), FORTRAN 90 (see <a href="netcdf-f90.html#Top">Top</a>), and C++ (see <a href="netcdf-cxx.html#Top">Top</a>).

   <p>The netCDF library is supported for various UNIX operating systems. A
MS Windows port is also available. The software is also ported and
tested on a few other operating systems, with assistance from users
with access to these systems, before each major release. Unidata's
netCDF software is freely available via FTP to encourage its
widespread use. (<a href="ftp://ftp.unidata.ucar.edu/pub/netcdf">ftp://ftp.unidata.ucar.edu/pub/netcdf</a>).

   <p>For detailed installation instructions, see the Porting and
Installation Guide. See <a href="netcdf-install.html#Top">Top</a>.

<div class="node">
<a name="Not-DBMS"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Format">Format</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Interface">Interface</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.2 NetCDF Is Not a Database Management System</h3>

<p><a name="index-data-base-24"></a><a name="index-DBMS-25"></a>
Why not use an existing database management system for storing
array-oriented data? Relational database software is not suitable for
the kinds of data access supported by the netCDF interface.

   <p>First, existing database systems that support the relational model do
not support multidimensional objects (arrays) as a basic unit of data
access. Representing arrays as relations makes some useful kinds of
data access awkward and provides little support for the abstractions
of multidimensional data and coordinate systems. A quite different
data model is needed for array-oriented data to facilitate its
retrieval, modification, mathematical manipulation and visualization.

   <p>Related to this is a second problem with general-purpose database
systems: their poor performance on large arrays. Collections of
satellite images, scientific model outputs and long-term global
weather observations are beyond the capabilities of most database
systems to organize and index for efficient retrieval.

   <p>Finally, general-purpose database systems provide, at significant cost
in terms of both resources and access performance, many facilities
that are not needed in the analysis, management, and display of
array-oriented data. For example, elaborate update facilities, audit
trails, report formatting, and mechanisms designed for
transaction-processing are unnecessary for most scientific
applications.

<div class="node">
<a name="Format"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Which-Format">Which Format</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Not-DBMS">Not DBMS</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.3 The netCDF File Format</h3>

<p><a name="index-XDR-format-26"></a>
Until version 3.6.0, all versions of netCDF employed only one binary
data format, now referred to as netCDF classic format. NetCDF classic
is the default format for all versions of netCDF.

   <p>In version 3.6.0 a new binary format was introduced, 64-bit offset
format. Nearly identical to netCDF classic format, it uses 64-bit
offsets (hence the name), and allows users to create far larger
datasets.

   <p>In version 4.0.0 a third binary format was introduced: the HDF5
format. Starting with this version, the netCDF library can use HDF5
files as its base format. (Only HDF5 files created with netCDF-4 can
be understood by netCDF-4).

   <p>By default, netCDF uses the classic format. To use the 64-bit offset
or netCDF-4/HDF5 format, set the appropriate constant when creating
the file.

   <p>To achieve network-transparency (machine-independence), netCDF classic
and 64-bit offset formats are implemented in terms of an external
representation much like XDR (eXternal Data Representation, see
<a href="http://www.ietf.org/rfc/rfc1832.txt">http://www.ietf.org/rfc/rfc1832.txt</a>), a standard for describing
and encoding data. This representation provides encoding of data into
machine-independent sequences of bits. It has been implemented on a
wide variety of computers, by assuming only that eight-bit bytes can
be encoded and decoded in a consistent way. The IEEE 754
floating-point standard is used for floating-point data
representation.

   <p>Descriptions of the overall structure of netCDF classic and 64-bit
offset files are provided later in this manual. See <a href="#Structure">Structure</a>.

   <p>The details of the classic and 64-bit offset formats are described in
an appendix.  See <a href="#File-Format">File Format</a>. However, users are discouraged from
using the format specification to develop independent low-level
software for reading and writing netCDF files, because this could lead
to compatibility problems if the format is ever modified.

<div class="node">
<a name="Which-Format"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Performance">Performance</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Format">Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.4 How to Select the Format</h3>

<p><a name="index-format-selection-advice-27"></a>
With three different base formats, care must be taken in creating data
files to choose the correct base format.

   <p>The format of a netCDF file is determined at create time.

   <p>When opening an existing netCDF file the netCDF library will
transparently detect its format and adjust accordingly. However,
netCDF library versions earlier than 3.6.0 cannot read 64-bit offset
format files, and library versions before 4.0 can't read netCDF-4/HDF5
files. NetCDF classic format files (even if created by version
3.6.0 or later) remain compatible with older versions of the netCDF
library.

   <p>Users are encouraged to use netCDF classic format to distribute data,
for maximum portability.

   <p>To select 64-bit offset or netCDF-4 format files, C programmers should
use flag NC_64BIT_OFFSET or NC_NETCDF4 in function
nc_create. See <a href="netcdf-c.html#nc_005fcreate">nc_create</a>.

   <p>In Fortran, use flag nf_64bit_offset or nf_format_netcdf4 in function
NF_CREATE. See <a href="netcdf-f77.html#NF_005fCREATE">NF_CREATE</a>.

   <p>It is also possible to change the default creation format, to convert
a large body of code without changing every create call. C programmers
see <a href="netcdf-c.html#nc_005fset_005fdefault_005fformat">nc_set_default_format</a>. Fortran
programs see <a href="netcdf-f77.html#NF_005fSET_005fDEFAULT_005fFORMAT">NF_SET_DEFAULT_FORMAT</a>.

<h4 class="subsection">1.4.1 NetCDF Classic Format</h4>

<p>The original netCDF format is identified using four bytes in the file
header. All files in this format have &ldquo;CDF\001&rdquo; at the beginning of the
file. In this documentation this format is referred to as &ldquo;netCDF
classic format.&rdquo;

   <p>NetCDF classic format is identical to the format used by every
previous version of netCDF. It has maximum portability, and is still
the default netCDF format.

   <p>For some users, the various 2 GiB format limitations of the classic
format become a problem. (see <a href="#Classic-Limitations">Classic Limitations</a>).

<h4 class="subsection">1.4.2 NetCDF 64-bit Offset Format</h4>

<p>For these users, 64-bit offset format is a natural choice. It greatly
eases the size restrictions of netCDF classic files (see <a href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a>).

   <p>Files with the 64-bit offsets are identified with a &ldquo;CDF\002&rdquo; at the
beginning of the file. In this documentation this format is called
&ldquo;64-bit offset format.&rdquo;

   <p>Since 64-bit offset format was introduced in version 3.6.0, earlier
versions of the netCDF library can't read 64-bit offset files.

<h4 class="subsection">1.4.3 NetCDF-4 Format</h4>

<p>In version 4.0, netCDF included another new underlying format:
HDF5.

   <p>NetCDF-4 format files offer new features such as groups, compound
types, variable length arrays, new unsigned integer types, parallel
I/O access, etc. None of these new features can be used with classic
or 64-bit offset files.

   <p>NetCDF-4 files can't be created at all, unless the netCDF configure
script is run with &ndash;enable-netcdf-4. This also requires version 1.8.0
of HDF5.

   <p>For the netCDF-4.0 release, netCDF-4 features are only available from
the C and Fortran interfaces. We plan to bring netCDF-4 features to the
CXX API in a future release of netCDF.

   <p>NetCDF-4 files can't be read by any version of the netCDF library
previous to 4.0. (But they can be read by HDF5, version 1.8.0 or
better).

   <p>For more discussion of format issues see <a href="netcdf-tutorial.html#Versions">The NetCDF Tutorial</a>.

<div class="node">
<a name="Performance"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Archival">Archival</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Which-Format">Which Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.5 What about Performance?</h3>

<p><a name="index-performance_002c-introduction-28"></a>
One of the goals of netCDF is to support efficient access to small
subsets of large datasets. To support this goal, netCDF uses direct
access rather than sequential access. This can be much more efficient
when the order in which data is read is different from the order in
which it was written, or when it must be read in different orders for
different applications.

   <p>The amount of overhead for a portable external representation depends
on many factors, including the data type, the type of computer, the
granularity of data access, and how well the implementation has been
tuned to the computer on which it is run. This overhead is typically
small in comparison to the overall resources used by an
application. In any case, the overhead of the external representation
layer is usually a reasonable price to pay for portable data access.

   <p>Although efficiency of data access has been an important concern in
designing and implementing netCDF, it is still possible to use the
netCDF interface to access data in inefficient ways: for example, by
requesting a slice of data that requires a single value from each
record. Advice on how to use the interface efficiently is provided in
<a href="#Structure">Structure</a>.

   <p>The use of HDF5 as a data format adds significant overhead in metadata
operations, less so in data access operations. We continue to study
the challenge of implementing netCDF-4/HDF5 format without
compromising performance.

<div class="node">
<a name="Archival"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Conventions">Conventions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Performance">Performance</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.6 Is NetCDF a Good Archive Format?</h3>

<p><a name="index-archive-format-29"></a><a name="index-compression-30"></a>
NetCDF classic or 64-bit offset formats can be used as a
general-purpose archive format for storing arrays. Compression of data
is possible with netCDF (e.g., using arrays of eight-bit or 16-bit
integers to encode low-resolution floating-point numbers instead of
arrays of 32-bit numbers), or the resulting data file may be
compressed before storage (but must be uncompressed before it is
read). Hence, using these netCDF formats may require more space than
special-purpose archive formats that exploit knowledge of particular
characteristics of specific datasets.

   <p>With netCDF-4/HDF5 format, the zlib library can provide compression on
a per-variable basis. That is, some variables may be compressed,
others not. In this case the compression and decompression of data
happen transparently to the user, and the data may be stored, read,
and written compressed.

<div class="node">
<a name="Conventions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Background">Background</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Archival">Archival</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.7 Creating Self-Describing Data conforming to Conventions</h3>

<p><a name="index-applications_002c-generic_002c-conventions-31"></a><a name="index-conventions_002c-introduction-32"></a>
The mere use of netCDF is not sufficient to make data
"self-describing" and meaningful to both humans and machines. The
names of variables and dimensions should be meaningful and conform to
any relevant conventions. Dimensions should have corresponding
coordinate variables where sensible.

   <p>Attributes play a vital role in providing ancillary information. It is
important to use all the relevant standard attributes using the
relevant conventions. For a description of reserved attributes (used by
the netCDF library) and attribute conventions for generic application
software, see <a href="#Attribute-Conventions">Attribute Conventions</a>.

   <p>A number of groups have defined their own additional conventions and
styles for netCDF data. Descriptions of these conventions, as well as
examples incorporating them can be accessed from the netCDF
Conventions site, <a href="http://www.unidata.ucar.edu/netcdf/conventions.html">http://www.unidata.ucar.edu/netcdf/conventions.html</a>.

   <p>These conventions should be used where suitable. Additional
conventions are often needed for local use. These should be
contributed to the above netCDF conventions site if likely to interest
other users in similar areas.

<div class="node">
<a name="Background"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Whats-New">Whats New</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Conventions">Conventions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.8 Background and Evolution of the NetCDF Interface</h3>

<p><a name="index-XDR_002c-introduction-into-netCDF-33"></a><a name="index-workshop_002c-CDF-34"></a><a name="index-CANDIS-35"></a><a name="index-NASA-CDF-format-36"></a><a name="index-SNIDE-37"></a><a name="index-New-Mexico-Institute-of-Mining-38"></a><a name="index-SeaSpace_002c-Inc-39"></a><a name="index-University-of-Miami-40"></a><a name="index-Terascan-data-format-41"></a><a name="index-FAN-42"></a><a name="index-NCO-43"></a><a name="index-DODS-44"></a><a name="index-OpenDAP-45"></a><a name="index-NcML-46"></a><a name="index-Northwestern-University-47"></a><a name="index-Argonne-National-Laboratory-48"></a><a name="index-g_t64_002dbit-offsets_002c-history-49"></a><a name="index-ruby-API_002c-history-50"></a><a name="index-python-API_002c-history-51"></a><a name="index-Tcl_002fTk-API_002c-history-52"></a><a name="index-Java-API_002c-history-53"></a><a name="index-Matlab-API_002c-history-54"></a><a name="index-WetCDF_002c-history-55"></a><a name="index-ADA-API_002c-history-56"></a><a name="index-g_t64_002dbit-offsets_002c-history-57"></a>
The development of the netCDF interface began with a modest goal
related to Unidata's needs: to provide a common interface between
Unidata applications and real-time meteorological data. Since Unidata
software was intended to run on multiple hardware platforms with
access from both C and FORTRAN, achieving Unidata's goals had the
potential for providing a package that was useful in a broader
context. By making the package widely available and collaborating with
other organizations with similar needs, we hoped to improve the then
current situation in which software for scientific data access was
only rarely reused by others in the same discipline and almost never
reused between disciplines (Fulker, 1988).

   <p>Important concepts employed in the netCDF software originated in a
paper (Treinish and Gough, 1987) that described data-access software
developed at the NASA Goddard National Space Science Data Center
(NSSDC). The interface provided by this software was called the Common
Data Format (CDF). The NASA CDF was originally developed as a
platform-specific FORTRAN library to support an abstraction for
storing arrays.

   <p>The NASA CDF package had been used for many different kinds of data in
an extensive collection of applications. It had the virtues of
simplicity (only 13 subroutines), independence from storage format,
generality, ability to support logical user views of data, and support
for generic applications.

   <p>Unidata held a workshop on CDF in Boulder in August 1987. We proposed
exploring the possibility of collaborating with NASA to extend the CDF
FORTRAN interface, to define a C interface, and to permit the access
of data aggregates with a single call, while maintaining compatibility
with the existing NASA interface.

   <p>Independently, Dave Raymond at the New Mexico Institute of Mining and
Technology had developed a package of C software for UNIX that
supported sequential access to self-describing array-oriented data and
a "pipes and filters" (or "data flow") approach to processing,
analyzing, and displaying the data. This package also used the "Common
Data Format" name, later changed to C-Based Analysis and Display
System (CANDIS). Unidata learned of Raymond's work (Raymond, 1988),
and incorporated some of his ideas, such as the use of named
dimensions and variables with differing shapes in a single data
object, into the Unidata netCDF interface.

   <p>In early 1988, Glenn Davis of Unidata developed a prototype netCDF
package in C that was layered on XDR. This prototype proved that a
single-file, XDR-based implementation of the CDF interface could be
achieved at acceptable cost and that the resulting programs could be
implemented on both UNIX and VMS systems. However, it also
demonstrated that providing a small, portable, and NASA CDF-compatible
FORTRAN interface with the desired generality was not
practical. NASA's CDF and Unidata's netCDF have since evolved
separately, but recent CDF versions share many characteristics with
netCDF.

   <p>In early 1988, Joe Fahle of SeaSpace, Inc. (a commercial software
development firm in San Diego, California), a participant in the 1987
Unidata CDF workshop, independently developed a CDF package in C that
extended the NASA CDF interface in several important ways (Fahle,
1989). Like Raymond's package, the SeaSpace CDF software permitted
variables with unrelated shapes to be included in the same data object
and permitted a general form of access to multidimensional
arrays. Fahle's implementation was used at SeaSpace as the
intermediate form of storage for a variety of steps in their
image-processing system. This interface and format have subsequently
evolved into the Terascan data format.

   <p>After studying Fahle's interface, we concluded that it solved many of
the problems we had identified in trying to stretch the NASA interface
to our purposes. In August 1988, we convened a small workshop to agree
on a Unidata netCDF interface, and to resolve remaining open
issues. Attending were Joe Fahle of SeaSpace, Michael Gough of Apple
(an author of the NASA CDF software), Angel Li of the University of
Miami (who had implemented our prototype netCDF software on VMS and
was a potential user), and Unidata systems development
staff. Consensus was reached at the workshop after some further
simplifications were discovered. A document incorporating the results
of the workshop into a proposed Unidata netCDF interface specification
was distributed widely for comments before Glenn Davis and Russ Rew
implemented the first version of the software. Comparison with other
data-access interfaces and experience using netCDF are discussed in
Rew and Davis (1990a), Rew and Davis (1990b), Jenter and Signell
(1992), and Brown, Folk, Goucher, and Rew (1993).

   <p>In October 1991, we announced version 2.0 of the netCDF software
distribution. Slight modifications to the C interface (declaring
dimension lengths to be long rather than int) improved the usability
of netCDF on inexpensive platforms such as MS-DOS computers, without
requiring recompilation on other platforms. This change to the
interface required no changes to the associated file format.

   <p>Release of netCDF version 2.3 in June 1993 preserved the same file
format but added single call access to records, optimizations for
accessing cross-sections involving non-contiguous data, subsampling
along specified dimensions (using 'strides'), accessing non-contiguous
data (using 'mapped array sections'), improvements to the ncdump and
ncgen utilities, and an experimental C++ interface.

   <p>In version 2.4, released in February 1996, support was added for new
platforms and for the C++ interface, significant optimizations
were implemented for supercomputer architectures, and the file format
was formally specified in an appendix to the User's Guide.

   <p>FAN (File Array Notation), software providing a high-level interface
to netCDF data, was made available in May 1996. The capabilities of
the FAN utilities include extracting and manipulating array data from
netCDF datasets, printing selected data from netCDF arrays, copying
ASCII data into netCDF arrays, and performing various operations (sum,
mean, max, min, product, and others) on netCDF arrays.

   <p>In 1996 and 1997, Joe Sirott implemented and made available the first
implementation of a read-only netCDF interface for Java, Bill Noon
made a Python module available for netCDF, and Konrad Hinsen
contributed another netCDF interface for Python.

   <p>In May 1997, Version 3.3 of netCDF was released. This included a new
type-safe interface for C and Fortran, as well as many other
improvements.  A month later, Charlie Zender released version 1.0 of
the NCO (netCDF Operators) package, providing command-line utilities
for general purpose operations on netCDF data.

   <p>Version 3.4 of Unidata's netCDF software, released in March 1998,
included initial large file support, performance enhancements, and
improved Cray platform support.  Later in 1998, Dan Schmitt provided a
Tcl/Tk interface, and Glenn Davis provided version 1.0 of netCDF for
Java.

   <p>In May 1999, Glenn Davis, who was instrumental in creating and
developing netCDF, died in a small plane crash during a
thunderstorm. The memory of Glenn's passions and intellect continue to
inspire those of us who worked with him.

   <p>In February 2000, an experimental Fortran 90 interface developed by
Robert Pincus was released.

   <p>John Caron released netCDF for Java, version 2.0 in February 2001. 
This version incorporated a new high-performance package for
multidimensional arrays, simplified the interface, and included
OpenDAP (known previously as DODS) remote access, as well as remote
netCDF access via HTTP contributed by Don Denbo.

   <p>In March 2001, netCDF 3.5.0 was released. This release fully
integrated the new Fortran 90 interface, enhanced portability,
improved the C++ interface, and added a few new tuning functions.

   <p>Also in 2001, Takeshi Horinouchi and colleagues made a netCDF
interface for Ruby available, as did David Pierce for the R language
for statistical computing and graphics.  Charles Denham released
WetCDF, an independent implementation of the netCDF interface for
Matlab, as well as updates to the popular netCDF Toolbox for Matlab.

   <p>In 2002, Unidata and collaborators developed NcML, an XML
representation for netCDF data useful for cataloging data holdings,
aggregation of data from multiple datasets, augmenting metadata in
existing datasets, and support for alternative views of data.  The
Java interface currently provides access to netCDF data through NcML.

   <p>Additional developments in 2002 included translation of C and Fortran
User Guides into Japanese by Masato Shiotani and colleagues, creation
of a &ldquo;Best Practices&rdquo; guide for writing netCDF files, and provision
of an Ada-95 interface by Alexandru Corlan.

   <p>In July 2003 a group of researchers at Northwestern University and
Argonne National Laboratory (Jianwei Li, Wei-keng Liao, Alok
Choudhary, Robert Ross, Rajeev Thakur, William Gropp, and Rob Latham)
contributed a new parallel interface for writing and reading netCDF
data, tailored for use on high performance platforms with parallel
I/O. The implementation built on the MPI-IO interface, providing
portability to many platforms.

   <p>In October 2003, Greg Sjaardema contributed support for an alternative
format with 64-bit offsets, to provide more complete support for very
large files. These changes, with slight modifications at Unidata, were
incorporated into version 3.6.0, released in December, 2004.

   <p>In 2004, thanks to a NASA grant, Unidata and NCSA began a
collaboration to increase the interoperability of netCDF and HDF5, and
bring some advanced HDF5 features to netCDF users.

   <p>In February, 2006, release 3.6.1 fixed some minor bugs.

   <p>In March, 2007, release 3.6.2 introduced an improved build system that
used automake and libtool, and an upgrade to the most recent autoconf
release, to support shared libraries and the netcdf-4 builds. This
release also introduced the NetCDF Tutorial and example programs.

   <p>The first beta release of netCDF-4.0 was celebrated with a giant party
at Unidata in April, 2007. Over 2000 people danced 'til dawn at the
NCAR Mesa Lab, listening to the Flaming Lips and the Denver Gilbert &amp;
Sullivan repertory company.

   <p>In June, 2008, netCDF-4.0 was released. Version 3.6.3, the same code
but with netcdf-4 features turned off, was released at the same
time. The 4.0 release uses HDF5 1.8.1 as the data storage layer for
netcdf, and introduces many new features including groups and
user-defined types. The 3.6.3/4.0 releases also introduced handling of
UTF8-encoded Unicode names.

   <p>NetCDF-4.1.1 was released in April, 2010, provided built-in client
support for the DAP protocol for accessing data from remote OPeNDAP
servers, full support for the enhanced netCDF-4 data model in the
ncgen utility, a new nccopy utility for copying and conversion among
netCDF format variants, ability to read some HDF4/HDF5 data archives
through the netCDF C or Fortran interfaces, support for parallel I/O
on netCDF classic and 64-bit offset files using the parallel-netcdf
(formerly pnetcdf) library from Argonne/Northwestern, a new nc-config
utility to help compile and link programs that use netCDF, inclusion
of the UDUNITS library for hadling &ldquo;units&rdquo; attributes, and inclusion
of libcf to assist in creating data compliant with the Climate and
Forecast (CF) metadata conventions.

   <p>In September, 2010, the Netcdf-Java/CDM (Common Data Model) version
4.2 library was declared stable and made available to users.  This
100%-Java implementation provides a read-write interface to netCDF-3
classic and 64-bit offset data, as well as a read-onlt interface to
netCDF-4 enhanced model data and many other formats of scientific data
through a common (CDM) interface.  The NetCDF-Java library also
implements NcML, which allows you to add metadata to CDM datasets, as
well as to create virtual datasets through aggregation.  A ToolsUI
application is also included that provides a graphical user interface
to capabilities similar to the C-based ncdump and ncgen utilities, as
well as CF-compliance checking and many other features.

<div class="node">
<a name="Whats-New"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Limitations">Limitations</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Background">Background</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.9 What's New Since the Previous Release?</h3>

<p><a name="index-new-netCDF-features-in-4_002e0-58"></a>
This Guide documents the 4.1.3 release of netCDF, which
introduces a new storage format, netCDF-4/HDF5, while maintaining full
backward compatibility.

   <p>New features available with netCDF-4/HDF5 files include:

     <ul>
<li>The use of groups to organize datasets.

     <li>New unsigned integer data types, 64-bit integer types, and a string
type.

     <li>A user defined compound type, which can be constructed by users to
match a C struct or other arbitrary organization of types.

     <li>A variable length array type.

     <li>Multiple unlimited dimensions.

     <li>Support for parallel I/O.

   </ul>

   <p>More information about netCDF-4 can be found at the netCDF web
page <a href="http://www.unidata.ucar.edu/netcdf/netcdf-4">http://www.unidata.ucar.edu/netcdf/netcdf-4</a>.

<div class="node">
<a name="Limitations"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Future">Future</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Whats-New">Whats New</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.10 Limitations of NetCDF</h3>

<p><a name="index-arrays_002c-ragged-59"></a><a name="index-writers_002c-multiple-60"></a><a name="index-limitations-of-netCDF-61"></a><a name="index-classic-netCDF-format-62"></a><a name="index-GiBytes-63"></a><a name="index-GBytes-64"></a>
The netCDF classic data model is widely applicable to data that can be
organized into a collection of named array variables with named
attributes, but there are some important limitations to the model and
its implementation in software. Some of these limitations have been
removed or relaxed in netCDF-4 files, but still apply to netCDF
classic and netCDF 64-bit offset files.

   <p>Currently, netCDF classic and 64-bit offset formats offer a limited
number of external numeric data types: 8-, 16-, 32-bit integers, or
32- or 64-bit floating-point numbers. (The netCDF-4 format adds 64-bit
integer types and unsigned integer types.)

   <p>With the netCDF-4/HDF5 format, new unsigned integers (of various
sizes), 64-bit integers, and the string type allow improved expression
of meaning in scientific data. The new VLEN (variable length) and
COMPOUND types allow users to organize data in new ways.

   <p>With the classic netCDF file format, there are constraints that limit
how a dataset is structured to store more than 2 <dfn>GiBytes</dfn> (a
GiByte is 2^30
or 1,073,741,824 bytes, as compared to a <dfn>Gbyte</dfn>, which is
1,000,000,000 bytes.)  of data in a single netCDF
dataset. (see <a href="#Classic-Limitations">Classic Limitations</a>).  This limitation
is a result of 32-bit offsets used for storing relative offsets within
a classic netCDF format file. Since one of the goals of netCDF is
portable data, and some file systems still can't deal with files
larger than 2 GiB, it is best to keep files that must be portable
below this limit. Nevertheless, it is possible to create and access
netCDF files larger than 2 GiB on platforms that provide support for
such files (see <a href="#Large-File-Support">Large File Support</a>).

   <p>The new 64-bit offset format allows large files, and makes it easy to
create to create fixed variables of about 4 GiB, and record variables
of about 4 GiB per record. (see <a href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a>). However, old netCDF applications will not be able to
read the 64-bit offset files until they are upgraded to at least
version 3.6.0 of netCDF (i.e. the version in which 64-bit offset
format was introduced).

   <p>With the netCDF-4/HDF5 format, size limitations are further relaxed,
and files can be as large as the underlying file system
supports. NetCDF-4/HDF5 files are unreadable to the netCDF library
before version 4.0.

   <p>Another limitation of the classic (and 64-bit offset) model is that
only one unlimited (changeable) dimension is permitted for each netCDF
data set. Multiple variables can share an unlimited dimension, but
then they must all grow together. Hence the classic netCDF model does
not permit variables with several unlimited dimensions or the use of
multiple unlimited dimensions in different variables within the same
dataset. Variables that have non-rectangular shapes (for example,
ragged arrays) cannot be represented conveniently.

   <p>In netCDF-4/HDF5 files, multiple unlimited dimensions are fully
supported. Any variable can be defined with any combination of limited
and unlimited dimensions.

   <p>The extent to which data can be completely self-describing is limited:
there is always some assumed context without which sharing and
archiving data would be impractical. NetCDF permits storing meaningful
names for variables, dimensions, and attributes; units of measure in a
form that can be used in computations; text strings for attribute
values that apply to an entire data set; and simple kinds of
coordinate system information. But for more complex kinds of metadata
(for example, the information necessary to provide accurate
georeferencing of data on unusual grids or from satellite images), it
is often necessary to develop conventions.

   <p>Specific additions to the netCDF data model might make some of these
conventions unnecessary or allow some forms of metadata to be
represented in a uniform and compact way. For example, adding explicit
georeferencing to the netCDF data model would simplify elaborate
georeferencing conventions at the cost of complicating the model. The
problem is finding an appropriate trade-off between the richness of
the model and its generality (i.e., its ability to encompass many
kinds of data). A data model tailored to capture the shared context
among researchers within one discipline may not be appropriate for
sharing or combining data from multiple disciplines.

   <p>The classic netCDF data model (which is used for classic-format and
64-bit offset format data) does not support nested data structures
such as trees, nested arrays, or other recursive structures.  Through use of
indirection and conventions it is possible to represent some kinds of
nested structures, but the result may fall short of the netCDF goal of
self-describing data.

   <p>In netCDF-4/HDF5 format files, the introduction of the compound type
allows the creation of complex data types, involving any combination
of types. The VLEN type allows efficient storage of ragged arrays, and
the introduction of hierarchical groups allows users new ways to organize data.

   <p>Finally, using the netCDF-3 programming interfaces, concurrent access to a
netCDF dataset is limited. One writer and multiple readers may access
data in a single dataset simultaneously, but there is no support for
multiple concurrent writers.

   <p>NetCDF-4 supports parallel read/write access to netCDF-4/HDF5 files,
using the underlying HDF5 library and parallel read/write access to
classic and 64-bit offset files using the parallel-netcdf library.

   <p>For more information about HDF5, see the HDF5 web site:
<a href="http://hdfgroup.org/HDF5/">http://hdfgroup.org/HDF5/</a>.

   <p>For more information about parallel-netcdf, see their web site:
<a href="http://www.mcs.anl.gov/parallel-netcdf">http://www.mcs.anl.gov/parallel-netcdf</a>.

<div class="node">
<a name="Future"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#References">References</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Limitations">Limitations</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.11 Plans for NetCDF</h3>

<p><a name="index-future-plans-for-netCDF-65"></a><a name="index-plans-for-netCDF-66"></a><a name="index-netCDF-5_002e0-67"></a><a name="index-pong-68"></a>
Future versions of netCDF will include the following features:

     <ol type=1 start=1>

     <li>Extensions of netCDF-4 features to C++ API and to tools
ncgen/ncdump.

     <li>Better documentation and more examples.

        </ol>

<div class="node">
<a name="References"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Future">Future</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.12 References</h3>

<p><a name="index-references-69"></a>
     <ol type=1 start=1>

     <li>Brown, S. A, M. Folk, G. Goucher, and R. Rew, "Software for
Portable Scientific Data Management," Computers in Physics, American
Institute of Physics, Vol. 7, No. 3, May/June 1993.

     <li>Davies, H. L., "FAN - An array-oriented query language," Second
Workshop on Database Issues for Data Visualization (Visualization
1995), Atlanta, Georgia, IEEE, October 1995.

     <li>Fahle, J., TeraScan Applications Programming Interface, SeaSpace,
San Diego, California, 1989.

     <li>Fulker, D. W., "The netCDF: Self-Describing, Portable Files&mdash;a
Basis for 'Plug-Compatible' Software Modules Connectable by Networks,"
ICSU Workshop on Geophysical Informatics, Moscow, USSR, August 1988.

     <li>Fulker, D. W., "Unidata Strawman for Storing Earth-Referencing
Data," Seventh International Conference on Interactive Information and
Processing Systems for Meteorology, Oceanography, and Hydrology, New
Orleans, La., American Meteorology Society, January 1991.

     <li>Gough, M. L., NSSDC CDF Implementer's Guide (DEC VAX/VMS) Version
1.1, National Space Science Data Center, 88-17, NASA/Goddard Space
Flight Center, 1988.

     <li>Jenter, H. L. and R. P. Signell, "NetCDF: A Freely-Available
Software-Solution to Data-Access Problems for Numerical Modelers,"
Proceedings of the American Society of Civil Engineers Conference on
Estuarine and Coastal Modeling, Tampa, Florida, 1992.

     <li>Raymond, D. J., "A C Language-Based Modular System for Analyzing
and Displaying Gridded Numerical Data," Journal of Atmospheric and
Oceanic Technology, 5, 501-511, 1988.

     <li>Rew, R. K. and G. P. Davis, "The Unidata netCDF: Software for
Scientific Data Access," Sixth International Conference on Interactive
Information and Processing Systems for Meteorology, Oceanography, and
Hydrology, Anaheim, California, American Meteorology Society, February
1990.

     <li>Rew, R. K. and G. P. Davis, "NetCDF: An Interface for Scientific
Data Access," Computer Graphics and Applications, IEEE, pp. 76-82,
July 1990.

     <li>Rew, R. K. and G. P. Davis, "Unidata's netCDF Interface for Data
Access: Status and Plans," Thirteenth International Conference on
Interactive Information and Processing Systems for Meteorology,
Oceanography, and Hydrology, Anaheim, California, American Meteorology
Society, February 1997.

     <li>Treinish, L. A. and M. L. Gough, "A Software Package for the Data
Independent Management of Multi-Dimensional Data," EOS Transactions,
American Geophysical Union, 68, 633-635, 1987.
        </ol>

<div class="node">
<a name="Dataset-Components"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Data">Data</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">2 Components of a NetCDF Dataset</h2>

<ul class="menu">
<li><a accesskey="1" href="#Data-Model">Data Model</a>:                   How NetCDF Sees Data
<li><a accesskey="2" href="#Dimensions">Dimensions</a>:                   Specifying Data Shape
<li><a accesskey="3" href="#Variables">Variables</a>:                    Storing Data
<li><a accesskey="4" href="#Attributes">Attributes</a>:                   Storing Metadata
<li><a accesskey="5" href="#Attributes-and-Variables">Attributes and Variables</a>:     Attributes vs. Variables
</ul>

<div class="node">
<a name="Data-Model"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Dimensions">Dimensions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Dataset-Components">Dataset Components</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Dataset-Components">Dataset Components</a>

</div>

<h3 class="section">2.1 The NetCDF Data Model</h3>

<p><a name="index-netCDF-data-model-70"></a><a name="index-data-model_002c-netCDF-71"></a><a name="index-naming-conventions-72"></a><a name="index-conventions_002c-naming-73"></a><a name="index-CDL_002c-example-74"></a><a name="index-common-data-form-language-75"></a><a name="index-ncdump_002c-introduction-76"></a><a name="index-groups-77"></a><a name="index-user-defined-types-78"></a>

   <p>A netCDF dataset contains dimensions, variables, and attributes, which
all have both a name and an ID number by which they are
identified. These components can be used together to capture the
meaning of data and relations among data fields in an array-oriented
dataset. The netCDF library allows simultaneous access to multiple
netCDF datasets which are identified by dataset ID numbers, in
addition to ordinary file names.

<h4 class="subsection">2.1.1 Enhanced Model in NetCDF-4 Files</h4>

<p>Files created with the netCDF-4 format have access to an enhanced data
model, which includes named groups. Groups, like directories in a Unix
file system, are hierarchically organized, to arbitrary depth. They
can be used to organize large numbers of variables.

   <p>Each group acts as an entire netCDF dataset in the classic model. That
is, each group may have attributes, dimensions, and variables, as well
as other groups.

   <p>The default group is the root group, which allows the classic netCDF
data model to fit neatly into the new model.

   <p>Dimensions are scoped such that they can be seen in all descendant
groups. That is, dimensions can be shared between variables in
different groups, if they are defined in a parent group.

   <p>In netCDF-4 files, the user may also define a type. For example a
compound type may hold information from an array of C structures, or a
variable length type allows the user to read and write arrays of
variable length values.

   <p>Variables, groups, and types share a namespace. Within the same group,
variables, groups, and types must have unique names. (That is, a type
and variable may not have the same name within the same group, and
similarly for sub-groups of that group.)

   <p>Groups and user-defined types are only available in files created in
the netCDF-4/HDF5 format. They are not available for classic or 64-bit
offset format files.

<h4 class="subsection">2.1.2 Naming Conventions</h4>

<p>The names of dimensions, variables and attributes (and, in netCDF-4
files, groups, user-defined types, compound member names, and
enumeration symbols) consist of arbitrary sequences of alphanumeric
characters, underscore '_', period '.', plus '+', hyphen '-', or at
sign '@', but beginning with an alphanumeric character or underscore.  However names
commencing with underscore are reserved for system use.  Case is
significant in netCDF names. A zero-length name is not allowed.  Some
widely used conventions restrict names to only alphanumeric characters
or underscores.  Beginning with versions 3.6.3 and 4.0, names may also
include UTF-8 encoded Unicode characters as well as other special
characters, except for the character '/', which may not appear in a
name.  Names that have trailing space characters are also
not permitted.

<h4 class="subsection">2.1.3 Network Common Data Form Language (CDL)</h4>

<p>We will use a small netCDF example to illustrate the concepts of the
netCDF classic data model. This includes dimensions, variables, and
attributes. The notation used to describe this simple netCDF object is
called CDL (network Common Data form Language), which provides a
convenient way of describing netCDF datasets. The netCDF system
includes the ncdump utility for producing human-oriented CDL text
files from binary netCDF datasets and vice versa using the ncgen
utility. 
(The ncdump utility
accommodates netCDF-4 features in the CDL
output, but the example here is restricted to netCDF-3 CDL.)

<pre class="example">     netcdf example_1 {  // example of CDL notation for a netCDF dataset
     
     dimensions:         // dimension names and lengths are declared first
             lat = 5, lon = 10, level = 4, time = unlimited;
     
     variables:          // variable types, names, shapes, attributes
             float   temp(time,level,lat,lon);
                         temp:long_name     = "temperature";
                         temp:units         = "celsius";
             float   rh(time,lat,lon);
                         rh:long_name = "relative humidity";
                         rh:valid_range = 0.0, 1.0;      // min and max
             int     lat(lat), lon(lon), level(level);
                         lat:units       = "degrees_north";
                         lon:units       = "degrees_east";
                         level:units     = "millibars";
             short   time(time);
                         time:units      = "hours since 1996-1-1";
             // global attributes
                         :source = "Fictional Model Output";
     
     data:                // optional data assignments
             level   = 1000, 850, 700, 500;
             lat     = 20, 30, 40, 50, 60;
             lon     = -160,-140,-118,-96,-84,-52,-45,-35,-25,-15;
             time    = 12;
             rh      =.5,.2,.4,.2,.3,.2,.4,.5,.6,.7,
                      .1,.3,.1,.1,.1,.1,.5,.7,.8,.8,
                      .1,.2,.2,.2,.2,.5,.7,.8,.9,.9,
                      .1,.2,.3,.3,.3,.3,.7,.8,.9,.9,
                       0,.1,.2,.4,.4,.4,.4,.7,.9,.9;
     }
</pre>
   <p>The CDL notation for a netCDF dataset can be generated automatically
by using ncdump, a utility program described later
(see <a href="#ncdump">ncdump</a>). Another netCDF utility, ncgen, generates a netCDF
dataset (or optionally C or FORTRAN source code containing calls
needed to produce a netCDF dataset) from CDL input (see <a href="#ncgen">ncgen</a>). 
This version of ncgen can produce netcdf-3 or netcdf-4
files and can utilize CDL input that includes the netcdf-4 data model
constructs. The older ncgen program is still available under the name
ncgen3.

   <p>The CDL notation is simple and largely self-explanatory. It will be
explained more fully as we describe the components of a netCDF
dataset. For now, note that CDL statements are terminated by a
semicolon. Spaces, tabs, and newlines can be used freely for
readability. Comments in CDL follow the characters '//' on any line. A
CDL description of a netCDF dataset takes the form

<pre class="example">       netCDF name {
         types: [netcdf-4 only]
         dimensions: ...
         variables: ...
         data: ...
       }
</pre>
   <p>where the name is used only as a default in constructing file names by
the ncgen utility. The CDL description consists of three optional
parts, introduced by the keywords dimensions, variables, and
data. NetCDF dimension declarations appear after the dimensions
keyword, netCDF variables and attributes are defined after the
variables keyword, and variable data assignments appear after the data
keyword.

   <p>The ncgen utility provides a command line option which indicates the
desired output format. Limitations are enforced for the selected
format - that is, some CDL files may be expressible only in 64-bit
offset or netCDF-4 format.

   <p>For example, trying to create a file with very large variables in
classic format may result in an error because size limits are
violated.

<div class="node">
<a name="Dimensions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Variables">Variables</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Data-Model">Data Model</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Dataset-Components">Dataset Components</a>

</div>

<h3 class="section">2.2 Dimensions</h3>

<p><a name="index-appending-data-along-unlimited-dimension-79"></a><a name="index-dimensions_002c-introduction-80"></a><a name="index-dimensions_002c-unlimited-81"></a><a name="index-unlimited-dimensions-82"></a><a name="index-multiple-unlimited-dimensions-83"></a>
A dimension may be used to represent a real physical dimension, for
example, time, latitude, longitude, or height. A dimension might also
be used to index other quantities, for example station or
model-run-number.

   <p>A netCDF dimension has both a name and a length.

<!-- As a convenience, in netCDF-4 format files, a name is no longer -->
<!-- necessary for every dimension. Dimensions without a name are called -->
<!-- anonymous dimensions, and function in every other way just as other -->
<!-- dimensions do. -->
   <p>A dimension length is an arbitrary positive integer, except that one
dimension in a classic or 64-bit offset netCDF dataset can have the
length UNLIMITED. In a netCDF-4 dataset, any number of unlimited
dimensions can be used.

   <p>Such a dimension is called the unlimited dimension or the record
dimension. A variable with an unlimited dimension can grow to any
length along that dimension. The unlimited dimension index is like a
record number in conventional record-oriented files.

   <p>A netCDF classic or 64-bit offset dataset can have at most one
unlimited dimension, but need not have any. If a variable has an
unlimited dimension, that dimension must be the most significant
(slowest changing) one. Thus any unlimited dimension must be the first
dimension in a CDL shape and the first dimension in corresponding C
array declarations.

   <p>A netCDF-4 dataset may have multiple unlimited dimensions, and there
are no restrictions on their order in the list of a variables
dimensions.

   <p>To grow variables along an unlimited dimension, write the data using
any of the netCDF data writing functions, and specify the index of the
unlimited dimension to the desired record number. The netCDF library
will write however many records are needed (using the fill value,
unless that feature is turned off, to fill in any intervening
records).

   <p>CDL dimension declarations may appear on one or more lines following
the CDL keyword dimensions. Multiple dimension declarations on the
same line may be separated by commas. Each declaration is of the form
name = length. Use the &ldquo;/&rdquo; character to include group information
(netCDF-4 output only).

   <p>There are four dimensions in the above example: lat, lon, level, and
time (see <a href="#Data-Model">Data Model</a>). The first three are assigned fixed lengths;
time is assigned the length UNLIMITED, which means it is the unlimited
dimension.

   <p>The basic unit of named data in a netCDF dataset is a variable. When a
variable is defined, its shape is specified as a list of
dimensions. These dimensions must already exist. The number of
dimensions is called the rank (a.k.a. dimensionality). A scalar
variable has rank 0, a vector has rank 1 and a matrix has rank 2.

   <p>It is possible (since version 3.1 of netCDF) to use the same dimension
more than once in specifying a variable shape. For example,
correlation(instrument, instrument) could be a matrix giving
correlations between measurements using different instruments. But
data whose dimensions correspond to those of physical space/time
should have a shape comprising different dimensions, even if some of
these have the same length.

<div class="node">
<a name="Variables"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Attributes">Attributes</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Dimensions">Dimensions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Dataset-Components">Dataset Components</a>

</div>

<h3 class="section">2.3 Variables</h3>

<p><a name="index-variables_002c-defined-84"></a><a name="index-variable-types-85"></a><a name="index-netCDF-data-types-86"></a><a name="index-NC_005fBYTE-87"></a><a name="index-NC_005fINT-88"></a><a name="index-NC_005fSHORT-89"></a><a name="index-NC_005fLONG-90"></a><a name="index-NC_005fCHAR-91"></a><a name="index-NC_005fFLOAT-92"></a><a name="index-NC_005fDOUBLE-93"></a><a name="index-NC_005fUBYTE-94"></a><a name="index-NC_005fUINT-95"></a><a name="index-NC_005fUSHORT-96"></a><a name="index-NC_005fUINT-97"></a><a name="index-NC_005fINT64-98"></a><a name="index-NC_005fUINT64-99"></a><a name="index-NC_005fSTRING-100"></a><a name="index-nf_005fbyte-101"></a><a name="index-nf_005fchar-102"></a><a name="index-nf_005fshort-103"></a><a name="index-nf_005fint1-104"></a><a name="index-nf_005fint2-105"></a><a name="index-nf_005freal-106"></a><a name="index-nf_005fdouble-107"></a><a name="index-nf_005ffloat-108"></a><a name="index-attributes-associated-with-a-variable-109"></a><a name="index-primary-variables-110"></a><a name="index-variables_002c-primary-111"></a><a name="index-coordinate-variables-112"></a><a name="index-variables_002c-coordinate-113"></a>
Variables are used to store the bulk of the data in a netCDF
dataset. A variable represents an array of values of the same type. A
scalar value is treated as a 0-dimensional array. A variable has a
name, a data type, and a shape described by its list of dimensions
specified when the variable is created. A variable may also have
associated attributes, which may be added, deleted or changed after
the variable is created.

   <p>A variable external data type is one of a small set of netCDF
types. In classic and 64-bit offset files, only the original six types
are available (byte, character, short, int, float, and
double). Variables in netCDF-4 files may also use unsigned short,
unsigned int, 64-bit int, unsigned 64-bit int, or string. Or the user
may define a type, as an opaque blob of bytes, as an array of variable
length arrays, or as a compound type, which acts like a C struct.

   <p>For more information on types for the C interface, see <a href="netcdf-c.html#Variable-Types">Variable Types</a> in The NetCDF C Interface Guide.

   <p>For more information on types for the Fortran interface, see
<a href="netcdf-f77.html#Variable-Types">Variable Types</a> in
The NetCDF Fortran 77 Interface Guide.

   <p>In the CDL notation, classic and 64-bit offset type can be
used. They are given the simpler names byte, char, short, int, float,
and double. The name real may be used as a synonym for float in the CDL
notation. The name long is a deprecated synonym for int. For the exact meaning
of each of the types see <a href="#External-Types">External Types</a>.  The ncgen utility
supports new primitive types with names ubyte, ushort, uint,
int64, uint64, and string.

   <p>CDL variable declarations appear after the variable keyword in a CDL
unit. They have the form

<pre class="example">          type variable_name ( dim_name_1, dim_name_2, ... );
</pre>
   <p>for variables with dimensions, or

<pre class="example">          type variable_name;
</pre>
   <p>for scalar variables.

   <p>In the above CDL example there are six variables. As discussed below,
four of these are coordinate variables. The remaining variables
(sometimes called primary variables), temp and rh, contain what is
usually thought of as the data. Each of these variables has the
unlimited dimension time as its first dimension, so they are called
record variables. A variable that is not a record variable has a fixed
length (number of data values) given by the product of its dimension
lengths. The length of a record variable is also the product of its
dimension lengths, but in this case the product is variable because it
involves the length of the unlimited dimension, which can vary. The
length of the unlimited dimension is the number of records.

<h4 class="subsection">2.3.1 Coordinate Variables</h4>

<p>It is legal for a variable to have the same name as a dimension. Such
variables have no special meaning to the netCDF library. However there
is a convention that such variables should be treated in a special way
by software using this library.

   <p>A variable with the same name as a dimension is called a coordinate
variable. It typically defines a physical coordinate corresponding to
that dimension. The above CDL example includes the coordinate
variables lat, lon, level and time, defined as follows:

<pre class="example">             int     lat(lat), lon(lon), level(level);
             short   time(time);
     ...
     data:
             level   = 1000, 850, 700, 500;
             lat     = 20, 30, 40, 50, 60;
             lon     = -160,-140,-118,-96,-84,-52,-45,-35,-25,-15;
             time    = 12;
</pre>
   <p>These define the latitudes, longitudes, barometric pressures and times
corresponding to positions along these dimensions. Thus there is data
at altitudes corresponding to 1000, 850, 700 and 500 millibars; and at
latitudes 20, 30, 40, 50 and 60 degrees north. Note that each
coordinate variable is a vector and has a shape consisting of just the
dimension with the same name.

   <p>A position along a dimension can be specified using an index. This is
an integer with a minimum value of 0 for C programs, 1 in Fortran
programs. Thus the 700 millibar level would have an index value of 2
in the example above in a C program, and 3 in a Fortran program.

   <p>If a dimension has a corresponding coordinate variable, then this
provides an alternative, and often more convenient, means of
specifying position along it. Current application packages that make
use of coordinate variables commonly assume they are numeric vectors
and strictly monotonic (all values are different and either increasing
or decreasing).

<div class="node">
<a name="Attributes"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Attributes-and-Variables">Attributes and Variables</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Variables">Variables</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Dataset-Components">Dataset Components</a>

</div>

<h3 class="section">2.4 Attributes</h3>

<p><a name="index-attributes_002c-defined-114"></a><a name="index-attributes_002c-defining-in-CDL-115"></a><a name="index-attributes_002c-adding-to-existing-dataset-116"></a><a name="index-CDL_002c-defining-attributes-117"></a><a name="index-CDL_002c-defining-global-attributes-118"></a><a name="index-ancillary-data_002c-storing-119"></a><a name="index-storing-ancillary-data-120"></a><a name="index-applications_002c-generic-121"></a><a name="index-generic-applications-122"></a><a name="index-attributes_002c-data-type-123"></a><a name="index-attributes_002c-global-124"></a><a name="index-attributes_002c-operations-on-125"></a><a name="index-global-attributes-126"></a><a name="index-operations-on-attributes-127"></a>
NetCDF attributes are used to store data about the data (ancillary
data or metadata), similar in many ways to the information stored in
data dictionaries and schema in conventional database systems. Most
attributes provide information about a specific variable. These are
identified by the name (or ID) of that variable, together with the
name of the attribute.

   <p>Some attributes provide information about the dataset as a whole and
are called global attributes. These are identified by the attribute
name together with a blank variable name (in CDL) or a special null
"global variable" ID (in C or Fortran).

   <p>In netCDF-4 file, attributes can also be added at the group level.

   <p>An attribute has an associated variable (the null "global variable"
for a global or group-level attribute), a name, a data type, a length,
and a value. The current version treats all attributes as vectors;
scalar values are treated as single-element vectors.

   <p>Conventional attribute names should be used where applicable. New
names should be as meaningful as possible.

   <p>The external type of an attribute is specified when it is created. The
types permitted for attributes are the same as the netCDF external
data types for variables. Attributes with the same name for different
variables should sometimes be of different types. For example, the
attribute valid_max specifying the maximum valid data value for a
variable of type int should be of type int, whereas the attribute
valid_max for a variable of type double should instead be of type
double.

   <p>Attributes are more dynamic than variables or dimensions; they can be
deleted and have their type, length, and values changed after they are
created, whereas the netCDF interface provides no way to delete a
variable or to change its type or shape.

   <p>The CDL notation for defining an attribute is

<pre class="example">         variable_name:attribute_name = list_of_values;
</pre>
   <p>for a variable attribute, or

<pre class="example">         :attribute_name = list_of_values;
</pre>
   <p>for a global attribute.

   <p>For the netCDF classic model,
the type and length of each attribute are not explicitly declared in
CDL; they are derived from the values assigned to the attribute. All
values of an attribute must be of the same type. The notation used for
constant values of the various netCDF types is discussed later
(see <a href="#CDL-Constants">CDL Constants</a>).

   <p>The extended CDL syntax for the enhanced
data model supported by netCDF-4 allows optional type specifications,
including user-defined types, for
attributes of user-defined types.  See ncdump output or the reference
documentation for ncgen for details of the extended CDL systax.

   <p>In the netCDF example (see <a href="#Data-Model">Data Model</a>), units is an attribute for
the variable lat that has a 13-character array value
'degrees_north'. And valid_range is an attribute for the variable rh
that has length 2 and values '0.0' and '1.0'.

   <p>One global attribute, called &ldquo;source&rdquo;, is defined for the example
netCDF dataset. This is a character array intended for documenting the
data. Actual netCDF datasets might have more global attributes to
document the origin, history, conventions, and other characteristics
of the dataset as a whole.

   <p>Most generic applications that process netCDF datasets assume standard
attribute conventions and it is strongly recommended that these be
followed unless there are good reasons for not doing so. For
information about units, long_name, valid_min, valid_max, valid_range,
scale_factor, add_offset, _FillValue, and other conventional
attributes, see <a href="#Attribute-Conventions">Attribute Conventions</a>.

   <p>Attributes may be added to a netCDF dataset long after it is first
defined, so you don't have to anticipate all potentially useful
attributes. However adding new attributes to an existing classic or
64-bit offset format dataset can incur the same expense as copying the
dataset. For a more extensive discussion see <a href="#Structure">Structure</a>.

<div class="node">
<a name="Attributes-and-Variables"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Attributes">Attributes</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Dataset-Components">Dataset Components</a>

</div>

<h3 class="section">2.5 Differences between Attributes and Variables</h3>

<p><a name="index-ancillary-data-as-attributes-128"></a><a name="index-attributes-vs_002e-variables-129"></a><a name="index-variables-vs_002e-attributes-130"></a><a name="index-differences-between-attributes-and-variables-131"></a>
In contrast to variables, which are intended for bulk data, attributes
are intended for ancillary data, or information about the data. The
total amount of ancillary data associated with a netCDF object, and
stored in its attributes, is typically small enough to be
memory-resident. However variables are often too large to entirely fit
in memory and must be split into sections for processing.

   <p>Another difference between attributes and variables is that variables
may be multidimensional. Attributes are all either scalars
(single-valued) or vectors (a single, fixed dimension).

   <p>Variables are created with a name, type, and shape before they are
assigned data values, so a variable may exist with no values.  The
value of an attribute is specified when it is created, unless it is a
zero-length attribute.

   <p>A variable may have attributes, but an attribute cannot have
attributes. Attributes assigned to variables may have the same units
as the variable (for example, valid_range) or have no units (for
example, scale_factor). If you want to store data that requires units
different from those of the associated variable, it is better to use a
variable than an attribute. More generally, if data require ancillary
data to describe them, are multidimensional, require any of the
defined netCDF dimensions to index their values, or require a
significant amount of storage, that data should be represented using
variables rather than attributes.

<div class="node">
<a name="Data"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Structure">Structure</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Dataset-Components">Dataset Components</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">3 Data</h2>

<p>This chapter discusses the primitive netCDF external data types, the
kinds of data access supported by the netCDF interface, and how data
structures other than arrays may be implemented in a netCDF dataset.

<ul class="menu">
<li><a accesskey="1" href="#External-Types">External Types</a>:               Integers, Floats, and so on
<li><a accesskey="2" href="#Classic-Data-Structures">Classic Data Structures</a>:      Complex Data in Classic Format
<li><a accesskey="3" href="#User-Defined-Types">User Defined Types</a>:           Complex Data in NetCDF-4/HDF5 Format
<li><a accesskey="4" href="#Data-Access">Data Access</a>:                  Reading and Writing Data
<li><a accesskey="5" href="#Type-Conversion">Type Conversion</a>:              Changing Type of Numeric Data
</ul>

<div class="node">
<a name="External-Types"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Classic-Data-Structures">Classic Data Structures</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Data">Data</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Data">Data</a>

</div>

<h3 class="section">3.1 NetCDF External Data Types</h3>

<p><a name="index-ASCII-characters-132"></a><a name="index-data-types_002c-external-133"></a><a name="index-conversion-of-data-types_002c-introduction-134"></a><a name="index-external-data-types-135"></a><a name="index-byte_002c-signed-vs_002e-unsigned-136"></a>
The atomic external types supported by the netCDF interface are:

   <p><table summary="">
<tr align="left"><td valign="top" width="15%">C name </td><td valign="top" width="15%">Fortran name </td><td valign="top" width="70%">storage

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_BYTE </td><td valign="top" width="15%">nf_byte </td><td valign="top" width="70%">8-bit signed integer

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_CHAR </td><td valign="top" width="15%">nf_char </td><td valign="top" width="70%">8-bit unsigned integer

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_SHORT </td><td valign="top" width="15%">nf_short </td><td valign="top" width="70%">16-bit signed integer

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_USHORT </td><td valign="top" width="15%">nf_ushort </td><td valign="top" width="70%">16-bit unsigned integer *

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_INT (or NC_LONG) </td><td valign="top" width="15%">nf_int </td><td valign="top" width="70%">32-bit signed integer

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_UINT </td><td valign="top" width="15%">nf_uint </td><td valign="top" width="70%">32-bit unsigned integer *

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_INT64 </td><td valign="top" width="15%">nf_int64 </td><td valign="top" width="70%">64-bit signed integer *

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_UINT64 </td><td valign="top" width="15%">nf_uint64 </td><td valign="top" width="70%">64-bit unsigned integer *

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_FLOAT </td><td valign="top" width="15%">nf_float </td><td valign="top" width="70%">32-bit floating point

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_DOUBLE </td><td valign="top" width="15%">nf_double </td><td valign="top" width="70%">64-bit floating point

<p><br></td></tr><tr align="left"><td valign="top" width="15%">NC_STRING </td><td valign="top" width="15%">nf_string </td><td valign="top" width="70%">variable length character string *

   <br></td></tr></table>

   <p>* These types are available only for netCDF-4 format files. All the
unsigned ints (except NC_CHAR), the 64-bit ints, and string
type are for netCDF-4 files only.

   <p>These types were chosen to provide a reasonably wide range of
trade-offs between data precision and number of bits required for each
value. These external data types are independent from whatever
internal data types are supported by a particular machine and language
combination.

   <p>These types are called "external", because they correspond to the
portable external representation for netCDF data. When a program reads
external netCDF data into an internal variable, the data is converted,
if necessary, into the specified internal type. Similarly, if you
write internal data into a netCDF variable, this may cause it to be
converted to a different external type, if the external type for the
netCDF variable differs from the internal type.

   <p>The separation of external and internal types and automatic type
conversion have several advantages. You need not be aware of the
external type of numeric variables, since automatic conversion to or
from any desired numeric type is available. You can use this feature
to simplify code, by making it independent of external types, using a
sufficiently wide internal type, e.g., double precision, for numeric
netCDF data of several different external types. Programs need not be
changed to accommodate a change to the external type of a variable.

   <p>If conversion to or from an external numeric type is necessary, it is
handled by the library.

   <p>Converting from one numeric type to another may result in an error if
the target type is not capable of representing the converted
value. For example, an internal short integer type may not be able to
hold data stored externally as an integer. When accessing an array of
values, a range error is returned if one or more values are out of the
range of representable values, but other values are converted
properly.

   <p>Note that mere loss of precision in type conversion does not return an
error. Thus, if you read double precision values into a
single-precision floating-point variable, for example, no error
results unless the magnitude of the double precision value exceeds the
representable range of single-precision floating point numbers on your
platform. Similarly, if you read a large integer into a float
incapable of representing all the bits of the integer in its mantissa,
this loss of precision will not result in an error. If you want to
avoid such precision loss, check the external types of the variables
you access to make sure you use an internal type that has adequate
precision.

   <p>The names for the primitive external data types (byte, char, short,
ushort, int, uint, int64, uint64, float or real, double, string)
are reserved words in CDL, so the names of variables, dimensions, and
attributes must not be type names.

   <p>It is possible to interpret byte data as either signed (-128 to 127)
or unsigned (0 to 255). However, when reading byte data to be
converted into other numeric types, it is interpreted as signed.

   <p>For the correspondence between netCDF external data types and the data
types of a language see <a href="#Variables">Variables</a>.

<div class="node">
<a name="Classic-Data-Structures"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#User-Defined-Types">User Defined Types</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#External-Types">External Types</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Data">Data</a>

</div>

<h3 class="section">3.2 Data Structures in Classic and 64-bit Offset Files</h3>

<p><a name="index-data-structures-137"></a><a name="index-structures_002c-data-138"></a>
The only kind of data structure directly supported by the netCDF
classic (and 64-bit offset) abstraction is a collection of named
arrays with attached vector attributes. NetCDF is not particularly
well-suited for storing linked lists, trees, sparse matrices, ragged
arrays or other kinds of data structures requiring pointers.

   <p>It is possible to build other kinds of data structures in netCDF
classic or 64-bit offset formats, from sets of arrays by adopting
various conventions regarding the use of data in one array as pointers
into another array. The netCDF library won't provide much help or
hindrance with constructing such data structures, but netCDF provides
the mechanisms with which such conventions can be designed.

   <p>The following netCDF classic example stores a ragged array ragged_mat using an
attribute row_index to name an associated index variable giving the
index of the start of each row. In this example, the first row
contains 12 elements, the second row contains 7 elements (19 - 12),
and so on. (NetCDF-4 includes native support for variable length
arrays. See below.)

<pre class="example">             float   ragged_mat(max_elements);
                     ragged_mat:row_index = "row_start";
             int     row_start(max_rows);
     data:
             row_start   = 0, 12, 19, ...
</pre>
   <p>As another example, netCDF variables may be grouped within a netCDF
classic or 64-bit offset dataset by defining attributes that list the
names of the variables in each group, separated by a conventional
delimiter such as a space or comma. Using a naming convention for
attribute names for such groupings permits any number of named groups
of variables. A particular conventional attribute for each variable
might list the names of the groups of which it is a member. Use of
attributes, or variables that refer to other attributes or variables,
provides a flexible mechanism for representing some kinds of complex
structures in netCDF datasets.

<div class="node">
<a name="User-Defined-Types"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Data-Access">Data Access</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Classic-Data-Structures">Classic Data Structures</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Data">Data</a>

</div>

<h3 class="section">3.3 NetCDF-4 User Defined Data Types</h3>

<p><a name="index-compound-type-139"></a><a name="index-vlen-type-140"></a><a name="index-variable-length-array-type-141"></a><a name="index-opaque-type-142"></a><a name="index-enum-type-143"></a>
NetCDF supported six data types through version 3.6.0 (char, byte,
short, int, float, and double). Starting with version 4.0, many new
data types are supported (unsigned int types, strings, compound types,
variable length arrays, enums, opaque).

   <p>In addition to the new atomic types the user may define types.

   <p>Types are defined in define mode, and must be fully defined before
they are used. New types may be added to a file by re-entering define
mode.

   <p>Once defined the type may be used to create a variable or attribute.

   <p>Types may be nested in complex ways. For example, a compound type
containing an array of VLEN types, each containing variable length
arrays of some other compound type, etc. Users are cautioned to keep
types simple. Reading data of complex types can be challenging for
Fortran users.

   <p>Types may be defined in any group in the data file, but they are
always available globally in the file.

   <p>Types cannot have attributes (but variables of the type may have
attributes).

   <p>Only files created with the netCDF-4/HDF5 mode flag (NC_NETCDF4,
NF_NETCDF4, or NF90_NETCDF4), but without the classic model flag
(NC_CLASSIC_MODEL, NF_CLASSIC_MODEL, or NF90_CLASSIC_MODEL.)

   <p>Once types are defined, use their ID like any other type ID when
defining variables or attributes. Each API has functions to read and
write variables and attributes of any type. Use these functions to
read and write variables and attributes of user defined type. In C use
nc_put_att/nc_get_att and the nc_put_var/nc_get_var,
nc_put_var1/nc_get_var1, nc_put_vara/nc_get_vara, or
nc_put_vars/nc_get_vars functons to access attribute and variable data
of user defined type.

<h4 class="subsection">3.3.1 Compound Types</h4>

<p>Compound types allow the user to combine atomic and user-defined types
into C-like structs. Since users defined types may be used within a
compound type, they can contain nested compound types.

   <p>Users define a compound type, and (in their C code) a corresponding C
struct. They can then use the nc_put_var[1asm] calls to write
multi-dimensional arrays of these structs, and nc_get_var[1asm] calls
to read them. (For example, the nc_put_varm function will write mapped
arrays of these structs.)

   <p>While structs, in general, are not portable from platform to platform,
the HDF5 layer (when installed) performs the magic required to figure
out your platform's idiosyncrasies, and adjust to them. The end result
is that HDF5 compound types (and therefore, netCDF-4 compound types),
are portable.

   <p>For more information on creating and using compound types, see
<a href="netcdf-c.html#Compound-Types">Compound Types</a> in The NetCDF C Interface Guide.

<h4 class="subsection">3.3.2 VLEN Types</h4>

<p>Variable length arrays can be used to create a ragged array of data,
in which one of the dimensions varies in size from point to point.

   <p>An example of VLEN use would the to store a 1-D array of dropsonde
data, in which the data at each drop point is of variable length.

   <p>There is no special restriction on the dimensionality of VLEN
variables. It's possible to have 2D, 3D, 4D, etc. data, in which each
point contains a VLEN.

   <p>A VLEN has a base type (that is, the type that it is a VLEN of). This
may be one of the atomic types (forming, for example, a variable
length array of NC_INT), or it can be another user defined type, like
a compound type.

   <p>With VLEN data, special memory allocation and deallocation procedures
must be followed, or memory leaks may occur.

   <p>Compression is permitted but may not be effective for VLEN data,
because the compression is applied to structures containing lengths
and pointers to the data, rather than the actual data.

   <p>For more information on creating and using variable length arrays, see
<a href="netcdf-c.html#Variable-Length-Arrays">Variable Length Arrays</a> in
The NetCDF C Interface Guide.

<h4 class="subsection">3.3.3 Opaque Types</h4>

<p>Opaque types allow the user to store arrays of data blobs of a fixed
size.

   <p>For more information on creating and using opaque types, see
<a href="netcdf-c.html#Opaque-Type">Opaque Type</a> in The NetCDF C Interface Guide.

<h4 class="subsection">3.3.4 Enum Types</h4>

<p>Enum types allow the user to specify an enumeration.

   <p>For more information on creating and using enum types, see <a href="netcdf-c.html#Enum-Type">Enum Type</a> in The NetCDF C Interface Guide.

<h4 class="subsection">3.3.5 Groups</h4>

<p>Although not a type of data, groups can help organize data within a
dataset. Like a directory structure on a Unix file-system, the
grouping feature allows users to organize variables and dimensions
into distinct, named, hierarchical areas, called groups. For more
information on groups types, see <a href="netcdf-c.html#Groups">Groups</a> in The NetCDF C Interface Guide.

<div class="node">
<a name="Data-Access"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Type-Conversion">Type Conversion</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#User-Defined-Types">User Defined Types</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Data">Data</a>

</div>

<h3 class="section">3.4 Data Access</h3>

<p><a name="index-data_002c-reading-144"></a><a name="index-data_002c-writing-145"></a><a name="index-access-random-146"></a>
To access (read or write) netCDF data you specify an open netCDF
dataset, a netCDF variable, and information (e.g., indices)
identifying elements of the variable. The name of the access function
corresponds to the internal type of the data. If the internal type has
a different representation from the external type of the variable, a
conversion between the internal type and external type will take place
when the data is read or written.

   <p>Access to data in classic and 64-bit offset format is direct. Access
to netCDF-4 data is buffered by the HDF5 layer. In either case you can
access a small subset of data from a large dataset efficiently,
without first accessing all the data that precedes it.

   <p>Reading and writing data by specifying a variable, instead of a
position in a file, makes data access independent of how many other
variables are in the dataset, making programs immune to data format
changes that involve adding more variables to the data.

   <p>In the C and FORTRAN interfaces, datasets are not specified by name
every time you want to access data, but instead by a small integer
called a dataset ID, obtained when the dataset is first created or
opened.

   <p>Similarly, a variable is not specified by name for every data access
either, but by a variable ID, a small integer used to identify each
variable in a netCDF dataset.

<h4 class="subsection">3.4.1 Forms of Data Access</h4>

<p><a name="index-array-section_002c-corner-147"></a><a name="index-array-section_002c-definition-148"></a><a name="index-array-section_002c-edges-149"></a><a name="index-array-section_002c-mapped-150"></a>
The netCDF interface supports several forms of direct access to data
values in an open netCDF dataset. We describe each of these forms of
access in order of increasing generality:

     <ul>
<li>access to all elements;

     <li>access to individual elements, specified with an index vector;

     <li>access to array sections, specified with an index vector, and count
vector;

     <li>access to sub-sampled array sections, specified with an index vector,
count vector, and stride vector; and

     <li>access to mapped array sections, specified with an index vector, count
vector, stride vector, and an index mapping vector.

   </ul>

   <p>The four types of vector (index vector, count vector, stride vector
and index mapping vector) each have one element for each dimension of
the variable. Thus, for an n-dimensional variable (rank = n),
n-element vectors are needed. If the variable is a scalar (no
dimensions), these vectors are ignored.

   <p>An array section is a "slab" or contiguous rectangular block that is
specified by two vectors. The index vector gives the indices of the
element in the corner closest to the origin. The count vector gives
the lengths of the edges of the slab along each of the variable's
dimensions, in order. The number of values accessed is the product of
these edge lengths.

   <p>A subsampled array section is similar to an array section, except that
an additional stride vector is used to specify sampling. This vector
has an element for each dimension giving the length of the strides to
be taken along that dimension. For example, a stride of 4 means every
fourth value along the corresponding dimension. The total number of
values accessed is again the product of the elements of the count
vector.

   <p>A mapped array section is similar to a subsampled array section except
that an additional index mapping vector allows one to specify how data
values associated with the netCDF variable are arranged in memory. The
offset of each value from the reference location, is given by the sum
of the products of each index (of the imaginary internal array which
would be used if there were no mapping) by the corresponding element
of the index mapping vector. The number of values accessed is the same
as for a subsampled array section.

   <p>The use of mapped array sections is discussed more fully below, but
first we present an example of the more commonly used array-section
access.

<ul class="menu">
<li><a accesskey="1" href="#C-Section-Access">C Section Access</a>:             A C Example
<li><a accesskey="2" href="#Fortran-Section-Access">Fortran Section Access</a>:       A Fortran Example
</ul>

<div class="node">
<a name="C-Section-Access"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Fortran-Section-Access">Fortran Section Access</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Data-Access">Data Access</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Data-Access">Data Access</a>

</div>

<h4 class="subsection">3.4.2 A C Example of Array-Section Access</h4>

<p><a name="index-access-C-example-of-array-section-151"></a><a name="index-array-section_002c-C-example-152"></a>
Assume that in our earlier example of a netCDF dataset (see <a href="#Data-Model">Network Common Data Form Language (CDL)</a>), we wish to read a
cross-section of all the data for the temp variable at one level (say,
the second), and assume that there are currently three records (time
values) in the netCDF dataset. Recall that the dimensions are defined
as

<pre class="example">       lat = 5, lon = 10, level = 4, time = unlimited;
</pre>
   <p>and the variable temp is declared as

<pre class="example">       float   temp(time, level, lat, lon);
</pre>
   <p>in the CDL notation.

   <p>A corresponding C variable that holds data for only one level might be
declared as

<pre class="example">     #define LATS  5
     #define LONS 10
     #define LEVELS 1
     #define TIMES 3                 /* currently */
         ...
     float   temp[TIMES*LEVELS*LATS*LONS];
     
     to keep the data in a one-dimensional array, or
     
         ...
     float   temp[TIMES][LEVELS][LATS][LONS];
</pre>
   <p>using a multidimensional array declaration.

   <p>To specify the block of data that represents just the second level,
all times, all latitudes, and all longitudes, we need to provide a
start index and some edge lengths. The start index should be (0, 1, 0,
0) in C, because we want to start at the beginning of each of the
time, lon, and lat dimensions, but we want to begin at the second
value of the level dimension. The edge lengths should be (3, 1, 5, 10)
in C, (since we want to get data for all three time values, only one
level value, all five lat values, and all 10 lon values. We should
expect to get a total of 150 floating-point values returned (3 * 1 * 5
* 10), and should provide enough space in our array for this many. The
order in which the data will be returned is with the last dimension,
lon, varying fastest:

<pre class="example">          temp[0][1][0][0]
          temp[0][1][0][1]
          temp[0][1][0][2]
          temp[0][1][0][3]
     
                ...
     
          temp[2][1][4][7]
          temp[2][1][4][8]
          temp[2][1][4][9]
</pre>
   <p>Different dimension orders for the C, FORTRAN, or other language
interfaces do not reflect a different order for values stored on the
disk, but merely different orders supported by the procedural
interfaces to the languages. In general, it does not matter whether a
netCDF dataset is written using the C, FORTRAN, or another language
interface; netCDF datasets written from any supported language may be
read by programs written in other supported languages.

<h4 class="subsection">3.4.3 More on General Array Section Access for C</h4>

<p>The use of mapped array sections allows non-trivial relationships
between the disk addresses of variable elements and the addresses
where they are stored in memory. For example, a matrix in memory could
be the transpose of that on disk, giving a quite different order of
elements. In a regular array section, the mapping between the disk and
memory addresses is trivial: the structure of the in-memory values
(i.e., the dimensional lengths and their order) is identical to that
of the array section. In a mapped array section, however, an index
mapping vector is used to define the mapping between indices of netCDF
variable elements and their memory addresses.

   <p>With mapped array access, the offset (number of array elements) from
the origin of a memory-resident array to a particular point is given
by the inner product[1] of the index mapping vector with the point's
coordinate offset vector. A point's coordinate offset vector gives,
for each dimension, the offset from the origin of the containing array
to the point.In C, a point's coordinate offset vector is the same as
its coordinate vector.

   <p>The index mapping vector for a regular array section would have&ndash;in
order from most rapidly varying dimension to most slowly&ndash;a constant
1, the product of that value with the edge length of the most rapidly
varying dimension of the array section, then the product of that value
with the edge length of the next most rapidly varying dimension, and
so on. In a mapped array, however, the correspondence between netCDF
variable disk locations and memory locations can be different.

   <p>For example, the following C definitions

<pre class="example">     struct vel {
         int flags;
         float u;
         float v;
     } vel[NX][NY];
     ptrdiff_t imap[2] = {
         sizeof(struct vel),
         sizeof(struct vel)*NY
     };
</pre>
   <p>where imap is the index mapping vector, can be used to access the
memory-resident values of the netCDF variable, vel(NY,NX), even though
the dimensions are transposed and the data is contained in a 2-D array
of structures rather than a 2-D array of floating-point values.

   <p>A detailed example of mapped array access is presented in the
description of the interfaces for mapped array
access. See <a href="netcdf-c.html#nc_005fput_005fvarm_005f-type">Write a Mapped Array of Values - nc_put_varm_ type</a>.

   <p>Note that, although the netCDF abstraction allows the use of
subsampled or mapped array-section access there use is not
required. If you do not need these more general forms of access, you
may ignore these capabilities and use single value access or regular
array section access instead.

<div class="node">
<a name="Fortran-Section-Access"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#C-Section-Access">C Section Access</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Data-Access">Data Access</a>

</div>

<h4 class="subsection">3.4.4 A Fortran Example of Array-Section Access</h4>

<p><a name="index-access-Fortran-example-of-array-section-153"></a><a name="index-array-section_002c-Fortran-example-154"></a>
Assume that in our earlier example of a netCDF dataset (see <a href="#Data-Model">Data Model</a>), we wish to read a cross-section of all the data for the temp
variable at one level (say, the second), and assume that there are
currently three records (time values) in the netCDF dataset. Recall
that the dimensions are defined as

<pre class="example">       lat = 5, lon = 10, level = 4, time = unlimited;
</pre>
   <p>and the variable temp is declared as

<pre class="example">       float   temp(time, level, lat, lon);
</pre>
   <p>in the CDL notation.

   <p>In FORTRAN, the dimensions are reversed from the CDL declaration with
the first dimension varying fastest and the record dimension as the
last dimension of a record variable. Thus a FORTRAN declarations for a
variable that holds data for only one level is

<pre class="example">     INTEGER LATS, LONS, LEVELS, TIMES
     PARAMETER (LATS=5, LONS=10, LEVELS=1, TIMES=3)
        ...
     REAL TEMP(LONS, LATS, LEVELS, TIMES)
</pre>
   <p>To specify the block of data that represents just the second level,
all times, all latitudes, and all longitudes, we need to provide a
start index and some edge lengths. The start index should be (1, 1, 2,
1) in FORTRAN, because we want to start at the beginning of each of
the time, lon, and lat dimensions, but we want to begin at the second
value of the level dimension. The edge lengths should be (10, 5, 1, 3)
in FORTRAN, since we want to get data for all three time values, only
one level value, all five lat values, and all 10 lon values. We should
expect to get a total of 150 floating-point values returned (3 * 1 * 5
* 10), and should provide enough space in our array for this many. The
order in which the data will be returned is with the first dimension,
LON, varying fastest:

<pre class="example">          TEMP( 1, 1, 2, 1)
          TEMP( 2, 1, 2, 1)
          TEMP( 3, 1, 2, 1)
          TEMP( 4, 1, 2, 1)
     
                ...
     
          TEMP( 8, 5, 2, 3)
          TEMP( 9, 5, 2, 3)
          TEMP(10, 5, 2, 3)
</pre>
   <p>Different dimension orders for the C, FORTRAN, or other language
interfaces do not reflect a different order for values stored on the
disk, but merely different orders supported by the procedural
interfaces to the languages. In general, it does not matter whether a
netCDF dataset is written using the C, FORTRAN, or another language
interface; netCDF datasets written from any supported language may be
read by programs written in other supported languages.

<h4 class="subsection">3.4.5 More on General Array Section Access for Fortran</h4>

<p>The use of mapped array sections allows non-trivial relationships
between the disk addresses of variable elements and the addresses
where they are stored in memory. For example, a matrix in memory could
be the transpose of that on disk, giving a quite different order of
elements. In a regular array section, the mapping between the disk and
memory addresses is trivial: the structure of the in-memory values
(i.e., the dimensional lengths and their order) is identical to that
of the array section. In a mapped array section, however, an index
mapping vector is used to define the mapping between indices of netCDF
variable elements and their memory addresses.

   <p>With mapped array access, the offset (number of array elements) from
the origin of a memory-resident array to a particular point is given
by the inner product[1] of the index mapping vector with the point's
coordinate offset vector. A point's coordinate offset vector gives,
for each dimension, the offset from the origin of the containing array
to the point. In FORTRAN, the values of a point's coordinate offset
vector are one less than the corresponding values of the point's
coordinate vector, e.g., the array element A(3,5) has coordinate
offset vector [2, 4].

   <p>The index mapping vector for a regular array section would have&ndash;in
order from most rapidly varying dimension to most slowly&ndash;a constant
1, the product of that value with the edge length of the most rapidly
varying dimension of the array section, then the product of that value
with the edge length of the next most rapidly varying dimension, and
so on. In a mapped array, however, the correspondence between netCDF
variable disk locations and memory locations can be different.

   <p>A detailed example of mapped array access is presented in the
description of the interfaces for mapped array
access. See <a href="netcdf-f77.html#nf_005fput_005fvarm_005f-type">nf_put_varm_ type</a>.

   <p>Note that, although the netCDF abstraction allows the use of
subsampled or mapped array-section access there use is not
required. If you do not need these more general forms of access, you
may ignore these capabilities and use single value access or regular
array section access instead.

<div class="node">
<a name="Type-Conversion"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Data-Access">Data Access</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Data">Data</a>

</div>

<h3 class="section">3.5 Type Conversion</h3>

<p><a name="index-type-conversion-155"></a><a name="index-byte-array-vs_002e-text-string-156"></a><a name="index-data-types_002c-conversion-157"></a>
Each netCDF variable has an external type, specified when the variable
is first defined. This external type determines whether the data is
intended for text or numeric values, and if numeric, the range and
precision of numeric values.

   <p>If the netCDF external type for a variable is char, only character
data representing text strings can be written to or read from the
variable. No automatic conversion of text data to a different
representation is supported.

   <p>If the type is numeric, however, the netCDF library allows you to
access the variable data as a different type and provides automatic
conversion between the numeric data in memory and the data in the
netCDF variable. For example, if you write a program that deals with
all numeric data as double-precision floating point values, you can
read netCDF data into double-precision arrays without knowing or
caring what the external type of the netCDF variables are. On reading
netCDF data, integers of various sizes and single-precision
floating-point values will all be converted to double-precision, if
you use the data access interface for double-precision values. Of
course, you can avoid automatic numeric conversion by using the netCDF
interface for a value type that corresponds to the external data type
of each netCDF variable, where such value types exist.

   <p>The automatic numeric conversions performed by netCDF are easy to
understand, because they behave just like assignment of data of one
type to a variable of a different type. For example, if you read
floating-point netCDF data as integers, the result is truncated
towards zero, just as it would be if you assigned a floating-point
value to an integer variable. Such truncation is an example of the
loss of precision that can occur in numeric conversions.

   <p>Converting from one numeric type to another may result in an error if
the target type is not capable of representing the converted
value. For example, an integer may not be able to hold data stored
externally as an IEEE floating-point number. When accessing an array
of values, a range error is returned if one or more values are out of
the range of representable values, but other values are converted
properly.

   <p>Note that mere loss of precision in type conversion does not result in
an error. For example, if you read double precision values into an
integer, no error results unless the magnitude of the double precision
value exceeds the representable range of integers on your
platform. Similarly, if you read a large integer into a float
incapable of representing all the bits of the integer in its mantissa,
this loss of precision will not result in an error. If you want to
avoid such precision loss, check the external types of the variables
you access to make sure you use an internal type that has a compatible
precision.

   <p>Whether a range error occurs in writing a large floating-point value
near the boundary of representable values may be depend on the
platform. The largest floating-point value you can write to a netCDF
float variable is the largest floating-point number representable on
your system that is less than 2 to the 128th power. The largest double
precision value you can write to a double variable is the largest
double-precision number representable on your system that is less than
2 to the 1024th power.

<div class="node">
<a name="Structure"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#NetCDF-Utilities">NetCDF Utilities</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Data">Data</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">4 File Structure and Performance</h2>

<p><a name="index-file-structure_002c-overview-158"></a><a name="index-performance-of-NetCDF-159"></a>
This chapter describes the file structure of a netCDF classic or
64-bit offset dataset in enough detail to aid in understanding netCDF
performance issues.

   <p>NetCDF is a data abstraction for array-oriented data access and a
software library that provides a concrete implementation of the
interfaces that support that abstraction. The implementation provides
a machine-independent format for representing arrays. Although the
netCDF file format is hidden below the interfaces, some understanding
of the current implementation and associated file structure may help
to make clear why some netCDF operations are more expensive than
others.

   <p>Knowledge of the format is not needed for reading and writing netCDF
data or understanding most efficiency issues. Programs that use only
the documented interfaces and that make no assumptions about the
format will continue to work even if the netCDF format is changed in
the future, because any such change will be made below the documented
interfaces and will support earlier versions of the netCDF file
format.

<ul class="menu">
<li><a accesskey="1" href="#Classic-File-Parts">Classic File Parts</a>:           The Classic and 64-bit Offset File
<li><a accesskey="2" href="#NetCDF_002d4-File-Parts">NetCDF-4 File Parts</a>:          The NetCDF-4/HDF5 File
<li><a accesskey="3" href="#XDR-Layer">XDR Layer</a>:                    Classic Machine Interoperability
<li><a accesskey="4" href="#Large-File-Support">Large File Support</a>:           Files that Exceed 2 GiBytes
<li><a accesskey="5" href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a>:    Limitations on File and Data Size
<li><a accesskey="6" href="#Classic-Limitations">Classic Limitations</a>:          Limitations on File and Data Size
<li><a accesskey="7" href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a>:        Classic I/O Described
<li><a accesskey="8" href="#UNICOS-Optimization">UNICOS Optimization</a>:          Some Cray Optimizations
<li><a accesskey="9" href="#Chunking">Chunking</a>:                     NetCDF-4/HDF5 Files Read/Write Chunks
<li><a href="#Parallel-Access">Parallel Access</a>:              Parallel I/O with NetCDF-4
<li><a href="#Interoperability-with-HDF5">Interoperability with HDF5</a>:   Using HDF5 with NetCDF-4
<li><a href="#DAP-Support">DAP Support</a>
</ul>

<div class="node">
<a name="Classic-File-Parts"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#NetCDF_002d4-File-Parts">NetCDF-4 File Parts</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Structure">Structure</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.1 Parts of a NetCDF Classic File</h3>

<p><a name="index-classic-file-format-160"></a><a name="index-file-format_002c-classic-161"></a><a name="index-file-format_002c-64_002dbit-offset-162"></a><a name="index-g_t64_002dbit-offset-file-format-163"></a>
A netCDF classic or 64-bit offset dataset is stored as a single file
comprising two parts:

   <p>a header, containing all the information about dimensions, attributes,
and variables except for the variable data;

   <p>a data part, comprising fixed-size data, containing the data for
variables that don't have an unlimited dimension; and variable-size
data, containing the data for variables that have an unlimited
dimension.

   <p>Both the header and data parts are represented in a
machine-independent form. This form is very similar to XDR (eXternal
Data Representation), extended to support efficient storage of arrays
of non-byte data.

   <p>The header at the beginning of the file contains information about the
dimensions, variables, and attributes in the file, including their
names, types, and other characteristics. The information about each
variable includes the offset to the beginning of the variable's data
for fixed-size variables or the relative offset of other variables
within a record. The header also contains dimension lengths and
information needed to map multidimensional indices for each variable
to the appropriate offsets.

   <p>By default, this header has little usable extra space; it is only as
large as it needs to be for the dimensions, variables, and attributes
(including all the attribute values) in the netCDF dataset, with a
small amount of extra space from rounding up to the nearest disk block
size. This has the advantage that netCDF files are compact, requiring
very little overhead to store the ancillary data that makes the
datasets self-describing. A disadvantage of this organization is that
any operation on a netCDF dataset that requires the header to grow
(or, less likely, to shrink), for example adding new dimensions or new
variables, requires moving the data by copying it. This expense is
incurred when the enddef function is called: nc_enddef in C
(see <a href="netcdf-c.html#nc_005fenddef">nc_enddef</a>), NF_ENDDEF in Fortran
(see <a href="netcdf-f77.html#NF_005fENDDEF">NF_ENDDEF</a>), after a previous
call to the redef function: nc_redef in C (see <a href="netcdf-c.html#nc_005fredef">nc_redef</a>) or NF_REDEF in Fortran (see <a href="netcdf-f77.html#NF_005fREDEF">NF_REDEF</a>). If you create all necessary dimensions,
variables, and attributes before writing data, and avoid later
additions and renamings of netCDF components that require more space
in the header part of the file, you avoid the cost associated with
later changing the header.

   <p>Alternatively, you can use an alternative version of the enddef
function with two underbar characters instead of one to explicitly
reserve extra space in the file header when the file is created: in C
nc__enddef (see <a href="netcdf-c.html#nc_005f_005fenddef">nc__enddef</a>), in Fortran
NF__ENDDEF (see <a href="netcdf-f77.html#NF_005f_005fENDDEF">NF__ENDDEF</a>), after
a previous call to the redef function.  This avoids the expense of
moving all the data later by reserving enough extra space in the
header to accommodate anticipated changes, such as the addition of new
attributes or the extension of existing string attributes to hold
longer strings.

   <p>When the size of the header is changed, data in the file is moved, and
the location of data values in the file changes. If another program is
reading the netCDF dataset during redefinition, its view of the file
will be based on old, probably incorrect indexes. If netCDF datasets
are shared across redefinition, some mechanism external to the netCDF
library must be provided that prevents access by readers during
redefinition, and causes the readers to call nc_sync/NF_SYNC before
any subsequent access.

   <p>The fixed-size data part that follows the header contains all the
variable data for variables that do not employ an unlimited
dimension. The data for each variable is stored contiguously in this
part of the file. If there is no unlimited dimension, this is the last
part of the netCDF file.

   <p>The record-data part that follows the fixed-size data consists of a
variable number of fixed-size records, each of which contains data for
all the record variables. The record data for each variable is stored
contiguously in each record.

   <p>The order in which the variable data appears in each data section is
the same as the order in which the variables were defined, in
increasing numerical order by netCDF variable ID. This knowledge can
sometimes be used to enhance data access performance, since the best
data access is currently achieved by reading or writing the data in
sequential order.

   <p>For more detail see <a href="#File-Format">File Format</a>.

<div class="node">
<a name="NetCDF-4-File-Parts"></a>
<a name="NetCDF_002d4-File-Parts"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#XDR-Layer">XDR Layer</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Classic-File-Parts">Classic File Parts</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.2 Parts of a NetCDF-4 HDF5 File</h3>

<p><a name="index-netcdf_002d4-file-format-164"></a><a name="index-file-format_002c-netcdf_002d4-165"></a>
NetCDF-4 files are created with the HDF5 library, and are HDF5 files
in every way, and can be read without the netCDF-4 interface. (Note
that modifying these files with HDF5 will almost certainly make them
unreadable to netCDF-4.)

   <p>Groups in a netCDF-4 file correspond with HDF5 groups (although the
netCDF-4 tree is rooted not at the HDF5 root, but in group
&ldquo;_netCDF&rdquo;).

   <p>Variables in netCDF coo-respond with identically named datasets in
HDF5. Attributes similarly.

   <p>Since there is more metadata in a netCDF file than an HDF5 file,
special datasets are used to hold netCDF metadata.

   <p>The _netcdf_dim_info dataset (in group _netCDF) contains the ids of
the shared dimensions, and their length (0 for unlimited dimensions).

   <p>The _netcdf_var_info dataset (in group _netCDF) holds an array of
compound types which contain the variable ID, and the associated
dimension ids.

<div class="node">
<a name="XDR-Layer"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Large-File-Support">Large File Support</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#NetCDF_002d4-File-Parts">NetCDF-4 File Parts</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.3 The Extended XDR Layer</h3>

<p><a name="index-XDR-layer-166"></a>
XDR is a standard for describing and encoding data and a library of
functions for external data representation, allowing programmers to
encode data structures in a machine-independent way. Classic or 64-bit
offset netCDF employs an extended form of XDR for representing
information in the header part and the data parts. This extended XDR
is used to write portable data that can be read on any other machine
for which the library has been implemented.

   <p>The cost of using a canonical external representation for data varies
according to the type of data and whether the external form is the
same as the machine's native form for that type.

   <p>For some data types on some machines, the time required to convert
data to and from external form can be significant. The worst case is
reading or writing large arrays of floating-point data on a machine
that does not use IEEE floating-point as its native representation.

<div class="node">
<a name="Large-File-Support"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#XDR-Layer">XDR Layer</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.4 Large File Support</h3>

<p><a name="index-large-file-support-167"></a><a name="index-g_t64_002dbit-offset-format_002c-introduction-168"></a><a name="index-classic-format_002c-introduction-169"></a><a name="index-LFS-170"></a><a name="index-CDF1-171"></a><a name="index-CDF2-172"></a>
It is possible to write netCDF files that exceed 2 GiByte on platforms
that have "Large File Support" (LFS). Such files are
platform-independent to other LFS platforms, but trying to open them
on an older platform without LFS yields a "file too large" error.

   <p>Without LFS, no files larger than 2 GiBytes can be used. The rest of
this section applies only to systems with LFS.

   <p>The original binary format of netCDF (classic format) limits the size
of data files by using a signed 32-bit offset within its internal
structure. Files larger than 2 GiB can be created, with certain
limitations. See <a href="#Classic-Limitations">Classic Limitations</a>.

   <p>In version 3.6.0, netCDF included its first-ever variant of the underlying
data format.  The new format introduced in 3.6.0 uses 64-bit file offsets
in place of the 32-bit offsets. There are still some limits on the sizes
of variables, but the new format can create very large
datasets. See <a href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a>.

   <p>NetCDF-4 variables and files can be any size supported by the
underlying file system.

   <p>The original data format (netCDF classic), is still the default data
format for the netCDF library.

   <p>The following table summarizes the size limitations of various
permutations of LFS support, netCDF version, and data format. Note
that 1 GiB = 2^30 bytes or about 1.07e+9 bytes, 1 EiB = 2^60 bytes or
about 1.15e+18 bytes. Note also that all sizes
are really 4 bytes less than the ones given below. For example the
maximum size of a fixed variable in netCDF 3.6 classic format is
really 2 GiB - 4 bytes.

   <p><table summary="">
<tr align="left"><td valign="top" width="25%">Limit </td><td valign="top" width="15%">No LFS </td><td valign="top" width="15%">v3.5 </td><td valign="top" width="15%">v3.6/classic </td><td valign="top" width="15%">v3.6/64-bit
offset </td><td valign="top" width="15%">v4.0/netCDF-4

<p><br></td></tr><tr align="left"><td valign="top" width="25%">Max File Size </td><td valign="top" width="15%">2 GiB </td><td valign="top" width="15%">8 EiB </td><td valign="top" width="15%">8 EiB </td><td valign="top" width="15%">8 EiB </td><td valign="top" width="15%">??

<p><br></td></tr><tr align="left"><td valign="top" width="25%">Max Number of Fixed Vars &gt; 2 GiB </td><td valign="top" width="15%">0 </td><td valign="top" width="15%">1 (last) </td><td valign="top" width="15%">1
(last) </td><td valign="top" width="15%">2^32 </td><td valign="top" width="15%">??

<p><br></td></tr><tr align="left"><td valign="top" width="25%">Max Record Vars w/ Rec Size &gt; 2 GiB </td><td valign="top" width="15%">0 </td><td valign="top" width="15%">1 (last) </td><td valign="top" width="15%">1
(last) </td><td valign="top" width="15%">2^32 </td><td valign="top" width="15%">??

<p><br></td></tr><tr align="left"><td valign="top" width="25%">Max Size of Fixed/Record Size of Record Var </td><td valign="top" width="15%">2 GiB </td><td valign="top" width="15%">2
GiB </td><td valign="top" width="15%">2 GiB </td><td valign="top" width="15%">4 GiB </td><td valign="top" width="15%">??

<p><br></td></tr><tr align="left"><td valign="top" width="25%">Max Record Size </td><td valign="top" width="15%">2 GiB/nrecs </td><td valign="top" width="15%">4 GiB </td><td valign="top" width="15%">8 EiB/nrecs
</td><td valign="top" width="15%">8 EiB/nrecs </td><td valign="top" width="15%">??

   <br></td></tr></table>

   <p>For more information about the different file formats of netCDF
See <a href="#Which-Format">Which Format</a>.

<div class="node">
<a name="g_t64-bit-Offset-Limitations"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Classic-Limitations">Classic Limitations</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Large-File-Support">Large File Support</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.5 NetCDF 64-bit Offset Format Limitations</h3>

<p><a name="index-g_t64_002dbit-offset-format_002c-limitations-173"></a>
Although the 64-bit offset format allows the creation of much larger
netCDF files than was possible with the classic format, there are
still some restrictions on the size of variables.

   <p>It's important to note that without Large File Support (LFS) in the
operating system, it's impossible to create any file larger than 2
GiBytes.  Assuming an operating system with LFS, the following
restrictions apply to the netCDF 64-bit offset format.

   <p>No fixed-size variable can require more than 2^32 - 4 bytes (i.e. 4GiB
- 4 bytes, or 4,294,967,292 bytes) of storage for its data, unless it is the
last fixed-size variable and there are no record variables. When there
are no record variables, the last fixed-size variable can be any size
supported by the file system, e.g. terabytes.

   <p>A 64-bit offset format netCDF file can have up to 2^32 - 1 fixed sized
variables, each under 4GiB in size. If there are no record variables
in the file the last fixed variable can be any size.

   <p>No record variable can require more than 2^32 - 4 bytes of storage for
each record's worth of data, unless it is the last record variable. 
A 64-bit offset format netCDF file can have up to 2^32 - 1 records, of
up to 2^32 - 1 variables, as long as the size of one record's data for
each record variable except the last is less than 4 GiB - 4.

   <p>Note also that all netCDF variables and records are padded to 4 byte
boundaries.

<div class="node">
<a name="Classic-Limitations"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.6 NetCDF Classic Format Limitations</h3>

<p><a name="index-classic-format_002c-limitations-174"></a>
There are important constraints on the structure of large netCDF
classic files that result from the 32-bit relative offsets that are
part of the netCDF classic file format:

   <p>The maximum size of a record in the classic format in versions 3.5.1
and earlier is 2^32 - 4 bytes, or about 4 GiB.  In versions 3.6.0 and
later, there is no such restriction on total record size for the classic
format or 64-bit offset format.

   <p>If you don't use the unlimited dimension, only one variable can exceed
2 GiB in size, but it can be as large as the underlying file system
permits. It must be the last variable in the dataset, and the offset
to the beginning of this variable must be less than about 2
GiB.

   <p>The limit is really 2^31 - 4.  If you were to specify a variable
size of 2^31 -3, for example, it would be rounded up to the nearest
multiple of 4 bytes, which would be 2^31, which is larger than the
largest signed integer, 2^31 - 1.

   <p>For example, the structure of the data might be something like:

<pre class="example">     netcdf bigfile1 {
         dimensions:
            x=2000;
            y=5000;
            z=10000;
         variables:
            double x(x);         // coordinate variables
            double y(y);
            double z(z);
            double var(x, y, z); // 800 Gbytes
         }
</pre>
   <p>If you use the unlimited dimension, record variables may
exceed 2 GiB in size, as long as the offset of the start of each
record variable within a record is less than 2 GiB - 4. For
example, the structure of the data in a 2.4 Tbyte file might be
something like:

<pre class="example">     netcdf bigfile2 {
         dimensions:
            x=2000;
            y=5000;
            z=10;
            t=UNLIMITED;         // 1000 records, for example
         variables:
            double x(x);         // coordinate variables
            double y(y);
            double z(z);
            double t(t);
                                 // 3 record variables, 2400000000 bytes per record
            double var1(t, x, y, z);
            double var2(t, x, y, z);
            double var3(t, x, y, z);
         }
</pre>
   <div class="node">
<a name="The-NetCDF-3-IO-Layer"></a>
<a name="The-NetCDF_002d3-IO-Layer"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#UNICOS-Optimization">UNICOS Optimization</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Classic-Limitations">Classic Limitations</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.7 The NetCDF-3 I/O Layer</h3>

<p><a name="index-I_002fO-layer-175"></a><a name="index-access-shared-dataset-I_002fO-176"></a><a name="index-shared-dataset-I_002fO-access-177"></a><a name="index-buffers_002c-I_002fO-178"></a><a name="index-NC_005fSHARE-179"></a><a name="index-NF_005fSHARE-180"></a><a name="index-share-flag-181"></a><a name="index-NF_005fSYNC-182"></a><a name="index-nc_005fsync-183"></a><a name="index-fflush-184"></a><a name="index-flushing-buffers-185"></a><a name="index-g_t_005fIONBF-flag-186"></a>

   <p>The following discussion applies only to netCDF classic and 64-bit
offset files. For netCDF-4 files, the I/O layer is the HDF5 library.

   <p>For netCDF classic and 64-bit offset files, an I/O layer implemented
much like the C standard I/O (stdio) library is used by netCDF to read
and write portable data to netCDF datasets. Hence an understanding of
the standard I/O library provides answers to many questions about
multiple processes accessing data concurrently, the use of I/O
buffers, and the costs of opening and closing netCDF files. In
particular, it is possible to have one process writing a netCDF
dataset while other processes read it.

   <p>Data reads and writes are no more atomic than calls to stdio fread()
and fwrite(). An nc_sync/NF_SYNC call is analogous to the fflush call
in the C standard I/O library, writing unwritten buffered data so
other processes can read it; The C function nc_sync (see <a href="netcdf-c.html#nc_005fsync">nc_sync</a>), or the Fortran function NF_SYNC
(see <a href="netcdf-f77.html#NF_005fSYNC">NF_SYNC</a>), also brings header
changes up-to-date (for example, changes to attribute values). Opening
the file with the NC_SHARE (in C) or the NF_SHARE (in Fortran) is
analogous to setting a stdio stream to be unbuffered with the _IONBF
flag to setvbuf.

   <p>As in the stdio library, flushes are also performed when "seeks" occur
to a different area of the file. Hence the order of read and write
operations can influence I/O performance significantly. Reading data
in the same order in which it was written within each record will
minimize buffer flushes.

   <p>You should not expect netCDF classic or 64-bit offset format data
access to work with multiple writers having the same file open for
writing simultaneously.

   <p>It is possible to tune an implementation of netCDF for some platforms
by replacing the I/O layer with a different platform-specific I/O
layer. This may change the similarities between netCDF and standard
I/O, and hence characteristics related to data sharing, buffering, and
the cost of I/O operations.

   <p>The distributed netCDF implementation is meant to be
portable. Platform-specific ports that further optimize the
implementation for better I/O performance are practical in some cases.

<div class="node">
<a name="UNICOS-Optimization"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Chunking">Chunking</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.8 UNICOS Optimization</h3>

<p><a name="index-UNICOS-187"></a><a name="index-NETCDF_005fFFIOSPEC-188"></a>
It should be noted that no UNICOS platform has been available at
Unidata for netCDF testing for some years. The following information
is left here for historical reasons.

   <p>As was mentioned in the previous section, it is possible to replace
the I/O layer in order to increase I/O efficiency. This has been done
for UNICOS, the operating system of Cray computers similar to the Cray
Y-MP.

   <p>Additionally, it is possible for the user to obtain even greater I/O
efficiency through appropriate setting of the NETCDF_FFIOSPEC
environment variable. This variable specifies the Flexible File I/O
buffers for netCDF I/O when executing under the UNICOS operating
system (the variable is ignored on other operating systems). An
appropriate specification can greatly increase the efficiency of
netCDF I/O&ndash;to the extent that it can surpass default FORTRAN binary
I/O. Possible specifications include the following:

     <dl>
<dt><code>bufa:336:2</code><dd>2, asynchronous, I/O buffers of 336 blocks each (i.e., double
buffering). This is the default specification and favors sequential
I/O.

     <br><dt><code>cache:256:8</code><dd>8, synchronous, 256-block buffers. This favors larger random accesses.

     <br><dt><code>cachea:256:8:2</code><dd>8, asynchronous, 256-block buffers with a 2 block
read-ahead/write-behind factor. This also favors larger random
accesses.

     <br><dt><code>cachea:8:256:0</code><dd>256, asynchronous, 8-block buffers without
read-ahead/write-behind. This favors many smaller pages without
read-ahead for more random accesses as typified by slicing netCDF
arrays.

     <br><dt><code>cache:8:256,cachea.sds:1024:4:1</code><dd>This is a two layer cache. The first (synchronous) layer is composed
of 256 8-block buffers in memory, the second (asynchronous) layer is
composed of 4 1024-block buffers on the SSD. This scheme works well
when accesses proceed through the dataset in random waves roughly
2x1024-blocks wide.

   </dl>

   <p>All of the options/configurations supported in CRI's FFIO library are
available through this mechanism. We recommend that you look at CRI's
I/O optimization guide for information on using FFIO to its
fullest. This mechanism is also compatible with CRI's EIE I/O library.

   <p>Tuning the NETCDF_FFIOSPEC variable to a program's I/O pattern can
dramatically improve performance. Speedups of two orders of magnitude
have been seen.

<div class="node">
<a name="Chunking"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Parallel-Access">Parallel Access</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#UNICOS-Optimization">UNICOS Optimization</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.9 Improving Performance With Chunking</h3>

<p><a name="index-chunking-189"></a><a name="index-deflation-190"></a><a name="index-shuffle-filter-191"></a>
NetCDF may use HDF5 as a storage format (when files are created with
NC_NETCDF4/NF_NETCDF4/NF90_NETCDF4). For those files, the writer may
control the size of the chunks of data that are written to the HDF5,
along with other aspects of the data, such as endianness, a shuffle
and checksum filter, on-the-fly compression/decompression of the data.

   <p>The chunk sizes of a variable are specified after the variable is
defined, but before any data are written. If chunk sizes are not
specified for a variable, default chunk sizes are chosen by the
library.

   <p>The selection of good chunk sizes is a complex topic, and one that data
writers must grapple with. Once the data are written, there is no way
to change the chunk sizes except to copy the data to a new variable.

   <p>Chunks should match read access patterns; the best chunk performance
can be achieved by writing chunks which exactly match the size of the
subsets of data that will be read. When multiple read access patterns
are to be used, there is no one way to best set the chunk sizes.

   <p>Some good discussion of chunking can be found in the HDF5-EOS XIII
workshop presentation (<a href="http://hdfeos.org/workshops/ws13/presentations/day1/HDF5-EOSXIII-Advanced-Chunking.ppt">http://hdfeos.org/workshops/ws13/presentations/day1/HDF5-EOSXIII-Advanced-Chunking.ppt</a>).

<ul class="menu">
<li><a accesskey="1" href="#Chunk-Cache">Chunk Cache</a>
<li><a accesskey="2" href="#Default-Chunking">Default Chunking</a>
<li><a accesskey="3" href="#Default-Chunking-4_005f0_005f1">Default Chunking 4_0_1</a>
<li><a accesskey="4" href="#Parallel-Chunking">Parallel Chunking</a>
<li><a accesskey="5" href="#bm_005ffile">bm_file</a>
</ul>

<div class="node">
<a name="Chunk-Cache"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Default-Chunking">Default Chunking</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Chunking">Chunking</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Chunking">Chunking</a>

</div>

<h4 class="subsection">4.9.1 The Chunk Cache</h4>

<p>When data are first read or written to a netCDF-4/HDF5 variable, the
HDF5 library opens a cache for that variable. The default size of that
cache (settable with the &ndash;with-chunk-cache-size at netCDF build
time).

   <p>For good performance your chunk cache must be larger than one chunk of
your data - preferably that it be large enough to hold multiple chunks
of data.

   <p>In addition, when a file is opened (or a variable created in an open
file), the netCDF-4 library checks to make sure the default chunk
cache size will work for that variable. The cache will be large enough
to hold N chunks, up to a maximum size of M bytes. (Both N and M are
settable at configure time with the &ndash;with-default-chunks-in-cache and
the &ndash;with-max-default-cache-size options to the configure
script. Currently they are set to 10 and 64 MB.)

   <p>To change the default chunk cache size, use the set_chunk_cache
function before opening the file. C programmers see
<a href="netcdf-c.html#nc_005fset_005fchunk_005fcache">nc_set_chunk_cache</a>, Fortran 77
programmers see <a href="netcdf-f77.html#NF_005fSET_005fCHUNK_005fCACHE">NF_SET_CHUNK_CACHE</a>). Fortran 90 programmers use the optional cache_size,
cache_nelems, and cache_preemption parameters to nf90_open/nf90_create
to change the chunk size before opening the file.

   <p>To change the per-variable cache size, use the set_var_chunk_cache
function at any time on an open file. C programmers see
<a href="netcdf-c.html#nc_005fset_005fvar_005fchunk_005fcache">nc_set_var_chunk_cache</a>, Fortran 77
programmers see <a href="netcdf-f77.html#NF_005fSET_005fVAR_005fCHUNK_005fCACHE">NF_SET_VAR_CHUNK_CACHE</a>, <!-- Fortran 90 programmers see -->
<!-- @ref{NF90_SET_VAR_CHUNK_CACHE,,, netcdf-f90, @value{f90-man}} -->
).

<div class="node">
<a name="Default-Chunking"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Default-Chunking-4_005f0_005f1">Default Chunking 4_0_1</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Chunk-Cache">Chunk Cache</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Chunking">Chunking</a>

</div>

<h4 class="subsection">4.9.2 The Default Chunking Scheme in version 4.1 (and 4.1.1)</h4>

<p>When the data writer does not specify chunk sizes for variable, the
netCDF library has to come up with some default values.

   <p>The C code below determines the default chunks sizes.

   <p>For unlimited dimensions, a chunk size of one is always used. Users
are advised to set chunk sizes for large data sets with one or more
unlimited dimensions, since a chunk size of one is quite inefficient.

   <p>For fixed dimensions, the algorithm below finds a size for the chunk
sizes in each dimension which results in chunks of DEFAULT_CHUNK_SIZE
(which can be modified in the netCDF configure script).

<pre class="example">     		     /* Unlimited dim always gets chunksize of 1. */
     		     if (dim-&gt;unlimited)
     			chunksize[d] = 1;
     		     else
     			chunksize[d] = pow((double)DEFAULT_CHUNK_SIZE/type_size,
     					   1/(double)(var-&gt;ndims - unlimdim));
</pre>
   <div class="node">
<a name="Default-Chunking-4_0_1"></a>
<a name="Default-Chunking-4_005f0_005f1"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Parallel-Chunking">Parallel Chunking</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Default-Chunking">Default Chunking</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Chunking">Chunking</a>

</div>

<h4 class="subsection">4.9.3 The Default Chunking Scheme in version 4.0.1</h4>

<p>In the 4.0.1 release, the default chunk sizes were chosen with a
different scheme, as demonstrated in the following C code:

<pre class="example">     /* These are limits for default chunk sizes. (2^16 and 2^20). */
     #define NC_LEN_TOO_BIG 65536
     #define NC_LEN_WAY_TOO_BIG 1048576
     
           /* Now we must determine the default chunksize. */
           if (dim-&gt;unlimited)
              chunksize[d] = 1;
           else if (dim-&gt;len &lt; NC_LEN_TOO_BIG)
              chunksize[d] = dim-&gt;len;
           else if (dim-&gt;len &gt; NC_LEN_TOO_BIG &amp;&amp; dim-&gt;len &lt;= NC_LEN_WAY_TOO_BIG)
              chunksize[d] = dim-&gt;len / 2 + 1;
           else
              chunksize[d] = NC_LEN_WAY_TOO_BIG;
</pre>
   <p>As can be seen from this code, the default chunksize is 1 for
unlimited dimensions, otherwise it is the full length of the dimension
(if it is under NC_LEN_TOO_BIG), or half the size of the dimension (if
it is between NC_LEN_TOO_BIG and NC_LEN_WAY_TOO_BIG), and, if it's
longer than NC_LEN_WAY_TOO_BIG, it is set to NC_LEN_WAY_TOO_BIG.

   <p>Our experience is that these defaults work well for small data sets,
but once variable size reaches the GB range, the user is better off
determining chunk sizes for their read access patterns.

   <p>In particular, the idea of using 1 for the chunksize of an unlimited
dimension works well if the data are being read a record at a
time. Any other read access patterns will result in slower
performance.

<div class="node">
<a name="Parallel-Chunking"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#bm_005ffile">bm_file</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Default-Chunking-4_005f0_005f1">Default Chunking 4_0_1</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Chunking">Chunking</a>

</div>

<h4 class="subsection">4.9.4 Chunking and Parallel I/O</h4>

<p>When files are opened for read/write parallel I/O access, the chunk
cache is not used. Therefore it is important to open parallel files
with read only access when possible, to achieve the best performance.

<div class="node">
<a name="bm_file"></a>
<a name="bm_005ffile"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Parallel-Chunking">Parallel Chunking</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Chunking">Chunking</a>

</div>

<h4 class="subsection">4.9.5 A Utility to Help Benchmark Results: bm_file</h4>

<p>The bm_file utility may be used to copy files, from one netCDF format to
another, changing chunking, filter, parallel I/O, and other
parameters. This program may be used for benchmarking netCDF
performance for user data files with a range of choices, allowing data
producers to pick settings that best serve their user base.

   <p>NetCDF must have been configured with &ndash;enable-benchmarks at build
time for the bm_file program to be built. When built with
&ndash;enable-benchmarks, netCDF will include tests (run with &ldquo;make
check&rdquo;) that will run the bm_file program on sample data files.

   <p>Since data files and their access patterns vary from case to case,
these benchmark tests are intended to suggest further use of the
bm_file program for users.

   <p>Here's an example of a call to bm_file:
<pre class="example">     ./bm_file -d -f 3 -o  tst_elena_out.nc -c 0:-1:0:1024:256:256 tst_elena_int_3D.nc
</pre>
   <p>Generally a range of settings must be tested. This is best done with a
shell script, which calls bf_file repeatedly, to create output like
this:

<pre class="example">     *** Running benchmarking program bm_file for simple shorts test files, 1D to 6D...
     input format, output_format, input size, output size, meta read time, meta write time, data read time, data write time, enddianness, metadata reread time, data reread time, read rate, write rate, reread rate, deflate, shuffle, chunksize[0], chunksize[1], chunksize[2], chunksize[3]
     1, 4, 200092, 207283, 1613, 1054, 409, 312, 0, 1208, 1551, 488.998, 641.026, 128.949, 0, 0, 100000, 0, 0, 0
     1, 4, 199824, 208093, 1545, 1293, 397, 284, 0, 1382, 1563, 503.053, 703.211, 127.775, 0, 0, 316, 316, 0, 0
     1, 4, 194804, 204260, 1562, 1611, 390, 10704, 0, 1627, 2578, 499.159, 18.1868, 75.5128, 0, 0, 46, 46, 46, 0
     1, 4, 167196, 177744, 1531, 1888, 330, 265, 0, 12888, 1301, 506.188, 630.347, 128.395, 0, 0, 17, 17, 17, 17
     1, 4, 200172, 211821, 1509, 2065, 422, 308, 0, 1979, 1550, 473.934, 649.351, 129.032, 0, 0, 10, 10, 10, 10
     1, 4, 93504, 106272, 1496, 2467, 191, 214, 0, 32208, 809, 488.544, 436.037, 115.342, 0, 0, 6, 6, 6, 6
     *** SUCCESS!!!
</pre>
   <p>Such tables are suitable for import into spreadsheets, for easy
graphing of results.

   <p>Several test scripts are run during the &ldquo;make check&rdquo; of the netCDF
build, in the nc_test4 directory. The following example may be found
in nc_test4/run_bm_elena.sh.

<pre class="example">     #!/bin/sh
     
     # This shell runs some benchmarks that Elena ran as described here:
     # http://hdfeos.org/workshops/ws06/presentations/Pourmal/HDF5_IO_Perf.pdf
     
     # $Id: netcdf.texi,v 1.82 2010/05/15 20:43:13 dmh Exp $
     
     set -e
     echo ""
     
     echo "*** Testing the benchmarking program bm_file for simple float file, no compression..."
     ./bm_file -h -d -f 3 -o  tst_elena_out.nc -c 0:-1:0:1024:16:256 tst_elena_int_3D.nc
     ./bm_file -d -f 3 -o  tst_elena_out.nc -c 0:-1:0:1024:256:256 tst_elena_int_3D.nc
     ./bm_file -d -f 3 -o  tst_elena_out.nc -c 0:-1:0:512:64:256 tst_elena_int_3D.nc
     ./bm_file -d -f 3 -o  tst_elena_out.nc -c 0:-1:0:512:256:256 tst_elena_int_3D.nc
     ./bm_file -d -f 3 -o  tst_elena_out.nc -c 0:-1:0:256:64:256 tst_elena_int_3D.nc
     ./bm_file -d -f 3 -o  tst_elena_out.nc -c 0:-1:0:256:256:256 tst_elena_int_3D.nc
     echo '*** SUCCESS!!!'
     
     exit 0
</pre>
   <p>The reading that bm_file does can be tailored to match the expected
access pattern.

   <p>The bm_file program is controlled with command line options.

<pre class="example">     ./bm_file
     bm_file -v [-s N]|[-t V:S:S:S -u V:C:C:C -r V:I:I:I] -o file_out -f N -h -c V:C:C,V:C:C:C -d -m -p -i -e 1|2 file
       [-v]        Verbose
       [-o file]   Output file name
       [-f N]      Output format (1 - classic, 2 - 64-bit offset, 3 - netCDF-4, 4 - netCDF4/CLASSIC)
       [-h]        Print output header
       [-c V:Z:S:C:C:C[,V:Z:S:C:C:C, etc.]] Deflate, shuffle, and chunking parameters for vars
       [-t V:S:S:S[,V:S:S:S, etc.]] Starts for reads/writes
       [-u V:C:C:C[,V:C:C:C, etc.]] Counts for reads/writes
       [-r V:I:I:I[,V:I:I:I, etc.]] Incs for reads/writes
       [-d]        Doublecheck output by rereading each value
       [-m]        Do compare of each data value during doublecheck (slow for large files!)
       [-p]        Use parallel I/O
       [-s N]      Denom of fraction of slowest varying dimension read.
       [-i]        Use MPIIO (only relevant for parallel builds).
       [-e 1|2]    Set the endianness of output (1=little 2=big).
       file        Name of netCDF file
</pre>
   <div class="node">
<a name="Parallel-Access"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Interoperability-with-HDF5">Interoperability with HDF5</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Chunking">Chunking</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.10 Parallel Access with NetCDF-4</h3>

<p><a name="index-parallel-access-192"></a>
Use the special parallel open (or create) calls to open (or create) a
file, and then to use parallel I/O to read or write that file. C
programmers see <a href="netcdf-c.html#nc_005fopen_005fpar">nc_open_par</a>, Fortran 77
programmers see <a href="netcdf-f77.html#NF_005fOPEN_005fPAR">NF_OPEN_PAR</a>). Fortran 90 programmers use the optional comm and
info parameters to nf90_open/nf90_create to initiate parallel access.

   <p>Note that the chunk cache is turned off if a file is opened for
parallel I/O in read/write mode. Open the file in read-only mode to
engage the chunk cache.

   <p>NetCDF uses the HDF5 parallel programming model for parallel I/O
with netCDF-4/HDF5 files. The HDF5 tutorial
(<a href="http://hdfgroup.org/HDF5//HDF5/Tutor">http://hdfgroup.org/HDF5//HDF5/Tutor</a>) is a good reference.

   <p>For classic and 64-bit offset files, netCDF uses the parallel-netcdf
(formerly pnetcdf) library from Argonne National Labs/Nortwestern
University. For parallel access of classic and 64-bit offset files,
netCDF must be configured with the &ndash;with-pnetcdf option at build
time. See the parallel-netcdf site for more information
(<a href="http://www.mcs.anl.gov/parallel-netcdf">http://www.mcs.anl.gov/parallel-netcdf</a>).

<div class="node">
<a name="Interoperability-with-HDF5"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#DAP-Support">DAP Support</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Parallel-Access">Parallel Access</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.11 Interoperability with HDF5</h3>

<p><a name="index-interoperability-with-HDF5-193"></a>
To create HDF5 files that can be read by netCDF-4, use HDF5 1.8, which
is not yet released. However most (but not all) of the necessary
features can be found in their latest development snapshot.

   <p>HDF5 has some features that will not be supported by netCDF-4, and
will cause problems for interoperability:

     <ul>
<li>HDF5 allows a Group to be both an ancestor and a descendant of
another Group, creating cycles in the subgroup graph. HDF5 also
permits multiple parents for a Group.  In the netCDF-4 data model,
Groups form a tree with no cycles, so each Group (except the top-level
unnamed Group) has a unique parent.

     <li>HDF5 supports "references" which are like pointers to objects and data
regions within a file.  The netCDF-4 data model omits references.

     <li>HDF5 supports some primitive types that are not included in the
netCDF-4 data model, including H5T_TIME and H5T_BITFIELD.

     <li>HDF5 supports multiple names for data objects like Datasets (netCDF-4
variables) with no distinguished name.  The netCDF-4 data model
requires that each variable, attribute, dimension, and group have a
single distinguished name.

     <li>HDF5 (like netCDF) supports scalar attributes, but netCDF-4 cannot
read scalar HDF5 attributes (unless it is a string attribute). This
limitation will be removed in a future release of netCDF.

   </ul>

   <p>These are fairly easy requirements to meet, but there is one relating
to shared dimensions which is a little more challenging. Every HDF5
dataset must have a dimension scale attached to each dimension.

   <p>Dimension scales are a new feature for HF 1.8, which allow
specification of shared dimensions.

   <p>(In the future netCDF-4 will be able to deal with HDF5 files which do
not have dimension scales. However, this is not expected before netCDF
4.1.)

   <p>Finally, there is one feature which is missing from all current HDF5
releases, but which will be in 1.8 - the ability to track object
creation order. As you may know, netCDF keeps track of the creation
order of variables, dimensions, etc. HDF5 (currently) does not.

   <p>There is a bit of a hack in place in netCDF-4 files for this, but that
hack will go away when HDF5 1.8 comes out.

   <p>Without creation order, the files will still be readable to netCDF-4,
it's just that netCDF-4 will number the variables in alphabetical,
rather than creation, order.

   <p>Interoperability is a complex task, and all of this is in the alpha
release stage. It is tested in libsrc4/tst_interops.c, which contains
some examples of how to create HDF5 files, modify them in netCDF-4,
and then verify them in HDF5. (And vice versa).

<div class="node">
<a name="DAP-Support"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Interoperability-with-HDF5">Interoperability with HDF5</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Structure">Structure</a>

</div>

<h3 class="section">4.12 DAP Support</h3>

<p><a name="index-DAP-support-194"></a>
Beginning with netCDF version 4.1,
optional support is provided for accessing data through
OPeNDAP servers using the DAP protocol.

   <p>DAP support is automatically enabled if a usable curl library can be
located using the curl-config program or by the &ndash;with-curl-config flag. 
It can forcibly be enabled or disabled using the &ndash;enable-dap
flag or the &ndash;disable-dap flag, respectively.  If enabled,
then DAP support requires access to the curl library. 
Refer to the installation manual for details
<a href="netcdf-install.html#Top">The NetCDF Installation and Porting Guide</a>.

   <p>DAP uses a data model that is different from that supported by netCDF,
either classic or enhanced. Generically, the DAP data model
is encoded textually in a <acronym title="Dataset Descriptor Structure">DDS</acronym> (Dataset Descriptor Structure). 
There is a second data model for DAP attributes, which
is encoded textually in a <acronym title="Dataset Attribute Structure">DAS</acronym> (Dataset Attribute Structure). 
For detailed information about the DAP DDS and DAS, refer to
the OPeNDAP web site <a href="http://opendap.org">http://opendap.org</a>.

<h4 class="subsection">4.12.1 Accessing OPeNDAP Data</h4>

<p>In order to access an OPeNDAP data source through the netCDF
API, the file name normally used is replaced with a
URL with a specific format. 
The URL is composed of four parts.
     <ol type=1 start=1>
<li>Client parameters - these are prefixed to the front of the
URL and are of the general form [&lt;name&gt;] or [&lt;name&gt;=value]. 
Examples include [cache=1] and [netcdf3]. 
<li>URL - this is a standard form URL such as
http://test.opendap.org:8080/dods/dts/test.01
<li>Constraints - these are suffixed to the URL and
take the form &ldquo;?&lt;projections&gt;&amp;selections&rdquo;. 
The meaning of the terms projection and selection is somewhat complicated;
and the OPeNDAP web site,
<a href="http://www.opendap.or">http://www.opendap.or</a>,
should be consulted. 
The interaction of DAP constraints with netCDF is complex and
at the moment requires an understanding of how DAP is translated
to netCDF.
        </ol>

   <p>It is possible to see what the translation does to a particular DAP
data source in either of two ways. 
First, one can examine the DDS source through a web browser
and then examine the translation using the ncdump -h command
to see the netCDF Classic translation. 
The ncdump output will actually be the union of the
DDS with the DAS, so to see the complete translation, it is necessary
to view both.

   <p>For example, if a web browser is given the following,
the first URL will return the DDS for the specified dataset,
and the second URL will return the DAS for the specified dataset.
<pre class="example">     http://test.opendap.org:8080/dods/dts/test.01.dds
     http://test.opendap.org:8080/dods/dts/test.01.das
</pre>
   <p>Then by using the following ncdump command, it is possible to see the
equivalent netCDF Classic translation.
<pre class="example">     ncdump -h http://test.opendap.org:8080/dods/dts/test.01
</pre>
   <p>The DDS output from the web server should look like this.
<pre class="verbatim">Dataset {
    Byte b;
    Int32 i32;
    UInt32 ui32;
    Int16 i16;
    UInt16 ui16;
    Float32 f32;
    Float64 f64;
    String s;
    Url u;
} SimpleTypes;
</pre>

   <p>The DAS output from the web server should look like this.
<pre class="verbatim">Attributes {
    Facility {
        String PrincipleInvestigator ``Mark Abbott'', ``Ph.D'';
        String DataCenter ``COAS Environmental Computer Facility'';
        String DrifterType ``MetOcean WOCE/OCM'';
    }
    b {
        String Description ``A test byte'';
        String units ``unknown'';
    }
    i32 {
        String Description ``A 32 bit test server int'';
        String units ``unknown'';
    }
}
</pre>

   <p>The output from ncdump should look like this.
<pre class="verbatim">netcdf test {
dimensions:
	stringdim64 = 64 ;
variables:
	byte b ;
		b:Description = "A test byte" ;
		b:units = "unknown" ;
	int i32 ;
		i32:Description = "A 32 bit test server int" ;
		i32:units = "unknown" ;
	int ui32 ;
	short i16 ;
	short ui16 ;
	float f32 ;
	double f64 ;
	char s(stringdim64) ;
	char u(stringdim64) ;
}
</pre>
Note that the fields of type String and type URL
have suddenly acquired a dimension. This is because strings
are translated to arrays of char, which requires adding
an extra dimension.  The size of the dimension
is determined in a variety of ways and can be specified. 
It defaults to 64 and when read, the underlying string is
either padded or truncated to that length.

   <p>Also note that the <code>Facility</code> attributes do not appear
in the translation because they are neither global nor
associated with a variable in the DDS.

   <p>Alternately, one can get the text of the DDS as a global attribute
by using the client parameters
mechanism . In this case, the parameter &ldquo;[show=dds]&rdquo;
can be prefixed to the URL and the data retrieved using
the following command
<pre class="example">     ncdump -h [show=dds]http://test.opendap.org:8080/dods/dts/test.01.dds
</pre>
   <p>The ncdump -h command will then show both the translation and the original
DDS. In the above example, the DDS would appear as the global
attribute &ldquo;_DDS&rdquo; as follows.
<pre class="verbatim">netcdf test {
...
variables:
        :_DDS = "Dataset { Byte b; Int32 i32; UInt32 ui32; Int16 i16;
                 UInt16 ui16; Float32 f32; Float64 f64;
                 Strings; Url u; } SimpleTypes;"

	byte b ;
...
}
</pre>

<h4 class="subsection">4.12.2 DAP to NetCDF Translation Rules</h4>

<p>Two translations are currently available.
     <ul>
<li>DAP 2 Protocol to netCDF-3
<li>DAP 2 Protocol to netCDF-4
</ul>

<h5 class="subsubsection">4.12.2.1 netCDF-3 Translation Rules</h5>

<p>The current default translation code
translates the OPeNDAP protocol to netCDF-3 (classic). 
This netCDF-3 translation converts an OPeNDAP
DAP protocol version 2 DDS to netCDF-3 and is designed to mimic
as closely as possible the translation provided by the libnc-dap
system. 
In addition, a translation to netCDF-4 (enhanced) is provided
that is entirely new.

   <p>For illustrative purposes, the following example will be used.
<pre class="verbatim">Dataset {
  Int32 f1;
  Structure {
    Int32 f11;        
    Structure {
      Int32 f1[3];
      Int32 f2;
    } FS2[2]; 
  } S1; 
  Structure {
    Grid {
      Array:
        Float32 temp[lat=2][lon=2];
      Maps:
        Int32 lat[lat=2];
        Int32 lon[lon=2];
    } G1;
  } S2;
  Grid {
      Array:
        Float32 G2[lat=2][lon=2];
      Maps:
        Int32 lat[2];
        Int32 lon[2];
  } G2;
  Int32 lat[lat=2];
  Int32 lon[lon=2];
} D1;
</pre>

<h5 class="subsubsection">4.12.2.2 Variable Definition</h5>

<p>The set of netCDF variables is derived from the fields with
primitive base types as they occur in
Sequences, Grids, and Structures. 
The field names are modified to be fully qualified initially. 
For the above, the set of variables are as follows. 
The coordinate variables within grids are left out
in order to mimic the behavior of libnc-dap.
     <ol type=1 start=1>
<li>f1
<li>S1.f11
<li>S1.FS2.f1
<li>S1.FS2.f2
<li>S2.G1.temp
<li>S2.G2.G2
<li>lat
<li>lon
        </ol>

<h5 class="subsubsection">4.12.2.3 Variable Dimension Translation</h5>

<p>A variable's rank is determined from three sources.
     <ol type=1 start=1>
<li>The variable has the dimensions associated with the field
it represents (e.g. S1.FS2.f1[3] in the above example). 
<li>The variable inherits the dimensions associated with any containing
structure that has a rank greater than zero. 
These dimensions precede those of case 1. 
Thus, we have in our example, f1[2][3], where the first dimension
comes from the containing Structure FS2[2]. 
<li>The variable's set of dimensions are altered
if any of its containers is a DAP DDS Sequence. 
This is discussed more fully below. 
<li>If the type of the netCDF variable is char, then an extra
string dimension is added as the last dimension.
        </ol>

<h5 class="subsubsection">4.12.2.4 Dimension translation</h5>

<p>For dimensions, the rules are as follows.
     <ol type=1 start=1>
<li>Fields in dimensioned structures inherit the dimension
of the structure; thus the above list would have the following
dimensioned variables.
          <ul>
<li>S1.FS2.f1 -&gt; S1.FS2.f1[2][3]
<li>S1.FS2.f2 -&gt; S1.FS2.f2[2]
<li>S2.G1.temp -&gt; S2.G1.temp[lat=2][lon=2]
<li>S2.G1.lat -&gt; S2.G1.lat[lat=2]
<li>S2.G1.lon -&gt; S2.G1.lon[lon=2]
<li>S2.G2.G2 -&gt; S2.G2.lon[lat=2][lon=2]
<li>S2.G2.lat -&gt; S2.G2.lat[lat=2]
<li>S2.G2.lon -&gt; S2.G2.lon[lon=2]
<li>lat -&gt; lat[lat=2]
<li>lon -&gt; lon[lon=2]
</ul>

     <li>Collect all of the dimension specifications from the DDS, both
named and anonymous (unnamed)
For each unique anonymous dimension with value NN
create a netCDF dimension of the form "XX_&lt;i&gt;=NN",
where XX is the fully qualified name of the variable and i is the
i'th (inherited) dimension of the array where the anonymous dimension occurs. 
For our example, this would create the following dimensions.
          <ul>
<li>S1.FS2.f1_0 = 2 ;
<li>S1.FS2.f1_1 = 3 ;
<li>S1.FS2.f2_0 = 2 ;
<li>S2.G2.lat_0 = 2 ;
<li>S2.G2.lon_0 = 2 ;
</ul>

     <li>If however, the anonymous dimension is the single dimension
of a MAP vector in a Grid then the dimension is given the
same name as the map vector This leads to the following.
          <ul>
<li>S2.G2.lat_0 -&gt; S2.G2.lat
<li>S2.G2.lon_0 -&gt; S2.G2.lon
</ul>

     <li>For each unique named dimension "&lt;name&gt;=NN",
create a netCDF dimension of the form "&lt;name&gt;=NN",
where name has the qualifications removed. 
If this leads to duplicates (i.e. same name and same value),
then the duplicates are ignored. 
This produces the following.
          <ul>
<li>S2.G2.lat -&gt; lat
<li>S2.G2.lon -&gt; lon
</ul>
     Note that this produces duplicates that will be ignored later.

     <li>At this point the only dimensions left to process should be named
dimensions with the same name as some dimension from step number 3,
but with a different value.  For those dimensions create a dimension
of the form "&lt;name&gt;M=NN" where M is a counter starting at 1. 
The example has no instances of this.

     <li>Finally and if needed, define a single UNLIMITED dimension named "unlimited"
with value zero. 
Unlimited will be used to handle certain kinds of DAP sequences (see below).
        </ol>
This leads to the following set of dimensions.
<pre class="verbatim">dimensions:
  unlimited = UNLIMITED;
  lat = 2 ;
  lon = 2 ;
  S1.FS2.f1_0 = 2 ;
  S1.FS2.f1_1 = 3 ;
  S1.FS2.f2_0 = 2 ;
</pre>

<h5 class="subsubsection">4.12.2.5 Variable Name Translation</h5>

<p>The steps for variable name translation are as follows.

     <ol type=1 start=1>
<li>Take the set of variables captured above. 
Thus for the above DDS, the following fields would be collected.
          <ul>
<li>f1
<li>S1.f11
<li>S1.FS2.f1
<li>S1.FS2.f2
<li>S2.G1.temp
<li>S2.G2.G2
<li>lat
<li>lon
</ul>

     <li>All grid array variables are renamed to be the same as the containing
grid and the grid prefix is removed. 
In the above DDS, this results in the following changes.
          <ol type=1 start=1>
<li>G1.temp -&gt; G1
<li>G2.G2 -&gt; G2
          </ol>
        </ol>

   <p>It is important to note that this process could produce duplicate
variables (i.e. with the same name); in that case they are all assumed
to have the same content and the duplicates are ignored. 
If it turns out that the duplicates have different content, then
the translation will not detect this. YOU HAVE BEEN WARNED.

   <p>The final netCDF-3 schema (minus attributes) is then as follows.
<pre class="verbatim">netcdf t {
dimensions:
        unlimited = UNLIMITED ;
        lat = 2 ;
        lon = 2 ;
        S1.FS2.f1_0 = 2 ;
        S1.FS2.f1_1 = 3 ;
        S1.FS2.f2_0 = 2 ;
variables:
        int f1 ;
        int lat(lat) ;
        int lon(lon) ;
        int S1.f11 ;
	int S1.FS2.f1(S1.FS2.f1_0, S1.FS2.f1_1) ;
        int S1.FS2.f2(S1_FS2_f2_0) ;
        float S2.G1(lat, lon) ;
        float G2(lat, lon) ;
}
</pre>
In actuality, the unlimited dimension is dropped because
it is unused.

   <p>There are differences with the original libnc-dap here
because libnc-dap technically was incorrect.  The original
would have said this, for example.
<pre class="verbatim">int S1.FS2.f1(lat, lat) ;
</pre>
Note that this is incorrect because it dimensions
S1.FS2.f1(2,2) rather than S1.FS2.f1(2,3).

<h5 class="subsubsection">4.12.2.6 Translating DAP DDS Sequences</h5>

<p>Any variable (as determined above) that is contained
directly or indirectly by a Sequence is subject to revision
of its rank using the following rules.
     <ol type=1 start=1>
<li>Let the variable be contained in Sequence Q1, where Q1 is the
innermost containing sequence. If Q1 is itself contained
(directly or indirectly) in a sequence,
or Q1 is contained (again directly or indirectly)
in a structure that has rank greater than 0,
then the variable will have an initial UNLIMITED
dimension.  Further, all dimensions coming from "above" and including (in
the containment sense) the innermost Sequence, Q1, will be
removed and replaced by that single UNLIMITED dimension.  The
size associated with that UNLIMITED is zero, which means
that its contents are inaccessible through the netCDF-3 API. 
Again, this differs from libnc-dap, which leaves out such variables. 
Again, however, this difference is backward compatible.

     <li>If the variable is contained in a single Sequence (i.e. not nested)
and all containing structures have rank 0, then the variable will
have an initial dimension whose size is the record count for that
Sequence. The name of the new dimension will be the name of the
Sequence.
        </ol>

   <p>Consider this example.
<pre class="verbatim">Dataset {
  Structure {
    Sequence {
      Int32 f1[3];
      Int32 f2;
    } SQ1;
  } S1[2]; 
  Sequence {
    Structure {
      Int32 x1[7];
    } S2[5];
  } Q2;
} D;
</pre>
The corresponding netCDF-3 translation is pretty much as follows
(the value for dimension Q2 may differ).
<pre class="verbatim">dimensions:
    unlimited = UNLIMITED ; // (0 currently)
    S1.SQ1.f1_0 = 2 ;
    S1.SQ1.f1_1 = 3 ;
    S1.SQ1.f2_0 = 2 ;
    Q2.S2.x1_0 = 5 ;
    Q2.S2.x1_1 = 7 ;
    Q2 = 5 ;
variables:
    int S1.SQ1.f1(unlimited, S1.SQ1.f1_1) ;
    int S1.SQ1.f2(unlimited) ;
    int Q2.S2.x1(Q2, Q2.S2.x1_0, Q2.S2.x1_1) ;
</pre>
Note that for example S1.SQ1.f1_0
is not actually used because it has been folded
into the unlimited dimension.

   <p>Note that for sequences without a leading unlimited dimension,
there is a performance cost
because the translation code has to walk the data to determine
how many records are associated with the sequence. 
Since libnc-dap did essentially the same thing, it can be assumed that
the cost is not prohibitive.

<h5 class="subsubsection">4.12.2.7 netCDF-4 Translation Rules</h5>

<p>A DAP to netCDF-4 translation also exists, but is not the
default and in any case is only available if the
"&ndash;enable-netcdf-4" option is specified at configure time. 
This translation includes some elements of the libnc-dap
translation, but attempts to provide a simpler (but not,
unfortunately, simple) set of translation rules than is used
for the netCDF-3 translation.  Please note that the
translation is still experimental and will change to respond
to unforeseen problems or to suggested improvements.

   <p>This text will use this running example.
<pre class="verbatim">Dataset {
  Int32 f1[fdim=10];
  Structure {
    Int32 f11;        
    Structure {
      Int32 f1[3];
      Int32 f2;
    } FS2[2]; 
  } S1; 
  Grid {
    Array:
      Float32 temp[lat=2][lon=2];
    Maps:
      Int32 lat[2];
      Int32 lon[2];
  } G1;
  Sequence {
    Float64 depth;
  } Q1;
} D
</pre>

<h5 class="subsubsection">4.12.2.8 Variable Definition</h5>

<p>The rule for choosing variables is relatively simple. 
Start with the names of the top-level fields of the DDS. 
The term top-level means that the object is a direct subnode
of the Dataset object. In our example, this produces the set
[f1, S1, G1, Q1].

<h5 class="subsubsection">4.12.2.9 Dimension Definition</h5>

<p>The rules for choosing and defining dimensions is as follows.
     <ol type=1 start=1>
<li>Collect the set of dimensions (named and anonymous) directly
associated with the  variables as defined above. 
This means that dimensions
within user-defined types are ignored.  From our example,
the dimension set is [fdim=10,lat=2,lon=2,2,2].  Note that the
unqualified names are used.

     <li>All remaining anonymous dimensions are given the
name "&lt;var&gt;_NN", where "&lt;var&gt;" is the
unqualified name of the variable in which the anonymous
dimension appears and NN is the relative position of that
dimension in the dimensions associated with that array. 
No instances of this rule occur in the running example.

     <li>Remove duplicate dimensions (those with same name and value). 
Our dimension set now becomes
[fdim=10,lat=2,lon=2].

     <li>The final case occurs when there are dimensions with the same
name but with different values. For this case,
the size of the dimension is appended to the dimension name.
        </ol>

<h5 class="subsubsection">4.12.2.10 Type Definition</h5>

<p>The rules for choosing user-defined types are as follows.
     <ol type=1 start=1>
<li>For every Structure, Grid, and Sequence, a netCDF-4
compound type is created whose fields are the fields of the
Structure, Sequence, or Grid. With one exception, the name
of the type is the same as the Structure or Grid name
suffixed with "_t".  The exception is that the compound
types derived from Sequences are instead suffixed with
"_record_t".

     <p>The types of the fields are the types of the corresponding field
of the Structure, Sequence, or Grid. Note that this type
might be itself a user-defined type.

     <p>From the example, we get the following compound types. 
<pre class="verbatim">     compound FS2_t {
         int f1(3);
         int f2;
     };
     compound S1_t {
         int f11;
         FS2_t FS2(2);  
     };
     compound G1_t {
         float temp(2,2);
         int lat(2);
         int lon(2);
     }
     compound Q1_record_t {
         double depth;
     };
</pre>

     <li>For all sequences of name X,
also create this type. 
<pre class="verbatim">         X_record_t (*) X_t
</pre>
In our example, this produces the following type. 
<pre class="verbatim">         Q1_record_t (*) Q1_t
</pre>

     <li>If a Sequence, Q has a single field F,
whose type is a primitive type, T,
(e.g., int, float, string), then
do not apply the previous rule, but instead replace the whole
sequence with the the following field. 
<pre class="verbatim">         T (*) Q.f
</pre>

        </ol>

<h5 class="subsubsection">4.12.2.11 Choosing a Translation</h5>

<p>The decision about whether to translate to netCDF-3
or netCDF-4 is determined by applying the
following rules in order.
     <ol type=1 start=1>
<li>If the NC_CLASSIC_MODEL flag is set on nc_open(), then
netCDF-3 translation is used. 
<li>If the NC_NETCDF4 flag is set on nc_open(), then netCDF-4
translation is used. 
<li>If the URL is prefixed with the client parameter
"[netcdf3]" or "[netcdf-3]"
then netCF-3 translation is used. 
<li>If the URL is prefixed with the client parameter
"[netcdf4]" or "[netcdf-4]"
then netCF-4 translation is used. 
<li>If none of the above holds, then default to netCDF-3 classic
translation.
        </ol>

<h5 class="subsubsection">4.12.2.12 Caching</h5>

<p>In an effort to provide better
performance for some access patterns,
client-side caching of data is available. 
The default is no caching, but it may
be enabled by prefixing the URL
with "[cache]".

   <p>Caching operates basically as follows.
     <ol type=1 start=1>
<li>When a URL is first accessed using nc_open(),
netCDF automatically does a pre-fetch
of selected variables. These include all
variables smaller than a specified (and user definable)
size. This allows, for example, quick access to
coordinate variables.

     <li>Whenever a request is made using some variant
of the nc_get_var() API procedures, the complete
variable is fetched and stored in the cache as a new
cache entry. Subsequence requests for any part of that
variable will access the cache entry to obtain the data.

     <li>The cache may become too full, either because there are
too many entries or because it is taking up too much disk space. 
In this case cache entries are purged until the cache size
limits are reached. 
The cache purge algorithm is LRU (least recently used) so that
variables that are repeatedly referenced will tend to stay
in the cache.

     <li>The cache is completely purged when nc_close() is invoked.
        </ol>

   <p>In order to decide if you should enable caching,
you will need to have some understanding of the
access patterns  of your program.
     <ul>
<li>The ncdump program always dumps one or more
whole variables so it turns on caching.

     <li>If your program accesses only parts of a number of variables,
then caching should probably not be used since fetching
whole variables will probably slow down your program
for no purpose. 
</ul>

   <p>Unfortunately, caching is currently an all or nothing proposition,
so for more complex access patterns, the decision to cache or not
may not have an obvious answer. Probably a good rule of thumb
is to avoid caching initially and later turn it on to see
its effect on performance.

<h5 class="subsubsection">4.12.2.13 Defined Client Parameters</h5>

<p>Currently, a limited set of client parameters is recognized. 
Parameters not listed here are ignored, but no error is signalled.
     <dl>
<dt><em>Parameter Name Legal Values Semantics</em><br><dt><em>[netcdf-3]|[netcdf-3]</em><dd>Specify translation to netCDF-3. 
<br><dt><em>[netcdf-4]|[netcdf-4]</em><dd>Specify translation to netCDF-4. 
<br><dt><em>"[log]|[log=&lt;file&gt;]" ""</em><dd>Turn on logging and send the log output to the specified file. 
If no file is specified, then output to standard error. 
<br><dt><em>"[show=...]" das|dds|url</em><dd>This causes information to appear as specific global attributes. 
The currently recognized tags are "dds" to
display the underlying DDS, "das" similarly, and "url" to display
the url used to retrieve the data. 
This parameter may be specified multiple times (e.g. &ldquo;[show=dds][show=url]&rdquo;). 
<br><dt><em>"[show=fetch]"</em><dd>This parameter causes the netCDF code to log a copy of the complete
url for every HTTP get request. If logging is enabled, then
this can be helpful in checking to see the access behavior of the
netCDF code. 
<br><dt><em>"[stringlength=NN]"</em><dd>Specify the default string length to use for string dimensions. 
The default is 64. 
<br><dt><em>"[stringlength_&lt;var&gt;=NN]"</em><dd>Specify the default string length to use for a string dimension
for the specified variable. 
The default is 64. 
<br><dt><em>"[cache]"</em><dd>This enables caching. 
<br><dt><em>"[cachelimit=NN]"</em><dd>Specify the maximum amount of space allowed for the cache. 
<br><dt><em>"[cachecount=NN]"</em><dd>Specify the maximum number of entries in the cache. 
</dl>

<h4 class="subsection">4.12.3 Notes on Debugging OPeNDAP Access</h4>

<p>The OPeNDAP support makes use of the logging facility of the
underlying oc system. Note that this is currently
separate from the existing netCDF logging facility. 
Turning on this logging can sometimes give
important information. Logging can be enabled
by prefixing the url with
the client parameter [log] or [log=filename], where the first
case will send log output to standard error and the second
will send log output to the specified file.

   <p>Users should also be aware that the DAP subsystem
creates temporary files of the name dataddsXXXXXX,
where XXXXX is some random string. If the program
using the DAP subsystem crashes, these files may
be left around. It is perfectly safe to delete them. 
Also, if you are accessing data over an NFS mount,
you may see some .nfsxxxxx files; those can be ignored
as well.

<h4 class="subsection">4.12.4 HTTP Configuration.</h4>

<p>Limited support for configuring the http connection
is provided via parameters in the
&ldquo;.httprc&rdquo; configuration file. Although deprecated, the name
&ldquo;.dodsrc&rdquo; may also be used. 
The relevant .httprc file is located by first looking in the
current working directory, and if not found, then looking in the
directory specified by the &ldquo;$HOME&rdquo; environment variable.

   <p>Entries in the .httprc file are of the form:
<pre class="example">     ['['&lt;url&gt;']']&lt;key&gt;=&lt;value&gt;
</pre>
   <p>That is, it consists of a key name and value pair
and optionally preceded by a url enclosed in square
brackets.

   <p>For given KEY and URL strings, the value chosen is as follows:
     <ol type=1 start=1>
<li>If URL is null, then look for the .dodsrc entry that has no url prefix and whose key is same as the KEY for which we are looking.

     <li>If the URL is not null, then look for all the .dodsrc entries
that have a url, URL1, say, and for which URL1 is a prefix (in the
string sense) of URL. For example, if URL = http//x.y/a, then it will
match entries of the form
     <pre class="example">          1. [http//x.y/a]KEY=VALUE
          2. [http//x.y/a/b]KEY=VALUE
</pre>
     <p>It will not match an entry of the form
     <pre class="example">          [http//x.y/b]KEY=VALUE
</pre>
     <p>because &ldquo;http://x.y/b&rdquo; is not a string prefix of &ldquo;http://x.y/a&rdquo;. 
Finally from the set so constructed, choose the entry with the longest
url prefix: &ldquo;http//x.y/a/b]KEY=VALUE&rdquo; in this case.
        </ol>

   <p>Currently, the supported set of keys (with descriptions) are as follows.
     <ul>
<li>HTTP.VERBOSE
          <ol type=1 start=1>
    <li>Type: boolean ("1"/"0")
    <li>Description:
Produce verbose output, especially using SSL. 
    <li>Related CURL Flags: CURLOPT_VERBOSE
          </ol>

     <li>HTTP.DEFLATE
          <ol type=1 start=1>
    <li>Type: boolean ("1"/"0")
    <li>Description:
Allow use of compression by the server. 
    <li>Related CURL Flags: CURLOPT_ENCODING
          </ol>

     <li>HTTP.COOKIEJAR
          <ol type=1 start=1>
    <li>Type: String representing file path
    <li>Description:
Specify the name of file into which to store cookies. 
Defaults to in-memory storage. 
    <li>Related CURL Flags:CURLOPT_COOKIEJAR
          </ol>

     <li>HTTP.COOKIEFILE
          <ol type=1 start=1>
    <li>Type: String representing file path
    <li>Description:
Same as HTTP.COOKIEJAR. 
    <li>Related CURL Flags: CURLOPT_COOKIEFILE
          </ol>

     <li>HTTP.CREDENTIALS.USER
          <ol type=1 start=1>
    <li>Type: String representing user name
    <li>Description:
Specify the user name for Digest and Basic authentication. 
    <li>Related CURL Flags:
          </ol>

     <li>HTTP.CREDENTIALS.PASSWORD
          <ol type=1 start=1>
    <li>Type: String representing password
    <li>Type: boolean ("1"/"0")
    <li>Description:
Specify the password for Digest and Basic authentication. 
    <li>Related CURL Flags:
          </ol>

     <li>HTTP.SSL.CERTIFICATE
          <ol type=1 start=1>
    <li>Type: String representing file path
    <li>Description:
Path to a file containing a PEM cerficate. 
    <li>Related CURL Flags: CURLOPT_CERT
          </ol>

     <li>HTTP.SSL.KEY
          <ol type=1 start=1>
    <li>Type: String representing file path
    <li>Description:
Same as HTTP.SSL.CERTIFICATE, and should usually have the same value. 
    <li>Related CURL Flags: CURLOPT_SSLKEY
          </ol>

     <li>HTTP.SSL.KEYPASSWORD
          <ol type=1 start=1>
    <li>Type: String representing password
    <li>Description:
Password for accessing the HTTP.SSL.KEY/HTTP.SSL.CERTIFICATE
    <li>Related CURL Flags: CURLOPT_KEYPASSWORD
          </ol>

     <li>HTTP.SSL.CAPATH
          <ol type=1 start=1>
    <li>Type: String representing directory
    <li>Description:
Path to a directory containing trusted certificates for validating
server sertificates. 
    <li>Related CURL Flags: CURLOPT_CAPATH
          </ol>

     <li>HTTP.SSL.VALIDATE
          <ol type=1 start=1>
    <li>Type: boolean ("1"/"0")
    <li>Description:
Cause the client to verify the server's presented certificate. 
    <li>Related CURL Flags: CURLOPT_SSL_VERIFYPEER, CURLOPT_SSL_VERIFYHOST
          </ol>

     <li>HTTP.TIMEOUT
          <ol type=1 start=1>
    <li>Type: String ("dddddd")
    <li>Description:
Specify the maximum time in seconds that you allow the http
transfer operation to take. 
    <li>Related CURL Flags:
CURLOPT_TIMEOUT, CURLOPT_NOSIGNAL
          </ol>

     <li>HTTP.PROXY_SERVER
          <ol type=1 start=1>
    <li>Type: String representing url to access the proxy:
                (e.g.http://[username:password@]host[:port])
    <li>Description:
Specify the needed information for accessing a proxy. 
    <li>Related CURL Flags: CURLOPT_PROXY, CURLOPT_PROXYHOST, CURLOPT_PROXYUSERPWD
          </ol>

   </ul>

   <p>The related curl flags line indicates the curl flags modified
by this key.  See the libcurl documentation of the curl_easy_setopt()
function for more detail
<a href="http://curl.haxx.se/libcurl/c/curl_easy_setopt.html">http://curl.haxx.se/libcurl/c/curl_easy_setopt.html</a>.

   <p>For ESG, the following entries must be specified:
     <ul>
<li>HTTP.SSL.VALIDATE
<li>HTTP.COOKIEJAR
<li>HTTP.SSL.CERTIFICATE
<li>HTTP.SSL.KEY
<li>HTTP.SSL.CAPATH
</ul>
   Additionally, for ESG, the HTTP.SSL.CERTIFICATE and HTTP.SSL.KEY
entries should have same value, which is the file path for the
certificate produced by MyProxyLogon.  The HTTP.SSL.CAPATH entry
should be the path to the "certificates" directory produced by
MyProxyLogon.

<div class="node">
<a name="NetCDF-Utilities"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Units">Units</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Structure">Structure</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">5 NetCDF Utilities</h2>

<p><a name="index-utilities-195"></a><a name="index-ncgen-and-ncgen3_002c-overview-196"></a><a name="index-ncdump_002c-overview-197"></a><a name="index-nccopy_002c-overview-198"></a><a name="index-software-list-199"></a><a name="index-applications_002c-generic_002c-reasons-for-netCDF-200"></a>
One of the primary reasons for using the netCDF interface for
applications that deal with arrays is to take advantage of
higher-level netCDF utilities and generic applications for netCDF
data. Currently three netCDF utilities are available as part of the
netCDF software distribution:

     <dl>
<dt><code>ncdump</code><dd>reads a netCDF dataset and prints a textual representation of
the information in the dataset

     <br><dt><code>ncgen</code><dd>reads a textual representation of a netCDF dataset and generates
the corresponding binary netCDF file or a program to
create the netCDF dataset

     <br><dt><code>nccopy</code><dd>reads a netCDF dataset using the netCDF programming interface and
copies it, optionally to a different kind of netCDF dataset, and
optionally with compression or chunking

   </dl>

   <p>Users have contributed other netCDF utilities, and various
visualization and analysis packages are available that access netCDF
data. For an up-to-date list of freely-available and commercial
software that can access or manipulate netCDF data, see the netCDF
Software list,
<a href="http://www.unidata.ucar.edu/netcdf/software.html">http://www.unidata.ucar.edu/netcdf/software.html</a>.

   <p>This chapter describes the ncgen, ncdump, and nccopy utilities.  These
tools convert between binary netCDF datasets and a text representation
of netCDF datasets, or between netCDF data format variants. The output
of ncdump and the input to ncgen is a text description of a netCDF
dataset in a tiny language known as CDL (network Common data form
Description Language).

<ul class="menu">
<li><a accesskey="1" href="#CDL-Syntax">CDL Syntax</a>:                   Creating a File without Code
<li><a accesskey="2" href="#CDL-Data-Types">CDL Data Types</a>:               Describing Types in CDL
<li><a accesskey="3" href="#CDL-Constants">CDL Constants</a>:                Constant Values in CDL
<li><a accesskey="4" href="#ncgen">ncgen</a>:                        Turning CDL into Classic or Enhanced Data Files
<li><a accesskey="5" href="#ncdump">ncdump</a>:                       Turning Data Files into CDL (or XML)
<li><a accesskey="6" href="#nccopy">nccopy</a>:                       Copying, Converting, Compressing, and Chunking Data Files
<li><a accesskey="7" href="#ncgen3">ncgen3</a>:                       Turning CDL into Classic Data Files
</ul>

<div class="node">
<a name="CDL-Syntax"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#CDL-Data-Types">CDL Data Types</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#NetCDF-Utilities">NetCDF Utilities</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Utilities">NetCDF Utilities</a>

</div>

<h3 class="section">5.1 CDL Syntax</h3>

<p><a name="index-CDL-syntax-201"></a><a name="index-attributes_002c-CDL_002c-defining-202"></a><a name="index-attributes_002c-CDL_002c-global-203"></a><a name="index-dimensions_002c-CDL_002c-defining-204"></a><a name="index-variables_002c-CDL_002c-defining-205"></a><a name="index-CDL-attributes_002c-defining-206"></a><a name="index-CDL-dimensions_002c-defining-207"></a><a name="index-CDL-variables_002c-defining-208"></a>
Below is an example of CDL, describing a netCDF dataset with several
named dimensions (lat, lon, time), variables (z, t, p, rh, lat, lon,
time), variable attributes (units, _FillValue, valid_range), and some
data.

<pre class="example">     netcdf foo {    // example netCDF specification in CDL
     
     dimensions:
     lat = 10, lon = 5, time = unlimited;
     
     variables:
       int     lat(lat), lon(lon), time(time);
       float   z(time,lat,lon), t(time,lat,lon);
       double  p(time,lat,lon);
       int     rh(time,lat,lon);
     
       lat:units = "degrees_north";
       lon:units = "degrees_east";
       time:units = "seconds";
       z:units = "meters";
       z:valid_range = 0., 5000.;
       p:_FillValue = -9999.;
       rh:_FillValue = -1;
     
     data:
       lat   = 0, 10, 20, 30, 40, 50, 60, 70, 80, 90;
       lon   = -140, -118, -96, -84, -52;
     }
</pre>
   <p>All CDL statements are terminated by a semicolon. Spaces, tabs, and
newlines can be used freely for readability. Comments may follow the
double slash characters '//' on any line.

   <p>A CDL description for a classic model file consists of three optional
parts: dimensions, variables, and data. The variable part may contain
variable declarations and attribute assignments.  For the enhanced
model supported by netCDF-4, a CDL decription may also includes
groups, subgroups, and user-defined types.

   <p>A dimension is used to define the shape of one or more of the
multidimensional variables described by the CDL description. A
dimension has a name and a length. At most one dimension in a classic CDL
description can have the unlimited length, which means a variable
using this dimension can grow to any length (like a record number in a
file).  Any number of dimensions can be declared of unlimited length
in CDL for an enhanced model file.

   <p>A variable 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 attributes
(see below) as well as data values. The name, data type, and shape of
a variable are specified by its declaration in the variable section of
a CDL description. A variable may have the same name as a dimension;
by convention such a variable contains coordinates of the dimension it
names.

   <p>An attribute contains information about a variable or about the whole
netCDF dataset or containing group. Attributes may be used to specify
such properties as
units, special values, maximum and minimum valid values, and packing
parameters. Attribute information is represented by single values or
one-dimensional arrays of values. For example, &ldquo;units&rdquo; might be an attribute
represented by a string such as &ldquo;celsius&rdquo;. 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
ancillary data or metadata (data about data).

   <p>In CDL, an attribute is designated by a variable and attribute name,
separated by a colon (':'). It is possible to assign global attributes
to the netCDF dataset as a whole by omitting the variable name and
beginning the attribute name with a colon (':'). The data type of an
attribute in CDL, if not explicitly specified, is derived from the
type of the value assigned to
it. The length of an attribute is the number of data values 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.  In the netCDF-4 enhanced model, attributes may be declared
to be of user-defined type, like variables.

   <p>In CDL, just as for netCDF, the names of dimensions, variables and
attributes (and, in netCDF-4 files, groups, user-defined types,
compound member names, and enumeration symbols) consist of arbitrary
sequences of alphanumeric characters, underscore '_', period '.', plus
'+', hyphen '-', or at sign '@', but beginning with a letter or
underscore.  However names commencing with underscore are reserved for
system use.  Case is significant in netCDF names. A zero-length name
is not allowed.  Some widely used conventions restrict names to only
alphanumeric characters or underscores.  Names that have trailing
space characters are also not permitted.

   <p>Beginning with versions 3.6.3 and 4.0, names may also include UTF-8
encoded Unicode characters as well as other special characters, except
for the character '/', which may not appear in a name (because it is
reserved for path names of nested groups).  In CDL, most special
characters are escaped with a backslash '\' character, but that
character is not actually part of the netCDF name.  The special
characters that do not need to be escaped in CDL names are underscore
'_', period '.', plus '+', hyphen '-', or at sign '@'.  For the
formal specification of CDL name syntax See <a href="#Format">Format</a>.  Note that by
using special characters in names, you may make your data not
compliant with conventions that have more stringent requirements on
valid names for netCDF components, for example the CF Conventions.

   <p>The names for the primitive data types are reserved words in CDL, so
names of variables, dimensions, and attributes must not be primitive
type names.

   <p>The optional data section of a CDL description is where netCDF
variables may be initialized. The syntax of an initialization is
simple:

<pre class="example">     variable = value_1, value_2, ...;
</pre>
   <p>The comma-delimited list of constants may be separated by spaces,
tabs, and newlines. For multidimensional 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 the fill value. The types of constants
need not match the type declared for a variable; coercions are done to
convert integers to floating point, for example. All meaningful type
conversions among primitive types are supported.

   <p>A special notation for fill values is supported: the &lsquo;<samp><span class="samp">_</span></samp>&rsquo; character
designates a fill value for variables.

<div class="node">
<a name="CDL-Data-Types"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#CDL-Constants">CDL Constants</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#CDL-Syntax">CDL Syntax</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Utilities">NetCDF Utilities</a>

</div>

<h3 class="section">5.2 CDL Data Types</h3>

<p><a name="index-CDL-data-types-209"></a><a name="index-byte_002c-CDL-data-type-210"></a><a name="index-char_002c-CDL-data-type-211"></a><a name="index-short_002c-CDL-data-type-212"></a><a name="index-int_002c-CDL-data-type-213"></a><a name="index-long_002c-CDL-data-type-214"></a><a name="index-float_002c-CDL-data-type-215"></a><a name="index-real_002c-CDL-data-type-216"></a><a name="index-double_002c-CDL-data-type-217"></a>
The CDL primitive data types for the classic model are:

     <dl>
<dt><code>char</code><a name="index-char-218"></a><dd>Characters.

     <br><dt><code>byte</code><a name="index-byte-219"></a><dd>Eight-bit integers.

     <br><dt><code>short</code><a name="index-short-220"></a><dd>16-bit signed integers.

     <br><dt><code>int</code><a name="index-int-221"></a><dd>32-bit signed integers.

     <br><dt><code>long</code><a name="index-long-222"></a><dd>(Deprecated, synonymous with int)

     <br><dt><code>float</code><a name="index-float-223"></a><dd>IEEE single-precision floating point (32 bits).

     <br><dt><code>real</code><a name="index-real-224"></a><dd>(Synonymous with float).

     <br><dt><code>double</code><a name="index-double-225"></a><dd>IEEE double-precision floating point (64 bits). 
</dl>

   <p>NetCDF-4 supports the additional primitive types:

     <dl>
<dt><code>ubyte</code><a name="index-ubyte-226"></a><dd>Unsigned eight-bit integers.

     <br><dt><code>ushort</code><a name="index-ushort-227"></a><dd>Unsigned 16-bit integers.

     <br><dt><code>uint</code><a name="index-uint-228"></a><dd>Unsigned 32-bit integers.

     <br><dt><code>int64</code><a name="index-int64-229"></a><dd>64-bit singed integers.

     <br><dt><code>uint64</code><a name="index-uint64-230"></a><dd>Unsigned 64-bit singed integers.

     <br><dt><code>string</code><a name="index-string-231"></a><dd>Variable-length string of characters
</dl>

   <p>Except for the added data-type byte, CDL supports the same primitive
data types as C. For
backward compatibility, in declarations primitive type names may be
specified in either upper or lower case.

   <p>The byte type differs from the char type in that it is intended for
numeric data, and the zero byte has no special significance, as it may
for character data.  The short type holds values between -32768 and
32767.  The ushort type holds values between 0 and 65536.  The int
type can hold values between -2147483648 and 2147483647.  The uint
type holds values between 0 and 4294967296.  The int64 type can hold
values between -9223372036854775808 and 9223372036854775807.  The
uint64 type can hold values between 0 and 18446744073709551616.

   <p>The float type can hold values between about -3.4+38 and 3.4+38, with
external representation as 32-bit IEEE normalized single-precision
floating-point numbers.  The double type can hold values between about
-1.7+308 and 1.7+308, with external representation as 64-bit IEEE
standard normalized double-precision, floating-point numbers. 
The string type holds variable length strings.

<div class="node">
<a name="CDL-Constants"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#ncgen">ncgen</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#CDL-Data-Types">CDL Data Types</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Utilities">NetCDF Utilities</a>

</div>

<h3 class="section">5.3 CDL Notation for Data Constants</h3>

<p><a name="index-CDL-constants-232"></a><a name="index-attributes_002c-CDL_002c-initializing-233"></a><a name="index-dimensions_002c-CDL_002c-initializing-234"></a><a name="index-variables_002c-CDL_002c-initializing-235"></a><a name="index-attributes_002c-data-types_002c-CDL-236"></a><a name="index-variables_002c-data-types_002c-CDL-237"></a><a name="index-attributes_002c-length_002c-CDL-238"></a><a name="index-dimensions_002c-length_002c-CDL-239"></a><a name="index-byte-CDL-constant-240"></a><a name="index-initializing-CDL-241"></a>
This section describes the CDL notation for constants.

   <p>Attributes are initialized in the variables section of a CDL
description by providing a list of constants that determines the
attribute's length and type (if primitive and not explicitly declared). 
CDL defines a syntax
for constant values that permits distinguishing among different netCDF
primitive types. The syntax for CDL constants is similar to C syntax, with
type suffixes appended to bytes, shorts, and floats to distinguish
them from ints and doubles.

   <p>A byte constant is represented by a single character or multiple
character escape sequence enclosed in single quotes. For example:

<pre class="example">     'a'     // ASCII a
     '\0'    // a zero byte
     '\n'    // ASCII newline character
     '\33'   // ASCII escape character (33 octal)
     '\x2b'  // ASCII plus (2b hex)
     '\376'  // 377 octal = -127 (or 254) decimal
</pre>
   <p>Character constants are enclosed in double quotes. A character array
may be represented as a string enclosed in double quotes. Multiple
strings are concatenated into a single array of characters, permitting
long character arrays to appear on multiple lines. To support multiple
variable-length string values, a conventional delimiter such as ','
may be used, but interpretation of any such convention for a string
delimiter must be implemented in software above the netCDF library
layer. The usual escape conventions for C strings are honored. For
example:

<pre class="example">     "a"            // ASCII 'a'
     "Two\nlines\n" // a 10-character string with two embedded newlines
     "a bell:\007"  // a string containing an ASCII bell
     "ab","cde"     // the same as "abcde"
</pre>
   <p>The form of a short constant is an integer constant with an 's' or 'S'
appended. If a short constant begins with '0', it is interpreted as
octal. When it begins with '0x', it is interpreted as a hexadecimal
constant. For example:

<pre class="example">     2s      // a short 2
     0123s   // octal
     0x7ffs  // hexadecimal
</pre>
   <p>The form of an int constant is an ordinary integer constant. If an int
constant begins with '0', it is interpreted as octal. When it begins
with '0x', it is interpreted as a hexadecimal constant. Examples of
valid int constants include:

<pre class="example">     -2
     0123            // octal
     0x7ff           // hexadecimal
     1234567890L     // deprecated, uses old long suffix
</pre>
   <p>The float type is appropriate for representing data with about seven
significant digits of precision. The form of a float constant is the
same as a C floating-point constant with an 'f' or 'F' appended. A
decimal point is required in a CDL float to distinguish it from an
integer. For example, the following are all acceptable float
constants:

<pre class="example">     -2.0f
     3.14159265358979f       // will be truncated to less precision
     1.f
     .1f
</pre>
   <p>The double type is appropriate for representing floating-point data
with about 16 significant digits of precision. The form of a double
constant is the same as a C floating-point constant. An optional 'd'
or 'D' may be appended. A decimal point is required in a CDL double to
distinguish it from an integer. For example, the following are all
acceptable double constants:

<pre class="example">     -2.0
     3.141592653589793
     1.0e-20
     1.d
</pre>
   <div class="node">
<a name="ncgen"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#ncdump">ncdump</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#CDL-Constants">CDL Constants</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Utilities">NetCDF Utilities</a>

</div>

<h3 class="section">5.4 ncgen</h3>

<p><a name="index-ncgen-242"></a><a name="index-C-code-via-ncgen_002c-generating-243"></a><a name="index-generating-C-code-via-ncgen-244"></a>
The ncgen tool generates a netCDF file or a C or FORTRAN program that
creates a netCDF dataset. If no options are specified in invoking
ncgen, the program merely checks the syntax of the CDL input,
producing error messages for any violations of CDL syntax.

   <p>The ncgen tool is now is capable of producing netcdf-4 files. 
It operates essentially identically to the original ncgen.

   <p>The CDL input to ncgen may include data model constructs
from the netcdf- data model. In particular, it includes
new primitive types such as unsigned integers and strings,
opaque data, enumerations, and user-defined constructs using
vlen and compound types. 
The ncgen man page should be consulted for more detailed information.

   <p>UNIX syntax for invoking ncgen:

<pre class="example">     ncgen [-b] [-o netcdf-file] [-c] [-f] [-k&lt;kind&gt;] [-l&lt;language&gt;] [-x] [input-file]
</pre>
   <p>where:

     <dl>
<dt><code>-b</code><dd>Create a (binary) netCDF file. If the '-o' option is absent, a default
file name will be constructed from the netCDF name (specified after
the netcdf keyword in the input) by appending the '.nc'
extension. Warning: if a file already exists with the specified name
it will be overwritten.

     <br><dt><code>-o netcdf-file</code><dd>Name for the netCDF file created. If this option is specified, it
implies the '-b' option. (This option is necessary because netCDF
files are direct-access files created with seek calls, and hence
cannot be written to standard output.)

     <br><dt><code>-c</code><dd>Generate C source code that will create a netCDF dataset matching the
netCDF specification. The C source code is written to standard
output. This is only useful for relatively small CDL files, since all
the data is included in variable initializations in the generated
program. 
The -c flag is deprecated and the -lc flag should be used intstead.

     <br><dt><code>-f</code><dd>Generate FORTRAN source code that will create a netCDF dataset
matching the netCDF specification. The FORTRAN source code is written
to standard output. This is only useful for relatively small CDL
files, since all the data is included in variable initializations in
the generated program. 
The -f flag is deprecated and the -lf77 flag should be used intstead.

     <br><dt><code>-k</code><dd>The -k file specifies the kind of netCDF file to generate. 
The arguments to the -k flag can be as follows.
          <ul>
<li>1, classic
&ndash; Produce a netcdf classic file format file." 
<li>2, 64-bit-offset, '64-bit offset'
&ndash; Produce a netcdf 64 bit classic file format file. 
<li>3, hdf5, netCDF-4, enhanced
&ndash; Produce a netcdf-4 format file. 
<li>4, hdf5-nc3, 'netCDF-4 classic model', enhanced-nc3
&ndash; Produce a netcdf-4 file format, but restricted to
netcdf-3 classic CDL input. 
</ul>
     Note that the -v flag is a deprecated alias for -k.

     <br><dt><code>-l</code><dd>The -l file specifies that ncgen should output (to
standard output) the text of a program that, when
compiled and executed, will produce the corresponding
binary .nc file. 
The arguments to the -l flag can be as follows.
          <ul>
<li>c|C
=&gt; C language output. 
<li>f77|fortran77
=&gt; FORTRAN 77 language output; note that currently
only the classic model is supported for fortran output. 
<li>cml|CML
=&gt; (experimental) NcML language output
<li>j|java
=&gt; (experimental) Java language output; the generated
java code targets the existing Unidata Java interface,
which means that only the classic model is supported. 
</ul>
     <br><dt><code>-x</code><dd>Use &ldquo;no fill&rdquo; mode, omitting the initialization of variable values
with fill values.  This can make the creation of large files much
faster, but it will also eliminate the possibility of detecting the
inadvertent reading of values that haven't been written. 
</dl>

<h3 class="heading">Examples</h3>

<p>Check the syntax of the CDL file foo.cdl:

<pre class="example">     ncgen foo.cdl
</pre>
   <p>From the CDL file foo.cdl, generate an equivalent binary netCDF file
named bar.nc:

<pre class="example">     ncgen -o bar.nc foo.cdl
</pre>
   <p>From the CDL file foo.cdl, generate a C program containing netCDF
function invocations that will create an equivalent binary netCDF
dataset:

<pre class="example">     ncgen -c foo.cdl &gt; foo.c
</pre>
   <div class="node">
<a name="ncdump"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#nccopy">nccopy</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#ncgen">ncgen</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Utilities">NetCDF Utilities</a>

</div>

<h3 class="section">5.5 ncdump</h3>

<p><a name="index-ncdump-245"></a>
The ncdump tool generates the CDL text representation of a netCDF
dataset on standard output, optionally excluding some or all of the
variable data in the output. The output from ncdump is intended to be
acceptable as input to ncgen. Thus ncdump and ncgen can be used as
inverses to transform data representation between binary and text
representations.

   <p>As of netCDF version 4.1, ncdump can also access DAP data sources
if DAP support is enabled in the underlying netCDF library. 
Instead of specifying a file name as argument to ncdump, the user
specifies a URL to a DAP source.

   <p>ncdump may also be used as a simple browser for netCDF datasets, to
display the dimension names and lengths; variable names, types, and
shapes; attribute names and values; and optionally, the values of data
for all variables or selected variables in a netCDF dataset.

   <p>ncdump defines a default format used for each type of netCDF variable
data, but this can be overridden if a C_format attribute is defined
for a netCDF variable. In this case, ncdump will use the C_format
attribute to format values for that variable. For example, if
floating-point data for the netCDF variable Z is known to be accurate
to only three significant digits, it might be appropriate to use this
variable attribute:

<pre class="example">     Z:C_format = "%.3g"
</pre>
   <p>Ncdump uses '_' to represent data values that are equal to the
_FillValue attribute for a variable, intended to represent data that
has not yet been written. If a variable has no _FillValue attribute,
the default fill value for the variable type is used unless the
variable is of byte type.

   <p>UNIX syntax for invoking ncdump:

<pre class="example">     ncdump  [ -c | -h]  [-v var1,...]  [-b lang]  [-f lang]
     [-l len]  [ -p fdig[,ddig]] [ -s ] [ -n name]  [input-file]
</pre>
   <p>where:

     <dl>
<dt><code>-c</code><dd>Show the values of coordinate variables (variables that are also
dimensions) as well as the declarations of all dimensions, variables,
and attribute values. Data values of non-coordinate variables are not
included in the output. This is often the most suitable option to use
for a brief look at the structure and contents of a netCDF dataset.

     <br><dt><code>-h</code><dd>Show only the header information in the output, that is, output only
the declarations for the netCDF dimensions, variables, and attributes
of the input file, but no data values for any variables. The output is
identical to using the '-c' option except that the values of
coordinate variables are not included. (At most one of '-c' or '-h'
options may be present.)

     <br><dt><code>-v var1,...</code><dd>The output will include data values for the specified variables, in
addition to the declarations of all dimensions, variables, and
attributes. One or more variables must be specified by name in the
comma-delimited list following this option. The list must be a single
argument to the command, hence cannot contain blanks or other white
space characters. The named variables must be valid netCDF variables
in the input-file. The default, without this option and in the absence
of the '-c' or '-h' options, is to include data values for all
variables in the output.

     <br><dt><code>-b lang</code><dd>A brief annotation in the form of a CDL comment (text beginning with
the characters '//') will be included in the data section of the
output for each 'row' of data, to help identify data values for
multidimensional variables. If lang begins with 'C' or 'c', then C
language conventions will be used (zero-based indices, last dimension
varying fastest). If lang begins with 'F' or 'f', then FORTRAN
language conventions will be used (one-based indices, first dimension
varying fastest). In either case, the data will be presented in the
same order; only the annotations will differ. This option may be
useful for browsing through large volumes of multidimensional data.

     <br><dt><code>-f lang</code><dd>Full annotations in the form of trailing CDL comments (text beginning
with the characters '//') for every data value (except individual
characters in character arrays) will be included in the data
section. If lang begins with 'C' or 'c', then C language conventions
will be used (zero-based indices, last dimension varying fastest). If
lang begins with 'F' or 'f', then FORTRAN language conventions will be
used (one-based indices, first dimension varying fastest). In either
case, the data will be presented in the same order; only the
annotations will differ. This option may be useful for piping data
into other filters, since each data value appears on a separate line,
fully identified. (At most one of '-b' or '-f' options may be
present.)

     <br><dt><code>-l len</code><dd>Changes the default maximum line length (80) used in formatting lists
of non-character data values.

     <br><dt><code>-p float_digits[,double_digits]</code><dd>Specifies default precision (number of significant digits) to use in
displaying floating-point or double precision data values for
attributes and variables. If specified, this value overrides the value
of the C_format attribute, if any, for a variable. Floating-point data
will be displayed with float_digits significant digits. If
double_digits is also specified, double-precision values will be
displayed with that many significant digits. In the absence of any
'-p' specifications, floating-point and double-precision data are
displayed with 7 and 15 significant digits respectively. CDL files can
be made smaller if less precision is required. If both floating-point
and double precisions are specified, the two values must appear
separated by a comma (no blanks) as a single argument to the command.

     <br><dt><code>-n name</code><dd>CDL requires a name for a netCDF dataset, for use by 'ncgen -b' in
generating a default netCDF dataset name. By default, ncdump
constructs this name from the last component of the file name of the
input netCDF dataset by stripping off any extension it has. Use the
'-n' option to specify a different name. Although the output file name
used by 'ncgen -b' can be specified, it may be wise to have ncdump
change the default name to avoid inadvertently overwriting a valuable
netCDF dataset when using ncdump, editing the resulting CDL file, and
using 'ncgen -b' to generate a new netCDF dataset from the edited CDL
file.

     <br><dt><code>-s</code><dd>Specifies that special virtual attributes should be output for the
file format variant and for variable properties such as compression,
chunking, and other properties specific to the format implementation
that are primarily related to performance rather than the logical
schema of the data.  All the special virtual attributes begin with '_'
followed by an upper-case letter.  Currently they include the global
attribute &ldquo;_Format&rdquo; and the variable attributes &ldquo;_Fletcher32&rdquo;,
&ldquo;_ChunkSizes&rdquo;, &ldquo;_Endianness&rdquo;, &ldquo;_DeflateLevel&rdquo;, &ldquo;_Shuffle&rdquo;,
&ldquo;_Storage&rdquo;, and &ldquo;_NoFill&rdquo;.  The ncgen utility recognizes these
attributes and supports them appropriately.

     <br><dt><code>-t</code><dd>Controls display of time data, if stored in a variable that uses a
udunits compliant time representation such as &ldquo;days since
1970-01-01&rdquo; or &ldquo;seconds since 2009-03-15 12:01:17&rdquo;.  If this option
is specified, time values are displayed as human-readable date-time
strings rather than numerical values, interpreted in terms of a
&ldquo;calendar&rdquo; variable attribute, if specified.  Calendar attribute
values interpreted with this option include the CF Conventions values
&ldquo;gregorian&rdquo; or &ldquo;standard&rdquo;, &ldquo;proleptic_gregorian&rdquo;, &ldquo;noleap&rdquo; or
&ldquo;365_day&rdquo;, &ldquo;all_leap&rdquo; or &ldquo;366_day&rdquo;, &ldquo;360_day&rdquo;, and &ldquo;julian&rdquo;.

   </dl>

<h3 class="heading">Examples</h3>

<p>Look at the structure of the data in the netCDF dataset foo.nc:

   <p>ncdump -c foo.nc

   <p>Produce an annotated CDL version of the structure and data in the
netCDF dataset foo.nc, using C-style indexing for the annotations:

   <p>ncdump -b c foo.nc &gt; foo.cdl

   <p>Output data for only the variables uwind and vwind from the netCDF
dataset foo.nc, and show the floating-point data with only three
significant digits of precision:

   <p>ncdump -v uwind,vwind -p 3 foo.nc

   <p>Produce a fully-annotated (one data value per line) listing of the
data for the variable omega, using FORTRAN conventions for indices,
and changing the netCDF dataset name in the resulting CDL file to
omega:

   <p>ncdump -v omega -f fortran -n omega foo.nc &gt; Z.cdl

   <p>Examine the translated DDS for the DAP source from the specified URL.

   <p>ncdump -h http://test.opendap.org:8080/dods/dts/test.01

<div class="node">
<a name="nccopy"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#ncgen3">ncgen3</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#ncdump">ncdump</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Utilities">NetCDF Utilities</a>

</div>

<h3 class="section">5.6 nccopy</h3>

<p><a name="index-nccopy-246"></a>
The nccopy utility copies an input netCDF file to an output netCDF
file, in any of the four format variants, if possible.  For example,
if built with the netCDF-3 library, a netCDF classic file may be
copied to a netCDF 64-bit offset file, permitting larger variables. 
If built with the netCDF-4 library, a netCDF classic file may be
copied to a netCDF-4 file or to a netCDF-4 classic model file as well,
permitting data compression, data chunking, efficient schema changes, larger
variable sizes, and use of other netCDF-4 features in case the output
uses the enhanced netCDF model.

   <p>The nccopy source also serves as an example of a <dfn>generic</dfn>
netCDF-4 program, with its ability to read any valid netCDF file and
handle strings, arbitrarily nested groups, any user-defined types,
(including arbitrarily nested compound types and variable-length
types), and data of any valid netCDF-4 type.  Functions from and
fragments of the nccopy source may be useful to other developers for
writing generic programs that handle or write arbitrary netCDF data.

   <p>As of netCDF version 4.1, and if DAP support was enabled when nccopy
was built, the input file name on which nccopy is invoked may specify
a DAP URL. This allows nccopy to convert data on DAP servers to local
netCDF files.

   <p>UNIX syntax for invoking nccopy:

<pre class="example">     nccopy  [ -k kind]  [ -d n]  [ -s ]  [ -u ]  [ -c chunkspec ]
             [ -m bufsize] input  output
</pre>
   <p>where:

     <dl>
<dt><code>-k kind</code><dd>Specifies the kind of file to be created
and, by inference,
the data model (i.e. netcdf-3 (classic) versus
netcdf-4 (enhanced)). 
The possible arguments are as follows.
          <ul>
<li>&ldquo;1&rdquo; or &ldquo;classic&rdquo;
write a netCDF classic file format file
<li>&ldquo;2&rdquo;, &ldquo;64-bit-offset&rdquo;, or &ldquo;64-bit offset&rdquo;
write a netCDF 64 bit classic file format file
<li>&ldquo;3&rdquo;, &ldquo;hdf5&rdquo;, &ldquo;netCDF-4&rdquo;, or &ldquo;enhanced&rdquo;
write a netCDF-4 format file
<li>&ldquo;4&rdquo;, &ldquo;hdf5-nc3&rdquo;, &ldquo;netCDF-4 classic model&rdquo;, or &ldquo;enhanced-nc3&rdquo;
write a netCDF-4 classic model file format, which is restricted to
netCDF-3 classic data model but may use netCDF-4/HDF5 features such as
compression and chunking. 
</ul>
     If no value for -k is specified, then the output will use the same
format as the input.  However, if the input is classic or 64-bit
offset and a compression level is specified with the -d option or
chunking is specified with the -c option, then
the output will be netCDF-4 classic model format.  Note that attempting some
kinds of format conversion will result in an error, if the conversion
is not possible.  For example, an attempt to copy a netCDF-4 file that
uses features of the enhanced model to any of the other kinds of
netCDF formats that use the classic model will result in an error.

     <br><dt><code>-d n</code><dd>Specify deflation level (level of compression) for variable data in
output.  0 corresponds to no compression and 9 to maximum compression,
with higher levels of compression requiring marginally more time to
compress or uncompress than lower levels.  Compression achieved may
also depend on chunking parameters, which will use default chunking in
the current nccopy implementation.  If this option is specified for a
classic format or 64-bit offset format input file, it is not necessary
to also specify that the output should be netCDF-4 classic model, as
that will be the default.  If this option is not specified and the
input file has compressed variables, the compression will still be
preserved in the output, using the same chunking as in the input
unless the -c option is used to specify different chunking.

     <p>Note that nccopy requires all variables to be compressed using
the same compression level, but the API has no such restriction.  With
a program you can customize compression for each variable independently.

     <br><dt><code>-s</code><dd>Specify shuffling of variable data bytes before compression or after
decompression.  This option is ignored unless a non-zero deflation
level is specified.  Turning shuffling on sometimes improves
compression.

     <br><dt><code>-u</code><dd>Convert any unlimited size dimensions in the input to fixed size
dimensions in the output.

     <br><dt><code>-c chunkspec</code><dd>Specify chunking (multidimensional tiling) for variable data in the
output, useful to specify the units of disk access, compression, or
other filters such as checksums.  The chunkspec argument is a string
of comma-separated associations, each specifying a dimension name, a
`/' character, and optionally the corresponding chunk length for that
dimension.  No blanks should appear in the chunkspec string, except
possibly escaped blanks that are part of a dimension name.  A
chunkspec must name at least one dimension, and may omit dimensions
which are not to be chunked or for which the default chunk length is
desired.  If a dimension name is followed by a `/' character but no
subsequent chunk length, the actual dimension length is assumed.  If
copying a classic model file to a netCDF-4 output file and not naming
all dimensions in the chunkspec, unnamed dimensions will also use the
actual dimension length for the chunk length.

     <p>By default, fixed-size variables smaller than 1024 bytes of data will
not be chunked even if they use dimensions mentioned in the chunkspec
string.

     <p>An example of a chunkspec for variables that use the `m' and `n'
dimensions might be `m/100,n/200' to specify 100 by 200 chunks.  To
see the chunking resulting from copying with a chunkspec, use ncdump
with the `-s' option (and typically with the `-h' option) on the
output file.

     <p>Note that nccopy requires variables that share a dimension to
also share the chunk size associated with that dimension, but the API
has no such restriction.  With a program you can customize chunking
for each variable independently.

     <br><dt><code>-m bufsize</code><dd>Specifies the size, in bytes, of the copy buffer used to
to copy large variables, by copying them in smaller pieces, each no
larger than <dfn>bufsize</dfn>.  A suffix of k, m, or g multiplies
the copy buffer size by one thousand, million, or billion, respectively. 
The default is 5 million bytes,
but will be increased if necessary to hold at least one chunk of
netCDF-4 chunked variables in the input file.  You may want to specify
a value larger than the default for OPeNDAP copies of large files over high
latency networks. 
</dl>

<h3 class="heading">Examples</h3>

<h5 class="subsubheading">Simple copy, check for corruption or truncation</h5>

<p>Make a copy of foo1.nc, a netCDF file of any type, to foo2.nc, a
netCDF file of the same type:

<pre class="example">     nccopy foo1.nc foo2.nc
</pre>
   <p>This also can be used to check foo1.nc for corruption of metadata
or for truncation, because such problems will usually be detected in
trying to parse and read through the data.

   <p>Note that the above copy will not be as fast as use of a simple copy
utility, because the file is copied using only the netCDF API.  If the
input file has extra bytes after the end of the netCDF data, those
will not be copied, because they are not accessible through the netCDF
interface.  If the original file was generated in `No fill' mode so
that fill values are not stored for padding for data alignment, the
output file may have different padding bytes.

<h5 class="subsubheading">Uncompress and convert to classic format</h5>

<p>Convert a netCDF-4 classic model file that uses compression (compressed.nc)
to a netCDF-3 file (classic.nc):

<pre class="example">     nccopy -k classic compressed.nc classic.nc
</pre>
   <p>Note that &ldquo;1&rdquo; could be used instead of &ldquo;classic&rdquo;.

<h5 class="subsubheading">Copy a subset of data on an OPeNDAP server to a netCDF file</h5>

<p>Download the variable `time_bnds' and it's associated attributes from
an OPeNDAP server and copy the result to a netCDF file named `tb.nc':

<pre class="example">     nccopy 'http://test.opendap.org/opendap/data/nc/sst.mnmean.nc.gz?time_bnds' tb.nc
</pre>
   <p>Note that URLs that name specific variables as command-line arguments
should generally be quoted, to avoid the shell interpreting special
characters in OPeNDAP syntax, such as `?'.

<h5 class="subsubheading">Apply compression to a netCDF file</h5>

<p>Compress all the variables in the input file foo.nc, a netCDF file of any
type, to the output file bar.nc:

<pre class="example">     nccopy -d1 foo.nc bar.nc
</pre>
   <p>If foo.nc was a classic or 64-bit offset netCDF file, bar.nc will be a
netCDF-4 classic model netCDF file, because the classic and 64-bit
offset format variants don't support compression.  If foo.nc was a
netCDF-4 file with some variables compressed using various deflation
levels, the output will also be a netCDF-4 file of the same type, but
all the variables, including any uncompressed variables in the input,
will now use deflation level 1.

<div class="node">
<a name="ncgen3"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#nccopy">nccopy</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Utilities">NetCDF Utilities</a>

</div>

<h3 class="section">5.7 ncgen3</h3>

<p><a name="index-ncgen3-247"></a><a name="index-C-code-via-ncgen3_002c-generating-248"></a><a name="index-generating-C-code-via-ncgen3-249"></a>
The ncgen3 tool is the new name for the older, original
ncgen utility.

   <p>The ncgen3 tool generates a netCDF file or a C or FORTRAN program that
creates a netCDF dataset. If no options are specified in invoking
ncgen3, the program merely checks the syntax of the CDL input,
producing error messages for any violations of CDL syntax.

   <p>The ncgen3 utility can only generate
classic-model netCDF-4 files or programs.

   <p>UNIX syntax for invoking ncgen3:

<pre class="example">     ncgen3 [-b] [-o netcdf-file] [-c] [-f] [-v2|-v3] [-x] [input-file]
</pre>
   <p>where:

     <dl>
<dt><code>-b</code><dd>Create a (binary) netCDF file. If the '-o' option is absent, a default
file name will be constructed from the netCDF name (specified after
the netcdf keyword in the input) by appending the '.nc'
extension. Warning: if a file already exists with the specified name
it will be overwritten.

     <br><dt><code>-o netcdf-file</code><dd>Name for the netCDF file created. If this option is specified, it
implies the '-b' option. (This option is necessary because netCDF
files are direct-access files created with seek calls, and hence
cannot be written to standard output.)

     <br><dt><code>-c</code><dd>Generate C source code that will create a netCDF dataset matching the
netCDF specification. The C source code is written to standard
output. This is only useful for relatively small CDL files, since all
the data is included in variable initializations in the generated
program.

     <br><dt><code>-f</code><dd>Generate FORTRAN source code that will create a netCDF dataset
matching the netCDF specification. The FORTRAN source code is written
to standard output. This is only useful for relatively small CDL
files, since all the data is included in variable initializations in
the generated program.

     <br><dt><code>-v2</code><dd>The generated netCDF file or program will use the version of the
format with 64-bit offsets, to allow for the creation of very large
files.  These files are not as portable as classic format netCDF
files, because they require version 3.6.0 or later of the netCDF
library.

     <br><dt><code>-v3</code><dd>The generated netCDF file will be in netCDF-4/HDF5 format. These files
are not as portable as classic format netCDF files, because they
require version 4.0 or later of the netCDF library.

     <br><dt><code>-x</code><dd>Use &ldquo;no fill&rdquo; mode, omitting the initialization of variable values
with fill values.  This can make the creation of large files much
faster, but it will also eliminate the possibility of detecting the
inadvertent reading of values that haven't been written. 
</dl>

<div class="node">
<a name="Units"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Attribute-Conventions">Attribute Conventions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#NetCDF-Utilities">NetCDF Utilities</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="appendix">Appendix A Units</h2>

<p><a name="index-units-library-250"></a><a name="index-udunits-251"></a><a name="index-applications_002c-generic_002c-units-252"></a>
The Unidata Program Center has developed a units library to convert
between formatted and binary forms of units specifications and perform
unit algebra on the binary form. Though the units library is
self-contained and there is no dependency between it and the netCDF
library, it is nevertheless useful in writing generic netCDF programs
and we suggest you obtain it. The library and associated documentation
is available from <a href="http://www.unidata.ucar.edu/packages/udunits/">http://www.unidata.ucar.edu/packages/udunits/</a>.

   <p>The following are examples of units strings that can be interpreted by
the utScan() function of the Unidata units library:

<pre class="example">     10 kilogram.meters/seconds2
     10 kg-m/sec2
     10 kg m/s^2
     10 kilogram meter second-2
     (PI radian)2
     degF
     100rpm
     geopotential meters
     33 feet water
     milliseconds since 1992-12-31 12:34:0.1 -7:00
</pre>
   <p>A unit is specified as an arbitrary product of constants and
unit-names raised to arbitrary integral powers. Division is indicated
by a slash '/'. Multiplication is indicated by white space, a period
'.', or a hyphen '-'. Exponentiation is indicated by an integer suffix
or by the exponentiation operators '^' and '**'. Parentheses may be
used for grouping and disambiguation. The time stamp in the last
example is handled as a special case.

   <p>Arbitrary Galilean transformations (i.e., y = ax + b) are allowed. In
particular, temperature conversions are correctly handled. The
specification:

<pre class="example">     degF  32
</pre>
   <p>indicates a Fahrenheit scale with the origin shifted to thirty-two
degrees Fahrenheit (i.e., to zero Celsius). Thus, the Celsius scale is
equivalent to the following unit:

<pre class="example">     1.8 degF  32
</pre>
   <p>Note that the origin-shift operation takes precedence over
multiplication. In order of increasing precedence, the operations are
division, multiplication, origin-shift, and exponentiation.

   <p>utScan() understands all the SI prefixes (e.g. "mega" and "milli")
plus their abbreviations (e.g. "M" and "m")

   <p>The function utPrint() always encodes a unit specification one way. To
reduce misunderstandings, it is recommended that this encoding style
be used as the default. In general, a unit is encoded in terms of
basic units, factors, and exponents. Basic units are separated by
spaces, and any exponent directly appends its associated unit. The
above examples would be encoded as follows:

<pre class="example">     10 kilogram meter second-2
     9.8696044 radian2
     0.555556 kelvin  255.372
     10.471976 radian second-1
     9.80665 meter2 second-2
     98636.5 kilogram meter-1 second-2
     0.001 seconds since 1992-12-31 19:34:0.1000 UTC
</pre>
   <p>(Note that the Fahrenheit unit is encoded as a deviation, in
fractional kelvins, from an origin at 255.372 kelvin, and that the
time in the last example has been referenced to UTC.)

   <p>The database for the units library is a formatted file containing unit
definitions and is used to initialize this package. It is the first
place to look to discover the set of valid names and symbols.

   <p>The format for the units-file is documented internally and the file
may be modified by the user as necessary. In particular, additional
units and constants may be easily added (including variant spellings
of existing units or constants).

   <p>utScan() is case-sensitive. If this causes difficulties, you might try
making appropriate additional entries to the units-file.

   <p>Some unit abbreviations in the default units-file might seem
counter-intuitive. In particular, note the following:

   <p><table summary="">
<tr align="left"><td valign="top" width="25%">For </td><td valign="top" width="25%">Use </td><td valign="top" width="25%">Not </td><td valign="top" width="25%">Which Instead Means

<p><br></td></tr><tr align="left"><td valign="top" width="25%">Celsius </td><td valign="top" width="25%">Celsius </td><td valign="top" width="25%">C </td><td valign="top" width="25%">coulomb

<p><br></td></tr><tr align="left"><td valign="top" width="25%">gram </td><td valign="top" width="25%">gram </td><td valign="top" width="25%">g </td><td valign="top" width="25%">&lt;standard free fall&gt;

<p><br></td></tr><tr align="left"><td valign="top" width="25%">gallon </td><td valign="top" width="25%">gallon </td><td valign="top" width="25%">gal </td><td valign="top" width="25%">&lt;acceleration&gt;

<p><br></td></tr><tr align="left"><td valign="top" width="25%">radian </td><td valign="top" width="25%">radian </td><td valign="top" width="25%">rad </td><td valign="top" width="25%">&lt;absorbed dose&gt;

<p><br></td></tr><tr align="left"><td valign="top" width="25%">Newton </td><td valign="top" width="25%">newton or N </td><td valign="top" width="25%">nt </td><td valign="top" width="25%">nit (unit of photometry)

   <br></td></tr></table>

   <p>For additional information on this units library, please consult the
manual pages that come with its distribution.

<div class="node">
<a name="Attribute-Conventions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#File-Format">File Format</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Units">Units</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="appendix">Appendix B Attribute Conventions</h2>

<p><a name="index-attribute-conventions-253"></a><a name="index-applications_002c-generic_002c-conventions-254"></a><a name="index-conventions_002c-attributes-255"></a>
Names commencing with underscore ('_') are reserved for use by the
netCDF library. Most generic applications that process netCDF datasets
assume standard attribute conventions and it is strongly recommended
that these be followed unless there are good reasons for not doing
so. Below we list the names and meanings of recommended standard
attributes that have proven useful. Note that some of these
(e.g. units, valid_range, scale_factor) assume numeric data and should
not be used with character data.

     <dl>
<dt><code>units</code><a name="index-units-256"></a><dd>A character string that specifies the units used for the variable's
data. Unidata has developed a freely-available library of routines to
convert between character string and binary forms of unit
specifications and to perform various useful operations on the binary
forms. This library is used in some netCDF applications. Using the
recommended units syntax permits data represented in conformable units
to be automatically converted to common units for arithmetic
operations. For more information see <a href="#Units">Units</a>.

     <br><dt><code>long_name</code><a name="index-long_005fname-257"></a><dd>A long descriptive name. This could be used for labeling plots, for
example. If a variable has no long_name attribute assigned, the
variable name should be used as a default.

     <br><dt><code>_FillValue</code><a name="index-g_t_005fFillValue-258"></a><dd>The _FillValue attribute specifies the fill value used to pre-fill
disk space allocated to the variable. Such pre-fill occurs unless
nofill mode is set using nc_set_fill in C (see <a href="netcdf-c.html#nc_005fset_005ffill">nc_set_fill</a>) or NF_SET_FILL in Fortran
(see <a href="netcdf-f77.html#NF_005fSET_005fFILL">NF_SET_FILL</a>). The fill value
is returned when reading values that were never written. If _FillValue
is defined then it should be scalar and of the same type as the
variable. If the variable is packed using scale_factor and
add_offset attributes (see below), the _FillValue attribute should
have the data type of the packed data.

     <p>It is not necessary to define your own _FillValue attribute for a
variable if the default fill value for the type of the variable is
adequate. However, use of the default fill value for data type byte is
not recommended. Note that if you change the value of this attribute,
the changed value applies only to subsequent writes; previously
written data are not changed.

     <p>Generic applications often need to write a value to represent
undefined or missing values. The fill value provides an appropriate
value for this purpose because it is normally outside the valid range
and therefore treated as missing when read by generic applications. It
is legal (but not recommended) for the fill value to be within the
valid range.

     <p>For more information for C programmers see <a href="netcdf-c.html#Fill-Values">Fill Values</a>. For more information for Fortran
programmers see <a href="netcdf-f77.html#Fill-Values">Fill Values</a>.

     <br><dt><code>missing_value</code><a name="index-missing_005fvalue-259"></a><dd>This attribute is not treated in any special way by the
library or conforming generic applications, but is often useful
documentation and may be used by specific applications. The
missing_value attribute can be a scalar or vector containing values
indicating missing data. These values should all be outside the valid
range so that generic applications will treat them as missing.

     <p>When scale_factor and add_offset are used for packing, the value(s) of
the missing_value attribute should be specified in the domain of the
data in the file (the packed data), so that missing values can be
detected before the scale_factor and add_offset are applied.

     <br><dt><code>valid_min</code><a name="index-valid_005fmin-260"></a><dd>A scalar specifying the minimum valid value for this variable.

     <br><dt><code>valid_max</code><a name="index-valid_005fmax-261"></a><dd>A scalar specifying the maximum valid value for this variable.

     <br><dt><code>valid_range</code><a name="index-valid_005frange-262"></a><dd>A vector of two numbers specifying the minimum and maximum valid
values for this variable, equivalent to specifying values for both
valid_min and valid_max attributes. Any of these attributes define the
valid range. The attribute valid_range must not be defined if either
valid_min or valid_max is defined.

     <p>Generic applications should treat values outside the valid range as
missing. The type of each valid_range, valid_min and valid_max
attribute should match the type of its variable (except that for byte
data, these can be of a signed integral type to specify the intended
range).

     <p>If neither valid_min, valid_max nor valid_range is defined then
generic applications should define a valid range as follows. If the
data type is byte and _FillValue is not explicitly defined, then the
valid range should include all possible values. Otherwise, the valid
range should exclude the _FillValue (whether defined explicitly or by
default) as follows. If the _FillValue is positive then it defines a
valid maximum, otherwise it defines a valid minimum. For integer
types, there should be a difference of 1 between the _FillValue and
this valid minimum or maximum. For floating point types, the
difference should be twice the minimum possible (1 in the least
significant bit) to allow for rounding error.

     <p>If the variable is packed using scale_factor and add_offset attributes
(see below), the _FillValue, missing_value, valid_range, valid_min, or
valid_max attributes should have the data type of the packed data.

     <br><dt><code>scale_factor</code><a name="index-scale_005ffactor-263"></a><dd>If present for a variable, the data are to be multiplied by this
factor after the data are read by the application that accesses the
data.

     <p>If valid values are specified using the valid_min, valid_max,
valid_range, or _FillValue attributes, those values should be
specified in the domain of the data in the file (the packed data),
so that they can be interpreted before the scale_factor and add_offset
are applied.

     <br><dt><code>add_offset</code><a name="index-add_005foffset-264"></a><dd>If present for a variable, this number is to be added to the data
after it is read by the application that accesses the data. If both
scale_factor and add_offset attributes are present, the data are first
scaled before the offset is added. The attributes scale_factor and
add_offset can be used together to provide simple data compression to
store low-resolution floating-point data as small integers in a netCDF
dataset. When scaled data are written, the application should first
subtract the offset and then divide by the scale factor, rounding the
result to the nearest integer to avoid a bias caused by truncation
towards zero.

     <p>When scale_factor and add_offset are used for packing, the associated
variable (containing the packed data) is typically of type byte or
short, whereas the unpacked values are intended to be of type float or
double. The attributes scale_factor and add_offset should both be of
the type intended for the unpacked data, e.g. float or double.

     <br><dt><code>signedness</code><a name="index-signedness-265"></a><dd>Deprecated attribute, originally designed to indicate whether byte
values should be treated as signed or unsigned. The attributes
valid_min and valid_max may be used for this purpose. For example, if
you intend that a byte variable store only non-negative values, you can
use valid_min = 0 and valid_max = 255. This attribute is ignored by
the netCDF library.

     <br><dt><code>C_format</code><a name="index-C_005fformat-266"></a><dd>A character array providing the format that should be used by C
applications to print values for this variable. For example, if you
know a variable is only accurate to three significant digits, it would
be appropriate to define the C_format attribute as "%.3g". The ncdump
utility program uses this attribute for variables for which it is
defined. The format applies to the scaled (internal) type and value,
regardless of the presence of the scaling attributes scale_factor and
add_offset.

     <br><dt><code>FORTRAN_format</code><a name="index-FORTRAN_005fformat-267"></a><dd>A character array providing the format that should be used by FORTRAN
applications to print values for this variable. For example, if you
know a variable is only accurate to three significant digits, it would
be appropriate to define the FORTRAN_format attribute as "(G10.3)".

     <br><dt><code>title</code><a name="index-title-268"></a><dd>A global attribute that is a character array providing a succinct
description of what is in the dataset.

     <br><dt><code>history</code><a name="index-history-269"></a><dd>A global attribute for an audit trail. This is a character array with
a line for each invocation of a program that has modified the
dataset. Well-behaved generic netCDF applications should append a line
containing: date, time of day, user name, program name and command
arguments.

     <br><dt><code>Conventions</code><a name="index-Conventions-270"></a><dd>If present, 'Conventions' is a global attribute that is a character
array for the name of the conventions followed by the dataset. 
Originally, these conventions were named by a string that was
interpreted as a directory name relative to the directory
/pub/netcdf/Conventions/ on the host ftp.unidata.ucar.edu.  The web
page http://www.unidata.ucar.edu/netcdf/conventions.html is now the preferred and
authoritative location for registering a URI reference to a set of
conventions maintained elsewhere.  The FTP site will be preserved for
compatibility with existing references, but authors of new conventions
should submit a request to support-netcdf@unidata.ucar.edu for listing
on the Unidata conventions web page.

     <p>It may be convenient for defining institutions and groups to use a
hierarchical structure for general conventions and more specialized
conventions. 
For example, if a group named NUWG agrees upon a set of conventions
for dimension names, variable names, required attributes, and netCDF
representations for certain discipline-specific data structures, they
may store a document describing the agreed-upon conventions in a
dataset in the NUWG/ subdirectory of the Conventions
directory. Datasets that followed these conventions would contain a
global Conventions attribute with value "NUWG".

     <p>Later, if the group agrees upon some additional conventions for a
specific subset of NUWG data, for example time series data, the
description of the additional conventions might be stored in the
NUWG/Time_series/ subdirectory, and datasets that adhered to these
additional conventions would use the global Conventions attribute with
value "NUWG/Time_series", implying that this dataset adheres to the
NUWG conventions and also to the additional NUWG time-series
conventions.

     <p>It is possible for a netCDF file to adhere to more than one set of
conventions, even when there is no inheritance relationship among the
conventions.  In this case, the value of the `Conventions' attribute
may be a single text string containing a list of the convention names
separated by blank space (recommended) or commas (if a convention name
contains blanks).

     <p>Typical conventions web sites will include references to documents in
some form agreed upon by the community that supports the conventions
and examples of netCDF file structures that follow the conventions. 
</dl>

<div class="node">
<a name="File-Format"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Internal-Dispatch-Table">Internal Dispatch Table</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Attribute-Conventions">Attribute Conventions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="appendix">Appendix C File Format Specification</h2>

<p><a name="index-file-format-271"></a>
In different contexts, &ldquo;netCDF&rdquo; may refer to an abstract data model,
a software implementation with associated application program
interfaces (APIs), or a data format. Confusion may easily arise in
discussions of different versions of the data models, software, and
formats, because the relationships among versions of these entities is
more complex than a simple one-to-one correspondence by version. For
example, compatibility commitments require that new versions of the
software support all previous variants of the format and data model.

   <p>To avoid this potential confusion, we assign distinct names to
versions of the formats, data models, and software releases that will
be used consistently in the remainder of this appendix.

   <p>In this appendix, two format variants are specified formally, the
<dfn>classic format</dfn> and the <dfn>64-bit offset format</dfn> for netCDF
data. Two additional format variants are discussed less formally, the
<dfn>netCDF-4 format</dfn> and the <dfn>netCDF-4 classic model format</dfn>.

   <p>The classic format was the only format for netCDF data created between
1989 and 2004 by various versions of the reference software from
Unidata. In 2004, the 64-bit offset format variant was introduced for
creation of and access to much larger files. The reference software,
available for C-based and Java-based programs, supported use of the
same APIs for accessing either classic or 64-bit offset files, so
programs reading the files would not have to depend on which format
was used.

   <p>There are only two netCDF data models, the <dfn>classic model</dfn> and the
<dfn>enhanced model</dfn>. The classic model is the simpler of the two, and is
used for all data stored in classic format, 64-bit offset format, or
netCDF-4 classic model format. The enhanced model (also referred to as
the netCDF- 4 data model) was introduced in 2008 as an extension of
the classic model that adds more powerful forms of data representation
and data types at the expense of some additional complexity. Although
data represented with the classic model can also be represented using
the enhanced model, datasets that use features of the enhanced model,
such as user-defined nested data types, cannot be represented with the
classic model. Use of added features of the enhanced model requires
that data be stored in the netCDF-4 format.

   <p>Versions 1.0 through 3.5 of the Unidata C-based reference software,
released between 1989 and 2000, supported only the classic data model
and classic format. Version 3.6, released in late 2004, first provided
support for the 64-bit offset format, but still used the classic data
model.  With version 4.0, released in 2008, the enhanced data model
was introduced along with the two new HDF5-based format variants, the
netCDF-4 format and the netCDF-4 classic model format.  Evolution of
the data models, formats, and APIs will continue the commitment to support
all previous netCDF data models, data format variants, and APIs in
future software releases.

   <p>Use of the HDF5 storage layer in netCDF-4 software provides features
for improved performance, independent of the data model used, for
example compression and dynamic schema changes. Such performance
improvements are available for data stored in the netCDF-4 classic
model format, even when accessed by programs that only support the
classic model.

   <p>Related formats not discussed in this appendix include
CDL (&ldquo;Common Data Language&rdquo;, the original ASCII form of binary netCDF
data), and NcML (NetCDF Markup Language, an XML-based representation
for netCDF metadata and data).

   <p>Knowledge of format details is not required to read or write netCDF
datasets. Software that reads netCDF data using the reference
implementation automatically detects and uses the correct version of
the format for accessing data. Understanding details may be helpful
for understanding performance issues related to disk or server access.

   <p>The netCDF reference library, developed and supported by Unidata, is
written in C, with Fortran77, Fortran90, and C++ interfaces. A number
of community and commercially supported interfaces to other languages
are also available, including IDL, Matlab, Perl, Python, and Ruby.  An
independent implementation, also developed and supported by Unidata,
is written entirely in Java.

<ul class="menu">
<li><a accesskey="1" href="#NetCDF-Classic-Format">NetCDF Classic Format</a>:        The Original Binary Format
<li><a accesskey="2" href="#g_t64_002dbit-Offset-Format">64-bit Offset Format</a>:         Supporting Larger Variables
<li><a accesskey="3" href="#NetCDF_002d4-Format">NetCDF-4 Format</a>:              Uses HDF5
<li><a accesskey="4" href="#NetCDF_002d4-Classic-Model-Format">NetCDF-4 Classic Model Format</a>:   HDF5 with NetCDF Limitations
<li><a accesskey="5" href="#HDF4-SD-Format">HDF4 SD Format</a>
</ul>

<div class="node">
<a name="NetCDF-Classic-Format"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#g_t64_002dbit-Offset-Format">64-bit Offset Format</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#File-Format">File Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#File-Format">File Format</a>

</div>

<h3 class="section">C.1 The NetCDF Classic Format Specification</h3>

<p>To present the format more formally, we use a BNF grammar notation. In
this notation:

     <ul>
<li>Non-terminals (entities defined by grammar rules) are in lower case. 
<li>Terminals (atomic entities in terms of which the format specification
is written) are in upper case, and are specified literally as US-ASCII
characters within single-quote characters or are described with text
between angle brackets (&lsquo;<samp><span class="samp">&lt;</span></samp>&rsquo; and &lsquo;<samp><span class="samp">&gt;</span></samp>&rsquo;). 
<li>Optional entities are enclosed between braces (&lsquo;<samp><span class="samp">[</span></samp>&rsquo; and &lsquo;<samp><span class="samp">]</span></samp>&rsquo;). 
<li>A sequence of zero or more occurrences of an entity is denoted by
&lsquo;<samp><span class="samp">[entity ...]</span></samp>&rsquo;. 
<li>A vertical line character (&lsquo;<samp><span class="samp">|</span></samp>&rsquo;) separates alternatives. Alternation
has lower precedence  than concatenation. 
<li>Comments follow &lsquo;<samp><span class="samp">//</span></samp>&rsquo; characters. 
<li>A single byte that is not a printable character is denoted using a
hexadecimal number with the notation &lsquo;<samp><span class="samp">\xDD</span></samp>&rsquo;, where each D is a
hexadecimal digit. 
<li>A literal single-quote character is denoted by &lsquo;<samp><span class="samp">\'</span></samp>&rsquo;, and a literal
back-slash character is denoted by &lsquo;<samp><span class="samp">\\</span></samp>&rsquo;. 
</ul>

   <p>Following the grammar, a few additional notes are included to specify
format characteristics that are impractical to capture in a BNF
grammar, and to note some special cases for implementers.  Comments in
the grammar point to the notes and special cases, and help to clarify
the intent of elements of the format.

<ul class="menu">
<li><a accesskey="1" href="#Classic-Format-Spec">Classic Format Spec</a>:          Detailed Format Information
<li><a accesskey="2" href="#Computing-Offsets">Computing Offsets</a>:            How to Get the Data You Want
<li><a accesskey="3" href="#Examples">Examples</a>:                     The Binary Layout of some Simple Files
</ul>

<div class="node">
<a name="Classic-Format-Spec"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Computing-Offsets">Computing Offsets</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#NetCDF-Classic-Format">NetCDF Classic Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Classic-Format">NetCDF Classic Format</a>

</div>

<h4 class="unnumberedsubsec">The Format in Detail</h4>

<pre class="example">     netcdf_file  = header  data
     header       = magic  numrecs  dim_list  gatt_list  var_list
     magic        = 'C'  'D'  'F'  VERSION
     VERSION      = \x01 |                      // classic format
                    \x02                        // 64-bit offset format
     numrecs      = NON_NEG | STREAMING         // length of record dimension
     dim_list     = ABSENT | NC_DIMENSION  nelems  [dim ...]
     gatt_list    = att_list                    // global attributes
     att_list     = ABSENT | NC_ATTRIBUTE  nelems  [attr ...]
     var_list     = ABSENT | NC_VARIABLE   nelems  [var ...]
     ABSENT       = ZERO  ZERO                  // Means list is not present
     ZERO         = \x00 \x00 \x00 \x00         // 32-bit zero
     NC_DIMENSION = \x00 \x00 \x00 \x0A         // tag for list of dimensions
     NC_VARIABLE  = \x00 \x00 \x00 \x0B         // tag for list of variables
     NC_ATTRIBUTE = \x00 \x00 \x00 \x0C         // tag for list of attributes
     nelems       = NON_NEG       // number of elements in following sequence
     dim          = name  dim_length
     name         = nelems  namestring
                         // Names a dimension, variable, or attribute.
                         // Names should match the regular expression
                         // ([a-zA-Z0-9_]|{MUTF8})([^\x00-\x1F/\x7F-\xFF]|{MUTF8})*
                         // For other constraints, see "Note on names", below.
     namestring   = ID1 [IDN ...] padding
     ID1          = alphanumeric | '_'
     IDN          = alphanumeric | special1 | special2
     alphanumeric = lowercase | uppercase | numeric | MUTF8
     lowercase    = 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'|'k'|'l'|'m'|
                    'n'|'o'|'p'|'q'|'r'|'s'|'t'|'u'|'v'|'w'|'x'|'y'|'z'
     uppercase    = 'A'|'B'|'C'|'D'|'E'|'F'|'G'|'H'|'I'|'J'|'K'|'L'|'M'|
                    'N'|'O'|'P'|'Q'|'R'|'S'|'T'|'U'|'V'|'W'|'X'|'Y'|'Z'
     numeric      = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
                                  // special1 chars have traditionally been
                                  // permitted in netCDF names.
     special1     = '_'|'.'|'@'|'+'|'-'
                                  // special2 chars are recently permitted in
                                  // names (and require escaping in CDL).
                                  // Note: '/' is not permitted.
     special2     = ' ' | '!' | '"' | '#'  | '$' | '%' | '&amp;' | '\'' |
                    '(' | ')' | '*' | ','  | ':' | ';' | '&lt;' | '='  |
                    '&gt;' | '?' | '[' | '\\' | ']' | '^' | '`' | '{'  |
                    '|' | '}' | '~'
     MUTF8        = &lt;multibyte UTF-8 encoded, NFC-normalized Unicode character&gt;
     dim_length   = NON_NEG       // If zero, this is the record dimension.
                                  // There can be at most one record dimension.
     attr         = name  nc_type  nelems  [values ...]
     nc_type      = NC_BYTE   |
                    NC_CHAR   |
                    NC_SHORT  |
                    NC_INT    |
                    NC_FLOAT  |
                    NC_DOUBLE
     var          = name  nelems  [dimid ...]  vatt_list  nc_type  vsize  begin
                                  // nelems is the dimensionality (rank) of the
                                  // variable: 0 for scalar, 1 for vector, 2
                                  // for matrix, ...
     dimid        = NON_NEG       // Dimension ID (index into dim_list) for
                                  // variable shape.  We say this is a "record
                                  // variable" if and only if the first
                                  // dimension is the record dimension.
     vatt_list    = att_list      // Variable-specific attributes
     vsize        = NON_NEG       // Variable size.  If not a record variable,
                                  // the amount of space in bytes allocated to
                                  // the variable's data.  If a record variable,
                                  // the amount of space per record.  See "Note
                                  // on vsize", below.
     begin        = OFFSET        // Variable start location.  The offset in
                                  // bytes (seek index) in the file of the
                                  // beginning of data for this variable.
     data         = non_recs  recs
     non_recs     = [vardata ...] // The data for all non-record variables,
                                  // stored contiguously for each variable, in
                                  // the same order the variables occur in the
                                  // header.
     vardata      = [values ...]  // All data for a non-record variable, as a
                                  // block of values of the same type as the
                                  // variable, in row-major order (last
                                  // dimension varying fastest).
     recs         = [record ...]  // The data for all record variables are
                                  // stored interleaved at the end of the
                                  // file.
     record       = [varslab ...] // Each record consists of the n-th slab
                                  // from each record variable, for example
                                  // x[n,...], y[n,...], z[n,...] where the
                                  // first index is the record number, which
                                  // is the unlimited dimension index.
     varslab      = [values ...]  // One record of data for a variable, a
                                  // block of values all of the same type as
                                  // the variable in row-major order (last
                                  // index varying fastest).
     values       = bytes | chars | shorts | ints | floats | doubles
     string       = nelems  [chars]
     bytes        = [BYTE ...]  padding
     chars        = [CHAR ...]  padding
     shorts       = [SHORT ...]  padding
     ints         = [INT ...]
     floats       = [FLOAT ...]
     doubles      = [DOUBLE ...]
     padding      = &lt;0, 1, 2, or 3 bytes to next 4-byte boundary&gt;
                                  // Header padding uses null (\x00) bytes.  In
                                  // data, padding uses variable's fill value.
                                  // See "Note on padding", below, for a special
                                  // case.
     NON_NEG      = &lt;non-negative INT&gt;
     STREAMING    = \xFF \xFF \xFF \xFF   // Indicates indeterminate record
                                          // count, allows streaming data
     OFFSET       = &lt;non-negative INT&gt; |  // For classic format or
                    &lt;non-negative INT64&gt;  // for 64-bit offset format
     BYTE         = &lt;8-bit byte&gt;          // See "Note on byte data", below.
     CHAR         = &lt;8-bit byte&gt;          // See "Note on char data", below.
     SHORT        = &lt;16-bit signed integer, Bigendian, two's complement&gt;
     INT          = &lt;32-bit signed integer, Bigendian, two's complement&gt;
     INT64        = &lt;64-bit signed integer, Bigendian, two's complement&gt;
     FLOAT        = &lt;32-bit IEEE single-precision float, Bigendian&gt;
     DOUBLE       = &lt;64-bit IEEE double-precision float, Bigendian&gt;
                                  // following type tags are 32-bit integers
     NC_BYTE      = \x00 \x00 \x00 \x01       // 8-bit signed integers
     NC_CHAR      = \x00 \x00 \x00 \x02       // text characters
     NC_SHORT     = \x00 \x00 \x00 \x03       // 16-bit signed integers
     NC_INT       = \x00 \x00 \x00 \x04       // 32-bit signed integers
     NC_FLOAT     = \x00 \x00 \x00 \x05       // IEEE single precision floats
     NC_DOUBLE    = \x00 \x00 \x00 \x06       // IEEE double precision floats
                                  // Default fill values for each type, may be
                                  // overridden by variable attribute named
                                  // `_FillValue'. See "Note on fill values",
                                  // below.
     FILL_CHAR    = \x00                      // null byte
     FILL_BYTE    = \x81                      // (signed char) -127
     FILL_SHORT   = \x80 \x01                 // (short) -32767
     FILL_INT     = \x80 \x00 \x00 \x01       // (int) -2147483647
     FILL_FLOAT   = \x7C \xF0 \x00 \x00       // (float) 9.9692099683868690e+36
     FILL_DOUBLE  = \x47 \x9E \x00 \x00 \x00 \x00 //(double)9.9692099683868690e+36
</pre>
   <p>Note on <code>vsize</code>: This number is the product of the dimension lengths
(omitting the record dimension) and the number of bytes per value
(determined from the type), increased to the next multiple of 4, for
each variable.  If a record variable, this is the amount of space per
record (except that, for backward compatibility, it always includes
padding to the next multiple of 4 bytes, even in the exceptional case
noted below under &ldquo;Note on padding&rdquo;).  The netCDF &ldquo;record size&rdquo; is
calculated as the sum of the <code>vsize</code>'s of all the record variables.

   <p>The <code>vsize</code> field is actually redundant, because its value may be
computed from other information in the header. The 32-bit <code>vsize</code> field
is not large enough to contain the size of variables that require more
than 2^32 - 4 bytes, so 2^32 - 1 is used in the <code>vsize</code> field for such
variables.

   <p>Note on names: Earlier versions of the netCDF C-library reference
implementation enforced a more restricted set of characters in
creating new names, but permitted reading names containing arbitrary
bytes.  This specification extends the permitted characters in names
to include multi-byte UTF-8 encoded Unicode and additional printing
characters from the US-ASCII alphabet. The first character of a name
must be alphanumeric, a multi-byte UTF-8 character, or '_'
(reserved for special names with meaning to implementations,
such as the &ldquo;_FillValue&rdquo; attribute).  Subsequent characters may also
include printing special characters, except for '/' which is not
allowed in names.  Names that have trailing space characters are also
not permitted.

   <p>Implementations of the netCDF classic and 64-bit offset format must
ensure that names are normalized according to Unicode NFC
normalization rules during encoding as UTF-8 for storing in the file
header.  This is necessary to ensure that gratuitous differences in
the representation of Unicode names do not cause anomalies in
comparing files and querying data objects by name.

   <p>Note on streaming data: The largest possible record count, 2^32
- 1, is reserved to indicate an indeterminate number of records. 
This means that the number of records in the file must be determined
by other means, such as reading them or computing the current number
of records from the file length and other information in the header. 
It also means that the numrecs field in the header will not be updated
as records are added to the file.  [This feature is not yet
implemented].

   <p>Note on padding: In the special case when there is only one record
variable and it is of type character, byte, or short, no padding is
used between record slabs, so records after the first record do not
necessarily start on four-byte boundaries.  However, as noted above
under &ldquo;Note on <code>vsize</code>&rdquo;, the <code>vsize</code> field is computed to
include padding to the next multiple of 4 bytes.  In this case,
readers should ignore <code>vsize</code> and assume no padding.  Writers
should store <code>vsize</code> as if padding were included.

   <p>Note on byte data: It is possible to interpret byte data as either
signed (-128 to 127) or unsigned (0 to 255). When reading byte data
through an interface that converts it into another numeric type, the
default interpretation is signed.  There are various attribute
conventions for specifying whether bytes represent signed or unsigned
data, but no standard convention has been established.  The variable
attribute &ldquo;_Unsigned&rdquo; is reserved for this purpose in future
implementations.

   <p>Note on char data: Although the characters used in netCDF names must
be encoded as UTF-8, character data may use other encodings. The
variable attribute &ldquo;_Encoding&rdquo; is reserved for this purpose in future
implementations.

   <p>Note on fill values: Because data variables may be created before
their values are written, and because values need not be written
sequentially in a netCDF file, default &ldquo;fill values&rdquo; are defined for
each type, for initializing data values before they are explicitly
written.  This makes it possible to detect reading values that were
never written.  The variable attribute &ldquo;_FillValue&rdquo;, if present,
overrides the default fill value for a variable. If _FillValue is
defined then it should be scalar and of the same type as the variable.

   <p>Fill values are not required, however, because netCDF libraries have
traditionally supported a &ldquo;no fill&rdquo; mode when writing, omitting the
initialization of variable values with fill values. This makes the
creation of large files faster, but also eliminates the possibility of
detecting the inadvertent reading of values that haven't been written.

<div class="node">
<a name="Computing-Offsets"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Examples">Examples</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Classic-Format-Spec">Classic Format Spec</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Classic-Format">NetCDF Classic Format</a>

</div>

<h4 class="unnumberedsubsec">Notes on Computing File Offsets</h4>

<p>The offset (position within the file) of a specified data value in a
classic format or 64-bit offset data file is completely determined by
the variable start location (the offset in the <code>begin</code> field), the
external type of the variable (the <code>nc_type</code> field), and the
dimension indices (one for each of the variable's dimensions) of the
value desired.

   <p>The external size in bytes of one data value for each possible
netCDF type, denoted <code>extsize</code> below, is:

   <p><table summary=""><tr align="left"><td valign="top" width="1%"><code>NC_BYTE</code>
</td><td valign="top" width="10%">1
<br></td></tr><tr align="left"><td valign="top" width="1%"><code>NC_CHAR</code>
</td><td valign="top" width="10%">1
<br></td></tr><tr align="left"><td valign="top" width="1%"><code>NC_SHORT</code>
</td><td valign="top" width="10%">2
<br></td></tr><tr align="left"><td valign="top" width="1%"><code>NC_INT</code>
</td><td valign="top" width="10%">4
<br></td></tr><tr align="left"><td valign="top" width="1%"><code>NC_FLOAT</code>
</td><td valign="top" width="10%">4
<br></td></tr><tr align="left"><td valign="top" width="1%"><code>NC_DOUBLE</code>
</td><td valign="top" width="10%">8
   <br></td></tr></table>

   <p>The record size, denoted by <code>recsize</code> below, is the sum of the <code>vsize</code>
fields of record variables (variables that use the unlimited
dimension), using the actual value determined by dimension sizes and
variable type in case the <code>vsize</code> field is too small for the variable
size.

   <p>To compute the offset of a value relative to the beginning of a
variable, it is helpful to precompute a &ldquo;product vector&rdquo; from the
dimension lengths.  Form the products of the dimension lengths for the
variable from right to left, skipping the leftmost (record) dimension
for record variables, and storing the results as the product vector
for each variable.

   <p>For example:

   <p>Non-record variable:

   <p>dimension lengths:      [  5  3  2 7]
        product vector:         [210 42 14 7]

   <p>Record variable:

   <p>dimension lengths:      [0  2  9 4]
        product vector:         [0 72 36 4]

   <p>At this point, the leftmost product, when rounded up to the next
multiple of 4, is the variable size, <code>vsize</code>, in the grammar above. For
example, in the non-record variable above, the value of the <code>vsize</code>
field is 212 (210 rounded up to a multiple of 4). For the record
variable, the value of <code>vsize</code> is just 72, since this is already a
multiple of 4.

   <p>Let coord be the array of coordinates (dimension indices, zero-based)
of the desired data value.  Then the offset of the value from the
beginning of the file is just the file offset of the first data value
of the desired variable (its <code>begin</code> field) added to the inner product
of the coord and product vectors times the size, in bytes, of each
datum for the variable. Finally, if the variable is a record variable,
the product of the record number, 'coord[0]', and the record size,
<code>recsize</code>, is added to yield the final offset value.

   <p>A special case: Where there is exactly one record variable, we drop
the requirement that each record be four-byte aligned, so in this case
there is no record padding.

<div class="node">
<a name="Examples"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Computing-Offsets">Computing Offsets</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#NetCDF-Classic-Format">NetCDF Classic Format</a>

</div>

<h4 class="unnumberedsubsec">Examples</h4>

<p>By using the grammar above, we can derive the smallest valid netCDF
file, having no dimensions, no variables, no attributes, and hence, no
data. A CDL representation of the empty netCDF file is

   <p>netcdf empty { }

   <p>This empty netCDF file has 32 bytes. It begins with the four-byte
&ldquo;magic number&rdquo; that identifies it as a netCDF version 1 file:
&lsquo;<samp><span class="samp">C</span></samp>&rsquo;, &lsquo;<samp><span class="samp">D</span></samp>&rsquo;, &lsquo;<samp><span class="samp">F</span></samp>&rsquo;, &lsquo;<samp><span class="samp">\x01</span></samp>&rsquo;. Following are seven 32-bit
integer zeros representing the number of records, an empty list of
dimensions, an empty list of global attributes, and an empty list of
variables.

   <p>Below is an (edited) dump of the file produced using the Unix command

   <p>od -xcs empty.nc

   <p>Each 16-byte portion of the file is displayed with 4 lines. The first
line displays the bytes in hexadecimal. The second line displays the
bytes as characters. The third line displays each group of two
bytes interpreted as a signed 16-bit integer. The fourth line (added
by human) presents the interpretation of the bytes in terms of netCDF
components and values.

<pre class="example">        4344    4601    0000    0000    0000    0000    0000    0000
       C   D   F 001  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
       17220   17921   00000   00000   00000   00000   00000   00000
     [magic number ] [  0 records  ] [  0 dimensions   (ABSENT)    ]
     
        0000    0000    0000    0000    0000    0000    0000    0000
      \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
       00000   00000   00000   00000   00000   00000   00000   00000
     [  0 global atts  (ABSENT)    ] [  0 variables    (ABSENT)    ]
</pre>
   <p>As a less trivial example, consider the CDL

<pre class="example">     netcdf tiny {
     dimensions:
             dim = 5;
     variables:
             short vx(dim);
     data:
             vx = 3, 1, 4, 1, 5 ;
     }
</pre>
   <p>which corresponds to a 92-byte netCDF file. The following is an edited
dump of this file:

<pre class="example">        4344    4601    0000    0000    0000    000a    0000    0001
       C   D   F 001  \0  \0  \0  \0  \0  \0  \0  \n  \0  \0  \0 001
       17220   17921   00000   00000   00000   00010   00000   00001
     [magic number ] [  0 records  ] [NC_DIMENSION ] [ 1 dimension ]
     
        0000    0003    6469    6d00    0000    0005    0000    0000
      \0  \0  \0 003   d   i   m  \0  \0  \0  \0 005  \0  \0  \0  \0
       00000   00003   25705   27904   00000   00005   00000   00000
     [  3 char name = "dim"        ] [ size = 5    ] [ 0 global atts
     
        0000    0000    0000    000b    0000    0001    0000    0002
      \0  \0  \0  \0  \0  \0  \0 013  \0  \0  \0 001  \0  \0  \0 002
       00000   00000   00000   00011   00000   00001   00000   00002
      (ABSENT)     ] [NC_VARIABLE  ] [ 1 variable  ] [ 2 char name =
     
        7678    0000    0000    0001    0000    0000    0000    0000
       v   x  \0  \0  \0  \0  \0 001  \0  \0  \0  \0  \0  \0  \0  \0
       30328   00000   00000   00001   00000   00000   00000   00000
      "vx"         ] [1 dimension  ] [ with ID 0   ] [ 0 attributes
     
        0000    0000    0000    0003    0000    000c    0000    0050
      \0  \0  \0  \0  \0  \0  \0 003  \0  \0  \0  \f  \0  \0  \0   P
       00000   00000   00000   00003   00000   00012   00000   00080
      (ABSENT)     ] [type NC_SHORT] [size 12 bytes] [offset:    80]
     
        0003    0001    0004    0001    0005    8001
      \0 003  \0 001  \0 004  \0 001  \0 005 200 001
       00003   00001   00004   00001   00005  -32767
     [    3] [    1] [    4] [    1] [    5] [fill ]
</pre>
   <div class="node">
<a name="64-bit-Offset-Format"></a>
<a name="g_t64_002dbit-Offset-Format"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#NetCDF_002d4-Format">NetCDF-4 Format</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#NetCDF-Classic-Format">NetCDF Classic Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#File-Format">File Format</a>

</div>

<h3 class="section">C.2 The 64-bit Offset Format</h3>

<p>The netCDF 64-bit offset format differs from the classic format
only in the VERSION byte, &lsquo;<samp><span class="samp">\x02</span></samp>&rsquo; instead of &lsquo;<samp><span class="samp">\x01</span></samp>&rsquo;, and the OFFSET
entity, a 64-bit instead of a 32-bit offset from the beginning of the
file.  This small format change permits much larger files, but there
are still some practical size restrictions.  Each fixed-size variable
and the data for one record's worth of each record variable are still
limited in size to a little less that 4 GiB.  The rationale for this
limitation is to permit aggregate access to all the data in a netCDF
variable (or a record's worth of data) on 32-bit platforms.

<div class="node">
<a name="NetCDF-4-Format"></a>
<a name="NetCDF_002d4-Format"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#NetCDF_002d4-Classic-Model-Format">NetCDF-4 Classic Model Format</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#g_t64_002dbit-Offset-Format">64-bit Offset Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#File-Format">File Format</a>

</div>

<h3 class="section">C.3 The NetCDF-4 Format</h3>

<p>The netCDF-4 format implements and expands the netCDF-3 data model by
using an enhanced version of HDF5 as the storage layer.  Use is
made of features that are only available in HDF5 version 1.8 and
later.

   <p>Using HDF5 as the underlying storage layer, netCDF-4 files remove many
of the restrictions for classic and 64-bit offset files.  The richer
enhanced model supports user-defined types and data structures,
hierarchical scoping of names using groups, additional primitive types
including strings, larger variable sizes, and multiple unlimited
dimensions.  The underlying HDF5 storage layer also supports
per-variable compression, multidimensional tiling, and efficient
dynamic schema changes, so that data need not be copied when adding
new variables to the file schema.

   <p>Creating a netCDF-4/HDF5 file with netCDF-4 results in an HDF5
file. The features of netCDF-4 are a subset of the features of HDF5,
so the resulting file can be used by any existing HDF5 application.

   <p>Although every file in netCDF-4 format is an HDF5 file, there are HDF5
files that are not netCDF-4 format files, because the netCDF-4 format
intentionally uses a limited subset of the HDF5 data model and file
format features.  Some HDF5 features not supported in the netCDF
enhanced model and netCDF-4 format include non-hierarchical group
structures, HDF5 reference types, multiple links to a data object,
user-defined atomic data types, stored property lists, more permissive
rules for data object names, the HDF5 date/time type, and attributes
associated with user-defined types.

   <p>A complete specification of HDF5 files is beyond the scope of this
document.  For more information about HDF5, see the HDF5 web site:
<a href="http://hdf.ncsa.uiuc.edu/HDF5/">http://hdf.ncsa.uiuc.edu/HDF5/</a>.

   <p>The specification that follows is sufficient to allow HDF5 users to
create files that will be accessable from netCDF-4.

<h4 class="subsection">C.3.1 Creation Order</h4>

<p>The netCDF API maintains the creation order of objects that are
created in the file. The same is not true in HDF5, which maintains the
objects in alphabetical order. Starting in version 1.8 of HDF5, the
ability to maintain creation order was added. This must be explicitly
turned on in the HDF5 data file in several ways.

   <p>Each group must have link and attribute creation order set. The
following code (from libsrc4/nc4hdf.c) shows how the netCDF-4 library
sets these when creating a group.

<pre class="example">           /* Create group, with link_creation_order set in the group
            * creation property list. */
           if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) &lt; 0)
              return NC_EHDFERR;
           if (H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED|H5P_CRT_ORDER_INDEXED) &lt; 0)
              BAIL(NC_EHDFERR);
           if (H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED|H5P_CRT_ORDER_INDEXED) &lt; 0)
              BAIL(NC_EHDFERR);
           if ((grp-&gt;hdf_grpid = H5Gcreate2(grp-&gt;parent-&gt;hdf_grpid, grp-&gt;name,
                                            H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) &lt; 0)
              BAIL(NC_EHDFERR);
           if (H5Pclose(gcpl_id) &lt; 0)
              BAIL(NC_EHDFERR);
</pre>
   <p>Each dataset in the HDF5 file must be created with a property list for
which the attribute creation order has been set to creation
ordering. The H5Pset_attr_creation_order funtion is used to set the
creation ordering of attributes of a variable.

   <p>The following example code (from libsrc4/nc4hdf.c) shows how the
creation ordering is turned on by the netCDF library.

<pre class="example">        /* Turn on creation order tracking. */
        if (H5Pset_attr_creation_order(plistid, H5P_CRT_ORDER_TRACKED|
                                       H5P_CRT_ORDER_INDEXED) &lt; 0)
           BAIL(NC_EHDFERR);
</pre>
   <h4 class="subsection">C.3.2 Groups</h4>

<p>NetCDF-4 groups are the same as HDF5 groups, but groups in a netCDF-4
file must be strictly hierarchical. In general, HDF5 permits
non-hierarchical structuring of groups (for example, a group that is
its own grandparent). These non-hierarchical relationships are not
allowed in netCDF-4 files.

   <p>In the netCDF API, the global attribute becomes a group-level
attribute. That is, each group may have its own global
attributes.

   <p>The root group of a file is named &ldquo;/&rdquo; in the netCDF API, where names
of groups are used. It should be noted that the netCDF API (like the
HDF5 API) makes little use of names, and refers to entities by number.

<h4 class="subsection">C.3.3 Dimensions with HDF5 Dimension Scales</h4>

<p>Until version 1.8, HDF5 did not have any capability to represent
shared dimensions. With the 1.8 release, HDF5 introduced the dimension
scale feature to allow shared dimensions in HDF5 files.

   <p>The dimension scale is unfortunately not exactly equivilent to the
netCDF shared dimension, and this leads to a number of compromises in
the design of netCDF-4.

   <p>A netCDF shared dimension consists solely of a length and a name. An
HDF5 dimension scale also includes values for each point along the
dimension, information that is (optionally) included in a netCDF
coordinate variable.

   <p>To handle the case of a netCDF dimension without a coordinate
variable, netCDF-4 creates dimension scales of type char, and leaves
the contents of the dimension scale empty. Only the name and length of
the scale are significant. To distinguish this case, netCDF-4 takes
advantage of the NAME attribute of the dimension scale. (Not to be
confused with the name of the scale itself.) In the case of dimensions
without coordinate data, the HDF5 dimension scale NAME attribute is
set to the string: "This is a netCDF dimension but not a netCDF
variable."

   <p>In the case where a coordinate variable is defined for a dimension,
the HDF5 dimscale matches the type of the netCDF coordinate variable,
and contains the coordinate data.

   <p>A further difficulty arrises when an n-dimensional coordinate
variable is defined, where n is greater than one. NetCDF allows such
coordinate variables, but the HDF5 model does not allow dimension
scales to be attached to other dimension scales, making it impossible
to completely represent the multi-dimensional coordinate variables of
the netCDF model.

   <p>To capture this information, multidimensional coordinate variables
have an attribute named _Netcdf4Coordinates. The attribute is an array
of H5T_NATIVE_INT, with the netCDF dimension IDs of each of its
dimensions.

   <p>The _Netcdf4Coordinates attribute is otherwise hidden by the netCDF
API. It does not appear as one of the attributes for the netCDF
variable involved, except through the HDF5 API.

<h4 class="subsection">C.3.4 Dimensions without HDF5 Dimension Scales</h4>

<p>Starting with the netCDF-4.1 release, netCDF can read HDF5 files which
do not use dimension scales. In this case the netCDF library assigns
dimensions to the HDF5 dataset as needed, based on the length of the
dimension.

   <p>When an HDF5 file is opened, each dataset is examined in
turn. The lengths of all the dimensions involved in the shape of the
dataset are determined. Each new (i.e. previously unencountered)
length results in the creation of a phony dimension in the netCDF API.

   <p>This will not accurately detect a shared, unlimited dimension in the
HDF5 file, if different datasets have different lengths along this
dimension (possible in HDF5, but not in netCDF).

   <p>Note that this is a read-only capability for the netCDF library. When
the netCDF library writes HDF5 files, they always use a dimension
scale for every dimension.

   <p>Datasets must have either dimension scales for every dimension, or no
dimension scales at all. Partial dimension scales are not, at this
time, understood by the netCDF library.

<h4 class="subsection">C.3.5 Dimension and Coordinate Variable Ordering</h4>

<p>In order to preserve creation order, the netCDF-4 library writes
variables in their creation order. Since some variables are also
dimension scales, their order reflects both the order of the
dimensions and the order of the coordinate variables.

   <p>However, these may be different. Consider the following code:

<pre class="example">           /* Create a test file. */
           if (nc_create(FILE_NAME, NC_CLASSIC_MODEL|NC_NETCDF4, &amp;ncid)) ERR;
     
           /* Define dimensions in order. */
           if (nc_def_dim(ncid, DIM0, NC_UNLIMITED, &amp;dimids[0])) ERR;
           if (nc_def_dim(ncid, DIM1, 4, &amp;dimids[1])) ERR;
     
           /* Define coordinate variables in a different order. */
           if (nc_def_var(ncid, DIM1, NC_DOUBLE, 1, &amp;dimids[1], &amp;varid[1])) ERR;
           if (nc_def_var(ncid, DIM0, NC_DOUBLE, 1, &amp;dimids[0], &amp;varid[0])) ERR;
</pre>
   <p>In this case the order of the coordinate variables will be different
from the order of the dimensions.

   <p>In practice, this should make little difference in user code, but if
the user is writing code that depends on the ordering of dimensions,
the netCDF library was updated in version 4.1 to detect this
condition, and add the attribute _Netcdf4Dimid to the dimension scales
in the HDF5 file. This attribute holds a scalar H5T_NATIVE_INT which
is the (zero-based) dimension ID for this dimension.

   <p>If this attribute is present on any dimension scale, it must be
present on all dimension scales in the file.

<h4 class="subsection">C.3.6 Variables</h4>

<p>Variables in netCDF-4/HDF5 files exactly correspond to HDF5
datasets. The data types match naturally between netCDF and HDF5.

   <p>In netCDF classic format, the problem of endianness is solved by
writing all data in big-endian order. The HDF5 library allows data to
be written as either big or little endian, and automatically reorders
the data when it is read, if necessary.

   <p>By default, netCDF uses the native types on the machine which writes
the data. Users may change the endianness of a variable (before any
data are written). In that case the specified endian type will be used
in HDF5 (for example, a H5T_STD_I16LE will be used for NC_SHORT, if
little-endian has been specified for that variable.)

     <dl>
<dt><code>NC_BYTE</code><dd>H5T_NATIVE_SCHAR

     <br><dt><code>NC_UBYTE</code><dd>H5T_NATIVE_SCHAR

     <br><dt><code>NC_CHAR</code><dd>H5T_C_S1

     <br><dt><code>NC_STRING</code><dd>variable length array of H5T_C_S1

     <br><dt><code>NC_SHORT</code><dd>H5T_NATIVE_SHORT

     <br><dt><code>NC_USHORT</code><dd>H5T_NATIVE_USHORT

     <br><dt><code>NC_INT</code><dd>H5T_NATIVE_INT

     <br><dt><code>NC_UINT</code><dd>H5T_NATIVE_UINT

     <br><dt><code>NC_INT64</code><dd>H5T_NATIVE_LLONG

     <br><dt><code>NC_UINT64</code><dd>H5T_NATIVE_ULLONG

     <br><dt><code>NC_FLOAT</code><dd>H5T_NATIVE_FLOAT

     <br><dt><code>NC_DOUBLE</code><dd>H5T_NATIVE_DOUBLE

   </dl>

   <p>The NC_CHAR type represents a single character, and the NC_STRING an
array of characters. This can be confusing because a one-dimensional
array of NC_CHAR is used to represent a string (i.e. a scalar
NC_STRING).

   <p>An odd case may arise in which the user defines a variable with the
same name as a dimension, but which is not intended to be the
coordinate variable for that dimension. In this case the string
"_nc4_non_coord_" is pre-pended to the name of the HDF5 dataset, and
stripped from the name for the netCDF API.

<h4 class="subsection">C.3.7 Attributes</h4>

<p>Attributes in HDF5 and netCDF-4 correspond very closely. Each
attribute in an HDF5 file is represented as an attribute in the netCDF-4
file, with the exception of the attributes below, which are ignored by
the netCDF-4 API.

     <dl>
<dt><code>_Netcdf4Coordinates</code><dd>An integer array containing the dimension IDs of a variable which is a
multi-dimensional coordinate variable.

     <br><dt><code>_nc3_strict</code><dd>When this (scalar, H5T_NATIVE_INT) attribute exists in the root group
of the HDF5 file, the netCDF API will enforce the netCDF classic model
on the data file.

     <br><dt><code>REFERENCE_LIST</code><dd>This attribute is created and maintained by the HDF5 dimension scale
API.

     <br><dt><code>CLASS</code><dd>This attribute is created and maintained by the HDF5 dimension scale
API. 
<br><dt><code>DIMENSION_LIST</code><dd>This attribute is created and maintained by the HDF5 dimension scale
API. 
<br><dt><code>NAME</code><dd>This attribute is created and maintained by the HDF5 dimension scale
API.

   </dl>

<h4 class="subsection">C.3.8 User-Defined Data Types</h4>

<p>Each user-defined data type in an HDF5 file exactly corresponds to a
user-defined data type in the netCDF-4 file. Only base data types which
correspond to netCDF-4 data types may be used. (For example, no
HDF5 reference data types may be used.)

<h4 class="subsection">C.3.9 Compression</h4>

<p>The HDF5 library provides data compression using the zlib library and
the szlib library. NetCDF-4 only allows users to create data with the
zlib library (due to licensing restrictions on the szlib
library). Since HDF5 supports the transparent reading of the data with
either compression filter, the netCDF-4 library can read data
compressed with szlib (if the underlying HDF5 library is built to
support szlib), but has no way to write data with szlib compression.

   <p>With zlib compression (a.k.a. deflation) the user may set a deflation
factor from 0 to 9. In our measurements the zero deflation level does
not compress the data, but does incur the performance penalty of
compressing the data. The netCDF API does not allow the user to write
a variable with zlib deflation of 0 - when asked to do so, it turns
off deflation for the variable instead. NetCDF can read an HDF5 file
with deflation of zero, and correctly report that to the user.

<div class="node">
<a name="NetCDF-4-Classic-Model-Format"></a>
<a name="NetCDF_002d4-Classic-Model-Format"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#HDF4-SD-Format">HDF4 SD Format</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#NetCDF_002d4-Format">NetCDF-4 Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#File-Format">File Format</a>

</div>

<h3 class="section">C.4 The NetCDF-4 Classic Model Format</h3>

<p>Every classic and 64-bit offset file can be represented as a netCDF-4
file, with no loss of information.  There are some significant
benefits to using the simpler netCDF classic model with the netCDF-4
file format.  For example, software that writes or reads classic model
data can write or read netCDF-4 classic model format data by
recompiling/relinking to a netCDF-4 API library, with no or only
trivial changes needed to the program source code.  The netCDF-4
classic model format supports this usage by enforcing rules on what
functions may be called to store data in the file, to make sure its
data can be read by older netCDF applications (when relinked to a netCDF-4
library).

   <p>Writing data in this format prevents use of enhanced model features
such as groups, added primitive types not available in the classic
model, and user-defined types.  However performance features of the
netCDF-4 formats that do not require additional features of the
enhanced model, such as per-variable compression and chunking,
efficient dynamic schema changes, and larger variable size limits,
offer potentially significant performance improvements to readers of
data stored in this format, without requiring program changes.

   <p>When a file is created via the netCDF API with a CLASSIC_MODEL mode
flag, the library creates an attribute (_nc3_strict) in the root
group. This attribute is hidden by the netCDF API, but is read when
the file is later opened, and used to ensure that no enhanced model
features are written to the file.

<div class="node">
<a name="HDF4-SD-Format"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#NetCDF_002d4-Classic-Model-Format">NetCDF-4 Classic Model Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#File-Format">File Format</a>

</div>

<h3 class="section">C.5 HDF4 SD Format</h3>

<p>Starting with version 4.1, the netCDF libraries can read HDF4 SD
(Scientific Dataset) files. Access is limited to those HDF4 files
created with the Scientific Dataset API. Access is read-only.

   <p>Dataset types are translated between HDF4 and netCDF in a
straighforward manner.

     <dl>
<dt><code>DFNT_CHAR</code><dd>NC_CHAR
<br><dt><code>DFNT_UCHAR, DFNT_UINT8</code><dd>NC_UBYTE
<br><dt><code>DFNT_INT8</code><dd>NC_BYTE
<br><dt><code>DFNT_INT16</code><dd>NC_SHORT
<br><dt><code>DFNT_UINT16</code><dd>NC_USHORT
<br><dt><code>DFNT_INT32</code><dd>NC_INT
<br><dt><code>DFNT_UINT32</code><dd>NC_UINT
<br><dt><code>DFNT_FLOAT32</code><dd>NC_FLOAT
<br><dt><code>DFNT_FLOAT64</code><dd>NC_DOUBLE
</dl>

<div class="node">
<a name="Internal-Dispatch-Table"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Combined-Index">Combined Index</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#File-Format">File Format</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="appendix">Appendix D Internal Dispatch Table</h2>

<h4 class="subheading">Draft 3: 5/15/2010</h4>

<h3 class="unnumberedsec">netCDF Dispatch Mechanism</h3>

<p>This document describes the architecture and details of the
new netCDF internal dispatch mechanism. The idea is that
when a user opens or creates a netcdf file, that a specific
dispatch table is chosen. Subsequent netcdf API calls are
then channeled through that dispatch table to the
appropriate function for implementing that API call.

   <p>Currently, the following four dispatch tables are supported.
     <ol type=1 start=1>
<li>netcdf classic files (netcdf-3)
<li>netcdf enhanced files (netcdf-4)
<li>OPeNDAP to netcdf-3
<li>OPeNDAP to netcdf-4
        </ol>

   <p>The dispatch table represents a distillation of the
netcdf API down to a minimal set of internal operations. The
format of the dispatch table is defined in the file
libdispatch/ncdispatch.h.  Every new dispatch table must
define this minimal set of operations.

<h3 class="unnumberedsec">Adding a New Dispatch Table</h3>

<p>In order to make this process concrete, let us assume we
plan to add an in-memory implementation of netcdf-3.

<h3 class="unnumberedsec">Step 1.</h3>

<p>Define a &ndash;enable flag and an AM_CONFIGURE flag in
configure.ac. We will use the flags &ndash;enable-netcdfm and
USE_NETCDFM respectively.

<h3 class="unnumberedsec">Step 2</h3>

<p>Choose some prefix of characters to identify the new
dispatch system. In effect we are defining a name-space. For
our in-memory system, we will choose "NCM" and "ncm". NCM is
used for non-static procedures to be entered into the
dispatch table and ncm for all other non-static procedures.

<h3 class="unnumberedsec">Step 3.</h3>

<p>Modify file libdispatch/ncdispatch.h as follows.
     <ul>
<li>Add a index for this implementation:
     <pre class="example">          #define NC_DISPATCH_NCM  5
</pre>
     <li>Define an external reference to the in-memory dispatch table.
     <pre class="example">          #ifdef USE_NETCDFM
          extern NC_Dispatch* NCM_dispatch_table;
          #endif
</pre>
     </ul>

<h3 class="unnumberedsec">Step 4.</h3>

<p>Modify file libdispatch/netcdf.c as follows.
     <ul>
<li>Add a ptr to the in-memory dispatch table.
     <pre class="example">          #ifdef USE_NETCDFM
          NC_Dispatch* NCM_dispatch_table = NULL;
          #endif
</pre>
     <li>Add any necessary #include files as needed. 
</ul>

<h3 class="unnumberedsec">Step 5.</h3>

<p>Define the functions necessary to fill in the dispatch
table. As a rule, we assume that a new directory is defined,
libsrcm, say.  Within this directory, we need to define
Makefile.am, the source files containing the dispatch table
and the functions to be placed in the dispatch table &ndash; call
them ncmdispatch.c and ncmdispatch.h. Look at
libsrc/nc3dispatch.[ch] for an example.

   <p>As part of the ncmdispatch.c file, you must define the following.
<pre class="example">     NC_Dispatch NCM_dispatcher = {
     NC_DISPATCH_NCM,
     NCM_create,
     NCM_open,
     ...
     };
     
     int
     NCM_initialize(void)
     {
         NCM_dispatch_table = &amp;NCM_dispatcher;
         return NC_NOERR;
     }
</pre>
   <p>Assuming that the in-memory library does not require any
external libraries, then the Makefile.am will look something
like this.
<pre class="example">     NCM_SOURCES = ncmdispatch.c ncmdispatch.h ...
     AM_CPPFLAGS +=  -I$(top_srcdir)/libsrc -I$(top_srcdir)/libdispatch
     libnetcdfm_la_SOURCES = $(NCM_SOURCES)
     noinst_LTLIBRARIES = libnetcdfm.la
</pre>
   <h3 class="unnumberedsec">Step 6.</h3>

<p>Provide for the inclusion of this library in the final
libnetcdf library. This is accomplished by modifying
liblib/Makefile.am by adding something like the following.
<pre class="example">     if USE_NETCDFM
        libnetcdf_la_LIBADD += $(top_builddir)/libsrcm/libnetcdfm.la
     endif
</pre>
   <h3 class="unnumberedsec">Step 7.</h3>

<p>Modify the NC_intialize function in liblib/stub.c by
adding appropriate references to the NCM dispatch function.
<pre class="example">     #ifdef USE_NETCDFM
     extern int NCM_initialize(void);
     #endif
     ...
     int NC_initialize(void)
     {
     ...
     #ifdef USE_DAP
         if((stat = NCM_initialize())) return stat;
     #endif
     ...
     }
</pre>
   <h3 class="unnumberedsec">Step 8.</h3>

<p>Add a directory of tests; ncm_test, say. The file
ncm_test/Makefile.am will look something like this.
<pre class="example">     # These files are created by the tests.
     CLEANFILES = ...
     # These are the tests which are always run.
     TESTPROGRAMS = test1 test2 ...
     test1_SOURCES = test1.c ...
     ...
     # Set up the tests.
     check_PROGRAMS = $(TESTPROGRAMS)
     TESTS = $(TESTPROGRAMS)
     # Any extra files required by the tests
     EXTRA_DIST = ...
</pre>
   <h3 class="unnumberedsec">Step 9.</h3>

<p>Provide for libnetcdfm to be constructed by adding the
following to the top-level Makefile.am.
<pre class="example">     if USE_NETCDFM
     NCM=libsrcm
     NCMTESTDIR=ncm_test
     endif
     ...
     SUBDIRS = ... $(DISPATCHDIR)  $(NCM) ... $(NCMTESTDIR)
</pre>
   <h4 class="subsection">D.0.1 Choosing a Dispatch Table</h4>

<p>The dispatch table is chosen in the NC_create and the
NC_open procedures in libdispatch/netcdf.c.  The decision is
currently based on the following pieces of information.
     <ul>
<li>The file path &ndash; this can be used to detect, for example, a DAP url versus a normal file system file. 
<li>The mode argument &ndash; this can be used to detect, for example, what kind of file to create: netcdf-3, netcdf-4, 64-bit netcdf-3, etc. 
<li>For nc_open and when the file path references a real file, the contents of the file can also be used to determine the dispatch table. 
<li>Although currently not used, this code could be modified to also use other pieces of information such as environment variables. 
</ul>

   <p>In addition to the above, there is one additional mechanism
to force the use of a specific dispatch table. The procedure
"NC_set_dispatch_override()" can be invoked to specify a
dispatch table.

   <p>When adding a new dispatcher, it is necessary to modify
NC_create and NC_open in libdispatch/netcdf.c to detect when
it is appropriate to use the NCM dispatcher. 
Some possibilities are as follows.
     <ol type=1 start=1>
<li>Add a new mode flag: say NC_NETCDFM. 
<li>Use an environment variable. 
<li>Define a special file path format that indicates the need to use a special dispatch table.
        </ol>

<h4 class="subsection">D.0.2 Special Dispatch Table Signatures.</h4>

<p>Several of the entries in the dispatch table are
significantly different than those of the external API.

<h5 class="subsubsection">D.0.2.1 Create/Open</h5>

<p>The create table entry and the open table entry have the
following signatures respectively.
<pre class="example">     int (*create)(const char *path, int cmode,
                size_t initialsz, int basepe, size_t *chunksizehintp,
                int useparallel, MPI_Comm comm, MPI_Info info,
                struct NC_Dispatch*, struct NC** ncp);
     
     int (*open)(const char *path, int mode,
              int basepe, size_t *chunksizehintp,
              int use_parallel, MPI_Comm comm, MPI_Info info,
              NC_Dispatch*, NC** ncp);
</pre>
   <p>The key difference is that these are the union of all the
possible create/open signatures from the netcdf.h API. Note
especially the last two parameters. The dispatch table is
included in case the create function (e.g. NCM_create) needs
to invoke other dispatch functions. The very last parameter
is a pointer to a pointer to an NC instance. It is expected
that the create function will allocate and fill in an
instance of an "NC" object and return a pointer to it in the
ncp parameter.

<h5 class="subsubsection">D.0.2.2 Notes:</h5>

     <ul>
<li>As with the existing code, and when MPI is not being used, the comm
and info parameters should be passed in as 0.  This is taken care of in the
nc_open and nc_create API procedures in libdispatch/netcdf.c.

     <li>In fact, the object returned in the ncp parameter does
not actually have to be an instance of struct NC.  It only
needs to "look like it for the first few fields.  This is,
in effect, a fake version of subclassing.  Let us suppose
that the NCM_create function uses a struct NCM object. The
initial part of the definition of NCM must match the fields
at the beginning of struct NC between the comments
BEGIN_COMMON and END_COMMON. So, we would have the
following.
     <pre class="example">          typedef struct NCM {
          /*BEGIN COMMON*/
                  int ext_ncid; /* uid «« 16 */
                  int int_ncid; /* unspecified other id */
                  struct NC_Dispatch* dispatch;
          #ifdef USE_DAP
                  struct NCDRNO* drno;
          #endif
          /*END COMMON*/
          ...
          } NCM;
</pre>
     <p>This allows the pointer to the NCM object to be cast as an instance of NC* and its pointer returned in the ncp file. 
Eventually, this will be replaced with a separate structure containing the common fields. 
</ul>

<h5 class="subsubsection">D.0.2.3 put_vara/get_vara</h5>

<pre class="example">     int (*put_vara)(int ncid, int varid, const size_t *start, const size_t *count,
                          const void *value, nc_type memtype);
     
     int (*get_vara)(int ncid, int varid, const size_t *start, const size_t *count,
                     void *value, nc_type memtype);
</pre>
   <p>Most of the parameters are similar to the netcdf API
parameters. The last parameter, however, is the type of the
data in memory. Additionally, instead of using an "int
islong" parameter, the memtype will be either NC_INT or
NC_INT64, depending on the value of sizeof(long). This means
that even netcdf-3 code must be prepared to encounter the
NC_INT64 type.

<h5 class="subsubsection">D.0.2.4 put_attr/get_attr</h5>

<pre class="example">     int (*get_att)(int ncid, int varid, const char *name,
                         void *value, nc_type memtype);
     
     int (*put_att)(int ncid, int varid, const char *name, nc_type datatype, size_t len,
                    const void *value, nc_type memtype);
</pre>
   <p>Again, the key difference is the memtype parameter. As with
put/get_vara, it used NC_INT64 to encode the long case.

<h4 class="subsection">D.0.3 NetCDF Library Assembly</h4>

<p>The assembly of the final libnetcdf library occurs in the directory
liblib. The Makefile uses all of the available configuration flags
to decide which component libraries will be added to libnetcdf to produce
the final library. In addition, the proper version of netcdf.h will have
been placed in liblib: either the version from libsrc or the version from
libsrc4 depending on the USE_NETCDF4 flag.

<h4 class="subsection">D.0.4 Utility Construction</h4>

<p>All of the utilities and the test directories (nctest, nc_test, ...) 
are expected to obtain their libnetcdf library and their netcdf.h
from the ones in liblib.

<h4 class="subsection">D.0.5 Miscellaneous Notes</h4>

     <ol type=1 start=1>
<li>It may be desirable to include a few test cases in the
libsrcm directory. Libsrc4, for example, has quite a number
of such tests. In order to do this, it is necessary to
create a number of stub definitions so that the library will
compile and load with the test cases. The file
libsrc/stub3.c shows a typical stub file.

     </ol>

<div class="node">
<a name="Combined-Index"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Internal-Dispatch-Table">Internal Dispatch Table</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Index</h2>

<ul class="index-cp" compact>
<li><a href="#index-g_t64_002dbit-offset-file-format-163">64-bit offset file format</a>: <a href="#Classic-File-Parts">Classic File Parts</a></li>
<li><a href="#index-g_t64_002dbit-offset-format_002c-introduction-168">64-bit offset format, introduction</a>: <a href="#Large-File-Support">Large File Support</a></li>
<li><a href="#index-g_t64_002dbit-offset-format_002c-limitations-173">64-bit offset format, limitations</a>: <a href="#g_t64-bit-Offset-Limitations">64 bit Offset Limitations</a></li>
<li><a href="#index-g_t64_002dbit-offsets_002c-history-49">64-bit offsets, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-g_t_005fFillValue-258"><code>_FillValue</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-g_t_005fIONBF-flag-186"><code>_IONBF flag</code></a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-access-C-example-of-array-section-151">access C example of array section</a>: <a href="#C-Section-Access">C Section Access</a></li>
<li><a href="#index-access-Fortran-example-of-array-section-153">access Fortran example of array section</a>: <a href="#Fortran-Section-Access">Fortran Section Access</a></li>
<li><a href="#index-access-random-146">access random</a>: <a href="#Data-Access">Data Access</a></li>
<li><a href="#index-access-shared-dataset-I_002fO-176">access shared dataset I/O</a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-ADA-API_002c-history-56">ADA API, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-add_005foffset-264"><code>add_offset</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-ancillary-data-as-attributes-128">ancillary data as attributes</a>: <a href="#Attributes-and-Variables">Attributes and Variables</a></li>
<li><a href="#index-ancillary-data_002c-storing-119">ancillary data, storing</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-API_002c-C-14">API, C</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-API_002c-C-8">API, C</a>: <a href="#Top">Top</a></li>
<li><a href="#index-API_002c-C_002b_002b-17">API, C++</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-API_002c-C_002b_002b-5">API, C++</a>: <a href="#Top">Top</a></li>
<li><a href="#index-API_002c-F90-16">API, F90</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-API_002c-Fortran-15">API, Fortran</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-API_002c-Fortran-77-6">API, Fortran 77</a>: <a href="#Top">Top</a></li>
<li><a href="#index-API_002c-Fortran-90-7">API, Fortran 90</a>: <a href="#Top">Top</a></li>
<li><a href="#index-API_002c-Java-18">API, Java</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-appending-data-along-unlimited-dimension-79">appending data along unlimited dimension</a>: <a href="#Dimensions">Dimensions</a></li>
<li><a href="#index-applications_002c-generic-121">applications, generic</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-applications_002c-generic_002c-conventions-254">applications, generic, conventions</a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-applications_002c-generic_002c-conventions-31">applications, generic, conventions</a>: <a href="#Conventions">Conventions</a></li>
<li><a href="#index-applications_002c-generic_002c-reasons-for-netCDF-200">applications, generic, reasons for netCDF</a>: <a href="#NetCDF-Utilities">NetCDF Utilities</a></li>
<li><a href="#index-applications_002c-generic_002c-units-252">applications, generic, units</a>: <a href="#Units">Units</a></li>
<li><a href="#index-archive-format-29">archive format</a>: <a href="#Archival">Archival</a></li>
<li><a href="#index-Argonne-National-Laboratory-48">Argonne National Laboratory</a>: <a href="#Background">Background</a></li>
<li><a href="#index-array-section_002c-C-example-152">array section, C example</a>: <a href="#C-Section-Access">C Section Access</a></li>
<li><a href="#index-array-section_002c-corner-147">array section, corner</a>: <a href="#Data-Access">Data Access</a></li>
<li><a href="#index-array-section_002c-definition-148">array section, definition</a>: <a href="#Data-Access">Data Access</a></li>
<li><a href="#index-array-section_002c-edges-149">array section, edges</a>: <a href="#Data-Access">Data Access</a></li>
<li><a href="#index-array-section_002c-Fortran-example-154">array section, Fortran example</a>: <a href="#Fortran-Section-Access">Fortran Section Access</a></li>
<li><a href="#index-array-section_002c-mapped-150">array section, mapped</a>: <a href="#Data-Access">Data Access</a></li>
<li><a href="#index-arrays_002c-ragged-59">arrays, ragged</a>: <a href="#Limitations">Limitations</a></li>
<li><a href="#index-ASCII-characters-132">ASCII characters</a>: <a href="#External-Types">External Types</a></li>
<li><a href="#index-attribute-conventions-253">attribute conventions</a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-attributes-associated-with-a-variable-109">attributes associated with a variable</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-attributes-vs_002e-variables-129">attributes vs. variables</a>: <a href="#Attributes-and-Variables">Attributes and Variables</a></li>
<li><a href="#index-attributes_002c-adding-to-existing-dataset-116">attributes, adding to existing dataset</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-attributes_002c-CDL_002c-defining-202">attributes, CDL, defining</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-attributes_002c-CDL_002c-global-203">attributes, CDL, global</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-attributes_002c-CDL_002c-initializing-233">attributes, CDL, initializing</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-attributes_002c-data-type-123">attributes, data type</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-attributes_002c-data-types_002c-CDL-236">attributes, data types, CDL</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-attributes_002c-defined-114">attributes, defined</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-attributes_002c-defining-in-CDL-115">attributes, defining in CDL</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-attributes_002c-global-124">attributes, global</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-attributes_002c-length_002c-CDL-238">attributes, length, CDL</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-attributes_002c-operations-on-125">attributes, operations on</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-buffers_002c-I_002fO-178">buffers, I/O</a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-byte-219"><code>byte</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-byte-array-vs_002e-text-string-156">byte array vs. text string</a>: <a href="#Type-Conversion">Type Conversion</a></li>
<li><a href="#index-byte-CDL-constant-240">byte CDL constant</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-byte_002c-CDL-data-type-210">byte, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-byte_002c-signed-vs_002e-unsigned-136">byte, signed vs. unsigned</a>: <a href="#External-Types">External Types</a></li>
<li><a href="#index-C-API-19">C API</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-C-API-4">C API</a>: <a href="#Top">Top</a></li>
<li><a href="#index-C-code-via-ncgen_002c-generating-243">C code via ncgen, generating</a>: <a href="#ncgen">ncgen</a></li>
<li><a href="#index-C-code-via-ncgen3_002c-generating-248">C code via ncgen3, generating</a>: <a href="#ncgen3">ncgen3</a></li>
<li><a href="#index-C_002b_002b-API-22">C++ API</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-C_002b_002b-API-1">C++ API</a>: <a href="#Top">Top</a></li>
<li><a href="#index-C_005fformat-266"><code>C_format</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-CANDIS-35">CANDIS</a>: <a href="#Background">Background</a></li>
<li><a href="#index-CDF1-171">CDF1</a>: <a href="#Large-File-Support">Large File Support</a></li>
<li><a href="#index-CDF2-172">CDF2</a>: <a href="#Large-File-Support">Large File Support</a></li>
<li><a href="#index-CDL-attributes_002c-defining-206">CDL attributes, defining</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-CDL-constants-232">CDL constants</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-CDL-data-types-209">CDL data types</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-CDL-dimensions_002c-defining-207">CDL dimensions, defining</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-CDL-syntax-201">CDL syntax</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-CDL-variables_002c-defining-208">CDL variables, defining</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-CDL_002c-defining-attributes-117">CDL, defining attributes</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-CDL_002c-defining-global-attributes-118">CDL, defining global attributes</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-CDL_002c-example-74">CDL, example</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-char-218"><code>char</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-char_002c-CDL-data-type-211">char, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-chunking-189">chunking</a>: <a href="#Chunking">Chunking</a></li>
<li><a href="#index-classic-file-format-160">classic file format</a>: <a href="#Classic-File-Parts">Classic File Parts</a></li>
<li><a href="#index-classic-format_002c-introduction-169">classic format, introduction</a>: <a href="#Large-File-Support">Large File Support</a></li>
<li><a href="#index-classic-format_002c-limitations-174">classic format, limitations</a>: <a href="#Classic-Limitations">Classic Limitations</a></li>
<li><a href="#index-classic-netCDF-format-62">classic netCDF format</a>: <a href="#Limitations">Limitations</a></li>
<li><a href="#index-common-data-form-language-75">common data form language</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-compound-type-139">compound type</a>: <a href="#User-Defined-Types">User Defined Types</a></li>
<li><a href="#index-compression-30">compression</a>: <a href="#Archival">Archival</a></li>
<li><a href="#index-Conventions-270"><code>Conventions</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-conventions_002c-attributes-255">conventions, attributes</a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-conventions_002c-introduction-32">conventions, introduction</a>: <a href="#Conventions">Conventions</a></li>
<li><a href="#index-conventions_002c-naming-73">conventions, naming</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-conversion-of-data-types_002c-introduction-134">conversion of data types, introduction</a>: <a href="#External-Types">External Types</a></li>
<li><a href="#index-coordinate-variables-112">coordinate variables</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-DAP-support-194">DAP support</a>: <a href="#DAP-Support">DAP Support</a></li>
<li><a href="#index-data-base-24">data base</a>: <a href="#Not-DBMS">Not DBMS</a></li>
<li><a href="#index-data-model_002c-netCDF-71">data model, netCDF</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-data-structures-137">data structures</a>: <a href="#Classic-Data-Structures">Classic Data Structures</a></li>
<li><a href="#index-data-types_002c-conversion-157">data types, conversion</a>: <a href="#Type-Conversion">Type Conversion</a></li>
<li><a href="#index-data-types_002c-external-133">data types, external</a>: <a href="#External-Types">External Types</a></li>
<li><a href="#index-data_002c-reading-144">data, reading</a>: <a href="#Data-Access">Data Access</a></li>
<li><a href="#index-data_002c-writing-145">data, writing</a>: <a href="#Data-Access">Data Access</a></li>
<li><a href="#index-DBMS-25">DBMS</a>: <a href="#Not-DBMS">Not DBMS</a></li>
<li><a href="#index-deflation-190">deflation</a>: <a href="#Chunking">Chunking</a></li>
<li><a href="#index-differences-between-attributes-and-variables-131">differences between attributes and variables</a>: <a href="#Attributes-and-Variables">Attributes and Variables</a></li>
<li><a href="#index-dimensions_002c-CDL_002c-defining-204">dimensions, CDL, defining</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-dimensions_002c-CDL_002c-initializing-234">dimensions, CDL, initializing</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-dimensions_002c-introduction-80">dimensions, introduction</a>: <a href="#Dimensions">Dimensions</a></li>
<li><a href="#index-dimensions_002c-length_002c-CDL-239">dimensions, length, CDL</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-dimensions_002c-unlimited-81">dimensions, unlimited</a>: <a href="#Dimensions">Dimensions</a></li>
<li><a href="#index-DODS-44">DODS</a>: <a href="#Background">Background</a></li>
<li><a href="#index-double-225"><code>double</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-double_002c-CDL-data-type-217">double, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-enum-type-143">enum type</a>: <a href="#User-Defined-Types">User Defined Types</a></li>
<li><a href="#index-external-data-types-135">external data types</a>: <a href="#External-Types">External Types</a></li>
<li><a href="#index-F90-API-21">F90 API</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-FAN-42">FAN</a>: <a href="#Background">Background</a></li>
<li><a href="#index-fflush-184">fflush</a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-file-format-271">file format</a>: <a href="#File-Format">File Format</a></li>
<li><a href="#index-file-format_002c-64_002dbit-offset-162">file format, 64-bit offset</a>: <a href="#Classic-File-Parts">Classic File Parts</a></li>
<li><a href="#index-file-format_002c-classic-161">file format, classic</a>: <a href="#Classic-File-Parts">Classic File Parts</a></li>
<li><a href="#index-file-format_002c-netcdf_002d4-165">file format, netcdf-4</a>: <a href="#NetCDF_002d4-File-Parts">NetCDF-4 File Parts</a></li>
<li><a href="#index-file-structure_002c-overview-158">file structure, overview</a>: <a href="#Structure">Structure</a></li>
<li><a href="#index-float-223"><code>float</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-float_002c-CDL-data-type-215">float, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-flushing-buffers-185">flushing buffers</a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-format-selection-advice-27">format selection advice</a>: <a href="#Which-Format">Which Format</a></li>
<li><a href="#index-Fortran-77-API-2">Fortran 77 API</a>: <a href="#Top">Top</a></li>
<li><a href="#index-Fortran-90-API-3">Fortran 90 API</a>: <a href="#Top">Top</a></li>
<li><a href="#index-Fortran-API-20">Fortran API</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-FORTRAN_005fformat-267"><code>FORTRAN_format</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-future-plans-for-netCDF-65">future plans for netCDF</a>: <a href="#Future">Future</a></li>
<li><a href="#index-GBytes-64">GBytes</a>: <a href="#Limitations">Limitations</a></li>
<li><a href="#index-generating-C-code-via-ncgen-244">generating C code via ncgen</a>: <a href="#ncgen">ncgen</a></li>
<li><a href="#index-generating-C-code-via-ncgen3-249">generating C code via ncgen3</a>: <a href="#ncgen3">ncgen3</a></li>
<li><a href="#index-generic-applications-122">generic applications</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-GiBytes-63">GiBytes</a>: <a href="#Limitations">Limitations</a></li>
<li><a href="#index-global-attributes-126">global attributes</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-groups-77">groups</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-history-269"><code>history</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-I_002fO-layer-175">I/O layer</a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-initializing-CDL-241">initializing CDL</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-int-221"><code>int</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-int_002c-CDL-data-type-213">int, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-int64-229"><code>int64</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-Interface-Guide_002c-C-9">Interface Guide, C</a>: <a href="#Top">Top</a></li>
<li><a href="#index-Interface-Guide_002c-C_002b_002b-10">Interface Guide, C++</a>: <a href="#Top">Top</a></li>
<li><a href="#index-Interface-Guide_002c-Fortran-77-11">Interface Guide, Fortran 77</a>: <a href="#Top">Top</a></li>
<li><a href="#index-Interface-Guide_002c-Fortran-90-12">Interface Guide, Fortran 90</a>: <a href="#Top">Top</a></li>
<li><a href="#index-interoperability-with-HDF5-193">interoperability with HDF5</a>: <a href="#Interoperability-with-HDF5">Interoperability with HDF5</a></li>
<li><a href="#index-Java-API-23">Java API</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-Java-API_002c-history-53">Java API, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-large-file-support-167">large file support</a>: <a href="#Large-File-Support">Large File Support</a></li>
<li><a href="#index-LFS-170">LFS</a>: <a href="#Large-File-Support">Large File Support</a></li>
<li><a href="#index-limitations-of-netCDF-61">limitations of netCDF</a>: <a href="#Limitations">Limitations</a></li>
<li><a href="#index-long-222"><code>long</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-long_002c-CDL-data-type-214">long, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-long_005fname-257"><code>long_name</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-Matlab-API_002c-history-54">Matlab API, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-missing_005fvalue-259"><code>missing_value</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-multiple-unlimited-dimensions-83">multiple unlimited dimensions</a>: <a href="#Dimensions">Dimensions</a></li>
<li><a href="#index-naming-conventions-72">naming conventions</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-NASA-CDF-format-36">NASA CDF format</a>: <a href="#Background">Background</a></li>
<li><a href="#index-NC_005fBYTE-87"><code>NC_BYTE</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fCHAR-91"><code>NC_CHAR</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fDOUBLE-93"><code>NC_DOUBLE</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fFLOAT-92"><code>NC_FLOAT</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fINT-88"><code>NC_INT</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fINT64-98"><code>NC_INT64</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fLONG-90"><code>NC_LONG</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fSHARE-179"><code>NC_SHARE</code></a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-NC_005fSHORT-89"><code>NC_SHORT</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fSTRING-100"><code>NC_STRING</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nc_005fsync-183"><code>nc_sync</code></a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-NC_005fUBYTE-94"><code>NC_UBYTE</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fUINT-95"><code>NC_UINT</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fUINT64-99"><code>NC_UINT64</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NC_005fUSHORT-96"><code>NC_USHORT</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nccopy-246">nccopy</a>: <a href="#nccopy">nccopy</a></li>
<li><a href="#index-nccopy_002c-overview-198">nccopy, overview</a>: <a href="#NetCDF-Utilities">NetCDF Utilities</a></li>
<li><a href="#index-ncdump-245">ncdump</a>: <a href="#ncdump">ncdump</a></li>
<li><a href="#index-ncdump_002c-introduction-76">ncdump, introduction</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-ncdump_002c-overview-197">ncdump, overview</a>: <a href="#NetCDF-Utilities">NetCDF Utilities</a></li>
<li><a href="#index-ncgen-242">ncgen</a>: <a href="#ncgen">ncgen</a></li>
<li><a href="#index-ncgen-and-ncgen3_002c-overview-196">ncgen and ncgen3, overview</a>: <a href="#NetCDF-Utilities">NetCDF Utilities</a></li>
<li><a href="#index-ncgen3-247">ncgen3</a>: <a href="#ncgen3">ncgen3</a></li>
<li><a href="#index-NcML-46">NcML</a>: <a href="#Background">Background</a></li>
<li><a href="#index-NCO-43">NCO</a>: <a href="#Background">Background</a></li>
<li><a href="#index-netCDF-5_002e0-67">netCDF 5.0</a>: <a href="#Future">Future</a></li>
<li><a href="#index-netCDF-data-model-70">netCDF data model</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-netCDF-data-types-86">netCDF data types</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-netcdf_002d4-file-format-164">netcdf-4 file format</a>: <a href="#NetCDF_002d4-File-Parts">NetCDF-4 File Parts</a></li>
<li><a href="#index-NETCDF_005fFFIOSPEC-188"><code>NETCDF_FFIOSPEC</code></a>: <a href="#UNICOS-Optimization">UNICOS Optimization</a></li>
<li><a href="#index-New-Mexico-Institute-of-Mining-38">New Mexico Institute of Mining</a>: <a href="#Background">Background</a></li>
<li><a href="#index-new-netCDF-features-in-4_002e0-58">new netCDF features in 4.0</a>: <a href="#Whats-New">Whats New</a></li>
<li><a href="#index-nf_005fbyte-101"><code>nf_byte</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nf_005fchar-102"><code>nf_char</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nf_005fdouble-107"><code>nf_double</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nf_005ffloat-108"><code>nf_float</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nf_005fint1-104"><code>nf_int1</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nf_005fint2-105"><code>nf_int2</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-nf_005freal-106"><code>nf_real</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NF_005fSHARE-180"><code>NF_SHARE</code></a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-nf_005fshort-103"><code>nf_short</code></a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-NF_005fSYNC-182"><code>NF_SYNC</code></a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-Northwestern-University-47">Northwestern University</a>: <a href="#Background">Background</a></li>
<li><a href="#index-opaque-type-142">opaque type</a>: <a href="#User-Defined-Types">User Defined Types</a></li>
<li><a href="#index-OpenDAP-45">OpenDAP</a>: <a href="#Background">Background</a></li>
<li><a href="#index-operations-on-attributes-127">operations on attributes</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-parallel-access-192">parallel access</a>: <a href="#Parallel-Access">Parallel Access</a></li>
<li><a href="#index-performance-of-NetCDF-159">performance of NetCDF</a>: <a href="#Structure">Structure</a></li>
<li><a href="#index-performance_002c-introduction-28">performance, introduction</a>: <a href="#Performance">Performance</a></li>
<li><a href="#index-plans-for-netCDF-66">plans for netCDF</a>: <a href="#Future">Future</a></li>
<li><a href="#index-pong-68">pong</a>: <a href="#Future">Future</a></li>
<li><a href="#index-primary-variables-110">primary variables</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-python-API_002c-history-51">python API, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-real-224"><code>real</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-real_002c-CDL-data-type-216">real, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-references-69">references</a>: <a href="#References">References</a></li>
<li><a href="#index-ruby-API_002c-history-50">ruby API, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-scale_005ffactor-263"><code>scale_factor</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-SeaSpace_002c-Inc-39">SeaSpace, Inc</a>: <a href="#Background">Background</a></li>
<li><a href="#index-share-flag-181">share flag</a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-shared-dataset-I_002fO-access-177">shared dataset I/O access</a>: <a href="#The-NetCDF_002d3-IO-Layer">The NetCDF-3 IO Layer</a></li>
<li><a href="#index-short-220"><code>short</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-short_002c-CDL-data-type-212">short, CDL data type</a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-shuffle-filter-191">shuffle filter</a>: <a href="#Chunking">Chunking</a></li>
<li><a href="#index-signedness-265"><code>signedness</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-SNIDE-37">SNIDE</a>: <a href="#Background">Background</a></li>
<li><a href="#index-software-list-199">software list</a>: <a href="#NetCDF-Utilities">NetCDF Utilities</a></li>
<li><a href="#index-storing-ancillary-data-120">storing ancillary data</a>: <a href="#Attributes">Attributes</a></li>
<li><a href="#index-string-231"><code>string</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-structures_002c-data-138">structures, data</a>: <a href="#Classic-Data-Structures">Classic Data Structures</a></li>
<li><a href="#index-supported-programming-languages-13">supported programming languages</a>: <a href="#Summary">Summary</a></li>
<li><a href="#index-Tcl_002fTk-API_002c-history-52">Tcl/Tk API, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-Terascan-data-format-41">Terascan data format</a>: <a href="#Background">Background</a></li>
<li><a href="#index-title-268"><code>title</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-type-conversion-155">type conversion</a>: <a href="#Type-Conversion">Type Conversion</a></li>
<li><a href="#index-ubyte-226"><code>ubyte</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-udunits-251">udunits</a>: <a href="#Units">Units</a></li>
<li><a href="#index-uint-228"><code>uint</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-uint64-230"><code>uint64</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-UNICOS-187">UNICOS</a>: <a href="#UNICOS-Optimization">UNICOS Optimization</a></li>
<li><a href="#index-units-256"><code>units</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-units-library-250">units library</a>: <a href="#Units">Units</a></li>
<li><a href="#index-University-of-Miami-40">University of Miami</a>: <a href="#Background">Background</a></li>
<li><a href="#index-unlimited-dimensions-82">unlimited dimensions</a>: <a href="#Dimensions">Dimensions</a></li>
<li><a href="#index-user-defined-types-78">user defined types</a>: <a href="#Data-Model">Data Model</a></li>
<li><a href="#index-ushort-227"><code>ushort</code></a>: <a href="#CDL-Data-Types">CDL Data Types</a></li>
<li><a href="#index-utilities-195">utilities</a>: <a href="#NetCDF-Utilities">NetCDF Utilities</a></li>
<li><a href="#index-valid_005fmax-261"><code>valid_max</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-valid_005fmin-260"><code>valid_min</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-valid_005frange-262"><code>valid_range</code></a>: <a href="#Attribute-Conventions">Attribute Conventions</a></li>
<li><a href="#index-variable-length-array-type-141">variable length array type</a>: <a href="#User-Defined-Types">User Defined Types</a></li>
<li><a href="#index-variable-types-85">variable types</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-variables-vs_002e-attributes-130">variables vs. attributes</a>: <a href="#Attributes-and-Variables">Attributes and Variables</a></li>
<li><a href="#index-variables_002c-CDL_002c-defining-205">variables, CDL, defining</a>: <a href="#CDL-Syntax">CDL Syntax</a></li>
<li><a href="#index-variables_002c-CDL_002c-initializing-235">variables, CDL, initializing</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-variables_002c-coordinate-113">variables, coordinate</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-variables_002c-data-types_002c-CDL-237">variables, data types, CDL</a>: <a href="#CDL-Constants">CDL Constants</a></li>
<li><a href="#index-variables_002c-defined-84">variables, defined</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-variables_002c-primary-111">variables, primary</a>: <a href="#Variables">Variables</a></li>
<li><a href="#index-vlen-type-140">vlen type</a>: <a href="#User-Defined-Types">User Defined Types</a></li>
<li><a href="#index-WetCDF_002c-history-55">WetCDF, history</a>: <a href="#Background">Background</a></li>
<li><a href="#index-workshop_002c-CDF-34">workshop, CDF</a>: <a href="#Background">Background</a></li>
<li><a href="#index-writers_002c-multiple-60">writers, multiple</a>: <a href="#Limitations">Limitations</a></li>
<li><a href="#index-XDR-format-26">XDR format</a>: <a href="#Format">Format</a></li>
<li><a href="#index-XDR-layer-166">XDR layer</a>: <a href="#XDR-Layer">XDR Layer</a></li>
<li><a href="#index-XDR_002c-introduction-into-netCDF-33">XDR, introduction into netCDF</a>: <a href="#Background">Background</a></li>
</ul></body></html>