|
NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
|
Basic NetCDF-4/HDF5 format file creation and format detection. More...
#include <stdio.h>#include <stdlib.h>#include <netcdf.h>Macros | |
| #define | FILE_NAME "simple_nc4.nc" |
| #define | NDIMS 2 |
| #define | NX 6 |
| #define | NY 12 |
| #define | ERRCODE 2 |
| #define | ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
Functions | |
| int | main () |
Basic NetCDF-4/HDF5 format file creation and format detection.
This example introduces the NetCDF-4 format, which uses HDF5 as the underlying storage layer. NetCDF-4 provides enhanced features including compression, chunking, multiple unlimited dimensions, and user-defined types while maintaining backward compatibility with the NetCDF API.
The program creates a simple 2D array using the NC_NETCDF4 flag and demonstrates format detection to verify the file was created in NetCDF-4/HDF5 format rather than classic NetCDF format.
Learning Objectives:
Key Concepts:
NetCDF-4 vs Classic Comparison:
Prerequisites:
Related Examples:
Compilation:
Usage:
Expected Output: Creates simple_nc4.nc in NetCDF-4/HDF5 format containing:
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define FILE_NAME "simple_nc4.nc" |
| #define NDIMS 2 |
| #define NX 6 |
| #define NY 12 |
| int main | ( | ) |