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

cdfInqContents: skip time variable with type = NC_CHAR

parent ef7bff78
2008-08-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> 2008-08-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* add support for netCDF4 classic with deflate option * add support for netCDF4 classic with deflate option
* streamClose: use taxisDestroy to release memory
* cdfInqContents: skip time variable with type = NC_CHAR
* ptaxisCopy: don't overwrite item 'self' (bug fix)
* Version 1.2.0 released * Version 1.2.0 released
2008-04-08 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> 2008-04-08 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
...@@ -128,7 +128,7 @@ static int getFiletype(const char *filename, int *byteorder) ...@@ -128,7 +128,7 @@ static int getFiletype(const char *filename, int *byteorder)
if ( version <= 1 ) if ( version <= 1 )
{ {
filetype = FILETYPE_GRB; filetype = FILETYPE_GRB;
if ( CDI_Debug ) Message(func, "found GRIB file = %s, version %d", filename); if ( CDI_Debug ) Message(func, "found GRIB file = %s, version %d", filename, version);
} }
} }
else if ( strncmp(buffer, "CDF\001", 4) == 0 ) else if ( strncmp(buffer, "CDF\001", 4) == 0 )
...@@ -1184,6 +1184,11 @@ void streamClose(int streamID) ...@@ -1184,6 +1184,11 @@ void streamClose(int streamID)
stream_delete_entry(streamptr); stream_delete_entry(streamptr);
if ( vlistInqTaxis(vlistID) != -1 )
{
taxisDestroy(vlistInqTaxis(vlistID));
}
if ( vlistID != -1 ) if ( vlistID != -1 )
{ {
vlistDestroy(vlistID); vlistDestroy(vlistID);
......
...@@ -50,7 +50,6 @@ NCDIM; ...@@ -50,7 +50,6 @@ NCDIM;
typedef struct { typedef struct {
int ignore; int ignore;
int vartype;
int isvar; int isvar;
int islon; int islon;
int islat; int islat;
...@@ -3368,7 +3367,6 @@ int cdfInqContents(int streamID) ...@@ -3368,7 +3367,6 @@ int cdfInqContents(int streamID)
for ( ncvarid = 0; ncvarid < nvars; ncvarid++ ) for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
{ {
ncvars[ncvarid].ignore = FALSE; ncvars[ncvarid].ignore = FALSE;
ncvars[ncvarid].vartype = UNDEFID;
ncvars[ncvarid].isvar = UNDEFID; ncvars[ncvarid].isvar = UNDEFID;
ncvars[ncvarid].islon = FALSE; ncvars[ncvarid].islon = FALSE;
ncvars[ncvarid].islat = FALSE; ncvars[ncvarid].islat = FALSE;
...@@ -3932,7 +3930,9 @@ int cdfInqContents(int streamID) ...@@ -3932,7 +3930,9 @@ int cdfInqContents(int streamID)
else else
{ {
for ( ncvarid = 0; ncvarid < nvars; ncvarid++ ) for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
if ( ncvars[ncvarid].ndims == 1 && timedimid == ncvars[ncvarid].dimids[0] ) if ( ncvars[ncvarid].ndims == 1 &&
timedimid == ncvars[ncvarid].dimids[0] &&
ncvars[ncvarid].xtype != NC_CHAR )
{ {
streamptr->basetime.ncvarid = ncvarid; streamptr->basetime.ncvarid = ncvarid;
break; break;
......
...@@ -232,6 +232,8 @@ static TAXIS *taxis_new_entry(void) ...@@ -232,6 +232,8 @@ static TAXIS *taxis_new_entry(void)
if ( taxisptr ) taxis_init_entry(taxisptr); if ( taxisptr ) taxis_init_entry(taxisptr);
/* fprintf(stderr, "self: %d %p\n", taxisptr->self, taxisptr); */
return (taxisptr); return (taxisptr);
} }
...@@ -370,6 +372,14 @@ int taxisCreate(int taxistype) ...@@ -370,6 +372,14 @@ int taxisCreate(int taxistype)
*/ */
void taxisDestroy(int taxisID) void taxisDestroy(int taxisID)
{ {
static char func[] = "taxisDestroy";
TAXIS *taxisptr;
taxisptr = taxis_to_pointer(taxisID);
taxis_check_ptr(func, taxisptr);
taxis_delete_entry(taxisptr);
} }
...@@ -1113,5 +1123,19 @@ void ptaxisInit(TAXIS *taxisptr) ...@@ -1113,5 +1123,19 @@ void ptaxisInit(TAXIS *taxisptr)
void ptaxisCopy(TAXIS *dest, TAXIS *source) void ptaxisCopy(TAXIS *dest, TAXIS *source)
{ {
memcpy(dest, source, sizeof(TAXIS)); /* memcpy(dest, source, sizeof(TAXIS)); */
dest->used = source->used;
dest->type = source->type;
dest->vdate = source->vdate;
dest->vtime = source->vtime;
dest->rdate = source->rdate;
dest->rtime = source->rtime;
dest->calendar = source->calendar;
dest->unit = source->unit;
dest->numavg = source->numavg;
dest->has_bounds = source->has_bounds;
dest->vdate_lb = source->vdate_lb;
dest->vtime_lb = source->vtime_lb;
dest->vdate_ub = source->vdate_ub;
dest->vtime_ub = source->vtime_ub;
} }
...@@ -24,8 +24,8 @@ ZaxistypeEntry[] = { ...@@ -24,8 +24,8 @@ ZaxistypeEntry[] = {
{"lev", "hybrid_half", "level"}, {"lev", "hybrid_half", "level"},
{"lev", "pressure", "Pa"}, {"lev", "pressure", "Pa"},
{"height", "height", "m"}, {"height", "height", "m"},
{"depth", "depth below sea", "m"}, {"depth", "depth_below_sea", "m"},
{"depth", "depth below land", "cm"}, {"depth", "depth_below_land", "cm"},
{"lev", "isentropic", "K"}, {"lev", "isentropic", "K"},
{"lev", "trajectory", ""}, {"lev", "trajectory", ""},
{"alt", "altitude", "m"}, {"alt", "altitude", "m"},
...@@ -730,6 +730,7 @@ double zaxisInqLbound(int zaxisID, int index) ...@@ -730,6 +730,7 @@ double zaxisInqLbound(int zaxisID, int index)
zaxis_check_ptr(func, zaxisptr); zaxis_check_ptr(func, zaxisptr);
if ( zaxisptr->lbounds )
if ( index >= 0 && index < zaxisptr->size ) if ( index >= 0 && index < zaxisptr->size )
level = zaxisptr->lbounds[index]; level = zaxisptr->lbounds[index];
...@@ -747,6 +748,7 @@ double zaxisInqUbound(int zaxisID, int index) ...@@ -747,6 +748,7 @@ double zaxisInqUbound(int zaxisID, int index)
zaxis_check_ptr(func, zaxisptr); zaxis_check_ptr(func, zaxisptr);
if ( zaxisptr->ubounds )
if ( index >= 0 && index < zaxisptr->size ) if ( index >= 0 && index < zaxisptr->size )
level = zaxisptr->ubounds[index]; level = zaxisptr->ubounds[index];
...@@ -1063,10 +1065,13 @@ void zaxisDefLbounds(int zaxisID, double *lbounds) ...@@ -1063,10 +1065,13 @@ void zaxisDefLbounds(int zaxisID, double *lbounds)
size = zaxisptr->size; size = zaxisptr->size;
if ( CDI_Debug )
if ( zaxisptr->lbounds != NULL ) if ( zaxisptr->lbounds != NULL )
Warning(func, "Lbounds already defined for zaxisID = %d", zaxisID); Warning(func, "Lower bounds already defined for zaxisID = %d", zaxisID);
if ( zaxisptr->lbounds == NULL )
zaxisptr->lbounds = (double *) malloc(size*sizeof(double)); zaxisptr->lbounds = (double *) malloc(size*sizeof(double));
memcpy(zaxisptr->lbounds, lbounds, size*sizeof(double)); memcpy(zaxisptr->lbounds, lbounds, size*sizeof(double));
} }
...@@ -1083,10 +1088,13 @@ void zaxisDefUbounds(int zaxisID, double *ubounds) ...@@ -1083,10 +1088,13 @@ void zaxisDefUbounds(int zaxisID, double *ubounds)
size = zaxisptr->size; size = zaxisptr->size;
if ( CDI_Debug )
if ( zaxisptr->ubounds != NULL ) if ( zaxisptr->ubounds != NULL )
Warning(func, "Ubounds already defined for zaxisID = %d", zaxisID); Warning(func, "Upper bounds already defined for zaxisID = %d", zaxisID);
if ( zaxisptr->ubounds == NULL )
zaxisptr->ubounds = (double *) malloc(size*sizeof(double)); zaxisptr->ubounds = (double *) malloc(size*sizeof(double));
memcpy(zaxisptr->ubounds, ubounds, size*sizeof(double)); memcpy(zaxisptr->ubounds, ubounds, size*sizeof(double));
} }
...@@ -1103,10 +1111,13 @@ void zaxisDefWeights(int zaxisID, double *weights) ...@@ -1103,10 +1111,13 @@ void zaxisDefWeights(int zaxisID, double *weights)
size = zaxisptr->size; size = zaxisptr->size;
if ( CDI_Debug )
if ( zaxisptr->weights != NULL ) if ( zaxisptr->weights != NULL )
Warning(func, "Weights already defined for zaxisID = %d", zaxisID); Warning(func, "Weights already defined for zaxisID = %d", zaxisID);
if ( zaxisptr->weights == NULL )
zaxisptr->weights = (double *) malloc(size*sizeof(double)); zaxisptr->weights = (double *) malloc(size*sizeof(double));
memcpy(zaxisptr->weights, weights, size*sizeof(double)); memcpy(zaxisptr->weights, weights, size*sizeof(double));
} }
......
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