Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
d8698d4c
Commit
d8698d4c
authored
1 year ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
gen_boxgrid_curv2D: fuse 2D loops
parent
25e382f8
No related branches found
No related tags found
1 merge request
!119
M214003/develop
Pipeline
#41223
failed
1 year ago
Stage: build
Stage: check
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Gridboxstat.cc
+43
-50
43 additions, 50 deletions
src/Gridboxstat.cc
with
43 additions
and
50 deletions
src/Gridboxstat.cc
+
43
−
50
View file @
d8698d4c
...
@@ -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_
y
1
=
(
y1
>=
nlat1
)
?
nlat1
-
1
:
y
1
;
auto
use_
x
1
=
x
1
;
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
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment