Commit 875d140e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added CDI function zaxisDefNlevRef() and zaxisInqNlevRef() [Feature #4117]

parent 8f2abb10
......@@ -3,6 +3,10 @@
* Version 1.6.2 released
* using CGRIBEX library version 1.6.2
2013-11-05 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Added CDI function zaxisDefNlevRef() and zaxisInqNlevRef() [Feature #4117]
2013-11-04 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* merged branch cdi-pio to trunk cdi
......
......@@ -5,7 +5,8 @@ Version 1.6.2 (12 November 2013):
New features:
* Added support for netCDF CF time attribute: climatology [Feature #4092]
* made gridtype GRID_REFERENCE part of GRID_UNSTRUCTED
* Added CDI function zaxisDefNlevRef() and zaxisInqNlevRef() [Feature #4117]
* Made gridtype GRID_REFERENCE part of GRID_UNSTRUCTED
* GRIB2: added support for level type Lake Bottom (grib level type 162)
* GRIB2: added support for level type Bottom Of Sediment Layer (grib level type 163)
* GRIB2: added support for level type Bottom Of Thermally Active Sediment Layer (grib level type 164)
......
......@@ -839,6 +839,12 @@ void zaxisDefLevel(int zaxisID, int levelID, double levels);
/* zaxisInqLevel: Get one level of a Z-axis */
double zaxisInqLevel(int zaxisID, int levelID);
/* zaxisDefNlevRef: Define the number of half levels of a generalized Z-axis */
void zaxisDefNlevRef(int gridID, int nhlev);
/* zaxisInqNlevRef: Get the number of half levels of a generalized Z-axis */
int zaxisInqNlevRef(int gridID);
/* zaxisDefNumber: Define the reference number for a generalized Z-axis */
void zaxisDefNumber(int gridID, int number);
......
......@@ -878,7 +878,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
size_t len;
char uuid[17];
long ltmp;
long nlev, nvgrid;
long nhlev, nvgrid;
GRIB_CHECK(grib_get_long(gh, "NV", &lpar), 0);
if ( lpar != 6 )
......@@ -886,13 +886,13 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
fprintf(stderr, "Warning ...\n");
}
GRIB_CHECK(grib_get_long(gh, "nlev", &ltmp), 0);
nlev = ltmp;
nhlev = ltmp;
GRIB_CHECK(grib_get_long(gh, "numberOfVGridUsed", &ltmp), 0);
nvgrid = ltmp;
len = (size_t) 16;
uuid[16] = 0;
GRIB_CHECK(grib_get_bytes(gh, "uuidOfVGrid", (unsigned char *) uuid, &len), 0);
varDefZAxisReference((int) nlev, (int) nvgrid, uuid);
varDefZAxisReference((int) nhlev, (int) nvgrid, uuid);
break;
}
}
......@@ -2893,7 +2893,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", GRIB2_LTYPE_REFERENCE);
gribapiDefLevelType(gh, gcinit, "typeOfSecondFixedSurface", GRIB2_LTYPE_REFERENCE);
GRIB_CHECK(grib_set_long(gh, "NV", 6), 0);
GRIB_CHECK(grib_set_long(gh, "nlev", zaxisInqSize(zaxisID)+1), 0);
GRIB_CHECK(grib_set_long(gh, "nlev", zaxisInqNlevRef(zaxisID)), 0);
GRIB_CHECK(grib_set_long(gh, "numberOfVGridUsed", number), 0);
len = 16;
if (grib_set_bytes(gh, "uuidOfVGrid", (unsigned char *) zaxisInqUUID(zaxisID, uuid), &len) != 0)
......@@ -2911,7 +2911,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
number = zaxisInqNumber(zaxisID);
gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", GRIB2_LTYPE_REFERENCE);
GRIB_CHECK(grib_set_long(gh, "NV", 6), 0);
GRIB_CHECK(grib_set_long(gh, "nlev", zaxisInqSize(zaxisID)), 0);
GRIB_CHECK(grib_set_long(gh, "nlev", zaxisInqNlevRef(zaxisID)), 0);
GRIB_CHECK(grib_set_long(gh, "numberOfVGridUsed", number), 0);
len = 16;
if (grib_set_bytes(gh, "uuidOfVGrid", (unsigned char *) zaxisInqUUID(zaxisID, uuid), &len) != 0)
......
......@@ -574,6 +574,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 ( uuidVGrid[0] != 0 ) zaxisDefUUID(zaxisID, uuidVGrid);
}
......@@ -710,9 +711,9 @@ void varDefVCT(size_t vctsize, double *vctptr)
}
void varDefZAxisReference(int nlev, int nvgrid, char *uuid)
void varDefZAxisReference(int nhlev, int nvgrid, char *uuid)
{
numberOfVerticalLevels = nlev;
numberOfVerticalLevels = nhlev;
numberOfVerticalGrid = nvgrid;
memcpy(uuidVGrid, uuid, 16);
}
......
......@@ -79,6 +79,7 @@ typedef struct {
int vctsize;
double *vct;
int number; /* Reference number to a generalized Z-axis */
int nhlev;
char uuid[17];
}
zaxis_t;
......@@ -117,6 +118,7 @@ void zaxisDefaultValue ( zaxis_t *zaxisptr )
zaxisptr->vctsize = 0;
zaxisptr->vct = NULL;
zaxisptr->number = 0;
zaxisptr->nhlev = 0;
zaxisptr->uuid[0] = 0;
}
......@@ -680,6 +682,39 @@ void zaxisDefLevel(int zaxisID, int levelID, double level)
zaxisptr->vals[levelID] = level;
}
void zaxisDefNlevRef(int zaxisID, const int nhlev)
{
zaxis_t *zaxisptr;
if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
return;
}
zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
zaxis_check_ptr(zaxisID, zaxisptr);
zaxisptr->nhlev = nhlev;
}
int zaxisInqNlevRef(int zaxisID)
{
int nhlev = -1;
zaxis_t *zaxisptr;
zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
zaxis_check_ptr(zaxisID, zaxisptr);
nhlev = zaxisptr->nhlev;
return (nhlev);
}
/*
@Function zaxisDefNumber
@Title Define the reference number for a generalized Z-axis
......
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