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

time axis: added support for NC_FLOAT.

parent 2b02a478
2016-09-19 Uwe Schulzweida
* time axis: added support for NC_FLOAT
2016-09-15 Uwe Schulzweida 2016-09-15 Uwe Schulzweida
* zaxis: added support for user defined attributes * zaxis: added support for user defined attributes
......
...@@ -3809,8 +3809,12 @@ int cdfInqContents(stream_t *streamptr) ...@@ -3809,8 +3809,12 @@ int cdfInqContents(stream_t *streamptr)
{ {
taxis_t *taxis = &streamptr->tsteps[0].taxis; taxis_t *taxis = &streamptr->tsteps[0].taxis;
ptaxisDefName(taxis, ncvars[nctimevarid].name); ptaxisDefName(taxis, ncvars[nctimevarid].name);
if ( ncvars[nctimevarid].longname[0] ) if ( ncvars[nctimevarid].longname[0] )
ptaxisDefLongname(taxis, ncvars[nctimevarid].longname); ptaxisDefLongname(taxis, ncvars[nctimevarid].longname);
int datatype = (ncvars[nctimevarid].xtype == NC_FLOAT) ? DATATYPE_FLT32 : DATATYPE_FLT64;
ptaxisDefDatatype(taxis, datatype);
} }
if ( nctimevarid != UNDEFID ) if ( nctimevarid != UNDEFID )
......
...@@ -246,7 +246,9 @@ void cdfDefTime(stream_t* streamptr) ...@@ -246,7 +246,9 @@ void cdfDefTime(stream_t* streamptr)
cdf_def_dim(fileID, taxis_name, NC_UNLIMITED, &time_dimid); cdf_def_dim(fileID, taxis_name, NC_UNLIMITED, &time_dimid);
streamptr->basetime.ncdimid = time_dimid; streamptr->basetime.ncdimid = time_dimid;
cdf_def_var(fileID, taxis_name, NC_DOUBLE, 1, &time_dimid, &time_varid); nc_type xtype = (taxis->datatype == DATATYPE_FLT32) ? NC_FLOAT : NC_DOUBLE;
cdf_def_var(fileID, taxis_name, xtype, 1, &time_dimid, &time_varid);
streamptr->basetime.ncvarid = time_varid; streamptr->basetime.ncvarid = time_varid;
...@@ -291,7 +293,7 @@ void cdfDefTime(stream_t* streamptr) ...@@ -291,7 +293,7 @@ void cdfDefTime(stream_t* streamptr)
{ {
int leadtimeid; int leadtimeid;
cdf_def_var(fileID, "leadtime", NC_DOUBLE, 1, &time_dimid, &leadtimeid); cdf_def_var(fileID, "leadtime", xtype, 1, &time_dimid, &leadtimeid);
streamptr->basetime.leadtimeid = leadtimeid; streamptr->basetime.leadtimeid = leadtimeid;
......
...@@ -151,6 +151,7 @@ void taxisDefaultValue(taxis_t* taxisptr) ...@@ -151,6 +151,7 @@ void taxisDefaultValue(taxis_t* taxisptr)
{ {
taxisptr->self = CDI_UNDEFID; taxisptr->self = CDI_UNDEFID;
taxisptr->used = false; taxisptr->used = false;
taxisptr->datatype = DATATYPE_FLT64;
taxisptr->type = DefaultTimeType; taxisptr->type = DefaultTimeType;
taxisptr->vdate = 0; taxisptr->vdate = 0;
taxisptr->vtime = 0; taxisptr->vtime = 0;
...@@ -878,6 +879,12 @@ taxis_t *taxisPtr(int taxisID) ...@@ -878,6 +879,12 @@ taxis_t *taxisPtr(int taxisID)
} }
void ptaxisDefDatatype(taxis_t *taxisptr, int datatype)
{
taxisptr->datatype = datatype;
}
void ptaxisDefName(taxis_t *taxisptr, const char *name) void ptaxisDefName(taxis_t *taxisptr, const char *name)
{ {
if ( name ) if ( name )
...@@ -1347,6 +1354,7 @@ void ptaxisCopy(taxis_t *dest, taxis_t *source) ...@@ -1347,6 +1354,7 @@ void ptaxisCopy(taxis_t *dest, taxis_t *source)
/* memcpy(dest, source, sizeof(taxis_t)); */ /* memcpy(dest, source, sizeof(taxis_t)); */
dest->used = source->used; dest->used = source->used;
dest->datatype = source->datatype;
dest->type = source->type; dest->type = source->type;
dest->vdate = source->vdate; dest->vdate = source->vdate;
dest->vtime = source->vtime; dest->vtime = source->vtime;
......
...@@ -13,6 +13,7 @@ typedef struct { ...@@ -13,6 +13,7 @@ typedef struct {
int self; int self;
bool used; bool used;
short has_bounds; short has_bounds;
int datatype; // datatype
int type; // time type int type; // time type
int vdate; // verification date int vdate; // verification date
int vtime; // verification time int vtime; // verification time
...@@ -30,8 +31,8 @@ typedef struct { ...@@ -30,8 +31,8 @@ typedef struct {
int vtime_ub; // upper bounds of vtime int vtime_ub; // upper bounds of vtime
int fc_unit; // forecast time unit int fc_unit; // forecast time unit
double fc_period; // forecast time period double fc_period; // forecast time period
char* name; char *name;
char* longname; char *longname;
} }
taxis_t; taxis_t;
...@@ -44,6 +45,7 @@ double cdiEncodeTimeval(int date, int time, taxis_t* taxis); ...@@ -44,6 +45,7 @@ double cdiEncodeTimeval(int date, int time, taxis_t* taxis);
void timeval2vtime(double timevalue, taxis_t* taxis, int* vdate, int* vtime); void timeval2vtime(double timevalue, taxis_t* taxis, int* vdate, int* vtime);
double vtime2timeval(int vdate, int vtime, taxis_t *taxis); double vtime2timeval(int vdate, int vtime, taxis_t *taxis);
void ptaxisDefDatatype(taxis_t *taxisptr, int datatype);
void ptaxisDefName(taxis_t *taxisptr, const char *name); void ptaxisDefName(taxis_t *taxisptr, const char *name);
void ptaxisDefLongname(taxis_t *taxisptr, const char *name); void ptaxisDefLongname(taxis_t *taxisptr, const char *name);
void taxisDestroyKernel(taxis_t *taxisptr); void taxisDestroyKernel(taxis_t *taxisptr);
......
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