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

Demonstrates file size and dimension limits for NetCDF classic formats. More...

#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>
#include <sys/stat.h>

Macros

#define ERRCODE   2
 
#define ERR(e)   {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
 
#define CLASSIC_DIM   5000 /* ~20KB for float data */
 
#define OFFSET_DIM   5000 /* ~20KB for float data */
 
#define DATA_DIM   5000 /* ~20KB for float data */
 
#define TEST_MODE   "SMALL"
 

Functions

long get_file_size (const char *filename)
 
void print_format_limits (void)
 
void test_format (const char *filename, int format_flag, const char *format_name, size_t dim_size)
 
int main ()
 

Detailed Description

Demonstrates file size and dimension limits for NetCDF classic formats.

This example explores the size limitations of the three classic NetCDF formats (CDF-1, CDF-2, CDF-5) by creating test files and explaining theoretical limits. Understanding these limits is essential for choosing the appropriate format for large datasets.

The program runs in small test mode (suitable for CI) by default, creating modest-sized test files and displaying theoretical limits. This helps users understand when they need to upgrade from CDF-1 to CDF-2 or CDF-5 for larger datasets.

Learning Objectives:

Key Concepts:

Format Limits Summary:

Prerequisites:

Related Examples:

Compilation:

gcc -o size_limits size_limits.c -lnetcdf

Usage:

./size_limits

Expected Output:

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

Macro Definition Documentation

◆ CLASSIC_DIM

#define CLASSIC_DIM   5000 /* ~20KB for float data */

◆ DATA_DIM

#define DATA_DIM   5000 /* ~20KB for float data */

◆ ERR

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

◆ ERRCODE

#define ERRCODE   2

◆ OFFSET_DIM

#define OFFSET_DIM   5000 /* ~20KB for float data */

◆ TEST_MODE

#define TEST_MODE   "SMALL"

Function Documentation

◆ get_file_size()

long get_file_size ( const char *  filename)

◆ main()

int main ( )

◆ print_format_limits()

void print_format_limits ( void  )

◆ test_format()

void test_format ( const char *  filename,
int  format_flag,
const char *  format_name,
size_t  dim_size 
)