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

Replaced vlistDefVarLongname()/vlistInqVarLongname() by...

Replaced vlistDefVarLongname()/vlistInqVarLongname() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_LONGNAME.
parent 212256a1
2020-06-10 Uwe Schulzweida
* Replaced vlistDefVarName()/vlistInqVarName() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_NAME
* Replaced vlistDefVarLongname()/vlistInqVarLongname() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_LONGNAME
2020-05-15 Uwe Schulzweida
......
......@@ -3220,7 +3220,7 @@ void cdf_define_institut_and_model_id(int vlistID, int varID)
if ( name[0] )
{
cdiDeleteKey(vlistID, varID, CDI_KEY_NAME);
vlistDestroyVarLongname(vlistID, varID);
cdiDeleteKey(vlistID, varID, CDI_KEY_LONGNAME);
vlistDestroyVarUnits(vlistID, varID);
if ( varTableID != CDI_UNDEFID )
......
......@@ -229,8 +229,6 @@ void vlist_delete(vlist_t *vlistptr)
for ( int varID = 0; varID < nvars; varID++ )
{
if ( vars[varID].levinfo ) Free(vars[varID].levinfo);
//if ( vars[varID].name ) Free(vars[varID].name);
if ( vars[varID].longname ) Free(vars[varID].longname);
if ( vars[varID].stdname ) Free(vars[varID].stdname);
if ( vars[varID].units ) Free(vars[varID].units);
......@@ -293,8 +291,6 @@ void cdiVlistDestroy_(int vlistID)
static
void var_copy_entries(var_t *var2, var_t *var1)
{
//if ( var1->name ) var2->name = strdupx(var1->name);
if ( var1->longname ) var2->longname = strdupx(var1->longname);
if ( var1->stdname ) var2->stdname = strdupx(var1->stdname);
if ( var1->units ) var2->units = strdupx(var1->units);
......@@ -1113,8 +1109,7 @@ void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
if ( nvars > 0 )
{
fprintf(fp, " varID param gridID zaxisID stypeID tsteptype flag iorank"
" name longname units\n");
fprintf(fp, " varID param gridID zaxisID stypeID tsteptype flag iorank name longname units\n");
for ( int varID = 0; varID < nvars; varID++ )
{
int param = vlistptr->vars[varID].param;
......@@ -1122,10 +1117,11 @@ void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
int zaxisID = vlistptr->vars[varID].zaxisID;
int subtypeID = vlistptr->vars[varID].subtypeID;
int tsteptype = vlistptr->vars[varID].tsteptype;
char name[CDI_MAX_NAME];
char name[CDI_MAX_NAME], longname[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length);
const char *longname = vlistptr->vars[varID].longname;
length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_LONGNAME, longname, &length);
const char *units = vlistptr->vars[varID].units;
int flag = vlistptr->vars[varID].flag;
int iorank = vlistptr->vars[varID].iorank;
......@@ -1134,7 +1130,7 @@ void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
cdiParamToString(param, paramstr, sizeof(paramstr));
fprintf(fp, "%6d %-8s %6d %6d %6d %6d %5d %6d %-8s %s [%s]\n",
varID, paramstr, gridID, zaxisID, subtypeID, tsteptype, flag, iorank,
name, longname?longname:"", units?units:"");
name, longname, units?units:"");
}
fputs("\n"
......
......@@ -66,7 +66,6 @@ typedef struct
int xyz;
bool missvalused; // true if missval is defined
bool lvalidrange;
char *longname;
char *stdname;
char *units;
char *extra;
......@@ -121,7 +120,6 @@ vlist_t *vlist_to_pointer(int vlistID);
void cdiVlistMakeInternal(int vlistID);
void cdiVlistMakeImmutable(int vlistID);
void vlistCheckVarID(const char *caller, int vlistID, int varID);
void vlistDestroyVarLongname(int vlistID, int varID);
void vlistDestroyVarStdname(int vlistID, int varID);
void vlistDestroyVarUnits(int vlistID, int varID);
void cdiVlistDestroy_(int vlistID);
......
......@@ -35,7 +35,6 @@ void vlistvarInitEntry(int vlistID, int varID)
vlistptr->vars[varID].missval = CDI_default_missval;
vlistptr->vars[varID].addoffset = 0.0;
vlistptr->vars[varID].scalefactor = 1.0;
vlistptr->vars[varID].longname = NULL;
vlistptr->vars[varID].stdname = NULL;
vlistptr->vars[varID].units = NULL;
vlistptr->vars[varID].extra = NULL;
......@@ -529,14 +528,15 @@ otherwise the result is an empty string.
*/
void vlistInqVarLongname(int vlistID, int varID, char *longname)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, longname, &length);
if (!longname[0])
{
vlistCheckVarID(__func__, vlistID, varID);
longname[0] = '\0';
vlist_t *vlistptr = vlist_to_pointer(vlistID);
if ( vlistptr->vars[varID].longname == NULL )
{
int param = vlistptr->vars[varID].param;
int pdis, pcat, pnum;
cdiDecodeParam(param, &pnum, &pcat, &pdis);
......@@ -547,12 +547,6 @@ void vlistInqVarLongname(int vlistID, int varID, char *longname)
tableInqEntry(tableID, code, -1, NULL, longname, NULL);
}
}
else
{
// strcpy(longname, vlistptr->vars[varID].longname);
strncpy(longname, vlistptr->vars[varID].longname, CDI_MAX_NAME);
longname[CDI_MAX_NAME-1] = 0;
}
return;
}
......@@ -852,28 +846,7 @@ The function @func{vlistDefVarLongname} defines the long name of a variable.
*/
void vlistDefVarLongname(int vlistID, int varID, const char *longname)
{
/*
if (longname)
{
(void)cdiDefKeyString(vlistID, varID, CDI_KEY_LONGNAME, longname);
reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
}
*/
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlistCheckVarID(__func__, vlistID, varID);
if ( longname )
{
if ( vlistptr->vars[varID].longname )
{
Free(vlistptr->vars[varID].longname);
vlistptr->vars[varID].longname = 0;
}
vlistptr->vars[varID].longname = strdupx(longname);
reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
}
if (longname) (void)cdiDefKeyString(vlistID, varID, CDI_KEY_LONGNAME, longname);
}
/*
......@@ -1208,18 +1181,6 @@ int vlistInqVarTimave(int vlistID, int varID)
}
void vlistDestroyVarLongname(int vlistID, int varID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
if ( vlistptr->vars[varID].longname )
{
Free(vlistptr->vars[varID].longname);
vlistptr->vars[varID].longname = NULL;
reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
}
}
void vlistDestroyVarStdname(int vlistID, int varID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
......@@ -1630,7 +1591,7 @@ int vlistVarCompare(vlist_t *a, int varIDA, vlist_t *b, int varIDB)
| FCMP(chunktype) | FCMP(xyz) | FCMP2(gridID) | FCMP2(zaxisID)
| FCMP2(instID) | FCMP2(modelID) | FCMP2(tableID) | FCMP(missvalused)
| FCMPFLT(missval) | FCMPFLT(addoffset) | FCMPFLT(scalefactor)
| FCMPSTR(longname) | FCMPSTR(stdname) | FCMPSTR(units) | FCMPSTR(extra)
| FCMPSTR(stdname) | FCMPSTR(units) | FCMPSTR(extra)
| FCMP(comptype) | FCMP(complevel) | FCMP(lvalidrange)
| FCMPFLT(validrange[0]) | FCMPFLT(validrange[1]);
#undef FCMP
......
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