diff --git a/CMakeLists.txt b/CMakeLists.txt index ec425ffb7d5..f8468ae352d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,16 @@ if (HAVE_472) message (FATAL_ERROR "PIO cannot build with netcdf-c-4.7.2, please upgrade your netCDF library") endif () +### +# Check to see if dispatch table version 2 is supported for netcdf integration. +### +CHECK_C_SOURCE_COMPILES(" +#include +#if NC_DISPATCH_VERSION != 2 + choke me +#endif +int main() {return 0;}" HAVE_DISPATCH2) + ##### # Configure and print the libpio.settings file. ##### diff --git a/configure.ac b/configure.ac index cdac2b29c18..cc4365fe05d 100644 --- a/configure.ac +++ b/configure.ac @@ -311,6 +311,19 @@ if test "x$have_472" = xyes; then AC_MSG_ERROR([PIO cannot build with netcdf-c-4.7.2, please upgrade your netCDF version.]) fi +# Do we have the correct dispatch table version in netcdf-c for netcdf +# integration? +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "netcdf_meta.h"], +[[#if NC_DISPATCH_VERSION != 2 +# error +#endif] +])], [have_dispatch2=yes], [have_dispatch2=no]) +AC_MSG_CHECKING([whether netcdf-c supports version 2 of dispatch table for netcdf integration]) +AC_MSG_RESULT([${have_dispatch2}]) +if test "x$enable_netcdf_integration" = xyes -a "x$have_dispatch2" = xno; then + AC_MSG_ERROR([NetCDF integration cannot be used with this version of netcdf-c, please upgrade your netCDF version.]) +fi + # Set some build settings for when netcdf-4 is supported. if test x$have_netcdf_par = xyes; then AC_DEFINE([_NETCDF4],[1],[Does netCDF library provide netCDF-4 with parallel access])