Commit 4d5ac71c authored by Uwe Schulzweida's avatar Uwe Schulzweida

Replaced gridDefScannigMode()/gridInqScanningMode() by...

Replaced gridDefScannigMode()/gridInqScanningMode() by cdiDefKeyInt()/cdiInqKeyInt() with CDI_KEY_SCANNINGMODE
parent 74845af0
2019-11-20 Uwe Schulzweida
* Replaced gridDefScannigMode()/gridInqScanningMode() by cdiDefKeyInt()/cdiInqKeyInt() with CDI_KEY_SCANNINGMODE
2019-11-12 Uwe Schulzweida
* Replaced gridDefUUID()/gridInqUUID() by cdiDefKeyBytes()/cdiInqKeyBytes() with CDI_KEY_UUID
......
......@@ -1000,9 +1000,6 @@ void gridChangeType(int gridID, int gridtype);
void gridDefComplexPacking(int gridID, int lpack);
int gridInqComplexPacking(int gridID);
void gridDefScanningMode(int gridID, int mode);
int gridInqScanningMode(int gridID);
// ZAXIS routines
void zaxisName(int zaxistype, char *zaxisname);
......
......@@ -853,7 +853,9 @@ bool gribapiGetGrid(grib_handle *gh, grid_t *grid)
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);
grid->scanningMode = 128*iScansNegatively + 64*jScansPositively + 32*jPointsAreConsecutive;
int scanningMode = 128*iScansNegatively + 64*jScansPositively + 32*jPointsAreConsecutive;
cdiDefVarKeyInt(&grid->keys, CDI_KEY_SCANNINGMODE, scanningMode);
/* scanningMode = 128 * iScansNegatively + 64 * jScansPositively + 32 * jPointsAreConsecutive;
64 = 128 * 0 + 64 * 1 + 32 * 0
00 = 128 * 0 + 64 * 0 + 32 * 0
......@@ -870,9 +872,7 @@ bool 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, jPointsAreConsecutive,
jScansPositively, iScansNegatively,
uvRelativeToGrid);
scanningMode, jPointsAreConsecutive, jScansPositively, iScansNegatively, uvRelativeToGrid);
}
#endif //HIRLAM_EXTENSIONS
}
......
......@@ -165,7 +165,8 @@ void grid_init(grid_t *gridptr)
cdiInitKeys(&gridptr->keys);
gridptr->atts.nalloc = MAX_ATTRIBUTES;
gridptr->atts.nelems = 0;
gridptr->scanningMode = 64;
cdiDefVarKeyInt(&gridptr->keys, CDI_KEY_SCANNINGMODE, 64);
}
......@@ -2343,14 +2344,16 @@ bool gridCompare(int gridID, const grid_t *grid, bool coord_compare)
}
}
if ( (grid->scanningMode != gridInqScanningMode(gridID)) )
int scanningModeA = cdiInqVarKeyInt(&grid->keys, CDI_KEY_SCANNINGMODE);
int scanningModeB = cdiInqVarKeyInt(&gridRef->keys, CDI_KEY_SCANNINGMODE);
if ( scanningModeA != scanningModeB )
{
// often grid definition may differ in UV-relativeToGrid
differ = 1;
#ifdef HIRLAM_EXTENSIONS
if ( cdiDebugExt>=200 )
printf("gridCompare(gridID=%d): Differs: grid.scanningMode [%d] != gridInqScanningMode(gridID) [%d]\n",
gridID, grid->scanningMode, gridInqScanningMode(gridID));
printf("gridCompare(gridID=%d): Differs: scanningModeA [%d] != scanningModeB(gridID) [%d]\n",
gridID, scanningModeA, scanningModeB);
#endif // HIRLAM_EXTENSIONS
}
......@@ -2403,7 +2406,7 @@ int gridCompareP(void *gridptr1, void *gridptr2)
if ( IS_NOT_EQUAL(g1->y.last , g2->y.last) ) return differ;
if ( IS_NOT_EQUAL(g1->x.inc , g2->x.inc) ) return differ;
if ( IS_NOT_EQUAL(g1->y.inc , g2->y.inc) ) return differ;
if ( IS_NOT_EQUAL(g1->scanningMode , g2->scanningMode) ) return differ;
if ( cmp_key_int(&g1->keys, &g2->keys, CDI_KEY_SCANNINGMODE) ) return differ;
const double *restrict g1_xvals = g1->vtable->inqXValsPtr(g1),
*restrict g2_xvals = g2->vtable->inqXValsPtr(g2);
......@@ -2719,7 +2722,8 @@ int gridGenerate(const grid_t *grid)
cdiCopyVarKey(&grid->keys, CDI_KEY_NUMBEROFGRIDINREFERENCE, &gridptr->keys);
cdiCopyVarKey(&grid->keys, CDI_KEY_REFERENCEURI, &gridptr->keys);
gridptr->scanningMode = grid->scanningMode;
cdiCopyVarKey(&grid->keys, CDI_KEY_SCANNINGMODE, &gridptr->keys);
if ( gridtype == GRID_PROJECTION )
gridptr->name = strdup(grid->name);
if ( gridtype == GRID_GAUSSIAN_REDUCED )
......@@ -4074,25 +4078,6 @@ void gridInqUUID(int gridID, unsigned char uuid[CDI_UUID_SIZE])
}
void gridDefScanningMode(int gridID, int mode)
{
grid_t *gridptr = grid_to_pointer(gridID);
if ( gridptr->scanningMode != mode )
{
gridMark4Update(gridID);
gridptr->scanningMode = mode;
}
}
int gridInqScanningMode(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->scanningMode;
}
void cdiGridGetIndexList(unsigned ngrids, int * gridIndexList)
{
reshGetResHListOfType(ngrids, gridIndexList, &gridOps);
......@@ -4130,7 +4115,6 @@ enum {
GRID_PACK_INT_IDX_JSCANSPOSITIVELY,
GRID_PACK_INT_IDX_JPOINTSARECONSECUTIVE,
*/
GRID_PACK_INT_IDX_SCANNINGMODE,
gridNint
};
......@@ -4308,7 +4292,6 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
memberMask = intBuffer[GRID_PACK_INT_IDX_MEMBERMASK];
gridP->x.stdname = xystdname_tab[intBuffer[GRID_PACK_INT_IDX_XTSTDNNAME]][0];
gridP->y.stdname = xystdname_tab[intBuffer[GRID_PACK_INT_IDX_YTSTDNNAME]][1];
gridP->scanningMode = intBuffer[GRID_PACK_INT_IDX_SCANNINGMODE];
}
if (memberMask & gridHasReducedPointsFlag)
......@@ -4470,8 +4453,6 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize,
(int)((const char (*)[2][24])gridP->y.stdname
- (const char (*)[2][24])xystdname_tab[0][1]);
intBuffer[GRID_PACK_INT_IDX_SCANNINGMODE] = gridP->scanningMode;
serializePack(intBuffer, gridNint, CDI_DATATYPE_INT,
packBuffer, packBufferSize, packBufferPos, context);
d = cdiCheckSum(CDI_DATATYPE_INT, gridNint, intBuffer);
......
......@@ -109,7 +109,6 @@ struct grid_t {
const struct gridVirtTable *vtable;
cdi_keys_t keys;
cdi_atts_t atts;
int scanningMode;
};
......
......@@ -2634,10 +2634,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int zaxisID, int levelI
int gribapiGetScanningMode(grib_handle *gh)
{
long iScansNegatively;
long jScansPositively;
long jPointsAreConsecutive;
long iScansNegatively, jScansPositively, jPointsAreConsecutive;
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);
......@@ -2843,7 +2840,7 @@ convertDataScanningMode(int scanModeIN, int scanModeOUT, double *data,
#ifdef VERTICAL_FLIP
{ // flip the data vertically ..
idxIN= 0; idxOUT= (jDim-1)*iDim;
if (cdiDebugExt>=30) printf("convertDataScanningMode(): copying rows nr. (%04d : %04d)\n",0,jDim-1);
if (cdiDebugExt>=30) printf("convertDataScanningMode(): copying rows nr. (%04d : %04zu)\n",0,jDim-1);
for (j=0; j<jDim; j++)
{
memcpy((void*)&data[idxOUT], (void*)&dataCopy[idxIN], iDim*sizeof(double));
......@@ -2995,7 +2992,8 @@ void gribapiSetExtMode(grib_handle *gh, int gridID, size_t datasize, const doubl
gridtype == GRID_GAUSSIAN_REDUCED || gridtype == CDI_PROJ_LCC )
{
#ifdef HIRLAM_EXTENSIONS
int scanModeIN = gridInqScanningMode(gridID);
int scanModeIN = 0;
cdiInqKeyInt(gridID, CDI_GLOBAL, CDI_KEY_SCANNINGMODE, &scanModeIN);
if (cdiDebugExt>=100)
{
......
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