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
1826ccc0
Commit
1826ccc0
authored
11 months ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Added function field_operation()
parent
29aba1c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!229
M214003/develop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Diff.cc
+17
-6
17 additions, 6 deletions
src/Diff.cc
with
17 additions
and
6 deletions
src/Diff.cc
+
17
−
6
View file @
1826ccc0
...
...
@@ -124,13 +124,24 @@ diff(size_t n, const Field &field1, const Field &field2)
return
diffParam
;
}
static
void
use_real_part
(
size_t
gridsize
,
Field
&
field
)
template
<
typename
FUNC
,
typename
FIELD
,
typename
...
ARGS
>
inline
auto
field_operation
(
FUNC
func
,
FIELD
&
field
,
ARGS
&
...
args
)
->
decltype
(
func
(
field
.
vec_f
,
args
...))
{
if
(
field
.
memType
==
MemType
::
Float
)
for
(
size_t
i
=
0
;
i
<
gridsize
;
++
i
)
field
.
vec_f
[
i
]
=
field
.
vec_f
[
i
*
2
]
;
return
func
(
field
.
vec_f
,
args
...)
;
else
for
(
size_t
i
=
0
;
i
<
gridsize
;
++
i
)
field
.
vec_d
[
i
]
=
field
.
vec_d
[
i
*
2
];
return
func
(
field
.
vec_d
,
args
...);
}
static
void
use_real_part
(
Field
&
field
)
{
auto
func
=
[](
auto
&
v
)
{
auto
n
=
v
.
size
()
/
2
;
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
v
[
i
]
=
v
[
i
*
2
];
};
return
field_operation
(
func
,
field
);
}
struct
DiffParam
...
...
@@ -385,11 +396,11 @@ public:
field1
.
init
(
var1
);
cdo_read_record
(
streamID1
,
field1
);
if
(
var1
.
nwpv
==
CDI_COMP
)
use_real_part
(
var1
.
gridsize
,
field1
);
if
(
var1
.
nwpv
==
CDI_COMP
)
use_real_part
(
field1
);
field2
.
init
(
var2
);
cdo_read_record
(
streamID2
,
field2
);
if
(
var2
.
nwpv
==
CDI_COMP
)
use_real_part
(
var1
.
gridsize
,
field2
);
if
(
var2
.
nwpv
==
CDI_COMP
)
use_real_part
(
field2
);
if
(
runAsync
&&
numSets
>
0
)
{
...
...
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