Skip to content

Commit

Permalink
#1421 Use double instead of float at getData
Browse files Browse the repository at this point in the history
  • Loading branch information
hsoh-u committed Dec 17, 2020
1 parent 23112c8 commit f3ecc35
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions met/src/libcode/vx_data2d_nccf/nccf_file.cc
Expand Up @@ -995,9 +995,9 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const
// get the data
int *i;
short *s;
double *d;
float *f;
const int plane_size = nx * ny;
float *f = new float[plane_size];
double *d = new double[plane_size];

size_t dim_size;
long offsets[dim_count];
Expand Down Expand Up @@ -1039,26 +1039,26 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const
case NcType::nc_SHORT:
s = new short[plane_size];
get_nc_data(v, s, lengths, offsets);
for (int x=0; x<plane_size; ++x) f[x] = (float)s[x];
for (int x=0; x<plane_size; ++x) d[x] = (double)s[x];
delete [] s;
break;

case NcType::nc_INT:
i = new int[plane_size];
get_nc_data(v, i, lengths, offsets);
for (int x=0; x<plane_size; ++x) f[x] = (float)i[x];
for (int x=0; x<plane_size; ++x) d[x] = (double)i[x];
delete [] i;
break;

case NcType::nc_FLOAT:
f = new float[plane_size];
get_nc_data(v, f, lengths, offsets);
for (int x=0; x<plane_size; ++x) d[x] = (double)f[x];
delete [] f;
break;

case NcType::nc_DOUBLE:
d = new double[plane_size];
get_nc_data(v, d, lengths, offsets);
for (int x=0; x<plane_size; ++x) f[x] = (float)d[x];
delete [] d;
break;

default:
Expand All @@ -1077,7 +1077,7 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const
if (swap_to_north) y_offset = ny - 1 - y;

for (int x = 0; x< nx; ++x) {
float value = f[offset++];
double value = d[offset++];

if( is_eq(value, missing_value) || is_eq(value, fill_value) ) {
value = bad_data_double;
Expand All @@ -1095,7 +1095,7 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const
y_offset = y;
if (swap_to_north) y_offset = ny - 1 - y;

float value = f[offset++];
double value = d[offset++];

if( is_eq(value, missing_value) || is_eq(value, fill_value) ) {
value = bad_data_double;
Expand All @@ -1108,7 +1108,7 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const
} // for x
}

delete [] f;
delete [] d;

// done
mlog << Debug(6) << method_name << "took "
Expand Down

0 comments on commit f3ecc35

Please sign in to comment.