Commit 0f9a0757 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added function varDefKeyBytes().

parent db35384f
......@@ -237,14 +237,9 @@ int cdiInqKeyInt(int cdiID, int varID, int key, int *value)
return status;
}
// cdiDefKeyBytes: Define a bytes array from a key of a CDI variable
int cdiDefKeyBytes(int cdiID, int varID, int key, const unsigned char *bytes, int length)
{
int status = CDI_NOERR;
cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID);
xassert(keysp != NULL);
void cdiDefVarKeyBytes(cdi_keys_t *keysp, int key, const unsigned char *bytes, int length)
{
cdi_key_t *keyp = find_key(keysp, key);
if ( keyp == NULL ) keyp = new_key(keysp, key);
......@@ -264,6 +259,17 @@ int cdiDefKeyBytes(int cdiID, int varID, int key, const unsigned char *bytes, in
memcpy(keyp->v.s, bytes, length);
keyp->type = KEY_BYTES;
}
}
// cdiDefKeyBytes: Define a bytes array from a key of a CDI variable
int cdiDefKeyBytes(int cdiID, int varID, int key, const unsigned char *bytes, int length)
{
int status = CDI_NOERR;
cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID);
xassert(keysp != NULL);
cdiDefVarKeyBytes(keysp, key, bytes, length);
return status;
}
......
......@@ -21,7 +21,10 @@ typedef struct {
cdi_key_t value[MAX_KEYS];
} cdi_keys_t;
void cdiDefVarKeyInt(cdi_keys_t *keysp, int key, int value);
void cdiDefVarKeyBytes(cdi_keys_t *keysp, int key, const unsigned char *bytes, int length);
void cdiCopyVarKeys(cdi_keys_t *keysp, int cdiID2, int varID2);
void cdiDeleteVarKeys(cdi_keys_t *keysp);
int cdiDeleteKeys(int cdiID, int varID);
......
......@@ -449,6 +449,12 @@ void gribapiGetKeys(grib_handle *gh, int varID)
varDefKeyInt(varID, CDI_KEY_PERTURBATIONNUMBER, (int) perturbationNumber);
}
}
long ltmp;
if ( grib_get_long(gh, "grib2LocalSectionNumber", &ltmp) == 0 )
{
// printf("grib2LocalSectionNumber %ld\n", ltmp);
}
}
static
......
......@@ -1097,6 +1097,13 @@ void varDefKeyInt(int varID, int key, int value)
}
void varDefKeyBytes(int varID, int key, const unsigned char *bytes, int length)
{
cdi_keys_t *keysp = &(vartable[varID].keys);
cdiDefVarKeyBytes(keysp, key, bytes, length);
}
#if defined (HAVE_LIBGRIB_API)
/* Resizes and initializes opt_grib_kvpair data structure. */
static
......
......@@ -30,6 +30,7 @@ void varDefTable(int varID, int tableID);
int varInqTable(int varID);
void varDefKeyInt(int varID, int key, int value);
void varDefKeyBytes(int varID, int key, const unsigned char *bytes, int length);
void varDefOptGribInt(int varID, int tile_index, long lval, const char *keyword);
void varDefOptGribDbl(int varID, int tile_index, double dval, const char *keyword);
......
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