Commit 46ec6def authored by Florian Prill's avatar Florian Prill
Browse files

[cdi-tiles] merged changes from trunk.

parents 202826e1 b573f034
2015-06-02 Uwe Schulzweida
* gribapiDefParam: check range of parameter number
2015-05-28 Uwe Schulzweida
* dmemory: added env. MEMORY_INFO
......
......@@ -1424,7 +1424,7 @@ void cgribexDefParam(int *isec1, int param)
static bool lwarn_pnum = true;
if ( pnum > 255 && lwarn_pnum )
{
Warning("Parameter number %d out of bounds (1-255), set to %d!", pnum, pnum%256);
Warning("Parameter number %d out of range (1-255), set to %d!", pnum, pnum%256);
lwarn_pnum = false;
pnum = pnum%256;
}
......
......@@ -1617,6 +1617,14 @@ void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *
{
if ( pnum < 0 ) pnum = -pnum;
static bool lwarn_pnum = true;
if ( pnum > 255 && lwarn_pnum )
{
Warning("Parameter number %d out of range (1-255), set to %d!", pnum, pnum%256);
lwarn_pnum = false;
pnum = pnum%256;
}
if ( editionNumber <= 1 )
{
static bool lwarn_pdis = true;
......@@ -1628,14 +1636,6 @@ void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *
lwarn_pdis = false;
}
static bool lwarn_pnum = true;
if ( pnum > 255 && lwarn_pnum )
{
Warning("Parameter number %d out of bounds (1-255), set to %d!", pnum, pnum%256);
lwarn_pnum = false;
pnum = pnum%256;
}
GRIB_CHECK(my_grib_set_long(gh, "table2Version", pcat), 0);
GRIB_CHECK(my_grib_set_long(gh, "indicatorOfParameter", pnum), 0);
}
......
......@@ -985,8 +985,8 @@ int vlistNtsteps(int vlistID)
return (int)vlistptr->ntsteps;
}
static void
vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
static
void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
{
char paramstr[32];
......@@ -1006,8 +1006,8 @@ vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
if ( nvars > 0 )
{
fprintf(fp, " varID param gridID zaxisID tsteptype flag "
" name longname iorank\n");
fprintf(fp, " varID param gridID zaxisID tsteptype flag iorank"
" name longname units\n");
for ( int varID = 0; varID < nvars; varID++ )
{
int param = vlistptr->vars[varID].param;
......@@ -1021,14 +1021,9 @@ vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
int iorank = vlistptr->vars[varID].iorank;
cdiParamToString(param, paramstr, sizeof(paramstr));
fprintf(fp, "%6d %-8s %6d %6d %6d %5d %-8s"
" %s %6d",
varID, paramstr, gridID, zaxisID, tsteptype, flag,
name ? name : "", longname ? longname : "",
iorank);
if ( units ) fprintf(fp, " [%s]", units);
fputs("\n", fp);
fprintf(fp, "%6d %-8s %6d %6d %6d %5d %6d %-8s %s [%s]\n",
varID, paramstr, gridID, zaxisID, tsteptype, flag, iorank,
name?name:"", longname?longname:"", units?units:"");
}
fputs("\n"
......
......@@ -423,7 +423,8 @@ int vlistInqVarCode(int vlistID, int varID)
int param = vlistptr->vars[varID].param;
int pdis, pcat, pnum;
cdiDecodeParam(param, &pnum, &pcat, &pdis);
int code = pdis == 255 ? pnum : -varID-1;
int code = pnum;
if ( pdis != 255 ) code = -varID-1; // GRIB2 Parameter
if ( code < 0 && vlistptr->vars[varID].tableID != -1 && vlistptr->vars[varID].name != NULL )
{
......
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