Commit 9d2f06e1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gribapi cleanup

parent 9f1da458
......@@ -1757,10 +1757,18 @@ void gribapiDefInstitut(grib_handle *gh, int vlistID, int varID)
if ( instID != CDI_UNDEFID )
{
int center, subcenter;
long center, subcenter;
long center0, subcenter0;
center = institutInqCenter(instID);
subcenter = institutInqSubcenter(instID);
GRIB_CHECK(grib_get_long(gh, "centre", &center0), 0);
GRIB_CHECK(grib_get_long(gh, "subCentre", &subcenter0), 0);
if ( center != center0 )
GRIB_CHECK(grib_set_long(gh, "centre", center), 0);
if ( subcenter != subcenter0 )
GRIB_CHECK(grib_set_long(gh, "subCentre", subcenter), 0);
}
}
......@@ -2136,18 +2144,9 @@ void gribapiDefGrid(grib_handle *gh, int gridID, int ljpeg)
if ( gridInqComplexPacking(gridID) )
{
static int lwarncomplex = 1;
if ( lwarncomplex )
{
Warning("GRIB2 complex packing not implemented, using simple packing!");
lwarncomplex = 0;
}
mesg = "spectral_simple"; len = strlen(mesg);
GRIB_CHECK(grib_set_string(gh, "packingType", mesg, &len), 0);
/*
mesg = "spectral_complex"; len = strlen(mesg);
GRIB_CHECK(grib_set_string(gh, "packingType", mesg, &len), 0);
/*
GRIB_CHECK(grib_set_long(gh, "JS", 20), 0);
GRIB_CHECK(grib_set_long(gh, "KS", 20), 0);
GRIB_CHECK(grib_set_long(gh, "MS", 20), 0);
......@@ -2428,6 +2427,11 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
gribapiDefParam(gh, param);
gribapiDefTime(gh, vdate, vtime, tsteptype, numavg, vlistInqTaxis(vlistID));
/* bitsPerValue have to be defined befor call to DefGrid (complex packing) */
bitsPerValue = grbBitsPerValue(datatype);
GRIB_CHECK(grib_set_long(gh, "bitsPerValue", bitsPerValue), 0);
gribapiDefGrid(gh, gridID, ljpeg);
gribapiDefLevel(gh, param, zaxisID, levelID);
......@@ -2437,9 +2441,6 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
GRIB_CHECK(grib_set_double(gh, "missingValue", vlistInqVarMissval(vlistID, varID)), 0);
}
bitsPerValue = grbBitsPerValue(datatype);
GRIB_CHECK(grib_set_long(gh, "bitsPerValue", bitsPerValue), 0);
GRIB_CHECK(grib_set_double_array(gh, "values", data, datasize), 0);
/* get the size of coded message */
......
Supports Markdown
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