|
NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
|
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 () |
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:
Usage:
Expected Output: Creates three files with different chunking strategies:
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define NDIMS 3 |
| #define NLAT 180 |
| #define NLON 360 |
| #define NTIME 100 |
| double create_chunked_file | ( | const char * | filename, |
| const char * | strategy_name, | ||
| int | storage, | ||
| size_t * | chunksizes | ||
| ) |
| double get_time_diff | ( | struct timespec | start, |
| struct timespec | end | ||
| ) |
| int main | ( | ) |
| double read_and_validate | ( | const char * | filename, |
| const char * | test_name | ||
| ) |