Commit 851b2bc8 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdfGetAttDouble: convert to double only if attr type is not equal NC_CHAR

parent 612ddbfa
......@@ -382,11 +382,18 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin
static
void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double *attdouble)
{
size_t nc_attlen;
double *pdoubleatt;
nc_type atttype;
size_t nc_attlen = 0;
*attdouble = 0;
cdf_inq_atttype(fileID, ncvarid, attname, &atttype);
cdf_inq_attlen(fileID, ncvarid, attname, &nc_attlen);
if ( atttype != NC_CHAR )
{
double *pdoubleatt = NULL;
if ( (int)nc_attlen > attlen )
pdoubleatt = (double *) malloc(nc_attlen * sizeof (double));
else
......@@ -399,6 +406,7 @@ void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double
memcpy(attdouble, pdoubleatt, (size_t)attlen * sizeof (double));
free(pdoubleatt);
}
}
}
static
......
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