mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-27 08:49:16 +08:00
e7d5f24078
The primary change is to support the use of a zip file as a storage format. Simultaneously the .nz4 support is made obsolete Use of zip requires the libzip support library, so a number of changes to the build files (Makefile.am, CMakeLists.txt) are necessary to locate and incorporate libzip. The nczarr_tests tests are also changed to add zip testing. Other changes: * Make sure distcheck leaves no files around. * Add some functions to netcdf_aux to export some functions of libnetcdf. * Add a new error NC_EFOUND as the complement of NC_EEMPTY. * Add tracing support to nclog and use it in libnczarr. * Modify the zmap interface to support the writeonce semantics of zip. * Create a new s3util.c to support a variety of S3 auxilliary functions. * EXTERNL'ize a number of functions so they can be used in s3util. * Add support for the S3 ListObjects CommonPrefixes mechanism to improve search. * Add experimental support for running nczarr X s3 tests against the actual Amazon S3 cloud.
88 lines
1.7 KiB
C
88 lines
1.7 KiB
C
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "netcdf.h"
|
|
#include "nclist.h"
|
|
|
|
#include "zincludes.h"
|
|
|
|
#include "tst_utils.h"
|
|
|
|
#undef DEBUG
|
|
|
|
static void
|
|
nccheck(int ret, int lineno)
|
|
{
|
|
if(ret == NC_NOERR) return;
|
|
report(ret,lineno);
|
|
}
|
|
|
|
#define NCCHECK(err) nccheck(err,__LINE__)
|
|
|
|
int
|
|
main(int argc, char *argv[] )
|
|
{
|
|
int err, ncid, varid, dimid[1];
|
|
size_t dimlen[1];
|
|
float *fdat;
|
|
int *idat;
|
|
const char* filename = NULL;
|
|
const char* varname = "f";
|
|
const char* dimname = "x";
|
|
size_t i;
|
|
|
|
NCCHECK(getoptions(&argc,&argv));
|
|
filename = options->file;
|
|
|
|
NCCHECK(err = nc_open(filename,NC_NETCDF4,&ncid));
|
|
NCCHECK(err = nc_inq_varid(ncid, varname, &varid));
|
|
NCCHECK(err = nc_inq_dimid(ncid, dimname, dimid));
|
|
NCCHECK(err = nc_inq_dim(ncid, dimid[0], NULL, dimlen));
|
|
|
|
/* Make room for both double and floating dat */
|
|
fdat = (float *)calloc(1,sizeof(float) * dimlen[0]);
|
|
idat = (int *)calloc(1,sizeof(int) * dimlen[0]);
|
|
|
|
NCCHECK(err = nc_get_var_int(ncid, varid, idat));
|
|
NCCHECK(err = nc_get_var_float(ncid, varid, fdat));
|
|
|
|
#ifdef DEBUG
|
|
printf("int[0..%d]:",(int)dimlen[0]);
|
|
for(i=0; i<dimlen[0]; i++ ) printf(" %i", idat[i]);
|
|
printf("\n");
|
|
|
|
printf("float[0..%d]:",(int)dimlen[0]);
|
|
for(i=0; i<dimlen[0]; i++ ) printf(" %f", fdat[i]);
|
|
printf("\n");
|
|
#endif
|
|
|
|
/* Do the comparisons */
|
|
for(i=0; i<dimlen[0]; i++ ) {
|
|
if(fdat[i] != (float)(idat[i])) {
|
|
fprintf(stderr,"data mismatch [%d]: float=%f (float)int=%f int=%i\n",(int)i,fdat[i],(float)idat[i],idat[i]);
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
if(fdat) free(fdat);
|
|
if(idat) free(idat);
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|