Skip to content
GitLab
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
22326140
Commit
22326140
authored
Jul 27, 2015
by
Uwe Schulzweida
Browse files
renamed scrip_remap_weights_distwgt() to remap_distwgt_weights()
parent
4bdf5a33
Changes
6
Hide whitespace changes
Inline
Side-by-side
.gitattributes
View file @
22326140
...
...
@@ -631,7 +631,7 @@ src/remap_bicubic_scrip.c -text
src/remap_bilinear_scrip.c -text
src/remap_conserv.c -text
src/remap_conserv_scrip.c -text
src/remap_distwgt
_scrip
.c -text
src/remap_distwgt.c -text
src/remap_scrip_io.c -text
src/remap_search_latbins.c -text
src/remap_search_reg2d.c -text
...
...
src/Makefile.am
View file @
22326140
...
...
@@ -116,7 +116,7 @@ libcdo_la_SOURCES = \
remap_store_link_cnsrv.h
\
remap_conserv.c
\
remap_conserv_scrip.c
\
remap_distwgt
_scrip
.c
\
remap_distwgt.c
\
remap_bicubic_scrip.c
\
remap_bilinear_scrip.c
\
stdnametable.c
\
...
...
src/Makefile.in
View file @
22326140
...
...
@@ -148,8 +148,7 @@ am_libcdo_la_OBJECTS = libcdo_la-cdo_pthread.lo libcdo_la-cdo_vlist.lo \
libcdo_la-remap_search_latbins.lo \
libcdo_la-remap_store_link.lo \
libcdo_la-remap_store_link_cnsrv.lo libcdo_la-remap_conserv.lo \
libcdo_la-remap_conserv_scrip.lo \
libcdo_la-remap_distwgt_scrip.lo \
libcdo_la-remap_conserv_scrip.lo libcdo_la-remap_distwgt.lo \
libcdo_la-remap_bicubic_scrip.lo \
libcdo_la-remap_bilinear_scrip.lo libcdo_la-stdnametable.lo \
libcdo_la-specspace.lo libcdo_la-statistic.lo \
...
...
@@ -571,7 +570,7 @@ libcdo_la_SOURCES = cdo_int.h compare.h cdo_pthread.c cdo_vlist.c \
remaplib.c remapsort.c remap_scrip_io.c remap_search_reg2d.c \
remap_search_latbins.c remap_store_link.c remap_store_link.h \
remap_store_link_cnsrv.c remap_store_link_cnsrv.h \
remap_conserv.c remap_conserv_scrip.c remap_distwgt
_scrip
.c \
remap_conserv.c remap_conserv_scrip.c remap_distwgt.c \
remap_bicubic_scrip.c remap_bilinear_scrip.c stdnametable.c \
stdnametable.h specspace.c specspace.h statistic.c statistic.h \
table.c text.c text.h timebase.h timer.c userlog.c util.c \
...
...
@@ -1064,7 +1063,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_bilinear_scrip.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_conserv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_conserv_scrip.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_distwgt
_scrip
.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_distwgt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_scrip_io.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_search_latbins.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-remap_search_reg2d.Plo@am__quote@
...
...
@@ -1587,12 +1586,12 @@ libcdo_la-remap_conserv_scrip.lo: remap_conserv_scrip.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-remap_conserv_scrip.lo `test -f 'remap_conserv_scrip.c' || echo '$(srcdir)/'`remap_conserv_scrip.c
libcdo_la-remap_distwgt
_scrip
.lo: remap_distwgt
_scrip
.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-remap_distwgt
_scrip
.lo -MD -MP -MF $(DEPDIR)/libcdo_la-remap_distwgt
_scrip
.Tpo -c -o libcdo_la-remap_distwgt
_scrip
.lo `test -f 'remap_distwgt
_scrip
.c' || echo '$(srcdir)/'`remap_distwgt
_scrip
.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-remap_distwgt
_scrip
.Tpo $(DEPDIR)/libcdo_la-remap_distwgt
_scrip
.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='remap_distwgt
_scrip
.c' object='libcdo_la-remap_distwgt
_scrip
.lo' libtool=yes @AMDEPBACKSLASH@
libcdo_la-remap_distwgt.lo: remap_distwgt.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-remap_distwgt.lo -MD -MP -MF $(DEPDIR)/libcdo_la-remap_distwgt.Tpo -c -o libcdo_la-remap_distwgt.lo `test -f 'remap_distwgt.c' || echo '$(srcdir)/'`remap_distwgt.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-remap_distwgt.Tpo $(DEPDIR)/libcdo_la-remap_distwgt.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='remap_distwgt.c' object='libcdo_la-remap_distwgt.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-remap_distwgt
_scrip
.lo `test -f 'remap_distwgt
_scrip
.c' || echo '$(srcdir)/'`remap_distwgt
_scrip
.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-remap_distwgt.lo `test -f 'remap_distwgt.c' || echo '$(srcdir)/'`remap_distwgt.c
libcdo_la-remap_bicubic_scrip.lo: remap_bicubic_scrip.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-remap_bicubic_scrip.lo -MD -MP -MF $(DEPDIR)/libcdo_la-remap_bicubic_scrip.Tpo -c -o libcdo_la-remap_bicubic_scrip.lo `test -f 'remap_bicubic_scrip.c' || echo '$(srcdir)/'`remap_bicubic_scrip.c
...
...
src/Remap.c
View file @
22326140
...
...
@@ -162,7 +162,7 @@ int maptype2operfunc(int map_type, int submap_type, int num_neighbors, int remap
}
static
void
print_remap_info
(
int
operfunc
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
int
nmiss
)
void
print_remap_info
(
int
operfunc
,
int
remap_genweights
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
int
nmiss
)
{
char
line
[
256
];
char
tmpstr
[
256
];
...
...
@@ -171,15 +171,19 @@ void print_remap_info(int operfunc, remapgrid_t *src_grid, remapgrid_t *tgt_grid
if
(
operfunc
==
REMAPBIL
||
operfunc
==
GENBIL
)
strcpy
(
line
,
"SCRIP bilinear"
);
else
if
(
operfunc
==
REMAPBIC
||
operfunc
==
GENBIC
)
strcpy
(
line
,
"SCRIP bicubic"
);
else
if
(
operfunc
==
REMAPNN
||
operfunc
==
GENNN
)
strcpy
(
line
,
"
SCRIP n
earest neighbor"
);
else
if
(
operfunc
==
REMAPDIS
||
operfunc
==
GENDIS
)
strcpy
(
line
,
"
SCRIP d
istance-weighted average"
);
else
if
(
operfunc
==
REMAPNN
||
operfunc
==
GENNN
)
strcpy
(
line
,
"
N
earest neighbor"
);
else
if
(
operfunc
==
REMAPDIS
||
operfunc
==
GENDIS
)
strcpy
(
line
,
"
D
istance-weighted average"
);
else
if
(
operfunc
==
REMAPCON
||
operfunc
==
GENCON
)
strcpy
(
line
,
"SCRIP first order conservative"
);
else
if
(
operfunc
==
REMAPCON2
||
operfunc
==
GENCON2
)
strcpy
(
line
,
"SCRIP second order conservative"
);
else
if
(
operfunc
==
REMAPLAF
||
operfunc
==
GENLAF
)
strcpy
(
line
,
"YAC largest area fraction"
);
else
if
(
operfunc
==
REMAPYCON
||
operfunc
==
GENYCON
)
strcpy
(
line
,
"YAC first order conservative"
);
else
strcpy
(
line
,
"Unknown"
);
strcat
(
line
,
" remapping from "
);
if
(
remap_genweights
)
strcat
(
line
,
" weights from "
);
else
strcat
(
line
,
" remapping from "
);
strcat
(
line
,
gridNamePtr
(
gridInqType
(
src_grid
->
gridID
)));
if
(
src_grid
->
rank
==
2
)
sprintf
(
tmpstr
,
" (%dx%d)"
,
src_grid
->
dims
[
0
],
src_grid
->
dims
[
1
]);
...
...
@@ -1129,14 +1133,14 @@ void *Remap(void *argument)
remap_vars_init
(
map_type
,
remaps
[
r
].
src_grid
.
size
,
remaps
[
r
].
tgt_grid
.
size
,
&
remaps
[
r
].
vars
);
if
(
cdoTimer
)
timer_stop
(
timer_remap_init
);
print_remap_info
(
operfunc
,
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
nmiss1
);
print_remap_info
(
operfunc
,
remap_genweights
,
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
nmiss1
);
if
(
remap_genweights
)
{
if
(
map_type
==
MAP_TYPE_CONSERV
)
scrip_remap_weights_conserv
(
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
&
remaps
[
r
].
vars
);
else
if
(
map_type
==
MAP_TYPE_BILINEAR
)
scrip_remap_weights_bilinear
(
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
&
remaps
[
r
].
vars
);
else
if
(
map_type
==
MAP_TYPE_BICUBIC
)
scrip_remap_weights_bicubic
(
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
&
remaps
[
r
].
vars
);
else
if
(
map_type
==
MAP_TYPE_DISTWGT
)
scrip_remap_weights_distwgt
(
num_neighbors
,
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
&
remaps
[
r
].
vars
);
else
if
(
map_type
==
MAP_TYPE_DISTWGT
)
remap_distwgt_weights
(
num_neighbors
,
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
&
remaps
[
r
].
vars
);
else
if
(
map_type
==
MAP_TYPE_CONSERV_YAC
)
remap_weights_conserv
(
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
&
remaps
[
r
].
vars
);
if
(
map_type
==
MAP_TYPE_CONSERV
&&
remaps
[
r
].
vars
.
num_links
!=
remaps
[
r
].
vars
.
max_links
)
...
...
@@ -1184,7 +1188,7 @@ void *Remap(void *argument)
{
if
(
map_type
==
MAP_TYPE_BILINEAR
)
scrip_remap_bilinear
(
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
array1
,
array2
,
missval
);
else
if
(
map_type
==
MAP_TYPE_BICUBIC
)
scrip_remap_bicubic
(
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
array1
,
array2
,
missval
);
else
if
(
map_type
==
MAP_TYPE_DISTWGT
)
scrip_
remap_distwgt
(
num_neighbors
,
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
array1
,
array2
,
missval
);
else
if
(
map_type
==
MAP_TYPE_DISTWGT
)
remap_distwgt
(
num_neighbors
,
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
array1
,
array2
,
missval
);
else
if
(
map_type
==
MAP_TYPE_CONSERV_YAC
)
remap_conserv
(
&
remaps
[
r
].
src_grid
,
&
remaps
[
r
].
tgt_grid
,
array1
,
array2
,
missval
);
}
...
...
src/remap.h
View file @
22326140
...
...
@@ -187,13 +187,13 @@ void remap_sum(double *restrict dst_array, double missval, long dst_size, long n
void
scrip_remap_weights_bilinear
(
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
);
void
scrip_remap_weights_bicubic
(
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
);
void
scrip_remap_weights_distwgt
(
int
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
);
void
remap_distwgt_weights
(
unsigned
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
);
void
scrip_remap_weights_conserv
(
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
);
void
remap_weights_conserv
(
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
);
void
scrip_remap_bilinear
(
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
const
double
*
restrict
src_array
,
double
*
restrict
tgt_array
,
double
missval
);
void
scrip_remap_bicubic
(
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
const
double
*
restrict
src_array
,
double
*
restrict
tgt_array
,
double
missval
);
void
scrip_
remap_distwgt
(
int
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
const
double
*
restrict
src_array
,
double
*
restrict
tgt_array
,
double
missval
);
void
remap_distwgt
(
unsigned
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
const
double
*
restrict
src_array
,
double
*
restrict
tgt_array
,
double
missval
);
void
remap_conserv
(
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
const
double
*
restrict
src_array
,
double
*
restrict
tgt_array
,
double
missval
);
...
...
src/remap_distwgt
_scrip
.c
→
src/remap_distwgt.c
View file @
22326140
...
...
@@ -45,13 +45,12 @@ void nbr_store_distance(int nadd, double distance, int num_neighbors, int *restr
}
static
void
nbr_check_distance
(
int
num_neighbors
,
const
int
*
restrict
nbr_add
,
double
*
restrict
nbr_dist
)
void
nbr_check_distance
(
unsigned
num_neighbors
,
const
int
*
restrict
nbr_add
,
double
*
restrict
nbr_dist
)
{
int
nchk
;
double
distance
;
/* Uwe Schulzweida: if distance is zero, set to small number */
for
(
nchk
=
0
;
nchk
<
num_neighbors
;
++
nchk
)
for
(
unsigned
nchk
=
0
;
nchk
<
num_neighbors
;
++
nchk
)
{
if
(
nbr_add
[
nchk
]
>=
0
)
{
...
...
@@ -62,6 +61,51 @@ void nbr_check_distance(int num_neighbors, const int *restrict nbr_add, double *
}
}
static
double
nbr_compute_weights
(
unsigned
num_neighbors
,
const
int
*
restrict
src_grid_mask
,
int
*
restrict
nbr_mask
,
const
int
*
restrict
nbr_add
,
double
*
restrict
nbr_dist
)
{
/* Compute weights based on inverse distance if mask is false, eliminate those points */
double
dist_tot
=
0
.;
/* sum of neighbor distances (for normalizing) */
for
(
unsigned
n
=
0
;
n
<
num_neighbors
;
++
n
)
{
// printf("tgt_cell_add %ld %ld %d %g\n", tgt_cell_add, n, nbr_add[n], nbr_dist[n]);
nbr_mask
[
n
]
=
FALSE
;
/* Uwe Schulzweida: check if nbr_add is valid */
if
(
nbr_add
[
n
]
>=
0
)
if
(
src_grid_mask
[
nbr_add
[
n
]]
)
{
nbr_dist
[
n
]
=
ONE
/
nbr_dist
[
n
];
dist_tot
=
dist_tot
+
nbr_dist
[
n
];
nbr_mask
[
n
]
=
TRUE
;
}
}
return
dist_tot
;
}
static
unsigned
nbr_normalize_weights
(
unsigned
num_neighbors
,
double
dist_tot
,
const
int
*
restrict
nbr_mask
,
int
*
restrict
nbr_add
,
double
*
restrict
nbr_dist
)
{
/* Normalize weights and store the link */
unsigned
nadds
=
0
;
for
(
unsigned
n
=
0
;
n
<
num_neighbors
;
++
n
)
{
if
(
nbr_mask
[
n
]
)
{
nbr_dist
[
nadds
]
=
nbr_dist
[
n
]
/
dist_tot
;
nbr_add
[
nadds
]
=
nbr_add
[
n
];
nadds
++
;
}
}
return
nadds
;
}
static
double
get_search_radius
(
void
)
{
...
...
@@ -304,13 +348,10 @@ void grid_search_nbr(struct gridsearch *gs, int num_neighbors, int *restrict nbr
-----------------------------------------------------------------------------------------
*/
void
scrip_remap_weights_distwgt
(
int
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
)
void
remap_distwgt_weights
(
unsigned
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
remapvars_t
*
rv
)
{
/* Local variables */
long
n
,
nadds
;
long
tgt_cell_add
;
/* destination address */
double
dist_tot
;
/* sum of neighbor distances (for normalizing) */
double
plat
,
plon
;
/* lat/lon coords of destination point */
unsigned
tgt_cell_add
;
/* destination address */
int
remap_grid_type
=
src_grid
->
remap_grid_type
;
if
(
cdoVerbose
)
cdoPrint
(
"Called %s()"
,
__func__
);
...
...
@@ -319,10 +360,10 @@ void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remap
/* Compute mappings from source to target grid */
long
src_grid_size
=
src_grid
->
size
;
long
tgt_grid_size
=
tgt_grid
->
size
;
long
nx
=
src_grid
->
dims
[
0
];
long
ny
=
src_grid
->
dims
[
1
];
unsigned
src_grid_size
=
src_grid
->
size
;
unsigned
tgt_grid_size
=
tgt_grid
->
size
;
unsigned
nx
=
src_grid
->
dims
[
0
];
unsigned
ny
=
src_grid
->
dims
[
1
];
weightlinks_t
*
weightlinks
=
(
weightlinks_t
*
)
malloc
(
tgt_grid_size
*
sizeof
(
weightlinks_t
));
...
...
@@ -343,7 +384,7 @@ void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remap
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(ompNumThreads, cdoSilentMode, gs, weightlinks, num_neighbors, remap_grid_type, src_grid, tgt_grid, tgt_grid_size, findex) \
private(tgt_cell_add,
n, nadds, dist_tot, plat, plon,
nbr_mask, nbr_add, nbr_dist)
private(tgt_cell_add, nbr_mask, nbr_add, nbr_dist)
#endif
for
(
tgt_cell_add
=
0
;
tgt_cell_add
<
tgt_grid_size
;
++
tgt_cell_add
)
{
...
...
@@ -363,8 +404,8 @@ void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remap
if
(
!
tgt_grid
->
mask
[
tgt_cell_add
]
)
continue
;
plat
=
tgt_grid
->
cell_center_lat
[
tgt_cell_add
];
plon
=
tgt_grid
->
cell_center_lon
[
tgt_cell_add
];
double
plat
=
tgt_grid
->
cell_center_lat
[
tgt_cell_add
];
double
plon
=
tgt_grid
->
cell_center_lon
[
tgt_cell_add
];
/* Find nearest grid points on source grid and distances to each point */
if
(
remap_grid_type
==
REMAP_GRID_TYPE_REG2D
)
...
...
@@ -375,36 +416,14 @@ void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remap
/* Compute weights based on inverse distance if mask is false, eliminate those points */
dist_tot
=
0
.;
for
(
n
=
0
;
n
<
num_neighbors
;
++
n
)
{
// printf("tgt_cell_add %ld %ld %d %g\n", tgt_cell_add, n, nbr_add[n], nbr_dist[n]);
nbr_mask
[
n
]
=
FALSE
;
/* Uwe Schulzweida: check if nbr_add is valid */
if
(
nbr_add
[
n
]
>=
0
)
if
(
src_grid
->
mask
[
nbr_add
[
n
]]
)
{
nbr_dist
[
n
]
=
ONE
/
nbr_dist
[
n
];
dist_tot
=
dist_tot
+
nbr_dist
[
n
];
nbr_mask
[
n
]
=
TRUE
;
}
}
double
dist_tot
=
nbr_compute_weights
(
num_neighbors
,
src_grid
->
mask
,
nbr_mask
,
nbr_add
,
nbr_dist
);
/* Normalize weights and store the link */
nadds
=
0
;
for
(
n
=
0
;
n
<
num_neighbors
;
++
n
)
{
if
(
nbr_mask
[
n
]
)
{
nbr_dist
[
nadds
]
=
nbr_dist
[
n
]
/
dist_tot
;
nbr_add
[
nadds
]
=
nbr_add
[
n
];
nadds
++
;
unsigned
nadds
=
nbr_normalize_weights
(
num_neighbors
,
dist_tot
,
nbr_mask
,
nbr_add
,
nbr_dist
);
tgt_grid
->
cell_frac
[
tgt_cell_add
]
=
ONE
;
}
}
for
(
unsigned
n
=
0
;
n
<
nadds
;
++
n
)
if
(
nbr_mask
[
n
]
)
tgt_grid
->
cell_frac
[
tgt_cell_add
]
=
ONE
;
store_weightlinks
(
nadds
,
nbr_add
,
nbr_dist
,
tgt_cell_add
,
weightlinks
);
}
...
...
@@ -425,13 +444,10 @@ void distwgt_remap(double* restrict tgt_point, const double* restrict src_array,
}
void
scrip_
remap_distwgt
(
int
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
const
double
*
restrict
src_array
,
double
*
restrict
tgt_array
,
double
missval
)
void
remap_distwgt
(
unsigned
num_neighbors
,
remapgrid_t
*
src_grid
,
remapgrid_t
*
tgt_grid
,
const
double
*
restrict
src_array
,
double
*
restrict
tgt_array
,
double
missval
)
{
/* Local variables */
long
n
,
nadds
;
long
tgt_cell_add
;
/* destination address */
double
dist_tot
;
/* sum of neighbor distances (for normalizing) */
double
plat
,
plon
;
/* lat/lon coords of destination point */
unsigned
tgt_cell_add
;
/* destination address */
int
remap_grid_type
=
src_grid
->
remap_grid_type
;
if
(
cdoVerbose
)
cdoPrint
(
"Called %s()"
,
__func__
);
...
...
@@ -440,10 +456,10 @@ void scrip_remap_distwgt(int num_neighbors, remapgrid_t *src_grid, remapgrid_t *
/* Compute mappings from source to target grid */
long
src_grid_size
=
src_grid
->
size
;
long
tgt_grid_size
=
tgt_grid
->
size
;
long
nx
=
src_grid
->
dims
[
0
];
long
ny
=
src_grid
->
dims
[
1
];
unsigned
src_grid_size
=
src_grid
->
size
;
unsigned
tgt_grid_size
=
tgt_grid
->
size
;
unsigned
nx
=
src_grid
->
dims
[
0
];
unsigned
ny
=
src_grid
->
dims
[
1
];
int
nbr_mask
[
num_neighbors
];
/* mask at nearest neighbors */
int
nbr_add
[
num_neighbors
];
/* source address at nearest neighbors */
...
...
@@ -471,7 +487,7 @@ void scrip_remap_distwgt(int num_neighbors, remapgrid_t *src_grid, remapgrid_t *
#pragma omp parallel for default(none) \
shared(ompNumThreads, cdoSilentMode, gs, num_neighbors, remap_grid_type, src_grid, tgt_grid, tgt_grid_size, findex) \
shared(src_array, tgt_array, missval) \
private(tgt_cell_add,
n, nadds, dist_tot, plat, plon,
nbr_mask, nbr_add, nbr_dist)
private(tgt_cell_add, nbr_mask, nbr_add, nbr_dist)
#endif
for
(
tgt_cell_add
=
0
;
tgt_cell_add
<
tgt_grid_size
;
++
tgt_cell_add
)
{
...
...
@@ -491,8 +507,8 @@ void scrip_remap_distwgt(int num_neighbors, remapgrid_t *src_grid, remapgrid_t *
if
(
!
tgt_grid
->
mask
[
tgt_cell_add
]
)
continue
;
plat
=
tgt_grid
->
cell_center_lat
[
tgt_cell_add
];
plon
=
tgt_grid
->
cell_center_lon
[
tgt_cell_add
];
double
plat
=
tgt_grid
->
cell_center_lat
[
tgt_cell_add
];
double
plon
=
tgt_grid
->
cell_center_lon
[
tgt_cell_add
];
/* Find nearest grid points on source grid and distances to each point */
if
(
remap_grid_type
==
REMAP_GRID_TYPE_REG2D
)
...
...
@@ -503,36 +519,14 @@ void scrip_remap_distwgt(int num_neighbors, remapgrid_t *src_grid, remapgrid_t *
/* Compute weights based on inverse distance if mask is false, eliminate those points */
dist_tot
=
0
.;
for
(
n
=
0
;
n
<
num_neighbors
;
++
n
)
{
// printf("tgt_cell_add %ld %ld %d %g\n", tgt_cell_add, n, nbr_add[n], nbr_dist[n]);
nbr_mask
[
n
]
=
FALSE
;
/* Uwe Schulzweida: check if nbr_add is valid */
if
(
nbr_add
[
n
]
>=
0
)
if
(
src_grid
->
mask
[
nbr_add
[
n
]]
)
{
nbr_dist
[
n
]
=
ONE
/
nbr_dist
[
n
];
dist_tot
=
dist_tot
+
nbr_dist
[
n
];
nbr_mask
[
n
]
=
TRUE
;
}
}
double
dist_tot
=
nbr_compute_weights
(
num_neighbors
,
src_grid
->
mask
,
nbr_mask
,
nbr_add
,
nbr_dist
);
/* Normalize weights and store the link */
nadds
=
0
;
for
(
n
=
0
;
n
<
num_neighbors
;
++
n
)
{
if
(
nbr_mask
[
n
]
)
{
nbr_dist
[
nadds
]
=
nbr_dist
[
n
]
/
dist_tot
;
nbr_add
[
nadds
]
=
nbr_add
[
n
];
nadds
++
;
unsigned
nadds
=
nbr_normalize_weights
(
num_neighbors
,
dist_tot
,
nbr_mask
,
nbr_add
,
nbr_dist
);
tgt_grid
->
cell_frac
[
tgt_cell_add
]
=
ONE
;
}
}
for
(
unsigned
n
=
0
;
n
<
nadds
;
++
n
)
if
(
nbr_mask
[
n
]
)
tgt_grid
->
cell_frac
[
tgt_cell_add
]
=
ONE
;
if
(
nadds
>
1
)
sort_add_and_wgts
(
nadds
,
nbr_add
,
nbr_dist
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment