Commit c0807f3d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

remap cleanup

parent ae8b7e5e
......@@ -150,7 +150,8 @@ void bilinear_remap(double* restrict tgt_point, const double* restrict src_array
{
// *tgt_point = 0.;
// for ( int n = 0; n < 4; ++n ) *tgt_point += src_array[src_add[n]]*wgts[n];
*tgt_point = src_array[src_add[0]]*wgts[0] + src_array[src_add[1]]*wgts[1] + src_array[src_add[2]]*wgts[2] + src_array[src_add[3]]*wgts[3];
*tgt_point = src_array[src_add[0]]*wgts[0] + src_array[src_add[1]]*wgts[1]
+ src_array[src_add[2]]*wgts[2] + src_array[src_add[3]]*wgts[3];
}
/*
......@@ -164,7 +165,7 @@ void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid,
{
/* Local variables */
int search_result;
long tgt_cell_add; /* destination addresss */
long tgt_cell_add; /* destination addresss */
int src_add[4]; /* address for the four source points */
double src_lats[4]; /* latitudes of four bilinear corners */
double src_lons[4]; /* longitudes of four bilinear corners */
......@@ -292,7 +293,7 @@ void scrip_remap_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid, const do
/* Local variables */
int search_result;
long tgt_grid_size;
long tgt_cell_add; /* destination addresss */
long tgt_cell_add; /* destination addresss */
int src_add[4]; /* address for the four source points */
double src_lats[4]; /* latitudes of four bilinear corners */
double src_lons[4]; /* longitudes of four bilinear corners */
......
......@@ -341,12 +341,11 @@ void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remap
{
/* Local variables */
long n, nadds;
long tgt_cell_add; /* destination address */
long tgt_cell_add; /* destination address */
double dist_tot; /* sum of neighbor distances (for normalizing) */
double *coslat, *sinlat; /* cosine, sine of grid lats (for distance) */
double *coslon, *sinlon; /* cosine, sine of grid lons (for distance) */
double plat, plon; /* lat/lon coords of destination point */
double findex = 0;
int remap_grid_type = src_grid->remap_grid_type;
if ( cdoVerbose ) cdoPrint("Called %s()", __func__);
......@@ -412,6 +411,9 @@ void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remap
}
/* Loop over destination grid */
double findex = 0;
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(ompNumThreads, weightlinks, num_neighbors, remap_grid_type, src_grid, tgt_grid, rv, tgt_grid_size, coslat, coslon, sinlat, sinlon, findex) \
......
......@@ -178,15 +178,15 @@ void weightlinks2remaplinks(long tgt_grid_size, weightlinks_t *weightlinks, rema
#if defined(_OPENMP)
#pragma omp parallel for default(shared) \
shared(rv, weightlinks) \
shared(rv, weightlinks) \
private(tgt_cell_add)
#endif
for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
{
long num_links = weightlinks[tgt_cell_add].nlinks;
long offset = weightlinks[tgt_cell_add].offset;
if ( num_links )
{
long offset = weightlinks[tgt_cell_add].offset;
for ( long ilink = 0; ilink < num_links; ++ilink )
{
rv->src_cell_add[offset+ilink] = weightlinks[tgt_cell_add].addweights[ilink].add;
......@@ -230,17 +230,18 @@ void weightlinks2remaplinks4(long tgt_grid_size, weightlinks4_t *weightlinks, re
for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
{
long num_links = weightlinks[tgt_cell_add].nlinks;
long offset = weightlinks[tgt_cell_add].offset;
if ( num_links )
{
long offset = weightlinks[tgt_cell_add].offset;
addweight4_t *addweights = weightlinks[tgt_cell_add].addweights;
for ( long ilink = 0; ilink < num_links; ++ilink )
{
rv->src_cell_add[offset+ilink] = weightlinks[tgt_cell_add].addweights[ilink].add;
rv->src_cell_add[offset+ilink] = addweights[ilink].add;
rv->tgt_cell_add[offset+ilink] = tgt_cell_add;
for ( long k = 0; k < 4; ++k )
rv->wts[(offset+ilink)*4+k] = weightlinks[tgt_cell_add].addweights[ilink].weight[k];
rv->wts[(offset+ilink)*4+k] = addweights[ilink].weight[k];
}
free(weightlinks[tgt_cell_add].addweights);
free(addweights);
}
}
}
......
......@@ -38,8 +38,8 @@ done
# result on hama2: gcc 4.9.2
# =================
# bil bic nn con ycon
# reg2d 0.5 1.2 0.7 152 112
# curv 27 27 70 152 197
# reg2d 0.6 1.3 0.7 151 86
# curv 26 27 71 152 172
#
# CDO 1.6.4
#
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment