Skip to content
Snippets Groups Projects
Commit d8698d4c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gen_boxgrid_curv2D: fuse 2D loops

parent 25e382f8
No related branches found
No related tags found
1 merge request!119M214003/develop
Pipeline #41223 failed
...@@ -136,64 +136,57 @@ gen_boxgrid_curv2D(int gridID1, size_t xinc, size_t yinc, int gridID2) ...@@ -136,64 +136,57 @@ gen_boxgrid_curv2D(int gridID1, size_t xinc, size_t yinc, int gridID2)
// Process grid2 bounds // Process grid2 bounds
double area_norm = xinc * yinc; double area_norm = xinc * yinc;
#ifdef _OPENMP #ifdef _OPENMP
//#pragma omp parallel for default(shared) #pragma omp parallel for default(shared)
#endif #endif
// for (size_t ig = 0; ig < nlat2 * nlon2; ++ig) for (size_t ig = 0; ig < nlat2 * nlon2; ++ig)
// {
// auto y2 = ig / nlon2;
// auto x2 = ig - y2 * nlon2;
for (size_t y2 = 0; y2 < nlat2; y2++)
{ {
for (size_t x2 = 0; x2 < nlon2; x2++) auto y2 = ig / nlon2;
{ auto x2 = ig - y2 * nlon2;
auto g2_add = (y2 * nlon2 + x2); auto g2_add = (y2 * nlon2 + x2);
for (size_t y1 = y2 * yinc; y1 < yinc * (y2 + 1); y1++) for (size_t y1 = y2 * yinc; y1 < yinc * (y2 + 1); y1++)
{
auto use_y1 = (y1 >= nlat1) ? nlat1 - 1 : y1;
for (size_t x1 = x2 * xinc; x1 < xinc * (x2 + 1); x1++)
{ {
auto use_y1 = (y1 >= nlat1) ? nlat1 - 1 : y1; auto use_x1 = x1;
for (size_t x1 = x2 * xinc; x1 < xinc * (x2 + 1); x1++) if (x1 >= nlon1)
{ {
auto use_x1 = x1; if (circular && use_y1 == y1)
if (x1 >= nlon1) use_y1 -= 1;
{
if (circular && use_y1 == y1)
use_y1 -= 1;
else
use_x1 = nlon1 - 1;
}
auto g1_add = (use_y1 * nlon1) + use_x1;
auto xval1 = xvals1[g1_add];
auto yval1 = yvals1[g1_add];
constexpr double xrangeLim = 359.99;
if (y1 == y2 * yinc && x1 == x2 * xinc)
{
xvals2_0 = xval1;
xvals2[g2_add] = xval1 / area_norm;
yvals2[g2_add] = yval1 / area_norm;
}
else if (std::fabs(xval1 - xvals2_0) > xrangeLim)
{
if ((xval1 - xvals2_0) > xrangeLim)
xvals2[g2_add] += (xval1 - 360.0) / area_norm;
else if ((xval1 - xvals2_0) < -xrangeLim)
xvals2[g2_add] += (xval1 + 360.0) / area_norm;
yvals2[g2_add] += yval1 / area_norm;
}
else else
{ use_x1 = nlon1 - 1;
xvals2[g2_add] += xval1 / area_norm; }
yvals2[g2_add] += yval1 / area_norm;
}
} // x1
} // y1
auto g1_add = (use_y1 * nlon1) + use_x1;
auto xval1 = xvals1[g1_add];
auto yval1 = yvals1[g1_add];
// while ( xvals2[g2_add] > 180. ) xvals2[g2_add] -= 360.; constexpr double xrangeLim = 359.99;
// while ( xvals2[g2_add] < -180. ) xvals2[g2_add] += 360.; if (y1 == y2 * yinc && x1 == x2 * xinc)
} {
xvals2_0 = xval1;
xvals2[g2_add] = xval1 / area_norm;
yvals2[g2_add] = yval1 / area_norm;
}
else if (std::fabs(xval1 - xvals2_0) > xrangeLim)
{
if ((xval1 - xvals2_0) > xrangeLim)
xvals2[g2_add] += (xval1 - 360.0) / area_norm;
else if ((xval1 - xvals2_0) < -xrangeLim)
xvals2[g2_add] += (xval1 + 360.0) / area_norm;
yvals2[g2_add] += yval1 / area_norm;
}
else
{
xvals2[g2_add] += xval1 / area_norm;
yvals2[g2_add] += yval1 / area_norm;
}
} // x1
} // y1
// while ( xvals2[g2_add] > 180. ) xvals2[g2_add] -= 360.;
// while ( xvals2[g2_add] < -180. ) xvals2[g2_add] += 360.;
} }
gridDefXvals(gridID2, xvals2.data()); gridDefXvals(gridID2, xvals2.data());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment