diff --git a/Makefile.am b/Makefile.am
index c3ff722357e9972ef25b6662c4d9abb638582c12..42820a0f50334e959363483b48ede8d57d611fe6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = src interfaces app examples tests
+SUBDIRS = src app examples tests
 
 # The pdf files below cannot be created in parallel:
 doc/cdi_cman.pdf: doc/cdi_fman.pdf
diff --git a/configure.ac b/configure.ac
index 0ba5cba05e6301eabd4c2a1a09588abde9d8144d..b22ec792e5fe7bd987b9bebde7f07d814c958d73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,12 +8,8 @@ AC_PREREQ([2.69])
 LT_PREREQ([2.4.6])
 
 AC_INIT([cdi],[2.1.1],[https://mpimet.mpg.de/cdi])
-
 AC_DEFINE_UNQUOTED(CDI, ["$PACKAGE_VERSION"], [CDI version])
 
-echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
-
-CONFIG_ABORT=yes
 AC_CONFIG_AUX_DIR([config])
 AC_CONFIG_MACRO_DIR([m4])
 dnl forbid acx macro names from remaining unexpanded
@@ -22,172 +18,286 @@ AC_CANONICAL_HOST
 AC_CANONICAL_BUILD
 
 AM_INIT_AUTOMAKE([1.16.1 foreign serial-tests])
-AC_CONFIG_HEADERS([src/config.h])
 AM_MAINTAINER_MODE([disable])
 
-# Check building environment
 AC_PROG_CC_C99
-dnl The check above forgets to delete the following directory
-dnl generated by the MacOS linker, which results in multiple
-dnl annoying messages from the rm utility:
-rm -rf conftest.dSYM
-dnl verify the setup supports POSIX 2001
+AS_VAR_IF([ac_cv_prog_cc_c99], [no],
+  [AC_MSG_FAILURE([C compiler does not support ISO C99])])
 ACX_PROG_CC_POSIX([2001])
 AC_C_RESTRICT
-AC_PROG_FC
-AS_IF([test -n "$FC" && test "X$FC" != Xno],
-  [AC_FC_SRCEXT([f90])
-   AC_LANG_PUSH([Fortran])
-   dnl check that FC is working just as well as CC
-   _AC_COMPILER_EXEEXT
-   AC_PROG_FPP
-   AC_LANG_POP([Fortran])])
-AC_PROG_F77
-AS_IF([test -n "$F77" && test "X$F77" != Xno],
-  [AC_LANG_PUSH([Fortran 77])
-   dnl check that F77 is working just as well as CC
-   _AC_COMPILER_EXEEXT
-   AC_LANG_POP([Fortran 77])])
-AC_PROG_CXX
+
+AC_ARG_ENABLE([iso-c-interface],
+  [AS_HELP_STRING([--enable-iso-c-interface],
+     [create Fortran 90 interface using Fortran 2003 ISO_C_BINDING facility ]dnl
+[@<:@default=no@:>@])],
+  [test "x$enableval" != xno && enable_iso_c_interface=yes],
+  [enable_iso_c_interface=no])
+AM_CONDITIONAL([ENABLE_ISOC_INTERFACE],
+  [test "x$enable_iso_c_interface" = xyes])
+
+AC_ARG_ENABLE([cf-interface],
+  [AS_HELP_STRING([--enable-cf-interface],
+     [create Fortran 77 interface using cfortran.h @<:@default=yes@:>@])],
+  [test "x$enableval" != xno && enable_cf_interface=yes],
+  [enable_cf_interface=yes])
+AM_CONDITIONAL([ENABLE_CF_INTERFACE], [test "x$enable_cf_interface" = xyes])
+
+dnl We need FC for the Fortran 90 and for the Fortran 77 interfaces. In the
+dnl latter case, the compiler is used for testing. Note that we use neither
+dnl AS_IF nor AS_VAR_IF here to prevent checking for FC when we do not need it:
+if test "x$enable_iso_c_interface" = xyes || \
+   test "x$enable_cf_interface" = xyes; then
+  if test "x$FC" != xno; then
+    AC_PROG_FC
+    test -z $FC 2>/dev/null && FC=no
+    AS_IF([test "x$FC" != xno], [AC_FC_SRCEXT([f90], [], [FC=no])])
+    AS_IF([test "x$FC" != xno],
+      [AC_MSG_CHECKING([whether the Fortran compiler works])
+       works_FC=no
+       AC_LANG_PUSH([Fortran])
+       AC_LINK_IFELSE([AC_LANG_PROGRAM],
+         [AS_IF([test "x$cross_compiling" != xyes],
+            [AC_TRY_COMMAND([./conftest$ac_exeext])
+             AS_IF([test $ac_status -eq 0], [works_FC=yes])],
+            [works_FC=yes])])
+       AC_LANG_POP([Fortran])
+       AC_MSG_RESULT([$works_FC])
+       AS_VAR_IF([works_FC], [no], [FC=no])
+       AS_UNSET([works_FC])])
+  fi
+else
+  FC=no
+fi
+dnl Additional checks required for the Fortran 90 interface:
+AS_VAR_IF([enable_iso_c_interface], [yes],
+  [AS_IF([test "x$FC" != xno], [ACX_FC_CHECK_STRPTR_CONVERT([], [FC=no])])
+   AS_VAR_IF([FC], [no],
+     [AC_MSG_FAILURE([the Fortran 90 interface is requested but the Fortran ]dnl
+[compiler is disabled, missing or lacks the required features])])
+dnl Additional tests with fallback values:
+   AS_IF([test "x$FC" != xno],
+     [AC_LANG_PUSH([Fortran])
+      ACX_SL_FC_CHECK_MOD_PATH_FLAG([], [FC_MOD_FLAG=-I])
+      ACX_SL_FC_MOD_SUFFIX([], [FCMODEXT=mod])
+      AC_LANG_POP([Fortran])])])
+AM_CONDITIONAL([FC_MOD_UPPERCASE], [test "x$FCMODCASE" = xuc])
+
+dnl We need Fortran 77 if either FC is not available or the user has specified
+dnl F77 explicitly to make sure that the generated Fortran 77 interface is
+dnl compatible with it:
+if test "x$enable_cf_interface" = xyes; then
+  AS_IF([test -n "$F77" && test "x$F77" != xno],
+    [requested_F77=yes], [requested_F77=no])
+  if test "x$FC" = xno || test "x$requested_F77" = xyes; then
+    AC_PROG_F77
+    test -z $F77 2>/dev/null && F77=no
+    AS_IF([test "x$F77" != xno],
+      [AC_MSG_CHECKING([whether the Fortran 77 compiler works])
+       works_F77=no
+       AC_LANG_PUSH([Fortran 77])
+       AC_LINK_IFELSE([AC_LANG_PROGRAM],
+         [AS_IF([test "x$cross_compiling" != xyes],
+            [AC_TRY_COMMAND([./conftest$ac_exeext])
+             AS_IF([test $ac_status -eq 0], [works_F77=yes])],
+            [works_F77=yes])])
+       AC_LANG_POP([Fortran 77])
+       AC_MSG_RESULT([$works_F77])
+       AS_VAR_IF([works_F77], [no], [F77=no])
+       AS_UNSET([works_F77])])
+  else
+    F77=no
+  fi
+  AS_IF([test "x$F77" = xno && test "x$requested_F77" = xyes],
+    [AC_MSG_FAILURE([the explicitly requested Fortran 77 compiler is ]dnl
+[missing or lacks the required features])])
+  AS_UNSET([requested_F77])
+else
+  F77=no
+fi
+dnl Additional checks required for the Fortran 77 interface:
+AS_VAR_IF([enable_cf_interface], [yes],
+  [dnl
+dnl The following macro make sure the the user's request for the Fortran 77
+dnl interface compatibility is fulfilled:
+   ACX_FIND_CFORTRAN_DEF
+   ACX_XLF_QEXTNAME_ADD_APPENDUS
+   ACX_CHECK_CFORTRAN([$srcdir/src],
+     [AC_DEFINE([HAVE_CF_INTERFACE], [1],
+        [Defined to 1 if C / Fortran interface cfortran.h works])])
+   AS_IF([test "x$FC" = xno && test "x$F77" = xno],
+     [AC_MSG_FAILURE([the Fortran 77 interface is requested but both ]dnl
+[Fortran and Fortran 77 compilers are disabled, missing or lack the ]dnl
+[required features])])
+   AS_IF([test "x$FC" != xno],
+     [dnl
+dnl Additional tests with fallback values:
+dnl TODO: the following should be put to a separate .m4 file (note that we
+dnl test the Fortran include statement, which we actually use in the code, and
+dnl not the Fortran preprocessor include directive, which is tested in
+dnl ACX_SL_PROG_FC_FPP_FEATURES):
+      AC_CACHE_CHECK([for Fortran compiler flag needed to specify search dnl
+paths for the \"INCLUDE\" statement], [acx_cv_fc_ftn_include_flag],
+        [AC_LANG_PUSH([Fortran])
+         acx_cv_fc_ftn_include_flag=unknown
+         AS_MKDIR_P([conftest.dir])
+         AC_LANG_CONFTEST([AC_LANG_PROGRAM])
+         mv conftest.$ac_ext conftest.dir/conftest.inc
+         AC_LANG_CONFTEST([AC_LANG_SOURCE(
+           [[      include "conftest.inc"]])])
+         saved_FCFLAGS=$FCFLAGS
+         for acx_flag in -I '-I '; do
+           FCFLAGS="$saved_FCFLAGS ${acx_flag}conftest.dir"
+           AC_LINK_IFELSE([], [acx_cv_fc_ftn_include_flag=$acx_flag])
+           test "x$acx_cv_fc_ftn_include_flag" != xunknown && break
+         done
+         FCFLAGS=$saved_FCFLAGS
+         rm -rf conftest.$ac_ext conftest.dir
+         AC_LANG_POP([Fortran])])
+      AS_VAR_IF([acx_cv_fc_ftn_include_flag], [unknown],
+        [acx_cv_fc_ftn_include_flag=-I])
+      AC_SUBST([FC_OPTINC], [$acx_cv_fc_ftn_include_flag])
+dnl Find the Fortran compiler flag needed to specify a preprocessor macro
+dnl definition for *.F90 source files:
+      m4_pushdef([AC_FC_PP_SRCEXT])dnl
+      saved_ac_fc_srcext=$ac_fc_srcext
+      ac_fc_srcext='F90'
+      AC_FC_PP_DEFINE([], [FC_DEFINE=-D])
+      ac_fc_srcext=$saved_ac_fc_srcext
+      m4_popdef([AC_FC_PP_DEFINE])])])
+
 AC_PROG_INSTALL
 AC_OPENMP
-# Set up libtool.
+
+dnl Set up libtool:
 AC_MSG_NOTICE([setting up libtool])
 ACX_USE_LIBTOOL_CONFIGURATION([pic-only])
 
-# -----------------------------------------------------------------------
-# Check endianess of system
+dnl Check endianess of system:
 AC_C_BIGENDIAN
-#  ----------------------------------------------------------------------
-# Check large file support on 32 bit systems
+dnl Check large file support on 32 bit systems:
 AC_SYS_LARGEFILE
-#  ----------------------------------------------------------------------
-# Checks for library functions.
+dnl Checks for library functions:
 AC_FUNC_MMAP
-#  ----------------------------------------------------------------------
-# Checks for structures.
+dnl Check for structures:
 AC_CHECK_MEMBERS([struct stat.st_blksize])
-#  ----------------------------------------------------------------------
-# Checks for header files
+dnl Checks for header files:
 AC_CHECK_HEADERS([malloc.h unistd.h sys/time.h],,,[AC_INCLUDES_DEFAULT])
 AX_EXECINFO
-#  ----------------------------------------------------------------------
-# Checks for the availability of functions
+dnl Checks for the availability of functions:
 AC_CHECK_FUNCS([mallinfo pwrite])
 AC_REPLACE_FUNCS([getline])
+dnl Check for UUID library:
 ACX_UUID
-LIBS="${LIBS+$LIBS }$UUID_C_LIB"
-CPPFLAGS="${CPPFLAGS+$CPPFLAGS }$UUID_C_INCLUDE"
-#  ----------------------------------------------------------------------
-# Checks for the availability of ANSI-C99 functions
-AC_CHECK_DECLS([isnan],,,[AC_INCLUDES_DEFAULT
+AS_VAR_APPEND([CFLAGS], [" $UUID_C_INCLUDE"])
+LIBS="$UUID_C_LIB $LIBS"
+dnl Checks for the availability of ANSI-C99 functions:
+AC_CHECK_DECLS([isnan], [], [],
+  [AC_INCLUDES_DEFAULT
 @%:@include <math.h>])
-
-# check for sysconf names
-AC_CHECK_DECLS([_SC_LARGE_PAGESIZE, PAGESIZE, PAGE_SIZE, _SC_PAGE_SIZE, dnl
-_SC_PAGESIZE, _PC_REC_XFER_ALIGN, POSIX_REC_XFER_ALIGN],,,[AC_INCLUDES_DEFAULT
+dnl Check for sysconf names:
+AC_CHECK_DECLS(
+  [_SC_LARGE_PAGESIZE, PAGESIZE, PAGE_SIZE, _SC_PAGE_SIZE, _SC_PAGESIZE, dnl
+_PC_REC_XFER_ALIGN, POSIX_REC_XFER_ALIGN], [], [],
+  [AC_INCLUDES_DEFAULT
 @%:@include <limits.h>
 @%:@include <unistd.h>])
-#
-# Check for non-standard builtin
-AS_FOR([builtin_macro],[builtin],[__builtin_ctz],
-  [AS_VAR_PUSHDEF([builtin_cache],[acx_cv_have_decl_]builtin_macro)
+dnl Check for math library:
+AC_SEARCH_LIBS(floor, m)
+
+dnl Check for non-standard builtin:
+AS_FOR([builtin_macro], [builtin], [__builtin_ctz],
+  [AS_VAR_PUSHDEF([builtin_cache], [acx_cv_have_decl_]builtin_macro)
    AC_CACHE_CHECK([whether ]builtin_macro[ is declared],
      [builtin_cache],
-     [AC_LINK_IFELSE([AC_LANG_PROGRAM(,[  unsigned lbz = builtin_macro][[(56U)]])],
-        [AS_VAR_SET([builtin_cache],[yes])],
-        [AS_VAR_SET([builtin_cache],[no])])])
-   AS_VAR_IF([builtin_cache],[yes],
-     [AC_DEFINE_UNQUOTED([HAVE_DECL_]AS_TR_CPP([builtin_macro]),[1])
+     [AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM([], [  unsigned lbz = builtin_macro][[(56U)]])],
+        [AS_VAR_SET([builtin_cache], [yes])],
+        [AS_VAR_SET([builtin_cache], [no])])])
+   AS_VAR_IF([builtin_cache], [yes],
+     [AC_DEFINE_UNQUOTED([HAVE_DECL_]AS_TR_CPP([builtin_macro]), [1])
       break],
-     [AC_DEFINE_UNQUOTED([HAVE_DECL_]AS_TR_CPP([builtin_macro]),[0])])])
+     [AC_DEFINE_UNQUOTED([HAVE_DECL_]AS_TR_CPP([builtin_macro]), [0])])])
 AH_TEMPLATE([HAVE_DECL___BUILTIN_CTZ],
   [Define to 1 if __builtin_ctz is available, 0 if not])
 
-# Check compiler version
-case "$CC" in
-  pgcc*)  COMP_VERSION=`$CC -V | head -2 | tail -n 1`;;
-  *gcc*)  COMP_VERSION=`$CC --version | head -n 1`;;
-  g++*)   COMP_VERSION=`$CC --version | head -n 1`;;
-  clang*) COMP_VERSION=`$CC --version | head -n 1`;;
-  sxc*)   COMP_VERSION=`$CC -V 2>&1   | tail -n 1`;;
-  xlc*)   COMP_VERSION=`$CC -qversion 2>&1   | head -n 1`;;
-  *)
-     # 'head -n 1' exits after printing the first line, which closes the pipe
-     # and kills the compiler's process leaving it no chance to clean any
-     # temporary files it might have created (e.g. Intel compiler creates
-     # 'a.out' when it is called with additional flags like -I, -L, etc.,
-     # which is the case when $CC is an MPI wrapper). Therefore, we have to
-     # run the processes one after another:
-     COMP_VERSION=`$CC -V 2>&1`
-     COMP_VERSION=`echo "$COMP_VERSION" | head -n 1` ;;
-esac
-
-if test -z "$COMP_VERSION" ; then COMP_VERSION="unknown"; fi;
-AC_DEFINE_UNQUOTED(COMP_VERSION, ["$COMP_VERSION"], [Compiler version])
-
-# Check for system type
-AC_DEFINE_UNQUOTED([SYSTEM_TYPE],["$ac_cv_build"], [System type])
-AC_SUBST([SYSTEM_TYPE],["$ac_cv_build"])
-# -----------------------------------------------------------------------
-# Check for math library and add -lm to LIBS
-AC_SEARCH_LIBS(floor, m)
-#  ----------------------------------------------------------------------
-# Add basic configure options
+dnl TODO: add comments on why we do not have all options in one place:
+dnl Add basic configure options:
 ACX_CDI_OPTIONS
-AM_CONDITIONAL([ENABLE_NETCDF],[test x$ENABLE_NETCDF = xyes])
+AM_CONDITIONAL([ENABLE_NETCDF], [test "x$ENABLE_NETCDF" = xyes])
 AC_CHECK_FUNCS([grib_get_length])
-AS_IF([test x"$with_grib_api" != x -a "x$with_grib_api" != xno \
-            -o x"$with_eccodes" != x -a x"$with_eccodes" != xno],
-  [ENABLE_LIBGRIB_API=yes],[ENABLE_LIBGRIB_API=no])
-AC_SUBST([ENABLE_LIBGRIB_API])
-AM_SUBST_NOTMAKE([ENABLE_LIBGRIB_API])
-#  ----------------------------------------------------------------------
-# Compile with MPI support
+
+dnl TODO: check whether we really need all the following information. Is it just
+dnl for 'app/cdi -d'? If so, we can skip this when we are not going to install
+dnl the executable:
+AC_DEFINE_UNQUOTED(COMPILER, ["$CC $CFLAGS"], [Compiler])
+dnl TODO: replace the following with a macro that can do the detection better:
+dnl Check compiler version:
+COMP_VERSION=
+AS_CASE([$CC],
+  [pgcc*], [COMP_VERSION=`$CC -V | head -2 | tail -n 1`],
+  [*gcc*], [COMP_VERSION=`$CC --version | head -n 1`],
+  [g++*], [COMP_VERSION=`$CC --version | head -n 1`],
+  [clang*], [COMP_VERSION=`$CC --version | head -n 1`],
+  [sxc*], [COMP_VERSION=`$CC -V 2>&1   | tail -n 1`],
+  [xlc*], [COMP_VERSION=`$CC -qversion 2>&1   | head -n 1`],
+  [dnl
+dnl 'head -n 1' exits after printing the first line, which closes the pipe and
+dnl kills the compiler's process leaving it no chance to clean any temporary
+dnl files it might have created (e.g. Intel compiler creates 'a.out' when it is
+dnl called with additional flags like -I, -L, etc., which is the case when $CC
+dnl is an MPI wrapper). Therefore, we have to run the processes one after
+dnl another:
+   COMP_VERSION=`$CC -V 2>&1`
+   COMP_VERSION=`echo "$COMP_VERSION" | head -n 1`])
+test -z "$COMP_VERSION" && COMP_VERSION=unknown
+AC_DEFINE_UNQUOTED([COMP_VERSION], ["$COMP_VERSION"], [Compiler version])
+dnl
+dnl Checks for system type:
+AC_DEFINE_UNQUOTED([SYSTEM_TYPE], ["$ac_cv_build"], [System type])
+AC_SUBST([SYSTEM_TYPE], ["$ac_cv_build"])
+
+dnl Compile with MPI support:
 AC_ARG_ENABLE([mpi],
-  AS_HELP_STRING([--enable-mpi],
-    [Compile with MPI compiler @<:@default=no@:>@]),,
-    [enable_mpi=no])
+  [AS_HELP_STRING([--enable-mpi],
+     [enable parallel I/O with MPI @<:@default=no@:>@])],
+  [test "x$enableval" != xno && enable_mpi=yes],
+  [enable_mpi=no])
+
+build_pio_fc_programs=no
+have_ppm=no
+have_parallel_nc4=no
 AS_VAR_IF([enable_mpi], [yes],
-  [ACX_C_PACKAGE([MPI],[mpi.h],,,
-     [AC_MSG_FAILURE([Required header mpi.h not found or not compilable.])
-      enable_MPI=no],
-     [MPI_Waitall],[mpi mpich],,,
-     [AC_MSG_FAILURE([Cannot link C MPI programs.])
-      enable_MPI=no])
-   AS_IF([test -n "$FC" && test "X$FC" != "Xno"],
-     [ACX_FORTRAN_PACKAGE([MPI], [mpif.h],,,
-        [AC_MSG_FAILURE([Required include mpif.h not found or not compilable.])
-         enable_MPI=no],[mpi_waitall],
-        [mpi mpi_f90 mpi_f77 mpich],[[-lmpi_f77 -lmpi],[-lmpi]],,
-        [AC_MSG_FAILURE([Cannot link Fortran MPI programs.])
-         enable_MPI=no],[])])])
-AS_IF([test x"${enable_mpi}" = xyes],
-      [USE_MPI=yes])
-HAVE_PARALLEL_NC4=0
-enable_ppm=no
-AS_IF([test x"$USE_MPI" = xyes],
-  [AC_DEFINE([USE_MPI],[1],[parallel I/O requested and available])
-dnl test properties of MPI system
+  [dnl
+dnl Check for MPI C interface:
+   ACX_C_PACKAGE([MPI], [mpi.h],,,
+     [AC_MSG_FAILURE([required header mpi.h not found or not compilable])],
+     [MPI_Waitall],[mpi mpich], [], [],
+     [AC_MSG_FAILURE([cannot link C MPI programs])])
+
+dnl Check for MPI_LAUNCH command:
    saved_CFLAGS=$CFLAGS
-   saved_FCFLAGS=$FCFLAGS
    saved_LIBS=$LIBS
-   CFLAGS="$CFLAGS $MPI_C_INCLUDE"
-   FCFLAGS="$FCFLAGS $MPI_FC_INCLUDE"
-   LIBS="$LIBS $MPI_C_LIB"
-   ACX_MPIRUN(,,[AC_MSG_WARN([MPI launch command unavailable])])
-   AH_TEMPLATE([YAXT_UID_DT],[Defined to MPI datatype to be used for Xt_uid])dnl
-   AC_CHECK_DECL([MPI_UINT64_T],
-     [AC_DEFINE([YAXT_UID_DT],[MPI_UINT64_T])],
-     [AC_CHECK_SIZEOF([unsigned long])
-      AC_CHECK_SIZEOF([unsigned long long])
-      AC_CHECK_DECLS([MPI_UNSIGNED_LONG_LONG],,,[AC_INCLUDES_DEFAULT
-@%:@include <mpi.h>])],[AC_INCLUDES_DEFAULT
-@%:@include <mpi.h>])
+   AS_VAR_APPEND([CFLAGS], [" $MPI_C_INCLUDE"])
+   LIBS="$MPI_C_LIB $LIBS"
+   ACX_MPIRUN(,,[AC_MSG_WARN([MPI launch command not found or not compilable])])
    CFLAGS=$saved_CFLAGS
-   FCFLAGS=$saved_FCFLAGS
    LIBS=$saved_LIBS
 
+dnl Check for MPI Fortran interface (if needed):
+   build_pio_fc_programs=$enable_cf_interface
+   test "x$FC" = xno && build_pio_fc_programs=no
+   AS_VAR_IF([build_pio_fc_programs], [yes],
+     [ACX_F90_PACKAGE([MPI], [mpi],,,
+     [AC_MSG_WARN([required Fortran module mpi not found or not compilable])
+      build_pio_fc_programs=no],
+     [mpi_waitall], [mpi mpi_f90 mpi_f77 mpich], [[-lmpi_f77 -lmpi],[-lmpi]],,
+     [AC_MSG_WARN([cannot link Fortran MPI programs])
+      build_pio_fc_programs=no],,
+     [[INTEGER :: req(1), stat(mpi_status_size, 1), ierror]],
+     [[(1, req, stat, ierror)]])])
+
+dnl Check for YAXT C interface:
+dnl
 dnl Declare pkg-config precious variables:
    PKG_PROG_PKG_CONFIG
 dnl Set precious variables following the naming convention of ACX_C_PACKAGE:
@@ -223,8 +333,8 @@ dnl have names YAXT_C_INCLUDE and YAXT_C_LIB, respectively:
    m4_popdef([AC_ARG_VAR])dnl
    saved_CFLAGS=$CFLAGS
    saved_LIBS=$LIBS
-   CFLAGS="$CFLAGS $MPI_C_INCLUDE"
-   LIBS="$LIBS $MPI_C_LIB"
+   AS_VAR_APPEND([CFLAGS], [" $MPI_C_INCLUDE"])
+   LIBS="$MPI_C_LIB $LIBS"
 dnl The following is extracted from ACX_GENERIC_PACKAGE, which is expanded by
 dnl ACX_C_PACKAGE. We do not use the latter macro here to avoid introduction of
 dnl the '--with-yaxt-XXX' configure options, which might be very confusing since
@@ -233,13 +343,42 @@ dnl whatever pkg-config finds will be used instead.
      [YAXT_C_INCLUDE=$acx_cv_c_include_yaxt_h
       ACX_OPTION_SEARCH_LIBS_MULTI([xt_initialized], [yaxt_c yaxt],
         [YAXT_C_LIB=$acx_cv_option_search_xt_initialized_c],
-        [AC_MSG_FAILURE([Cannot link to yaxt.])],,[$YAXT_C_LIB])],
-     [AC_MSG_FAILURE([Required include yaxt.h not found or not compilable.])],,
+        [AC_MSG_FAILURE([cannot link C YAXT programs])],,[$YAXT_C_LIB])],
+     [AC_MSG_FAILURE([required header yaxt.h not found or not compilable])],,
      [$YAXT_C_INCLUDE],[[]])
+dnl
+   AH_TEMPLATE([YAXT_UID_DT],
+     [Defined to MPI datatype to be used for Xt_uid])dnl
+   defined_Xt_uid=no
+   AC_CHECK_DECL([MPI_UINT64_T],
+     [AC_DEFINE([YAXT_UID_DT], [MPI_UINT64_T])
+      defined_Xt_uid=yes],
+     [AS_VAR_APPEND([CFLAGS], [" $YAXT_C_INCLUDE"])
+      LIBS="$YAXT_C_LIB $LIBS"
+      AC_CHECK_SIZEOF([Xt_uid],,
+        [AC_INCLUDES_DEFAULT
+@%:@include <yaxt.h>])
+      AC_CHECK_SIZEOF([unsigned long])
+      AS_IF([test "$ac_cv_sizeof_unsigned_long" -eq "$ac_cv_sizeof_Xt_uid"],
+        [AC_DEFINE([YAXT_UID_DT], [MPI_UNSIGNED_LONG])
+         defined_Xt_uid=yes],
+        [AC_CHECK_DECLS([MPI_UNSIGNED_LONG_LONG],
+           [AC_CHECK_SIZEOF([unsigned long long])
+            AS_IF([test "$ac_cv_sizeof_unsigned_long_long" -eq "$ac_cv_sizeof_Xt_uid"],
+              [AC_DEFINE([YAXT_UID_DT],[MPI_UNSIGNED_LONG_LONG])
+               defined_Xt_uid=yes])],,
+           [AC_INCLUDES_DEFAULT
+@%:@include <mpi.h>])])],
+     [AC_INCLUDES_DEFAULT
+@%:@include <mpi.h>])
+   AS_VAR_IF([defined_Xt_uid], [no],
+     [AC_MSG_FAILURE([no way to communicate Xt_uid found])])
+   AS_UNSET([defined_Xt_uid])
    CFLAGS=$saved_CFLAGS
    LIBS=$saved_LIBS
-dnl
-   AS_IF([test -n "$FC" && test "X$FC" != Xno],
+
+dnl Check for YAXT Fortran interface (if needed):
+   AS_VAR_IF([build_pio_fc_programs], [yes],
      [dnl
 dnl Set precious variables following the naming convention of ACX_F90_PACKAGE:
       AC_ARG_VAR([YAXT_FC_MOD],
@@ -259,52 +398,34 @@ dnl have names YAXT_FC_MOD and YAXT_FC_LIB, respectively:
       m4_popdef([AC_ARG_VAR])dnl
       saved_FCFLAGS=$FCFLAGS
       saved_LIBS=$LIBS
-      FCFLAGS="$FCFLAGS $MPI_FC_INCLUDE"
-      LIBS="$LIBS $MPI_FC_LIB"
+      AS_VAR_APPEND([FCFLAGS], [" $MPI_FC_MOD"])
+      LIBS="$MPI_FC_LIB $LIBS"
 dnl The following is extracted from ACX_F90_PACKAGE. We do not use the
 dnl aforementioned macro here to avoid introduction of the '--with-yaxt-XXX'
 dnl configure options, which might be very confusing since whatever pkg-config
 dnl finds will be used instead.
       AC_LANG_PUSH([Fortran])dnl
-      ACX_SL_FC_CHECK_MOD_PATH_FLAG
       ACX_FORTRAN_CHECK_MOD_PATHS_IFELSE([yaxt],,
         [YAXT_FC_MOD=$acx_cv_fortran_mod_yaxt
-dnl The original FCFLAGS are already saved above:
-         FCFLAGS="$FCFLAGS $YAXT_FC_MOD"
+         AS_VAR_APPEND([FCFLAGS], [" $YAXT_FC_MOD"])
 dnl Note that the following test must check for a function implemented in the
 dnl Fortran library, as well as for a function implemented in the C library and
 dnl available via C bindings:
          ACX_OPTION_SEARCH_LIBS_MULTI([xt_initialized],[yaxt],
            [YAXT_FC_LIB=$acx_cv_option_search_xt_initialized_fc],
-           [AC_MSG_FAILURE([Cannot link to yaxt.])],[[-lyaxt_c]],
+           [AC_MSG_WARN([cannot link Fortran YAXT programs])
+            build_pio_fc_programs=no],[[-lyaxt_c]],
            [$YAXT_FC_LIB],
            [[      use yaxt
       logical is_initialized]],
            [[      is_initialized = xt_initialized()
       call xt_finalize()]])],
-        [AC_MSG_FAILURE([Required module yaxt not found or not compilable.])],,
+        [AC_MSG_WARN([required Fortran module yaxt not found or not compilable])
+         build_pio_fc_programs=no],,
         [$YAXT_FC_MOD])
       AC_LANG_POP([Fortran])dnl
       FCFLAGS=$saved_FCFLAGS
       LIBS=$saved_LIBS])
-dnl The configure script fails above if YAXT is not available:
-   AC_DEFINE([HAVE_YAXT],,[yaxt library is available])
-
-   AS_IF([test "x$ac_cv_have_decl_MPI_UINT64_T" != xyes],
-     [saved_CFLAGS=$CFLAGS
-      saved_LIBS=$LIBS
-      CFLAGS="$CFLAGS $YAXT_C_INCLUDE $MPI_C_INCLUDE"
-      LIBS="$LIBS $YAXT_C_LIB $MPI_C_LIB"
-      AC_CHECK_SIZEOF([Xt_uid],,[AC_INCLUDES_DEFAULT
-@%:@include <yaxt.h>])
-      AS_IF([test "$ac_cv_sizeof_unsigned_long" -eq "$ac_cv_sizeof_Xt_uid"],
-        [AC_DEFINE([YAXT_UID_DT],[MPI_UNSIGNED_LONG])],
-        [test "x$ac_cv_have_decl_MPI_UNSIGNED_LONG_LONG" = xyes \
-          -a "$ac_cv_sizeof_unsigned_long_long" -eq "$ac_cv_sizeof_Xt_uid"],
-        [AC_DEFINE([YAXT_UID_DT],[MPI_UNSIGNED_LONG_LONG])],
-        [AC_MSG_FAILURE([no way to communicate Xt_uid found])])
-      CFLAGS=$saved_CFLAGS
-      LIBS=$saved_LIBS])
 
 dnl Parallel netCDF support still requires ScalES-PPM and YAXT to re-arrange the
 dnl data when running with more than one collector.
@@ -328,8 +449,8 @@ dnl case have names PPM_CORE_C_INCLUDE and PPM_CORE_C_LIB, respectively:
    m4_popdef([AC_ARG_VAR])dnl
    saved_CFLAGS=$CFLAGS
    saved_LIBS=$LIBS
-   CFLAGS="$CFLAGS $MPI_C_INCLUDE"
-   LIBS="$LIBS $MPI_C_LIB"
+   AS_VAR_APPEND([CFLAGS], [" $MPI_C_INCLUDE"])
+   LIBS="$MPI_C_LIB $LIBS"
 dnl The following is extracted from ACX_GENERIC_PACKAGE, which is expanded by
 dnl ACX_C_PACKAGE. We do not use the latter macro here to avoid introduction of
 dnl the '--with-ppm-core-XXX' configure options, which might be very confusing
@@ -338,29 +459,26 @@ dnl since whatever pkg-config finds will be used instead.
      [PPM_CORE_C_INCLUDE=$acx_cv_c_include_ppm_ppm_h
       ACX_OPTION_SEARCH_LIBS_MULTI([PPM_initialize], [scalesppmcore],
         [PPM_CORE_C_LIB=$acx_cv_option_search_PPM_initialize_c
-         enable_ppm=yes
+         have_ppm=yes
          AC_DEFINE([HAVE_PPM_CORE],,[ScalES PPM C core library is available])
-         saved_CPPFLAGS=$CPPFLAGS
-         CPPFLAGS="$CPPFLAGS $PPM_CORE_C_INCLUDE"
+         AS_VAR_APPEND([CFLAGS], [" $PPM_CORE_C_INCLUDE"])
          AC_CHECK_HEADERS([ppm/dist_array.h],
-            [HAVE_PPM_DIST_ARRAY=yes],,
-            [AC_INCLUDES_DEFAULT])
-         CPPFLAGS=$saved_CPPFLAGS
+           [HAVE_PPM_DIST_ARRAY=yes],
+           [HAVE_PPM_DIST_ARRAY=no],
+           [AC_INCLUDES_DEFAULT])
          AC_SUBST([HAVE_PPM_DIST_ARRAY])
          AM_SUBST_NOTMAKE([HAVE_PPM_DIST_ARRAY])],
-        [AC_MSG_WARN([Cannot link to scales-ppm-core library.])],,
+        [AC_MSG_WARN([cannot link C SCALES-PPM-CORE programs])],,
         [$PPM_CORE_C_LIB])],
-     [AC_MSG_WARN([Include ppm/ppm.h not found or not compilable.])],,
+     [AC_MSG_WARN([required header ppm/ppm.h not found or not compilable])],,
      [$PPM_CORE_C_INCLUDE],[[]])
    CFLAGS=$saved_CFLAGS
    LIBS=$saved_LIBS
-   AS_VAR_IF([enable_ppm], [no],
-     [PPM_CORE_C_INCLUDE=
-      PPM_CORE_C_LIB=])
-dnl
+
 dnl NC_HAS_PNETCDF is useful when available to short-circuit some tests
-   AS_IF([test x"$ENABLE_NETCDF" = xyes],
-     [AC_CHECK_HEADERS([netcdf_meta.h],,,[AC_INCLUDES_DEFAULT
+   AS_VAR_IF([ENABLE_NETCDF], [yes],
+     [AC_CHECK_HEADERS([netcdf_meta.h],,,
+        [AC_INCLUDES_DEFAULT
 @%:@include <netcdf.h>])
 dnl The following test is relevant only for older versions of netCDF. Starting
 dnl version 4.3.3, netCDF provides the NC_HAS_PNETCDF macro and its value
@@ -372,172 +490,55 @@ dnl overrides the result of the test.
          test "x$($NC_CONFIG --has-pnetcdf)" = "xyes" && \
          acx_cv_have_pnetcdf=yes])
       AS_VAR_IF([acx_cv_have_pnetcdf], [yes],
-        [AC_DEFINE([HAVE_NETCDF_PAR_PNETCDF],[1],
+        [AC_DEFINE([HAVE_NETCDF_PAR_PNETCDF], [1],
            [Defined to 1 if NetCDF parallel open supports NC_PNETCDF])])])
-dnl
-dnl If not both scales-ppm and yaxt are available, netcdf can only be used in
-dnl serial mode:
-   AS_IF([test x"$ENABLE_NC4" = xyes && test x"$enable_ppm" = xyes],
+
+dnl If scales-ppm is not available, netcdf can only be used in serial mode:
+   AS_IF([test x"$ENABLE_NC4" = xyes && test x"$have_ppm" = xyes],
      [saved_CFLAGS=$CFLAGS
       CFLAGS="$CFLAGS $MPI_C_INCLUDE"
-      AC_CHECK_HEADERS([netcdf_par.h],,,[AC_INCLUDES_DEFAULT
+      AC_CHECK_HEADERS([netcdf_par.h],,,
+        [AC_INCLUDES_DEFAULT
 @%:@include <netcdf.h>])
       AC_CHECK_DECL([MPI_Bcast],
-        [HAVE_PARALLEL_NC4=1
+        [have_parallel_nc4=yes
          AC_CHECK_DECLS([nc_inq_format_extended],,
-           [AC_MSG_NOTICE([The supplied netCDF library does not support nc_inq_format_extended.])],
+           [AC_MSG_NOTICE([The supplied netCDF library does not support ]dnl
+[nc_inq_format_extended.])],
            [AC_INCLUDES_DEFAULT
 @%:@include <netcdf.h>])
          ACX_TLS_XLC_RETRY
-         AC_DEFINE([HAVE_PARALLEL_NC4],[1],
+         AC_DEFINE([HAVE_PARALLEL_NC4], [1],
            [netCDF library does support MPI parallel invocations])],
-        [AC_MSG_WARN([The supplied netCDF library does not support MPI parallel invocations])],
+        [AC_MSG_WARN([the supplied netCDF library does not support MPI ]dnl
+[parallel invocations])],
         [AC_INCLUDES_DEFAULT
 @%:@include <netcdf.h>
 @%:@ifdef HAVE_NETCDF_PAR_H
 @%:@include <netcdf_par.h>
 @%:@endif])
       CFLAGS=$saved_CFLAGS])
-dnl
+
+dnl Check for librt:
    AC_SUBST([LIBRT], [''])
    AC_CHECK_DECL([_POSIX_ASYNCHRONOUS_IO],
      [saved_LIBS=$LIBS
       AC_SEARCH_LIBS([aio_suspend], [rt],
         [test "$ac_res" = "none required" || LIBRT=$ac_res])
       LIBS=$saved_LIBS])],
-dnl
-  [MPI_LAUNCH="`pwd`/util/serialrun"
-   AC_SUBST([MPI_LAUNCH])])
-AC_SUBST([HAVE_PARALLEL_NC4])
-AM_CONDITIONAL([USE_MPI],[test x"$USE_MPI" = xyes])
-AM_CONDITIONAL([USE_PPM_CORE],[test $enable_ppm = yes])
-AM_CONDITIONAL([HAVE_PARALLEL_NC4],[test $HAVE_PARALLEL_NC4 -gt 0])
-AC_SUBST([USE_MPI])
-AC_SUBST([ENABLE_MPI],[`test x"$enable_mpi" = xyes && echo true || echo false`])
-#  ----------------------------------------------------------------------
-#  Create the Fortran Interface via iso_c_binding module (Fortran 2003 Standard)
-#
-AC_ARG_ENABLE([iso-c-interface],
-              [AS_HELP_STRING([--enable-iso-c-interface],
-                 [Create Fortran Interface via iso_c_bindings facility of F2003 [default=no].])],
-              [enable_isoc=${enableval}],[enable_isoc=no])
-AS_IF([test x"$enable_isoc" = xyes],
-  [AS_IF([test -z "$FC" || test "X$FC" = "Xno"],
-     [AC_MSG_FAILURE([Fortran compiler not found or disabled: either disable dnl
-Fortran 2003 interface (--disable-iso-c-interface) or set FC accordingly])])
-   ACX_FC_CHECK_STRPTR_CONVERT([],
-     [AC_MSG_FAILURE([the Fortran compiler cannot handle complex CHARACTER dnl
-interoperability: disable Fortran 2003 interface (--disable-iso-c-interface)])])],
-  [enable_isoc=no])
-AM_CONDITIONAL([CREATE_ISOC],[test "x$enable_isoc" = 'xyes'])
-AC_SUBST([ENABLE_F2003_ISOC],[$enable_isoc])
-AM_SUBST_NOTMAKE([ENABLE_F2003_ISOC])
-# in case the Fortran interface uses the more modern F90-style interface,
-# the FCFLAGS for users of the library have to include a switch to use the
-# .mod file
-CDI_F90_INTERFACE_FCFLAGS=''
-AS_IF([test "x${enable_isoc}" = "xyes"],
-  [AC_LANG_PUSH([Fortran])
-   ACX_SL_FC_CHECK_MOD_PATH_FLAG
-   AC_LANG_POP([Fortran])
-   CDI_F90_INTERFACE_FCFLAGS="${FC_MOD_FLAG}${includedir}"])
-AC_SUBST([CDI_F90_INTERFACE_FCFLAGS])
-#  Check the module extension of the fortran compiler
-AS_IF([test -n "$FC" && test "X$FC" != "Xno"],
-  [ACX_SL_FC_MOD_SUFFIX(,[FCMODEXT=mod])])
-AM_CONDITIONAL([FORTRAN_MOD_UC],[test "x$FCMODCASE" = "xuc"])
-# -----------------------------------------------------------------------
-# Check for SWIG - Generator for script-language bindings
-AC_ARG_ENABLE(swig,
-              [AS_HELP_STRING([--enable-swig],[use swig to create extra bindings [default=no] (EXPERIMENTAL)])],
-              [AC_CHECK_PROG(SWIG,swig,swig)],
-              [enable_swig=no])
-AM_CONDITIONAL(ENABLE_SWIG,[test "x$SWIG" != "x"])
-#  ----------------------------------------------------------------------
-#  Create the Ruby Interface via swig
-#
-AC_ARG_ENABLE([ruby],
-  [AS_HELP_STRING([--enable-ruby],[ruby language bindings [default=no] (EXPERIMENTAL)])],
-  [AC_CHECK_PROG([RUBY],[ruby],[ruby])
-   RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
-   saved_CPPFLAGS=$CPPFLAGS
-   CPPFLAGS="$CPPFLAGS $RUBY_INCLUDES"
-   AC_CHECK_HEADER([ruby.h],,[enable_ruby=no], [AC_INCLUDES_DEFAULT])
-   CPPFLAGS=$saved_CPPFLAGS
-   AS_IF([test "x$RUBY" != "x"],
-         [AS_IF([test "x$SWIG" = "x"],
-                [AC_MSG_ERROR([Ruby bindings: Please enable SWIG with '--enable-swig'!])])],
-                [AS_IF([test `$SWIG -help 2>&1 | $GREP -c '\-ruby *- Generate'` = 0],
-                       [AC_MSG_NOTICE([No (swig does not support -ruby option)])
-                        enable_ruby=no
-                       ])])],
-  [enable_ruby=no])
-AM_CONDITIONAL(ENABLE_RUBY,[test "x$enable_ruby" != "xno"])
-AS_IF([test "x$enable_ruby" != "xno"],[AC_SUBST([ENABLE_RUBY],[true])],[AC_SUBST([ENABLE_RUBY],[false])])
-# Ruby is also used for the Fortran 2003 ISO C generator in maintainer mode.
-# Report properly if it's missing:
-AS_VAR_IF([RUBY], [], [AS_UNSET([RUBY])])
+  [YAXT_C_INCLUDE=; YAXT_C_LIB=
+   MPI_C_INCLUDE=; MPI_C_LIB=
+   MPI_LAUNCH="`pwd`/util/serialrun"])
+AS_VAR_IF([have_ppm], [no], [PPM_CORE_C_INCLUDE=; PPM_CORE_C_LIB=])
+AS_VAR_IF([build_pio_fc_programs], [no],
+  [YAXT_FC_MOD=; YAXT_FC_LIB=
+   MPI_FC_MOD=; MPI_FC_LIB=])
+AM_CONDITIONAL([BUILD_PIO_FC_PROGRAMS], [test "x$build_pio_fc_programs" = xyes])
+AM_CONDITIONAL([ENABLE_MPI], [test "x$enable_mpi" = xyes])
+AM_CONDITIONAL([HAVE_PARALLEL_NC4], [test "x$have_parallel_nc4" = xyes])
+
 AM_MISSING_PROG([RUBY], [ruby])
-#  ----------------------------------------------------------------------
-#  Create the Python Interface via swig
-AC_ARG_ENABLE(python,
-  [AS_HELP_STRING([--enable-python],[python language bindings [default=no] (EXPERIMENTAL)])],
-  [AC_CHECK_PROG(PYTHON,python,python)
-   enable_python=no
-   for PYTHON_INCLUDES in \
-     "-I`$PYTHON -c 'from distutils import sysconfig;print(sysconfig.get_python_inc())'`" \
-     "-I`$PYTHON -c 'from distutils import sysconfig;print(sysconfig.get_python_lib(1,1))' | $SED 's/lib/include/'`"
-   do
-     saved_CPPFLAGS=$CPPFLAGS
-     CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
-     AC_CHECK_HEADER([Python.h],[enable_python=yes
-       break],,[AC_INCLUDES_DEFAULT])
-     CPPFLAGS=$saved_CPPFLAGS
-   done
-   AS_IF([test "x$enable_python" != "xno"],
-         [AS_IF([test "x$SWIG" = "x"],
-                [AC_MSG_ERROR([Python bindings: Please enable SWIG with '--enable-swig'!])],
-                [PYTHON=])],
-                [AS_IF([test `$SWIG -help 2>&1 | $GREP -c '\-python *- Generate'` = 0],
-                       [AC_MSG_NOTICE([No (swig does not support -python option)])
-                        enable_python=no
-                       ])])],
-  [enable_python=no])
-AM_CONDITIONAL(ENABLE_PYTHON, [test "x$enable_python" != "xno"])
-AS_IF([test "x$enable_python" != "xno"],[AC_SUBST([ENABLE_PYTHON],[true])],[AC_SUBST([ENABLE_PYTHON],[false])])
-#  ----------------------------------------------------------------------
-AM_CONDITIONAL(CREATE_INTERFACES, [test  "x$enable_ruby" = "xyes" -o "x$enable_python" = "xyes"])
-#  ----------------------------------------------------------------------
-#  Create the CDI Fortran77 Interface via cfortran.h
-AC_ARG_ENABLE([cf-interface],
-              [AS_HELP_STRING([--disable-cf-interface],
-                              [Omit building of cfortran Interface])],
-              [enable_cfinterface=${enableval}],[enable_cfinterface=yes])
-AS_IF([test "x${enable_cfinterface}" = "xyes"], [
-dnl ######################################################################
-dnl Test whether cfortran.h works correctly
-dnl ######################################################################
-ACX_FIND_CFORTRAN_DEF
-ACX_XLF_QEXTNAME_ADD_APPENDUS
-AS_IF([test -n "$FC" -a X"$FC" != Xno -o -n "$F77" -a X"$F77" != Xno],
-  [ACX_CHECK_CFORTRAN([$srcdir/src],
-    [AC_DEFINE([HAVE_CF_INTERFACE],[1],
-       [Defined to 1 if C / Fortran interface cfortran.h works])],
-    [AS_CASE([x"$acx_cv_cfortran_works"],
-       [x"error"],
-       [AC_MSG_NOTICE([Linking/Running with C EXTERNAL built with cfortran.h does not work!])],
-       [x"compiling with cfortran.h failed"],
-       [AC_MSG_NOTICE([Compilation with cfortran.h is not working!])],
-       [x"error compiling Fortran subroutine"],
-       [AC_MSG_NOTICE([compilation of simple Fortran source failed!])],
-       [AC_MSG_NOTICE([Unexpected error when linking C and Fortran via cfortran.h!])])
-     AC_MSG_NOTICE([Disabling cfortran.h bindings generation])
-     acx_cv_cfortran_works=no])])
-])
-AM_CONDITIONAL([USE_FC],[test -n "$FC" -a X"$FC" != Xno -a x"$acx_cv_cfortran_works" = xyes])dnl
-dnl
-AC_SUBST([CPPFLAGS])dnl
-dnl
+
 m4_foreach([build_flag_var],[[BUILD_CFLAGS],[BUILD_FCFLAGS],[BUILD_LDFLAGS],[BUILD_LIBS],[BUILD_MPI_C_LIB],[BUILD_MPI_FC_LIB],[BUILD_C_INCLUDE],[BUILD_FC_INCLUDE]],
   [AC_ARG_VAR(build_flag_var,
      [append to ]m4_bpatsubst(build_flag_var, [BUILD_], [])[ during build but not in configure phase])dnl
@@ -549,63 +550,69 @@ m4_foreach([build_tool_var],[[BUILD_CC],[BUILD_CXX],[BUILD_FC],[BUILD_F77]],
      [replace ]m4_bpatsubst(build_tool_var, [BUILD_], [])[ with expansion of $]build_tool_var[ during build but not in configure phase])dnl
 AC_CONFIG_COMMANDS_PRE(m4_bpatsubst(build_tool_var, [BUILD_], [])[="$]{build_tool_var:-$[]m4_bpatsubst(build_tool_var, [BUILD_], [])}["])dnl
 AM_SUBST_NOTMAKE(build_tool_var)])dnl
-dnl
-dnl
-dnl
-# Checks for compiler
-COMPILER="$CC $CFLAGS"
-AC_DEFINE_UNQUOTED(COMPILER, ["$COMPILER"], [Compiler])
-
-AC_CONFIG_FILES([tests/test_cksum_grib \
-                 tests/test_cksum_grib2 \
-                 tests/test_cksum_nc \
-                 tests/test_cksum_nc2 \
-                 tests/test_cksum_nc4 \
-                 tests/test_cksum_extra \
-                 tests/test_cksum_service \
-                 tests/test_cksum_ieg \
-                 tests/test_chunk_cksum \
-                 tests/test_f2003 \
-                 tests/pio_write_run \
-                 tests/pio_write_deco2d_run \
-                 tests/pio_cksum_mpinonb \
-                 tests/pio_cksum_mpi_fw_ordered \
-                 tests/pio_cksum_mpi_fw_at_all \
-                 tests/pio_cksum_mpi_fw_at_reblock \
-                 tests/pio_cksum_fpguard \
-                 tests/pio_cksum_asynch \
-                 tests/pio_cksum_writer \
-                 tests/pio_cksum_cdf \
-                 tests/test_byteswap_run \
-                 tests/test_resource_copy_run \
-                 tests/pio_cksum_grb2 \
-                 tests/test_resource_copy_mpi_run \
-                 tests/test_cdf_transformation \
-                 tests/test_cdf_const \
-                 tests/test_table_run \
-                 tables/gen_tableheaderfile \
-                 util/serialrun],[chmod a+x "$ac_file"])
-
-AC_CONFIG_FILES([Makefile src/Makefile interfaces/Makefile app/Makefile \
-	tests/Makefile examples/Makefile cdi.settings \
-	examples/pio/Makefile src/cmake/cdi/cdi-config.cmake src/cmake/cdi/cdi-config-version.cmake \
-        src/pkgconfig/cdi.pc src/pkgconfig/cdipio.pc src/pkgconfig/cdi_f2003.pc])
+
+dnl Additional output variables for cdi.settings:
+AC_SUBST([ENABLE_MPI], [$enable_mpi])
+AM_SUBST_NOTMAKE([ENABLE_MPI)])dnl
+AC_SUBST([HAVE_PARALLEL_NC4], [$have_parallel_nc4])
+AM_SUBST_NOTMAKE([HAVE_PARALLEL_NC4)])dnl
+
+AC_CONFIG_HEADERS([src/config.h])
+AC_CONFIG_FILES([
+  Makefile
+  app/Makefile
+  cdi.settings
+  examples/Makefile
+  examples/pio/Makefile
+  src/Makefile
+  src/cmake/cdi/cdi-config-version.cmake
+  src/cmake/cdi/cdi-config.cmake
+  src/pkgconfig/cdi.pc
+  src/pkgconfig/cdi_f2003.pc
+  src/pkgconfig/cdipio.pc
+  tests/Makefile
+])
+AC_CONFIG_FILES([
+  tables/gen_tableheaderfile
+  tests/pio_cksum_asynch
+  tests/pio_cksum_cdf
+  tests/pio_cksum_fpguard
+  tests/pio_cksum_grb2
+  tests/pio_cksum_mpi_fw_at_all
+  tests/pio_cksum_mpi_fw_at_reblock
+  tests/pio_cksum_mpi_fw_ordered
+  tests/pio_cksum_mpinonb
+  tests/pio_cksum_writer
+  tests/pio_write_deco2d_run
+  tests/pio_write_run
+  tests/test_byteswap_run
+  tests/test_cdf_const
+  tests/test_cdf_transformation
+  tests/test_chunk_cksum
+  tests/test_cksum_extra
+  tests/test_cksum_grib
+  tests/test_cksum_grib2
+  tests/test_cksum_ieg
+  tests/test_cksum_nc
+  tests/test_cksum_nc2
+  tests/test_cksum_nc4
+  tests/test_cksum_service
+  tests/test_f2003
+  tests/test_resource_copy_mpi_run
+  tests/test_resource_copy_run
+  tests/test_table_run
+  util/serialrun
+],
+[chmod a+x "$ac_file"])
+
 AC_OUTPUT
 
-#  ----------------------------------------------------------------------
-#  Show configuration
 AC_MSG_NOTICE([CDI is configured with the following options:])
-./config.status cdi.settings
 cat cdi.settings
 
-AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
-      [AC_MSG_NOTICE([
-
-  Warning: The C compiler does not accept ANSI C99 source code!
-])])
 AC_MSG_NOTICE([
 
   Configuration completed.
 
-    You can now say 'make' to compile the CDI package and 'make install' to install it afterwards.
+    You can now run 'make' to compile the CDI package and 'make install' to install it afterwards.
 ])
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 17695a7360ff4da73f42f24d73818d1772644cb9..f32cc8b87abe67804e8f921e1d5aed344fbd201b 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -14,12 +14,12 @@ if ENABLE_NETCDF
 check_PROGRAMS += cdi_write_const
 endif
 
-if CREATE_ISOC
+if ENABLE_ISOC_INTERFACE
 check_PROGRAMS += cdi_read_f2003 cdi_write_f2003
-endif
+endif ENABLE_ISOC_INTERFACE
 
 AM_CPPFLAGS = -I$(top_srcdir)/src
-AM_FCFLAGS  = $(FPP_INCOPT)$(top_srcdir)/src $(FC_MOD_FLAG)../src
+AM_FCFLAGS  = $(FC_OPTINC)$(top_srcdir)/src $(FC_MOD_FLAG)../src
 
 AM_LDFLAGS =
 if ENABLE_ALL_STATIC
@@ -52,7 +52,7 @@ cdi_read_f2003_LDADD = $(top_builddir)/src/libcdi_f2003.la $(top_builddir)/src/l
 cdi_write_f2003_SOURCES = cdi_write_f2003.f90
 cdi_write_f2003_LDADD = $(top_builddir)/src/libcdi_f2003.la $(top_builddir)/src/libcdi.la
 
-if FORTRAN_MOD_UC
+if FC_MOD_UPPERCASE
 cdi_read_f2003.$(OBJEXT) cdi_write_f2003.$(OBJEXT): $(top_builddir)/src/MO_CDI.$(FCMODEXT)
 else
 cdi_read_f2003.$(OBJEXT) cdi_write_f2003.$(OBJEXT): $(top_builddir)/src/mo_cdi.$(FCMODEXT)
diff --git a/examples/pio/Makefile.am b/examples/pio/Makefile.am
index 4f8caaf3f23292f7c1066867bc2121ca3912225a..1c8671d4a2a02d965d2a15a83fe17a24cee7a74e 100644
--- a/examples/pio/Makefile.am
+++ b/examples/pio/Makefile.am
@@ -2,34 +2,37 @@ check_PROGRAMS = \
   collectData \
   collectDataNStreams
 
-if USE_MPI
+if ENABLE_MPI
 check_PROGRAMS += compareResourcesArray
-endif
+endif ENABLE_MPI
 
-if USE_FC
+if ENABLE_CF_INTERFACE
 check_PROGRAMS += collectData2003
-endif
+endif ENABLE_CF_INTERFACE
 
 AM_CPPFLAGS = -I$(top_srcdir)/src $(YAXT_C_INCLUDE)
+if ENABLE_MPI
+AM_CPPFLAGS += -DUSE_MPI
+endif ENABLE_MPI
 AM_CFLAGS = $(MPI_C_INCLUDE)
 
-AM_FCFLAGS = $(FPP_INCOPT)$(top_srcdir)/src $(MPI_FC_INCLUDE)
-if USE_MPI
-AM_FCFLAGS += $(FPP_DEFOPT)USE_MPI
-endif
+AM_FCFLAGS = $(FC_OPTINC)$(top_srcdir)/src $(MPI_FC_INCLUDE)
+if ENABLE_MPI
+AM_FCFLAGS += $(FC_DEFINE)USE_MPI
+endif ENABLE_MPI
 
 AM_LDFLAGS =
 if ENABLE_ALL_STATIC
 AM_LDFLAGS += -all-static
 endif
 
-if USE_MPI
+if ENABLE_MPI
 LDADD = $(top_builddir)/src/libcdipio.la $(top_builddir)/src/libcdi.la $(YAXT_LIBS) $(MPI_C_LIB)
 collectData2003_LDADD = $(top_builddir)/src/libcdipio.la $(top_builddir)/src/libcdi.la $(YAXT_FC_LIB) $(MPI_FC_LIB)
-else
+else !ENABLE_MPI
 LDADD = $(top_builddir)/src/libcdi.la
 collectData2003_LDADD = $(top_builddir)/src/libcdi.la
-endif
+endif !ENABLE_MPI
 
 collectData_SOURCES = collectData.c
 
diff --git a/src/Makefile.am b/src/Makefile.am
index dbc3279722e99ddd4d87416c1485920ba52c816d..85f94b1628a3428e81cb86e7a94428bde29643b7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,11 +10,11 @@ EXTRA_DIST = cdilib.c
 nodist_pkgconfig_DATA =
 nodist_cmake_DATA =
 
-if FORTRAN_MOD_UC
+if FC_MOD_UPPERCASE
 mo_cdi_mod = MO_CDI.$(FCMODEXT)
-else
+else !FC_MOD_UPPERCASE
 mo_cdi_mod = mo_cdi.$(FCMODEXT)
-endif
+endif !FC_MOD_UPPERCASE
 
 if ENABLE_CDI_LIB
 include_HEADERS += \
@@ -27,36 +27,34 @@ nodist_pkgconfig_DATA += pkgconfig/cdi.pc
 nodist_cmake_DATA += \
   cmake/cdi/cdi-config-version.cmake \
   cmake/cdi/cdi-config.cmake
-# add cdi.inc only if cfortran interface is required
-if USE_FC
+if ENABLE_CF_INTERFACE
 include_HEADERS += cdi.inc
-endif
-if CREATE_ISOC
+endif ENABLE_CF_INTERFACE
+if ENABLE_ISOC_INTERFACE
 nodist_include_HEADERS += $(mo_cdi_mod)
 lib_LTLIBRARIES += libcdi_f2003.la
 nodist_pkgconfig_DATA += pkgconfig/cdi_f2003.pc
-endif
-if USE_MPI
+endif ENABLE_ISOC_INTERFACE
+if ENABLE_MPI
 include_HEADERS += cdipio.h
 lib_LTLIBRARIES += libcdipio.la
 nodist_pkgconfig_DATA += pkgconfig/cdipio.pc
-# add cdipio.inc only if cfortran interface is required
-if USE_FC
+if ENABLE_CF_INTERFACE
 include_HEADERS += cdipio.inc
-endif
-endif
-else
+endif ENABLE_CF_INTERFACE
+endif ENABLE_MPI
+else !ENABLE_CDI_LIB
 noinst_LTLIBRARIES += libcdi.la
-if CREATE_ISOC
+if ENABLE_ISOC_INTERFACE
 noinst_LTLIBRARIES += libcdi_f2003.la
-endif
-if USE_MPI
+endif ENABLE_ISOC_INTERFACE
+if ENABLE_MPI
 noinst_LTLIBRARIES += libcdipio.la
-endif
-endif
+endif ENABLE_MPI
+endif !ENABLE_CDI_LIB
 
 AM_CPPFLAGS =
-if USE_MPI
+if ENABLE_MPI
 # TODO: this needs a refactoring but for now we set this macro here and not in
 # config.h because the macro is used in several files that do not include the
 # header file directly.
@@ -208,21 +206,17 @@ libcdi_la_SOURCES = \
   zaxis.c \
   zaxis.h
 
-# cfortran.h is an optional part of libcdi
-if USE_FC
+if ENABLE_CF_INTERFACE
 libcdi_la_SOURCES += \
   cdiFortran.c \
   cfortran.h
-endif
+endif ENABLE_CF_INTERFACE
 
-# these only contain code if grib_api is available
 if HAVE_LIBGRIB_API
 libcdi_la_SOURCES += \
   gribapi_utilities.c \
   stream_gribapi.c
-endif
-
-libcdi_la_LIBADD = $(UUID_C_LIB)
+endif HAVE_LIBGRIB_API
 
 libcdi_f2003_la_SOURCES = mo_cdi.f90
 libcdi_f2003_la_LIBADD = libcdi.la
@@ -270,15 +264,15 @@ libcdipio_la_SOURCES = \
   resource_unpack.c \
   resource_unpack.h
 
-if USE_FC
+if ENABLE_CF_INTERFACE
 libcdipio_la_SOURCES += \
   cdipioFortran.c \
   cfortran.h
-endif
+endif ENABLE_CF_INTERFACE
 
 if HAVE_PARALLEL_NC4
 libcdipio_la_SOURCES += pio_cdf_int.c
-endif
+endif HAVE_PARALLEL_NC4
 
 libcdipio_la_LIBADD = libcdi.la $(LIBRT) $(PPM_CORE_C_LIB) $(YAXT_C_LIB) $(MPI_C_LIB)
 
@@ -331,7 +325,7 @@ cdilib.c:
 
 CLEANFILES = cdilib.c
 MOSTLYCLEANFILES = make_fint
-if CREATE_ISOC
+if ENABLE_ISOC_INTERFACE
 MOSTLYCLEANFILES += $(mo_cdi_mod)
 endif
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1c2b40caa95afc5fbaebdf07841efb4a49d5d17e..56ac4b0991b9c8914fe4b42eb7be5e8943269a38 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -29,7 +29,7 @@ TESTS = \
   test_resource_copy_run \
   test_table_run
 
-if USE_MPI
+if ENABLE_MPI
 TESTS += test_resource_copy_mpi_run
 endif
 
@@ -53,11 +53,14 @@ check_PROGRAMS += \
   test_cdf_write
 endif
 
-if USE_MPI
+if ENABLE_MPI
 check_PROGRAMS += test_resource_copy_mpi
-endif
+endif ENABLE_MPI
 
 AM_CPPFLAGS = -I$(top_srcdir)/src
+if ENABLE_MPI
+AM_CPPFLAGS += -DUSE_MPI
+endif ENABLE_MPI
 AM_CFLAGS = $(PPM_CORE_C_INCLUDE) $(YAXT_C_INCLUDE) $(MPI_C_INCLUDE)
 
 AM_LDFLAGS =
@@ -98,7 +101,7 @@ pio_write_SOURCES = \
   simple_model.c \
   simple_model_helper.c \
   simple_model_helper.h
-if USE_MPI
+if ENABLE_MPI
 pio_write_LDADD = ../src/libcdipio.la ../src/libcdi.la $(PPM_CORE_LIBS) $(YAXT_LIBS) $(MPI_C_LIB)
 else
 pio_write_LDADD = $(LDADD)
@@ -112,7 +115,7 @@ pio_write_deco2d_SOURCES = \
   pio_write_setup_grid.h \
   simple_model_helper.c \
   simple_model_helper.h
-if USE_MPI
+if ENABLE_MPI
 pio_write_deco2d_LDADD = ../src/libcdipio.la ../src/libcdi.la $(PPM_CORE_LIBS) $(YAXT_LIBS) $(MPI_C_LIB)
 else
 pio_write_deco2d_LDADD = $(LDADD)
@@ -137,7 +140,7 @@ test_cdf_write_SOURCES = \
   test_cdf_write.c
 
 test_resource_copy_mpi_SOURCES = test_resource_copy_mpi.c
-if USE_MPI
+if ENABLE_MPI
 test_resource_copy_mpi_LDADD = ../src/libcdipio.la ../src/libcdi.la $(UUID_C_LIB)
 else
 test_resource_copy_mpi_LDADD = $(LDADD)
diff --git a/tests/pio_cksum_asynch.in b/tests/pio_cksum_asynch.in
index a9b19b2c968693b7e08cfe8456e175ab4d158fcb..d958a3b74de2acc9646929c9da855bb738ea0c58 100644
--- a/tests/pio_cksum_asynch.in
+++ b/tests/pio_cksum_asynch.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 pio_write_args="-p PIO_ASYNCH -w 3"
 mpi_task_num=7
diff --git a/tests/pio_cksum_cdf.in b/tests/pio_cksum_cdf.in
index 50a1449d9f87947be707d2e6c420a2b86d2074fc..e46ddf0a78e0342201d5373a13c35d18e519e8fb 100644
--- a/tests/pio_cksum_cdf.in
+++ b/tests/pio_cksum_cdf.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 LOG=pio_cksum_cdf.log
 
diff --git a/tests/pio_cksum_fpguard.in b/tests/pio_cksum_fpguard.in
index aa50e3322192c34ebffcee45ae8ff9e695b709d1..fbb654028930eb68698fa08848276372e11b9a4e 100644
--- a/tests/pio_cksum_fpguard.in
+++ b/tests/pio_cksum_fpguard.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 pio_write_args="-p PIO_FPGUARD -w 3"
 mpi_task_num=6
diff --git a/tests/pio_cksum_grb2.in b/tests/pio_cksum_grb2.in
index c436e1dea707ebbf39cfe6892728a117a4cff9c1..36702c5647a4c451e32d72c621ad7e4ce6b35ed1 100644
--- a/tests/pio_cksum_grb2.in
+++ b/tests/pio_cksum_grb2.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 pio_write_args="-w 3"
 mpi_task_num=8
diff --git a/tests/pio_cksum_mpi_fw_at_all.in b/tests/pio_cksum_mpi_fw_at_all.in
index b6560fcb5f4c6a8ffb9928835b563394838d9ace..ac1d199da8727312ef6d831c42fe29ddb01e5818 100644
--- a/tests/pio_cksum_mpi_fw_at_all.in
+++ b/tests/pio_cksum_mpi_fw_at_all.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 pio_write_args="-p PIO_MPI_FW_AT_ALL -w 2"
 mpi_task_num=5
diff --git a/tests/pio_cksum_mpi_fw_at_reblock.in b/tests/pio_cksum_mpi_fw_at_reblock.in
index 8b8cd1b24b6b84306a4065722b9f327dedd1a50b..57c67b168387763abcf97dcd63304293faa3741b 100644
--- a/tests/pio_cksum_mpi_fw_at_reblock.in
+++ b/tests/pio_cksum_mpi_fw_at_reblock.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 pio_write_args="-p PIO_MPI_FW_AT_REBLOCK -w 2"
 mpi_task_num=5
diff --git a/tests/pio_cksum_mpi_fw_ordered.in b/tests/pio_cksum_mpi_fw_ordered.in
index 55e4a825b09b4ee09c56a4892d4a906aa0a19e9f..40c3deebfba8801be101a5740625fb513a7d50c8 100644
--- a/tests/pio_cksum_mpi_fw_ordered.in
+++ b/tests/pio_cksum_mpi_fw_ordered.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 pio_write_args="-p PIO_MPI_FW_ORDERED -w 2"
 mpi_task_num=5
diff --git a/tests/pio_cksum_mpinonb.in b/tests/pio_cksum_mpinonb.in
index 609defe156553672c17e743d90b580e3f39a0994..4cbc92d56683815641847369f0a26b8e7e0e59e3 100644
--- a/tests/pio_cksum_mpinonb.in
+++ b/tests/pio_cksum_mpinonb.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 
 pio_write_args="-p PIO_MPI -w 2"
 mpi_task_num=4
diff --git a/tests/pio_cksum_writer.in b/tests/pio_cksum_writer.in
index e5a39f73e1ce9a4057302ae07f6585f8ea7d377b..733ddd49b1ef25fa758a325fd271b6f6d3f07733 100644
--- a/tests/pio_cksum_writer.in
+++ b/tests/pio_cksum_writer.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@USE_MPI_FALSE@exit 77
+@ENABLE_MPI_FALSE@exit 77
 test 'x@ENABLE_GRIB@' = xyes || exit 77
 
 pio_write_args="-p PIO_WRITER -w 4"
diff --git a/tests/pio_write_run.in b/tests/pio_write_run.in
index c9a0e7256c91eed89d3f062244d440c9e9b5f8dc..5d60a27eda162b8c20ad1c61814fa78b6b8effba 100644
--- a/tests/pio_write_run.in
+++ b/tests/pio_write_run.in
@@ -25,8 +25,8 @@ case ${suffix} in
     ;;
 esac
 
-@USE_MPI_TRUE@variations="-qno-batch-rma -qcache-redists -qcreate-curvilinear-grid -qpreset-decomposition=true"
-@USE_MPI_FALSE@variations="-qcreate-curvilinear-grid"
+@ENABLE_MPI_TRUE@variations='-qno-batch-rma -qcache-redists -qcreate-curvilinear-grid -qpreset-decomposition=true'
+@ENABLE_MPI_FALSE@variations='-qcreate-curvilinear-grid'
 
 test_variation()
 {
@@ -50,7 +50,9 @@ for variation in "" $variations ; do
   test_variation "$variation"
 done
 
-@USE_MPI_TRUE@@USE_PPM_CORE_TRUE@test_variation "-qcreate-curvilinear-grid -quse-dist-grid"
+if test 'x@HAVE_PPM_DIST_ARRAY@' = xyes; then
+  test_variation "-qcreate-curvilinear-grid -quse-dist-grid"
+fi
 
 exec 2>&6 1>&5 5>&- 6>&-
 #
diff --git a/tests/test_f2003.in b/tests/test_f2003.in
index 1e7efd99c69ded240374d48543e23c9400736054..956e4c262fbb9a85efc7fb5af6898f45db6d8397 100644
--- a/tests/test_f2003.in
+++ b/tests/test_f2003.in
@@ -1,5 +1,5 @@
 #!@SHELL@
-@CREATE_ISOC_FALSE@exit 77
+@ENABLE_ISOC_INTERFACE_FALSE@exit 77
 test 'x@ENABLE_NETCDF@' = xyes || exit 77
 
 cdi_read_f2003_stdout="$0.cdi_read_f2003.stdout"