Commit 722c149c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added read support for GRIB2 local section.

parent a44bcb31
......@@ -816,6 +816,9 @@ size_t gridInqYCvals(int gridID, char *ycvals[]);
#define CDI_KEY_MPIMUSER 815 // GRIB2 mpimUser
#define CDI_KEY_REVSTATUS 816 // GRIB2 revStatus
#define CDI_KEY_REVNUMBER 817 // GRIB2 revNumber
#define CDI_KEY_GRIB2LOCALSECTIONNUMBER 818 // GRIB2 grib2LocalSectionNumber
#define CDI_KEY_SECTION2PADDINGLENGTH 819 // GRIB2 length of section2Padding
#define CDI_KEY_SECTION2PADDING 820 // GRIB2 section2Padding
// cdiDefKeyInt: Define an integer value from a key of a CDI variable
int cdiDefKeyInt(int cdiID, int varID, int key, int value);
......
......@@ -9,7 +9,7 @@
#include "zaxis.h"
#include "resource_unpack.h"
enum {KEY_INT, KEY_FLOAT, KEY_BYTES};
enum {KEY_INT = 1, KEY_FLOAT, KEY_BYTES};
static
cdi_keys_t *get_keysp(vlist_t *vlistptr, int varID)
......@@ -193,7 +193,7 @@ void cdiDefVarKeyInt(cdi_keys_t *keysp, int key, int value)
if ( keyp != NULL )
{
if ( keyp->v.i != value )
//if ( keyp->v.i != value )
{
keyp->type = KEY_INT;
keyp->v.i = value;
......
......@@ -450,10 +450,23 @@ void gribapiGetKeys(grib_handle *gh, int varID)
}
}
long ltmp;
if ( grib_get_long(gh, "grib2LocalSectionNumber", &ltmp) == 0 )
{
// printf("grib2LocalSectionNumber %ld\n", ltmp);
long section2Length;
grib_get_long(gh, "section2Length", &section2Length);
if ( section2Length > 0 )
{
long grib2LocalSectionNumber;
grib_get_long(gh, "grib2LocalSectionNumber", &grib2LocalSectionNumber);
size_t size;
grib_get_size(gh, "section2Padding", &size);
if ( size > 0 )
{
varDefKeyInt(varID, CDI_KEY_GRIB2LOCALSECTIONNUMBER, (int) grib2LocalSectionNumber);
varDefKeyInt(varID, CDI_KEY_SECTION2PADDINGLENGTH, (int) size);
unsigned char *section2Padding = (unsigned char*) Malloc(size);
grib_get_bytes(gh, "section2Padding", section2Padding, &size);
varDefKeyBytes(varID, CDI_KEY_SECTION2PADDING, section2Padding, size);
Free(section2Padding);
}
}
}
......
......@@ -116,7 +116,7 @@ void paramInitEntry(unsigned varID, int param)
vartable[varID].keys.nalloc = MAX_KEYS;
vartable[varID].keys.nelems = 0;
for ( int i = 0; i < MAX_KEYS; ++i )
vartable[varID].keys.value[i].length = 0;
memset(&vartable[varID].keys.value[i], 0, sizeof(cdi_key_t));
vartable[varID].comptype = CDI_COMPRESS_NONE;
vartable[varID].complevel = 1;
vartable[varID].lmissval = false;
......
......@@ -108,7 +108,7 @@ void vlist_init_entry(vlist_t *vlistptr)
vlistptr->keys.nalloc = MAX_KEYS;
vlistptr->keys.nelems = 0;
for ( int i = 0; i < MAX_KEYS; ++i )
vlistptr->keys.value[i].length = 0;
memset(&vlistptr->keys.value[i], 0, sizeof(cdi_key_t));
vlistptr->atts.nalloc = MAX_ATTRIBUTES;
vlistptr->atts.nelems = 0;
vlistptr->nsubtypes = 0;
......
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