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

netCDF: added support for zaxis attribute: positive

parent cc614682
......@@ -3,6 +3,10 @@
* Version 1.6.2 released
* using CGRIBEX library version 1.6.2
2013-07-16 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* netCDF: added support for zaxis attribute: positive
2013-07-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Version 1.6.1.1 released (merged branche cdi-pio to trunk cdi)
......
......@@ -852,6 +852,7 @@ void zaxisInqUnits(int zaxisID, char *units);
void zaxisDefPrec(int zaxisID, int prec);
int zaxisInqPrec(int zaxisID);
void zaxisDefPositive(int zaxisID, int positive);
int zaxisInqPositive(int zaxisID);
void zaxisDefLtype(int zaxisID, int ltype);
......
......@@ -42,6 +42,9 @@ void cdfDefLocalAtts(stream_t *streamptr);
#define Z_AXIS 3
#define T_AXIS 4
#define POSITIVE_UP 1
#define POSITIVE_DOWN 2
typedef struct {
int ncvarid;
int dimtype;
......@@ -2343,12 +2346,12 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
cdf_put_att_text(fileID, ncvarid, "units", len, units);
positive = zaxisInqPositive(zaxisID);
if ( positive == 1 )
if ( positive == POSITIVE_UP )
{
strcpy(tmpname, "up");
cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
}
else if ( positive == 2 )
else if ( positive == POSITIVE_DOWN )
{
strcpy(tmpname, "down");
cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
......@@ -4879,8 +4882,8 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
cdfGetAttText(ncid, ncvarid, attname, attstringlen-1, attstring);
strtolower(attstring);
if ( memcmp(attstring, "down", 4) == 0 ) ncvars[ncvarid].positive = -1;
else if ( memcmp(attstring, "up", 2) == 0 ) ncvars[ncvarid].positive = 1;
if ( memcmp(attstring, "down", 4) == 0 ) ncvars[ncvarid].positive = POSITIVE_DOWN;
else if ( memcmp(attstring, "up", 2) == 0 ) ncvars[ncvarid].positive = POSITIVE_UP;
if ( ncvars[ncvarid].ndims == 1 )
{
......@@ -6011,6 +6014,7 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
int zaxisindex;
int zprec;
int nbdims, nvertex, nlevel;
int positive = 0;
char *pname, *plongname, *punits;
for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
......@@ -6026,6 +6030,8 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
double *ubounds = NULL;
int zaxisType;
positive = 0;
ndims = ncvars[ncvarid].ndims;
for ( i = 0; i < ndims; i++ )
{
......@@ -6053,6 +6059,7 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
if ( zvarid != UNDEFID )
{
positive = ncvars[zvarid].positive;
pname = ncvars[zvarid].name;
plongname = ncvars[zvarid].longname;
punits = ncvars[zvarid].units;
......@@ -6119,6 +6126,9 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
ncvars[ncvarid].zaxisID = varDefZaxis(vlistID, zaxisType, (int) zsize, zvar, with_bounds, lbounds, ubounds,
vctsize, vct, pname, plongname, punits, zprec, 1, 0);
if ( positive > 0 ) zaxisDefPositive(ncvars[ncvarid].zaxisID, positive);
free(zvar);
free(lbounds);
free(ubounds);
......
......@@ -542,6 +542,24 @@ int zaxisInqPrec(int zaxisID)
}
void zaxisDefPositive(int zaxisID, int positive)
{
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->positive = positive;
}
int zaxisInqPositive(int zaxisID)
{
zaxis_t *zaxisptr;
......
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