Commit 6b282eae authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdi_generate_vars: removed support for sortname.

parent 2f5cf91e
......@@ -604,17 +604,8 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
record->gridsize = gribapiGetGridsize(gh);
record->tiles = tiles ? *tiles : dummy_tiles;
//FIXME: This may leave the variable name unterminated (which is the behavior that I found in the code).
// I don't know precisely how this field is used, so I did not change this behavior to avoid regressions,
// but I think that it would be better to at least add a line
//
// record->varname[sizeof(record->varname) - 1] = 0;`
//
// after the `strncpy()` call.
//
// I would consider using strdup() (that requires POSIX-2008 compliance, though), or a similar homebrew approach.
// I. e. kick the fixed size array and allocate enough space, whatever that may be.
strncpy(record->varname, varname, sizeof(record->varname));
strncpy(record->varname, varname, sizeof(record->varname)-1);
record->varname[sizeof(record->varname) - 1] = 0;
grid_t *grid = (grid_t *)Malloc(sizeof(*grid));
gribapiGetGrid(gh, grid);
......
......@@ -52,8 +52,7 @@ int recordNewEntry(stream_t *streamptr, int tsID)
}
else
{
while ( recordID < recordSize
&& records[recordID].used != CDI_UNDEFID )
while ( recordID < recordSize && records[recordID].used != CDI_UNDEFID )
++recordID;
}
/*
......@@ -67,8 +66,7 @@ int recordNewEntry(stream_t *streamptr, int tsID)
recordSize = INT_MAX;
else
Error("Cannot handle this many records!\n");
records = (record_t *) Realloc(records,
recordSize * sizeof (record_t));
records = (record_t *) Realloc(records, recordSize * sizeof (record_t));
for ( size_t i = recordID; i < recordSize; i++ )
records[i].used = CDI_UNDEFID;
......
......@@ -535,46 +535,6 @@ int cmpLevelTableInv(const void* s1, const void* s2)
}
struct paraminfo
{
int varid, param, ltype;
};
static
int cmp_param(const void* s1, const void* 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 );
return cmp;
}
struct varinfo
{
int varid;
const char *name;
};
/*
static
int cmp_varname(const void *s1, const void *s2)
{
const struct varinfo *x = (const struct varinfo *)s1,
*y = (const struct varinfo *)s2;
return strcmp(x->name, y->name);
}
*/
static
int cmp_varname(const void *s1, const void *s2)
{
const vartable_t *x = (const vartable_t *)s1,
*y = (const vartable_t *)s2;
return strcmp(x->name, y->name);
}
void varCopyKeys(int vlistID, int varID)
{
cdi_keys_t *keysp = &(vartable[varID].keys);
......@@ -603,6 +563,7 @@ void cdi_generate_vars(stream_t *streamptr)
int *varids = (int *) Malloc(varTableUsed*sizeof(int));
for ( size_t varID = 0; varID < varTableUsed; varID++ ) varids[varID] = (int)varID;
/*
if ( streamptr->sortname )
{
size_t varID;
......@@ -627,30 +588,8 @@ void cdi_generate_vars(stream_t *streamptr)
Free(varInfo);
}
}
/*
if ( streamptr->sortparam )
{
struct paraminfo *varInfo = (struct paraminfo *) Malloc((size_t)varTableUsed * sizeof(struct paraminfo));
for ( unsigned varID = 0; varID < varTableUsed; varID++ )
{
varInfo[varID].varid = varids[varID];
varInfo[varID].param = vartable[varID].param;
varInfo[varID].ltype = vartable[varID].ltype1;
}
qsort(varInfo, (size_t)varTableUsed, sizeof(struct paraminfo), cmp_param);
for ( unsigned varID = 0; varID < varTableUsed; varID++ )
{
varids[varID] = varInfo[varID].varid;
}
Free(varInfo);
}
if ( streamptr->sortname )
{
qsort(vartable, (size_t)varTableUsed, sizeof(vartable_t), cmp_varname);
}
*/
for ( size_t index = 0; index < varTableUsed; index++ )
{
int varid = varids[index];
......@@ -869,10 +808,8 @@ void cdi_generate_vars(stream_t *streamptr)
unsigned nsub = vartable[varid].nsubtypes >= 0 ? (unsigned)vartable[varid].nsubtypes : 0U;
for ( size_t isub = 0; isub < nsub; isub++ )
{
sleveltable_t *restrict streamRecordTable
= streamptr->vars[index].recordTable + isub;
leveltable_t *restrict vartableLevelTable
= vartable[varid].recordTable[isub].levelTable;
sleveltable_t *restrict streamRecordTable = streamptr->vars[index].recordTable + isub;
leveltable_t *restrict vartableLevelTable = vartable[varid].recordTable[isub].levelTable;
for ( unsigned levelID = 0; levelID < nlevels; levelID++ )
{
streamRecordTable->recordID[levelID] = vartableLevelTable[levelID].recID;
......
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