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

Removed some SX defines.

parent 933efab1
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef _DMEMORY_H
#ifndef _DMEMORY_H
#include "dmemory.h"
#endif
......@@ -10,7 +10,7 @@
#include "cdo_int.h"
#ifdef SX
#ifdef SX
#define NFFT 1024
#else
#define NFFT 8
......
......@@ -760,16 +760,10 @@ void interpolate(field_type *field1, field_type *field2)
|| lon[nlon] >= lon[ 0] + 360 - 0.001);
for (ilat = 0; ilat < nlat; ilat++)
#if defined(SX)
#pragma vdir nodep
#endif
for (ilon = 0; ilon < nlon; ilon++)
xin[2 * ilat + 1][2 * ilon + 1] = in0[ilat][ilon];
for (ilat = 0; ilat < nxlat; ilat += 2)
#if defined(SX)
#pragma vdir nodep
#endif
for (ilon = 1; ilon < nxlon; ilon += 2)
{
sum = 0;
......@@ -788,9 +782,6 @@ void interpolate(field_type *field1, field_type *field2)
}
for ( ilat = 1; ilat < nxlat; ilat += 2 )
#if defined(SX)
#pragma vdir nodep
#endif
for ( ilon = 0; ilon < nxlon; ilon += 2 )
{
sum = 0;
......@@ -819,9 +810,6 @@ void interpolate(field_type *field1, field_type *field2)
}
for ( ilat = 0; ilat < nxlat; ilat += 2 )
#if defined(SX)
#pragma vdir nodep
#endif
for ( ilon = 0; ilon < nxlon; ilon += 2 )
{
sum = 0;
......
......@@ -14,6 +14,7 @@
static
void set_bicubic_weights(double iw, double jw, double wgts[4][4])
{
// clang-format off
wgts[0][0] = (1.-jw*jw*(3.-2.*jw)) * (1.-iw*iw*(3.-2.*iw));
wgts[1][0] = (1.-jw*jw*(3.-2.*jw)) * iw*iw*(3.-2.*iw);
wgts[2][0] = jw*jw*(3.-2.*jw) * iw*iw*(3.-2.*iw);
......@@ -30,6 +31,7 @@ void set_bicubic_weights(double iw, double jw, double wgts[4][4])
wgts[1][3] = iw*iw*(iw-1.) * jw*(jw-1.)*(jw-1.);
wgts[2][3] = iw*iw*(iw-1.) * jw*jw*(jw-1.);
wgts[3][3] = iw*(iw-1.)*(iw-1.) * jw*jw*(jw-1.);
// clang-format on
}
unsigned num_src_points(const int* restrict mask, const size_t src_add[4], double src_lats[4]);
......@@ -37,14 +39,13 @@ unsigned num_src_points(const int* restrict mask, const size_t src_add[4], doubl
static
void renormalize_weights(const double src_lats[4], double wgts[4][4])
{
unsigned n;
double sum_wgts = 0.0; /* sum of weights for normalization */
/* 2012-05-08 Uwe Schulzweida: using absolute value of src_lats (bug fix) */
for ( n = 0; n < 4; ++n ) sum_wgts += fabs(src_lats[n]);
for ( n = 0; n < 4; ++n ) wgts[n][0] = fabs(src_lats[n])/sum_wgts;
for ( n = 0; n < 4; ++n ) wgts[n][1] = 0.;
for ( n = 0; n < 4; ++n ) wgts[n][2] = 0.;
for ( n = 0; n < 4; ++n ) wgts[n][3] = 0.;
for ( unsigned n = 0; n < 4; ++n ) sum_wgts += fabs(src_lats[n]);
for ( unsigned n = 0; n < 4; ++n ) wgts[n][0] = fabs(src_lats[n])/sum_wgts;
for ( unsigned n = 0; n < 4; ++n ) wgts[n][1] = 0.;
for ( unsigned n = 0; n < 4; ++n ) wgts[n][2] = 0.;
for ( unsigned n = 0; n < 4; ++n ) wgts[n][3] = 0.;
}
static
......
......@@ -85,10 +85,12 @@ bool find_ij_weights(double plon, double plat, double *restrict src_lons, double
static
void set_bilinear_weights(double iw, double jw, double wgts[4])
{
// clang-format off
wgts[0] = (1.-iw) * (1.-jw);
wgts[1] = iw * (1.-jw);
wgts[2] = iw * jw;
wgts[3] = (1.-iw) * jw;
// clang-format on
}
......
......@@ -586,9 +586,6 @@ void remapNormalizeWeights(remapgrid_t *tgt_grid, remapvars_t *rv)
if ( rv->normOpt == NormOpt::DESTAREA )
{
#if defined(SX)
#pragma vdir nodep
#endif
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(num_wts, num_links, rv, tgt_grid) \
......@@ -597,20 +594,12 @@ void remapNormalizeWeights(remapgrid_t *tgt_grid, remapvars_t *rv)
for ( size_t n = 0; n < num_links; ++n )
{
tgt_cell_add = rv->tgt_cell_add[n];
if ( IS_NOT_EQUAL(tgt_grid->cell_area[tgt_cell_add], 0) )
norm_factor = 1./tgt_grid->cell_area[tgt_cell_add];
else
norm_factor = 0.;
norm_factor = IS_NOT_EQUAL(tgt_grid->cell_area[tgt_cell_add], 0) ? 1./tgt_grid->cell_area[tgt_cell_add] : 0.;
rv->wts[n*num_wts] *= norm_factor;
}
}
else if ( rv->normOpt == NormOpt::FRACAREA )
{
#if defined(SX)
#pragma vdir nodep
#endif
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(num_wts, num_links, rv, tgt_grid) \
......@@ -619,12 +608,7 @@ void remapNormalizeWeights(remapgrid_t *tgt_grid, remapvars_t *rv)
for ( size_t n = 0; n < num_links; ++n )
{
tgt_cell_add = rv->tgt_cell_add[n];
if ( IS_NOT_EQUAL(tgt_grid->cell_frac[tgt_cell_add], 0) )
norm_factor = 1./tgt_grid->cell_frac[tgt_cell_add];
else
norm_factor = 0.;
norm_factor = IS_NOT_EQUAL(tgt_grid->cell_frac[tgt_cell_add], 0) ? 1./tgt_grid->cell_frac[tgt_cell_add] : 0.;
rv->wts[n*num_wts] *= norm_factor;
}
}
......
......@@ -1026,9 +1026,7 @@ void correct_pole(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv,
if ( src_grid->cell_area[n] < -THREE*PIH && src_grid->cell_center_lat[n] > ZERO )
{
src_cell_add = n;
#ifndef SX
break;
#endif
}
tgt_cell_add = tgt_grid_size;
......@@ -1037,9 +1035,7 @@ void correct_pole(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv,
if ( tgt_grid->cell_area[n] < -THREE*PIH && tgt_grid->cell_center_lat[n] > ZERO )
{
tgt_cell_add = n;
#ifndef SX
break;
#endif
}
if ( src_cell_add != src_grid_size )
......@@ -1081,9 +1077,7 @@ void correct_pole(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv,
if ( src_grid->cell_area[n] < -THREE*PIH && src_grid->cell_center_lat[n] < ZERO )
{
src_cell_add = n;
#ifndef SX
break;
#endif
}
tgt_cell_add = tgt_grid_size;
......@@ -1092,9 +1086,7 @@ void correct_pole(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv,
if ( tgt_grid->cell_area[n] < -THREE*PIH && tgt_grid->cell_center_lat[n] < ZERO )
{
tgt_cell_add = n;
#ifndef SX
break;
#endif
}
if ( src_cell_add != src_grid_size )
......@@ -1123,7 +1115,7 @@ void correct_pole(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv,
}
}
static
static inline
void norm_weight(double norm_factor, double *weights, double src_centroid_lat, double src_centroid_lon)
{
double weight0 = weights[0];
......@@ -1145,9 +1137,6 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
if ( rv->normOpt == NormOpt::DESTAREA )
{
#if defined(SX)
#pragma vdir nodep
#endif
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon) \
......@@ -1156,20 +1145,12 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
for ( long n = 0; n < num_links; ++n )
{
src_cell_add = rv->src_cell_add[n]; tgt_cell_add = rv->tgt_cell_add[n];
if ( IS_NOT_EQUAL(tgt_grid->cell_area[tgt_cell_add], 0) )
norm_factor = ONE/tgt_grid->cell_area[tgt_cell_add];
else
norm_factor = ZERO;
norm_factor = IS_NOT_EQUAL(tgt_grid->cell_area[tgt_cell_add], 0) ? ONE/tgt_grid->cell_area[tgt_cell_add] : ZERO;
norm_weight(norm_factor, &weights[n*3], src_centroid_lat[src_cell_add], src_centroid_lon[src_cell_add]);
}
}
else if ( rv->normOpt == NormOpt::FRACAREA )
{
#if defined(SX)
#pragma vdir nodep
#endif
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon) \
......@@ -1178,20 +1159,12 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
for ( long n = 0; n < num_links; ++n )
{
src_cell_add = rv->src_cell_add[n]; tgt_cell_add = rv->tgt_cell_add[n];
if ( IS_NOT_EQUAL(tgt_grid->cell_frac[tgt_cell_add], 0) )
norm_factor = ONE/tgt_grid->cell_frac[tgt_cell_add];
else
norm_factor = ZERO;
norm_factor = IS_NOT_EQUAL(tgt_grid->cell_frac[tgt_cell_add], 0) ? ONE/tgt_grid->cell_frac[tgt_cell_add] : ZERO;
norm_weight(norm_factor, &weights[n*3], src_centroid_lat[src_cell_add], src_centroid_lon[src_cell_add]);
}
}
else if ( rv->normOpt == NormOpt::NONE )
{
#if defined(SX)
#pragma vdir nodep
#endif
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon) \
......@@ -1199,10 +1172,8 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
#endif
for ( long n = 0; n < num_links; ++n )
{
src_cell_add = rv->src_cell_add[n];;
src_cell_add = rv->src_cell_add[n];
norm_factor = ONE;
norm_weight(norm_factor, &weights[n*3], src_centroid_lat[src_cell_add], src_centroid_lon[src_cell_add]);
}
}
......@@ -1272,18 +1243,12 @@ void scrip_remap_conserv_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
link_add2[0] = (long*) Malloc(tgt_grid_size*sizeof(long));
link_add2[1] = (long*) Malloc(tgt_grid_size*sizeof(long));
#if defined(SX)
#pragma vdir nodep
#endif
for ( long n = 0; n < src_grid_size; ++n )
{
link_add1[0][n] = -1;
link_add1[1][n] = -1;
}
#if defined(SX)
#pragma vdir nodep
#endif
for ( long n = 0; n < tgt_grid_size; ++n )
{
link_add2[0][n] = -1;
......
......@@ -24,17 +24,17 @@ void nbr_store_distance(size_t nadd, double distance, size_t numNeighbors, size_
}
else
{
for ( size_t nchk = 0; nchk < numNeighbors; ++nchk )
for ( size_t i = 0; i < numNeighbors; ++i )
{
if ( distance < nbr_dist[nchk] || (distance <= nbr_dist[nchk] && nadd < nbr_add[nchk]) )
if ( distance < nbr_dist[i] || (distance <= nbr_dist[i] && nadd < nbr_add[i]) )
{
for ( size_t n = numNeighbors-1; n > nchk; --n )
for ( size_t n = numNeighbors-1; n > i; --n )
{
nbr_add[n] = nbr_add[n-1];
nbr_dist[n] = nbr_dist[n-1];
}
nbr_add[nchk] = nadd;
nbr_dist[nchk] = distance;
nbr_add[i] = nadd;
nbr_dist[i] = distance;
break;
}
}
......@@ -45,8 +45,8 @@ static
void nbr_check_distance(size_t numNeighbors, const size_t *restrict nbr_add, double *restrict nbr_dist)
{
// If distance is zero, set to small number
for ( size_t nchk = 0; nchk < numNeighbors; ++nchk )
if ( nbr_add[nchk] < SIZE_MAX && nbr_dist[nchk] <= 0. ) nbr_dist[nchk] = TINY;
for ( size_t i = 0; i < numNeighbors; ++i )
if ( nbr_add[i] < SIZE_MAX && nbr_dist[i] <= 0. ) nbr_dist[i] = TINY;
}
......
Markdown is supported
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