Commit f2cc6a7c authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add missing serialization of Extra variable attribute.

parent 7fdabac5
...@@ -2053,7 +2053,7 @@ int vlistVarCompare(vlist_t *a, int varIDA, vlist_t *b, int varIDB) ...@@ -2053,7 +2053,7 @@ int vlistVarCompare(vlist_t *a, int varIDA, vlist_t *b, int varIDB)
enum { enum {
vlistvar_nints = 20, vlistvar_nints = 21,
vlistvar_ndbls = 3, vlistvar_ndbls = 3,
}; };
...@@ -2070,6 +2070,8 @@ int vlistVarGetPackSize(vlist_t *p, int varID, void *context) ...@@ -2070,6 +2070,8 @@ int vlistVarGetPackSize(vlist_t *p, int varID, void *context)
varsize += serializeGetSize((int)strlen(var->stdname), DATATYPE_TXT, context); varsize += serializeGetSize((int)strlen(var->stdname), DATATYPE_TXT, context);
if (var->units) if (var->units)
varsize += serializeGetSize((int)strlen(var->units), DATATYPE_TXT, context); varsize += serializeGetSize((int)strlen(var->units), DATATYPE_TXT, context);
if (var->extra)
varsize += serializeGetSize((int)strlen(var->extra), DATATYPE_TXT, context);
varsize += serializeGetSize(4 * zaxisInqSize(var->zaxisID), varsize += serializeGetSize(4 * zaxisInqSize(var->zaxisID),
DATATYPE_INT, context); DATATYPE_INT, context);
varsize += vlistAttsGetSize(p, varID, context); varsize += vlistAttsGetSize(p, varID, context);
...@@ -2081,7 +2083,8 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position, ...@@ -2081,7 +2083,8 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
{ {
double dtempbuf[vlistvar_ndbls]; double dtempbuf[vlistvar_ndbls];
var_t *var = p->vars + varID; var_t *var = p->vars + varID;
int tempbuf[vlistvar_nints], namesz, longnamesz, stdnamesz, unitssz; int tempbuf[vlistvar_nints], namesz, longnamesz, stdnamesz, unitssz,
extralen;
tempbuf[0] = var->flag; tempbuf[0] = var->flag;
tempbuf[1] = var->gridID; tempbuf[1] = var->gridID;
...@@ -2104,6 +2107,7 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position, ...@@ -2104,6 +2107,7 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
int nlevs = var->levinfo ? zaxisInqSize(var->zaxisID) : 0; int nlevs = var->levinfo ? zaxisInqSize(var->zaxisID) : 0;
tempbuf[18] = nlevs; tempbuf[18] = nlevs;
tempbuf[19] = var->iorank; tempbuf[19] = var->iorank;
tempbuf[20] = extralen = var->extra?(int)strlen(var->extra):0;
dtempbuf[0] = var->missval; dtempbuf[0] = var->missval;
dtempbuf[1] = var->scalefactor; dtempbuf[1] = var->scalefactor;
dtempbuf[2] = var->addoffset; dtempbuf[2] = var->addoffset;
...@@ -2122,6 +2126,9 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position, ...@@ -2122,6 +2126,9 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
if (unitssz) if (unitssz)
serializePack(var->units, unitssz, DATATYPE_TXT, serializePack(var->units, unitssz, DATATYPE_TXT,
buf, size, position, context); buf, size, position, context);
if (extralen)
serializePack(var->extra, extralen, DATATYPE_TXT,
buf, size, position, context);
if (nlevs) if (nlevs)
{ {
int levbuf[nlevs][4]; int levbuf[nlevs][4];
...@@ -2164,11 +2171,12 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position, ...@@ -2164,11 +2171,12 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
int newvar = vlistDefVar ( vlistID, int newvar = vlistDefVar ( vlistID,
namespaceAdaptKey ( tempbuf[1], originNamespace ), namespaceAdaptKey ( tempbuf[1], originNamespace ),
namespaceAdaptKey ( tempbuf[2], originNamespace ), namespaceAdaptKey ( tempbuf[2], originNamespace ),
tempbuf[3]); tempbuf[3]);
if (tempbuf[4] || tempbuf[5] || tempbuf[6] || tempbuf[7]) if (tempbuf[4] || tempbuf[5] || tempbuf[6] || tempbuf[7] || tempbuf[20])
varname = (char *) Malloc((size_t)imax(imax(imax(tempbuf[4],tempbuf[5]), varname = (char *)Malloc((size_t)imax(imax(imax(imax(tempbuf[4],
tempbuf[6]), tempbuf[5]),
tempbuf[7]) + 1); tempbuf[6]),
tempbuf[7]), tempbuf[20]) + 1);
if (tempbuf[4]) if (tempbuf[4])
{ {
serializeUnpack(buf, size, position, serializeUnpack(buf, size, position,
...@@ -2197,6 +2205,13 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position, ...@@ -2197,6 +2205,13 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
varname[tempbuf[7]] = '\0'; varname[tempbuf[7]] = '\0';
vlistDefVarUnits(vlistID, newvar, varname); vlistDefVarUnits(vlistID, newvar, varname);
} }
if (tempbuf[20])
{
serializeUnpack(buf, size, position,
varname, tempbuf[20], DATATYPE_TXT, context);
varname[tempbuf[20]] = '\0';
vlistDefVarExtra(vlistID, newvar, varname);
}
Free(varname); Free(varname);
vlistDefVarDatatype(vlistID, newvar, tempbuf[8]); vlistDefVarDatatype(vlistID, newvar, tempbuf[8]);
vlistDefVarInstitut ( vlistID, newvar, vlistDefVarInstitut ( vlistID, newvar,
......
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