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

Replaced gridDefUUID()/gridInqUUID() by cdiDefKeyBytes()/cdiInqKeyBytes() with CDI_KEY_UUID

parent 02e1a747
2019-11-12 Uwe Schulzweida
* Replaced gridDefUUID()/gridInqUUID() by cdiDefKeyBytes()/cdiInqKeyBytes() with CDI_KEY_UUID
2019-11-10 Uwe Schulzweida 2019-11-10 Uwe Schulzweida
* Replaced zaxisDefLtype()/zaxisInqLtype() by cdiDefKeyInt()/cdiInqKeyInt() with CDI_KEY_TYPEOFFIRSTFIXEDSURFACE * Replaced zaxisDefLtype()/zaxisInqLtype() by cdiDefKeyInt()/cdiInqKeyInt() with CDI_KEY_TYPEOFFIRSTFIXEDSURFACE
......
...@@ -824,6 +824,8 @@ size_t gridInqYCvals(int gridID, char *ycvals[]); ...@@ -824,6 +824,8 @@ size_t gridInqYCvals(int gridID, char *ycvals[]);
#define CDI_KEY_P0NAME 951 // Z-axis reference pressure name #define CDI_KEY_P0NAME 951 // Z-axis reference pressure name
#define CDI_KEY_P0VALUE 952 // Z-axis reference pressure in Pa #define CDI_KEY_P0VALUE 952 // Z-axis reference pressure in Pa
#define CDI_KEY_UUID 960 // UUID for grid/Z-axis reference
// cdiDefKeyInt: Define an integer value from a key of a CDI variable // cdiDefKeyInt: Define an integer value from a key of a CDI variable
int cdiDefKeyInt(int cdiID, int varID, int key, int value); int cdiDefKeyInt(int cdiID, int varID, int key, int value);
......
...@@ -51,18 +51,33 @@ cdi_key_t *new_key(cdi_keys_t *keysp, int key) ...@@ -51,18 +51,33 @@ cdi_key_t *new_key(cdi_keys_t *keysp, int key)
return keyp; return keyp;
} }
cdi_key_t *find_key(cdi_keys_t *keysp, int key) cdi_key_t *find_key(cdi_keys_t *keysp, int key)
{ {
xassert(keysp != NULL); xassert(keysp != NULL);
if ( keysp->nelems == 0 ) return NULL; if ( keysp->nelems == 0 ) return NULL;
cdi_key_t *keys = keysp->value;
for ( size_t keyid = 0; keyid < keysp->nelems; keyid++ ) for ( size_t keyid = 0; keyid < keysp->nelems; keyid++ )
{ {
cdi_key_t *keyp = keys + keyid; cdi_key_t *keyp = &(keysp->value[keyid]);
if ( keyp->key == key ) if ( keyp->key == key ) return keyp; // Normal return
return keyp; // Normal return }
return NULL;
}
static
const cdi_key_t *find_key_const(const cdi_keys_t *keysp, int key)
{
xassert(keysp != NULL);
if ( keysp->nelems == 0 ) return NULL;
for ( size_t keyid = 0; keyid < keysp->nelems; keyid++ )
{
const cdi_key_t *keyp = &(keysp->value[keyid]);
if ( keyp->key == key ) return keyp; // Normal return
} }
return NULL; return NULL;
...@@ -173,7 +188,7 @@ int cdiInqKeyLen(int cdiID, int varID, int key, int *length) ...@@ -173,7 +188,7 @@ int cdiInqKeyLen(int cdiID, int varID, int key, int *length)
cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID); cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID);
xassert(keysp != NULL); xassert(keysp != NULL);
cdi_key_t *keyp = find_key(keysp, key); const cdi_key_t *keyp = find_key(keysp, key);
if ( keyp != NULL ) if ( keyp != NULL )
{ {
*length = keyp->length; *length = keyp->length;
...@@ -185,23 +200,23 @@ int cdiInqKeyLen(int cdiID, int varID, int key, int *length) ...@@ -185,23 +200,23 @@ int cdiInqKeyLen(int cdiID, int varID, int key, int *length)
} }
static static
void cdi_copy_key(cdi_key_t *keyp, int cdiID, int varID) void cdi_define_key(const cdi_key_t *keyp, cdi_keys_t *keysp)
{ {
if ( keyp->type == KEY_INT ) if ( keyp->type == KEY_INT )
cdiDefKeyInt(cdiID, varID, keyp->key, keyp->v.i); cdiDefVarKeyInt(keysp, keyp->key, keyp->v.i);
else if ( keyp->type == KEY_FLOAT ) else if ( keyp->type == KEY_FLOAT )
cdiDefKeyFloat(cdiID, varID, keyp->key, keyp->v.d); cdiDefVarKeyFloat(keysp, keyp->key, keyp->v.d);
else if ( keyp->type == KEY_BYTES ) else if ( keyp->type == KEY_BYTES )
cdiDefKeyBytes(cdiID, varID, keyp->key, keyp->v.s, keyp->length); cdiDefVarKeyBytes(keysp, keyp->key, keyp->v.s, keyp->length);
} }
void cdiCopyVarKeys(cdi_keys_t *keysp, int cdiID2, int varID2) void cdiCopyVarKeys(const cdi_keys_t *keysp1, cdi_keys_t *keysp2)
{ {
for ( size_t keyid = 0; keyid < keysp->nelems; keyid++ ) for ( size_t keyid = 0; keyid < keysp1->nelems; keyid++ )
{ {
cdi_key_t *keyp = &(keysp->value[keyid]); const cdi_key_t *keyp = &(keysp1->value[keyid]);
cdi_copy_key(keyp, cdiID2, varID2); cdi_define_key(keyp, keysp2);
} }
} }
...@@ -210,10 +225,13 @@ int cdiCopyKeys(int cdiID1, int varID1, int cdiID2, int varID2) ...@@ -210,10 +225,13 @@ int cdiCopyKeys(int cdiID1, int varID1, int cdiID2, int varID2)
{ {
int status = CDI_NOERR; int status = CDI_NOERR;
cdi_keys_t *keysp = cdi_get_keysp(cdiID1, varID1); cdi_keys_t *keysp1 = cdi_get_keysp(cdiID1, varID1);
xassert(keysp != NULL); xassert(keysp1 != NULL);
cdiCopyVarKeys(keysp, cdiID2, varID2); cdi_keys_t *keysp2 = cdi_get_keysp(cdiID2, varID2);
xassert(keysp2 != NULL);
cdiCopyVarKeys(keysp1, keysp2);
return status; return status;
} }
...@@ -223,13 +241,16 @@ int cdiCopyKey(int cdiID1, int varID1, int key, int cdiID2) ...@@ -223,13 +241,16 @@ int cdiCopyKey(int cdiID1, int varID1, int key, int cdiID2)
{ {
int status = CDI_NOERR; int status = CDI_NOERR;
cdi_keys_t *keysp = cdi_get_keysp(cdiID1, varID1); cdi_keys_t *keysp1 = cdi_get_keysp(cdiID1, varID1);
xassert(keysp != NULL); xassert(keysp1 != NULL);
cdi_key_t *keyp = find_key(keysp, key); cdi_keys_t *keysp2 = cdi_get_keysp(cdiID2, varID1);
xassert(keysp2 != NULL);
cdi_key_t *keyp = find_key(keysp1, key);
if (keyp == NULL) return -1; if (keyp == NULL) return -1;
cdi_copy_key(keyp, cdiID2, varID1); cdi_define_key(keyp, keysp2);
return status; return status;
} }
...@@ -447,19 +468,11 @@ int cdiDefKeyBytes(int cdiID, int varID, int key, const unsigned char *bytes, in ...@@ -447,19 +468,11 @@ int cdiDefKeyBytes(int cdiID, int varID, int key, const unsigned char *bytes, in
return status; return status;
} }
// cdiInqKeyBytes: Get a bytes array from a key of a CDI variable int cdiInqVarKeyBytes(const cdi_keys_t *keysp, int key, unsigned char *bytes, int *length)
int cdiInqKeyBytes(int cdiID, int varID, int key, unsigned char *bytes, int *length)
{ {
int status = -1; int status = -1;
xassert(bytes != NULL);
xassert(length != NULL);
// if ( varID != CDI_GLOBAL ) status = cdiInqKeyBytes(cdiID, CDI_GLOBAL, key, bytes, length); const cdi_key_t *keyp = find_key_const(keysp, key);
cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID);
xassert(keysp != NULL);
cdi_key_t *keyp = find_key(keysp, key);
if ( keyp != NULL ) // key in use if ( keyp != NULL ) // key in use
{ {
if ( keyp->type == KEY_BYTES ) if ( keyp->type == KEY_BYTES )
...@@ -473,6 +486,20 @@ int cdiInqKeyBytes(int cdiID, int varID, int key, unsigned char *bytes, int *len ...@@ -473,6 +486,20 @@ int cdiInqKeyBytes(int cdiID, int varID, int key, unsigned char *bytes, int *len
return status; return status;
} }
// cdiInqKeyBytes: Get a bytes array from a key of a CDI variable
int cdiInqKeyBytes(int cdiID, int varID, int key, unsigned char *bytes, int *length)
{
xassert(bytes != NULL);
xassert(length != NULL);
// if ( varID != CDI_GLOBAL ) status = cdiInqKeyBytes(cdiID, CDI_GLOBAL, key, bytes, length);
const cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID);
xassert(keysp != NULL);
return cdiInqVarKeyBytes(keysp, key, bytes, length);
}
/* /*
@Function cdiDefKeyString @Function cdiDefKeyString
@Title Define a string value from a key of a CDI variable @Title Define a string value from a key of a CDI variable
...@@ -538,7 +565,7 @@ int cdiInqKeyString(int cdiID, int varID, int key, char *string, int *length) ...@@ -538,7 +565,7 @@ int cdiInqKeyString(int cdiID, int varID, int key, char *string, int *length)
const char *cdiInqVarKeyStringPtr(cdi_keys_t *keysp, int key) const char *cdiInqVarKeyStringPtr(cdi_keys_t *keysp, int key)
{ {
cdi_key_t *keyp = find_key(keysp, key); const cdi_key_t *keyp = find_key(keysp, key);
if ( keyp != NULL ) // key in use if ( keyp != NULL ) // key in use
{ {
if ( keyp->type == KEY_BYTES ) return (const char *)keyp->v.s; if ( keyp->type == KEY_BYTES ) return (const char *)keyp->v.s;
......
...@@ -27,6 +27,7 @@ enum {KEY_INT = 1, KEY_FLOAT, KEY_BYTES}; ...@@ -27,6 +27,7 @@ enum {KEY_INT = 1, KEY_FLOAT, KEY_BYTES};
void cdiDefVarKeyInt(cdi_keys_t *keysp, int key, int value); void cdiDefVarKeyInt(cdi_keys_t *keysp, int key, int value);
void cdiDefVarKeyFloat(cdi_keys_t *keysp, int key, double value); void cdiDefVarKeyFloat(cdi_keys_t *keysp, int key, double value);
void cdiDefVarKeyBytes(cdi_keys_t *keysp, int key, const unsigned char *bytes, int length); void cdiDefVarKeyBytes(cdi_keys_t *keysp, int key, const unsigned char *bytes, int length);
int cdiInqVarKeyBytes(const cdi_keys_t *keysp, int key, unsigned char *bytes, int *length);
cdi_key_t *find_key(cdi_keys_t *keysp, int key); cdi_key_t *find_key(cdi_keys_t *keysp, int key);
const char *cdiInqVarKeyStringPtr(cdi_keys_t *keysp, int key); const char *cdiInqVarKeyStringPtr(cdi_keys_t *keysp, int key);
...@@ -50,7 +51,7 @@ const char *cdiInqVarKeyString(cdi_keys_t *keysp, int key) ...@@ -50,7 +51,7 @@ const char *cdiInqVarKeyString(cdi_keys_t *keysp, int key)
return string; return string;
} }
void cdiCopyVarKeys(cdi_keys_t *keysp, int cdiID2, int varID2); void cdiCopyVarKeys(const cdi_keys_t *keysp1, cdi_keys_t *keysp2);
void cdiDeleteVarKeys(cdi_keys_t *keysp); void cdiDeleteVarKeys(cdi_keys_t *keysp);
void cdiDeleteKeys(int cdiID, int varID); void cdiDeleteKeys(int cdiID, int varID);
void cdiPrintKeys(int cdiID, int varID); void cdiPrintKeys(int cdiID, int varID);
......
...@@ -754,7 +754,8 @@ void gribapiGetGridUnstructured(grib_handle *gh, grid_t *grid, size_t numberOfPo ...@@ -754,7 +754,8 @@ void gribapiGetGridUnstructured(grib_handle *gh, grid_t *grid, size_t numberOfPo
} }
*/ */
size_t len = (size_t)CDI_UUID_SIZE; size_t len = (size_t)CDI_UUID_SIZE;
if ( grib_get_bytes(gh, "uuidOfHGrid", uuid, &len) == 0) memcpy(grid->uuid, uuid, CDI_UUID_SIZE); if ( grib_get_bytes(gh, "uuidOfHGrid", uuid, &len) == 0)
cdiDefVarKeyBytes(&grid->keys, CDI_KEY_UUID, uuid, CDI_UUID_SIZE);
} }
} }
......
...@@ -166,7 +166,6 @@ void grid_init(grid_t *gridptr) ...@@ -166,7 +166,6 @@ void grid_init(grid_t *gridptr)
gridptr->lcomplex = false; gridptr->lcomplex = false;
gridptr->hasdims = true; gridptr->hasdims = true;
memset(gridptr->uuid, 0, CDI_UUID_SIZE);
gridptr->name = NULL; gridptr->name = NULL;
gridptr->vtable = &cdiGridVtable; gridptr->vtable = &cdiGridVtable;
gridptr->keys.nalloc = MAX_KEYS; gridptr->keys.nalloc = MAX_KEYS;
...@@ -249,8 +248,13 @@ void grid_copy_base_scalar_fields(grid_t *gridptrOrig, grid_t *gridptrDup) ...@@ -249,8 +248,13 @@ void grid_copy_base_scalar_fields(grid_t *gridptrOrig, grid_t *gridptrDup)
{ {
memcpy(gridptrDup, gridptrOrig, sizeof(grid_t)); memcpy(gridptrDup, gridptrOrig, sizeof(grid_t));
gridptrDup->self = CDI_UNDEFID; gridptrDup->self = CDI_UNDEFID;
if ( gridptrOrig->reference ) gridptrDup->keys.nelems = 0;
gridptrDup->reference = strdupx(gridptrOrig->reference); cdiCopyVarKeys(&gridptrOrig->keys, &gridptrDup->keys);
gridptrDup->x.keys.nelems = 0;
cdiCopyVarKeys(&gridptrOrig->x.keys, &gridptrDup->x.keys);
gridptrDup->y.keys.nelems = 0;
cdiCopyVarKeys(&gridptrOrig->y.keys, &gridptrDup->y.keys);
if ( gridptrOrig->reference ) gridptrDup->reference = strdupx(gridptrOrig->reference);
} }
...@@ -2311,8 +2315,13 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare) ...@@ -2311,8 +2315,13 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
} }
else if ( grid->type == GRID_UNSTRUCTURED ) else if ( grid->type == GRID_UNSTRUCTURED )
{ {
/* FIXME: not octet 0 but octet 7 is guaranteed non-zero for any non-NULL UUID */ unsigned char uuid1[CDI_UUID_SIZE]; memset(uuid1, 0, CDI_UUID_SIZE);
differ = ((gridRef->uuid[0] || grid->uuid[0]) && memcmp(gridRef->uuid, grid->uuid, CDI_UUID_SIZE)); unsigned char uuid2[CDI_UUID_SIZE]; memset(uuid2, 0, CDI_UUID_SIZE);
int length = CDI_UUID_SIZE;
cdiInqVarKeyBytes(&gridRef->keys, CDI_KEY_UUID, uuid1, &length);
length = CDI_UUID_SIZE;
cdiInqVarKeyBytes(&grid->keys, CDI_KEY_UUID, uuid2, &length);
differ = ((uuid1[0] || uuid2[0]) && memcmp(uuid1, uuid2, CDI_UUID_SIZE));
if (!differ) if (!differ)
{ {
if ( coord_compare ) if ( coord_compare )
...@@ -2362,17 +2371,6 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare) ...@@ -2362,17 +2371,6 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
return differ; return differ;
} }
/*
int gridIsEqual(int gridID1, int gridID2)
{
const grid_t *grid2 = grid_to_pointer(gridID2);
int grid_is_equal = gridCompare(gridID1, grid2, true) == false;
return grid_is_equal;
}
*/
int gridCompareP(void *gridptr1, void *gridptr2) int gridCompareP(void *gridptr1, void *gridptr2)
{ {
grid_t *g1 = ( grid_t * ) gridptr1; grid_t *g1 = ( grid_t * ) gridptr1;
...@@ -2536,8 +2534,13 @@ int gridCompareP(void *gridptr1, void *gridptr2) ...@@ -2536,8 +2534,13 @@ int gridCompareP(void *gridptr1, void *gridptr2)
else if ( g2->mask_gme ) else if ( g2->mask_gme )
return differ; return differ;
if ( memcmp(g1->uuid, g2->uuid, CDI_UUID_SIZE) ) unsigned char uuid1[CDI_UUID_SIZE]; memset(uuid1, 0, CDI_UUID_SIZE);
return differ; unsigned char uuid2[CDI_UUID_SIZE]; memset(uuid2, 0, CDI_UUID_SIZE);
int length = CDI_UUID_SIZE;
cdiInqVarKeyBytes(&g1->keys, CDI_KEY_UUID, uuid1, &length);
length = CDI_UUID_SIZE;
cdiInqVarKeyBytes(&g2->keys, CDI_KEY_UUID, uuid2, &length);
if ( memcmp(uuid1, uuid2, CDI_UUID_SIZE) ) return differ;
return equal; return equal;
} }
...@@ -2718,13 +2721,14 @@ int gridGenerate(const grid_t *grid) ...@@ -2718,13 +2721,14 @@ int gridGenerate(const grid_t *grid)
gridptr->y.inc = grid->y.inc; gridptr->y.inc = grid->y.inc;
if ( valdef_group1 && grid->area) if ( valdef_group1 && grid->area)
gridDefArea(gridID, grid->area); gridDefArea(gridID, grid->area);
gridptr->number = grid->number; gridptr->number = grid->number;
gridptr->position = grid->position; gridptr->position = grid->position;
gridptr->scanningMode = grid->scanningMode; gridptr->scanningMode = grid->scanningMode;
gridptr->iScansNegatively = grid->iScansNegatively; gridptr->iScansNegatively = grid->iScansNegatively;
gridptr->jScansPositively = grid->jScansPositively; gridptr->jScansPositively = grid->jScansPositively;
gridptr->jPointsAreConsecutive = grid->jPointsAreConsecutive; gridptr->jPointsAreConsecutive = grid->jPointsAreConsecutive;
memcpy(gridptr->uuid, grid->uuid, CDI_UUID_SIZE);
if ( gridtype == GRID_UNSTRUCTURED && grid->reference ) if ( gridtype == GRID_UNSTRUCTURED && grid->reference )
gridDefReference(gridID, grid->reference); gridDefReference(gridID, grid->reference);
if ( gridtype == GRID_PROJECTION ) if ( gridtype == GRID_PROJECTION )
...@@ -3396,13 +3400,7 @@ void gridPrintKernel(int gridID, int opt, FILE *fp) ...@@ -3396,13 +3400,7 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
fprintf(fp, "number = %d\n", number); fprintf(fp, "number = %d\n", number);
if ( position >= 0 ) fprintf(fp, "position = %d\n", position); if ( position >= 0 ) fprintf(fp, "position = %d\n", position);
} }
/*
gridInqUUID(gridID, uuidOfHGrid);
d = (unsigned char *) &uuidOfHGrid;
fprintf(fp, "uuid = %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
*/
if ( gridInqReference(gridID, NULL) ) if ( gridInqReference(gridID, NULL) )
{ {
char reference_link[8192]; char reference_link[8192];
...@@ -4090,9 +4088,8 @@ The function @func{gridDefUUID} defines the UUID for an unstructured grid. ...@@ -4090,9 +4088,8 @@ The function @func{gridDefUUID} defines the UUID for an unstructured grid.
*/ */
void gridDefUUID(int gridID, const unsigned char uuid[CDI_UUID_SIZE]) void gridDefUUID(int gridID, const unsigned char uuid[CDI_UUID_SIZE])
{ {
grid_t* gridptr = grid_to_pointer(gridID); cdiDefKeyBytes(gridID, CDI_GLOBAL, CDI_KEY_UUID, uuid, CDI_UUID_SIZE);
memcpy(gridptr->uuid, uuid, CDI_UUID_SIZE);
gridMark4Update(gridID); gridMark4Update(gridID);
} }
...@@ -4113,9 +4110,9 @@ The function @func{gridInqUUID} returns the UUID to an unstructured grid. ...@@ -4113,9 +4110,9 @@ The function @func{gridInqUUID} returns the UUID to an unstructured grid.
*/ */
void gridInqUUID(int gridID, unsigned char uuid[CDI_UUID_SIZE]) void gridInqUUID(int gridID, unsigned char uuid[CDI_UUID_SIZE])
{ {
grid_t *gridptr = grid_to_pointer(gridID); memset(uuid, 0, CDI_UUID_SIZE);
int length = CDI_UUID_SIZE;
memcpy(uuid, gridptr->uuid, CDI_UUID_SIZE); cdiInqKeyBytes(gridID, CDI_GLOBAL, CDI_KEY_UUID, uuid, &length);
} }
...@@ -4205,7 +4202,6 @@ enum { ...@@ -4205,7 +4202,6 @@ enum {
gridHasYBoundsFlag = 1 << 6, gridHasYBoundsFlag = 1 << 6,
gridHasReferenceFlag = 1 << 7, gridHasReferenceFlag = 1 << 7,
gridHasReducedPointsFlag = 1 << 8, gridHasReducedPointsFlag = 1 << 8,
gridHasUUIDFlag = 1 << 9,
}; };
...@@ -4223,8 +4219,7 @@ static int gridGetComponentFlags(const grid_t * gridP) ...@@ -4223,8 +4219,7 @@ static int gridGetComponentFlags(const grid_t * gridP)
| (gridHasXBoundsFlag & (int)((unsigned)(gridP->x.bounds == NULL) - 1U)) | (gridHasXBoundsFlag & (int)((unsigned)(gridP->x.bounds == NULL) - 1U))
| (gridHasYBoundsFlag & (int)((unsigned)(gridP->y.bounds == NULL) - 1U)) | (gridHasYBoundsFlag & (int)((unsigned)(gridP->y.bounds == NULL) - 1U))
| (gridHasReferenceFlag & (int)((unsigned)(gridP->reference == NULL) - 1U)) | (gridHasReferenceFlag & (int)((unsigned)(gridP->reference == NULL) - 1U))
| (gridHasReducedPointsFlag & (int)((unsigned)(gridP->reducedPoints == NULL) - 1U)) | (gridHasReducedPointsFlag & (int)((unsigned)(gridP->reducedPoints == NULL) - 1U));
| (gridHasUUIDFlag & (int)((unsigned)cdiUUIDIsNull(gridP->uuid) - 1U));
return flags; return flags;
} }
...@@ -4302,6 +4297,7 @@ gridGetPackSize(void * voidP, void *context) ...@@ -4302,6 +4297,7 @@ gridGetPackSize(void * voidP, void *context)
+ serializeGetSize(1, CDI_DATATYPE_UINT32, context)); + serializeGetSize(1, CDI_DATATYPE_UINT32, context));
} }
packBuffSize += serializeKeysGetPackSize(&gridP->keys, context);
packBuffSize += serializeKeysGetPackSize(&gridP->x.keys, context); packBuffSize += serializeKeysGetPackSize(&gridP->x.keys, context);
packBuffSize += serializeKeysGetPackSize(&gridP->y.keys, context); packBuffSize += serializeKeysGetPackSize(&gridP->y.keys, context);
...@@ -4328,9 +4324,6 @@ gridGetPackSize(void * voidP, void *context) ...@@ -4328,9 +4324,6 @@ gridGetPackSize(void * voidP, void *context)
+ serializeGetSize(1, CDI_DATATYPE_UINT32, context); + serializeGetSize(1, CDI_DATATYPE_UINT32, context);
} }
if (!cdiUUIDIsNull(gridP->uuid))
packBuffSize += serializeGetSize(CDI_UUID_SIZE, CDI_DATATYPE_UCHAR, context);
return packBuffSize; return packBuffSize;
} }
...@@ -4476,6 +4469,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize, ...@@ -4476,6 +4469,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
xassert(cdiCheckSum(CDI_DATATYPE_FLT, size, gridP->y.bounds) == d); xassert(cdiCheckSum(CDI_DATATYPE_FLT, size, gridP->y.bounds) == d);
} }
serializeKeysUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos, &gridP->keys, context);
serializeKeysUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos, &gridP->x.keys, context); serializeKeysUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos, &gridP->x.keys, context);
serializeKeysUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos, &gridP->y.keys, context); serializeKeysUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos, &gridP->y.keys, context);
...@@ -4513,11 +4507,6 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize, ...@@ -4513,11 +4507,6 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
&d, 1, CDI_DATATYPE_UINT32, context); &d, 1, CDI_DATATYPE_UINT32, context);
xassert(cdiCheckSum(CDI_DATATYPE_UCHAR, gridP->size, gridP->mask_gme) == d); xassert(cdiCheckSum(CDI_DATATYPE_UCHAR, gridP->size, gridP->mask_gme) == d);
} }
if (memberMask & gridHasUUIDFlag)
{
serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
gridP->uuid, CDI_UUID_SIZE, CDI_DATATYPE_UCHAR, context);
}
reshSetStatus(gridP->self, &gridOps, reshSetStatus(gridP->self, &gridOps,
reshGetStatus(gridP->self, &gridOps) & ~RESH_SYNC_BIT); reshGetStatus(gridP->self, &gridOps) & ~RESH_SYNC_BIT);
...@@ -4677,6 +4666,7 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize, ...@@ -4677,6 +4666,7 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize,
packBuffer, packBufferSize, packBufferPos, context); packBuffer, packBufferSize, packBufferPos, context);
} }
serializeKeysPack(&gridP->keys, packBuffer, packBufferSize, packBufferPos, context);
serializeKeysPack(&gridP->x.keys, packBuffer, packBufferSize, packBufferPos, context); serializeKeysPack(&gridP->x.keys, packBuffer, packBufferSize, packBufferPos, context);
serializeKeysPack(&gridP->y.keys, packBuffer, packBufferSize, packBufferPos, context); serializeKeysPack(&gridP->y.keys, packBuffer, packBufferSize, packBufferPos, context);
...@@ -4712,10 +4702,6 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize, ...@@ -4712,10 +4702,6 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize,
serializePack(&d, 1, CDI_DATATYPE_UINT32, serializePack(&d, 1, CDI_DATATYPE_UINT32,
packBuffer, packBufferSize, packBufferPos, context); packBuffer, packBufferSize, packBufferPos, context);
} }
if (memberMask & gridHasUUIDFlag)
serializePack(gridP->uuid, CDI_UUID_SIZE, CDI_DATATYPE_UCHAR,
packBuffer, packBufferSize, packBufferPos, context);
} }
......
...@@ -96,7 +96,6 @@ struct grid_t { ...@@ -96,7 +96,6 @@ struct grid_t {
int trunc; /* parameter for GRID_SPECTEAL */ int trunc; /* parameter for GRID_SPECTEAL */
int nvertex; int nvertex;
char *reference; char *reference;
unsigned char uuid[CDI_UUID_SIZE]; /* uuid for grid reference */
int *reducedPoints; int *reducedPoints;
int reducedPointsSize; int reducedPointsSize;
int np; /* number of parallels between a pole and the equator */ int np; /* number of parallels between a pole and the equator */
......
...@@ -2572,7 +2572,7 @@ bool cdf_set_unstructured_par(ncvar_t *ncvar, grid_t *grid, int *xdimid, int *yd ...@@ -2572,7 +2572,7 @@ bool cdf_set_unstructured_par(ncvar_t *ncvar, grid_t *grid, int *xdimid, int *yd
if ( number_of_grid_used != CDI_UNDEFID ) grid->number = number_of_grid_used; if ( number_of_grid_used != CDI_UNDEFID ) grid->number = number_of_grid_used;
if ( ncvar->position > 0 ) grid->position = ncvar->position; if ( ncvar->position > 0 ) grid->position = ncvar->position;
if ( uuidOfHGrid[0] != 0 ) memcpy(grid->uuid, uuidOfHGrid, CDI_UUID_SIZE); if ( uuidOfHGrid[0] != 0 ) cdiDefVarKeyBytes(&grid->keys, CDI_KEY_UUID, uuidOfHGrid, CDI_UUID_SIZE);
return false; return false;
} }
......
...@@ -2155,13 +2155,14 @@ void gribapiDefGridUnstructured(grib_handle *gh, int gridID) ...@@ -2155,13 +2155,14 @@ void gribapiDefGridUnstructured(grib_handle *gh, int gridID)
} }
else else
{ {
unsigned char uuid[CDI_UUID_SIZE];
int position = gridInqPosition(gridID); int position = gridInqPosition(gridID);
int number = gridInqNumber(gridID); int number = gridInqNumber(gridID);
if ( position < 0 ) position = 0;