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

defineAttributes(): use cdf_put_att_float() for single precision float attributes

parent 4ba36f19
......@@ -620,7 +620,14 @@ void defineAttributes(int vlistID, int varID, int fileID, int ncvarID)
double *attflt = (double *)resizeBuf(&attBuf, &attBufSize, attSize);
vlistInqAttFlt(vlistID, varID, attname, attlen, attflt);
len = (size_t)attlen;
cdf_put_att_double(fileID, ncvarID, attname, atttype == DATATYPE_FLT32 ? NC_FLOAT : NC_DOUBLE, len, attflt);
if ( atttype == DATATYPE_FLT32 )
{
float attflt_sp[len];
for ( size_t i = 0; i < len; ++i ) attflt_sp[i] = attflt[i];
cdf_put_att_float(fileID, ncvarID, attname, NC_FLOAT, len, attflt_sp);
}
else
cdf_put_att_double(fileID, ncvarID, attname, atttype == DATATYPE_FLT32 ? NC_FLOAT : NC_DOUBLE, len, attflt);
}
}
free(attBuf);
......
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