mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-17 16:50:18 +08:00
Explicitly disallow variable length type compression
re: https://github.com/Unidata/netcdf-c/issues/2189 Compression of a variable whose type is variable length fails for all current filters. This is because at some point, the compression buffer will contain pointers to data instead of the actual data. Compression of pointers of course is meaningless. The PR changes the behavior of nc_def_var_filter so that it will fail with error NC_EFILTER if an attempt is made to add a filter to a variable whose type is variable-length. A variable is variable-length if it is of type string or VLEN or transitively (via a compound type) contains a string or VLEN. Also added a test case for this. ## Misc Changes 1. Turn off a number of debugging statements
This commit is contained in:
parent
a7465d46cb
commit
9b7202bf06
2
.github/workflows/mingw.yml
vendored
2
.github/workflows/mingw.yml
vendored
@ -1,5 +1,5 @@
|
||||
name: NetCDF-Build MinGW
|
||||
on: [workflow_dispatch]
|
||||
on: [workflow_dispatch,push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release
|
||||
|
||||
## 4.8.2 - TBD
|
||||
|
||||
* [Bug Fix] Require that the type of the variable in nc_def_var_filter is not variable length. See [Github #/???](https://github.com/Unidata/netcdf-c/pull/????).
|
||||
* [Enhancement] Add complete bitgroom support to NCZarr. See [Github #2197](https://github.com/Unidata/netcdf-c/pull/2197).
|
||||
* [Bug Fix] Clean up the handling of deeply nested VLEN types. Marks nc_free_vlen() and nc_free_string as deprecated in favor of ncaux_reclaim_data(). See [Github #2179(https://github.com/Unidata/netcdf-c/pull/2179).
|
||||
* [Bug Fix] Make sure that netcdf.h accurately defines the flags in the open/create mode flags. See [Github #2183](https://github.com/Unidata/netcdf-c/pull/2183).
|
||||
|
@ -12,7 +12,7 @@ Test the netcdf-4 data building process.
|
||||
#include <stdio.h>
|
||||
#include "netcdf.h"
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
static void
|
||||
fail(int code)
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "dapincludes.h"
|
||||
#include "dceparselex.h"
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
#define LBRACE "{"
|
||||
#define RBRACE "}"
|
||||
|
@ -116,10 +116,18 @@ done:
|
||||
EXTERNL int
|
||||
nc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const unsigned int* params)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
NC* ncp;
|
||||
int stat = NC_check_id(ncid,&ncp);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
TRACE(nc_inq_var_filter_info);
|
||||
int fixedsize;
|
||||
nc_type xtype;
|
||||
|
||||
TRACE(nc_inq_var_filter);
|
||||
if((stat = NC_check_id(ncid,&ncp))) return stat;
|
||||
/* Get variable' type */
|
||||
if((stat = nc_inq_vartype(ncid,varid,&xtype))) return stat;
|
||||
/* If the variable's type is not fixed-size, then signal error */
|
||||
if((stat = NC4_inq_type_fixed_size(ncid, xtype, &fixedsize))) return stat;
|
||||
if(!fixedsize) return NC_EFILTER;
|
||||
if((stat = ncp->dispatch->def_var_filter(ncid,varid,id,nparams,params))) goto done;
|
||||
done:
|
||||
return stat;
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#undef DEBUGPATH
|
||||
static int pathdebug = -1;
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define REPORT(e,msg) report((e),(msg),__LINE__)
|
||||
@ -113,7 +113,9 @@ static int wide2utf8(const wchar_t* u16, char** u8p);
|
||||
#endif
|
||||
|
||||
/*Forward*/
|
||||
#ifdef DEBUG
|
||||
static void report(int stat, const char* msg, int line);
|
||||
#endif
|
||||
static char* printPATH(struct Path* p);
|
||||
|
||||
EXTERNL
|
||||
@ -1227,6 +1229,7 @@ printutf8hex(const char* s, char* sx)
|
||||
*q = '\0';
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
report(int stat, const char* msg, int line)
|
||||
{
|
||||
@ -1235,3 +1238,4 @@ report(int stat, const char* msg, int line)
|
||||
line,msg,stat,nc_strerror(stat));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -73,9 +73,8 @@ NC_s3sdkinitialize(void)
|
||||
ncs3_finalized = 0;
|
||||
NCTRACE(11,NULL);
|
||||
Aws::InitAPI(ncs3options);
|
||||
NCUNTRACE(NC_NOERR);
|
||||
}
|
||||
return 1;
|
||||
return NCUNTRACE(NC_NOERR);
|
||||
}
|
||||
|
||||
EXTERNL int
|
||||
@ -86,9 +85,8 @@ NC_s3sdkfinalize(void)
|
||||
ncs3_finalized = 1;
|
||||
NCTRACE(11,NULL);
|
||||
Aws::ShutdownAPI(ncs3options);
|
||||
NCUNTRACE(NC_NOERR);
|
||||
}
|
||||
return 1;
|
||||
return NCUNTRACE(NC_NOERR);
|
||||
}
|
||||
|
||||
static char*
|
||||
|
@ -42,6 +42,7 @@ IF(ENABLE_FILTER_TESTING)
|
||||
build_bin_test(tst_multifilter)
|
||||
build_bin_test(test_filter_order)
|
||||
build_bin_test(test_filter_repeat)
|
||||
build_bin_test(test_filter_vlen)
|
||||
ADD_SH_TEST(nc_test4 tst_filter)
|
||||
IF(ENABLE_BLOSC)
|
||||
ADD_SH_TEST(nc_test4 tst_specific_filters)
|
||||
|
@ -75,7 +75,7 @@ endif
|
||||
# Filter Tests (requires ncdump and ncgen)
|
||||
if ENABLE_FILTER_TESTING
|
||||
extradir =
|
||||
check_PROGRAMS += test_filter test_filter_misc test_filter_order test_filter_repeat
|
||||
check_PROGRAMS += test_filter test_filter_misc test_filter_order test_filter_repeat test_filter_vlen
|
||||
check_PROGRAMS += tst_multifilter
|
||||
TESTS += tst_filter.sh
|
||||
if ENABLE_BLOSC
|
||||
|
@ -131,17 +131,24 @@ verifychunks(void)
|
||||
static int
|
||||
create(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Create a file with one big variable, but whose dimensions arte not a multiple of chunksize (to see what happens) */
|
||||
CHECK(nc_create(testfile, NC_NETCDF4|NC_CLOBBER, &ncid));
|
||||
CHECK(nc_set_fill(ncid, NC_NOFILL, NULL));
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
static int
|
||||
defvar(nc_type xtype)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Create a file with one big variable, but whose dimensions arte not a multiple of chunksize (to see what happens) */
|
||||
for(i=0;i<ndims;i++) {
|
||||
char dimname[1024];
|
||||
snprintf(dimname,sizeof(dimname),"dim%d",i);
|
||||
CHECK(nc_def_dim(ncid, dimname, dimsize[i], &dimids[i]));
|
||||
}
|
||||
CHECK(nc_def_var(ncid, "var", NC_FLOAT, ndims, dimids, &varid));
|
||||
CHECK(nc_def_var(ncid, "var", xtype, ndims, dimids, &varid));
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
@ -370,6 +377,7 @@ test_test1(void)
|
||||
|
||||
fprintf(stderr,"test1: compression.\n");
|
||||
create();
|
||||
defvar(NC_FLOAT);
|
||||
setchunking();
|
||||
setvarfilter();
|
||||
showparameters();
|
||||
@ -401,6 +409,7 @@ test_test2(void)
|
||||
|
||||
fprintf(stderr,"test2: dimsize %% chunksize != 0: compress.\n");
|
||||
create();
|
||||
defvar(NC_FLOAT);
|
||||
setchunking();
|
||||
setvarfilter();
|
||||
showparameters();
|
||||
@ -433,6 +442,7 @@ test_test3(void)
|
||||
|
||||
fprintf(stderr,"test3: dimsize %% chunksize != 0: compress.\n");
|
||||
create();
|
||||
defvar(NC_FLOAT);
|
||||
setchunking();
|
||||
setvarfilter();
|
||||
showparameters();
|
||||
|
494
nc_test4/test_filter_vlen.c
Normal file
494
nc_test4/test_filter_vlen.c
Normal file
@ -0,0 +1,494 @@
|
||||
/*
|
||||
Copyright 2018, UCAR/Unidata
|
||||
See COPYRIGHT file for copying and redistribution conditions.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <hdf5.h>
|
||||
#include "netcdf.h"
|
||||
#include "netcdf_aux.h"
|
||||
#include "netcdf_filter.h"
|
||||
|
||||
#undef TESTODDSIZE
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
#ifndef H5Z_FILTER_FLETCHER32
|
||||
#define H5Z_FILTER_FLETCHER32 3
|
||||
#endif
|
||||
|
||||
/* The C standard apparently defines all floating point constants as double;
|
||||
we rely on that in this code.
|
||||
*/
|
||||
#define DBLVAL 12345678.12345678
|
||||
|
||||
#define TEST_ID 32768
|
||||
|
||||
#define MAXERRS 8
|
||||
|
||||
#define MAXPARAMS 32
|
||||
|
||||
#define NPARAMS 14
|
||||
|
||||
static unsigned int baseline[NPARAMS];
|
||||
|
||||
static const char* testfile = NULL;
|
||||
|
||||
#define MAXDIMS 8
|
||||
|
||||
#define DFALT_TESTFILE "tmp_misc.nc"
|
||||
|
||||
#define spec "32768, -17b, 23ub, -25S, 27US, 77, 93U, 789f, 12345678.12345678d, -9223372036854775807L, 18446744073709551615UL"
|
||||
|
||||
#ifdef TESTODDSIZE
|
||||
#define NDIMS 1
|
||||
static size_t dimsize[NDIMS] = {4};
|
||||
static size_t chunksize[NDIMS] = {3};
|
||||
#else
|
||||
#define NDIMS 4
|
||||
static size_t dimsize[NDIMS] = {4,4,4,4};
|
||||
static size_t chunksize[NDIMS] = {4,4,4,4};
|
||||
#endif
|
||||
|
||||
static size_t ndims = NDIMS;
|
||||
|
||||
static size_t totalproduct = 1; /* x-product over max dims */
|
||||
static size_t actualproduct = 1; /* x-product over actualdims */
|
||||
static size_t chunkproduct = 1; /* x-product over actual chunks */
|
||||
|
||||
static size_t pattern[MAXDIMS];
|
||||
|
||||
static int nerrs = 0;
|
||||
|
||||
static int ncid, varid;
|
||||
static int dimids[MAXDIMS];
|
||||
static size_t odom[MAXDIMS];
|
||||
static float* array = NULL;
|
||||
static float* expected = NULL;
|
||||
|
||||
static unsigned int filterid = 0;
|
||||
static size_t nparams = 0;
|
||||
static unsigned int params[MAXPARAMS];
|
||||
|
||||
/* Forward */
|
||||
static int test_test1(void);
|
||||
static void init(int argc, char** argv);
|
||||
static void reset(void);
|
||||
static void odom_reset(void);
|
||||
static int odom_more(void);
|
||||
static int odom_next(void);
|
||||
static int odom_offset(void);
|
||||
static float expectedvalue(void);
|
||||
static void verifyparams(void);
|
||||
|
||||
#define ERRR 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)
|
||||
|
||||
static int
|
||||
check(int err,int line)
|
||||
{
|
||||
if(err != NC_NOERR) {
|
||||
fprintf(stderr,"fail (%d): %s\n",line,nc_strerror(err));
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
static void
|
||||
report(const char* msg, int lineno)
|
||||
{
|
||||
fprintf(stderr,"fail: line=%d %s\n",lineno,msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#define CHECK(x) check(x,__LINE__)
|
||||
#define REPORT(x) report(x,__LINE__)
|
||||
|
||||
static int
|
||||
verifychunks(void)
|
||||
{
|
||||
int i;
|
||||
int store = -1;
|
||||
size_t localchunks[MAXDIMS];
|
||||
memset(localchunks,0,sizeof(localchunks));
|
||||
CHECK(nc_inq_var_chunking(ncid, varid, &store, localchunks));
|
||||
if(store != NC_CHUNKED) {
|
||||
fprintf(stderr,"bad chunk store\n");
|
||||
return 0;
|
||||
}
|
||||
for(i=0;i<ndims;i++) {
|
||||
if(chunksize[i] != localchunks[i]) {
|
||||
fprintf(stderr,"bad chunk size: %d\n",i);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
create(void)
|
||||
{
|
||||
/* Create a file with one big variable, but whose dimensions arte not a multiple of chunksize (to see what happens) */
|
||||
CHECK(nc_create(testfile, NC_NETCDF4|NC_CLOBBER, &ncid));
|
||||
CHECK(nc_set_fill(ncid, NC_NOFILL, NULL));
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
static int
|
||||
defvar(nc_type xtype)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Create a file with one big variable, but whose dimensions arte not a multiple of chunksize (to see what happens) */
|
||||
for(i=0;i<ndims;i++) {
|
||||
char dimname[1024];
|
||||
snprintf(dimname,sizeof(dimname),"dim%d",i);
|
||||
CHECK(nc_def_dim(ncid, dimname, dimsize[i], &dimids[i]));
|
||||
}
|
||||
CHECK(nc_def_var(ncid, "var", xtype, ndims, dimids, &varid));
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
static void
|
||||
setvarfilter(void)
|
||||
{
|
||||
CHECK(nc_def_var_filter(ncid,varid,TEST_ID,NPARAMS,baseline));
|
||||
verifyparams();
|
||||
}
|
||||
|
||||
static void
|
||||
verifyparams(void)
|
||||
{
|
||||
int i;
|
||||
CHECK(nc_inq_var_filter(ncid,varid,&filterid,&nparams,params));
|
||||
if(filterid != TEST_ID) REPORT("id mismatch");
|
||||
if(nparams != NPARAMS) REPORT("nparams mismatch");
|
||||
for(i=0;i<nparams;i++) {
|
||||
if(params[i] != baseline[i])
|
||||
REPORT("param mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
openfile(void)
|
||||
{
|
||||
unsigned int* params = NULL;
|
||||
|
||||
/* Open the file and check it. */
|
||||
CHECK(nc_open(testfile, NC_NOWRITE, &ncid));
|
||||
CHECK(nc_inq_varid(ncid, "var", &varid));
|
||||
|
||||
/* Check the compression algorithm */
|
||||
CHECK(nc_inq_var_filter(ncid,varid,&filterid,&nparams,NULL));
|
||||
if(nparams > 0) {
|
||||
params = (unsigned int*)malloc(sizeof(unsigned int)*nparams);
|
||||
if(params == NULL)
|
||||
return NC_ENOMEM;
|
||||
CHECK(nc_inq_var_filter(ncid,varid,&filterid,&nparams,params));
|
||||
}
|
||||
if(filterid != TEST_ID) {
|
||||
fprintf(stderr,"open: test id mismatch: %d\n",filterid);
|
||||
free(params);
|
||||
return NC_EFILTER;
|
||||
}
|
||||
if(nparams != NPARAMS) {
|
||||
size_t i;
|
||||
fprintf(stderr,"nparams mismatch\n");
|
||||
for(nerrs=0,i=0;i<nparams;i++) {
|
||||
if(params[i] != baseline[i]) {
|
||||
fprintf(stderr,"open: testparam mismatch: %ld\n",(unsigned long)i);
|
||||
nerrs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(params);
|
||||
|
||||
if(nerrs > 0) return NC_EFILTER;
|
||||
|
||||
/* Verify chunking */
|
||||
if(!verifychunks())
|
||||
return 0;
|
||||
fflush(stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
setchunking(void)
|
||||
{
|
||||
int store;
|
||||
|
||||
store = NC_CHUNKED;
|
||||
CHECK(nc_def_var_chunking(ncid,varid,store,chunksize));
|
||||
if(!verifychunks())
|
||||
return NC_EINVAL;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
static void
|
||||
fill(void)
|
||||
{
|
||||
odom_reset();
|
||||
if(1) {
|
||||
int i;
|
||||
if(actualproduct <= 1) abort();
|
||||
for(i=0;i<actualproduct;i++)
|
||||
expected[i] = (float)i;
|
||||
} else {
|
||||
while(odom_more()) {
|
||||
int offset = odom_offset();
|
||||
float expect = expectedvalue();
|
||||
expected[offset] = expect;
|
||||
odom_next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
compare(void)
|
||||
{
|
||||
int errs = 0;
|
||||
fprintf(stderr,"data comparison: |array|=%ld\n",(unsigned long)actualproduct);
|
||||
if(1)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<actualproduct;i++) {
|
||||
if(expected[i] != array[i]) {
|
||||
fprintf(stderr,"data mismatch: array[%d]=%f expected[%d]=%f\n",
|
||||
i,array[i],i,expected[i]);
|
||||
errs++;
|
||||
if(errs >= MAXERRS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
odom_reset();
|
||||
while(odom_more()) {
|
||||
int offset = odom_offset();
|
||||
float expect = expectedvalue();
|
||||
if(array[offset] != expect) {
|
||||
fprintf(stderr,"data mismatch: array[%d]=%f expected=%f\n",
|
||||
offset,array[offset],expect);
|
||||
errs++;
|
||||
if(errs >= MAXERRS)
|
||||
break;
|
||||
}
|
||||
odom_next();
|
||||
}
|
||||
}
|
||||
|
||||
if(errs == 0)
|
||||
fprintf(stderr,"no data errors\n");
|
||||
return (errs == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
showparameters(void)
|
||||
{
|
||||
int i;
|
||||
fprintf(stderr,"test: nparams=%ld: params=",(unsigned long)nparams);
|
||||
for(i=0;i<nparams;i++) {
|
||||
fprintf(stderr," %u",params[i]);
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
for(i=0;i<ndims;i++) {
|
||||
if(i==0)
|
||||
fprintf(stderr,"dimsizes=%ld",(unsigned long)dimsize[i]);
|
||||
else
|
||||
fprintf(stderr,",%ld",(unsigned long)dimsize[i]);
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
for(i=0;i<ndims;i++) {
|
||||
if(i==0)
|
||||
fprintf(stderr,"chunksizes=%ld",(unsigned long)chunksize[i]);
|
||||
else
|
||||
fprintf(stderr,",%ld",(unsigned long)chunksize[i]);
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
insert(int index, void* src, size_t size)
|
||||
{
|
||||
unsigned char src8[8];
|
||||
void* dst = &baseline[index];
|
||||
if(size == 8) {
|
||||
memcpy(src8,src,size);
|
||||
ncaux_h5filterspec_fix8(src8,0);
|
||||
src = src8;
|
||||
}
|
||||
memcpy(dst,src,size);
|
||||
}
|
||||
|
||||
static void
|
||||
buildbaseline(unsigned int testcasenumber)
|
||||
{
|
||||
unsigned int val4;
|
||||
unsigned long long val8;
|
||||
float float4;
|
||||
double float8;
|
||||
|
||||
baseline[0] = testcasenumber;
|
||||
switch (testcasenumber) {
|
||||
case 1:
|
||||
val4 = ((unsigned int)-17) & 0xff;
|
||||
insert(1,&val4,sizeof(val4)); /* 1 signed int*/
|
||||
val4 = (unsigned int)23;
|
||||
insert(2,&val4,sizeof(val4)); /* 2 unsigned int*/
|
||||
val4 = ((unsigned int)-25) & 0xffff;
|
||||
insert(3,&val4,sizeof(val4)); /* 3 signed int*/
|
||||
val4 = (unsigned int)27;
|
||||
insert(4,&val4,sizeof(val4)); /* 4 unsigned int*/
|
||||
val4 = (unsigned int)77;
|
||||
insert(5,&val4,sizeof(val4)); /* 5 signed int*/
|
||||
val4 = (unsigned int)93;
|
||||
insert(6,&val4,sizeof(val4)); /* 6 unsigned int*/
|
||||
float4 = 789.0f;
|
||||
insert(7,&float4,sizeof(float4)); /* 7 float */
|
||||
float8 = DBLVAL;
|
||||
insert(8,&float8,sizeof(float8)); /* 8 double */
|
||||
val8 = -9223372036854775807L;
|
||||
insert(10,&val8,sizeof(val8)); /* 10 signed long long */
|
||||
val8 = 18446744073709551615UL;
|
||||
insert(12,&val8,sizeof(val8)); /* 12 unsigned long long */
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Unknown testcase number: %d\n",testcasenumber);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
test_test1(void)
|
||||
{
|
||||
int ok = 1;
|
||||
int stat = NC_NOERR;
|
||||
|
||||
reset();
|
||||
buildbaseline(1);
|
||||
fprintf(stderr,"test4: filter on a variable length type.\n");
|
||||
create();
|
||||
defvar(NC_STRING);
|
||||
setchunking();
|
||||
/* Do explicit filter; should fail */
|
||||
switch (stat = nc_def_var_filter(ncid,varid,H5Z_FILTER_FLETCHER32,0,NULL)) {
|
||||
case NC_EFILTER: break; /* XFAIL */
|
||||
case NC_NOERR: CHECK(NC_EINVAL); break;
|
||||
default: CHECK(stat); break;
|
||||
}
|
||||
CHECK(nc_abort(ncid));
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Utilities */
|
||||
|
||||
static void
|
||||
reset()
|
||||
{
|
||||
memset(array,0,sizeof(float)*actualproduct);
|
||||
}
|
||||
|
||||
static void
|
||||
odom_reset(void)
|
||||
{
|
||||
memset(odom,0,sizeof(odom));
|
||||
}
|
||||
|
||||
static int
|
||||
odom_more(void)
|
||||
{
|
||||
return (odom[0] < dimsize[0]);
|
||||
}
|
||||
|
||||
static int
|
||||
odom_next(void)
|
||||
{
|
||||
int i; /* do not make unsigned */
|
||||
for(i=ndims-1;i>=0;i--) {
|
||||
odom[i] += 1;
|
||||
if(odom[i] < dimsize[i]) break;
|
||||
if(i == 0) return 0; /* leave the 0th entry if it overflows*/
|
||||
odom[i] = 0; /* reset this position*/
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
odom_offset(void)
|
||||
{
|
||||
int i;
|
||||
int offset = 0;
|
||||
for(i=0;i<ndims;i++) {
|
||||
offset *= dimsize[i];
|
||||
offset += odom[i];
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
static float
|
||||
expectedvalue(void)
|
||||
{
|
||||
int i;
|
||||
float offset = 0;
|
||||
|
||||
for(i=0;i<ndims;i++) {
|
||||
offset *= dimsize[i];
|
||||
offset += odom[i];
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
static void
|
||||
init(int argc, char** argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get the testfile path */
|
||||
if(argc > 1)
|
||||
testfile = argv[1];
|
||||
else
|
||||
testfile = DFALT_TESTFILE;
|
||||
|
||||
/* Setup various variables */
|
||||
totalproduct = 1;
|
||||
actualproduct = 1;
|
||||
chunkproduct = 1;
|
||||
for(i=0;i<NDIMS;i++) {
|
||||
if(pattern[i] == 1)
|
||||
chunksize[i] = 1;
|
||||
totalproduct *= dimsize[i];
|
||||
if(i < ndims) {
|
||||
actualproduct *= dimsize[i];
|
||||
chunkproduct *= chunksize[i];
|
||||
}
|
||||
}
|
||||
/* Allocate max size */
|
||||
array = (float*)calloc(1,sizeof(float)*actualproduct);
|
||||
expected = (float*)calloc(1,sizeof(float)*actualproduct);
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
H5Eprint1(stderr);
|
||||
nc_set_log_level(1);
|
||||
#endif
|
||||
init(argc,argv);
|
||||
if(!test_test1()) ERRR;
|
||||
exit(nerrs > 0?1:0);
|
||||
}
|
@ -251,7 +251,6 @@ diff -b -w ${srcdir}/ref_filter_repeat.txt tmp_filterrepeat.txt
|
||||
fi
|
||||
|
||||
if test "x$ORDER" = x1 ; then
|
||||
|
||||
echo "*** Testing multiple filter order of invocation on create"
|
||||
rm -f tmp_crfilterorder.txt
|
||||
${execdir}/test_filter_order create >tmp_crfilterorder.txt
|
||||
|
@ -16,7 +16,7 @@ See \ref copyright file for more info.
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
#include "netcdf.h"
|
||||
#include "nctestserver.h"
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <nc_tests.h>
|
||||
#include "err_macros.h"
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
static int ret = NC_NOERR;
|
||||
|
||||
|
@ -5,8 +5,6 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
||||
|
||||
set -e
|
||||
|
||||
export SETX=1
|
||||
|
||||
# For a netCDF-4 build, test nccopy on netCDF files in this directory
|
||||
|
||||
echo "@@@@@@"
|
||||
@ -20,9 +18,11 @@ echo ""
|
||||
# These files are actually in $srcdir in distcheck builds, so they
|
||||
# need to be handled differently.
|
||||
# ref_tst_compounds2 ref_tst_compounds3 ref_tst_compounds4
|
||||
TESTFILES='tst_comp tst_comp2 tst_enum_data tst_fillbug
|
||||
TESTFILES0='tst_comp tst_comp2 tst_enum_data tst_fillbug
|
||||
tst_group_data tst_nans tst_opaque_data tst_solar_1 tst_solar_2
|
||||
tst_solar_cmp tst_special_atts tst_string_data'
|
||||
tst_solar_cmp tst_special_atts'
|
||||
|
||||
TESTFILES="$TESTFILES0 tst_string_data"
|
||||
|
||||
# Causes memory leak; source unknown
|
||||
MEMLEAK="tst_vlen_data"
|
||||
@ -76,12 +76,12 @@ fi
|
||||
rm tst_deflated.nc tst_inflated.nc tst_inflated4.nc tmp.nc tmp.cdl
|
||||
|
||||
echo "*** Testing nccopy -d1 -s on ncdump/*.nc files"
|
||||
for i in $TESTFILES ; do
|
||||
for i in $TESTFILES0 ; do
|
||||
echo "*** Test nccopy -d1 -s $i.nc copy_of_$i.nc ..."
|
||||
${NCCOPY} -d1 -s $i.nc copy_of_$i.nc
|
||||
${NCDUMP} -n copy_of_$i $i.nc > tmp.cdl
|
||||
${NCDUMP} copy_of_$i.nc > copy_of_$i.cdl
|
||||
# echo "*** compare " with copy_of_$i.cdl
|
||||
${NCDUMP} -n copy_of_$i $i.nc > tmp.cdl
|
||||
${NCDUMP} copy_of_$i.nc > copy_of_$i.cdl
|
||||
# echo "*** compare " with copy_of_$i.cdl
|
||||
diff copy_of_$i.cdl tmp.cdl
|
||||
rm copy_of_$i.nc copy_of_$i.cdl tmp.cdl
|
||||
done
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
/* The data file we will create. */
|
||||
static const unsigned char prefix[] = {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "includes.h"
|
||||
#include "dump.h"
|
||||
|
||||
#define DEBUGSRC
|
||||
#undef DEBUGSRC
|
||||
|
||||
#define MAXELEM 8
|
||||
#define MAXDEPTH 4
|
||||
|
@ -1,8 +1,8 @@
|
||||
netcdf ref_byte {
|
||||
dimensions:
|
||||
.zdim_20 = 20 ;
|
||||
_zdim_20 = 20 ;
|
||||
variables:
|
||||
ubyte byte(.zdim_20, .zdim_20) ;
|
||||
ubyte byte(_zdim_20, _zdim_20) ;
|
||||
byte:_Storage = "chunked" ;
|
||||
byte:_ChunkSizes = 20, 20 ;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
netcdf tmp_groups_regular {
|
||||
dimensions:
|
||||
.zdim_3 = 3 ;
|
||||
.zdim_2 = 2 ;
|
||||
.zdim_10 = 10 ;
|
||||
_zdim_3 = 3 ;
|
||||
_zdim_2 = 2 ;
|
||||
_zdim_10 = 10 ;
|
||||
|
||||
// global attributes:
|
||||
:_Format = "netCDF-4" ;
|
||||
|
||||
group: MyGroup {
|
||||
variables:
|
||||
int dset1(.zdim_3, .zdim_3) ;
|
||||
int dset1(_zdim_3, _zdim_3) ;
|
||||
dset1:_Storage = "chunked" ;
|
||||
dset1:_ChunkSizes = 3, 3 ;
|
||||
dset1:_NoFill = "true" ;
|
||||
@ -24,7 +24,7 @@ group: MyGroup {
|
||||
|
||||
group: Group_A {
|
||||
variables:
|
||||
int dset2(.zdim_2, .zdim_10) ;
|
||||
int dset2(_zdim_2, _zdim_10) ;
|
||||
dset2:_Storage = "chunked" ;
|
||||
dset2:_ChunkSizes = 2, 10 ;
|
||||
dset2:_NoFill = "true" ;
|
||||
|
@ -48,15 +48,17 @@ diff -wb ${srcdir}/ref_byte_fill_value_null.cdl tmp_byte_fill_value_null_$zext.c
|
||||
rm -fr ref_byte_fill_value_null.zarr
|
||||
}
|
||||
|
||||
#testcase2059 file
|
||||
#testcase2062 file
|
||||
|
||||
testcase2062 file
|
||||
testcase2063 file
|
||||
exit 0
|
||||
if test "x$FEATURE_NCZARR_ZIP" = xyes ; then
|
||||
if test "x$FEATURE_HDF5" = xyes ; then
|
||||
testcase2059 file
|
||||
if test "x$FEATURE_NCZARR_ZIP" = xyes ; then
|
||||
testcase2059 zip
|
||||
fi
|
||||
if test "x$FEATURE_S3TESTS" = xyes ; then
|
||||
fi
|
||||
if test "x$FEATURE_S3TESTS" = xyes ; then
|
||||
testcase2059 s3
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#undef NODELETE
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
#define DATANAME "data"
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "ut_includes.h"
|
||||
#include "test_nczarr_utils.h"
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
static int ret = NC_NOERR;
|
||||
#define FILE_NAME "tmp_chunks3.nc"
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "ut_includes.h"
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
|
||||
typedef enum Cmds {
|
||||
cmd_none = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user