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