NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
Loading...
Searching...
No Matches
Macros | Functions
multi_unlimited.c File Reference

Demonstrates multiple unlimited dimensions (NetCDF-4 feature) More...

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <netcdf.h>

Macros

#define FILE_NAME   "multi_unlimited.nc"
 
#define INITIAL_STATIONS   3
 
#define INITIAL_TIMES   5
 
#define ADDED_STATIONS   2
 
#define ADDED_TIMES   3
 
#define NDIMS   2
 
#define ERRCODE   2
 
#define ERR(e)   {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
 

Functions

int main ()
 

Detailed Description

Demonstrates multiple unlimited dimensions (NetCDF-4 feature)

This example showcases one of NetCDF-4's key enhancements over classic NetCDF: the ability to have multiple unlimited dimensions. While classic NetCDF allows only one unlimited dimension, NetCDF-4 supports any number, enabling more flexible data structures for complex datasets.

The program creates a file with two unlimited dimensions (station and time), writes initial data, then demonstrates appending data along both dimensions. This pattern is common in observational data where both the number of stations and timesteps can grow over time.

Learning Objectives:

Key Concepts:

Use Cases for Multiple Unlimited Dimensions:

Design Considerations:

Prerequisites:

Related Examples:

Compilation:

gcc -o multi_unlimited multi_unlimited.c -lnetcdf -lm

Usage:

./multi_unlimited
ncdump multi_unlimited.nc

Expected Output: Creates multi_unlimited.nc containing:

Author
Edward Hartnett, Intelligent Data Design, Inc.
Date
2026

Macro Definition Documentation

◆ ADDED_STATIONS

#define ADDED_STATIONS   2

◆ ADDED_TIMES

#define ADDED_TIMES   3

◆ ERR

#define ERR (   e)    {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}

◆ ERRCODE

#define ERRCODE   2

◆ FILE_NAME

#define FILE_NAME   "multi_unlimited.nc"

◆ INITIAL_STATIONS

#define INITIAL_STATIONS   3

◆ INITIAL_TIMES

#define INITIAL_TIMES   5

◆ NDIMS

#define NDIMS   2

Function Documentation

◆ main()

int main ( )