|
NEP 2.7.0
NetCDF Extension Pack
|
Demonstrate chunked storage in a local NcZarr dataset. More...
#include <netcdf.h>#include <stdio.h>#include <stdlib.h>Macros | |
| #define | FILE_URL "file://nczarr_chunking.zarr#mode=nczarr" |
| #define | NY 4 |
| #define | NX 5 |
| #define | NDIMS 2 |
| #define | CHUNK_Y 2 |
| #define | CHUNK_X 5 |
| #define | ERR(e) |
Functions | |
| int | main (void) |
Demonstrate chunked storage in a local NcZarr dataset.
This example extends nczarr_simple.c by adding explicit chunk shape selection. Chunking controls how a variable's data is split into separate storage units (chunks) in the underlying Zarr directory tree. Each chunk becomes a separate file on disk (or object in cloud storage), so the chunk shape directly affects I/O access patterns.
The program creates the same 4x5 temperature grid used in nczarr_simple.c but specifies a 2x5 (y x x) chunk shape using nc_def_var_chunking(). This splits the 4-row array into two 2-row chunks. After writing, the program reopens the dataset and verifies the chunk metadata via nc_inq_var_chunking(), then reads and validates all data values.
Learning Objectives:
Key Concepts:
Related Examples:
Compilation:
Usage:
Expected Output: Creates the directory nczarr_chunking.zarr containing:
| #define CHUNK_X 5 |
| #define CHUNK_Y 2 |
| #define ERR | ( | e | ) |
| #define FILE_URL "file://nczarr_chunking.zarr#mode=nczarr" |
| #define NDIMS 2 |
| #define NX 5 |
| #define NY 4 |
| int main | ( | void | ) |