|
NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
|
Demonstrates NetCDF-4 compression filters with performance analysis. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <math.h>#include <netcdf.h>Data Structures | |
| struct | CompressionTest |
Macros | |
| #define | NTIME 50 |
| #define | NLAT 90 |
| #define | NLON 180 |
| #define | NDIMS 3 |
| #define | ERRCODE 2 |
| #define | ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
Functions | |
| void | generate_temperature_data (float *data) |
| long | get_file_size (const char *filename) |
| void | create_compressed_file (CompressionTest *test, float *data) |
| void | read_compressed_file (CompressionTest *test, float *original_data) |
| int | main () |
Demonstrates NetCDF-4 compression filters with performance analysis.
This example explores NetCDF-4's built-in compression capabilities by creating multiple files with different compression settings and measuring their performance characteristics. Compression is essential for reducing storage requirements and I/O bandwidth for large scientific datasets.
The program generates realistic 3D temperature data (time×lat×lon) and creates files with various compression configurations: no compression, deflate only, shuffle only, and shuffle+deflate combinations at different compression levels. It measures write/read times, file sizes, and compression ratios.
Learning Objectives:
Key Concepts:
Compression Strategies:
When to Use Compression:
Prerequisites:
Related Examples:
Compilation:
Usage:
Expected Output: Creates multiple files with compression analysis:
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define NDIMS 3 |
| #define NLAT 90 |
| #define NLON 180 |
| #define NTIME 50 |
| void create_compressed_file | ( | CompressionTest * | test, |
| float * | data | ||
| ) |
| void generate_temperature_data | ( | float * | data | ) |
| long get_file_size | ( | const char * | filename | ) |
| int main | ( | ) |
| void read_compressed_file | ( | CompressionTest * | test, |
| float * | original_data | ||
| ) |