Commit 9789e2e8 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge branch 'develop' of git.mpimet.mpg.de:libcdi into develop

parents dfd5eddf 0879f664
......@@ -2,6 +2,14 @@
* Version 1.9.3 released
2018-01-16 Uwe Schulzweida
* Skip unavailable coordinate variables (bug fix)
2018-01-13 Uwe Schulzweida
* streamFilesuffix(): refactoring (bug fix)
2018-01-09 Uwe Schulzweida
* GRIBAPI: Added support for variables with same name and different gridsize.
......
......@@ -303,17 +303,27 @@ int streamInqByteorder(int streamID)
const char *streamFilesuffix(int filetype)
{
// static char *fileSuffix[] = {"", ".grb", ".g2", ".nc", ".nc", ".nc4", ".nc4", ".srv", ".ext", ".ieg"};
/* note: the 2nd dimenstion of the fileSuffix array must be equal to or
* larger than the length of the longest suffix (dot and \0 terminator
* included) */
static const char fileSuffix[][5] = {"", ".grb", ".grb", ".nc", ".nc", ".nc", ".nc", ".srv", ".ext", ".ieg"};
int size = (int)(sizeof(fileSuffix)/sizeof(fileSuffix[0]));
if ( filetype > 0 && filetype < size )
return fileSuffix[filetype];
else
return fileSuffix[0];
static const char *noSuffix = "";
static const char *ncSuffix = ".nc";
static const char *grbSuffix = ".grb";
static const char *srvSuffix = ".srv";
static const char *extSuffix = ".ext";
static const char *iegSuffix = ".ieg";
switch (filetype)
{
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
case CDI_FILETYPE_NC5: return ncSuffix;
case CDI_FILETYPE_GRB:
case CDI_FILETYPE_GRB2: return grbSuffix;
case CDI_FILETYPE_SRV: return srvSuffix;
case CDI_FILETYPE_EXT: return extSuffix;
case CDI_FILETYPE_IEG: return iegSuffix;
default: return noSuffix;
}
}
......
......@@ -1343,6 +1343,8 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
}
else
{
if ( !cdiIgnoreAttCoordinates ) ncvars[ncvarid].ncoordvars++;
int k;
for ( k = 0; k < nchecked_vars; ++k )
if ( strcmp(checked_vars[k], varname) == 0 ) break;
......@@ -3874,13 +3876,16 @@ int cdfInqContents(stream_t *streamptr)
int ncoordvars = ncvar->ncoordvars;
for ( int i = 0; i < ncoordvars; i++ )
{
if ( ncvars[ncvar->coordvarids[i]].islon ||
ncvars[ncvar->coordvarids[i]].isx ) ncvar->xvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].islat ||
ncvars[ncvar->coordvarids[i]].isy ) ncvar->yvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].islev ) ncvar->zvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].isc ) ncvar->cvarids[i] = ncvar->coordvarids[i];
}
if ( ncvar->coordvarids[i] != CDI_UNDEFID )
{
if ( ncvars[ncvar->coordvarids[i]].islon ||
ncvars[ncvar->coordvarids[i]].isx ) ncvar->xvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].islat ||
ncvars[ncvar->coordvarids[i]].isy ) ncvar->yvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].islev ) ncvar->zvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].isc ) ncvar->cvarids[i] = ncvar->coordvarids[i];
}
}
}
}
......
......@@ -680,6 +680,7 @@ compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, int t
size_t gridsize, char *name, var_tile_t tiles_data)
{
compvar2_t compVar;
memset(&compVar, 0, sizeof(compvar2_t));
size_t maxlen = sizeof(compVar.name);
size_t len = strlen(name);
if ( len > maxlen ) len = maxlen;
......@@ -690,7 +691,7 @@ compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, int t
compVar.ltype = leveltype;
compVar.tsteptype = tsteptype;
compVar.gridsize = gridsize;
memset(compVar.name, 0, maxlen);
//memset(compVar.name, 0, maxlen);
memcpy(compVar.name, name, len);
compVar.tiles = tiles_data;
......@@ -701,6 +702,7 @@ static
int gribapiVarCompare(compvar2_t compVar, record_t record, int flag)
{
compvar2_t compVar0;
memset(&compVar0, 0, sizeof(compvar2_t));
compVar0.param = record.param;
compVar0.level1 = record.ilevel;
compVar0.level2 = record.ilevel2;
......
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