Commit 45f62b8d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Moved grib2LocalSectionPresent=0 to gribContainersNew().

parent f2d905ee
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
* using CGRIBEX library version 1.9.4 * using CGRIBEX library version 1.9.4
* Version 1.9.8 released * Version 1.9.8 released
2019-07-22 Uwe Schulzweida
* Moved grib2LocalSectionPresent=0 to gribContainersNew() [report: Florian Prill]
2019-07-16 Uwe Schulzweida 2019-07-16 Uwe Schulzweida
* netCDF: added support for GAUSSIAN_REDUCED grids * netCDF: added support for GAUSSIAN_REDUCED grids
......
...@@ -53,7 +53,7 @@ const char *gribapiLibraryVersionString(void) ...@@ -53,7 +53,7 @@ const char *gribapiLibraryVersionString(void)
void gribContainersNew(stream_t * streamptr) void gribContainersNew(stream_t * streamptr)
{ {
int editionNumber = (streamptr->filetype == CDI_FILETYPE_GRB) ? 1 : 2; const int editionNumber = (streamptr->filetype == CDI_FILETYPE_GRB) ? 1 : 2;
#ifdef HAVE_LIBCGRIBEX #ifdef HAVE_LIBCGRIBEX
if ( editionNumber == 1 && !CDI_gribapi_grib1 ) if ( editionNumber == 1 && !CDI_gribapi_grib1 )
...@@ -62,15 +62,15 @@ void gribContainersNew(stream_t * streamptr) ...@@ -62,15 +62,15 @@ void gribContainersNew(stream_t * streamptr)
else else
#endif #endif
{ {
int nvars = streamptr->nvars; const int nvars = streamptr->nvars;
#if defined (GRIBCONTAINER2D) #ifdef GRIBCONTAINER2D
gribContainer_t **gribContainers; gribContainer_t **gribContainers;
gribContainers = (gribContainer_t **) Malloc(nvars*sizeof(gribContainer_t *)); gribContainers = (gribContainer_t **) Malloc(nvars*sizeof(gribContainer_t *));
for ( int varID = 0; varID < nvars; ++varID ) for ( int varID = 0; varID < nvars; ++varID )
{ {
int nlevs = streamptr->vars[varID].nlevs; const int nlevs = streamptr->vars[varID].nlevs;
gribContainers[varID] = (gribContainer_t *) Malloc(nlevs*sizeof(gribContainer_t)); gribContainers[varID] = (gribContainer_t *) Malloc(nlevs*sizeof(gribContainer_t));
for ( int levelID = 0; levelID < nlevs; ++levelID ) for ( int levelID = 0; levelID < nlevs; ++levelID )
...@@ -101,14 +101,14 @@ void gribContainersDelete(stream_t * streamptr) ...@@ -101,14 +101,14 @@ void gribContainersDelete(stream_t * streamptr)
{ {
if ( streamptr->gribContainers ) if ( streamptr->gribContainers )
{ {
int nvars = streamptr->nvars; const int nvars = streamptr->nvars;
#if defined (GRIBCONTAINER2D) #ifdef GRIBCONTAINER2D
gribContainer_t **gribContainers = (gribContainer_t **) streamptr->gribContainers; gribContainer_t **gribContainers = (gribContainer_t **) streamptr->gribContainers;
for ( int varID = 0; varID < nvars; ++varID ) for ( int varID = 0; varID < nvars; ++varID )
{ {
int nlevs = streamptr->vars[varID].nlevs; const int nlevs = streamptr->vars[varID].nlevs;
for ( int levelID = 0; levelID < nlevs; ++levelID ) for ( int levelID = 0; levelID < nlevs; ++levelID )
{ {
gribHandleDelete(gribContainers[varID][levelID].gribHandle); gribHandleDelete(gribContainers[varID][levelID].gribHandle);
......
...@@ -98,6 +98,7 @@ static inline void *gribHandleNew(int editionNumber) ...@@ -98,6 +98,7 @@ static inline void *gribHandleNew(int editionNumber)
if ( gh == NULL ) Error("grib_handle_new_from_samples failed!"); if ( gh == NULL ) Error("grib_handle_new_from_samples failed!");
if ( editionNumber == 1 ) GRIB_CHECK(my_grib_set_long(gh, "deleteLocalDefinition", 1L), 0); if ( editionNumber == 1 ) GRIB_CHECK(my_grib_set_long(gh, "deleteLocalDefinition", 1L), 0);
if ( editionNumber == 2 ) GRIB_CHECK(my_grib_set_long(gh, "grib2LocalSectionPresent", 0L), 0);
if ( editionNumber == 2 ) GRIB_CHECK(my_grib_set_long(gh, "numberOfValues", 0L), 0); if ( editionNumber == 2 ) GRIB_CHECK(my_grib_set_long(gh, "numberOfValues", 0L), 0);
return gh; return gh;
......
...@@ -3002,12 +3002,12 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI ...@@ -3002,12 +3002,12 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
vlistInqVarName(vlistID, varID, name); vlistInqVarName(vlistID, varID, name);
vlistInqVarStdname(vlistID, varID, stdname); vlistInqVarStdname(vlistID, varID, stdname);
#if defined(GRIBAPIENCODETEST) #ifdef GRIBAPIENCODETEST
grib_handle *gh = (grib_handle *) gribHandleNew(editionNumber); grib_handle *gh = (grib_handle *) gribHandleNew(editionNumber);
#else #else
gribContainer_t *gc = (gribContainer_t *) gribContainer; gribContainer_t *gc = (gribContainer_t *) gribContainer;
assert(gc != NULL); assert(gc != NULL);
grib_handle *gh = (struct grib_handle *)gc->gribHandle; grib_handle *gh = (struct grib_handle *) gc->gribHandle;
#endif #endif
GRIB_CHECK(grib_get_long(gh, "editionNumber", &editionNumber), 0); GRIB_CHECK(grib_get_long(gh, "editionNumber", &editionNumber), 0);
...@@ -3059,7 +3059,6 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI ...@@ -3059,7 +3059,6 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
int shapeOfTheEarth = 0; int shapeOfTheEarth = 0;
cdiInqKeyInt(vlistID, varID, CDI_KEY_SHAPEOFTHEEARTH, &shapeOfTheEarth); cdiInqKeyInt(vlistID, varID, CDI_KEY_SHAPEOFTHEEARTH, &shapeOfTheEarth);
GRIB_CHECK(my_grib_set_long(gh, "shapeOfTheEarth", (long)shapeOfTheEarth), 0); GRIB_CHECK(my_grib_set_long(gh, "shapeOfTheEarth", (long)shapeOfTheEarth), 0);
GRIB_CHECK(my_grib_set_long(gh, "grib2LocalSectionPresent", 0), 0);
int grib2LocalSectionNumber, section2PaddingLength; int grib2LocalSectionNumber, section2PaddingLength;
int mpimType, mpimClass, mpimUser; int mpimType, mpimClass, mpimUser;
...@@ -3179,7 +3178,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI ...@@ -3179,7 +3178,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
/* get a copy of the coded message */ /* get a copy of the coded message */
GRIB_CHECK(grib_get_message_copy(gh, *gribbuffer, &recsize), 0); GRIB_CHECK(grib_get_message_copy(gh, *gribbuffer, &recsize), 0);
#if defined(GRIBAPIENCODETEST) #ifdef GRIBAPIENCODETEST
gribHandleDelete(gh); gribHandleDelete(gh);
#endif #endif
......
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