Skip to content

Commit

Permalink
Merge branch 'master' into nc_open_mem_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thehesiod authored May 1, 2017
2 parents 90609f6 + 8dddd22 commit 23c14bd
Show file tree
Hide file tree
Showing 57 changed files with 11,389 additions and 8,422 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ ctest.c
ctest64.c
nc_test/test_get.c
nc_test/test_put.c
nc_test/test_read.c
nc_test/test_write.c

#####
# End ignored generated files.
Expand Down
87 changes: 75 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
##################################

#Minimum required CMake Version
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.6.1)

#Project Name
project(netCDF C)
Expand Down Expand Up @@ -101,10 +101,10 @@ INCLUDE(${CMAKE_ROOT}/Modules/GetPrerequisites.cmake)
INCLUDE(CheckCCompilerFlag)
FIND_PACKAGE(PkgConfig QUIET)

# Check for Big Endian
# A check to see if the system is big endian
TEST_BIG_ENDIAN(BIGENDIAN)
IF(${BIGENDIAN})
SET(WORDS_BIGENDIAN "1")
SET(WORDS_BIGENDIAN "1")
ENDIF(${BIGENDIAN})

# A macro to check if a C linker supports a particular flag.
Expand Down Expand Up @@ -627,6 +627,7 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
SET(HDF5_C_LIBRARY ${HDF5_C_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY})
SET(HDF5_C_LIBRARY_hdf5 ${HDF5_C_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY})
SET(HDF5_HL_LIBRARY ${HDF5_HL_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY})

SET(HDF5_LIBRARIES ${HDF5_C_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY} ${HDF5_HL_${NC_HDF5_LINK_TYPE_UPPER}_LIBRARY})
ENDIF()
ENDIF(${HDF5_VERSION} VERSION_GREATER "1.8.15")
Expand All @@ -651,12 +652,13 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF()

###
# The following options are not used in Windows.
# The following options are not used in Windows currently.
###
IF(NOT MSVC)
# Find out if HDF5 was built with parallel support.
# Do that by checking for the targets H5Pget_fapl_mpiposx and
# H5Pget_fapl_mpio in ${HDF5_LIB}.

CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO)
IF(HDF5_IS_PARALLEL_MPIPOSIX OR HDF5_IS_PARALLEL_MPIO)
Expand Down Expand Up @@ -991,22 +993,22 @@ IF(ENABLE_PNETCDF)
FIND_LIBRARY(PNETCDF NAMES pnetcdf)
FIND_PATH(PNETCDF_INCLUDE_DIR pnetcdf.h)
IF(NOT PNETCDF)
MESSAGE(STATUS "Cannot find PNetCDF library. Disabling PNetCDF support.")
MESSAGE(STATUS "Cannot find PnetCDF library. Disabling PnetCDF support.")
SET(USE_PNETCDF OFF CACHE BOOL "")
ELSE(NOT PNETCDF)
SET(USE_PARALLEL ON CACHE BOOL "")

# Check PNetCDF version. Must be >= 1.6.0
# Check PnetCDF version. Must be >= 1.6.0
set(pnetcdf_h "${PNETCDF_INCLUDE_DIR}/pnetcdf.h" )
message(STATUS "PNetCDF include file ${pnetcdf_h} will be searched for version")
message(STATUS "PnetCDF include file ${pnetcdf_h} will be searched for version")
file(STRINGS "${pnetcdf_h}" pnetcdf_major_string REGEX "^#define PNETCDF_VERSION_MAJOR")
string(REGEX REPLACE "[^0-9]" "" pnetcdf_major "${pnetcdf_major_string}")
file(STRINGS "${pnetcdf_h}" pnetcdf_minor_string REGEX "^#define PNETCDF_VERSION_MINOR")
string(REGEX REPLACE "[^0-9]" "" pnetcdf_minor "${pnetcdf_minor_string}")
file(STRINGS "${pnetcdf_h}" pnetcdf_sub_string REGEX "^#define PNETCDF_VERSION_SUB")
string(REGEX REPLACE "[^0-9]" "" pnetcdf_sub "${pnetcdf_sub_string}")
set(pnetcdf_version "${pnetcdf_major}.${pnetcdf_minor}.${pnetcdf_sub}")
message(STATUS "Found PNetCDF version ${pnetcdf_version}")
message(STATUS "Found PnetCDF version ${pnetcdf_version}")

if(${pnetcdf_version} VERSION_GREATER "1.6.0")
SET(STATUS_PNETCDF "ON")
Expand All @@ -1015,13 +1017,66 @@ IF(ENABLE_PNETCDF)
# pnetcdf => parallel
SET(STATUS_PARALLEL ON)
SET(USE_PARALLEL ON)
MESSAGE(STATUS "Using PNetCDF Library: ${PNETCDF}")
MESSAGE(STATUS "Using PnetCDF Library: ${PNETCDF}")
ELSE()
MESSAGE(WARNING "ENABLE_PNETCDF requires version 1.6.1 or later; found version ${pnetcdf_version}. PNetCDF is disabled")
MESSAGE(WARNING "ENABLE_PNETCDF requires version 1.6.1 or later; found version ${pnetcdf_version}. PnetCDF is disabled")
ENDIF()
ENDIF(NOT PNETCDF)
ENDIF()

# Options to enable use of fill values for elements casuing NC_ERANGE
SET(STATUS_ERANGE_FILL "OFF")
OPTION(ENABLE_ERANGE_FILL "Enable use of fill value when out-of-range type conversion causes NC_ERANGE error." OF)
IF(ENABLE_ERANGE_FILL)
SET(STATUS_ERANGE_FILL "ON")
ENDIF()

# Options to use a more relaxed coordinate argument boundary check
SET(STATUS_RELAX_COORD_BOUND "OFF")
OPTION(ENABLE_ZERO_LENGTH_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_ZERO_LENGTH_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}" 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)
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()

# 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)
Expand Down Expand Up @@ -1155,6 +1210,9 @@ CHECK_INCLUDE_FILE("stdbool.h" HAVE_STDBOOL_H)
CHECK_INCLUDE_FILE("locale.h" HAVE_LOCALE_H)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
CHECK_INCLUDE_FILE("stdio.h" HAVE_STDIO_H)
IF(MSVC)
CHECK_INCLUDE_FILE("io.h" HAVE_IO_H)
ENDIF(MSVC)
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
CHECK_INCLUDE_FILE("stdarg.h" HAVE_STDARG_H)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
Expand Down Expand Up @@ -1251,9 +1309,13 @@ ENDIF(SIZEOF_PTRDIFF_T)

# __int64 is used on Windows for large file support.
CHECK_TYPE_SIZE("__int64" SIZEOF___INT_64)
CHECK_TYPE_SIZE("uchar" SIZEOF_UCHAR)
CHECK_TYPE_SIZE("int64_t" SIZEOF_INT64_T)
CHECK_TYPE_SIZE("uint64_t" SIZEOF_UINT64_T)
CHECK_TYPE_SIZE("unsigned char" SIZEOF_UCHAR)
CHECK_TYPE_SIZE("unsigned short int" SIZEOF_UNSIGNED_SHORT_INT)
CHECK_TYPE_SIZE("unsigned int" SIZEOF_UNSIGNED_INT)
CHECK_TYPE_SIZE("long long" SIZEOF_LONGLONG)
CHECK_TYPE_SIZE("unsigned long long" SIZEOF_ULONGLONG)

# On windows systems, we redefine off_t as __int64
# to enable LFS. This is true on 32 and 64 bit system.s
Expand Down Expand Up @@ -1348,7 +1410,7 @@ IF(HAVE_M4)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
COMMAND ${NC_M4}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
ARGS ${M4FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
VERBATIM
)
ENDIF(HAVE_M4)
Expand Down Expand Up @@ -1826,6 +1888,7 @@ is_enabled(ENABLE_DAP4 HAS_DAP4)
is_enabled(USE_DISKLESS HAS_DISKLESS)
is_enabled(USE_MMAP HAS_MMAP)
is_enabled(JNA HAS_JNA)
is_enabled(STATUS_RELAX_COORD_BOUND RELAX_COORD_BOUND)

# Generate file from template.
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"
Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ settings_DATA=libnetcdf.settings
####

MM4= ./nc_test/test_put ./nc_test/test_get \
./nc_test/test_write ./nc_test/test_read \
./libsrc/netcdf ./libsrc/putget ./libsrc/ncx \
./libsrc/t_ncxx ./libsrc/attr

Expand Down
22 changes: 22 additions & 0 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -749,3 +749,25 @@ esac
])# AX_C_FLOAT_WORDS_BIGENDIAN

dnl Find the full path of a header file
dnl
dnl UD_CHECK_HEADER_PATH(file, [action-if-found], [action-if-not-found])
dnl Example:
dnl UD_CHECK_HEADER_PATH([math.h])
dnl AC_MSG_NOTICE([ac_cv_header_path_math_h=$ac_cv_header_path_math_h])
dnl
dnl
AC_DEFUN([UD_CHECK_HEADER_PATH],
[
AS_VAR_PUSHDEF([ac_Path], [ac_cv_header_path_$1])dnl
AC_CACHE_CHECK(
[for full path of header file $1], [ac_Path],
[AC_PREPROC_IFELSE(
[AC_LANG_PROGRAM([[#include <$1>]])],
[AS_VAR_SET([ac_Path], [`sed -n '/\.h"/s/.*"\(.*\)".*/\1/p' conftest.i | grep -m 1 $1`])],
[AC_MSG_RESULT([not found])]
)])
AS_VAR_SET_IF([ac_Path], [$2], [$3])
AS_VAR_POPDEF([ac_Path])dnl
])

28 changes: 24 additions & 4 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ are set when opening a binary file on Windows. */
#define fdopen _fdopen
#define write _write
#define strtoll _strtoi64
#endif
#endif /*_MSC_VER */

#cmakedefine const

/* Define if building universal (internal helper macro) */
#cmakedefine AC_APPLE_UNIVERSAL_BUILD 1
Expand Down Expand Up @@ -456,6 +458,27 @@ are set when opening a binary file on Windows. */
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION "${netCDF_VERSION}"

/* The size of `ulonglong` as computed by sizeof. */
#cmakedefine SIZEOF_ULONGLONG @SIZEOF_ULONGLONG@

/* The size of `longlong` as computed by sizeof. */
#cmakedefine SIZEOF_LONGLONG @SIZEOF_LONGLONG@

/* The size of `uchar` as computed by sizeof. */
#cmakedefine SIZEOF_UCHAR @SIZEOF_UCHAR@

/* The size of `ssize_t` as computed by sizeof. */
#cmakedefine SIZEOF_SSIZE_T @SIZEOF_SSIZE_T@

/* The size of `__int64` found on Windows systems. */
#cmakedefine SIZEOF___INT64 ${SIZEOF___INT64}

/* The size of `void*` as computed by sizeof. */
#cmakedefine SIZEOF_VOIDSTAR ${SIZEOF_VOIDSTAR}

/* The size of `short` as computed by sizeof. */
#cmakedefine SIZEOF_OFF64_T ${SIZEOF_OFF64_T}

/* The size of `double', as computed by sizeof. */
#cmakedefine SIZEOF_DOUBLE ${SIZEOF_DOUBLE}

Expand Down Expand Up @@ -607,9 +630,6 @@ are set when opening a binary file on Windows. */
#cmakedefine __CHAR_UNSIGNED__
#endif

/* Define to empty if `const' does not conform to ANSI C. */
#cmakedefine const

/* Define to `long int' if <sys/types.h> does not define. */
#cmakedefine off_t long int

Expand Down
85 changes: 85 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,13 @@ AC_CHECK_SIZEOF(unsigned long long)
$SLEEPCMD
AC_CHECK_SIZEOF(unsigned long long)

$SLEEPCMD
if test "$ac_cv_type_uchar" = yes ; then
AC_CHECK_SIZEOF(uchar)
else
AC_CHECK_SIZEOF(unsigned char)
fi

$SLEEPCMD
if test "$ac_cv_type_ushort" = yes ; then
AC_CHECK_SIZEOF(ushort)
Expand Down Expand Up @@ -1110,6 +1117,83 @@ if test "x$enable_parallel" = xyes; then
AC_DEFINE([USE_PARALLEL], [1], [if true, pnetcdf or parallel netcdf-4 is in use])
fi

AC_ARG_ENABLE([erange_fill],
[AS_HELP_STRING([--enable-erange-fill],
[Enable use of fill value when out-of-range type
conversion causes NC_ERANGE error. @<:@default: disabled@:>@])],
[enable_erange_fill=${enableval}], [enable_erange_fill=no]
)

AC_ARG_ENABLE([zero-length-coord-bound],
[AS_HELP_STRING([--enable-zero-length-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. @<:@default: disabled@:>@])],
[enable_zero_length_coord_bound=${enableval}], [enable_zero_length_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 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
elax_coord_bound_pnetcdf=no
else
coord_bound_pnetcdf=`echo ${relax_coord_bound_pnetcdf} | cut -d' ' -f3`
if test "x$coord_bound_pnetcdf" = x0; then
relax_coord_bound_pnetcdf=no
else
relax_coord_bound_pnetcdf=yes
fi
fi
AC_MSG_NOTICE([$relax_coord_bound_pnetcdf])
if test "$enable_zero_length_coord_bound" != "$relax_coord_bound_pnetcdf"; then
if test "$relax_coord_bound_pnetcdf" = yes; then
AC_MSG_WARN([Enable relax-coord-bound to conform with PnetCDF setting])
else
AC_MSG_WARN([Disable relax-coord-bound to conform with PnetCDF setting])
fi
enable_zero_length_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_zero_length_coord_bound" = xyes; then
AC_DEFINE([RELAX_COORD_BOUND], [1], [if true, NC_EINVALCOORDS check is more relaxed])
fi

# Check for downloading/building fortran via postinstall script.
if test "x$enable_remote_fortran_bootstrap" = xyes; then
AC_DEFINE([BUILD_FORTRAN], 1, [If true, will attempt to download and build netcdf-fortran.])
Expand Down Expand Up @@ -1282,6 +1366,7 @@ AC_SUBST(HAS_PARALLEL4,[$enable_parallel4])
AC_SUBST(HAS_DISKLESS,[$enable_diskless])
AC_SUBST(HAS_MMAP,[$enable_mmap])
AC_SUBST(HAS_JNA,[$enable_jna])
AC_SUBST(RELAX_COORD_BOUND,[$enable_relax_coord_bound])

# Include some specifics for netcdf on windows.
#AH_VERBATIM([_WIN32_STRICMP],
Expand Down
18 changes: 18 additions & 0 deletions gdb-branch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set breakpoint pending yes
break test_nc_redef
commands
break util.c:888 if i == 6
end

#break util.c:903 if i == 6
#break util.c:1020
#break util.c:1014 if i == 6 && j == 0
#break util.c:1016 if i == 6 && j == 0
#commands
#break putget.c:10948
#end

#break test_write.c:216
#commands
#break ncx_put_int_double
#end
Loading

0 comments on commit 23c14bd

Please sign in to comment.