diff --git a/configure b/configure
index b8704bc95b1f168981de20d96d30c88cf70d4a2d..b5295f79837d70ac145d5a4c285da261f8a61df4 100755
--- a/configure
+++ b/configure
@@ -27742,62 +27742,7 @@ else
 $as_echo "no" >&6; }
 fi
 
-
-                            if test "x$NC_CONFIG" != "x"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's OpenDAP support" >&5
-$as_echo_n "checking netcdf's OpenDAP support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-dap)" = "xyes"; then :
-
-$as_echo "#define HAVE_LIBNC_DAP 1" >>confdefs.h
-
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-                                  { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc2 support" >&5
-$as_echo_n "checking netcdf's nc2 support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-nc2)" = "xyes"; then :
-
-$as_echo "#define HAVE_NETCDF2 1" >>confdefs.h
-
-                                          ENABLE_NC2=yes
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-                                   { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc4 support" >&5
-$as_echo_n "checking netcdf's nc4 support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-nc4)" = "xyes"; then :
-
-$as_echo "#define HAVE_NETCDF4 1" >>confdefs.h
-
-                                          ENABLE_NC4=yes
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-			           { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc4/hdf5 support" >&5
-$as_echo_n "checking netcdf's nc4/hdf5 support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-hdf5)" = "xyes"; then :
-
-$as_echo "#define HAVE_NC4HDF5 1" >>confdefs.h
-
-                                          ENABLE_NC4HDF5=yes
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-else
-  $as_echo Could not find nc-config! go on with default configuration
-fi ;; #(
+ ;; #(
   *) :
     if test -d "$with_netcdf"; then :
   NETCDF_ROOT=$with_netcdf
@@ -27917,77 +27862,69 @@ $as_echo "no" >&6; }
 fi
 
 
-                                 if test "x$NC_CONFIG" != "x"; then :
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: $with_netcdf is not a directory! NetCDF suppressed" >&5
+$as_echo "$as_me: $with_netcdf is not a directory! NetCDF suppressed" >&6;}
+fi ;; #(
+  *) :
+     ;;
+esac
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NetCDF library" >&5
+$as_echo_n "checking for NetCDF library... " >&6; }
+             { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
+$as_echo "suppressed" >&6; }
+fi
+
+
+if test x"$ENABLE_NETCDF" = xyes -a "x$NC_CONFIG" != "x"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's OpenDAP support" >&5
 $as_echo_n "checking netcdf's OpenDAP support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-dap)" = "xyes"; then :
+   acx_temp=`$NC_CONFIG --has-dap`
+   if test "x$acx_temp" = "xyes"; then :
 
 $as_echo "#define HAVE_LIBNC_DAP 1" >>confdefs.h
 
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
 fi
-                                   { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc2 support" >&5
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_temp" >&5
+$as_echo "$acx_temp" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc2 support" >&5
 $as_echo_n "checking netcdf's nc2 support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-nc2)" = "xyes"; then :
+   acx_temp=`$NC_CONFIG --has-nc2`
+   if test "x$acx_temp" = "xyes"; then :
 
 $as_echo "#define HAVE_NETCDF2 1" >>confdefs.h
 
-                                          ENABLE_NC2=yes
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+      ENABLE_NC2=yes
 fi
-                                   { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc4 support" >&5
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_temp" >&5
+$as_echo "$acx_temp" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc4 support" >&5
 $as_echo_n "checking netcdf's nc4 support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-nc4)" = "xyes"; then :
+   acx_temp=`$NC_CONFIG --has-nc4`
+   if test "x$acx_temp" = "xyes"; then :
 
 $as_echo "#define HAVE_NETCDF4 1" >>confdefs.h
 
-                                          ENABLE_NC4=yes
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+      ENABLE_NC4=yes
 fi
-			           { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc4/hdf5 support" >&5
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_temp" >&5
+$as_echo "$acx_temp" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf's nc4/hdf5 support" >&5
 $as_echo_n "checking netcdf's nc4/hdf5 support... " >&6; }
-                                   if test "x$($NC_CONFIG --has-hdf5)" = "xyes"; then :
+   acx_temp=`$NC_CONFIG --has-hdf5`
+   if test "x$acx_temp" = "xyes"; then :
 
 $as_echo "#define HAVE_NC4HDF5 1" >>confdefs.h
 
-                                          ENABLE_NC4HDF5=yes
-                                          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+      ENABLE_NC4HDF5=yes
 fi
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: Could not find nc-config! go on with default configuration" >&5
-$as_echo "Could not find nc-config! go on with default configuration" >&6; }
-fi
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: $with_netcdf is not a directory! NetCDF suppressed" >&5
-$as_echo "$as_me: $with_netcdf is not a directory! NetCDF suppressed" >&6;}
-fi ;; #(
-  *) :
-     ;;
-esac
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NetCDF library" >&5
-$as_echo_n "checking for NetCDF library... " >&6; }
-             { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
-$as_echo "suppressed" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_temp" >&5
+$as_echo "$acx_temp" >&6; }
+elif test x"$ENABLE_NETCDF" = xyes -a "x$NC_CONFIG" = "x"; then :
+  $as_echo Could not find nc-config! go on with default configuration
 fi
 
-
 if test "x$ENABLE_NC4HDF5" = "xyes"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing H5TS_mutex_lock" >&5
 $as_echo_n "checking for library containing H5TS_mutex_lock... " >&6; }
diff --git a/m4/acx_options.m4 b/m4/acx_options.m4
index 997cb0dfe47d4ca3be01d3d634924ae8d4817ff9..12e2905ca865fee31b0232a6a908a3085a41b2be 100644
--- a/m4/acx_options.m4
+++ b/m4/acx_options.m4
@@ -78,28 +78,7 @@ AC_ARG_WITH([netcdf],
                                             ENABLE_NETCDF=yes],
                                            [AC_MSG_ERROR([Could not link to NetCDF library])])
                             NETCDF_LIBS=" -lnetcdf"
-                            AC_CHECK_PROG(NC_CONFIG,nc-config,nc-config)
-                            AS_IF([test "x$NC_CONFIG" != "x"],
-                                  [AC_MSG_CHECKING([netcdf's OpenDAP support])
-                                   AS_IF([test "x$($NC_CONFIG --has-dap)" = "xyes"],
-                                         [AC_DEFINE([HAVE_LIBNC_DAP],[1],[Define to 1 for NetCDF OpenDAP])
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])]
-                                  [AC_MSG_CHECKING([netcdf's nc2 support])
-                                   AS_IF([test "x$($NC_CONFIG --has-nc2)" = "xyes"],
-                                         [AC_DEFINE([HAVE_NETCDF2],[1],[Define to 1 for NetCDF2 support])
-                                          ENABLE_NC2=yes
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
-                                   AC_MSG_CHECKING([netcdf's nc4 support])
-                                   AS_IF([test "x$($NC_CONFIG --has-nc4)" = "xyes"],
-                                         [AC_DEFINE([HAVE_NETCDF4],[1],[Define to 1 for NetCDF4 support])
-                                          ENABLE_NC4=yes
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
-			           AC_MSG_CHECKING([netcdf's nc4/hdf5 support])
-                                   AS_IF([test "x$($NC_CONFIG --has-hdf5)" = "xyes"],
-                                         [AC_DEFINE([HAVE_NC4HDF5],[1],[Define to 1 for NetCDF4/HDF5 support])
-                                          ENABLE_NC4HDF5=yes
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])]) ],
-                                  [AS_ECHO([Could not find nc-config! go on with default configuration])])],
+                            AC_CHECK_PROG(NC_CONFIG,nc-config,nc-config)],
                      [*],[AS_IF([test -d "$with_netcdf"],
                                 [NETCDF_ROOT=$with_netcdf
                                  LDFLAGS="-L$NETCDF_ROOT/lib $LDFLAGS"
@@ -113,32 +92,38 @@ AC_ARG_WITH([netcdf],
                                  NETCDF_LIBS=" -L$NETCDF_ROOT/lib -lnetcdf"
                                  NETCDF_INCLUDE=" -I$NETCDF_ROOT/include"
                                  AC_MSG_CHECKING([nc-config script])
-                                 AC_CHECK_PROG(NC_CONFIG,nc-config,[$NETCDF_ROOT/bin/nc-config],,["$NETCDF_ROOT/bin"])
-                                 AS_IF([test "x$NC_CONFIG" != "x"],
-                                   [AC_MSG_CHECKING([netcdf's OpenDAP support])
-                                   AS_IF([test "x$($NC_CONFIG --has-dap)" = "xyes"],
-                                         [AC_DEFINE([HAVE_LIBNC_DAP],[1],[Define to 1 for NetCDF OpenDAP])
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])]
-                                   [AC_MSG_CHECKING([netcdf's nc2 support])
-                                   AS_IF([test "x$($NC_CONFIG --has-nc2)" = "xyes"],
-                                         [AC_DEFINE([HAVE_NETCDF2],[1],[Define to 1 for NetCDF2 support])
-                                          ENABLE_NC2=yes
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
-                                   AC_MSG_CHECKING([netcdf's nc4 support])
-                                   AS_IF([test "x$($NC_CONFIG --has-nc4)" = "xyes"],
-                                         [AC_DEFINE([HAVE_NETCDF4],[1],[Define to 1 for NetCDF4 support])
-                                          ENABLE_NC4=yes
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
-			           AC_MSG_CHECKING([netcdf's nc4/hdf5 support])
-                                   AS_IF([test "x$($NC_CONFIG --has-hdf5)" = "xyes"],
-                                         [AC_DEFINE([HAVE_NC4HDF5],[1],[Define to 1 for NetCDF4/HDF5 support])
-                                          ENABLE_NC4HDF5=yes
-                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])]) ],
-                                   [AC_MSG_RESULT([Could not find nc-config! go on with default configuration])])],
+                                 AC_CHECK_PROG(NC_CONFIG,nc-config,[$NETCDF_ROOT/bin/nc-config],,["$NETCDF_ROOT/bin"])],
                                 [AC_MSG_NOTICE([$with_netcdf is not a directory! NetCDF suppressed])])])],
             [AC_MSG_CHECKING([for NetCDF library])
              AC_MSG_RESULT([suppressed])])
 
+AS_IF([test x"$ENABLE_NETCDF" = xyes -a "x$NC_CONFIG" != "x"],
+  [AC_MSG_CHECKING([netcdf's OpenDAP support])
+   acx_temp=`$NC_CONFIG --has-dap`
+   AS_IF([test "x$acx_temp" = "xyes"],
+     [AC_DEFINE([HAVE_LIBNC_DAP],[1],[Define to 1 for NetCDF OpenDAP])])
+   AC_MSG_RESULT([$acx_temp])
+   AC_MSG_CHECKING([netcdf's nc2 support])
+   acx_temp=`$NC_CONFIG --has-nc2`
+   AS_IF([test "x$acx_temp" = "xyes"],
+     [AC_DEFINE([HAVE_NETCDF2],[1],[Define to 1 for NetCDF2 support])
+      ENABLE_NC2=yes])
+   AC_MSG_RESULT([$acx_temp])
+   AC_MSG_CHECKING([netcdf's nc4 support])
+   acx_temp=`$NC_CONFIG --has-nc4`
+   AS_IF([test "x$acx_temp" = "xyes"],
+     [AC_DEFINE([HAVE_NETCDF4],[1],[Define to 1 for NetCDF4 support])
+      ENABLE_NC4=yes])
+   AC_MSG_RESULT([$acx_temp])
+   AC_MSG_CHECKING([netcdf's nc4/hdf5 support])
+   acx_temp=`$NC_CONFIG --has-hdf5`
+   AS_IF([test "x$acx_temp" = "xyes"],
+     [AC_DEFINE([HAVE_NC4HDF5],[1],[Define to 1 for NetCDF4/HDF5 support])
+      ENABLE_NC4HDF5=yes])
+   AC_MSG_RESULT([$acx_temp])],
+  [test x"$ENABLE_NETCDF" = xyes -a "x$NC_CONFIG" = "x"],
+  [AS_ECHO([Could not find nc-config! go on with default configuration])])
+
 AS_IF([test "x$ENABLE_NC4HDF5" = "xyes"],
       [AC_SEARCH_LIBS([H5TS_mutex_lock], [netcdf],
                [AC_DEFINE([HAVE_NC4HDF5_THREADSAFE],[1],[Define to 1 for NetCDF4/HDF5 threadsafe support])],,[-lhdf5])])