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

grib2: change packingType from grid_jpeg to grid_simple if nmiss > 0

parent ffeaa461
......@@ -5,8 +5,12 @@
2012-10-16 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* grib2: change packingType from grid_jpeg to grid_simple if nmiss > 0 (bug fix)
2012-10-18 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* grib2: added stepType support for absolute time axis
2012-10-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* pio.h remove line 'typedef int MPI_Comm;' [Bug #2882]
......
......@@ -2135,7 +2135,7 @@ void gribapiDefTime(int editionNumber, grib_handle *gh , int vdate, int vtime, i
}
static
void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int ljpeg, int lieee, int datatype)
void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int ljpeg, int lieee, int datatype, int nmiss, int gcinit)
{
int gridtype;
int status;
......@@ -2188,6 +2188,30 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int ljpeg, i
gridtype = GRID_LONLAT;
}
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN )
{
if ( editionNumber != 2 || lieee ) { ljpeg = 0; }
if ( ljpeg )
{
if ( nmiss > 0 ) ljpeg = 0;
if ( ljpeg )
{
mesg = "grid_jpeg"; len = strlen(mesg);
GRIB_CHECK(grib_set_string(gh, "packingType", mesg, &len), 0);
}
else
{
mesg = "grid_simple"; len = strlen(mesg);
GRIB_CHECK(grib_set_string(gh, "packingType", mesg, &len), 0);
}
}
}
if ( gcinit ) return;
switch (gridtype)
{
case GRID_LONLAT:
......@@ -2331,6 +2355,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int ljpeg, i
/* South -> North */
//if ( ISEC2_LastLat > ISEC2_FirstLat ) ISEC2_ScanFlag += 64;
if ( editionNumber != 2 ) { lieee = 0; ljpeg = 0; }
if ( lieee )
{
mesg = "grid_ieee"; len = strlen(mesg);
......@@ -2341,10 +2367,20 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int ljpeg, i
else
GRIB_CHECK(grib_set_long(gh, "precision", 1), 0);
}
else if ( ljpeg && editionNumber == 2 )
else if ( ljpeg )
{
mesg = "grid_jpeg"; len = strlen(mesg);
GRIB_CHECK(grib_set_string(gh, "packingType", mesg, &len), 0);
if ( nmiss > 0 ) ljpeg = 0;
if ( ljpeg )
{
mesg = "grid_jpeg"; len = strlen(mesg);
GRIB_CHECK(grib_set_string(gh, "packingType", mesg, &len), 0);
}
else
{
mesg = "grid_simple"; len = strlen(mesg);
GRIB_CHECK(grib_set_string(gh, "packingType", mesg, &len), 0);
}
}
else
{
......@@ -2902,7 +2938,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
GRIB_CHECK(grib_set_long(gh, "bitsPerValue", bitsPerValue), 0);
}
if ( ! gc->init ) gribapiDefGrid(editionNumber, gh, gridID, ljpeg, lieee, datatype);
gribapiDefGrid(editionNumber, gh, gridID, ljpeg, lieee, datatype, nmiss, gc->init);
gribapiDefLevel(editionNumber, gh, param, zaxisID, levelID, gc->init);
......
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