Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
66addef1
Commit
66addef1
authored
Oct 16, 2015
by
Uwe Schulzweida
Browse files
remapbic: optimize memory handling
parent
d832cfab
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/remap_bicubic_scrip.c
View file @
66addef1
...
...
@@ -105,6 +105,9 @@ void scrip_remap_bicubic_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
long
tgt_grid_size
=
tgt_grid
->
size
;
weightlinks4_t
*
weightlinks
=
(
weightlinks4_t
*
)
Malloc
(
tgt_grid_size
*
sizeof
(
weightlinks4_t
));
weightlinks
[
0
].
addweights
=
(
addweight4_t
*
)
Malloc
(
4
*
tgt_grid_size
*
sizeof
(
addweight4_t
));
for
(
unsigned
tgt_cell_add
=
1
;
tgt_cell_add
<
tgt_grid_size
;
++
tgt_cell_add
)
weightlinks
[
tgt_cell_add
].
addweights
=
weightlinks
[
0
].
addweights
+
4
*
tgt_cell_add
;
/* Loop over destination grid */
...
...
src/remap_bilinear_scrip.c
View file @
66addef1
...
...
@@ -12,7 +12,7 @@
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
int
find_ij_weights
(
double
plon
,
double
plat
,
double
*
restrict
src_lats
,
double
*
restrict
src_lons
,
double
*
ig
,
double
*
jg
)
int
find_ij_weights
(
double
plon
,
double
plat
,
double
*
restrict
src_lats
,
double
*
restrict
src_lons
,
double
*
ig
,
double
*
jg
)
{
int
lfound
=
0
;
long
iter
;
/* iteration counters */
...
...
@@ -79,7 +79,7 @@ int find_ij_weights(double plon, double plat, double* restrict src_lats, double*
if
(
iter
<
remap_max_iter
)
lfound
=
1
;
return
(
lfound
)
;
return
lfound
;
}
static
...
...
@@ -104,7 +104,7 @@ int num_src_points(const int* restrict mask, const int src_add[4], double src_la
src_lats
[
n
]
=
0
.;
}
return
(
icount
)
;
return
icount
;
}
static
...
...
@@ -146,7 +146,7 @@ void bilinear_warning(double plon, double plat, double iw, double jw, int* src_a
}
static
void
bilinear_remap
(
double
*
restrict
tgt_point
,
const
double
*
restrict
src_array
,
const
double
wgts
[
4
],
const
int
src_add
[
4
])
void
bilinear_remap
(
double
*
restrict
tgt_point
,
const
double
*
restrict
src_array
,
const
double
wgts
[
4
],
const
int
src_add
[
4
])
{
// *tgt_point = 0.;
// for ( int n = 0; n < 4; ++n ) *tgt_point += src_array[src_add[n]]*wgts[n];
...
...
src/remap_store_link.c
View file @
66addef1
...
...
@@ -149,7 +149,8 @@ void store_weightlinks4(unsigned num_weights, int *srch_add, double weights[4][4
if
(
num_weights
)
{
addweight4_t
*
addweights
=
(
addweight4_t
*
)
Malloc
(
num_weights
*
sizeof
(
addweight4_t
));
addweight4_t
*
addweights
=
weightlinks
[
cell_add
].
addweights
;
for
(
unsigned
n
=
0
;
n
<
num_weights
;
++
n
)
{
addweights
[
n
].
add
=
srch_add
[
n
];
...
...
@@ -159,7 +160,6 @@ void store_weightlinks4(unsigned num_weights, int *srch_add, double weights[4][4
sort_addweights4
(
num_weights
,
addweights
);
weightlinks
[
cell_add
].
addweights
=
addweights
;
weightlinks
[
cell_add
].
nlinks
=
num_weights
;
}
}
...
...
@@ -265,12 +265,9 @@ void weightlinks2remaplinks4(unsigned tgt_grid_size, weightlinks4_t *weightlinks
for
(
unsigned
k
=
0
;
k
<
4
;
++
k
)
wts
[(
offset
+
ilink
)
*
4
+
k
]
=
addweights
[
ilink
].
weight
[
k
];
}
#ifdef _OPENMP
free
(
addweights
);
#else
Free
(
addweights
);
#endif
}
}
Free
(
weightlinks
[
0
].
addweights
);
}
}
Write
Preview
Supports
Markdown
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