/* Copyright 2018, UCAR/Unidata See COPYRIGHT file for copying and redistribution conditions. */ #include "config.h" #include #include #include #include #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 float* array = NULL; static float* expected = NULL; /* Forward */ static int test_test1(void); static void init(int argc, char** argv); static void reset(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; } #define CHECK(x) check(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 1) testfile = argv[1]; else testfile = DFALT_TESTFILE; /* Setup various variables */ totalproduct = 1; actualproduct = 1; chunkproduct = 1; for(i=0;i 0?1:0); }