check PnetCDF setting on erange-fill and adjust

This commit is contained in:
Wei-keng Liao 2016-11-14 10:41:10 -06:00
parent e8cfdbb25a
commit 154b805dc4
2 changed files with 65 additions and 21 deletions

View File

@ -985,41 +985,59 @@ IF(ENABLE_PNETCDF)
ENDIF(NOT PNETCDF)
ENDIF()
# Options to enable use of fill values for elements casuing NC_ERANGE
SET(STATUS_ERANGE_FILL "ON")
OPTION(ENABLE_ERANGE_FILL "Enable use of fill value when out-of-range type conversion causes NC_ERANGE error." ON)
IF(NOT ENABLE_ERANGE_FILL)
SET(STATUS_ERANGE_FILL "OFF")
ENDIF()
# Options to use a more relaxed coordinate argument boundary check
SET(STATUS_RELAX_COORD_BOUND "OFF")
OPTION(ENABLE_RELAX_COORD_BOUND "Enable a more relaxed boundary error check NC_EINVALCOORDS to allow coordinate start argument equal to dimension size when argument count is zero." OFF)
IF(ENABLE_RELAX_COORD_BOUND)
SET(STATUS_RELAX_COORD_BOUND "ON")
ENDIF()
# check and conform with PnetCDF settings on ERANGE_FILL and RELAX_COORD_BOUND
IF(STATUS_PNETCDF)
file(STRINGS "${pnetcdf_h}" enable_erange_fill_pnetcdf REGEX "^#define PNETCDF_ERANGE_FILL")
string(REGEX REPLACE "[^0-9]" "" erange_fill_pnetcdf "${enable_erange_fill_pnetcdf}")
IF("x${erange_fill_pnetcdf}" STREQUAL "x1")
IF(NOT STATUS_ERANGE_FILL)
MESSAGE(WARNING "Enable erange-fill to conform with PnetCDF setting")
SET(STATUS_ERANGE_FILL "ON")
ENDIF()
ELSE()
IF(STATUS_ERANGE_FILL)
MESSAGE(WARNING "Disable erange-fill to conform with PnetCDF setting")
SET(STATUS_ERANGE_FILL "OFF")
ENDIF()
ENDIF()
file(STRINGS "${pnetcdf_h}" relax_coord_bound_pnetcdf REGEX "^#define PNETCDF_RELAX_COORD_BOUND")
string(REGEX REPLACE "[^0-9]" "" relax_coord_bound "${relax_coord_bound_pnetcdf}")
IF("x${relax_coord_bound}" EQUAL "x1")
IF(NOT ${STATUS_RELAX_COORD_BOUND})
IF("x${relax_coord_bound}" STREQUAL "x1")
IF(NOT STATUS_RELAX_COORD_BOUND)
MESSAGE(WARNING "Enable relax-coord-bound to conform with PnetCDF setting")
SET(STATUS_RELAX_COORD_BOUND "ON")
ENDIF()
ELSE()
IF(${STATUS_RELAX_COORD_BOUND})
IF(STATUS_RELAX_COORD_BOUND)
MESSAGE(WARNING "Disable relax-coord-bound to conform with PnetCDF setting")
SET(STATUS_RELAX_COORD_BOUND "OFF")
ENDIF()
ENDIF()
ENDIF()
IF(STATUS_ERANGE_FILL)
SET(M4FLAGS "-DERANGE_FILL" CACHE STRING "")
ENDIF()
IF(STATUS_RELAX_COORD_BOUND)
MESSAGE(STATUS "Enabling a more relatexed check for NC_EINVALCOORDS")
ADD_DEFINITIONS(-DRELAX_COORD_BOUND)
ENDIF()
# Options to enable use of fill values for elements casuing NC_ERANGE
SET(STATUS_ERANGE_FILL "ON")
OPTION(DISABLE_ERANGE_FILL "Disable use of fill value when out-of-range type conversion causes NC_ERANGE error." OFF)
IF(DISABLE_ERANGE_FILL)
SET(STATUS_ERANGE_FILL "OFF")
ELSE()
SET(M4FLAGS "-DERANGE_FILL" CACHE STRING "")
ENDIF()
# Enable Parallel Tests.
OPTION(ENABLE_PARALLEL_TESTS "Enable Parallel IO Tests. Ignored if netCDF4 is not enabled, or if there is no parallel I/O Support." ${USE_PARALLEL})
IF(ENABLE_PARALLEL_TESTS AND USE_PARALLEL)

View File

@ -1086,14 +1086,6 @@ AC_ARG_ENABLE([erange_fill],
conversion causes NC_ERANGE error. @<:@default: enabled@:>@])],
[enable_erange_fill=${enableval}], [enable_erange_fill=yes]
)
if test "x$enable_erange_fill" = xyes ; then
if test "x$M4FLAGS" = x ; then
M4FLAGS="-DERANGE_FILL"
else
M4FLAGS="$M4FLAGS -DERANGE_FILL"
fi
fi
AC_SUBST(M4FLAGS)
AC_ARG_ENABLE([relax-coord-bound],
[AS_HELP_STRING([--enable-relax-coord-bound],
@ -1103,9 +1095,33 @@ AC_ARG_ENABLE([relax-coord-bound],
[enable_relax_coord_bound=${enableval}], [enable_relax_coord_bound=no]
)
# check PnetCDF's settings on enable_erange_fill and relax_coord_bound
if test "x$enable_pnetcdf" = xyes; then
UD_CHECK_HEADER_PATH([pnetcdf.h])
AC_MSG_CHECKING([if relax_coord_bound is enabled in PnetCDF])
AC_MSG_CHECKING([if erange-fill is enabled in PnetCDF])
erange_fill_pnetcdf=`grep PNETCDF_ERANGE_FILL ${ac_cv_header_path_pnetcdf_h}`
if test "x$erange_fill_pnetcdf" = x; then
erange_fill_pnetcdf=no
else
erange_fill_pnetcdf=`echo ${erange_fill_pnetcdf} | cut -d' ' -f3`
if test "x$coord_bound_pnetcdf" = x0; then
enable_erange_fill_pnetcdf=no
else
enable_erange_fill_pnetcdf=yes
fi
fi
AC_MSG_NOTICE([$enable_erange_fill_pnetcdf])
if test "$enable_erange_fill" != "$enable_erange_fill_pnetcdf"; then
if test "$enable_erange_fill_pnetcdf" = yes; then
AC_MSG_WARN([Enable erange-fill to conform with PnetCDF setting])
else
AC_MSG_WARN([Disable erange-fill to conform with PnetCDF setting])
fi
enable_erange_fill=$enable_erange_fill_pnetcdf
fi
AC_MSG_CHECKING([if relax-coord-bound is enabled in PnetCDF])
relax_coord_bound_pnetcdf=`grep PNETCDF_RELAX_COORD_BOUND ${ac_cv_header_path_pnetcdf_h}`
if test "x$relax_coord_bound_pnetcdf" = x; then
relax_coord_bound_pnetcdf=no
@ -1127,6 +1143,16 @@ if test "x$enable_pnetcdf" = xyes; then
enable_relax_coord_bound=$relax_coord_bound_pnetcdf
fi
fi
if test "x$enable_erange_fill" = xyes ; then
if test "x$M4FLAGS" = x ; then
M4FLAGS="-DERANGE_FILL"
else
M4FLAGS="$M4FLAGS -DERANGE_FILL"
fi
fi
AC_SUBST(M4FLAGS)
if test "x$enable_relax_coord_bound" = xyes; then
AC_DEFINE([RELAX_COORD_BOUND], [1], [if true, NC_EINVALCOORDS check is more relaxed])
fi