Loading...
Searching...
No Matches
filter_example.c File Reference
Tutorial Examples

Example program for write then read of a variable using bzip2 compression. More...

`#include "config.h"`
`#include <stdio.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <hdf5.h>`
`#include "netcdf.h"`
`#include "netcdf_filter.h"`
Include dependency graph for filter_example.c:

Go to the source code of this file.

## Macros

#define | BZIP2_ID 307
#define | BZIP2_LEVEL 9
#define | CHECK(x)
#define | CHUNKSIZE 4 /* Note: not the total size of the chunk, but size wrt a dim*/
#define | DIMSIZE 4
#define | ERRR
#define | MAXERRS 8
#define | NDIMS 4
#define | TESTFILE "bzip2.nc"

## Functions

static int | check (int err, int line)
static int | compare (void)
static void | init (int argc, char **argv)
int | main (int argc, char **argv)
static int | test_bzip2 (void)
static int | verifychunks (void)

## Variables

static size_t | actualdims = NDIMS
static size_t | actualproduct = 1
static float * | array = NULL
static size_t | chunkproduct = 1
static size_t | chunks [NDIMS]
static size_t | chunksize = CHUNKSIZE
static int | dimids [NDIMS]
static size_t | dims [NDIMS]
static size_t | dimsize = DIMSIZE
static float * | expected = NULL
static unsigned int | filterid = 0
static int | ncid
static int | nerrs = 0
static unsigned int * | params = NULL
static int | varid

## Detailed Description

Example program for write then read of a variable using bzip2 compression.

This is an example which creates a file with a variable that is compressed using bzip2. Then it reads that file and verifies that it returned the correct uncompressed data.

The meta-data (.cdl) for the created file is as follows:

netcdf bzip2 {
dimensions:
dim0 = 4 ;
dim1 = 4 ;
dim2 = 4 ;
dim3 = 4 ;
variables:
float var(dim0, dim1, dim2, dim3) ;
var:_Storage = "chunked" ;
var:_ChunkSizes = 4, 4, 4, 4 ;
var:_Filter = "307,9" ;
var:_NoFill = "true" ;
data:
var =
0, 1, 2, 3,
4, 5, 6, 7,
...
252, 253, 254, 255 ;
}

Definition in file filter_example.c.

## Macro Definition Documentation

## BZIP2_ID

#define BZIP2_ID 307

Definition at line 54 of file filter_example.c.

## BZIP2_LEVEL

#define BZIP2_LEVEL 9

Definition at line 56 of file filter_example.c.

## CHECK

#define CHECK | ( |  | x | ) |

Value:
check(x,__LINE__)

Definition at line 109 of file filter_example.c.

## CHUNKSIZE

#define CHUNKSIZE 4 /* Note: not the total size of the chunk, but size wrt a dim*/

Definition at line 65 of file filter_example.c.

## DIMSIZE

#define DIMSIZE 4

Definition at line 64 of file filter_example.c.

## ERRR

#define ERRR

Value:
do { \
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
__FILE__, __LINE__); \
nerrs++;\
} while (0)

Definition at line 91 of file filter_example.c.

## MAXERRS

#define MAXERRS 8

Definition at line 61 of file filter_example.c.

## NDIMS

#define NDIMS 4

Definition at line 63 of file filter_example.c.

## TESTFILE

#define TESTFILE "bzip2.nc"

Definition at line 58 of file filter_example.c.

## Function Documentation

## check()

int check | ( | int | err,
|  | int | line )

static

Definition at line 99 of file filter_example.c.

## compare()

int compare | ( | void |  | ) |

static

Definition at line 144 of file filter_example.c.

## init()

void init | ( | int | argc,
|  | char ** | argv )

static

Definition at line 282 of file filter_example.c.

## main()

int main | ( | int | argc,
|  | char ** | argv )

Definition at line 303 of file filter_example.c.

## test_bzip2()

int test_bzip2 | ( | void |  | ) |

static

Definition at line 169 of file filter_example.c.

## verifychunks()

int verifychunks | ( | void |  | ) |

static

Definition at line 117 of file filter_example.c.

## Variable Documentation

## actualdims

size_t actualdims = NDIMS

static

Definition at line 69 of file filter_example.c.

## actualproduct

size_t actualproduct = 1

static

Definition at line 71 of file filter_example.c.

## array

float* array = NULL

static

Definition at line 81 of file filter_example.c.

## chunkproduct

size_t chunkproduct = 1

static

Definition at line 72 of file filter_example.c.

## chunks

size_t chunks[NDIMS]

static

Definition at line 75 of file filter_example.c.

## chunksize

size_t chunksize = CHUNKSIZE

static

Definition at line 68 of file filter_example.c.

## dimids

int dimids[NDIMS]

static

Definition at line 80 of file filter_example.c.

## dims

size_t dims[NDIMS]

static

Definition at line 74 of file filter_example.c.

## dimsize

size_t dimsize = DIMSIZE

static

Definition at line 67 of file filter_example.c.

## expected

float* expected = NULL

static

Definition at line 82 of file filter_example.c.

## filterid

unsigned int filterid = 0

static

Definition at line 83 of file filter_example.c.

## ncid

int ncid

static

Definition at line 79 of file filter_example.c.

## nerrs

int nerrs = 0

static

Definition at line 77 of file filter_example.c.

## params

unsigned int* params = NULL

static

Definition at line 84 of file filter_example.c.

## varid

int varid

static

Definition at line 79 of file filter_example.c.