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

remapGradients: don't init bool arrays in OpenMP Loops (bug fix).

parent b81625e4
......@@ -221,9 +221,11 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
auto src_grid_size = src_grid->size;
std::vector<bool> src_grid_mask(src_grid_size);
/* doesn't work with bool arrays!!!
#ifdef _OPENMP
#pragma omp parallel for default(none) schedule(static) shared(src_grid_size, src_array, src_grid_mask, missval)
#endif
*/
for (size_t i = 0; i < src_grid_size; ++i) src_grid_mask[i] = !DBL_IS_EQUAL(src_array[i], missval);
// Compute mappings from source to target grid
......
......@@ -1152,19 +1152,18 @@ normalize_weights(RemapGrid *tgt_grid, RemapVars &rv, double *src_centroid_lat,
// src_cell_add: current linear address for source grid cell
// tgt_cell_add: current linear address for target grid cell
double *weights = &rv.wts[0];
double norm_factor = 0; /* factor for normalizing wts */
if (rv.normOpt == NormOpt::DESTAREA)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) \
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon) private(norm_factor)
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon)
#endif
for (long n = 0; n < num_links; ++n)
{
const auto src_cell_add = rv.src_cell_add[n];
const auto tgt_cell_add = rv.tgt_cell_add[n];
norm_factor = IS_NOT_EQUAL(tgt_grid->cell_area[tgt_cell_add], 0) ? ONE / tgt_grid->cell_area[tgt_cell_add] : ZERO;
auto norm_factor = IS_NOT_EQUAL(tgt_grid->cell_area[tgt_cell_add], 0) ? ONE / tgt_grid->cell_area[tgt_cell_add] : ZERO;
norm_weight(norm_factor, &weights[n * 3], src_centroid_lat[src_cell_add], src_centroid_lon[src_cell_add]);
}
}
......@@ -1172,13 +1171,13 @@ normalize_weights(RemapGrid *tgt_grid, RemapVars &rv, double *src_centroid_lat,
{
#ifdef _OPENMP
#pragma omp parallel for default(none) \
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon) private(norm_factor)
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon)
#endif
for (long n = 0; n < num_links; ++n)
{
const auto src_cell_add = rv.src_cell_add[n];
const auto tgt_cell_add = rv.tgt_cell_add[n];
norm_factor = IS_NOT_EQUAL(tgt_grid->cell_frac[tgt_cell_add], 0) ? ONE / tgt_grid->cell_frac[tgt_cell_add] : ZERO;
auto norm_factor = IS_NOT_EQUAL(tgt_grid->cell_frac[tgt_cell_add], 0) ? ONE / tgt_grid->cell_frac[tgt_cell_add] : ZERO;
norm_weight(norm_factor, &weights[n * 3], src_centroid_lat[src_cell_add], src_centroid_lon[src_cell_add]);
}
}
......@@ -1186,16 +1185,17 @@ normalize_weights(RemapGrid *tgt_grid, RemapVars &rv, double *src_centroid_lat,
{
#ifdef _OPENMP
#pragma omp parallel for default(none) \
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon) private(norm_factor)
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon)
#endif
for (long n = 0; n < num_links; ++n)
{
const auto src_cell_add = rv.src_cell_add[n];
norm_factor = ONE;
auto norm_factor = ONE;
norm_weight(norm_factor, &weights[n * 3], src_centroid_lat[src_cell_add], src_centroid_lon[src_cell_add]);
}
}
}
static void
srvout(const char *fname, int nlon, int nlat, double *data)
{
......@@ -1311,7 +1311,7 @@ remapConservWeightsScrip(RemapSearch &rsearch, RemapVars &rv)
#endif
for (long src_cell_add = 0; src_cell_add < src_grid_size; ++src_cell_add)
{
auto ompthID = cdo_omp_get_thread_num();
const auto ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
......@@ -1507,7 +1507,7 @@ remapConservWeightsScrip(RemapSearch &rsearch, RemapVars &rv)
#endif
for (long tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
auto ompthID = cdo_omp_get_thread_num();
const auto ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
......
......@@ -1022,9 +1022,11 @@ remapGradients(RemapGrid &grid, const double *restrict array, RemapGradients &gr
{
size_t grid_size = grid.size;
std::vector<bool> mask(grid_size);
/* doesn't work with bool arrays!!!
#ifdef _OPENMP
#pragma omp parallel for default(none) schedule(static) shared(grid_size, grid, mask)
#endif
*/
for (size_t i = 0; i < grid_size; ++i) mask[i] = grid.mask[i] > 0;
remapGradients(grid, mask, array, gradients);
......
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