Commit 4f7a44eb authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced zaxisDefNumber()/zaxisInqNumber() by cdiDefKeyInt()/cdiInqKeyInt()...

Replaced zaxisDefNumber()/zaxisInqNumber() by cdiDefKeyInt()/cdiInqKeyInt() with CDI_KEY_NUMBEROFVGRIDUSED
parent aeceb0a5
......@@ -10,3 +10,19 @@ gridInqXunits(gridID, xunits) -> cdiInqKeyString(gridID, CDI_XAXIS, CDI_KE
gridInqYname(gridID, yname) -> cdiInqKeyString(gridID, CDI_YAXIS, CDI_KEY_NAME, yname, &length)
gridInqYlongname(gridID, ylongname) -> cdiInqKeyString(gridID, CDI_YAXIS, CDI_KEY_LONGNAME, ylongname, &length)
gridInqYunits(gridID, yunits) -> cdiInqKeyString(gridID, CDI_YAXIS, CDI_KEY_UNITS, yunits, &length)
zaxisDefXname(zaxisID, xname) -> cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_NAME, xname)
zaxisDefXlongname(zaxisID, xlongname) -> cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, xlongname)
zaxisDefXunits(zaxisID, xunits) -> cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, xunits)
zaxisDefYname(zaxisID, yname) -> cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_NAME, yname)
zaxisDefYlongname(zaxisID, ylongname) -> cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, ylongname)
zaxisDefYunits(zaxisID, yunits) -> cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, yunits)
zaxisInqXname(zaxisID, xname) -> cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_NAME, xname, &length)
zaxisInqXlongname(zaxisID, xlongname) -> cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, xlongname, &length)
zaxisInqXunits(zaxisID, xunits) -> cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, xunits, &length)
zaxisInqYname(zaxisID, yname) -> cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_NAME, yname, &length)
zaxisInqYlongname(zaxisID, ylongname) -> cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, ylongname, &length)
zaxisInqYunits(zaxisID, yunits) -> cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, yunits, &length)
zaxisDefNumber(zaxisID, number) -> cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, number)
zaxisInqNumber(zaxisID) -> cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, &number)
......@@ -826,6 +826,7 @@ size_t gridInqYCvals(int gridID, char *ycvals[]);
#define CDI_KEY_P0VALUE 952 // Z-axis reference pressure in Pa
#define CDI_KEY_UUID 960 // UUID for grid/Z-axis reference
#define CDI_KEY_NUMBEROFVGRIDUSED 961 // GRIB2 numberOfVGridUsed
// cdiDefKeyInt: Define an integer value from a key of a CDI variable
int cdiDefKeyInt(int cdiID, int varID, int key, int value);
......
......@@ -309,10 +309,14 @@ int cdiFallbackIterator_zaxisUuid(CdiIterator *super, int *outVgridNumber, int *
int zaxisId = vlistInqVarZaxis(me->vlistId, me->curVariable);
int ltype = 0;
cdiInqKeyInt(zaxisId, CDI_GLOBAL, CDI_KEY_TYPEOFFIRSTFIXEDSURFACE, &ltype);
if(ltype != ZAXIS_HYBRID) return CDI_EINVAL;
if(outVgridNumber) *outVgridNumber = zaxisInqNumber(zaxisId);
if(outLevelCount) *outLevelCount = zaxisInqNlevRef(zaxisId);
if(outUuid) zaxisInqUUID(zaxisId, outUuid);
if (ltype != ZAXIS_HYBRID) return CDI_EINVAL;
if (outVgridNumber)
{
*outVgridNumber = 0;
cdiInqKeyInt(zaxisId, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, outVgridNumber);
}
if (outLevelCount) *outLevelCount = zaxisInqNlevRef(zaxisId);
if (outUuid) zaxisInqUUID(zaxisId, outUuid);
return CDI_NOERR;
}
......
......@@ -2588,7 +2588,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int zaxisID, int levelI
grib2DefLevel(gh, gcinit, grib_ltype, grib_ltype2, lbounds, level, dlevel1, dlevel2);
}
int number = zaxisInqNumber(zaxisID);
int number = 0;
cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, &number);
unsigned char uuid[CDI_UUID_SIZE];
GRIB_CHECK(my_grib_set_long(gh, "NV", 6), 0);
GRIB_CHECK(my_grib_set_long(gh, "nlev", zaxisInqNlevRef(zaxisID)), 0);
......
......@@ -699,7 +699,7 @@ void cdi_generate_vars(stream_t *streamptr)
if ( zaxisInqType(zaxisID) == ZAXIS_REFERENCE )
{
if ( numberOfVerticalLevels > 0 ) zaxisDefNlevRef(zaxisID, numberOfVerticalLevels);
if ( numberOfVerticalGrid > 0 ) zaxisDefNumber(zaxisID, numberOfVerticalGrid);
if ( numberOfVerticalGrid > 0 ) cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, numberOfVerticalGrid);
if ( !cdiUUIDIsNull(uuidVGrid) ) zaxisDefUUID(zaxisID, uuidVGrid);
}
......
......@@ -129,7 +129,6 @@ void zaxis_init(zaxis_t *zaxisptr)
zaxisptr->size = 0;
zaxisptr->vctsize = 0;
zaxisptr->vct = NULL;
zaxisptr->number = 0;
zaxisptr->nhlev = 0;
cdiInitKeys(&zaxisptr->keys);
......@@ -646,12 +645,7 @@ The function @func{zaxisDefNumber} defines the reference number for a generalize
*/
void zaxisDefNumber(int zaxisID, int number)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
if (zaxisptr->number != number)
{
zaxisptr->number = number;
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}
cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, number);
}
/*
......@@ -671,8 +665,9 @@ The function @func{zaxisInqNumber} returns the reference number to a generalized
*/
int zaxisInqNumber(int zaxisID)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
return zaxisptr->number;
int referenceNumber = 0;
cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, &referenceNumber);
return referenceNumber;
}
/*
......
......@@ -27,7 +27,6 @@ typedef struct {
int vctsize;
unsigned positive;
double *vct;
int number; /* Reference number to a generalized Z-axis */
int nhlev;
cdi_keys_t keys;
cdi_atts_t atts;
......
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