mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
Add szip support via libaec
This commit is contained in:
parent
5085df7595
commit
ed44fd7306
@ -95,7 +95,15 @@ HDF5 and zlib packages are available from the <a href="http://www.hdfgroup.org/d
|
||||
|
||||
### Optional: szip support {#op_szip_support}
|
||||
|
||||
*Optionally*, you can also build netCDF-4 with the szip library (a.k.a. szlib). If building with szlib, get szip 2.0 or later. NetCDF cannot create szipped data files, but can read HDF5 data files that have used szip. To determine whether license restrictions on the use of szip apply to your situation, see the <a href="http://www.hdfgroup.org/doc_resource/SZIP/">web page on szip compression in HDF products</a>.
|
||||
*Optionally*, you can also build netCDF-4 with the szip library (a.k.a. szlib). If building with szlib, get szip 2.0 or later. Technically, we mean that
|
||||
the HDF5 library is built with szip support. The netcdf build will then
|
||||
inherit szip support from the HDF5 library.
|
||||
If you intend to write files with szip compression, then we suggest that you
|
||||
use [libaec](https://gitlab.dkrz.de/k202009/libaec.git)
|
||||
to avoid patent problems. That library can be used as a
|
||||
drop-in replacement for the standard szip library.
|
||||
If you plan to use the standard szip library,
|
||||
then determine whether license restrictions on the use of szip apply to your situation. See the <a href="http://www.hdfgroup.org/doc_resource/SZIP/">web page on szip compression in HDF products</a>.
|
||||
|
||||
If `make check` fails for either `zlib` or `HDF5`, the problem must be resolved before the netCDF-4 installation can continue. For HDF5 problems, see the <a href="http://www.hdfgroup.org/services/support.html">HDF5 help services</a>.
|
||||
|
||||
|
@ -126,7 +126,6 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
);
|
||||
|
||||
|
@ -179,9 +179,6 @@ typedef struct NC_VAR_INFO
|
||||
int deflate_level;
|
||||
nc_bool_t shuffle; /* True if var has shuffle filter applied */
|
||||
nc_bool_t fletcher32; /* True if var has fletcher32 filter applied */
|
||||
nc_bool_t szip; /* True if var has szip filter applied */
|
||||
int options_mask;
|
||||
int pixels_per_block;
|
||||
size_t chunk_cache_size, chunk_cache_nelems;
|
||||
float chunk_cache_preemption;
|
||||
#ifdef USE_HDF4
|
||||
|
@ -245,9 +245,8 @@ int (*inq_var_all)(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
);
|
||||
);
|
||||
|
||||
int (*var_par_access)(int, int, int);
|
||||
|
||||
@ -400,7 +399,6 @@ NCDISPATCH_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* paramsp
|
||||
);
|
||||
extern int
|
||||
|
@ -14,6 +14,11 @@
|
||||
|
||||
#include <netcdf.h>
|
||||
|
||||
/* Must match values in <H5Zpublic.h> */
|
||||
#ifndef H5Z_FILTER_SZIP
|
||||
#define H5Z_FILTER_SZIP 4
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -2391,7 +2391,6 @@ NCD2_inq_var_all(int ncid, int varid, char *name, nc_type* xtypep,
|
||||
int* shufflep, int* deflatep, int* deflate_levelp,
|
||||
int* fletcher32p, int* contiguousp, size_t* chunksizesp,
|
||||
int* no_fill, void* fill_valuep, int* endiannessp,
|
||||
int* options_maskp, int* pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
)
|
||||
{
|
||||
@ -2403,7 +2402,6 @@ NCD2_inq_var_all(int ncid, int varid, char *name, nc_type* xtypep,
|
||||
shufflep, deflatep, deflate_levelp,
|
||||
fletcher32p, contiguousp, chunksizesp,
|
||||
no_fill, fill_valuep, endiannessp,
|
||||
options_maskp, pixels_per_blockp,
|
||||
idp,nparamsp,params
|
||||
);
|
||||
return THROW(ret);
|
||||
|
@ -135,7 +135,6 @@ NCD2_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
);
|
||||
|
||||
@ -145,7 +144,6 @@ NC3_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
);
|
||||
|
||||
|
@ -23,8 +23,10 @@ static void rcorder(NClist* rc);
|
||||
static char* rcreadline(char**);
|
||||
static int rcsearch(const char* prefix, const char* rcname, char** pathp);
|
||||
static void rctrim(char* text);
|
||||
static void storedump(char* msg, NClist* triples);
|
||||
static int rcsetinfocurlflag(NCD4INFO*, const char* flag, const char* value);
|
||||
#ifdef D4DEBUG
|
||||
static void storedump(char* msg, NClist* triples);
|
||||
#endif
|
||||
|
||||
/* Define default rc files and aliases, also defines search order*/
|
||||
static char* rcfilenames[] = {".daprc",".dodsrc",NULL};
|
||||
@ -97,7 +99,9 @@ rcorder(NClist* rc)
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef D4DEBUG
|
||||
storedump("reorder:",rc);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -506,6 +510,7 @@ NCD4_rclookup(char* key, char* hostport)
|
||||
return (triple == NULL ? NULL : triple->value);
|
||||
}
|
||||
|
||||
#ifdef D4DEBUG
|
||||
static void
|
||||
storedump(char* msg, NClist* triples)
|
||||
{
|
||||
@ -523,6 +528,7 @@ storedump(char* msg, NClist* triples)
|
||||
}
|
||||
fflush(stderr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prefix must end in '/'
|
||||
|
@ -427,7 +427,6 @@ NCD4_inq_var_all(int ncid, int varid, char *name, nc_type* xtypep,
|
||||
int* shufflep, int* deflatep, int* deflate_levelp,
|
||||
int* fletcher32p, int* contiguousp, size_t* chunksizesp,
|
||||
int* no_fill, void* fill_valuep, int* endiannessp,
|
||||
int* options_maskp, int* pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
)
|
||||
{
|
||||
@ -441,7 +440,6 @@ NCD4_inq_var_all(int ncid, int varid, char *name, nc_type* xtypep,
|
||||
shufflep, deflatep, deflate_levelp,
|
||||
fletcher32p, contiguousp, chunksizesp,
|
||||
no_fill, fill_valuep, endiannessp,
|
||||
options_maskp, pixels_per_blockp,
|
||||
idp, nparamsp, params);
|
||||
return (ret);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ NCDISPATCH_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
)
|
||||
{
|
||||
@ -34,8 +33,6 @@ NCDISPATCH_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
contiguousp, chunksizesp,
|
||||
no_fill, fill_valuep,
|
||||
endiannessp,
|
||||
options_maskp,
|
||||
pixels_per_blockp,
|
||||
idp, nparamsp, params);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ Research/Unidata. See COPYRIGHT file for more info.
|
||||
*/
|
||||
|
||||
#include "ncdispatch.h"
|
||||
#include "netcdf_filter.h"
|
||||
|
||||
/** \name Learning about Variables
|
||||
|
||||
@ -122,7 +123,7 @@ nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
TRACE(nc_inq_var);
|
||||
return ncp->dispatch->inq_var_all(ncid, varid, name, xtypep, ndimsp,
|
||||
dimidsp, nattsp, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL,NULL,NULL);
|
||||
}
|
||||
|
||||
@ -295,8 +296,6 @@ nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep,
|
||||
NULL, /*nofillp*/
|
||||
NULL, /*fillvaluep*/
|
||||
NULL, /*endianp*/
|
||||
NULL, /*optionsmaskp*/
|
||||
NULL, /*pixelsp*/
|
||||
NULL,NULL,NULL
|
||||
);
|
||||
}
|
||||
@ -304,12 +303,11 @@ nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep,
|
||||
/** \ingroup variables
|
||||
Learn the szip settings of a variable.
|
||||
|
||||
This function returns the szip settings for a variable. NetCDF does
|
||||
not allow variables to be created with szip (due to license problems
|
||||
with the szip library), but we do enable read-only access of HDF5
|
||||
files with szip compression.
|
||||
This function returns the szip settings for a variable.
|
||||
With the introduction of general filter support,
|
||||
szip inquiry is converted to use the filter interface.
|
||||
|
||||
This is a wrapper for nc_inq_var_all().
|
||||
This is a wrapper for nc_inq_var_filter().
|
||||
|
||||
\param ncid NetCDF or group ID, from a previous call to nc_open(),
|
||||
nc_create(), nc_def_grp(), or associated inquiry functions such as
|
||||
@ -327,15 +325,22 @@ here. \ref ignored_if_null.
|
||||
\returns ::NC_EBADID Bad ncid.
|
||||
\returns ::NC_ENOTNC4 Not a netCDF-4 file.
|
||||
\returns ::NC_ENOTVAR Invalid variable ID.
|
||||
\returns ::NC_EFILTER Variable is not szip encoded
|
||||
*/
|
||||
int
|
||||
nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
|
||||
{
|
||||
NC* ncp;
|
||||
unsigned int id;
|
||||
size_t nparams;
|
||||
unsigned int params[2];
|
||||
|
||||
int stat = NC_check_id(ncid,&ncp);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
TRACE(nc_inq_var_szip);
|
||||
return ncp->dispatch->inq_var_all(
|
||||
|
||||
/* Verify id and nparams */
|
||||
stat = ncp->dispatch->inq_var_all(
|
||||
ncid, varid,
|
||||
NULL, /*name*/
|
||||
NULL, /*xtypep*/
|
||||
@ -351,9 +356,39 @@ nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
|
||||
NULL, /*nofillp*/
|
||||
NULL, /*fillvaluep*/
|
||||
NULL, /*endianp*/
|
||||
options_maskp, /*optionsmaskp*/
|
||||
pixels_per_blockp, /*pixelsp*/
|
||||
NULL, NULL, NULL);
|
||||
&id,
|
||||
&nparams,
|
||||
NULL
|
||||
);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
if(id != H5Z_FILTER_SZIP || nparams != 2)
|
||||
return NC_EFILTER; /* not szip or bad # params */
|
||||
/* Get params */
|
||||
stat = ncp->dispatch->inq_var_all(
|
||||
ncid, varid,
|
||||
NULL, /*name*/
|
||||
NULL, /*xtypep*/
|
||||
NULL, /*ndimsp*/
|
||||
NULL, /*dimidsp*/
|
||||
NULL, /*nattsp*/
|
||||
NULL, /*shufflep*/
|
||||
NULL, /*deflatep*/
|
||||
NULL, /*deflatelevelp*/
|
||||
NULL, /*fletcher32p*/
|
||||
NULL, /*contiguousp*/
|
||||
NULL, /*chunksizep*/
|
||||
NULL, /*nofillp*/
|
||||
NULL, /*fillvaluep*/
|
||||
NULL, /*endianp*/
|
||||
&id,
|
||||
&nparams,
|
||||
params
|
||||
);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
/* Param[0] should be options_mask, Param[1] should be pixels_per_block */
|
||||
if(options_maskp) *options_maskp = (int)params[0];
|
||||
if(pixels_per_blockp) *pixels_per_blockp = (int)params[1];
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/** \ingroup variables
|
||||
@ -399,8 +434,6 @@ nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
|
||||
NULL, /*nofillp*/
|
||||
NULL, /*fillvaluep*/
|
||||
NULL, /*endianp*/
|
||||
NULL, /*optionsmaskp*/
|
||||
NULL, /*pixelsp*/
|
||||
NULL, NULL, NULL
|
||||
);
|
||||
}
|
||||
@ -474,7 +507,7 @@ nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
|
||||
TRACE(nc_inq_var_chunking);
|
||||
return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, storagep,
|
||||
chunksizesp, NULL, NULL, NULL, NULL, NULL,
|
||||
chunksizesp, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -524,8 +557,6 @@ nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep)
|
||||
no_fill, /*nofillp*/
|
||||
fill_valuep, /*fillvaluep*/
|
||||
NULL, /*endianp*/
|
||||
NULL, /*optionsmaskp*/
|
||||
NULL, /*pixelsp*/
|
||||
NULL, NULL, NULL
|
||||
);
|
||||
}
|
||||
@ -574,8 +605,6 @@ nc_inq_var_endian(int ncid, int varid, int *endianp)
|
||||
NULL, /*nofillp*/
|
||||
NULL, /*fillvaluep*/
|
||||
endianp, /*endianp*/
|
||||
NULL, /*optionsmaskp*/
|
||||
NULL, /*pixelsp*/
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -659,8 +688,6 @@ nc_inq_var_filter(int ncid, int varid, unsigned int* idp, size_t* nparamsp, unsi
|
||||
NULL, /*nofillp*/
|
||||
NULL, /*fillvaluep*/
|
||||
NULL, /*endianp*/
|
||||
NULL, /*optionsmaskp*/
|
||||
NULL, /*pixelsp*/
|
||||
idp, nparamsp, params);
|
||||
}
|
||||
|
||||
@ -705,7 +732,6 @@ NC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
)
|
||||
{
|
||||
@ -719,8 +745,6 @@ NC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
contiguousp, chunksizesp,
|
||||
no_fill, fill_valuep,
|
||||
endiannessp,
|
||||
options_maskp,
|
||||
pixels_per_blockp,
|
||||
idp,nparamsp,params);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ static int NC3_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
);
|
||||
|
||||
@ -196,7 +195,6 @@ NC3_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
)
|
||||
{
|
||||
@ -208,7 +206,6 @@ NC3_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
if(contiguousp) *contiguousp = NC_CONTIGUOUS;
|
||||
if(no_fill) *no_fill = 1;
|
||||
if(endiannessp) return NC_ENOTNC4;
|
||||
if(options_maskp) return NC_ENOTNC4;
|
||||
if(idp) return NC_ENOTNC4;
|
||||
if(nparamsp) return NC_ENOTNC4;
|
||||
if(params) return NC_ENOTNC4;
|
||||
|
@ -1691,14 +1691,6 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name,
|
||||
var->deflate_level = cd_values[0];
|
||||
break;
|
||||
|
||||
case H5Z_FILTER_SZIP:
|
||||
var->szip = NC_TRUE;
|
||||
if (cd_nelems != CD_NELEMS_SZIP)
|
||||
BAIL(NC_EHDFERR);
|
||||
var->options_mask = cd_values[0];
|
||||
var->pixels_per_block = cd_values[1];
|
||||
break;
|
||||
|
||||
default:
|
||||
var->filterid = filter;
|
||||
var->nparams = cd_nelems;
|
||||
|
@ -1625,17 +1625,22 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
|
||||
if (H5Pset_deflate(plistid, var->deflate_level) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
} else if(var->filterid) {
|
||||
if(H5Pset_filter(plistid, var->filterid, H5Z_FLAG_MANDATORY, var->nparams, var->params) < 0)
|
||||
BAIL(NC_EFILTER);
|
||||
/* Handle szip case here */
|
||||
if(var->filterid == H5Z_FILTER_SZIP) {
|
||||
int options_mask;
|
||||
int bits_per_pixel;
|
||||
if(var->nparams != 2)
|
||||
BAIL(NC_EFILTER);
|
||||
options_mask = (int)var->params[0];
|
||||
bits_per_pixel = (int)var->params[1];
|
||||
if(H5Pset_szip(plistid, options_mask, bits_per_pixel) < 0)
|
||||
BAIL(NC_EFILTER);
|
||||
} else {
|
||||
if(H5Pset_filter(plistid, var->filterid, H5Z_FLAG_MANDATORY, var->nparams, var->params) < 0)
|
||||
BAIL(NC_EFILTER);
|
||||
}
|
||||
}
|
||||
|
||||
/* Szip? NO! We don't want anyone to produce szipped netCDF files! */
|
||||
/* #ifdef USE_SZIP */
|
||||
/* if (var->options_mask) */
|
||||
/* if (H5Pset_szip(plistid, var->options_mask, var->bits_per_pixel) < 0) */
|
||||
/* BAIL(NC_EHDFERR); */
|
||||
/* #endif */
|
||||
|
||||
/* If the user wants to fletcher error correcton, set that up now. */
|
||||
if (var->fletcher32)
|
||||
if (H5Pset_fletcher32(plistid) < 0)
|
||||
@ -1661,7 +1666,7 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
|
||||
* has not specified chunksizes, use contiguous variable for
|
||||
* better performance. */
|
||||
|
||||
if(!var->shuffle && !var->deflate && !var->options_mask &&
|
||||
if(!var->shuffle && !var->deflate &&
|
||||
!var->fletcher32 && (var->chunksizes == NULL || !var->chunksizes[0])) {
|
||||
#ifdef USE_HDF4
|
||||
NC_HDF5_FILE_INFO_T *h5 = grp->nc4_info;
|
||||
|
@ -672,7 +672,6 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp,
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params
|
||||
)
|
||||
{
|
||||
@ -752,13 +751,6 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
*shufflep = (int)var->shuffle;
|
||||
if (fletcher32p)
|
||||
*fletcher32p = (int)var->fletcher32;
|
||||
/* NOTE: No interface for returning szip flag currently (but it should never
|
||||
* be set).
|
||||
*/
|
||||
if (options_maskp)
|
||||
*options_maskp = var->options_mask;
|
||||
if (pixels_per_blockp)
|
||||
*pixels_per_blockp = var->pixels_per_block;
|
||||
|
||||
if (idp)
|
||||
*idp = var->filterid;
|
||||
@ -1081,7 +1073,7 @@ nc_inq_var_chunking_ints(int ncid, int varid, int *contiguousp, int *chunksizesp
|
||||
|
||||
retval = NC4_inq_var_all(ncid, varid, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, contiguousp, cs, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* Copy from size_t array. */
|
||||
if (*contiguousp == NC_CHUNKED)
|
||||
@ -1195,7 +1187,18 @@ NC4_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const u
|
||||
if (var->created)
|
||||
return NC_ELATEDEF;
|
||||
|
||||
if(0) {
|
||||
#ifdef HAVE_H5Z_SZIP
|
||||
if(id == H5Z_FILTER_SZIP) {
|
||||
if(nparams != 2)
|
||||
return NC_EFILTER; /* incorrect no. of parameters */
|
||||
}
|
||||
#else /*!HAVE_H5Z_SZIP*/
|
||||
if(id == H5Z_FILTER_SZIP)
|
||||
return NC_EFILTER; /* Not allowed */
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
{
|
||||
unsigned int fcfg = 0;
|
||||
herr_t herr = H5Zget_filter_info(id,&fcfg);
|
||||
if(herr < 0)
|
||||
@ -1204,6 +1207,8 @@ NC4_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const u
|
||||
|| (H5Z_FILTER_CONFIG_DECODE_ENABLED & fcfg) == 0)
|
||||
return NC_EFILTER;
|
||||
}
|
||||
#endif /*0*/
|
||||
|
||||
var->filterid = id;
|
||||
var->nparams = nparams;
|
||||
var->params = NULL;
|
||||
|
@ -1157,7 +1157,7 @@ NCP_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
|
||||
int *shufflep, int *deflatep, int *deflate_levelp,
|
||||
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
|
||||
int *no_fill, void *fill_valuep, int *endiannessp,
|
||||
int *options_maskp, int *pixels_per_blockp)
|
||||
unsigned int* idp, size_t* nparamsp, unsigned int* params)
|
||||
{
|
||||
int status;
|
||||
NC* nc;
|
||||
|
@ -1,23 +1,25 @@
|
||||
# Test c output
|
||||
T=tst_misc
|
||||
T=tst_szip
|
||||
#CMD=valgrind --leak-check=full
|
||||
CMD=gdb --args
|
||||
|
||||
#PAR=1
|
||||
SZIP=1
|
||||
|
||||
CFLAGS=-Wall -Wno-unused-variable -Wno-unused-function -g -O0 -I.. -I../include
|
||||
CFLAGS = -Wall -Wno-unused-variable -Wno-unused-function -g -O0 -I.. -I../include
|
||||
|
||||
LDFLAGS = ../liblib/.libs/libnetcdf.a -L/usr/local/lib -lhdf5_hl -lhdf5 -lz -ldl -lcurl -lm
|
||||
|
||||
ifdef PAR
|
||||
CC=mpicc
|
||||
#CC=/usr/local/bin/mpicc
|
||||
LDFLAGS=../liblib/.libs/libnetcdf.a -L/usr/local/lib -lhdf5_hl -lhdf5 -lz -ldl -lcurl -lpnetcdf -lmpich -lm
|
||||
LDFLAGS += -lmpich
|
||||
else
|
||||
CC=gcc
|
||||
#LDFLAGS=../liblib/.libs/libnetcdf.a -L/usr/local/lib -lhdf5_hl -lhdf5 -lz -lm -lcurl
|
||||
LDFLAGS=../liblib/.libs/libnetcdf.a -L/usr/local/lib -lhdf5_hl -lhdf5 -lz -ldl -lm -lcurl
|
||||
endif
|
||||
|
||||
# cd .. ; ${MAKE} all
|
||||
ifdef SZIP
|
||||
LDFLAGS += -lsz -laec
|
||||
endif
|
||||
|
||||
LLP=/usr/local/lib:${LD_LIBRARY_PATH}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
Copyright 2008, UCAR/Unidata
|
||||
See COPYRIGHT file for copying and redistribution conditions.
|
||||
|
||||
This program tests the large file bug in netCDF 3.6.2,
|
||||
creating byte and short variables larger than 4 GiB.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
116
nc_test4/tst_szip.c
Normal file
116
nc_test4/tst_szip.c
Normal file
@ -0,0 +1,116 @@
|
||||
/* This is part of the netCDF package.
|
||||
Copyright 2005 University Corporation for Atmospheric Research/Unidata
|
||||
See COPYRIGHT file for conditions of use.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Example illustrates the use of SZIP compression in netCDF5
|
||||
* Taken from HDF5 example.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "nc_tests.h"
|
||||
#include "err_macros.h"
|
||||
#include "netcdf.h"
|
||||
#include "netcdf_filter.h"
|
||||
|
||||
#define PLAIN
|
||||
#undef USECLOSE
|
||||
|
||||
/* Szip Constants. */
|
||||
#define HDF5_FILTER_SZIP 4
|
||||
#define H5_SZIP_EC_OPTION_MASK 4
|
||||
#define H5_SZIP_NN_OPTION_MASK 32
|
||||
#define H5_SZIP_MAX_PIXELS_PER_BLOCK 32
|
||||
|
||||
#define NX 500
|
||||
#define NY 600
|
||||
#define CH_NX 100
|
||||
#define CH_NY 25
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int ncid, varid, dimids[2];
|
||||
size_t dims[2], chunk_size[2];
|
||||
float buf[NX][NY];
|
||||
float buf_r[NX][NY];
|
||||
int i, j;
|
||||
unsigned int szip_params[2]; /* [0]=options_mask [1]=pixels_per_block */
|
||||
|
||||
/* Create a new file using read/write access. */
|
||||
if(nc_create("testszip.nc", NC_CLOBBER|NC_NETCDF4, &ncid)) ERR;
|
||||
|
||||
/* Create dims */
|
||||
dims[0] = NX;
|
||||
dims[1] = NY;
|
||||
if(nc_def_dim(ncid, "x", dims[0], &dimids[0])) ERR;
|
||||
if(nc_def_dim(ncid, "y", dims[1], &dimids[1])) ERR;
|
||||
|
||||
/* Create a dimensioned variable */
|
||||
if(nc_def_var(ncid, "var", NC_FLOAT, 2, dimids, &varid)) ERR;
|
||||
|
||||
/* Define chunking for the variable:
|
||||
* the raw data is to be partitioned into 100x100 element chunks.
|
||||
*/
|
||||
chunk_size[0] = CH_NX;
|
||||
chunk_size[1] = CH_NY;
|
||||
if(nc_def_var_chunking(ncid, varid, NC_CHUNKED, chunk_size)) ERR;
|
||||
|
||||
#ifndef PLAIN
|
||||
/*
|
||||
* Set parameters for SZIP compression; check the description of
|
||||
* the H5Pset_szip function in the HDF5 Reference Manual for more
|
||||
* information.
|
||||
*/
|
||||
szip_params[0] = H5_SZIP_NN_OPTION_MASK;
|
||||
szip_params[1] = H5_SZIP_MAX_PIXELS_PER_BLOCK;
|
||||
if(nc_def_var_filter(ncid, varid, HDF5_FILTER_SZIP, 2, szip_params)) ERR;
|
||||
#endif
|
||||
|
||||
if(nc_enddef(ncid)) ERR;
|
||||
|
||||
/* Initialize data buffer with some bogus data. */
|
||||
for(i=0; i < NX; i++) {
|
||||
for(j=0; j < NY; j++) {
|
||||
buf[i][j] = (float)(i + j);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the array to the file */
|
||||
if(nc_put_var_float(ncid, varid, &buf[0][0])) ERR;
|
||||
|
||||
#if USECLOSE
|
||||
/* Close and re-open the file */
|
||||
if(nc_close(ncid)) ERR;
|
||||
if(nc_open("testszip.nc", NC_NETCDF4. &ncid)) ERR;
|
||||
if(nc_inq_varid(ncid, "var", &varid)) ERR;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Read the array. This is similar to writing data,
|
||||
* except the data flows in the opposite direction.
|
||||
* Note: Decompression should be automatic.
|
||||
*/
|
||||
|
||||
memset(buf_r,0,sizeof(buf_r));
|
||||
if(nc_get_var_float(ncid, varid, &buf_r[0][0])) ERR;
|
||||
|
||||
/* Do comparison */
|
||||
for (i=0; i < NX; i++) {
|
||||
for (j=0; j < NY; j++) {
|
||||
if(buf[i][j] != buf_r[i][j]) {
|
||||
printf("mismatch: [%d][%d]: write = %f read=%f\n",
|
||||
i,j,buf[i][j],buf_r[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(nc_close(ncid)) ERR;
|
||||
|
||||
SUMMARIZE_ERR;
|
||||
FINAL_RESULTS;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user