mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
f6e25b695e
re: https://github.com/Unidata/netcdf-c/issues/2117 re: https://github.com/Unidata/netcdf-c/issues/2119 * Modify libsrc to allow byte-range reading of netcdf-3 files in private S3 buckets; this required using the aws sdk. Also add a test case. * The aws sdk can sometimes cause problems if the Awd::ShutdownAPI function is not called. So at optional atexit() support to ensure it is called. This is disabled for Windows. * Add documentation to nczarr.md on how to build and use the aws sdk under windows. Currently it builds, but testing fails. * Switch testing from stratus to the Unidata bucket on S3. * Improve support for the s3: url protocol. * Add a s3 specific utility code file: ds3util.c * Modify NC_infermodel to attempt to read the magic number of byte-ranged files in S3. ## Misc. * Move and rename the core S3 SDK wrapper code (libnczarr/zs3sdk.cpp) to libdispatch since it now used in libsrc as well as libnczarr. * Add calls to nc_finalize in the utilities in case atexit is disabled. * Add header only json parser to the distribution rather than as a built source.
94 lines
2.1 KiB
C
Executable File
94 lines
2.1 KiB
C
Executable File
/*
|
|
* Copyright 2018, University Corporation for Atmospheric Research
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
*/
|
|
|
|
#include "ut_includes.h"
|
|
|
|
void ut_chunk_print(int sort, ...);
|
|
|
|
/**
|
|
Test computation of applying a slice to a sequence of chunks
|
|
*/
|
|
|
|
int
|
|
main(int argc, char** argv)
|
|
{
|
|
int stat = NC_NOERR;
|
|
NCZSliceProjections slpv[NC_MAX_VAR_DIMS];
|
|
NCZOdometer* odom = NULL;
|
|
Vardef* var = NULL;
|
|
struct Common common;
|
|
|
|
/* Initialize */
|
|
memset(&slpv,0,sizeof(slpv));
|
|
|
|
if((stat = ut_init(argc, argv, &utoptions))) goto done;
|
|
|
|
var = nclistget(utoptions.vardefs,0);
|
|
|
|
/* Fill in parts of common */
|
|
fillcommon(&common,var);
|
|
|
|
/* Set the printer */
|
|
zutester.tests = UTEST_RANGE;
|
|
zutester.print = ut_chunk_print;
|
|
zutest = &zutester;
|
|
|
|
if((stat = NCZ_projectslices(var->dimsizes, var->chunksizes, utoptions.slices, &common, &odom)))
|
|
goto done;
|
|
|
|
#if 0
|
|
{
|
|
int i;
|
|
size64_t* mem = (size64_t*)printer.output;
|
|
for(i=0;i<printer.used;i++) {
|
|
printf("[%d] %llu\n",i,mem[i]);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
done:
|
|
ut_final();
|
|
if(stat)
|
|
nc_strerror(stat);
|
|
return (stat ? 1 : 0);
|
|
}
|
|
|
|
void
|
|
ut_chunk_print(int sort, ...)
|
|
{
|
|
int i;
|
|
va_list ap;
|
|
#if 0
|
|
struct Common* common = NULL;
|
|
#endif
|
|
size64_t rank; /* variable rank */
|
|
NCZSlice* slices = NULL; /* the complete set of slices |slices| == R*/
|
|
size64_t* chunksizes = NULL; /* the chunk length corresponding to the dimensions */
|
|
NCZChunkRange* ranges = NULL; /* computed chunk ranges */
|
|
|
|
va_start(ap,sort);
|
|
|
|
switch (sort) {
|
|
default: break; /* ignore */
|
|
case UTEST_RANGE: /* () */
|
|
rank = va_arg(ap,size64_t);
|
|
slices = va_arg(ap,NCZSlice*);
|
|
chunksizes = va_arg(ap,size64_t*);
|
|
ranges = va_arg(ap,NCZChunkRange*);
|
|
printf("Chunksizes: %s\n",nczprint_vector(rank,chunksizes));
|
|
printf("Slices: ");
|
|
for(i=0;i<rank;i++)
|
|
printf(" %s",nczprint_slicesx(rank,slices,1));
|
|
printf("\n");
|
|
printf("Ranges: ");
|
|
for(i=0;i<rank;i++)
|
|
printf(" %s",nczprint_chunkrange(ranges[i]));
|
|
printf("\n");
|
|
break;
|
|
}
|
|
va_end(ap);
|
|
}
|
|
|