|
NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
|
Demonstrates unlimited dimensions for appendable time-series data. More...
#include <stdio.h>#include <stdlib.h>#include <netcdf.h>Macros | |
| #define | FILE_NAME "unlimited_dim.nc" |
| #define | NLAT 4 |
| #define | NLON 5 |
| #define | INITIAL_TIMESTEPS 3 |
| #define | APPEND_TIMESTEPS 2 |
| #define | TOTAL_TIMESTEPS (INITIAL_TIMESTEPS + APPEND_TIMESTEPS) |
| #define | ERRCODE 2 |
| #define | ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
Functions | |
| int | main () |
Demonstrates unlimited dimensions for appendable time-series data.
This example introduces unlimited dimensions - a special dimension type that can grow dynamically, allowing data to be appended to files over time. Unlimited dimensions are essential for time-series data where the total number of timesteps is not known in advance.
The program creates a file with an unlimited time dimension, writes initial timesteps, then reopens the file in write mode to append additional timesteps. This demonstrates the common pattern for incrementally building time-series datasets.
Learning Objectives:
Key Concepts:
Unlimited Dimension Characteristics:
Prerequisites:
Related Examples:
Compilation:
Usage:
Expected Output: Creates unlimited_dim.nc containing:
| #define APPEND_TIMESTEPS 2 |
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define FILE_NAME "unlimited_dim.nc" |
| #define INITIAL_TIMESTEPS 3 |
| #define NLAT 4 |
| #define NLON 5 |
| #define TOTAL_TIMESTEPS (INITIAL_TIMESTEPS + APPEND_TIMESTEPS) |
| int main | ( | ) |