Commit d0d13cdd authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added cdiSortParam.

parent 14440b7b
......@@ -67,6 +67,7 @@ int cdiGribApiDebug = 0;
int cdiDefaultLeveltype = -1;
int cdiDataUnreduced = 0;
int cdiSortName = 0;
int cdiSortParam = 0;
int cdiHaveMissval = 0;
......@@ -297,6 +298,9 @@ void cdiInitialize(void)
value = cdiGetenvInt("CDI_SORTNAME");
if ( value >= 0 ) cdiSortName = (int) value;
value = cdiGetenvInt("CDI_SORTPARAM");
if ( value >= 0 ) cdiSortParam = (int) value;
value = cdiGetenvInt("CDI_HAVE_MISSVAL");
if ( value >= 0 ) cdiHaveMissval = (int) value;
......@@ -420,6 +424,7 @@ void cdiDefGlobal(const char *string, int val)
if ( strcmp(string, "REGULARGRID") == 0 ) cdiDataUnreduced = val;
else if ( strcmp(string, "GRIBAPI_DEBUG") == 0 ) cdiGribApiDebug = val;
else if ( strcmp(string, "SORTNAME") == 0 ) cdiSortName = val;
else if ( strcmp(string, "SORTPARAM") == 0 ) cdiSortParam = val;
else if ( strcmp(string, "HAVE_MISSVAL") == 0 ) cdiHaveMissval = val;
else if ( strcmp(string, "NC_CHUNKSIZEHINT") == 0 ) cdiNcChunksizehint = val;
else if ( strcmp(string, "CMOR_MODE") == 0 ) CDI_cmor_mode = val;
......
......@@ -254,10 +254,11 @@ typedef struct {
int globalatts;
int localatts;
int unreduced;
int sortname;
int have_missval;
int comptype; // compression type
int complevel; // compression level
bool sortname;
bool sortparam;
#if defined (GRIBCONTAINER2D)
void **gribContainers;
#else
......@@ -317,6 +318,7 @@ extern int cdiChunkType;
extern int cdiSplitLtype105;
extern int cdiDataUnreduced;
extern int cdiSortName;
extern int cdiSortParam;
extern int cdiHaveMissval;
extern int cdiIgnoreAttCoordinates;
extern int cdiIgnoreValidRange;
......
......@@ -872,7 +872,8 @@ void streamDefaultValue ( stream_t * streamptr )
streamptr->globalatts = 0;
streamptr->localatts = 0;
streamptr->unreduced = cdiDataUnreduced;
streamptr->sortname = cdiSortName;
streamptr->sortname = cdiSortName > 0;
streamptr->sortparam = cdiSortParam > 0;
streamptr->have_missval = cdiHaveMissval;
streamptr->comptype = CDI_COMPRESS_NONE;
streamptr->complevel = 0;
......
......@@ -2894,6 +2894,7 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
}
}
struct varinfo
{
int ncvarid;
......
......@@ -534,20 +534,16 @@ int cmpLevelTableInv(const void* s1, const void* s2)
}
typedef struct
struct paraminfo
{
int varid;
int param;
int ltype;
}
param_t;
int varid, param, ltype;
};
static
int cmpparam(const void* s1, const void* s2)
{
const param_t *x = (const param_t*) s1;
const param_t *y = (const param_t*) s2;
const struct paraminfo *x = (const struct paraminfo*) s1;
const struct paraminfo *y = (const struct paraminfo*) s2;
int cmp = (( x->param > y->param ) - ( x->param < y->param )) * 2
+ ( x->ltype > y->ltype ) - ( x->ltype < y->ltype );
......@@ -564,9 +560,9 @@ void cdi_generate_vars(stream_t *streamptr)
int *varids = (int *) Malloc(nvars*sizeof(int));
for ( unsigned varID = 0; varID < nvars; varID++ ) varids[varID] = (int)varID;
if ( streamptr->sortname )
if ( streamptr->sortparam )
{
param_t *varInfo = (param_t *) Malloc((size_t)nvars * sizeof (param_t));
struct paraminfo *varInfo = (struct paraminfo *) Malloc((size_t)nvars * sizeof(struct paraminfo));
for ( unsigned varID = 0; varID < nvars; varID++ )
{
......@@ -574,7 +570,7 @@ void cdi_generate_vars(stream_t *streamptr)
varInfo[varID].param = vartable[varID].param;
varInfo[varID].ltype = vartable[varID].ltype1;
}
qsort(varInfo, (size_t)nvars, sizeof(param_t), cmpparam);
qsort(varInfo, (size_t)nvars, sizeof(struct paraminfo), cmpparam);
for ( unsigned varID = 0; varID < nvars; varID++ )
{
varids[varID] = varInfo[varID].varid;
......
Markdown is supported
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