Commit 91ee91d5 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced zaxisInqUnits()/zaxisDefUnits() by cdiInqKeyString()/cdiDefKeyString() with CDI_KEY_UNITS.

parent 33b3111c
......@@ -31,7 +31,7 @@ int main(void)
// Create a pressure level Z-axis
zaxisID2 = zaxisCreate(ZAXIS_DEPTH_BELOW_LAND, nlev);
zaxisDefLevels(zaxisID2, levs);
zaxisDefUnits(zaxisID2, "m");
cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, "m");
// Create a variable list
vlistID = vlistCreate();
......
......@@ -1855,7 +1855,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
Message("Changed zaxis type from %s to %s", zaxisNamePtr(zaxistype), zaxisNamePtr(ZAXIS_PRESSURE));
zaxistype = ZAXIS_PRESSURE;
zaxisChangeType(zaxisID, zaxistype);
zaxisDefUnits(zaxisID, "Pa");
cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, "Pa");
}
ISEC2_NumVCP = 0;
......@@ -1915,7 +1915,8 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
double level = zaxisInqLevel(zaxisID, levelID);
if ( level < 0 ) Warning("Pressure level of %f Pa is below zero!", level);
zaxisInqUnits(zaxisID, units);
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units, &length);
if ( units[0] && (units[0] != 'P') | (units[1] != 'a') ) level *= 100;
double dum;
......@@ -1931,7 +1932,8 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
{
double level = zaxisInqLevel(zaxisID, levelID);
zaxisInqUnits(zaxisID, units);
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units, &length);
if ( units[1] == 'm' && !units[2] )
{
// clang-format off
......@@ -1956,7 +1958,8 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
}
case ZAXIS_DEPTH_BELOW_LAND:
{
zaxisInqUnits(zaxisID, units);
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units, &length);
double factor = 100; // default: meter
// clang-format off
......
......@@ -2413,7 +2413,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int zaxisID, int levelI
Message("Changed zaxis type from %s to %s", zaxisNamePtr(zaxistype), zaxisNamePtr(ZAXIS_PRESSURE));
zaxistype = ZAXIS_PRESSURE;
zaxisChangeType(zaxisID, zaxistype);
zaxisDefUnits(zaxisID, "Pa");
cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, "Pa");
}
long grib_ltype = (editionNumber <= 1) ? zaxisTypeToGrib1ltype(zaxistype) : zaxisTypeToGrib2ltype(zaxistype);
......@@ -2432,7 +2432,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int zaxisID, int levelI
if ( zaxistype == ZAXIS_HEIGHT )
{
double sf = 1;
zaxisInqUnits(zaxisID, units);
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units, &length);
if ( units[1] == 'm' && !units[2] )
{
if ( units[0] == 'c' ) sf = 0.01;
......@@ -2514,7 +2515,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int zaxisID, int levelI
{
if ( level < 0 ) Warning("Pressure level of %f Pa is below zero!", level);
zaxisInqUnits(zaxisID, units);
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units, &length);
if ( units[0] && (units[0] != 'P') | (units[1] != 'a') )
{
level *= 100;
......@@ -2553,7 +2555,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int zaxisID, int levelI
}
case ZAXIS_DEPTH_BELOW_LAND:
{
zaxisInqUnits(zaxisID, units);
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units, &length);
double sf; //scalefactor
if ( editionNumber <= 1 )
......
......@@ -331,7 +331,7 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
zaxisNamePtr(leveltype), zaxisNamePtr(ZAXIS_PRESSURE));
leveltype = ZAXIS_PRESSURE;
zaxisChangeType(zaxisID, leveltype);
zaxisDefUnits(zaxisID, "Pa");
cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, "Pa");
}
/* IEG_G_NumVCP(gdb) = 0; */
......@@ -372,16 +372,16 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
}
case ZAXIS_PRESSURE:
{
double dum;
char units[CDI_MAX_NAME];
level = zaxisInqLevel(zaxisID, levelID);
if ( level < 0 ) Warning("pressure level of %f Pa is below 0.", level);
zaxisInqUnits(zaxisID, units);
char units[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units, &length);
if ( memcmp(units, "hPa", 3) == 0 || memcmp(units, "mb",2 ) == 0 )
level = level*100;
double dum;
int ilevel = (int) level;
if ( level < 32768 && (level < 100 || modf(level/100, &dum) > 0) )
pdbDefLevel(pdb, IEG_LTYPE_99, 0, ilevel);
......
......@@ -855,13 +855,14 @@ bool zaxisCompare(int zaxisID, int zaxistype, int nlevels, bool lbounds, const d
{
char zlongname[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, zlongname, &length)
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, zlongname, &length);
if ( zlongname[0] && (strcmp(longname, zlongname) != 0) ) differ = true;
}
if ( units && units[0] )
{
char zunits[CDI_MAX_NAME]; zunits[0] = 0;
zaxisInqUnits(zaxisID, zunits);
char zunits[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, zunits, &length);
if ( zunits[0] && (strcmp(units, zunits) != 0) ) differ = true;
}
}
......@@ -974,7 +975,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, c
if ( name && name[0] ) cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_NAME, name);
if ( longname && longname[0] ) cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, longname);
if ( units && units[0] ) zaxisDefUnits(zaxisID, units);
if ( units && units[0] ) cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, units);
zaxisDefDatatype(zaxisID, prec);
cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_TYPEOFFIRSTFIXEDSURFACE, ltype1);
if ( ltype2 != -1 ) cdiDefKeyInt(zaxisID, CDI_GLOBAL, CDI_KEY_TYPEOFSECONDFIXEDSURFACE, ltype2);
......
......@@ -696,8 +696,10 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_LONGNAME, ctemp, &length);
cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_LONGNAME, ctemp);
zaxisInqUnits(zaxisID, ctemp);
zaxisDefUnits(zaxisID2, ctemp);
length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, ctemp, &length);
cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_UNITS, ctemp);
zaxisDefDatatype(zaxisID2, zaxisInqDatatype(zaxisID));
zaxisDefPositive(zaxisID2, zaxisInqPositive(zaxisID));
......
......@@ -194,7 +194,7 @@ int zaxisCreate_(int zaxistype, int size, int id)
const int zaxisID = zaxisptr->self;
cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_NAME, ZaxistypeEntry[zaxistype].name);
if ( zaxistype != ZAXIS_GENERIC ) zaxisDefLongname(zaxisID, ZaxistypeEntry[zaxistype].longname);
zaxisDefUnits(zaxisID, ZaxistypeEntry[zaxistype].units);
cdiDefKeyString(zaxisID, CDI_GLOBAL, CDI_KEY_UNITS, ZaxistypeEntry[zaxistype].units);
const char *stdname = ZaxistypeEntry[zaxistype].stdname;
if ( *stdname )
......
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