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

Demonstrates chunking strategies and their impact on I/O performance. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <netcdf.h>

Macros

#define NTIME   100
 
#define NLAT   180
 
#define NLON   360
 
#define NDIMS   3
 
#define ERRCODE   2
 
#define ERR(e)   {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
 

Functions

double get_time_diff (struct timespec start, struct timespec end)
 
double create_chunked_file (const char *filename, const char *strategy_name, int storage, size_t *chunksizes)
 
double read_and_validate (const char *filename, const char *test_name)
 
int main ()
 

Detailed Description

Demonstrates chunking strategies and their impact on I/O performance.

This example explores NetCDF-4's chunking feature by creating identical 3D datasets with different chunking strategies and measuring their I/O performance. Chunking is fundamental to NetCDF-4 performance - the chunk size and shape dramatically affect read/write speeds for different access patterns.

The program creates a 3D temperature dataset (time×lat×lon) with three chunking strategies: contiguous (no chunking), spatial-optimized chunks, and balanced chunks. It measures write performance and demonstrates how chunk selection affects different access patterns (time-series vs spatial slices).

Learning Objectives:

Key Concepts:

Chunking Strategies:

Chunking Guidelines:

Prerequisites:

Related Examples:

Compilation:

gcc -o chunking_performance chunking_performance.c -lnetcdf

Usage:

./chunking_performance
ls -lh chunking_performance_*.nc

Expected Output: Creates three files with different chunking strategies:

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

Macro Definition Documentation

◆ ERR

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

◆ ERRCODE

#define ERRCODE   2

◆ NDIMS

#define NDIMS   3

◆ NLAT

#define NLAT   180

◆ NLON

#define NLON   360

◆ NTIME

#define NTIME   100

Function Documentation

◆ create_chunked_file()

double create_chunked_file ( const char *  filename,
const char *  strategy_name,
int  storage,
size_t *  chunksizes 
)

◆ get_time_diff()

double get_time_diff ( struct timespec  start,
struct timespec  end 
)

◆ main()

int main ( )

◆ read_and_validate()

double read_and_validate ( const char *  filename,
const char *  test_name 
)