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

Added attribute positive on netCDF zaxes

parent 82d66f71
2011-04-28 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> 2011-04-28 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Added standard_name on netCDF zaxes * Added attribute standard_name on netCDF zaxes [request: Karin Meier-Fleischer]
* Added attribute positive on netCDF zaxes [request: Karin Meier-Fleischer]
2011-04-27 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> 2011-04-27 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
...@@ -733,6 +733,8 @@ void zaxisInqUnits(int zaxisID, char *units); ...@@ -733,6 +733,8 @@ void zaxisInqUnits(int zaxisID, char *units);
void zaxisDefPrec(int zaxisID, int prec); void zaxisDefPrec(int zaxisID, int prec);
int zaxisInqPrec(int zaxisID); int zaxisInqPrec(int zaxisID);
int zaxisInqPositive(int zaxisID);
void zaxisDefLtype(int zaxisID, int ltype); void zaxisDefLtype(int zaxisID, int ltype);
int zaxisInqLtype(int zaxisID); int zaxisInqLtype(int zaxisID);
......
...@@ -2125,6 +2125,7 @@ void cdfDefZaxis(int streamID, int zaxisID) ...@@ -2125,6 +2125,7 @@ void cdfDefZaxis(int streamID, int zaxisID)
int vlistID; int vlistID;
int zaxisindex; int zaxisindex;
int xtype = NC_DOUBLE; int xtype = NC_DOUBLE;
int positive;
stream_t *streamptr; stream_t *streamptr;
streamptr = stream_to_pointer(streamID); streamptr = stream_to_pointer(streamID);
...@@ -2287,6 +2288,18 @@ void cdfDefZaxis(int streamID, int zaxisID) ...@@ -2287,6 +2288,18 @@ void cdfDefZaxis(int streamID, int zaxisID)
if ( (len = strlen(stdname)) ) if ( (len = strlen(stdname)) )
cdf_put_att_text(fileID, ncvarid, "standard_name", len, stdname); cdf_put_att_text(fileID, ncvarid, "standard_name", len, stdname);
positive = zaxisInqPositive(zaxisID);
if ( positive == 1 )
{
strcpy(tmpname, "up");
cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
}
else if ( positive == 2 )
{
strcpy(tmpname, "down");
cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
}
cdf_put_att_text(fileID, ncvarid, "axis", 1, "Z"); cdf_put_att_text(fileID, ncvarid, "axis", 1, "Z");
if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) ) if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "stream_int.h" #include "stream_int.h"
#define LevelDown 0
#define LevelUp 1 #define LevelUp 1
#define LevelDown 2
static struct { static struct {
...@@ -195,6 +195,7 @@ void zaxis_init_entry(zaxis_t *zaxisptr) ...@@ -195,6 +195,7 @@ void zaxis_init_entry(zaxis_t *zaxisptr)
zaxisptr->name[0] = 0; zaxisptr->name[0] = 0;
zaxisptr->longname[0] = 0; zaxisptr->longname[0] = 0;
zaxisptr->stdname[0] = 0;
zaxisptr->units[0] = 0; zaxisptr->units[0] = 0;
zaxisptr->vals = NULL; zaxisptr->vals = NULL;
zaxisptr->ubounds = NULL; zaxisptr->ubounds = NULL;
...@@ -202,7 +203,8 @@ void zaxis_init_entry(zaxis_t *zaxisptr) ...@@ -202,7 +203,8 @@ void zaxis_init_entry(zaxis_t *zaxisptr)
zaxisptr->weights = NULL; zaxisptr->weights = NULL;
zaxisptr->type = CDI_UNDEFID; zaxisptr->type = CDI_UNDEFID;
zaxisptr->ltype = 0; zaxisptr->ltype = 0;
zaxisptr->direction = CDI_UNDEFID; zaxisptr->positive = 0;
zaxisptr->direction = 0;
zaxisptr->prec = 0; zaxisptr->prec = 0;
zaxisptr->size = 0; zaxisptr->size = 0;
zaxisptr->vctsize = 0; zaxisptr->vctsize = 0;
...@@ -369,6 +371,8 @@ int zaxisCreate(int zaxistype, int size) ...@@ -369,6 +371,8 @@ int zaxisCreate(int zaxistype, int size)
if ( *ZaxistypeEntry[zaxistype].stdname ) if ( *ZaxistypeEntry[zaxistype].stdname )
strcpy(zaxisptr->stdname, ZaxistypeEntry[zaxistype].stdname); strcpy(zaxisptr->stdname, ZaxistypeEntry[zaxistype].stdname);
zaxisptr->positive = ZaxistypeEntry[zaxistype].positive;
vals = (double *) malloc(size*sizeof(double)); vals = (double *) malloc(size*sizeof(double));
for ( ilev = 0; ilev < size; ilev++ ) for ( ilev = 0; ilev < size; ilev++ )
...@@ -620,6 +624,18 @@ int zaxisInqPrec(int zaxisID) ...@@ -620,6 +624,18 @@ int zaxisInqPrec(int zaxisID)
} }
int zaxisInqPositive(int zaxisID)
{
zaxis_t *zaxisptr;
zaxisptr = zaxis_to_pointer(zaxisID);
zaxis_check_ptr(zaxisID, zaxisptr);
return (zaxisptr->positive);
}
void zaxisDefLtype(int zaxisID, int ltype) void zaxisDefLtype(int zaxisID, int ltype)
{ {
zaxis_t *zaxisptr; zaxis_t *zaxisptr;
...@@ -978,7 +994,7 @@ void cdiCheckZaxis(int zaxisID) ...@@ -978,7 +994,7 @@ void cdiCheckZaxis(int zaxisID)
if ( size > 1 ) if ( size > 1 )
{ {
/* check direction */ /* check direction */
if ( zaxisptr->direction == CDI_UNDEFID ) if ( ! zaxisptr->direction )
{ {
found = 0; found = 0;
for ( i = 1; i < size; i++ ) for ( i = 1; i < size; i++ )
...@@ -1001,9 +1017,9 @@ void cdiCheckZaxis(int zaxisID) ...@@ -1001,9 +1017,9 @@ void cdiCheckZaxis(int zaxisID)
} }
} }
/* check consistent */ /* check consistent */
if ( zaxisptr->direction == CDI_UNDEFID ) if ( !zaxisptr->direction )
{ {
Warning("direction undefined for zaxisID %d", zaxisID); Warning("Direction undefined for zaxisID %d", zaxisID);
} }
} }
} }
......
Supports Markdown
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