Commit 01fa2d30 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced zaxisDefNlevRef()/zaxisInqNlevRef() by cdiDefKeyInt()/cdiInqKeyInt() with CDI_KEY_NLEV.

parent 4f7a44eb
......@@ -26,3 +26,5 @@ zaxisInqYunits(zaxisID, yunits) -> cdiInqKeyString(zaxisID, CDI_GLOBAL, CD
zaxisDefNumber(zaxisID, number) -> cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, number)
zaxisInqNumber(zaxisID) -> cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, &number)
zaxisDefNlevRef(zaxisID, nlev) -> cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NLEV, nlev)
zaxisInqNlevRef(zaxisID) -> cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NLEV, &nlev)
......@@ -827,6 +827,7 @@ size_t gridInqYCvals(int gridID, char *ycvals[]);
#define CDI_KEY_UUID 960 // UUID for grid/Z-axis reference
#define CDI_KEY_NUMBEROFVGRIDUSED 961 // GRIB2 numberOfVGridUsed
#define CDI_KEY_NLEV 962 // GRIB2 nlev
// cdiDefKeyInt: Define an integer value from a key of a CDI variable
int cdiDefKeyInt(int cdiID, int varID, int key, int value);
......
......@@ -315,7 +315,11 @@ int cdiFallbackIterator_zaxisUuid(CdiIterator *super, int *outVgridNumber, int *
*outVgridNumber = 0;
cdiInqKeyInt(zaxisId, CDI_GLOBAL, CDI_KEY_NUMBEROFVGRIDUSED, outVgridNumber);
}
if (outLevelCount) *outLevelCount = zaxisInqNlevRef(zaxisId);
if (outLevelCount)
{
*outLevelCount = 0;
cdiInqKeyInt(zaxisId, CDI_GLOBAL, CDI_KEY_NLEV, outLevelCount);
}
if (outUuid) zaxisInqUUID(zaxisId, outUuid);
return CDI_NOERR;
}
......
......@@ -2588,12 +2588,14 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int zaxisID, int levelI
grib2DefLevel(gh, gcinit, grib_ltype, grib_ltype2, lbounds, level, dlevel1, dlevel2);
}
GRIB_CHECK(my_grib_set_long(gh, "NV", 6), 0);
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);
GRIB_CHECK(my_grib_set_long(gh, "numberOfVGridUsed", number), 0);
int nlev = 0;
cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NLEV, &nlev);
GRIB_CHECK(my_grib_set_long(gh, "nlev", nlev), 0);
unsigned char uuid[CDI_UUID_SIZE];
size_t len = CDI_UUID_SIZE;
zaxisInqUUID(zaxisID, uuid);
if ( grib_set_bytes(gh, "uuidOfVGrid", uuid, &len) != 0 ) Warning("Can't write UUID!");
......
......@@ -698,7 +698,7 @@ void cdi_generate_vars(stream_t *streamptr)
if ( zaxisInqType(zaxisID) == ZAXIS_REFERENCE )
{
if ( numberOfVerticalLevels > 0 ) zaxisDefNlevRef(zaxisID, numberOfVerticalLevels);
if ( numberOfVerticalLevels > 0 ) cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NLEV, numberOfVerticalLevels);
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->nhlev = 0;
cdiInitKeys(&zaxisptr->keys);
zaxisptr->atts.nalloc = MAX_ATTRIBUTES;
......@@ -612,21 +611,17 @@ void zaxisDefLevel(int zaxisID, int levelID, double level)
}
void zaxisDefNlevRef(int zaxisID, int nhlev)
void zaxisDefNlevRef(int zaxisID, int nlev)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
if (zaxisptr->nhlev != nhlev)
{
zaxisptr->nhlev = nhlev;
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}
cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NLEV, nlev);
}
int zaxisInqNlevRef(int zaxisID)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
return zaxisptr->nhlev;
int nlev = 0;
cdiInqKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_NLEV, &nlev);
return nlev;
}
/*
......
......@@ -27,7 +27,6 @@ typedef struct {
int vctsize;
unsigned positive;
double *vct;
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