|
NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
|
Basic example demonstrating 2D array creation and reading in NetCDF. More...
#include <stdio.h>#include <stdlib.h>#include <netcdf.h>Macros | |
| #define | FILE_NAME "simple_2D.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 example demonstrating 2D array creation and reading in NetCDF.
This example shows the fundamental workflow for working with NetCDF files:
The program creates a 2D integer array (6x12) with sequential values (0, 1, 2, ..., 71), writes it to a NetCDF-4 file, then reopens the file to verify both metadata and data correctness. This demonstrates the complete read-write cycle that forms the foundation of NetCDF programming.
Learning Objectives:
Key Concepts:
Prerequisites: None - this is a beginner example
Related Examples:
Compilation:
Usage:
Expected Output: Creates simple_2D.nc containing:
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define FILE_NAME "simple_2D.nc" |
| #define NDIMS 2 |
| #define NX 6 |
| #define NY 12 |
| int main | ( | ) |