mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-23 16:59:54 +08:00
added tests to confirm correct default chunksizes when fletcher32/shuffle are turned on
This commit is contained in:
parent
605a5bfb0b
commit
bc759bba58
@ -3,20 +3,13 @@
|
||||
See COPYRIGHT file for conditions of use.
|
||||
|
||||
Test netcdf-4 variables.
|
||||
$Id$
|
||||
Ed Hartnett
|
||||
*/
|
||||
|
||||
#include <nc_tests.h>
|
||||
#include "err_macros.h"
|
||||
|
||||
#define FILE_NAME "tst_vars4.nc"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf("\n*** Testing netcdf-4 variable functions, even more.\n");
|
||||
printf("**** testing Jeff's dimension problem...");
|
||||
{
|
||||
#define NDIMS2 2
|
||||
#define NUM_VARS 1
|
||||
#define Y_NAME "y"
|
||||
@ -25,6 +18,12 @@ main(int argc, char **argv)
|
||||
#define XDIM_LEN 2
|
||||
#define YDIM_LEN 5
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf("\n*** Testing netcdf-4 variable functions, even more.\n");
|
||||
printf("**** testing Jeff's dimension problem...");
|
||||
{
|
||||
int varid, ncid, dims[NDIMS2], dims_in[NDIMS2];
|
||||
int ndims, nvars, ngatts, unlimdimid, natts;
|
||||
char name_in[NC_MAX_NAME + 1];
|
||||
@ -62,5 +61,49 @@ main(int argc, char **argv)
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("**** testing chunking turned on by fletcher...");
|
||||
{
|
||||
int varid, ncid, dims[NDIMS2];
|
||||
int storage_in;
|
||||
size_t chunksizes_in[NDIMS2];
|
||||
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
|
||||
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
|
||||
if (nc_def_var_fletcher32(ncid, varid, NC_FLETCHER32)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and check. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("**** testing chunking turned on by shuffle...");
|
||||
{
|
||||
int varid, ncid, dims[NDIMS2];
|
||||
int storage_in;
|
||||
size_t chunksizes_in[NDIMS2];
|
||||
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
|
||||
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
|
||||
if (nc_def_var_deflate(ncid, varid, NC_SHUFFLE, 0, 0)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and check. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
|
||||
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
FINAL_RESULTS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user