Commit 16dba4ed authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replace fabs() by std::fabs().

parent b0df6c2f
......@@ -3079,7 +3079,7 @@ check_and_gen_bounds(int gridID, int nbounds, int length, double *coord_vals, do
static double
lonbnds_mids_trans_check(double value1, double value2)
{
if (fabs(value1 - value2) < 180.0)
if (std::fabs(value1 - value2) < 180.0)
return (value1 + value2) * 0.5;
else
{
......@@ -3093,7 +3093,7 @@ lonbnds_mids_trans_check(double value1, double value2)
static double
lonbnds_bnds_trans_check(double value1, double value2)
{
if (fabs(value1 - value2) < 180)
if (std::fabs(value1 - value2) < 180)
{
if (2 * value1 < value2)
return (2 * value1 - value2 + 360.0);
......
......@@ -155,7 +155,7 @@ cmor_check_prep(CmorVar &var, long gridsize, double missval, double *array)
aval = array[i];
if (!DBL_IS_EQUAL(aval, missval))
{
amean += fabs(aval);
amean += std::fabs(aval);
nvals++;
}
}
......
......@@ -199,14 +199,14 @@ Change(void *process)
int nfound = 0;
for (i = 0; i < nch; i += 2)
for (k = 0; k < nlevs; k++)
if (fabs(levels[k] - chlevels[i]) < 0.0001) nfound++;
if (std::fabs(levels[k] - chlevels[i]) < 0.0001) nfound++;
if (nfound)
{
int zaxisID2 = zaxisDuplicate(zaxisID1);
for (i = 0; i < nch; i += 2)
for (k = 0; k < nlevs; k++)
if (fabs(levels[k] - chlevels[i]) < 0.001) newlevels[k] = chlevels[i + 1];
if (std::fabs(levels[k] - chlevels[i]) < 0.001) newlevels[k] = chlevels[i + 1];
zaxisDefLevels(zaxisID2, &newlevels[0]);
vlistChangeZaxis(vlistID2, zaxisID1, zaxisID2);
......@@ -244,13 +244,13 @@ Change(void *process)
zaxisInqLevels(zaxisID1, &levels[0]);
int nfound = 0;
for (k = 0; k < nlevs; k++)
if (fabs(levels[k] - chlevels[0]) < 0.0001) nfound++;
if (std::fabs(levels[k] - chlevels[0]) < 0.0001) nfound++;
if (nfound)
{
int zaxisID2 = zaxisDuplicate(zaxisID1);
for (k = 0; k < nlevs; k++)
if (fabs(levels[k] - chlevels[0]) < 0.001) levels[k] = chlevels[1];
if (std::fabs(levels[k] - chlevels[0]) < 0.001) levels[k] = chlevels[1];
zaxisDefLevels(zaxisID2, &levels[0]);
vlistChangeVarZaxis(vlistID2, varID, zaxisID2);
......
......@@ -58,9 +58,9 @@ cmpxy_lt(const void *a, const void *b)
const double y2 = ((const xyinfoType *) b)->y;
int cmp = 0;
if (y1 < y2 || (!(fabs(y1 - y2) > 0) && x1 < x2))
if (y1 < y2 || (!(std::fabs(y1 - y2) > 0) && x1 < x2))
cmp = -1;
else if (y1 > y2 || (!(fabs(y1 - y2) > 0) && x1 > x2))
else if (y1 > y2 || (!(std::fabs(y1 - y2) > 0) && x1 > x2))
cmp = 1;
return cmp;
......@@ -75,9 +75,9 @@ cmpxy_gt(const void *a, const void *b)
const double y2 = ((const xyinfoType *) b)->y;
int cmp = 0;
if (y1 > y2 || (!(fabs(y1 - y2) > 0) && x1 < x2))
if (y1 > y2 || (!(std::fabs(y1 - y2) > 0) && x1 < x2))
cmp = -1;
else if (y1 < y2 || (!(fabs(y1 - y2) > 0) && x1 > x2))
else if (y1 < y2 || (!(std::fabs(y1 - y2) > 0) && x1 > x2))
cmp = 1;
return cmp;
......
......@@ -210,7 +210,7 @@ Diff(void *process)
}
else if (!DBL_IS_EQUAL(array1[i], missval1) && !DBL_IS_EQUAL(array2[i], missval2))
{
absdiff = fabs(array1[i] - array2[i]);
absdiff = std::fabs(array1[i] - array2[i]);
if (absdiff > 0.) ndiff++;
absm = cdo::max(absm, absdiff);
......@@ -220,7 +220,7 @@ Diff(void *process)
else if (IS_EQUAL(array1[i] * array2[i], 0.))
zero = true;
else
relm = cdo::max(relm, absdiff / cdo::max(fabs(array1[i]), fabs(array2[i])));
relm = cdo::max(relm, absdiff / cdo::max(std::fabs(array1[i]), std::fabs(array2[i])));
}
else if ((DBL_IS_EQUAL(array1[i], missval1) && !DBL_IS_EQUAL(array2[i], missval2))
|| (!DBL_IS_EQUAL(array1[i], missval1) && DBL_IS_EQUAL(array2[i], missval2)))
......
......@@ -89,7 +89,7 @@ genGridIndex(int gridID1, int gridID2, int *index)
for (int i2 = 0; i2 < nlat2; i2++)
{
for (i1 = 0; i1 < nlat1; i1++)
if (fabs(yvals2[i2] - yvals1[i1]) < 0.001) break;
if (std::fabs(yvals2[i2] - yvals1[i1]) < 0.001) break;
yindex[i2] = (i1 == nlat1) ? -1 : i1;
}
......@@ -97,19 +97,19 @@ genGridIndex(int gridID1, int gridID2, int *index)
for (int i2 = 0; i2 < nlon2; i2++)
{
for (i1 = 0; i1 < nlon1; i1++)
if (fabs(xvals2[i2] - xvals1[i1]) < 0.001) break;
if (std::fabs(xvals2[i2] - xvals1[i1]) < 0.001) break;
if (i1 == nlon1)
{
if (xvals2[i2] < 0)
{
for (i1 = 0; i1 < nlon1; i1++)
if (fabs(xvals2[i2] + 360 - xvals1[i1]) < 0.001) break;
if (std::fabs(xvals2[i2] + 360 - xvals1[i1]) < 0.001) break;
}
else if (xvals2[i2] > 180)
{
for (i1 = 0; i1 < nlon1; i1++)
if (fabs(xvals2[i2] - 360 - xvals1[i1]) < 0.001) break;
if (std::fabs(xvals2[i2] - 360 - xvals1[i1]) < 0.001) break;
}
}
......
......@@ -458,7 +458,7 @@ Ensval(void *process)
osum += brs_o[k];
}
if (fabs(osum - 1) > 1.e-06 || fabs(gsum - 1) > 1.e-06)
if (std::fabs(osum - 1) > 1.e-06 || std::fabs(gsum - 1) > 1.e-06)
{
cdoAbort("Internal error - normalization constraint of problem not fulfilled");
cdoAbort("This is likely due to missing values");
......
......@@ -155,7 +155,7 @@ flt2ibm(float x, unsigned char *ibm)
int sign, exp, i;
double mant;
if (!(fabs((double) x) > 0))
if (!(std::fabs((double) x) > 0))
{
ibm[0] = ibm[1] = ibm[2] = ibm[3] = 0;
return 0;
......
......@@ -206,7 +206,7 @@ genBoxGridCurv2D(int gridID1, size_t xinc, size_t yinc, int gridID2)
xvals2[g2_add] = xvals1[g1_add] / area_norm;
yvals2[g2_add] = yvals1[g1_add] / area_norm;
}
else if (fabs(xvals1[g1_add] - xvals2_0) > 270.)
else if (std::fabs(xvals1[g1_add] - xvals2_0) > 270.)
{
if ((xvals1[g1_add] - xvals2_0) > 270.)
xvals2[g2_add] += (xvals1[g1_add] - 360.) / area_norm;
......
......@@ -117,7 +117,7 @@ boundbox_from_corners1r(long ic, long nc, const double *restrict corner_lon, con
}
/*
if ( fabs(bound_box[3] - bound_box[2]) > PI )
if ( std::fabs(bound_box[3] - bound_box[2]) > PI )
{
bound_box[2] = 0;
bound_box[3] = PI2;
......
......@@ -84,7 +84,7 @@ y_is_gauss(double *gridyvals, int ysize)
for (i = 0; i < (int) ysize; i++) yvals[i] = asin(yvals[i]) / M_PI * 180.0;
for (i = 0; i < (int) ysize; i++)
if (fabs(yvals[i] - gridyvals[i]) > ((yvals[0] - yvals[1]) / 500)) break;
if (std::fabs(yvals[i] - gridyvals[i]) > ((yvals[0] - yvals[1]) / 500)) break;
if (i == (int) ysize) lgauss = TRUE;
......@@ -92,7 +92,7 @@ y_is_gauss(double *gridyvals, int ysize)
if (lgauss == FALSE)
{
for (i = 0; i < (int) ysize; i++)
if (fabs(yvals[i] - gridyvals[ysize - i - 1]) > ((yvals[0] - yvals[1]) / 500)) break;
if (std::fabs(yvals[i] - gridyvals[ysize - i - 1]) > ((yvals[0] - yvals[1]) / 500)) break;
if (i == (int) ysize) lgauss = TRUE;
}
......
......@@ -57,7 +57,7 @@ ReadCoords(double *xvals, double *yvals, const char *polyfile, FILE *fp)
double xcoord = strtod(linep, &linep);
if (!(fabs(xcoord) > 0)) jumpedlines++;
if (!(std::fabs(xcoord) > 0)) jumpedlines++;
while (((isdigit((int) *linep) == FALSE) && (*linep != '-')) && (i < 64))
{
......
......@@ -156,7 +156,7 @@ Math(void *process)
switch (operfunc)
{
case ABS:
for (i = 0; i < gridsize; i++) array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : fabs(array1[i]);
for (i = 0; i < gridsize; i++) array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : std::fabs(array1[i]);
break;
case FINT:
for (i = 0; i < gridsize; i++) array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : (int) (array1[i]);
......
......@@ -88,7 +88,7 @@ rotate_uv(double *u_i, double *v_j, int ix, int iy, double *lon, double *lat, do
dist_i = sqrt(dlon_i * dlon_i + dlat_i * dlat_i);
dist_j = sqrt(dlon_j * dlon_j + dlat_j * dlat_j);
if (fabs(dist_i) > 0 && fabs(dist_j) > 0)
if (std::fabs(dist_i) > 0 && std::fabs(dist_j) > 0)
{
u_lon[IX2D(j, i, ix)] /= dist_i;
v_lat[IX2D(j, i, ix)] /= dist_j;
......
......@@ -119,7 +119,7 @@ rotate_uv2(double *u_i, double *v_j, int ix, int iy, double *lon, double *lat, d
dist_i = sqrt(dlon_i * dlon_i + dlat_i * dlat_i);
dist_j = sqrt(dlon_j * dlon_j + dlat_j * dlat_j);
if (fabs(dist_i) > 0 && fabs(dist_j) > 0)
if (std::fabs(dist_i) > 0 && std::fabs(dist_j) > 0)
{
u_lon[IX2D(j, i, ix)] /= dist_i;
v_lat[IX2D(j, i, ix)] /= dist_j;
......
......@@ -543,7 +543,7 @@ Outputgmt(void *process)
if (alpha[IX2D(j, i, nlon)] < 0) alpha[IX2D(j, i, nlon)] += 360;
if (alpha[IX2D(j, i, nlon)] > 360) alpha[IX2D(j, i, nlon)] -= 360;
if (fabs(auv[IX2D(j, i, nlon)]) > 0)
if (std::fabs(auv[IX2D(j, i, nlon)]) > 0)
fprintf(stdout, " %g %g %g %g\n", grid_center_lon[IX2D(j, i, nlon)], grid_center_lat[IX2D(j, i, nlon)],
alpha[IX2D(j, i, nlon)], auv[IX2D(j, i, nlon)]);
}
......
......@@ -588,7 +588,7 @@ remapNormalizeField(NormOpt normOpt, size_t gridsize, double *array, double miss
{
double grid_err = tgt_grid->cell_frac[i] * tgt_grid->cell_area[i];
if (fabs(grid_err) > 0)
if (std::fabs(grid_err) > 0)
array[i] /= grid_err;
else
array[i] = missval;
......@@ -601,7 +601,7 @@ remapNormalizeField(NormOpt normOpt, size_t gridsize, double *array, double miss
{
if (!DBL_IS_EQUAL(array[i], missval))
{
if (fabs(tgt_grid->cell_frac[i]) > 0)
if (std::fabs(tgt_grid->cell_frac[i]) > 0)
array[i] /= tgt_grid->cell_frac[i];
else
array[i] = missval;
......
......@@ -126,7 +126,7 @@ datestr_to_double(const char *datestr, int opt)
int status = sscanf(datestr, "%d-%d-%dT%d:%d:%d", &year, &month, &day, &hour, &minute, &second);
if (status != 6) cdoAbort("Invalid date string >%s<!", datestr);
fval = cdiEncodeTime(hour, minute, second);
if (fabs(fval) > 0) fval /= 1000000;
if (std::fabs(fval) > 0) fval /= 1000000;
fval += cdiEncodeDate(year, month, day);
}
else
......@@ -134,7 +134,7 @@ datestr_to_double(const char *datestr, int opt)
int status = sscanf(datestr, "%d-%d-%d", &year, &month, &day);
if (status != 3) cdoAbort("Invalid date string >%s<!", datestr);
fval = cdiEncodeTime(hour, minute, second);
if (fabs(fval) > 0) fval /= 1000000;
if (std::fabs(fval) > 0) fval /= 1000000;
fval += cdiEncodeDate(year, month, day);
}
......
......@@ -194,7 +194,7 @@ Selvar(void *process)
else if (operatorID == SELSTDNAME)
found = wildcardmatch(argnames[isel], stdname) == 0;
else if (operatorID == SELLEVEL)
found = fabs(fltarr[isel] - level) < 0.0001;
found = std::fabs(fltarr[isel] - level) < 0.0001;
else if (operatorID == SELLEVIDX)
found = intarr[isel] == (levID + 1);
else if (operatorID == SELGRID && args_are_numeric)
......
......@@ -237,7 +237,7 @@ smooth9(int gridID, double missval, const double *restrict array1, double *restr
smooth9_sum(((i + 1) * nlon) + j + 1, mask, 0.3, array1, &avg, &divavg);
}
if (fabs(divavg) > 0)
if (std::fabs(divavg) > 0)
{
array2[i * nlon + j] = avg / divavg;
}
......
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