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

Replaced vlistDefVarStdname()/vlistInqVarStdname() by...

Replaced vlistDefVarStdname()/vlistInqVarStdname() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_STDNAME.
parent 6db4a4f1
......@@ -3,6 +3,7 @@
* Replaced vlistDefVarName()/vlistInqVarName() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_NAME
* Replaced vlistDefVarLongname()/vlistInqVarLongname() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_LONGNAME
* Replaced vlistDefVarUnits()/vlistInqVarUnits() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_UNITS
* Replaced vlistDefVarStdname()/vlistInqVarStdname() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_STDNAME
2020-05-15 Uwe Schulzweida
......
vlistDefVarName(vlistID, varID, name) -> cdiDefKeyString(vlistID, varID, CDI_KEY_NAME, name)
vlistInqVarName(vlistID, varID, name) -> cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length) // partly obsolete
vlistDefVarName(vlistID, varID, name) -> cdiDefKeyString(vlistID, varID, CDI_KEY_NAME, name)
vlistDefVarLongname(vlistID, varID, longname) -> cdiDefKeyString(vlistID, varID, CDI_KEY_LONGNAME, longname)
vlistDefVarUnits(vlistID, varID, units) -> cdiDefKeyString(vlistID, varID, CDI_KEY_UNITS, units)
vlistDefVarStdname(vlistID, varID, stdname) -> cdiDefKeyString(vlistID, varID, CDI_KEY_STDNAME, stdname)
vlistInqVarName(vlistID, varID, name) -> cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length)
vlistInqVarLongname(vlistID, varID, longname) -> cdiInqKeyString(vlistID, varID, CDI_KEY_LONGNAME, longname, &length)
vlistInqVarUnits(vlistID, varID, units) -> cdiInqKeyString(vlistID, varID, CDI_KEY_UNITS, units, &length)
vlistInqVarStdname(vlistID, varID, stdname) -> cdiInqKeyString(vlistID, varID, CDI_KEY_STDNAME, stdname, &length)
gridDefXname(gridID, xname) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_NAME, xname)
gridDefXlongname(gridID, xlongname) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_LONGNAME, xlongname)
......
......@@ -229,7 +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].stdname ) Free(vars[varID].stdname);
if ( vlistptr->vars[varID].opt_grib_kvpair )
{
......@@ -290,8 +289,6 @@ void cdiVlistDestroy_(int vlistID)
static
void var_copy_entries(var_t *var2, var_t *var1)
{
if ( var1->stdname ) var2->stdname = strdupx(var1->stdname);
var2->opt_grib_kvpair_size = 0;
var2->opt_grib_kvpair = NULL;
var2->opt_grib_nentries = 0;
......
......@@ -66,7 +66,6 @@ typedef struct
int xyz;
bool missvalused; // true if missval is defined
bool lvalidrange;
char *stdname;
char *extra;
double missval;
double scalefactor;
......@@ -119,7 +118,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 vlistDestroyVarStdname(int vlistID, int varID);
void cdiVlistDestroy_(int vlistID);
int vlistInqVarMissvalUsed(int vlistID, int varID);
int vlistHasTime(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].stdname = NULL;
vlistptr->vars[varID].extra = NULL;
vlistptr->vars[varID].levinfo = NULL;
vlistptr->vars[varID].comptype = CDI_COMPRESS_NONE;
......@@ -255,8 +254,6 @@ void vlistInqVar(int vlistID, int varID, int *gridID, int *zaxisID, int *timetyp
*gridID = vlistptr->vars[varID].gridID;
*zaxisID = vlistptr->vars[varID].zaxisID;
*timetype = vlistptr->vars[varID].timetype;
return;
}
/*
......@@ -445,8 +442,6 @@ void vlistInqVarName(int vlistID, int varID, char *name)
sprintf(name, "param%d.%d.%d", pnum, pcat, pdis);
}
}
return;
}
/*
......@@ -546,8 +541,6 @@ void vlistInqVarLongname(int vlistID, int varID, char *longname)
tableInqEntry(tableID, code, -1, NULL, longname, NULL);
}
}
return;
}
/*
......@@ -573,16 +566,8 @@ otherwise the result is an empty string.
*/
void vlistInqVarStdname(int vlistID, int varID, char *stdname)
{
vlistCheckVarID(__func__, vlistID, varID);
const vlist_t *vlistptr = vlist_to_pointer(vlistID);
if ( vlistptr->vars[varID].stdname == NULL )
stdname[0] = '\0';
else
strcpy(stdname, vlistptr->vars[varID].stdname);
return;
int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, stdname, &length);
}
/*
......@@ -627,8 +612,6 @@ void vlistInqVarUnits(int vlistID, int varID, char *units)
tableInqEntry(tableID, code, -1, NULL, NULL, units);
}
}
return;
}
// used in MPIOM !
......@@ -864,21 +847,7 @@ The function @func{vlistDefVarStdname} defines the standard name of a variable.
*/
void vlistDefVarStdname(int vlistID, int varID, const char *stdname)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlistCheckVarID(__func__, vlistID, varID);
if ( stdname )
{
if ( vlistptr->vars[varID].stdname )
{
Free(vlistptr->vars[varID].stdname);
vlistptr->vars[varID].stdname = 0;
}
vlistptr->vars[varID].stdname = strdupx(stdname);
reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
}
if (stdname) (void)cdiDefKeyString(vlistID, varID, CDI_KEY_STDNAME, stdname);
}
/*
......@@ -1014,8 +983,6 @@ void vlistInqVarExtra(int vlistID, int varID, char *extra)
sprintf(extra, "-");
else
strcpy(extra, vlistptr->vars[varID].extra);
return;
}
......@@ -1165,18 +1132,6 @@ int vlistInqVarTimave(int vlistID, int varID)
}
void vlistDestroyVarStdname(int vlistID, int varID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
if ( vlistptr->vars[varID].stdname )
{
Free(vlistptr->vars[varID].stdname);
vlistptr->vars[varID].stdname = NULL;
reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
}
}
int vlistInqVarMissvalUsed(int vlistID, int varID)
{
const vlist_t *vlistptr = vlist_to_pointer(vlistID);
......@@ -1563,7 +1518,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(stdname) | FCMPSTR(extra)
| FCMPSTR(extra)
| FCMP(comptype) | FCMP(complevel) | FCMP(lvalidrange)
| FCMPFLT(validrange[0]) | FCMPFLT(validrange[1]);
#undef FCMP
......
......@@ -11,7 +11,6 @@ enum {
VLISTVAR_PACK_INT_IDX_GRIDID,
VLISTVAR_PACK_INT_IDX_ZAXISID,
VLISTVAR_PACK_INT_IDX_TIMETYPE,
VLISTVAR_PACK_INT_IDX_STDNAMESZ,
VLISTVAR_PACK_INT_IDX_DATATYPE,
VLISTVAR_PACK_INT_IDX_PARAM,
VLISTVAR_PACK_INT_IDX_INSTID,
......@@ -36,8 +35,6 @@ int vlistVarGetPackSize(vlist_t *p, int varID, void *context)
var_t *var = p->vars + varID;
int varsize = serializeGetSize(vlistvarNint, CDI_DATATYPE_INT, context)
+ serializeGetSize(vlistvar_ndbls, CDI_DATATYPE_FLT64, context);
if (var->stdname)
varsize += serializeGetSize((int)strlen(var->stdname), CDI_DATATYPE_TXT, context);
if (var->extra)
varsize += serializeGetSize((int)strlen(var->extra), CDI_DATATYPE_TXT, context);
varsize += serializeGetSize(4 * zaxisInqSize(var->zaxisID), CDI_DATATYPE_INT, context);
......@@ -53,13 +50,12 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position, vo
{
double dtempbuf[vlistvar_ndbls];
var_t *var = p->vars + varID;
int tempbuf[vlistvarNint], stdnamesz, extralen;
int tempbuf[vlistvarNint], extralen;
tempbuf[VLISTVAR_PACK_INT_IDX_FLAG] = var->flag;
tempbuf[VLISTVAR_PACK_INT_IDX_GRIDID] = var->gridID;
tempbuf[VLISTVAR_PACK_INT_IDX_ZAXISID] = var->zaxisID;
tempbuf[VLISTVAR_PACK_INT_IDX_TIMETYPE] = var->timetype;
tempbuf[VLISTVAR_PACK_INT_IDX_STDNAMESZ] = stdnamesz = var->stdname?(int)strlen(var->stdname):0;
tempbuf[VLISTVAR_PACK_INT_IDX_DATATYPE] = var->datatype;
tempbuf[VLISTVAR_PACK_INT_IDX_PARAM] = var->param;
tempbuf[VLISTVAR_PACK_INT_IDX_INSTID] = var->instID;
......@@ -78,8 +74,6 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position, vo
dtempbuf[2] = var->addoffset;
serializePack(tempbuf, vlistvarNint, CDI_DATATYPE_INT, buf, size, position, context);
serializePack(dtempbuf, vlistvar_ndbls, CDI_DATATYPE_FLT64,buf, size, position, context);
if (stdnamesz)
serializePack(var->stdname, stdnamesz, CDI_DATATYPE_TXT, buf, size, position, context);
if (extralen)
serializePack(var->extra, extralen, CDI_DATATYPE_TXT, buf, size, position, context);
if (nlevs)
......@@ -124,15 +118,8 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
namespaceAdaptKey ( tempbuf[VLISTVAR_PACK_INT_IDX_GRIDID], originNamespace ),
namespaceAdaptKey ( tempbuf[VLISTVAR_PACK_INT_IDX_ZAXISID], originNamespace ),
tempbuf[VLISTVAR_PACK_INT_IDX_TIMETYPE]);
if (tempbuf[VLISTVAR_PACK_INT_IDX_STDNAMESZ] || tempbuf[VLISTVAR_PACK_INT_IDX_EXTRALEN])
varname = (char *)Malloc((size_t)imax(tempbuf[VLISTVAR_PACK_INT_IDX_STDNAMESZ], tempbuf[VLISTVAR_PACK_INT_IDX_EXTRALEN]) + 1);
if (tempbuf[VLISTVAR_PACK_INT_IDX_STDNAMESZ])
{
serializeUnpack(buf, size, position,
varname, tempbuf[VLISTVAR_PACK_INT_IDX_STDNAMESZ], CDI_DATATYPE_TXT, context);
varname[tempbuf[VLISTVAR_PACK_INT_IDX_STDNAMESZ]] = '\0';
vlistDefVarStdname(vlistID, newvar, varname);
}
if (tempbuf[VLISTVAR_PACK_INT_IDX_EXTRALEN])
varname = (char *)Malloc((size_t)tempbuf[VLISTVAR_PACK_INT_IDX_EXTRALEN] + 1);
if (tempbuf[VLISTVAR_PACK_INT_IDX_EXTRALEN])
{
serializeUnpack(buf, size, position,
......
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