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

grib param cleanup

parent 07bfe10e
...@@ -455,7 +455,6 @@ void vlistDefVarTimaccu(int vlistID, int varID, int timaccu); ...@@ -455,7 +455,6 @@ void vlistDefVarTimaccu(int vlistID, int varID, int timaccu);
int vlistInqVarTimaccu(int vlistID, int varID); int vlistInqVarTimaccu(int vlistID, int varID);
int vlistInqVarSize(int vlistID, int varID); int vlistInqVarSize(int vlistID, int varID);
int vlistInqVarID(int vlistID, int code);
void vlistDefIndex(int vlistID, int varID, int levID, int index); void vlistDefIndex(int vlistID, int varID, int levID, int index);
int vlistInqIndex(int vlistID, int varID, int levID); int vlistInqIndex(int vlistID, int varID, int levID);
......
...@@ -6093,7 +6093,8 @@ int cdfInqContents(int streamID) ...@@ -6093,7 +6093,8 @@ int cdfInqContents(int streamID)
vlistDefVarInstitut(vlistID, varID, instID); vlistDefVarInstitut(vlistID, varID, instID);
vlistDefVarModel(vlistID, varID, modelID); vlistDefVarModel(vlistID, varID, modelID);
vlistDefVarTable(vlistID, varID, ncvars[ncvarid].tableID); if ( ncvars[ncvarid].tableID != UNDEFID )
vlistDefVarTable(vlistID, varID, ncvars[ncvarid].tableID);
if ( ncvars[ncvarid].defmiss == TRUE ) vlistDefVarMissval(vlistID, varID, ncvars[ncvarid].missval); if ( ncvars[ncvarid].defmiss == TRUE ) vlistDefVarMissval(vlistID, varID, ncvars[ncvarid].missval);
......
...@@ -521,7 +521,7 @@ otherwise the result is an empty string. ...@@ -521,7 +521,7 @@ otherwise the result is an empty string.
void vlistInqVarName(int vlistID, int varID, char *name) void vlistInqVarName(int vlistID, int varID, char *name)
{ {
int tableID; int tableID;
int param, code; int param;
int pdis, pcat, pnum; int pdis, pcat, pnum;
vlist_t *vlistptr; vlist_t *vlistptr;
...@@ -533,10 +533,17 @@ void vlistInqVarName(int vlistID, int varID, char *name) ...@@ -533,10 +533,17 @@ void vlistInqVarName(int vlistID, int varID, char *name)
{ {
param = vlistptr->vars[varID].param; param = vlistptr->vars[varID].param;
cdiDecodeParam(param, &pnum, &pcat, &pdis); cdiDecodeParam(param, &pnum, &pcat, &pdis);
code = pnum; if ( pdis == 255 )
tableID = vlistptr->vars[varID].tableID; {
if ( tableInqParName(tableID, code, name) != 0 ) int code = pnum;
sprintf(name, "var%d", code); tableID = vlistptr->vars[varID].tableID;
if ( tableInqParName(tableID, code, name) != 0 )
sprintf(name, "var%d", code);
}
else
{
sprintf(name, "param%d.%d.%d", pnum, pcat, pdis);
}
} }
else else
strcpy(name, vlistptr->vars[varID].name); strcpy(name, vlistptr->vars[varID].name);
...@@ -566,7 +573,7 @@ otherwise the result is an empty string. ...@@ -566,7 +573,7 @@ otherwise the result is an empty string.
void vlistInqVarLongname(int vlistID, int varID, char *longname) void vlistInqVarLongname(int vlistID, int varID, char *longname)
{ {
int tableID; int tableID;
int param, code; int param;
int pdis, pcat, pnum; int pdis, pcat, pnum;
vlist_t *vlistptr; vlist_t *vlistptr;
...@@ -574,14 +581,19 @@ void vlistInqVarLongname(int vlistID, int varID, char *longname) ...@@ -574,14 +581,19 @@ void vlistInqVarLongname(int vlistID, int varID, char *longname)
vlistCheckVarID(__func__, vlistID, varID); vlistCheckVarID(__func__, vlistID, varID);
longname[0] = '\0';
if ( vlistptr->vars[varID].longname == NULL ) if ( vlistptr->vars[varID].longname == NULL )
{ {
param = vlistptr->vars[varID].param; param = vlistptr->vars[varID].param;
cdiDecodeParam(param, &pnum, &pcat, &pdis); cdiDecodeParam(param, &pnum, &pcat, &pdis);
code = pnum; if ( pdis == 255 )
tableID = vlistptr->vars[varID].tableID; {
if ( tableInqParLongname(tableID, code, longname) != 0 ) int code = pnum;
longname[0] = '\0'; tableID = vlistptr->vars[varID].tableID;
if ( tableInqParLongname(tableID, code, longname) != 0 )
longname[0] = '\0';
}
} }
else else
strcpy(longname, vlistptr->vars[varID].longname); strcpy(longname, vlistptr->vars[varID].longname);
...@@ -648,7 +660,7 @@ otherwise the result is an empty string. ...@@ -648,7 +660,7 @@ otherwise the result is an empty string.
void vlistInqVarUnits(int vlistID, int varID, char *units) void vlistInqVarUnits(int vlistID, int varID, char *units)
{ {
int tableID; int tableID;
int param, code; int param;
int pdis, pcat, pnum; int pdis, pcat, pnum;
vlist_t *vlistptr; vlist_t *vlistptr;
...@@ -656,14 +668,19 @@ void vlistInqVarUnits(int vlistID, int varID, char *units) ...@@ -656,14 +668,19 @@ void vlistInqVarUnits(int vlistID, int varID, char *units)
vlistCheckVarID(__func__, vlistID, varID); vlistCheckVarID(__func__, vlistID, varID);
units[0] = '\0';
if ( vlistptr->vars[varID].units == NULL ) if ( vlistptr->vars[varID].units == NULL )
{ {
param = vlistptr->vars[varID].param; param = vlistptr->vars[varID].param;
cdiDecodeParam(param, &pnum, &pcat, &pdis); cdiDecodeParam(param, &pnum, &pcat, &pdis);
code = pnum; if ( pdis == 255 )
tableID = vlistptr->vars[varID].tableID; {
if ( tableInqParUnits(tableID, code, units) != 0 ) int code = pnum;
units[0] = '\0'; tableID = vlistptr->vars[varID].tableID;
if ( tableInqParUnits(tableID, code, units) != 0 )
units[0] = '\0';
}
} }
else else
strcpy(units, vlistptr->vars[varID].units); strcpy(units, vlistptr->vars[varID].units);
...@@ -671,7 +688,7 @@ void vlistInqVarUnits(int vlistID, int varID, char *units) ...@@ -671,7 +688,7 @@ void vlistInqVarUnits(int vlistID, int varID, char *units)
return; return;
} }
/* not used
int vlistInqVarID(int vlistID, int code) int vlistInqVarID(int vlistID, int code)
{ {
int varID; int varID;
...@@ -689,15 +706,12 @@ int vlistInqVarID(int vlistID, int code) ...@@ -689,15 +706,12 @@ int vlistInqVarID(int vlistID, int code)
if ( varID == vlistptr->nvars ) if ( varID == vlistptr->nvars )
{ {
/*
Warning("varID not found for param %d", param);
*/
varID = CDI_UNDEFID; varID = CDI_UNDEFID;
} }
return (varID); return (varID);
} }
*/
int vlistInqVarSize(int vlistID, int varID) int vlistInqVarSize(int vlistID, int varID)
{ {
......
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