Commit 460431c6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added cdiSetChunk

parent c264fddf
......@@ -2774,8 +2774,7 @@ int cdfDefVar(int streamID, int varID)
}
if ( CDI_Debug )
fprintf(stderr, "chunks %d %d %d %d\n",
(int)chunks[0], (int)chunks[1], (int)chunks[2], (int)chunks[3]);
fprintf(stderr, "chunks %d %d %d %d\n", (int)chunks[0], (int)chunks[1], (int)chunks[2], (int)chunks[3]);
tableID = vlistInqVarTable(vlistID, varID);
......@@ -4411,9 +4410,16 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
if ( format == NC_FORMAT_NETCDF4_CLASSIC || format == NC_FORMAT_NETCDF4 )
{
int shuffle, deflate, deflate_level;
size_t chunks[nvdims];
int storage_in;
nc_inq_var_deflate(ncid, ncvarid, &shuffle, &deflate, &deflate_level);
if ( deflate > 0 )
ncvars[ncvarid].deflate = 1;
if ( deflate > 0 ) ncvars[ncvarid].deflate = 1;
if ( nc_inq_var_chunking(ncid, ncvarid, &storage_in, chunks) == NC_NOERR )
{
//printf("storage %d\n", storage_in);
//for ( int i = 0; i < nvdims; ++i ) printf("chunk %d %d\n", i, chunks[i]);
}
}
#endif
......
......@@ -29,6 +29,9 @@ int cdiDefaultModelID = CDI_UNDEFID;
int cdiDefaultTableID = CDI_UNDEFID;
int cdiNcMissingValue = CDI_UNDEFID;
int cdiNcChunksizehint = CDI_UNDEFID;
int cdiChunkAlgo = CHUNK_DEFAULT;
int cdiChunkX = -1;
int cdiChunkY = -1;
int cdiSplitLtype105 = CDI_UNDEFID;
int cdiIgnoreAttCoordinates = FALSE;
......@@ -124,6 +127,33 @@ long cdiGetenvInt(char *envName)
return (envValue);
}
static
void cdiSetChunk(const char *chunkAlgo)
{
char *pch;
size_t len = strlen(chunkAlgo);
if ( strcmp("default", chunkAlgo) == 0 ) cdiChunkAlgo = CHUNK_DEFAULT;
else if ( strcmp("auto", chunkAlgo) == 0 ) cdiChunkAlgo = CHUNK_AUTO;
else if ( strcmp("lines", chunkAlgo) == 0 ) cdiChunkAlgo = CHUNK_LINES;
else if ( (pch = strstr(chunkAlgo,"x")) != 0 )
{
int ix, iy;
ix = atoi(chunkAlgo);
iy = atoi(pch+1);
if ( ix > 0 && iy > 0 )
{
cdiChunkX = ix;
cdiChunkY = iy;
cdiChunkAlgo = CHUNK_USER;
}
else
Warning("Invalid environment variable CDI_CHUNK_ALGO: %s", chunkAlgo);
}
else
Warning("Invalid environment variable CDI_CHUNK_ALGO: %s", chunkAlgo);
}
void cdiInitialize(void)
{
......@@ -140,9 +170,6 @@ void cdiInitialize(void)
gribSetConst(1); // 1: Don't pack constant fields on regular grids
#endif
value = cdiGetenvInt("CD_REGULARGRID");
if ( value >= 0 ) cdiDataUnreduced = (int) value;
value = cdiGetenvInt("CDI_REGULARGRID");
if ( value >= 0 ) cdiDataUnreduced = (int) value;
......@@ -152,15 +179,9 @@ void cdiInitialize(void)
value = cdiGetenvInt("CDI_HAVE_MISSVAL");
if ( value >= 0 ) cdiHaveMissval = (int) value;
value = cdiGetenvInt("CD_LEVELTYPE");
if ( value >= 0 ) cdiDefaultLeveltype = (int) value;
value = cdiGetenvInt("CDI_LEVELTYPE");
if ( value >= 0 ) cdiDefaultLeveltype = (int) value;
envString = getenv("CD_MISSVAL");
if ( envString ) cdiDefaultMissval = atof(envString);
envString = getenv("CDI_MISSVAL");
if ( envString ) cdiDefaultMissval = atof(envString);
......@@ -170,6 +191,9 @@ void cdiInitialize(void)
envString = getenv("NC_CHUNKSIZEHINT");
if ( envString ) cdiNcChunksizehint = atoi(envString);
envString = getenv("CDI_CHUNK_ALGO");
if ( envString ) cdiSetChunk(envString);
envString = getenv("SPLIT_LTYPE_105");
if ( envString ) cdiSplitLtype105 = atoi(envString);
......
......@@ -105,6 +105,9 @@ char *strdup(const char *s);
#define MEMTYPE_FLOAT 2
enum {CHUNK_DEFAULT, CHUNK_AUTO, CHUNK_LINES, CHUNK_USER};
typedef struct
{
void *buffer;
......@@ -263,6 +266,9 @@ extern int cdiDefaultTableID;
extern int cdiDefaultLeveltype;
extern int cdiNcMissingValue;
extern int cdiNcChunksizehint;
extern int cdiChunkAlgo;
extern int cdiChunkX;
extern int cdiChunkY;
extern int cdiSplitLtype105;
extern char *cdiPartabPath;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment