merged upstream master

This commit is contained in:
Ed Hartnett 2018-06-14 16:55:34 -06:00
commit 4763a6b831
6 changed files with 292 additions and 165 deletions

View File

@ -186,6 +186,7 @@ NC4_inq_typeid(int ncid, const char *name, nc_type *typeidp)
* @return ::NC_EINVAL Bad size.
* @return ::NC_EMAXNAME Name is too long.
* @return ::NC_EBADNAME Name breaks netCDF name rules.
* @return ::NC_ESTRICTNC3 Cannot define user types in classic model.
* @author Ed Hartnett
*/
static int
@ -210,6 +211,10 @@ add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid,
return retval;
assert(h5 && grp);
/* User types cannot be defined with classic model flag. */
if (h5->cmode & NC_CLASSIC_MODEL)
return NC_ESTRICTNC3;
/* Turn on define mode if it is not on. */
if (!(h5->cmode & NC_INDEF))
if ((retval = NC4_redef(ncid)))
@ -259,8 +264,11 @@ add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid,
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @return ::NC_ENOTNC4 User types in netCDF-4 files only.
* @return ::NC_EINVAL Bad size.
* @return ::NC_EMAXNAME Name is too long.
* @return ::NC_EBADNAME Name breaks netCDF name rules.
* @return ::NC_ESTRICTNC3 Cannot define user types in classic model.
* @author Ed Hartnett
*/
int
@ -364,8 +372,11 @@ NC4_insert_array_compound(int ncid, int typeid1, const char *name,
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @return ::NC_ENOTNC4 User types in netCDF-4 files only.
* @return ::NC_EINVAL Bad size.
* @return ::NC_EMAXNAME Name is too long.
* @return ::NC_EBADNAME Name breaks netCDF name rules.
* @return ::NC_ESTRICTNC3 Cannot define user types in classic model.
* @author Ed Hartnett
*/
int
@ -386,8 +397,10 @@ NC4_def_opaque(int ncid, size_t datum_size, const char *name,
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @return ::NC_ENOTNC4 User types in netCDF-4 files only.
* @return ::NC_EMAXNAME Name is too long.
* @return ::NC_EBADNAME Name breaks netCDF name rules.
* @return ::NC_ESTRICTNC3 Cannot define user types in classic model.
* @author Ed Hartnett
*/
int
@ -407,8 +420,11 @@ NC4_def_vlen(int ncid, const char *name, nc_type base_typeid,
* @param typeidp Pointer that gets new type ID.
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @return ::NC_ENOTNC4 User types in netCDF-4 files only.
* @return ::NC_EMAXNAME Name is too long.
* @return ::NC_EBADNAME Name breaks netCDF name rules.
* @return ::NC_ESTRICTNC3 Cannot define user types in classic model.
* @author Ed Hartnett
*/
int

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh

View File

@ -20,6 +20,7 @@
#define FILENAME2 "tst_types2.nc"
#define FILENAME3 "tst_types3.nc"
#define FILENAME4 "tst_types4.nc"
#define A_NAME "some_name"
#define CLEAN_INPUT_BUFFERS \
for (i = 0; i < SIZE; i++) { \
@ -153,7 +154,10 @@ int main(int argc, char *argv[])
if (nc_def_enum(ncid2 + TEST_VAL_42, NC_INT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3) != NC_EBADID) ERR;
if (nc_def_enum(ncid2, NC_INT, NULL, &typeid3) != NC_EINVAL) ERR;
if (nc_def_enum(ncid3, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3) != NC_ENOTNC4) ERR;
/* if (nc_def_enum(ncid4, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3) != NC_ENOTNC4) ERR; */
if (nc_def_enum(ncid4, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3) != NC_ESTRICTNC3) ERR;
if (nc_def_opaque(ncid4, TEST_VAL_42, A_NAME, &typeid3) != NC_ESTRICTNC3) ERR;
if (nc_def_compound(ncid4, TEST_VAL_42, A_NAME, &typeid3) != NC_ESTRICTNC3) ERR;
if (nc_def_vlen(ncid4, A_NAME, NC_INT, &typeid3) != NC_ESTRICTNC3) ERR;
/* Create some enum types that will not be equal to typeid1. */
if (nc_def_enum(ncid2, NC_SHORT, ENUM_UNEQUAL_TYPE_NAME_3, &typeid3)) ERR;

View File

@ -403,81 +403,144 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
/* #ifdef USE_SZIP */
/* printf("**** testing that szip works..."); */
/* { */
/* #define NDIMS1 1 */
/* #define D_SMALL "small_dim" */
/* #define D_SMALL_LEN1 100 */
/* #define D_MEDIUM "medium_dim" */
/* #define D_MEDIUM_LEN1 D_SMALL_LEN1 * 2 */
/* #define D_LARGE "large_dim" */
/* #define D_LARGE_LEN1 D_SMALL_LEN1 * 4 */
/* #define V_SMALL "small_var" */
/* #define V_MEDIUM "medium_var" */
/* #define V_LARGE "large_var" */
#ifdef USE_SZIP
printf("**** testing simple szip filter setup...");
{
#define NDIMS1 1
#define DIM_NAME_1 "one_dim"
#define DIM_LEN_1 100
#define VAR_NAME "var1"
#define H5_FILTER_SZIP 4
#define NUM_PARAMS 2
#define NC_SZIP_NN_OPTION_MASK 32 /**< @internal SZIP NN option mask. */
#define NC_SZIP_EC_OPTION_MASK 4 /**< @internal SZIP EC option mask. */
int ncid;
int dimid;
int varid;
/* int options_mask_in, bits_per_pixel_in; */
unsigned int params[NUM_PARAMS];
/* int ncid; */
/* int nvars, ndims, ngatts, unlimdimid; */
/* int ndims_in, natts_in, dimids_in; */
/* int small_dimid, medium_dimid, large_dimid; */
/* int small_varid, medium_varid, large_varid; */
/* char var_name_in[NC_MAX_NAME + 1]; */
/* nc_type xtype_in; */
/* int options_mask_in, bits_per_pixel_in; */
/* long long small_data[D_SMALL_LEN1], small_data_in[D_SMALL_LEN1]; */
/* long long medium_data[D_MEDIUM_LEN1], medium_data_in[D_MEDIUM_LEN1]; */
/* long long large_data[D_LARGE_LEN1], large_data_in[D_LARGE_LEN1]; */
/* int i; */
/* Create a netcdf-4 file with one dimensions. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME_1, DIM_LEN_1, &dimid)) ERR;
/* for (i = 0; i < D_SMALL_LEN1; i++) */
/* small_data[i] = i; */
/* for (i = 0; i < D_MEDIUM_LEN1; i++) */
/* medium_data[i] = i; */
/* for (i = 0; i < D_LARGE_LEN1; i++) */
/* large_data[i] = i; */
/* Add a var. Turn on szip filter. */
if (nc_def_var(ncid, V_SMALL, NC_INT64, NDIMS1, &dimid, &varid)) ERR;
params[0] = NC_SZIP_NN_OPTION_MASK;
params[1] = 32;
if (nc_def_var_chunking(ncid, varid, NC_CHUNKED, NULL)) ERR;
if (nc_def_var_filter(ncid, varid, H5_FILTER_SZIP, NUM_PARAMS, params)) ERR;
if (nc_close(ncid)) ERR;
/* /\* Create a netcdf-4 file with three dimensions. *\/ */
/* if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; */
/* if (nc_def_dim(ncid, D_SMALL, D_SMALL_LEN1, &small_dimid)) ERR; */
/* if (nc_def_dim(ncid, D_MEDIUM, D_MEDIUM_LEN1, &medium_dimid)) ERR; */
/* if (nc_def_dim(ncid, D_LARGE, D_LARGE_LEN1, &large_dimid)) ERR; */
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
/* The following code should work, but doesn't. See issue 972 in github. */
/* if (nc_inq_var_szip(ncid, varid, &options_mask_in, &bits_per_pixel_in)) ERR; */
/* if (options_mask_in != NC_SZIP_NN_OPTION_MASK || bits_per_pixel_in != 32) ERR; */
size_t nparams;
unsigned int filterid;
unsigned int params_in[4];
if (nc_inq_var_filter(ncid, varid, &filterid, &nparams, params_in));
if (filterid != H5_FILTER_SZIP || nparams != 4) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing more complex use of szip...");
{
#define NDIMS1 1
#define D_SMALL "small_dim"
#define D_SMALL_LEN1 100
#define D_MEDIUM "medium_dim"
#define D_MEDIUM_LEN1 D_SMALL_LEN1 * 2
#define D_LARGE "large_dim"
#define D_LARGE_LEN1 D_SMALL_LEN1 * 4
#define V_SMALL "small_var"
#define V_MEDIUM "medium_var"
#define V_LARGE "large_var"
#define H5_FILTER_SZIP 4
#define NUM_PARAMS 2
#define NC_SZIP_NN_OPTION_MASK 32 /**< @internal SZIP NN option mask. */
#define NC_SZIP_EC_OPTION_MASK 4 /**< @internal SZIP EC option mask. */
int ncid;
int nvars, ndims, ngatts, unlimdimid;
int ndims_in, natts_in, dimids_in;
int small_dimid, medium_dimid, large_dimid;
int small_varid, medium_varid, large_varid;
char var_name_in[NC_MAX_NAME + 1];
nc_type xtype_in;
/* int options_mask_in, bits_per_pixel_in; */
long long small_data[D_SMALL_LEN1], small_data_in[D_SMALL_LEN1];
long long medium_data[D_MEDIUM_LEN1], medium_data_in[D_MEDIUM_LEN1];
long long large_data[D_LARGE_LEN1], large_data_in[D_LARGE_LEN1];
unsigned int params[NUM_PARAMS];
int i;
/* /\* Add three vars. Turn on szip for two of them. *\/ */
/* if (nc_def_var(ncid, V_SMALL, NC_INT64, NDIMS1, &small_dimid, &small_varid)) ERR; */
for (i = 0; i < D_SMALL_LEN1; i++)
small_data[i] = i;
for (i = 0; i < D_MEDIUM_LEN1; i++)
medium_data[i] = i;
for (i = 0; i < D_LARGE_LEN1; i++)
large_data[i] = i;
/* if (nc_def_var(ncid, V_MEDIUM, NC_INT64, NDIMS1, &medium_dimid, &medium_varid)) ERR; */
/* if (nc_def_var_szip(ncid, medium_varid, NC_SZIP_EC_OPTION_MASK, 32)) ERR; */
/* Create a netcdf-4 file with three dimensions. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_dim(ncid, D_SMALL, D_SMALL_LEN1, &small_dimid)) ERR;
if (nc_def_dim(ncid, D_MEDIUM, D_MEDIUM_LEN1, &medium_dimid)) ERR;
if (nc_def_dim(ncid, D_LARGE, D_LARGE_LEN1, &large_dimid)) ERR;
/* if (nc_def_var(ncid, V_LARGE, NC_INT64, NDIMS1, &large_dimid, &large_varid)) ERR; */
/* if (nc_def_var_szip(ncid, large_varid, NC_SZIP_NN_OPTION_MASK, 16)) ERR; */
/* Add three vars. Turn on szip for two of them. */
if (nc_def_var(ncid, V_SMALL, NC_INT64, NDIMS1, &small_dimid, &small_varid)) ERR;
/* /\* Write data. *\/ */
/* if (nc_put_var_longlong(ncid, small_varid, small_data)) ERR; */
/* if (nc_put_var_longlong(ncid, medium_varid, medium_data)) ERR; */
/* if (nc_put_var_longlong(ncid, large_varid, large_data)) ERR; */
if (nc_def_var(ncid, V_MEDIUM, NC_INT64, NDIMS1, &medium_dimid, &medium_varid)) ERR;
params[0] = NC_SZIP_NN_OPTION_MASK;
params[1] = 32;
if (nc_def_var_chunking(ncid, medium_varid, NC_CHUNKED, NULL)) ERR;
if (nc_def_var_filter(ncid, medium_varid, H5_FILTER_SZIP, NUM_PARAMS, params)) ERR;
if (nc_def_var(ncid, V_LARGE, NC_INT64, NDIMS1, &large_dimid, &large_varid)) ERR;
params[1] = 32;
if (nc_def_var_chunking(ncid, large_varid, NC_CHUNKED, NULL)) ERR;
if (nc_def_var_filter(ncid, large_varid, H5_FILTER_SZIP, NUM_PARAMS, params)) ERR;
/* if (nc_close(ncid)) ERR; */
/* Write data. */
if (nc_put_var_longlong(ncid, small_varid, small_data)) ERR;
if (nc_put_var_longlong(ncid, medium_varid, medium_data)) ERR;
if (nc_put_var_longlong(ncid, large_varid, large_data)) ERR;
/* /\* Open the file and check. *\/ */
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
/* if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; */
/* if (nvars != 3 || ndims != 3 || ngatts != 0 || unlimdimid != -1) ERR; */
/* if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims_in, &dimids_in, &natts_in)) ERR; */
/* if (strcmp(var_name_in, V_SMALL) || xtype_in != NC_INT64 || ndims_in != 1 || */
/* natts_in != 0) ERR; */
if (nc_close(ncid)) ERR;
/* /\* Make sure we have the szip settings we expect. *\/ */
/* if (nc_inq_var_szip(ncid, small_varid, &options_mask_in, &bits_per_pixel_in)) ERR; */
/* if (options_mask_in != 0 || bits_per_pixel_in !=0) ERR; */
/* if (nc_inq_var_szip(ncid, medium_varid, &options_mask_in, &bits_per_pixel_in)) ERR; */
/* if (!(options_mask_in & NC_SZIP_EC_OPTION_MASK) || bits_per_pixel_in != 32) ERR; */
/* if (nc_inq_var_szip(ncid, large_varid, &options_mask_in, &bits_per_pixel_in)) ERR; */
/* if (!(options_mask_in & NC_SZIP_NN_OPTION_MASK) || bits_per_pixel_in != 16) ERR; */
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != 3 || ndims != 3 || ngatts != 0 || unlimdimid != -1) ERR;
if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims_in, &dimids_in, &natts_in)) ERR;
if (strcmp(var_name_in, V_SMALL) || xtype_in != NC_INT64 || ndims_in != 1 ||
natts_in != 0) ERR;
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
/* #endif */
/* The following code should work, but doesn't. See issue 972 in github. */
/* Make sure we have the szip settings we expect. */
/* if (nc_inq_var_szip(ncid, small_varid, &options_mask_in, &bits_per_pixel_in)) ERR; */
/* if (options_mask_in != 0 || bits_per_pixel_in !=0) ERR; */
/* if (nc_inq_var_szip(ncid, medium_varid, &options_mask_in, &bits_per_pixel_in)) ERR; */
/* if (!(options_mask_in & NC_SZIP_EC_OPTION_MASK) || bits_per_pixel_in != 32) ERR; */
/* if (nc_inq_var_szip(ncid, large_varid, &options_mask_in, &bits_per_pixel_in)) ERR; */
/* if (!(options_mask_in & NC_SZIP_NN_OPTION_MASK) || bits_per_pixel_in != 16) ERR; */
/* Read data. */
if (nc_get_var_longlong(ncid, small_varid, small_data_in)) ERR;
if (nc_get_var_longlong(ncid, medium_varid, medium_data_in)) ERR;
if (nc_get_var_longlong(ncid, large_varid, large_data_in)) ERR;
/* Check data. */
for (i = 0; i < D_SMALL_LEN1; i++)
if (small_data[i] != small_data_in[i]) ERR;
for (i = 0; i < D_MEDIUM_LEN1; i++)
if (medium_data[i] != medium_data_in[i]) ERR;
for (i = 0; i < D_LARGE_LEN1; i++)
if (large_data[i] != large_data_in[i]) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
#endif /* USE_SZIP */
FINAL_RESULTS;
}

View File

@ -105,5 +105,44 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
#define DIM_NAME "Distance_from_Mayo"
#define VAR_NAME_2 "Rocky_Road_to_Dublin"
#define NDIMS1 1
#define NUM_RECORDS 3
printf("**** testing extending var along unlimited dim with no coord var...");
{
int varid, ncid, dimid;
int ndims, nvars, natts, unlimdimid;
size_t dim_len_in, index;
int data = TEST_VAL_42;
/* Create the test file with one var, one unlimited dim. */
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME, NC_UNLIMITED, &dimid)) ERR;
if (nc_def_var(ncid, VAR_NAME_2, NC_INT, NDIMS1, &dimid, &varid)) ERR;
/* Write some records. */
for (index = 0; index < NUM_RECORDS; index++)
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
if (nc_close(ncid)) ERR;
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
if (ndims != 1 || nvars != 1 || natts != 0 || unlimdimid != 0) ERR;
if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR;
if (dim_len_in != NUM_RECORDS) ERR;
/* Now add more records. */
for (index = 3; index < NUM_RECORDS * 2; index++)
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR;
if (dim_len_in != NUM_RECORDS * 2) ERR;
/* Close the file. */
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}

View File

@ -1,12 +1,12 @@
/*
Create a netcdf-4 file with
a large variable for the purpose
of doing performance test on the
new NC4_get/put_vars functions.
Create a netcdf-4 file with
a large variable for the purpose
of doing performance test on the
new NC4_get/put_vars functions.
WARNING: do not attempt to run this
under windows because of the use
of gettimeofday().
WARNING: do not attempt to run this
under windows because of the use
of gettimeofday().
*/
@ -15,135 +15,140 @@ of gettimeofday().
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <assert.h>
#include "netcdf.h"
#include "nc4dispatch.h"
#include "err_macros.h"
#define FILE "bigvars.nc"
#define FILE "tst_varsperf_bigvars.nc"
#define VAR "bigvar"
#define NDIMS 2
#define DIM0 "d0"
#define DIM1 "d1"
#define DIMSIZE0 1024
#define DIMSIZE1 1024
#define DIMSIZE0 512
#define DIMSIZE1 512
#define TOTALSIZE (DIMSIZE0*DIMSIZE1)
#define CHECK(expr) assert((expr) == NC_NOERR)
static int data[TOTALSIZE];
static int read[TOTALSIZE];
extern void nc4_set_default_vars(int);
void
int
buildfile(void)
{
int ncid, varid;
int dimids[NDIMS];
int* p;
int index;
int ncid, varid;
int dimids[NDIMS];
int* p;
int index;
CHECK(nc_create(FILE, NC_NETCDF4, &ncid));
if(nc_create(FILE, NC_NETCDF4, &ncid)) ERR;
CHECK(nc_def_dim(ncid,DIM0,(size_t)DIMSIZE0,&dimids[0]));
CHECK(nc_def_dim(ncid,DIM1,(size_t)DIMSIZE1,&dimids[1]));
CHECK(nc_def_var(ncid,VAR,NC_INT,NDIMS,dimids,&varid));
if(nc_def_dim(ncid,DIM0,(size_t)DIMSIZE0,&dimids[0])) ERR;
if(nc_def_dim(ncid,DIM1,(size_t)DIMSIZE1,&dimids[1])) ERR;
if(nc_def_var(ncid,VAR,NC_INT,NDIMS,dimids,&varid)) ERR;
CHECK(nc_enddef(ncid));
if(nc_enddef(ncid)) ERR;
for(p=data,index=0;index<TOTALSIZE;index++)
*p++ = index;
for(p=data,index=0;index<TOTALSIZE;index++)
*p++ = index;
CHECK(nc_put_var_int(ncid,varid,data));
if(nc_put_var_int(ncid,varid,data)) ERR;
CHECK(nc_close(ncid));
if(nc_close(ncid)) ERR;
return 0;
}
long long
readfile(void)
readfile(int default_vars)
{
int ncid, varid;
int ndims, i;
int dimids[NDIMS];
size_t dimsizes[NDIMS];
int vardims[NDIMS];
size_t start[NDIMS];
size_t count[NDIMS];
ptrdiff_t stride[NDIMS];
struct timeval starttime, endtime;
long long delta;
long long startt, endt;
int ncid, varid;
int ndims, i;
int dimids[NDIMS];
size_t dimsizes[NDIMS];
int vardims[NDIMS];
size_t start[NDIMS];
size_t count[NDIMS];
ptrdiff_t stride[NDIMS];
struct timeval starttime, endtime;
long long delta;
long long startt, endt;
memset(&starttime,0,sizeof(starttime));
memset(&endtime,0,sizeof(endtime));
memset(&starttime,0,sizeof(starttime));
memset(&endtime,0,sizeof(endtime));
/* re-open to read */
CHECK(nc_open(FILE, NC_NETCDF4, &ncid));
/* re-open to read */
if(nc_open(FILE, NC_NETCDF4, &ncid)) ERR;
CHECK(nc_inq_dimid(ncid,DIM0,&dimids[0]));
CHECK(nc_inq_dimid(ncid,DIM1,&dimids[1]));
CHECK(nc_inq_dim(ncid,dimids[0],NULL,&dimsizes[0]));
CHECK(nc_inq_dim(ncid,dimids[1],NULL,&dimsizes[1]));
assert(dimsizes[0] == DIMSIZE0);
assert(dimsizes[1] == DIMSIZE1);
if(nc_inq_dimid(ncid,DIM0,&dimids[0])) ERR;
if(nc_inq_dimid(ncid,DIM1,&dimids[1])) ERR;
if(nc_inq_dim(ncid,dimids[0],NULL,&dimsizes[0])) ERR;
if(nc_inq_dim(ncid,dimids[1],NULL,&dimsizes[1])) ERR;
if(dimsizes[0] != DIMSIZE0) ERR;
if(dimsizes[1] != DIMSIZE1) ERR;
CHECK(nc_inq_varid(ncid,VAR,&varid));
CHECK(nc_inq_varndims(ncid,varid,&ndims));
assert(ndims == NDIMS);
CHECK(nc_inq_vardimid(ncid,varid,vardims));
for(i=0;i<NDIMS;i++)
assert(vardims[i] == dimids[i]);
if(nc_inq_varid(ncid,VAR,&varid)) ERR;
if(nc_inq_varndims(ncid,varid,&ndims)) ERR;
if(ndims != NDIMS) ERR;
if(nc_inq_vardimid(ncid,varid,vardims)) ERR;
for(i=0;i<NDIMS;i++)
if (vardims[i] != dimids[i]) ERR;
/* Do the timed read */
for(i=0;i<NDIMS;i++) {
start[i] = 0;
count[i] = dimsizes[i]/2;
stride[i] = 2;
}
/* Do the timed read */
for(i=0;i<NDIMS;i++) {
start[i] = 0;
count[i] = dimsizes[i]/2;
stride[i] = 2;
}
memset(read,0,sizeof(read));
gettimeofday(&starttime,NULL);
CHECK(nc_get_vars(ncid,varid,start,count,stride,read));
gettimeofday(&endtime,NULL);
memset(read,0,sizeof(read));
gettimeofday(&starttime,NULL);
CHECK(nc_close(ncid));
if(default_vars) {
if(NCDEFAULT_get_vars(ncid,varid,start,count,stride,read,NC_INT)) ERR;
} else {
if(NC4_get_vars(ncid,varid,start,count,stride,read,NC_INT)) ERR;
}
gettimeofday(&endtime,NULL);
/* Verify read -- Note: NDIMS dependent */
{
int d0, d1;
i = 0;
for(d0=0;d0<DIMSIZE0;d0+=stride[0]) {
for(d1=0;d1<DIMSIZE1;d1+=stride[1]) {
size_t dataindex = (d0 * DIMSIZE0) + d1;
size_t readindex = i;
assert(data[dataindex] == read[readindex]);
i++;
}
}
}
if(nc_close(ncid)) ERR;
/* Compute the time delta */
startt = (1000000*starttime.tv_sec) + starttime.tv_usec;
endt = (1000000*endtime.tv_sec) + endtime.tv_usec;
delta = endt - startt;
return delta;
/* Verify read -- Note: NDIMS dependent */
{
int d0, d1;
i = 0;
for(d0=0;d0<DIMSIZE0;d0+=stride[0]) {
for(d1=0;d1<DIMSIZE1;d1+=stride[1]) {
size_t dataindex = (d0 * DIMSIZE0) + d1;
size_t readindex = i;
if (data[dataindex] != read[readindex])
return -1;
i++;
}
}
}
/* Compute the time delta */
startt = (1000000*starttime.tv_sec) + starttime.tv_usec;
endt = (1000000*endtime.tv_sec) + endtime.tv_usec;
delta = endt - startt;
return delta;
}
int
main(int argc, char **argv)
{
long long defaultdelta, nc4delta, factor;
long long defaultdelta, nc4delta, factor;
buildfile();
nc4_set_default_vars(1);
defaultdelta = readfile();
nc4_set_default_vars(0);
nc4delta = readfile();
printf("testing speed of vars improvements...\n");
if (buildfile()) ERR;
if ((defaultdelta = readfile(1)) == -1)
return 1;
if ((nc4delta = readfile(0)) == -1)
return 1;
/* Print results to the millisec */
factor = defaultdelta / nc4delta;
printf("NCDEFAULT time=%lld NC4 time=%lld Speedup=%lld\n",
defaultdelta, nc4delta, factor);
return 0;
/* Print results to the millisec */
factor = defaultdelta / nc4delta;
printf("NCDEFAULT time=%lld NC4 time=%lld Speedup=%lld\n",
defaultdelta, nc4delta, factor);
SUMMARIZE_ERR;
FINAL_RESULTS;
}