Commit aa0b6504 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Reduce memory needed for flags.

* Ideally this should be consolidated with scanningMode.
parent d22bb654
......@@ -767,9 +767,13 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_LONLAT || gridtype == GRID_PROJECTION || gridtype == GRID_LCC )
{
GRIB_CHECK(grib_get_long(gh, "iScansNegatively", &grid->iScansNegatively), 0);
GRIB_CHECK(grib_get_long(gh, "jScansPositively", &grid->jScansPositively), 0);
GRIB_CHECK(grib_get_long(gh, "jPointsAreConsecutive", &grid->jPointsAreConsecutive), 0);
long temp;
GRIB_CHECK(grib_get_long(gh, "iScansNegatively", &temp), 0);
grid->iScansNegatively = (bool)temp;
GRIB_CHECK(grib_get_long(gh, "jScansPositively", &temp), 0);
grid->jScansPositively = (bool)temp;
GRIB_CHECK(grib_get_long(gh, "jPointsAreConsecutive", &temp), 0);
grid->jPointsAreConsecutive = (bool)temp;
grid->scanningMode = 128*grid->iScansNegatively + 64*grid->jScansPositively + 32*grid->jPointsAreConsecutive;
/* scanningMode = 128 * iScansNegatively + 64 * jScansPositively + 32 * jPointsAreConsecutive;
64 = 128 * 0 + 64 * 1 + 32 * 0
......@@ -787,8 +791,9 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
GRIB_CHECK(grib_get_long(gh, "level", &levelId), 0);
Message("(param,ltype,level) = (%3d,%3d,%4d); Scanning mode = %02d -> bits:(%1d.%1d.%1d)*32; uvRelativeToGrid = %02d",\
(int)paramId, (int)levelTypeId, (int)levelId,
grid->scanningMode,(int)grid->jPointsAreConsecutive,(int)grid->jScansPositively,(int)grid->iScansNegatively,
(int)grid->uvRelativeToGrid);
grid->scanningMode,grid->jPointsAreConsecutive,
grid->jScansPositively,grid->iScansNegatively,
grid->uvRelativeToGrid);
}
#endif //HIRLAM_EXTENSIONS
}
......
......@@ -4264,9 +4264,9 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
gridP->y.stdname =
xystdname_tab[intBuffer[GRID_PACK_INT_IDX_YTSTDNNAME]][1];
gridP->uvRelativeToGrid = intBuffer[GRID_PACK_INT_IDX_UVRELATIVETOGRID];
gridP->iScansNegatively = intBuffer[GRID_PACK_INT_IDX_ISCANSNEGATIVELY];
gridP->jScansPositively = intBuffer[GRID_PACK_INT_IDX_JSCANSPOSITIVELY];
gridP->jPointsAreConsecutive = intBuffer[GRID_PACK_INT_IDX_JPOINTSARECONSECUTIVE];
gridP->iScansNegatively = (bool)intBuffer[GRID_PACK_INT_IDX_ISCANSNEGATIVELY];
gridP->jScansPositively = (bool)intBuffer[GRID_PACK_INT_IDX_JSCANSPOSITIVELY];
gridP->jPointsAreConsecutive = (bool)intBuffer[GRID_PACK_INT_IDX_JPOINTSARECONSECUTIVE];
gridP->scanningMode = intBuffer[GRID_PACK_INT_IDX_SCANNINGMODE];
}
......
......@@ -113,10 +113,8 @@ struct grid_t {
struct gridaxis_t y;
const struct gridVirtTable *vtable;
cdi_atts_t atts;
long iScansNegatively;
long jScansPositively;
long jPointsAreConsecutive;
int scanningMode;
bool iScansNegatively, jScansPositively, jPointsAreConsecutive;
/* scanningMode = 128 * iScansNegatively + 64 * jScansPositively + 32 * jPointsAreConsecutive;
64 = 128 * 0 + 64 * 1 + 32 * 0
00 = 128 * 0 + 64 * 0 + 32 * 0
......
......@@ -2051,8 +2051,7 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
GRIB_CHECK(my_grib_set_double(gh, "latitudeOfLastGridPointInDegrees", ylast), 0);
{
long jscan = 0;
if ( yfirst < ylast ) jscan = 1;
long jscan = yfirst < ylast;
GRIB_CHECK(my_grib_set_long(gh, "jScansPositively", jscan), 0);
}
......@@ -2581,8 +2580,10 @@ int gribapiGetScanningMode(grib_handle *gh)
GRIB_CHECK(grib_get_long(gh, "iScansNegatively", &iScansNegatively), 0);
GRIB_CHECK(grib_get_long(gh, "jScansPositively", &jScansPositively), 0);
GRIB_CHECK(grib_get_long(gh, "jPointsAreConsecutive", &jPointsAreConsecutive), 0);
int scanningMode = 0;
scanningMode = 128*iScansNegatively + 64*jScansPositively + 32*jPointsAreConsecutive;
int scanningMode
= 128*(bool)iScansNegatively
+ 64 *(bool)jScansPositively
+ 32 *(bool)jPointsAreConsecutive;
if (cdiDebugExt>=30)
printf("gribapiGetScanningMode(): Scanning mode = %02d (%1d%1d%1d)*32; \n",\
scanningMode,(int)jPointsAreConsecutive,(int)jScansPositively,(int)iScansNegatively);
......
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