Commit 55ed82d1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

rect_grid_search: fixed rounding errors.

parent 529fd24a
......@@ -806,7 +806,7 @@ void *Remap(void *argument)
get_remap_env();
if ( cdoVerbose ) cdoPrint("Extrapolation %s!", remap_extrapolate?"enabled":"disables");
if ( cdoVerbose ) cdoPrint("Extrapolation %s!", remap_extrapolate?"enabled":"disabled");
if ( lremapxxx )
{
......
......@@ -85,8 +85,8 @@ long find_element(double x, long nelem, const double *restrict array)
return mid;
}
/*
static
long find_element(double x, long nelem, const double *array)
{
long ii;
......@@ -108,13 +108,16 @@ long find_element(double x, long nelem, const double *array)
int rect_grid_search(size_t *ii, size_t *jj, double x, double y, size_t nxm, size_t nym, const double *restrict xm, const double *restrict ym)
{
constexpr double rtol = 1.e-12;
int lfound = 0;
*jj = find_element(y, nym, ym);
*jj = find_element(y, nym, ym);
if ( *jj >= nym && fabs(ym[0]-y) < rtol ) *jj = 1; // fix rounding errors
if ( *jj < nym )
{
*ii = find_element(x, nxm, xm);
if ( *ii >= nxm && fabs(xm[0]-x) < rtol ) *ii = 1; // fix rounding errors
if ( *ii < nxm ) lfound = 1;
}
......
......@@ -19,7 +19,7 @@ GRIDS="n16 n32"
IFILE=$DATAPATH/bathy4.grb
NTEST=1
#
for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
for GRIDTYPE in regular curvilinear unstructured; do
SETGRID=""
if [ "$GRIDTYPE" != "regular" ]; then SETGRID="-setgridtype,$GRIDTYPE"; fi
for GRID in $GRIDS; do
......
......@@ -20,29 +20,35 @@ for RMOD in $RMODS; do
if [ $RMOD = dis ]; then ABSLIM=$ABSLIMDIS; fi
CDOTEST="remap${RMOD} regional"
RSTAT=0
for extra in def off on; do
# for extra in def off on; do
for extra in def; do
EXTRA="$extra"
if [ "$EXTRA" = "def" ]; then EXTRA=""; fi
OFILE=topo_eu5_${RMOD}_${extra}$$
RFILE=$DATAPATH/topo_eu5_${RMOD}_${extra}_ref
rm -f Remap2_${RMOD}_${extra}.debug
DEBUG_OUT="--seperateDebugFromLog Remap2_${RMOD}_${extra}.debug"
CDOCOMMAND="$CDO $DEBUG_OUT $FORMAT remap${RMOD},$GRID $IFILE ${OFILE}"
for GRIDTYPE in regular curvilinear; do
SETGRID=""
if [ "$GRIDTYPE" != "regular" ]; then SETGRID="-setgridtype,$GRIDTYPE"; fi
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
rm -f Remap2_${RMOD}_${extra}.debug
DEBUG_OUT="--seperateDebugFromLog Remap2_${RMOD}_${extra}.debug"
CDOCOMMAND="$CDO $DEBUG_OUT $FORMAT remap${RMOD},$GRID $SETGRID $IFILE ${OFILE}"
REMAP_EXTRAPOLATE=$EXTRA $CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
echo "Running test: $NTEST"
echo "$CDOCOMMAND"
$CDO $DEBUG_OUT diff,$ABSLIM $OFILE $RFILE > $CDOOUT 2> $CDOERR
test $? -eq 0 || let RSTAT+=1
test -s $CDOOUT && let RSTAT+=1
cat $CDOOUT $CDOERR
REMAP_EXTRAPOLATE=$EXTRA $CDOCOMMAND
test $? -eq 0 || let RSTAT+=1
rm -f $OFILE
$CDO $DEBUG_OUT diff,$ABSLIM $OFILE $RFILE > $CDOOUT 2> $CDOERR
test $? -eq 0 || let RSTAT+=1
test -s $CDOOUT && let RSTAT+=1
cat $CDOOUT $CDOERR
rm -f $OFILE
done
done
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
......
......@@ -5,17 +5,6 @@ CDO=cdo
FORMAT="-f srv -b F32"
########################################################################
#
# smooth
#
IFILE=t21_geosp_tsurf_sea.grb
#
OFILE=smooth
$CDO $FORMAT smooth,radius=5deg $IFILE ${OFILE}1_ref
$CDO $FORMAT smooth,radius=5deg,maxpoints=3 $IFILE ${OFILE}2_ref
$CDO $FORMAT smooth,radius=5deg,nsmooth=9 $IFILE ${OFILE}3_ref
exit
########################################################################
#
# Remap regional grid
#
RMODS="bil bic dis nn con con2 ycon laf"
......@@ -33,6 +22,17 @@ done
exit
########################################################################
#
# smooth
#
IFILE=t21_geosp_tsurf_sea.grb
#
OFILE=smooth
$CDO $FORMAT smooth,radius=5deg $IFILE ${OFILE}1_ref
$CDO $FORMAT smooth,radius=5deg,maxpoints=3 $IFILE ${OFILE}2_ref
$CDO $FORMAT smooth,radius=5deg,nsmooth=9 $IFILE ${OFILE}3_ref
exit
########################################################################
#
# Timpctl Yearpctl Monstat Daypctl
#
PCTLS="50"
......
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