Commit a7c88a3c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added support for grib_api key typeOfSecondFixedSurface

parent 2dc89d6d
......@@ -3,6 +3,10 @@
* Version 1.6.5 released
* using CGRIBEX library version 1.6.5
2014-10-13 Uwe Schulzweida
* added support for grib_api key typeOfSecondFixedSurface
2014-10-10 Uwe Schulzweida
* netCDF: added support 1D level variables
......
......@@ -19,7 +19,7 @@ case "${HOSTNAME}" in
--enable-swig \
--enable-python \
--with-jasper=/opt/local \
--with-grib_api=$HOME/local/gribapi-1.10.4 \
--with-grib_api=$HOME/local/gribapi-1.12.3 \
--with-netcdf=$HOME/local \
--with-szlib=$HOME/local \
CC=icc CFLAGS="-g -D_REENTRANT -Wall -O3 -march=native -Df2cFortran -fp-model source"
......@@ -31,7 +31,7 @@ case "${HOSTNAME}" in
--enable-swig \
--enable-python \
--with-jasper=/opt/local \
--with-grib_api=$HOME/local/gribapi-1.10.4 \
--with-grib_api=$HOME/local/gribapi-1.12.3 \
--with-netcdf=$HOME/local \
--with-szlib=$HOME/local \
CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O3 -march=native -Df2cFortran"
......
......@@ -414,7 +414,7 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
if ( datatype < 0 ) datatype = DATATYPE_PACK;
varAddRecord(recID, param, gridID, zaxistype, lbounds, level1, level2, 0, 0,
datatype, &varID, &levelID, tsteptype, numavg, ISEC1_LevelType, NULL, NULL, NULL, NULL);
datatype, &varID, &levelID, tsteptype, numavg, ISEC1_LevelType, -1, NULL, NULL, NULL, NULL);
(*record).varID = (short)varID;
(*record).levelID = (short)levelID;
......
......@@ -238,7 +238,7 @@ void extAddRecord(stream_t *streamptr, int param, int level, int xysize,
leveltype = ZAXIS_GENERIC;
varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
extInqDatatype(prec, number), &varID, &levelID, TSTEP_INSTANT, 0, 0, NULL, NULL, NULL, NULL);
extInqDatatype(prec, number), &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
(*record).varID = (short)varID;
(*record).levelID = (short)levelID;
......
......@@ -699,9 +699,9 @@ static
void grib1GetLevel(grib_handle *gh, int *leveltype, int *lbounds, int *level1, int *level2)
{
*leveltype = 0;
*lbounds = 0;
*level1 = 0;
*level2 = 0;
*lbounds = 0;
*level1 = 0;
*level2 = 0;
long lpar;
int status = grib_get_long(gh, "indicatorOfTypeOfLevel", &lpar);
......@@ -758,14 +758,15 @@ double grib2ScaleFactor(long factor)
}
static
void grib2GetLevel(grib_handle *gh, int *leveltype, int *lbounds, int *level1, int *level2, int *level_sf, int *level_unit)
void grib2GetLevel(grib_handle *gh, int *leveltype1, int *leveltype2, int *lbounds, int *level1,
int *level2, int *level_sf, int *level_unit)
{
int status;
int leveltype2 = -1;
long lpar;
long factor;
*leveltype = 0;
*leveltype1 = 0;
*leveltype2 = -1;
*lbounds = 0;
*level1 = 0;
*level2 = 0;
......@@ -778,26 +779,26 @@ void grib2GetLevel(grib_handle *gh, int *leveltype, int *lbounds, int *level1, i
long llevel;
double dlevel1 = 0, dlevel2 = 0;
*leveltype = (int) lpar;
*leveltype1 = (int) lpar;
status = grib_get_long(gh, "typeOfSecondFixedSurface", &lpar);
/* FIXME: assert(lpar >= INT_MIN && lpar <= INT_MAX) */
if ( status == 0 ) leveltype2 = (int)lpar;
if ( status == 0 ) *leveltype2 = (int)lpar;
if ( *leveltype != 255 && leveltype2 != 255 && leveltype2 > 0 ) *lbounds = 1;
if ( *leveltype == GRIB2_LTYPE_REFERENCE && leveltype2 == 1 ) *lbounds = 0;
if ( *leveltype1 != 255 && *leveltype2 != 255 && *leveltype2 > 0 ) *lbounds = 1;
if ( *leveltype1 == GRIB2_LTYPE_REFERENCE && *leveltype2 == 1 ) *lbounds = 0;
if ( *leveltype == GRIB2_LTYPE_LANDDEPTH )
if ( *leveltype1 == GRIB2_LTYPE_LANDDEPTH )
{
*level_sf = 1000;
*level_unit = CDI_UNIT_M;
}
else if ( *leveltype == GRIB2_LTYPE_ISOBARIC )
else if ( *leveltype1 == GRIB2_LTYPE_ISOBARIC )
{
*level_sf = 1000;
*level_unit = CDI_UNIT_PA;
}
else if ( *leveltype == GRIB2_LTYPE_SIGMA )
else if ( *leveltype1 == GRIB2_LTYPE_SIGMA )
{
*level_sf = 1000;
*level_unit = 0;
......@@ -849,7 +850,7 @@ void gribapiGetString(grib_handle *gh, const char *key, char *string, size_t len
static
void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
size_t recsize, off_t position, int datatype, int comptype, size_t len, const char *varname,
int leveltype, int lbounds, int level1, int level2, int level_sf, int level_unit)
int leveltype1, int leveltype2, int lbounds, int level1, int level2, int level_sf, int level_unit)
{
long editionNumber;
int zaxistype;
......@@ -878,14 +879,14 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
GRIB_CHECK(grib_get_long(gh, "editionNumber", &editionNumber), 0);
// fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype);
// fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype1);
(*record).size = recsize;
(*record).position = position;
(*record).param = param;
(*record).ilevel = level1;
(*record).ilevel2 = level2;
(*record).ltype = leveltype;
(*record).ltype = leveltype1;
(*record).tsteptype = tsteptype;
memcpy((*record).varname, varname, len);
......@@ -893,7 +894,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
gridID = varDefGrid(vlistID, grid, 0);
zaxistype = gribapiGetZaxisType(editionNumber, leveltype);
zaxistype = gribapiGetZaxisType(editionNumber, leveltype1);
switch (zaxistype)
{
......@@ -965,7 +966,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
// fprintf(stderr, "param %d name %s %s %s\n", param, name, longname, units);
varAddRecord(recID, param, gridID, zaxistype, lbounds, level1, level2, level_sf, level_unit,
datatype, &varID, &levelID, tsteptype, numavg, leveltype,
datatype, &varID, &levelID, tsteptype, numavg, leveltype1, leveltype2,
varname, stdname, longname, units);
(*record).varID = (short)varID;
......@@ -1168,7 +1169,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
long unzipsize;
compvar2_t compVar;
grib_handle *gh = NULL;
int leveltype;
int leveltype1, leveltype2 = -1;
long editionNumber;
long lpar;
size_t len;
......@@ -1242,7 +1243,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
param = cdiEncodeParam(rcode, rtabnum, 255);
grib1GetLevel(gh, &leveltype, &lbounds, &level1, &level2);
grib1GetLevel(gh, &leveltype1, &lbounds, &level1, &level2);
level_sf = 0;
level_unit = 0;
}
......@@ -1261,7 +1262,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
param = gribapiGetParam(gh);
grib2GetLevel(gh, &leveltype, &lbounds, &level1, &level2, &level_sf, &level_unit);
grib2GetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
}
cdiParamToString(param, paramstr, sizeof(paramstr));
......@@ -1275,7 +1276,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
tsteptype = gribapiGetTsteptype(gh);
gribapiGetValidityDateTime(gh, &vdate, &vtime);
/*
printf("%d %d %d\n", vdate, vtime, leveltype);
printf("%d %d %d\n", vdate, vtime, leveltype1);
*/
if ( lieee )
{
......@@ -1310,7 +1311,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
datetime.date = vdate;
datetime.time = vtime;
compVar = gribapiVarSet(param, level1, level2, leveltype, tsteptype, varname);
compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname);
for ( recID = 0; recID < nrecs; recID++ )
if ( gribapiVarCompare(compVar, streamptr->tsteps[0].records[recID]) == 0 ) break;
......@@ -1368,10 +1369,10 @@ int gribapiScanTimestep1(stream_t * streamptr)
if ( CDI_Debug )
Message("%4d %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
nrecs, (int)recpos, varname, paramstr, leveltype, level1, level2, vdate, vtime);
nrecs, (int)recpos, varname, paramstr, leveltype1, level1, level2, vdate, vtime);
gribapiAddRecord(streamptr, param, gh, recsize, recpos, datatype, comptype, len, varname,
leveltype, lbounds, level1, level2, level_sf, level_unit);
leveltype1, leveltype2, lbounds, level1, level2, level_sf, level_unit);
grib_handle_delete(gh);
gh = NULL;
......@@ -1476,7 +1477,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
long unzipsize;
compvar2_t compVar;
grib_handle *gh = NULL;
int leveltype;
int leveltype1, leveltype2 = -1;
int param = 0;
long editionNumber;
long lpar;
......@@ -1565,7 +1566,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
param = cdiEncodeParam(rcode, rtabnum, 255);
grib1GetLevel(gh, &leveltype, &lbounds, &level1, &level2);
grib1GetLevel(gh, &leveltype1, &lbounds, &level1, &level2);
level_sf = 0;
level_unit = 0;
}
......@@ -1573,7 +1574,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
{
param = gribapiGetParam(gh);
grib2GetLevel(gh, &leveltype, &lbounds, &level1, &level2, &level_sf, &level_unit);
grib2GetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
}
cdiParamToString(param, paramstr, sizeof(paramstr));
......@@ -1622,7 +1623,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
datetime.date = vdate;
datetime.time = vtime;
compVar = gribapiVarSet(param, level1, level2, leveltype, tsteptype, varname);
compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname);
for ( recID = 0; recID < nrecords; recID++ )
if ( gribapiVarCompare(compVar, streamptr->tsteps[tsID].records[recID]) == 0 ) break;
......@@ -1650,7 +1651,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
if ( CDI_Debug )
Message("%4d %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
nrecs_scanned, (int)recpos, varname, paramstr, leveltype, level1, level2, vdate, vtime);
nrecs_scanned, (int)recpos, varname, paramstr, leveltype1, level1, level2, vdate, vtime);
streamptr->tsteps[tsID].records[recID].size = recsize;
......@@ -1744,7 +1745,7 @@ int gribapiScanTimestep(stream_t * streamptr)
long unzipsize;
compvar2_t compVar;
grib_handle *gh = NULL;
int leveltype;
int leveltype1, leveltype2 = -1;
int param = 0;
long editionNumber;
long lpar;
......@@ -1840,7 +1841,7 @@ int gribapiScanTimestep(stream_t * streamptr)
param = cdiEncodeParam(rcode, rtabnum, 255);
grib1GetLevel(gh, &leveltype, &lbounds, &level1, &level2);
grib1GetLevel(gh, &leveltype1, &lbounds, &level1, &level2);
level_sf = 0;
level_unit = 0;
}
......@@ -1848,7 +1849,7 @@ int gribapiScanTimestep(stream_t * streamptr)
{
param = gribapiGetParam(gh);
grib2GetLevel(gh, &leveltype, &lbounds, &level1, &level2, &level_sf, &level_unit);
grib2GetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
}
cdiParamToString(param, paramstr, sizeof(paramstr));
......@@ -1900,7 +1901,7 @@ int gribapiScanTimestep(stream_t * streamptr)
int tsteptype = gribapiGetTsteptype(gh);
compVar = gribapiVarSet(param, level1, level2, leveltype, tsteptype, varname);
compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname);
for ( vrecID = 0; vrecID < nrecs; vrecID++ )
{
......@@ -2759,13 +2760,13 @@ void gribapiDefLevelType(grib_handle *gh, int gcinit, const char *keyname, long
}
static
void grib2DefLevel(grib_handle *gh, int gcinit, long leveltype, int lbounds, double level, double dlevel1, double dlevel2)
void grib2DefLevel(grib_handle *gh, int gcinit, long leveltype1, long leveltype2, int lbounds, double level, double dlevel1, double dlevel2)
{
long scaled_level;
long factor;
gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", leveltype);
if ( lbounds ) gribapiDefLevelType(gh, gcinit, "typeOfSecondFixedSurface", leveltype);
gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", leveltype1);
if ( lbounds ) gribapiDefLevelType(gh, gcinit, "typeOfSecondFixedSurface", leveltype2);
if ( !lbounds ) dlevel1 = level;
......@@ -2789,9 +2790,9 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
double dlevel1 = 0, dlevel2 = 0;
unsigned char uuid[16];
int zaxistype = zaxisInqType(zaxisID);
int ltype = zaxisInqLtype(zaxisID);
int ltype2 = zaxisInqLtype2(zaxisID);
double level = zaxisInqLevel(zaxisID, levelID);
if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
......@@ -2941,7 +2942,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
}
else
{
grib2DefLevel(gh, gcinit, GRIB2_LTYPE_ISOBARIC, lbounds, level, dlevel1, dlevel2);
if ( ltype2 == -1 ) ltype2 = GRIB2_LTYPE_ISOBARIC;
grib2DefLevel(gh, gcinit, GRIB2_LTYPE_ISOBARIC, ltype2, lbounds, level, dlevel1, dlevel2);
}
break;
......@@ -2952,7 +2954,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
; // not available
else
{
grib2DefLevel(gh, gcinit, GRIB2_LTYPE_SNOW, lbounds, level, dlevel1, dlevel2);
grib2DefLevel(gh, gcinit, GRIB2_LTYPE_SNOW, GRIB2_LTYPE_SNOW, lbounds, level, dlevel1, dlevel2);
}
break;
......@@ -2986,7 +2988,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
dlevel1 *= scalefactor;
dlevel2 *= scalefactor;
grib2DefLevel(gh, gcinit, GRIB2_LTYPE_LANDDEPTH, lbounds, level, dlevel1, dlevel2);
grib2DefLevel(gh, gcinit, GRIB2_LTYPE_LANDDEPTH, GRIB2_LTYPE_LANDDEPTH, lbounds, level, dlevel1, dlevel2);
}
break;
......
......@@ -735,7 +735,7 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
datatype = iegInqDatatype(prec);
varAddRecord(recID, param, gridID, leveltype, lbounds, level1, level2, 0, 0,
datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, NULL, NULL, NULL, NULL);
datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
record->varID = (short)varID;
record->levelID = (short)levelID;
......
......@@ -242,7 +242,7 @@ void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ys
datatype = srvInqDatatype(prec);
varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, NULL, NULL, NULL, NULL);
datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
xassert(varID <= SHRT_MAX && levelID <= SHRT_MAX);
(*record).varID = (short)varID;
......
......@@ -14,7 +14,8 @@
#include "zaxis.h"
extern void zaxisGetIndexList ( int, int * );
extern void zaxisGetIndexList(int, int *);
extern void zaxisDefLtype2(int zaxisID, int ltype2);
#undef UNDEFID
......@@ -45,7 +46,8 @@ typedef struct
int timaccu;
int gridID;
int zaxistype;
int ltype; /* GRIB level type */
int ltype1; /* GRIB first level type */
int ltype2; /* GRIB second level type */
int lbounds;
int level_sf;
int level_unit;
......@@ -96,7 +98,8 @@ void paramInitEntry(int varID, int param)
vartable[varID].timaccu = 0;
vartable[varID].gridID = UNDEFID;
vartable[varID].zaxistype = 0;
vartable[varID].ltype = 0;
vartable[varID].ltype1 = 0;
vartable[varID].ltype2 = -1;
vartable[varID].lbounds = 0;
vartable[varID].level_sf = 0;
vartable[varID].level_unit = 0;
......@@ -120,16 +123,16 @@ void paramInitEntry(int varID, int param)
}
static
int varGetEntry(int param, int zaxistype, int ltype, int tsteptype, const char *name)
int varGetEntry(int param, int zaxistype, int ltype1, int tsteptype, const char *name)
{
int varID;
for ( varID = 0; varID < varTablesize; varID++ )
{
if ( vartable[varID].param == param &&
vartable[varID].zaxistype == zaxistype &&
vartable[varID].ltype == ltype &&
vartable[varID].tsteptype == tsteptype )
if ( vartable[varID].param == param &&
vartable[varID].zaxistype == zaxistype &&
vartable[varID].ltype1 == ltype1 &&
vartable[varID].tsteptype == tsteptype )
{
if ( name && name[0] && vartable[varID].name && vartable[varID].name[0] )
{
......@@ -322,14 +325,14 @@ int paramNewEntry(int param)
void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
int level1, int level2, int level_sf, int level_unit, int prec,
int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype,
int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype1, int ltype2,
const char *name, const char *stdname, const char *longname, const char *units)
{
int varID = UNDEFID;
int levelID = -1;
if ( ! (cdiSplitLtype105 == 1 && zaxistype == ZAXIS_HEIGHT) )
varID = varGetEntry(param, zaxistype, ltype, tsteptype, name);
varID = varGetEntry(param, zaxistype, ltype1, tsteptype, name);
if ( varID == UNDEFID )
{
......@@ -337,7 +340,8 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
varID = paramNewEntry(param);
vartable[varID].gridID = gridID;
vartable[varID].zaxistype = zaxistype;
vartable[varID].ltype = ltype;
vartable[varID].ltype1 = ltype1;
vartable[varID].ltype2 = ltype2;
vartable[varID].lbounds = lbounds;
vartable[varID].level_sf = level_sf;
vartable[varID].level_unit = level_unit;
......@@ -443,7 +447,7 @@ void cdi_generate_vars(stream_t *streamptr)
{
int varID, gridID, zaxisID, levelID;
int instID, modelID, tableID;
int param, nlevels, zaxistype, lindex, ltype;
int param, nlevels, zaxistype, ltype1, ltype2, lindex;
int prec;
int tsteptype;
int timave, timaccu;
......@@ -473,7 +477,7 @@ void cdi_generate_vars(stream_t *streamptr)
{
varInfo[varid]->varid = varids[varid];
varInfo[varid]->param = vartable[varid].param;
varInfo[varid]->ltype = vartable[varid].ltype;
varInfo[varid]->ltype = vartable[varid].ltype1;
}
qsort(varInfo[0], (size_t)nvars, sizeof(param_t), cmpparam);
for ( varid = 0; varid < nvars; varid++ )
......@@ -486,31 +490,32 @@ void cdi_generate_vars(stream_t *streamptr)
for ( index = 0; index < nvars; index++ )
{
varid = varids[index];
varid = varids[index];
gridID = vartable[varid].gridID;
param = vartable[varid].param;
nlevels = vartable[varid].nlevels;
ltype = vartable[varid].ltype;
gridID = vartable[varid].gridID;
param = vartable[varid].param;
nlevels = vartable[varid].nlevels;
ltype1 = vartable[varid].ltype1;
ltype2 = vartable[varid].ltype2;
zaxistype = vartable[varid].zaxistype;
if ( ltype == 0 && zaxistype == ZAXIS_GENERIC && cdiDefaultLeveltype != -1 )
if ( ltype1 == 0 && zaxistype == ZAXIS_GENERIC && cdiDefaultLeveltype != -1 )
zaxistype = cdiDefaultLeveltype;
lbounds = vartable[varid].lbounds;
prec = vartable[varid].prec;
instID = vartable[varid].instID;
modelID = vartable[varid].modelID;
tableID = vartable[varid].tableID;
tsteptype = vartable[varid].tsteptype;
timave = vartable[varid].timave;
timaccu = vartable[varid].timaccu;
comptype = vartable[varid].comptype;
lbounds = vartable[varid].lbounds;
prec = vartable[varid].prec;
instID = vartable[varid].instID;
modelID = vartable[varid].modelID;
tableID = vartable[varid].tableID;
tsteptype = vartable[varid].tsteptype;
timave = vartable[varid].timave;
timaccu = vartable[varid].timaccu;
comptype = vartable[varid].comptype;
level_sf = 1;
if ( vartable[varid].level_sf != 0 ) level_sf = 1./vartable[varid].level_sf;
zaxisID = UNDEFID;
if ( ltype == 0 && zaxistype == ZAXIS_GENERIC && nlevels == 1 &&
if ( ltype1 == 0 && zaxistype == ZAXIS_GENERIC && nlevels == 1 &&
vartable[varid].levelTable[0].level1 == 0 )
zaxistype = ZAXIS_SURFACE;
......@@ -581,7 +586,12 @@ void cdi_generate_vars(stream_t *streamptr)
char *unitptr = cdiUnitNamePtr(vartable[varid].level_unit);
zaxisID = varDefZaxis(vlistID, zaxistype, nlevels, dlevels, lbounds, dlevels1, dlevels2,
(int)Vctsize, Vct, NULL, NULL, unitptr, 0, 0, ltype);
(int)Vctsize, Vct, NULL, NULL, unitptr, 0, 0, ltype1);
if ( ltype1 != ltype2 && ltype2 != -1 )
{
zaxisDefLtype2(zaxisID, ltype2);
}
if ( zaxisInqType(zaxisID) == ZAXIS_REFERENCE )
{
......@@ -810,14 +820,14 @@ int varDefGrid(int vlistID, grid_t grid, int mode)
}
int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, double *levels, char *longname, char *units, int ltype)
int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, double *levels, char *longname, char *units, int ltype1)
{
int differ = 1;
int levelID;
int zlbounds = 0;
int ltype_is_equal = FALSE;
if ( ltype == zaxisInqLtype(zaxisID) ) ltype_is_equal = TRUE;
if ( ltype1 == zaxisInqLtype(zaxisID) ) ltype_is_equal = TRUE;
if ( ltype_is_equal && (zaxistype == zaxisInqType(zaxisID) || zaxistype == ZAXIS_GENERIC) )
{
......@@ -859,7 +869,7 @@ int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, double *l
int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbounds,
double *levels1, double *levels2, int vctsize, double *vct, char *name,
char *longname, char *units, int prec, int mode, int ltype)
char *longname, char *units, int prec, int mode, int ltype1)
{
/*
mode: 0 search in vlist and zaxis table
......@@ -883,7 +893,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
{
zaxisID = vlistptr->zaxisIDs[index];
if ( zaxisCompare(zaxisID, zaxistype, nlevels, lbounds, levels, longname, units, ltype) == 0 )
if ( zaxisCompare(zaxisID, zaxistype, nlevels, lbounds, levels, longname, units, ltype1) == 0 )
{
zaxisdefined = 1;
break;
......@@ -901,7 +911,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
for ( i = 0; i < nzaxis; i++ )
{
zaxisID = zaxisIndexList[i];
if ( zaxisCompare(zaxisID, zaxistype, nlevels, lbounds, levels, longname, units, ltype) == 0 )
if ( zaxisCompare(zaxisID, zaxistype, nlevels, lbounds, levels, longname, units, ltype1) == 0 )
{
zaxisglobdefined = 1;
break;
......@@ -946,7 +956,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
zaxisDefLongname(zaxisID, longname);
zaxisDefUnits(zaxisID, units);
zaxisDefPrec(zaxisID, prec);
zaxisDefLtype(zaxisID, ltype);
zaxisDefLtype(zaxisID, ltype1);
}
nzaxis = vlistptr->nzaxis;
......
......@@ -8,7 +8,7 @@
void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
int level1, int level2, int level_sf, int level_unit, int prec,
int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype,
int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype1, int ltype2,
const char *name, const char *stdname, const char *longname, const char *units);
void varDefVCT(size_t vctsize, double *vctptr);
......
......@@ -76,6 +76,7 @@ typedef struct {
int prec;
int type;
int ltype; /* GRIB level type */
int ltype2;
int size;
int direction;
int vctsize;
......@@ -105,7 +106,7 @@ static const resOps zaxisOps = {
static int ZAXIS_Debug = 0; /* If set to 1, debugging */
static
void zaxisDefaultValue ( zaxis_t *zaxisptr )
void zaxisDefaultValue(zaxis_t *zaxisptr)
{
zaxisptr->self = CDI_UNDEFID;
zaxisptr->name[0] = 0;
......@@ -118,6 +119,7 @@ void zaxisDefaultValue ( zaxis_t *zaxisptr )
zaxisptr->weights = NULL;
zaxisptr->type = CDI_UNDEFID;
zaxisptr->ltype = 0;
zaxisptr->ltype2 = -1;
zaxisptr->positive = 0;
zaxisptr->direction = 0;
zaxisptr->prec = 0;
......@@ -578,6 +580,30 @@ int zaxisInqLtype(int zaxisID)
return (zaxisptr->ltype);
}
void zaxisDefLtype2(int zaxisID, int ltype2)