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
d58927c6
Commit
d58927c6
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
runpctl: OpenMP parallelized
parent
66eb988e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ChangeLog
+4
-0
4 additions, 0 deletions
ChangeLog
src/Runpctl.cc
+58
-49
58 additions, 49 deletions
src/Runpctl.cc
with
62 additions
and
49 deletions
ChangeLog
+
4
−
0
View file @
d58927c6
2022-09-30 Uwe Schulzweida
* runpctl: OpenMP parallelized
2022-09-29 Uwe Schulzweida
* mastrfu: check pressure level orientation
...
...
This diff is collapsed.
Click to expand it.
src/Runpctl.cc
+
58
−
49
View file @
d58927c6
...
...
@@ -19,6 +19,63 @@
#include
"percentiles.h"
#include
"datetime.h"
#include
"field_functions.h"
#include
"cimdOmp.h"
template
<
typename
T
>
static
size_t
runpctl
(
double
pn
,
int
ndates
,
size_t
gridsize
,
Varray
<
T
>
&
v2
,
T
missval
,
const
FieldVector3D
&
vars1
,
int
varID
,
int
levelID
,
MemType
memType
)
{
size_t
nmiss
=
0
;
Varray2D
<
T
>
array_2D
(
Threading
::
ompNumThreads
,
Varray
<
T
>
(
ndates
));
#ifdef _OPENMP
#pragma omp parallel for default(shared) schedule(dynamic)
#endif
for
(
size_t
i
=
0
;
i
<
gridsize
;
++
i
)
{
const
auto
ompthID
=
cdo_omp_get_thread_num
();
auto
&
array
=
array_2D
[
ompthID
];
int
j
=
0
;
if
(
memType
==
MemType
::
Float
)
{
for
(
int
inp
=
0
;
inp
<
ndates
;
++
inp
)
{
const
auto
val
=
vars1
[
inp
][
varID
][
levelID
].
vec_f
[
i
];
if
(
!
dbl_is_equal
(
val
,
missval
))
array
[
j
++
]
=
val
;
}
}
else
{
for
(
int
inp
=
0
;
inp
<
ndates
;
++
inp
)
{
const
auto
val
=
vars1
[
inp
][
varID
][
levelID
].
vec_d
[
i
];
if
(
!
dbl_is_equal
(
val
,
missval
))
array
[
j
++
]
=
val
;
}
}
if
(
j
>
0
)
{
v2
[
i
]
=
percentile
(
array
.
data
(),
j
,
pn
);
}
else
{
v2
[
i
]
=
missval
;
nmiss
++
;
}
}
return
nmiss
;
}
static
void
runpctl
(
double
pn
,
int
ndates
,
Field
&
field1
,
const
FieldVector3D
&
vars1
,
int
varID
,
int
levelID
)
{
if
(
field1
.
memType
==
MemType
::
Float
)
field1
.
nmiss
=
runpctl
(
pn
,
ndates
,
field1
.
gridsize
,
field1
.
vec_f
,
(
float
)
field1
.
missval
,
vars1
,
varID
,
levelID
,
field1
.
memType
);
else
field1
.
nmiss
=
runpctl
(
pn
,
ndates
,
field1
.
gridsize
,
field1
.
vec_d
,
field1
.
missval
,
vars1
,
varID
,
levelID
,
field1
.
memType
);
}
void
*
Runpctl
(
void
*
process
)
...
...
@@ -96,59 +153,11 @@ Runpctl(void *process)
{
if
(
varList1
[
varID
].
timetype
==
TIME_CONSTANT
)
continue
;
const
auto
gridsize
=
varList1
[
varID
].
gridsize
;
const
auto
nlevels
=
varList1
[
varID
].
nlevels
;
const
auto
missval
=
varList1
[
varID
].
missval
;
for
(
int
levelID
=
0
;
levelID
<
nlevels
;
++
levelID
)
{
auto
&
field1
=
vars1
[
0
][
varID
][
levelID
];
size_t
nmiss
=
0
;
if
(
field1
.
memType
==
MemType
::
Float
)
{
for
(
size_t
i
=
0
;
i
<
gridsize
;
++
i
)
{
int
j
=
0
;
for
(
int
inp
=
0
;
inp
<
ndates
;
++
inp
)
{
const
auto
val
=
vars1
[
inp
][
varID
][
levelID
].
vec_f
[
i
];
if
(
!
DBL_IS_EQUAL
(
val
,
(
float
)
missval
))
array_f
[
j
++
]
=
val
;
}
if
(
j
>
0
)
{
field1
.
vec_f
[
i
]
=
percentile
(
array_f
.
data
(),
j
,
pn
);
}
else
{
field1
.
vec_f
[
i
]
=
missval
;
nmiss
++
;
}
}
}
else
{
for
(
size_t
i
=
0
;
i
<
gridsize
;
++
i
)
{
int
j
=
0
;
for
(
int
inp
=
0
;
inp
<
ndates
;
++
inp
)
{
const
auto
val
=
vars1
[
inp
][
varID
][
levelID
].
vec_d
[
i
];
if
(
!
DBL_IS_EQUAL
(
val
,
missval
))
array_d
[
j
++
]
=
val
;
}
if
(
j
>
0
)
{
field1
.
vec_d
[
i
]
=
percentile
(
array_d
.
data
(),
j
,
pn
);
}
else
{
field1
.
vec_d
[
i
]
=
missval
;
nmiss
++
;
}
}
}
field1
.
nmiss
=
nmiss
;
runpctl
(
pn
,
ndates
,
field1
,
vars1
,
varID
,
levelID
);
}
}
...
...
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