Commit 1bd84eb5 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

removed dmemory include and usage

parent 123d5ce6
Pipeline #4373 passed with stages
in 14 minutes and 56 seconds
......@@ -287,7 +287,7 @@ grid_gen_corners(size_t n, const double *restrict vals, double *restrict corners
void
grid_gen_bounds(size_t n, const std::vector<double> &vals, std::vector<double> &bounds)
{
const auto lrev = (vals[0] > vals[n-1]);
const auto lrev = (vals[0] > vals[n - 1]);
if (lrev)
{
for (size_t i = 0; i < n - 1; ++i)
......@@ -560,8 +560,8 @@ qu2reg_subarea(size_t gridsize, int np, double xfirst, double xlast, double *arr
// int nwork = 0;
// for (j = 0; j < ny; ++j) nwork += reducedPoints[j];
double **pwork = (double **) Malloc(ny * sizeof(double *));
double *work = (double *) Malloc(ny * np4 * sizeof(double));
double **pwork = (double **) malloc(ny * sizeof(double *));
double *work = (double *) malloc(ny * np4 * sizeof(double));
wlen = 0;
pwork[0] = work;
for (j = 1; j < ny; ++j)
......@@ -622,8 +622,8 @@ qu2reg_subarea(size_t gridsize, int np, double xfirst, double xlast, double *arr
}
}
Free(work);
Free(pwork);
free(work);
free(pwork);
return nx;
}
......@@ -798,16 +798,16 @@ grid_has_proj_params(int gridID)
return has_proj_params;
}
static char *
static std::vector<char>
grid_get_proj_params(int gridID)
{
char *proj_params = nullptr;
std::vector<char> proj_params;
const auto gridtype = gridInqType(gridID);
if (gridtype == GRID_PROJECTION)
{
int atttype, attlen, atttxtlen = 0;
char *atttxt = nullptr;
std::vector<char> atttxt;
char attname[CDI_MAX_NAME + 1];
int natts;
......@@ -821,10 +821,10 @@ grid_get_proj_params(int gridID)
{
if (attlen > atttxtlen)
{
atttxt = (char *) Realloc(atttxt, (attlen + 1));
atttxt.resize(attlen + 1);
atttxtlen = attlen;
}
cdiInqAttTxt(gridID, CDI_GLOBAL, attname, attlen, atttxt);
cdiInqAttTxt(gridID, CDI_GLOBAL, attname, attlen, atttxt.data());
atttxt[attlen] = 0;
if (cstrIsEqual(attname, "proj_params") || cstrIsEqual(attname, "proj4_params"))
{
......@@ -833,7 +833,6 @@ grid_get_proj_params(int gridID)
}
}
}
if (proj_params == nullptr && atttxt) Free(atttxt);
}
return proj_params;
......@@ -918,14 +917,14 @@ get_projection(int gridID1)
}
static void
applyProjection(Projection projection, char *proj_params, int gridID, size_t n, double *x, double *y)
applyProjection(Projection projection, std::vector<char> &proj_params, int gridID, size_t n, double *x, double *y)
{
// clang-format off
if (projection == Projection::proj_sinu) cdo_sinu_to_lonlat(n, x, y);
else if (projection == Projection::proj_laea) cdo_laea_to_lonlat(gridID, n, x, y);
else if (projection == Projection::proj_lcc) cdo_lcc_to_lonlat(gridID, n, x, y);
else if (projection == Projection::proj_stere) cdo_stere_to_lonlat(gridID, n, x, y);
else if (projection == Projection::proj_params) cdo_proj_to_lonlat(proj_params, n, x, y);
else if (projection == Projection::proj_params) cdo_proj_to_lonlat(proj_params.data(), n, x, y);
// clang-format on
}
......@@ -947,11 +946,11 @@ gridToCurvilinear(int gridID1, int lbounds)
gridDefDatatype(gridID2, CDI_DATATYPE_FLT32);
Projection projection(Projection::none);
char *proj_params = nullptr;
std::vector<char> proj_params;
if (gridtype == GRID_PROJECTION && gridsize == nx * ny)
{
proj_params = grid_get_proj_params(gridID1);
projection = proj_params ? Projection::proj_params : get_projection(gridID1);
projection = !proj_params.empty() ? Projection::proj_params : get_projection(gridID1);
// if (projection != Projection::none) gridtype = GRID_LONLAT;
}
......@@ -965,7 +964,7 @@ gridToCurvilinear(int gridID1, int lbounds)
cdiInqKeyString(gridID1, CDI_XAXIS, CDI_KEY_UNITS, xunits, &length);
length = CDI_MAX_NAME;
cdiInqKeyString(gridID1, CDI_YAXIS, CDI_KEY_UNITS, yunits, &length);
if (lprojection) check_units("x", xunits);
if (lprojection) check_units("y", yunits);
......@@ -1074,8 +1073,6 @@ gridToCurvilinear(int gridID1, int lbounds)
gridCopyMask(gridID1, gridID2, gridsize);
if (proj_params) Free(proj_params);
return gridID2;
}
......@@ -1602,8 +1599,7 @@ grid_is_distance_generic(int gridID)
length = CDI_MAX_NAME;
cdiInqKeyString(gridID, CDI_YAXIS, CDI_KEY_UNITS, yunits, &length);
if (cstrIsEqual(xunits, "m") && cstrIsEqual(yunits, "m") && gridHasCoordinates(gridID))
status = true;
if (cstrIsEqual(xunits, "m") && cstrIsEqual(yunits, "m") && gridHasCoordinates(gridID)) status = true;
}
return status;
......
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