Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
0d2e877d
Commit
0d2e877d
authored
Oct 16, 2020
by
Uwe Schulzweida
Browse files
Refactor sort_add_and_4wgts().
parent
78f68252
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/remap_bilinear.cc
View file @
0d2e877d
...
...
@@ -325,7 +325,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
{
// Successfully found iw,jw - compute weights
bilinearSetWeights
(
iw
,
jw
,
wgts
);
sort_add_and_wgts
(
4
,
src_add
,
wgts
);
sort_add_and_
4
wgts
(
src_add
,
wgts
);
tgt_array
[
tgt_cell_add
]
=
bilinearRemap
(
src_array
,
wgts
,
src_add
);
}
else
...
...
@@ -345,7 +345,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
{
tgt_grid
->
cell_frac
[
tgt_cell_add
]
=
1.
;
renormalizeWeights
(
src_lats
,
wgts
);
sort_add_and_wgts
(
4
,
src_add
,
wgts
);
sort_add_and_
4
wgts
(
src_add
,
wgts
);
tgt_array
[
tgt_cell_add
]
=
bilinearRemap
(
src_array
,
wgts
,
src_add
);
}
}
...
...
src/remap_store_link.cc
View file @
0d2e877d
...
...
@@ -73,6 +73,32 @@ sortAddweights4(Addweight4 *addweights)
std
::
qsort
(
addweights
,
4
,
sizeof
(
Addweight4
),
qcompareAdds4
);
}
void
sort_add_and_4wgts
(
size_t
*
src_add
,
double
*
wgts
)
{
constexpr
size_t
numWeights
=
4
;
size_t
n
;
for
(
n
=
1
;
n
<
numWeights
;
++
n
)
if
(
src_add
[
n
]
<
src_add
[
n
-
1
])
break
;
if
(
n
==
numWeights
)
return
;
std
::
array
<
Addweight
,
numWeights
>
addweights
;
for
(
n
=
0
;
n
<
numWeights
;
++
n
)
{
addweights
[
n
].
add
=
src_add
[
n
];
addweights
[
n
].
weight
=
wgts
[
n
];
}
std
::
sort
(
addweights
.
begin
(),
addweights
.
end
(),
compareAdds
);
for
(
n
=
0
;
n
<
numWeights
;
++
n
)
{
src_add
[
n
]
=
addweights
[
n
].
add
;
wgts
[
n
]
=
addweights
[
n
].
weight
;
}
}
void
sort_add_and_wgts
(
size_t
numWeights
,
size_t
*
src_add
,
double
*
wgts
)
{
...
...
src/remap_store_link.h
View file @
0d2e877d
...
...
@@ -56,6 +56,7 @@ void storeWeightLinks4(size_t *srch_add, double weights[4][4], size_t cell_add,
void
weightLinksToRemapLinks
(
int
lalloc
,
size_t
gridSize
,
std
::
vector
<
WeightLinks
>
&
weightLinks
,
RemapVars
&
rv
);
void
weightLinks4ToRemapLinks
(
size_t
gridSize
,
std
::
vector
<
WeightLinks4
>
&
weightLinks
,
RemapVars
&
rv
);
void
sort_add_and_wgts
(
size_t
numWeights
,
size_t
*
src_add
,
double
*
wgts
);
void
sort_add_and_4wgts
(
size_t
*
src_add
,
double
*
wgts
);
void
sort_add_and_wgts_bic
(
size_t
*
src_add
,
double
(
&
wgts
)[
4
][
4
]);
#endif
/* REMAP_STORE_LINK */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment