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

Set type of initialized variables to auto.

parent 0e158360
Pipeline #3128 passed with stages
in 14 minutes and 15 seconds
......@@ -195,7 +195,7 @@ adjust_bbox_max(T *max)
static void *
gps_create_kdtree(size_t n, const Varray<double> &lons, const Varray<double> &lats, GridPointSearch &gps)
{
auto pointlist = (kd_point *) Malloc(n * sizeof(kd_point));
std::vector<kd_point> pointlist(n);
// see example_cartesian.c
kdata_t min[3] = { 1.e9, 1.e9, 1.e9 };
......@@ -206,7 +206,7 @@ gps_create_kdtree(size_t n, const Varray<double> &lons, const Varray<double> &la
#endif
for (size_t i = 0; i < n; i++)
{
kdata_t *restrict point = pointlist[i].point;
auto &point = pointlist[i].point;
gcLLtoXYZ(lons[i], lats[i], point);
for (unsigned j = 0; j < 3; ++j)
{
......@@ -223,8 +223,7 @@ gps_create_kdtree(size_t n, const Varray<double> &lons, const Varray<double> &la
if (Options::cdoVerbose) cdoPrint("BBOX: min=%g/%g/%g max=%g/%g/%g", min[0], min[1], min[2], max[0], max[1], max[2]);
auto kdt = kd_buildTree(pointlist, n, min, max, 3, Threading::ompNumThreads);
if (pointlist) Free(pointlist);
auto kdt = kd_buildTree(pointlist.data(), n, min, max, 3, Threading::ompNumThreads);
if (kdt == nullptr) cdoAbort("kd_buildTree failed!");
return (void *) kdt;
......@@ -576,16 +575,16 @@ llindex_in_quad(const GridPointSearch &gps, size_t index, double lon, double lat
{
if (index != GPS_NOT_FOUND)
{
const size_t nx = gps.dims[0];
const size_t ny = gps.dims[1];
const auto nx = gps.dims[0];
const auto ny = gps.dims[1];
size_t adds[4];
double lons[4], lats[4];
const bool isCyclic = gps.is_cyclic;
for (unsigned k = 0; k < 4; ++k)
{
// Determine neighbor addresses
size_t j = index / nx;
size_t i = index - j * nx;
auto j = index / nx;
auto i = index - j * nx;
if (k == 1 || k == 3) i = (i > 0) ? i - 1 : (isCyclic) ? nx - 1 : 0;
if (k == 2 || k == 3) j = (j > 0) ? j - 1 : 0;
......@@ -602,7 +601,7 @@ gridPointSearchNearest(GridPointSearch &gps, double lon, double lat, size_t *add
if (gps.in_use)
{
size_t nadds = 0;
double searchRadius = gps.searchRadius;
const auto searchRadius = gps.searchRadius;
void *sc = gps.search_container;
// clang-format off
if (gps.method == PointSearchMethod::kdtree) nadds = gps_nearest_kdtree(sc, lon, lat, searchRadius, addr, dist, gps);
......@@ -614,7 +613,7 @@ gridPointSearchNearest(GridPointSearch &gps, double lon, double lat, size_t *add
if (nadds > 0)
{
size_t index = *addr;
auto index = *addr;
if (!gps.extrapolate && gps.is_curve) index = llindex_in_quad(gps, *addr, lon, lat);
if (index != GPS_NOT_FOUND) return 1;
}
......@@ -700,12 +699,12 @@ gps_qnearest_spherepart(GridPointSearch &gps, double lon, double lat, double sea
if (gps.in_use)
{
double query_pt[1][3];
gcLLtoXYZ(lon, lat, query_pt[0]);
double query_pt[3];
gcLLtoXYZ(lon, lat, query_pt);
if (!gps.extrapolate)
for (unsigned j = 0; j < 3; ++j)
if (query_pt[0][j] < gps.min[j] || query_pt[0][j] > gps.max[j]) return nadds;
if (query_pt[j] < gps.min[j] || query_pt[j] > gps.max[j]) return nadds;
size_t local_point_ids_array_size = 0;
size_t num_local_point_ids;
......@@ -714,17 +713,17 @@ gps_qnearest_spherepart(GridPointSearch &gps, double lon, double lat, double sea
size_t cos_angles_array_size = 0;
double *cos_angles = nullptr;
yac_point_sphere_part_search_NNN((point_sphere_part_search *) gps.search_container, 1, query_pt, nnn, &cos_angles,
yac_point_sphere_part_search_NNN((point_sphere_part_search *) gps.search_container, 1, &query_pt, nnn, &cos_angles,
&cos_angles_array_size, nullptr, nullptr, &local_point_ids, &local_point_ids_array_size,
&num_local_point_ids);
if (num_local_point_ids > 0)
{
const size_t maxadds = (num_local_point_ids < nnn) ? num_local_point_ids : nnn;
const auto maxadds = (num_local_point_ids < nnn) ? num_local_point_ids : nnn;
nadds = 0;
for (size_t i = 0; i < maxadds; ++i)
{
const double angle = std::acos(cos_angles[i]);
const auto angle = std::acos(cos_angles[i]);
if (angle < searchRadius)
{
adds[nadds] = local_point_ids[i];
......
......@@ -76,8 +76,7 @@ bicubicWarning()
}
static double
bicubicRemap(const double *restrict src_array, double wgts[4][4], const size_t src_add[4],
RemapGradients &gradients)
bicubicRemap(const double *restrict src_array, const double wgts[4][4], const size_t src_add[4], const RemapGradients &gradients)
{
const auto &glat = gradients.grad_lat;
const auto &glon = gradients.grad_lon;
......
......@@ -241,7 +241,7 @@ check_lon_boundbox_range(size_t nlons, float *bound_box)
#endif
for (size_t n = 0; n < nlons; ++n)
{
size_t n4 = n << 2;
const auto n4 = n << 2;
if (fabsf(bound_box[n4 + 3] - bound_box[n4 + 2]) > PI_f)
{
bound_box[n4 + 2] = 0.0f;
......@@ -260,7 +260,7 @@ check_lat_boundbox_range(size_t nlats, float *restrict bound_box, Varray<double>
#endif
for (size_t n = 0; n < nlats; ++n)
{
size_t n4 = n << 2;
const auto n4 = n << 2;
if ((float) lats[n] < bound_box[n4]) bound_box[n4] = -PIH_f;
if ((float) lats[n] > bound_box[n4 + 1]) bound_box[n4 + 1] = PIH_f;
}
......@@ -287,12 +287,12 @@ grid_check_lat_borders_rad(size_t n, Varray<double> &ybounds)
static void
remap_define_reg2d(int gridID, RemapGrid &grid)
{
size_t nx = grid.dims[0];
size_t ny = grid.dims[1];
size_t nxp1 = nx + 1;
size_t nyp1 = ny + 1;
const auto nx = grid.dims[0];
const auto ny = grid.dims[1];
const auto nxp1 = nx + 1;
const auto nyp1 = ny + 1;
size_t nxm = nx;
auto nxm = nx;
if (grid.is_cyclic) nxm++;
if (grid.size != nx * ny) cdoAbort("Internal error, wrong dimensions!");
......@@ -352,7 +352,7 @@ remapDefineGrid(RemapMethod mapType, int gridID, RemapGrid &grid, const char *tx
bool lgrid_destroy = false;
int gridID_gme = -1;
auto gridtype = gridInqType(grid.gridID);
const auto gridtype = gridInqType(grid.gridID);
if (gridtype != GRID_UNSTRUCTURED && gridtype != GRID_CURVILINEAR)
{
if (gridtype == GRID_GME)
......@@ -466,7 +466,7 @@ cell_bounding_boxes(RemapGrid &grid, float *cell_bound_box, int remap_grid_basis
{
if (Options::cdoVerbose) cdoPrint("Grid: bounds missing -> full grid search!");
size_t gridsize = grid.size;
const auto gridsize = grid.size;
for (size_t i = 0; i < gridsize; ++i)
{
cell_bound_box[i * 4] = -PIH_f;
......@@ -481,8 +481,8 @@ cell_bounding_boxes(RemapGrid &grid, float *cell_bound_box, int remap_grid_basis
if (Options::cdoVerbose) cdoPrint("Grid: boundboxFromCenter");
if (grid.rank != 2) cdoAbort("Internal problem, grid rank = %d!", grid.rank);
size_t nx = grid.dims[0];
size_t ny = grid.dims[1];
const auto nx = grid.dims[0];
const auto ny = grid.dims[1];
boundboxFromCenter(grid.is_cyclic, grid.size, nx, ny, grid.cell_center_lon, grid.cell_center_lat, cell_bound_box);
}
......@@ -517,7 +517,7 @@ remapGridAlloc(RemapMethod mapType, RemapGrid &grid)
{
if (grid.num_cell_corners > 0)
{
size_t nalloc = grid.num_cell_corners * grid.size;
const auto nalloc = grid.num_cell_corners * grid.size;
grid.cell_corner_lon.resize(nalloc, 0);
grid.cell_corner_lat.resize(nalloc, 0);
}
......@@ -646,8 +646,8 @@ remapSearchFree(RemapSearch &search)
void
remapInitGrids(RemapMethod mapType, bool lextrapolate, int gridID1, RemapGrid &src_grid, int gridID2, RemapGrid &tgt_grid)
{
int reg2d_src_gridID = gridID1;
int reg2d_tgt_gridID = gridID2;
auto reg2d_src_gridID = gridID1;
auto reg2d_tgt_gridID = gridID2;
remapGridInit(src_grid);
remapGridInit(tgt_grid);
......@@ -723,7 +723,7 @@ remapInitGrids(RemapMethod mapType, bool lextrapolate, int gridID1, RemapGrid &s
}
}
int sgridID = src_grid.gridID;
auto sgridID = src_grid.gridID;
if (gridInqSize(sgridID) > 1
&& ((gridInqType(sgridID) == GRID_PROJECTION && gridInqProjType(sgridID) == CDI_PROJ_LCC)
|| (gridInqType(sgridID) == GRID_PROJECTION && gridInqProjType(sgridID) == CDI_PROJ_STERE)
......@@ -846,9 +846,9 @@ remapGradients(RemapGrid &grid, const std::vector<uint8_t> &mask, const double *
{
if (grid.rank != 2) cdoAbort("Internal problem (remapGradients), grid rank = %d!", grid.rank);
size_t grid_size = grid.size;
size_t nx = grid.dims[0];
size_t ny = grid.dims[1];
auto grid_size = grid.size;
auto nx = grid.dims[0];
auto ny = grid.dims[1];
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(grid_size, gradients, grid, nx, ny, array, mask)
......@@ -862,31 +862,31 @@ remapGradients(RemapGrid &grid, const std::vector<uint8_t> &mask, const double *
if (mask[n])
{
// clang-format off
double delew = 0.5;
double delns = 0.5;
auto delew = 0.5;
auto delns = 0.5;
const size_t j = n / nx + 1;
const size_t i = n - (j - 1) * nx + 1;
const auto j = n / nx + 1;
const auto i = n - (j - 1) * nx + 1;
size_t ip1 = i + 1;
size_t im1 = i - 1;
size_t jp1 = j + 1;
size_t jm1 = j - 1;
auto ip1 = i + 1;
auto im1 = i - 1;
auto jp1 = j + 1;
auto jm1 = j - 1;
if (ip1 > nx) ip1 = ip1 - nx;
if (im1 < 1) im1 = nx;
if (jp1 > ny) { jp1 = j; delns = 1.0; }
if (jm1 < 1) { jm1 = j; delns = 1.0; }
size_t in = (jp1 - 1) * nx + i - 1;
size_t is = (jm1 - 1) * nx + i - 1;
size_t ie = (j - 1) * nx + ip1 - 1;
size_t iw = (j - 1) * nx + im1 - 1;
auto in = (jp1 - 1) * nx + i - 1;
auto is = (jm1 - 1) * nx + i - 1;
auto ie = (j - 1) * nx + ip1 - 1;
auto iw = (j - 1) * nx + im1 - 1;
size_t ine = (jp1 - 1) * nx + ip1 - 1;
size_t inw = (jp1 - 1) * nx + im1 - 1;
size_t ise = (jm1 - 1) * nx + ip1 - 1;
size_t isw = (jm1 - 1) * nx + im1 - 1;
auto ine = (jp1 - 1) * nx + ip1 - 1;
auto inw = (jp1 - 1) * nx + im1 - 1;
auto ise = (jm1 - 1) * nx + ip1 - 1;
auto isw = (jm1 - 1) * nx + im1 - 1;
// Compute i-gradient
if (!mask[ie]) { ie = n; delew = 1.0; }
......@@ -951,7 +951,7 @@ remapGradients(RemapGrid &grid, const std::vector<uint8_t> &mask, const double *
}
}
const double grad_lat_zero = delew * (array[ine] - array[inw]);
const auto grad_lat_zero = delew * (array[ine] - array[inw]);
if (!mask[ise])
{
......@@ -999,8 +999,7 @@ remapGradients(RemapGrid &grid, const std::vector<uint8_t> &mask, const double *
}
}
const double grad_lon_zero = delew * (array[ise] - array[isw]);
const auto grad_lon_zero = delew * (array[ise] - array[isw]);
gradients.grad_latlon[n] = delns * (grad_lat_zero - grad_lon_zero);
}
}
......@@ -1009,7 +1008,7 @@ remapGradients(RemapGrid &grid, const std::vector<uint8_t> &mask, const double *
void
remapGradients(RemapGrid &grid, const double *restrict array, RemapGradients &gradients)
{
size_t grid_size = grid.size;
auto grid_size = grid.size;
std::vector<uint8_t> mask(grid_size);
#ifdef _OPENMP
#pragma omp parallel for default(none) schedule(static) shared(grid_size, grid, mask)
......
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