[pnetcdf] 05/08: Release 1.7.0

Alastair McKinstry mckinstry at moszumanska.debian.org
Wed Dec 7 12:31:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository pnetcdf.

commit 72029c08a04aa769a30828973a1feb945279ed45
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Tue Jun 14 15:18:54 2016 +0100

    Release 1.7.0
---
 README                                            |   1 +
 RELEASE_NOTES                                     | 154 ++++++
 benchmarks/C/aggregation.c                        |   8 +-
 benchmarks/FLASH-IO/checkpoint_ncmpi_parallel.F90 |  12 +-
 benchmarks/FLASH-IO/plotfile_ncmpi_parallel.F90   |   8 +-
 benchmarks/Makefile.in                            |   4 +-
 configure                                         | 181 +++++---
 configure.in                                      | 131 ++++--
 examples/C/block_cyclic.c                         |  12 +-
 examples/C/bput_varn_uint.c                       |  12 +-
 examples/C/column_wise.c                          |  12 +-
 examples/C/i_varn_int64.c                         |  12 +-
 examples/C/mput.c                                 |  12 +-
 examples/C/nonblocking_write.c                    |  16 +-
 examples/C/nonblocking_write_in_def.c             |  12 +-
 examples/C/req_all.c                              |  10 +-
 examples/C/transpose.c                            |  12 +-
 examples/F77/block_cyclic.f                       |  13 +-
 examples/F77/bput_varn_int8.f                     |  13 +-
 examples/F77/column_wise.f                        |  11 +-
 examples/F77/flexible_api.f                       |   4 +-
 examples/F77/i_varn_real.f                        |  13 +-
 examples/F77/nonblocking_write.f                  |  13 +-
 examples/F90/block_cyclic.f90                     |  12 +-
 examples/F90/column_wise.f90                      |  12 +-
 examples/F90/nonblocking_write.f90                |  13 +-
 examples/Makefile.in                              |   4 +-
 examples/tutorial/Makefile.in                     |   4 +-
 src/lib/Makefile.in                               |   9 +-
 src/lib/attr.m4                                   |  35 +-
 src/lib/bput.m4                                   |  10 +-
 src/lib/error.c                                   |   4 +-
 src/lib/filetype.c                                |  50 +-
 src/lib/fill.c                                    | 300 +++++++++++-
 src/lib/getput.m4                                 |  26 +-
 src/lib/header.c                                  |  49 +-
 src/lib/i_getput.m4                               |  21 +-
 src/lib/i_varn.m4                                 |   5 +-
 src/lib/m_getput_varx.m4                          |   6 +-
 src/lib/mpincio.c                                 |  24 +-
 src/lib/mpinetcdf.c                               |  60 +--
 src/lib/nc.c                                      |  67 ++-
 src/lib/nc.h                                      |   6 +-
 src/lib/ncconfig.h.in                             |   4 +-
 src/lib/ncmpidtype.c                              |   4 +-
 src/lib/nonblocking.c                             | 382 +++++++++++----
 src/lib/pnetcdf.h.in                              |   6 +-
 src/lib/pnetcdf.pc.in                             |  33 ++
 src/lib/var.c                                     |   9 +-
 src/lib/vard.c                                    |   9 +-
 src/lib/varn.m4                                   |   4 +-
 src/libcxx/ncmpiAtt.cpp                           |   8 +-
 src/libcxx/ncmpiDim.cpp                           |   4 +-
 src/libcxx/ncmpiType.cpp                          |   4 +-
 src/libcxx/ncmpiVar.cpp                           |   8 +-
 src/libf/pnetcdf.inc.in                           |   4 +
 src/libf90/Makefile.in                            |  10 +-
 src/libf90/api.f90.in                             | 542 +++++++++++-----------
 src/libf90/nf90_constants.f90                     |   4 +-
 src/libf90/nfmpi_constants.f90.in                 |   7 +-
 src/libf90/{pnetcdf.f90 => pnetcdf.f90.in}        |   3 +-
 src/utils/ncmpidump/ncmpidump.c                   |  23 +-
 src/utils/ncmpidump/vardata.c                     |   4 +-
 src/utils/ncmpigen/load.c                         |   3 +-
 src/utils/ncmpivalid/ncmpivalid.c                 |   8 +-
 src/utils/ncoffsets/ncoffsets.c                   |  12 +-
 test/Makefile.in                                  |   4 +-
 test/nc_test/test_get.m4                          |   7 +-
 test/nonblocking/Makefile.in                      |  10 +-
 test/nonblocking/i_varn_indef.c                   |   3 +-
 test/testcases/Makefile.in                        |  10 +-
 test/testcases/bigrecords.f                       |  52 ++-
 72 files changed, 1766 insertions(+), 808 deletions(-)

diff --git a/README b/README
index cfed149..ba2c0be 100644
--- a/README
+++ b/README
@@ -20,6 +20,7 @@ information regarding the contents of the release can be found in
 the RELEASE_NOTES file in the top-level directory.  Finally, the PnetCDF web
 site,
     http://trac.mcs.anl.gov/projects/parallel-netcdf
+    http://cucis.ece.northwestern.edu/projects/PnetCDF
 contains information on bug fixes and new releases.
 
 
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 8aff83d..dd4e20f 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -2,6 +2,160 @@ Parallel NetCDF Release Notes:
 =====================================
 
 -------------------------------------
+version  1.7.0 (March 3, 2016)
+-------------------------------------
+
+  o New features
+    * Nonblocking requests now can be posted while the program is in the define
+      mode. This feature enables applications to add new variables and post the
+      nonblocking write requests without separating the codes by
+      ncmpi_enddef(). Note ncmpi_wait_all and ncmpi_wait must still be called
+      in the data mode.
+    * When using immutable write buffer in put APIs on a Little Endian machine,
+      the in-place byte swap operation performed internally in PnetCDF can
+      cause a fatal error (by trying to change the contents of an immutable
+      memory space). The solution of copying user's write request to a
+      temporary buffer and perform byte swap there conflicts with PnetCDF's
+      design principle of avoiding internal memory allocation as much as
+      possible. Since the size of immutable buffer in most cases is small,
+      PnetCDF now compromise the two by making a copy of write requests that is
+      less than 4KB. Users are warned that using immutable write buffer larger
+      than 4KB will still cause the fatal error in the PnetCDF default
+      configuration. The way to completely disable in-place byte swap is to
+      build PnetCDF with --disable-in-place-swap option at the configure time.
+      In this case, the internal memory allocation in PnetCDF will increase.
+
+  o Syntax changes
+    * In ncmpi_wait_all(), ncmpi_wait(), and ncmpi_cancel(), the API's third
+      argument, array of requests IDs, is changed to INOUT. Upon successful
+      completion or cancellation of individual nonblocking requests, the
+      corresponding request IDs are set to NC_REQ_NULL.
+
+  o New run-time environment variables
+    * PNETCDF_VERBOSE_DEBUG_MODE environment variable can be used to print the
+      location in the source code where the error code is originated, no matter
+      the error is intended or not. This run-time environment variable only
+      takes effect when PnetCDF is configure with debug mode, i.e.
+      --enable-debug is used at the configure command line.  Set this variable
+      to 1 to enable. Set it to 0 or keep it unset disables this mode. Default
+      is 0, i.e. disabled.  Users are warned that enabling this mode may result
+      in a lot of debugging messages printed in stderr.
+
+  o New example programs
+    * examples/C/nonblocking_write_in_def.c shows an example of posting
+      nonblocking write requests in the define mode.
+    * examples/C/req_all.c shows an example of using NC_REQ_ALL to flush all
+      pending nonblocking requests without providing the requests IDs.
+
+  o New test program
+    * test/cdf_format/dim_cdf12.c tests defining maximal dimension size for
+      CDF-1 and CDF-2 file formats
+    * test/testcases/test_erange.c tests if the error code NC_ERANGE can be
+      correctly returned for two cases 1) get a NC_UBYTE value of 255 from a
+      netCDF file to a memory buffer of type signed char and 2) put a value
+      of -1 of signed char to a NC_UBYTE variable in a netCDF file
+    * test/testcases/check_type.c tests if the error codes can be correctly
+      returned when conflicted in-memory and extenal data types are used.
+    * test/testcases/put_parameter.f tests the use of immutable write buffer
+      (e.g. a buffer declared as PARAMETER). Note the buffer size must be
+      smaller than 4KB.
+    * test/nonblocking/i_varn_indef.c tests posting nonblocking requests in
+      define mode.
+    * test/nonblocking/req_all.c tests the use of NC_REQ_ALL for flushing
+      all pending nonblocking requests without providing the requests IDs.
+    * test/last_large_var.c tests the special case when there is no record
+      variable, the last fixed-size variable can be larger than 2GiB in size
+      if its starting file offset is less than 2GiB.
+    * test/testcases/buftype_free.c and test/testcases/buftype_freef.f test
+      the bug in r2160.
+    * testcases/add_var.c checks the starting file offsets of newly added
+      variables from re-entering the define mode.
+    * testcases/attrf.f checks NF_ERANGE is returned instead of coredump. This
+      is particularly for NAG Fortran compiler that may report "Arithmetics
+       exception".
+    * testcases/check_striping.c checks if the file striping unit and factor
+      returned from MPI-IO hints are consistent among processes.
+    * test/nonblocking/column_wise.c checks if PnetCDF detects interleaved
+      fileviews from multiple nonblocking requests and correctly breaks and
+      reconstructs the fileviews so the combined fileview is monotonic
+      non-decreasing in file offsets.
+
+  o New optimization
+    * Filling variables at ncmpi_enddef() is now done by aggregating all write
+      requests into one MPI collective write call. In v 1.6.1, this is done by
+      filling one variable at a time.
+
+  o New utility program
+    * ncoffsets reports the file offset information, including the starting and
+      ending file offsets, of variables stored in a netCDF file. ncoffsets is
+      compiled with gcc if gcc is presented on the build system. Additional
+      command-line options are: (-v) reports only for a selected list of
+      variables in interest, (-s) prints the variable sizes, (-g) outputs the
+      file space gap size from the end of previous variable, (-x) reports
+      whether there is a gap between any two adjacent fixed-size variables. See
+      the man page for descriptions of all command-line options and examples.
+
+  o Semantics updates
+    * All nonblocking APIs now take a NULL pointer for the request ID argument,
+      meaning users do not wish to keep track of the request ID. If NULL
+      request IDs are used, NC_REQ_ALL should be used when calling
+      ncmpi_wait_all/ncmpi_wait to commit all the pending nonblocking requests.
+      This feature relinquishes users from the responsibility of tracking the
+      IDs of pending requests.
+    * Using NC_REQ_ALL as the 2nd argument "num" in ncmpi_wait_all/ncmpi_wait
+      APIs will flush all the pending nonblocking requests. In this case, the
+      3rd and 4th arguments "array_of_requests" and "array_of_statuses" will be
+      ignored and thus these two arguments can be NULLs.
+    * Using NC_REQ_ALL in ncmpi_cancel() will cancel all the pending
+      nonblocking requests.
+    * Using NC_GET_REQ_ALL or NC_PUT_REQ_ALL in ncmpi_wait_all(), ncmpi_wait(),
+      and ncmpi_cancel() for all the pending get-only or put-only requests,
+      respectively.
+
+  o Other updates:
+    * Conform with netCDF on the maximal dimension size for CDF-2 file format
+      to be (2^32 - 4)
+    * NC_ERANGE checks have been removed from nc_test for text APIs and
+      variables that are defined as NC_CHAR type
+    * Add README.K-Computer build recipe for using Fujitsu MPI compilers on the
+      K computer at RIKEN in Japan
+    * Add README.INTEL build recipe for using Intel MPI compilers 4.x
+    * Build dependency rule is added for files configure and configure.in
+    * PnetCDF checks MPICC/MPICXX/MPIF77/MPIF90 instead of CC/CXX/F77/F90/FC.
+      If MPICC/MPICXX/MPIF77/MPIF90 are set, PnetCDF will ignore
+      CC/CXX/F77/F90/FC. If CC/CXX/F77/F90/FC is set instead of
+      MPICC/MPICXX/MPIF77/MPIF90, PnetCDF will now copy them to
+      MPICC/MPICXX/MPIF77/MPIF90.
+    * Enforce netCDF convention on error code priority: NC_ECHAR trumps
+      NC_EINVALCOORDS, NC_EEDGE, and NC_ESTRIDE.
+    * Return error code NC_EGLOBAL instead of NC_ENOTVAR for APIs where using
+      NC_GLOBAL as the variable ID argument is prohibited.
+    * All Fortran 77 test and example programs (files with .f and .F
+      extensions) have been revised to conform with 77 standard, and was tested
+      using pgf77.
+    * Now provides a pkg-config file
+      (http://www.freedesktop.org/wiki/Software/pkg-config/), making it
+      slightly easier to set the correct pnetcdf include and library paths.
+
+  o Bug fixes
+    * Fix the bus error of invalid address alignment when build with Fujitsu
+      compiler. See r2171 and r2180.
+    * Fix the bug for the special case when there is no record variable, the
+      last fixed-size variable can be larger than 2GiB in size if its starting
+      file offset is less than 2GiB. See r2166.
+    * Fix the nonblocking flexible APIs that fail to save (duplicate) the user
+      MPI derived data type that later is needed to unpack read data to the
+      user buffer (a call to MPI_Unpack). See r2160.
+    * Fix Fortran 77 constants nf_fill_uint and nf_fill_int64 (thanks Jim
+      Edwards) that pgf77-based MPI compiler does not like "_8" modifier.
+      See r2045 and r2051. The same issue for NAG Fortran compiler is also
+      resolved. See r2089 and r2093.
+    * In the example program examples/tutorial/pnetcdf-write-nb.c, the write
+      buffers used in two iput API calls should be different. See r2095.
+    * Fix the error reporting mechanism for NC_ERANGE, for when an arithmetic
+      overflow happens. Overflow checking is now performed before I/O.
+
+-------------------------------------
 version  1.6.1 (June 1, 2015)
 -------------------------------------
 
diff --git a/benchmarks/C/aggregation.c b/benchmarks/C/aggregation.c
index f5c8e20..276cdef 100644
--- a/benchmarks/C/aggregation.c
+++ b/benchmarks/C/aggregation.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: aggregation.c 2215 2015-12-08 04:58:04Z wkliao $ */
+/* $Id: aggregation.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -152,11 +152,11 @@ int benchmark_write(char       *filename,
 
     /* set PnetCDF I/O hints */
     MPI_Info_create(&info);
-    /* To disable the header and fixed-size variable alignments, set the
-       following hints.
+    /* disable the header extent alignments
     MPI_Info_set(info, "nc_header_align_size", "1");    size in bytes
-    MPI_Info_set(info, "nc_var_align_size",    "1");    size in bytes
     */
+    /* disable the fixed-size variable alignments */
+    MPI_Info_set(info, "nc_var_align_size", "1");
 
     /* initialize I/O buffer with random numbers */
     srand(rank);
diff --git a/benchmarks/FLASH-IO/checkpoint_ncmpi_parallel.F90 b/benchmarks/FLASH-IO/checkpoint_ncmpi_parallel.F90
index b602a3e..af7b1ad 100644
--- a/benchmarks/FLASH-IO/checkpoint_ncmpi_parallel.F90
+++ b/benchmarks/FLASH-IO/checkpoint_ncmpi_parallel.F90
@@ -332,14 +332,18 @@
       filename = trim(basenm) // 'ncmpi_chk_'//fnum_string//'.nc'
 
       ! set up MPI I/O hints for performance enhancement
+      file_info = MPI_INFO_NULL
       call MPI_Info_create(file_info, err)
 
-      ! use some ROMIO hints
-      call MPI_Info_set(file_info, 'romio_no_indep_rw', 'true', err)
+      ! set some ROMIO hints
+      ! call MPI_Info_set(file_info, 'romio_no_indep_rw', 'true', err)
+
+      ! disable file offset alignment for fix-sized variables
+      call MPI_Info_set(file_info, "nc_var_align_size", "1", err)
 
       cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
       err = nfmpi_create(MPI_COMM_WORLD, trim(filename), cmode, &
-                          file_info, ncid)
+                         file_info, ncid)
       if (err .NE. NF_NOERR) call check(err, "nfmpi_create")
 
       call MPI_Info_free(file_info, err)
@@ -540,7 +544,7 @@
 #endif
 
       if (use_nonblocking_io) then
-         ! create a derive data type for buffer unk
+         ! create an MPI derived data type for buffer unk
          gsizes(1) = nvar
          gsizes(2) = iu_bnd - il_bnd + 1
          gsizes(3) = ju_bnd - jl_bnd + 1
diff --git a/benchmarks/FLASH-IO/plotfile_ncmpi_parallel.F90 b/benchmarks/FLASH-IO/plotfile_ncmpi_parallel.F90
index 2b210d7..5feb6b5 100644
--- a/benchmarks/FLASH-IO/plotfile_ncmpi_parallel.F90
+++ b/benchmarks/FLASH-IO/plotfile_ncmpi_parallel.F90
@@ -371,14 +371,18 @@
       endif
 
       ! set up MPI I/O hints for performance enhancement
+      file_info = MPI_INFO_NULL
       call MPI_Info_create(file_info, err)
 
       ! use some ROMIO hints
-      call MPI_Info_set(file_info, 'romio_no_indep_rw', 'true', err)
+      ! call MPI_Info_set(file_info, 'romio_no_indep_rw', 'true', err)
+
+      ! disable file offset alignment for fix-sized variables
+      call MPI_Info_set(file_info, "nc_var_align_size", "1", err)
 
       cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
       err = nfmpi_create(MPI_COMM_WORLD, trim(filename), cmode, &
-                          file_info, ncid)
+                         file_info, ncid)
       if (err .NE. NF_NOERR) call check(err, "nfmpi_create")
 
       call MPI_Info_free(file_info, err)
diff --git a/benchmarks/Makefile.in b/benchmarks/Makefile.in
index 41e3bfd..5a14a2f 100644
--- a/benchmarks/Makefile.in
+++ b/benchmarks/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2219 2015-12-11 22:30:03Z wkliao $
+# $Id: Makefile.in 2318 2016-02-04 00:18:26Z wkliao $
 #
 # @configure_input@
 
@@ -14,8 +14,10 @@ include ../macros.make
 SUBDIRS = C
 
 ifeq (@has_fortran@, yes)
+ifeq (@mpi_mod@, yes)
 SUBDIRS += FLASH-IO
 endif
+endif
 
 PACKING_LIST = Makefile.in README
 
diff --git a/configure b/configure
index fd3fafb..8d78b89 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
 #! /bin/sh
-# From configure.in Id: configure.in 2304 2016-01-12 18:39:01Z wkliao .
+# From configure.in Id: configure.in 2341 2016-03-03 20:06:27Z wkliao .
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for parallel-netcdf 1.7.0.pre1.
+# Generated by GNU Autoconf 2.69 for parallel-netcdf 1.7.0.
 #
 # Report bugs to <parallel-netcdf at mcs.anl.gov>.
 #
@@ -581,8 +581,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='parallel-netcdf'
 PACKAGE_TARNAME='parallel-netcdf'
-PACKAGE_VERSION='1.7.0.pre1'
-PACKAGE_STRING='parallel-netcdf 1.7.0.pre1'
+PACKAGE_VERSION='1.7.0'
+PACKAGE_STRING='parallel-netcdf 1.7.0'
 PACKAGE_BUGREPORT='parallel-netcdf at mcs.anl.gov'
 PACKAGE_URL=''
 
@@ -703,6 +703,8 @@ FFREEFORMFLAG
 F77FLAGS
 FLIBS
 ac_ct_F77
+mpi_mod
+USE_MPIF_HEADER
 F90FLAGS
 FCLIBS
 host_os
@@ -1364,7 +1366,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures parallel-netcdf 1.7.0.pre1 to adapt to many kinds of systems.
+\`configure' configures parallel-netcdf 1.7.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1429,7 +1431,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of parallel-netcdf 1.7.0.pre1:";;
+     short | recursive ) echo "Configuration of parallel-netcdf 1.7.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1562,7 +1564,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-parallel-netcdf configure 1.7.0.pre1
+parallel-netcdf configure 1.7.0
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2459,7 +2461,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by parallel-netcdf $as_me 1.7.0.pre1, which was
+It was created by parallel-netcdf $as_me 1.7.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2851,7 +2853,7 @@ PNETCDF_VERSION_PRE=`echo ${PACKAGE_VERSION} | cut -d. -f4`
 
 PNETCDF_VERSION=${PACKAGE_VERSION}
 
-SVN_DATE="$LastChangedDate: 2016-01-12 12:39:01 -0600 (Tue, 12 Jan 2016) $"
+SVN_DATE="$LastChangedDate: 2016-03-03 14:06:27 -0600 (Thu, 03 Mar 2016) $"
 PNETCDF_RELEASE_DATE2=`echo $SVN_DATE | cut -d' ' -f2`
 PNETCDF_RELEASE_DATE=`echo $SVN_DATE | cut -d' ' -f6,7,8 | cut -d')' -f1`
 
@@ -6605,9 +6607,30 @@ ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if mpi.mod is available" >&5
+$as_echo_n "checking if mpi.mod is available... " >&6; }
    cat > conftest.$ac_ext <<_ACEOF
       program main
-      call MPI_Comm_rank
+        use mpi
+      end
+_ACEOF
+if ac_fn_fc_try_compile "$LINENO"; then :
+  mpi_mod=yes
+else
+  mpi_mod=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $mpi_mod" >&5
+$as_echo "$mpi_mod" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if MPIF90 is valid" >&5
+$as_echo_n "checking if MPIF90 is valid... " >&6; }
+   if test "x${mpi_mod}" = xyes ; then
+      cat > conftest.$ac_ext <<_ACEOF
+      program main
+        use mpi
+        integer err, rank
+        call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
       end
 _ACEOF
 if ac_fn_fc_try_compile "$LINENO"; then :
@@ -6617,49 +6640,64 @@ else
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if mpi.mod is valid" >&5
-$as_echo_n "checking if mpi.mod is valid... " >&6; }
-   cat > conftest.$ac_ext <<_ACEOF
+   else
+            cat > conftest.$ac_ext <<_ACEOF
       program main
-        use mpi
+        include "mpif.h"
+        integer err, rank
+        call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
       end
 _ACEOF
 if ac_fn_fc_try_compile "$LINENO"; then :
-  valid_mpi_mod=yes
+  valid_mpif90=yes
 else
-  valid_mpi_mod=no
+  valid_mpif90=no
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $valid_mpi_mod" >&5
-$as_echo "$valid_mpi_mod" >&6; }
+   fi
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $valid_mpif90" >&5
+$as_echo "$valid_mpif90" >&6; }
    ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-   if test "x${valid_mpif90}" = xno && test "x${enable_fortran}" = xyes ; then
-      as_fn_error $? "
+   if test "x${valid_mpif90}" = xno ; then
+      if test "x${enable_fortran}" = xyes ; then
+         as_fn_error $? "
+            ------------------------------------------------------------
+              Invalid MPI Fortran 90 compiler specified: \"${MPIF90}\"
+              A working MPI compiler is required. Please specify the
+              location of one either with the MPIF90 environment
+              variable or the --with-mpi configure flag.
+            ------------------------------------------------------------" "$LINENO" 5
+      fi
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
          ------------------------------------------------------------
-           Invalid MPI Fortran 90 compiler specified: \"${MPIF90}\"
-           A working MPI compiler is required. Please specify the
-           location of one either with the MPIF90 environment
-           variable or the --with-mpi configure flag.
-         ------------------------------------------------------------" "$LINENO" 5
-   fi
-   if test "x${valid_mpi_mod}" = xno && test "x${enable_fortran}" = xyes ; then
-      as_fn_error $? "
+           Invalid MPI Fortran 90 compiler: \"${MPIF90}\"
+           Fortran feature is disabled
+         ------------------------------------------------------------" >&5
+$as_echo "$as_me: WARNING:
          ------------------------------------------------------------
-           Invalid MPI Fortran module. The mpi.mod file in the include path
-           may not be generated by the same Fortran compiler used to build
-           \"${MPIF90}\". Please make sure the same Fortran compiler is used.
-         ------------------------------------------------------------" "$LINENO" 5
+           Invalid MPI Fortran 90 compiler: \"${MPIF90}\"
+           Fortran feature is disabled
+         ------------------------------------------------------------" >&2;}
+      enable_fortran=no
+   else
+      if test "x${mpi_mod}" = xyes ; then
+         USE_MPIF_HEADER="use mpi, only: MPI_OFFSET_KIND"
+      else
+         USE_MPIF_HEADER="include \"mpif.h\""
+      fi
+
+
    fi
 fi
 
 F77_SUPPORT_FREEFORM=no
-if test "x${MPIF77}" != x ; then
+if test "x${enable_fortran}" != xno && test "x${MPIF77}" != xno ; then
    F77=${MPIF77}
    ac_ext=f
 ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
@@ -7294,9 +7332,13 @@ ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
 ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_f77_compiler_gnu
 
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if MPIF77 is valid" >&5
+$as_echo_n "checking if MPIF77 is valid... " >&6; }
    cat > conftest.$ac_ext <<_ACEOF
       program main
-      call MPI_Comm_rank
+        include "mpif.h"
+        integer comm
+        comm = MPI_COMM_WORLD
       end
 _ACEOF
 if ac_fn_f77_try_compile "$LINENO"; then :
@@ -7306,20 +7348,35 @@ else
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $valid_mpif77" >&5
+$as_echo "$valid_mpif77" >&6; }
    ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-   if test "x${valid_mpif77}" = xno && test "x${enable_fortran}" = xyes ; then
-      as_fn_error $? "
+   if test "x${valid_mpif77}" = xno ; then
+      if test "x${enable_fortran}" = xyes ; then
+         as_fn_error $? "
+            ------------------------------------------------------------
+              Invalid MPI Fortran 77 compiler specified: \"${MPIF77}\"
+              A working MPI compiler is required. Please specify the
+              location of one either with the MPIF77 environment
+              variable or the --with-mpi configure flag
+            ------------------------------------------------------------" "$LINENO" 5
+      fi
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
          ------------------------------------------------------------
-           Invalid MPI Fortran 77 compiler specified: \"${MPIF77}\"
-           A working MPI compiler is required. Please specify the
-           location of one either with the MPIF77 environment
-           variable or the --with-mpi configure flag
-         ------------------------------------------------------------" "$LINENO" 5
+           MPI Fortran header file mpif.h is not valid:
+           Fortran feature is disabled
+         ------------------------------------------------------------" >&5
+$as_echo "$as_me: WARNING:
+         ------------------------------------------------------------
+           MPI Fortran header file mpif.h is not valid:
+           Fortran feature is disabled
+         ------------------------------------------------------------" >&2;}
+      enable_fortran=no
    fi
 fi
 
@@ -9890,14 +9947,14 @@ fi
 
 
 if test "$ac_cv_sizeof_MPI_Offset" -ne "$ac_cv_sizeof_MPI_Aint"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MPI_Offset and MPI_Aint have different sizes: non-blocking APIs now behave like blocking ones" >&5
-$as_echo "$as_me: WARNING: MPI_Offset and MPI_Aint have different sizes: non-blocking APIs now behave like blocking ones" >&2;}
-   enable_nonblocking=no
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MPI_Offset and MPI_Aint are detected of different sizes: the request aggregation in non-blocking APIs is thus disabled" >&5
+$as_echo "$as_me: WARNING: MPI_Offset and MPI_Aint are detected of different sizes: the request aggregation in non-blocking APIs is thus disabled" >&2;}
+   enable_aggregation=no
 else
 
-$as_echo "#define ENABLE_NONBLOCKING /**/" >>confdefs.h
+$as_echo "#define ENABLE_REQ_AGGREGATION /**/" >>confdefs.h
 
-   enable_nonblocking=yes
+   enable_aggregation=yes
 fi
 
 # check for MPI-2 only functions
@@ -13722,7 +13779,7 @@ fi
 
 ac_config_headers="$ac_config_headers src/libf/nfconfig_inc"
 
-ac_config_files="$ac_config_files macros.make Makefile src/Makefile src/lib/Makefile src/lib/pnetcdf.h src/utils/Makefile src/utils/ncmpidump/Makefile src/utils/ncmpidiff/Makefile src/utils/ncmpigen/Makefile src/utils/ncmpivalid/Makefile src/utils/pnetcdf_version/Makefile src/utils/ncoffsets/Makefile test/Makefile test/common/Makefile test/nc_test/Makefile test/C/Makefile test/fandc/Makefile test/testcases/Makefile test/nonblocking/Makefile test/header/Makefile test/cdf_format/Makefile t [...]
+ac_config_files="$ac_config_files macros.make Makefile src/Makefile src/lib/Makefile src/lib/pnetcdf.h src/lib/pnetcdf.pc src/utils/Makefile src/utils/ncmpidump/Makefile src/utils/ncmpidiff/Makefile src/utils/ncmpigen/Makefile src/utils/ncmpivalid/Makefile src/utils/pnetcdf_version/Makefile src/utils/ncoffsets/Makefile test/Makefile test/common/Makefile test/nc_test/Makefile test/C/Makefile test/fandc/Makefile test/testcases/Makefile test/nonblocking/Makefile test/header/Makefile test/cd [...]
 
 
 # The following dependency is for configure.in and configure
@@ -14243,7 +14300,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by parallel-netcdf $as_me 1.7.0.pre1, which was
+This file was extended by parallel-netcdf $as_me 1.7.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14305,7 +14362,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-parallel-netcdf config.status 1.7.0.pre1
+parallel-netcdf config.status 1.7.0
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -14434,6 +14491,7 @@ do
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "src/lib/Makefile") CONFIG_FILES="$CONFIG_FILES src/lib/Makefile" ;;
     "src/lib/pnetcdf.h") CONFIG_FILES="$CONFIG_FILES src/lib/pnetcdf.h" ;;
+    "src/lib/pnetcdf.pc") CONFIG_FILES="$CONFIG_FILES src/lib/pnetcdf.pc" ;;
     "src/utils/Makefile") CONFIG_FILES="$CONFIG_FILES src/utils/Makefile" ;;
     "src/utils/ncmpidump/Makefile") CONFIG_FILES="$CONFIG_FILES src/utils/ncmpidump/Makefile" ;;
     "src/utils/ncmpidiff/Makefile") CONFIG_FILES="$CONFIG_FILES src/utils/ncmpidiff/Makefile" ;;
@@ -14466,6 +14524,7 @@ do
     "examples/F77/Makefile") CONFIG_FILES="$CONFIG_FILES examples/F77/Makefile" ;;
     "examples/F90/Makefile") CONFIG_FILES="$CONFIG_FILES examples/F90/Makefile" ;;
     "src/libf90/Makefile") CONFIG_FILES="$CONFIG_FILES src/libf90/Makefile" ;;
+    "src/libf90/pnetcdf.f90") CONFIG_FILES="$CONFIG_FILES src/libf90/pnetcdf.f90" ;;
     "src/libf90/api.f90") CONFIG_FILES="$CONFIG_FILES src/libf90/api.f90" ;;
     "src/libf90/nfmpi_constants.f90") CONFIG_FILES="$CONFIG_FILES src/libf90/nfmpi_constants.f90" ;;
     "src/libf/Makefile") CONFIG_FILES="$CONFIG_FILES src/libf/Makefile" ;;
@@ -15067,7 +15126,7 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
-echo "--------------------------------------------------------------------"
+echo "------------------------------------------------------------------------------"
 
 if test "x${enable_mpi_io_test}" = xno ; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
@@ -15087,27 +15146,27 @@ echo \
 "
    ${PACKAGE_NAME} Version ${PACKAGE_VERSION}
 
-   Features:  Support for large files (> 4 GB) - ${msg_large_files}
-              Build C++ APIs                   - ${has_mpicxx}
-              Build Fortran APIs               - ${enable_fortran}
-              Build nonblocking APIs           - ${enable_nonblocking}
-              Build CDF-5 support              - ${enable_cdf5}
-              Build subfiling support          - ${enable_subfiling}"
+   Features:  Support for large files (> 4 GB)                  - ${msg_large_files}
+              Build C++ APIs                                    - ${has_mpicxx}
+              Build Fortran APIs                                - ${enable_fortran}
+              Enable request aggregation in nonblocking APIs    - ${enable_aggregation}
+              Build CDF-5 support                               - ${enable_cdf5}
+              Build subfiling support                           - ${enable_subfiling}"
 if test "x${ac_cv_c_bigendian}" = xno  && (test "x${in_place_swap}" = xno) ; then
    echo "\
-              Memory in-place byte swap        - disabled"
+              Memory in-place byte swap                         - disabled"
 fi
 if test "x${large_file_test}" = xyes; then
    echo "\
-              Testing large file/variable I/O  - enabled"
+              Testing large file/variable I/O                   - enabled"
 fi
 if test "x${debug}" = xyes; then
    echo "\
-              PnetCDF internal debug mode      - enabled"
+              PnetCDF internal debug mode                       - enabled"
 fi
 if test "x${enable_fortran}" = xyes && (test "x${F77_SUPPORT_FREEFORM}" = xno) ; then
    echo "\
-              Support free form in Fortran 77  - no"
+              Support free form in Fortran 77                   - no"
 fi
 
 echo "\
@@ -15161,5 +15220,5 @@ echo "\
            testing          - test PnetCDF build for sequential run
            ptest            - test PnetCDF build for parallel run
            install          - install PnetCDF
----------------------------------------------------------------------"
+------------------------------------------------------------------------------"
 
diff --git a/configure.in b/configure.in
index 3a5dff8..ee6984d 100644
--- a/configure.in
+++ b/configure.in
@@ -1,10 +1,10 @@
-AC_REVISION($Id: configure.in 2304 2016-01-12 18:39:01Z wkliao $)dnl
+AC_REVISION($Id: configure.in 2341 2016-03-03 20:06:27Z wkliao $)dnl
 dnl -*- Mode: shell-script-mode; -*-
 dnl Process this file with GNU autoconf(1) to produce a configure script.
 dnl
 
 AC_PREREQ([2.59])
-AC_INIT([parallel-netcdf],[1.7.0.pre1],[parallel-netcdf at mcs.anl.gov])
+AC_INIT([parallel-netcdf],[1.7.0],[parallel-netcdf at mcs.anl.gov])
 
 dnl ncconfig.h.in will be created by autoreconf (autoheader)
 AC_CONFIG_HEADERS([src/lib/ncconfig.h])
@@ -26,7 +26,7 @@ PNETCDF_VERSION=${PACKAGE_VERSION}
 dnl Do not change the following line, It is set by SVN automatically.
 dnl It defines PNETCDF_RELEASE_DATE, a string that will be used in
 dnl ncmpi_inq_libvers() to generate release date
-SVN_DATE="$LastChangedDate: 2016-01-12 12:39:01 -0600 (Tue, 12 Jan 2016) $"
+SVN_DATE="$LastChangedDate: 2016-03-03 14:06:27 -0600 (Thu, 03 Mar 2016) $"
 PNETCDF_RELEASE_DATE2=`echo $SVN_DATE | cut -d' ' -f2`
 PNETCDF_RELEASE_DATE=`echo $SVN_DATE | cut -d' ' -f6,7,8 | cut -d')' -f1`
 
@@ -378,37 +378,58 @@ if test "x${MPIF90}" != x ; then
    AC_SUBST(F90FLAGS)
 
    AC_LANG_PUSH([Fortran])
-   AC_COMPILE_IFELSE([AC_LANG_CALL([],[MPI_Comm_rank])],
-                     [valid_mpif90=yes],[valid_mpif90=no]
-   )
-   AC_MSG_CHECKING([if mpi.mod is valid])
+   AC_MSG_CHECKING([if mpi.mod is available])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[        use mpi]])],
-                     [valid_mpi_mod=yes], [valid_mpi_mod=no]
+                     [mpi_mod=yes], [mpi_mod=no]
    )
-   AC_MSG_RESULT($valid_mpi_mod)
-   AC_LANG_POP([Fortran])
-   if test "x${valid_mpif90}" = xno && test "x${enable_fortran}" = xyes ; then
-      AC_MSG_ERROR([
-         ------------------------------------------------------------
-           Invalid MPI Fortran 90 compiler specified: "${MPIF90}"
-           A working MPI compiler is required. Please specify the
-           location of one either with the MPIF90 environment
-           variable or the --with-mpi configure flag.
-         ------------------------------------------------------------])
+   AC_MSG_RESULT($mpi_mod)
+   AC_MSG_CHECKING([if MPIF90 is valid])
+   if test "x${mpi_mod}" = xyes ; then
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[        use mpi
+        integer err, rank
+        call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)]])],
+                           [valid_mpif90=yes],[valid_mpif90=no]
+      )
+   else
+      dnl mpi.mod is not available, check if can use mpif.h
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[        include "mpif.h"
+        integer err, rank
+        call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)]])],
+                           [valid_mpif90=yes],[valid_mpif90=no]
+      )
    fi
-   if test "x${valid_mpi_mod}" = xno && test "x${enable_fortran}" = xyes ; then
-      AC_MSG_ERROR([
+   AC_MSG_RESULT($valid_mpif90)
+   AC_LANG_POP([Fortran])
+   if test "x${valid_mpif90}" = xno ; then
+      if test "x${enable_fortran}" = xyes ; then
+         AC_MSG_ERROR([
+            ------------------------------------------------------------
+              Invalid MPI Fortran 90 compiler specified: "${MPIF90}"
+              A working MPI compiler is required. Please specify the
+              location of one either with the MPIF90 environment
+              variable or the --with-mpi configure flag.
+            ------------------------------------------------------------])
+      fi
+      AC_MSG_WARN([
          ------------------------------------------------------------
-           Invalid MPI Fortran module. The mpi.mod file in the include path
-           may not be generated by the same Fortran compiler used to build
-           "${MPIF90}". Please make sure the same Fortran compiler is used.
+           Invalid MPI Fortran 90 compiler: "${MPIF90}"
+           Fortran feature is disabled
          ------------------------------------------------------------])
+      enable_fortran=no
+   else
+      if test "x${mpi_mod}" = xyes ; then
+         USE_MPIF_HEADER="use mpi, only: MPI_OFFSET_KIND"
+      else
+         USE_MPIF_HEADER="include \"mpif.h\""
+      fi
+      AC_SUBST(USE_MPIF_HEADER)
+      AC_SUBST(mpi_mod)
    fi
 fi
 
 dnl Check if MPIF77 is a valid MPI compiler
 F77_SUPPORT_FREEFORM=no
-if test "x${MPIF77}" != x ; then
+if test "x${enable_fortran}" != xno && test "x${MPIF77}" != xno ; then
    F77=${MPIF77}
    AC_PROG_F77
    dnl FFLAGS is set in AC_PROG_F77
@@ -432,18 +453,30 @@ if test "x${MPIF77}" != x ; then
    FC=${FC_saved}
 
    AC_LANG_PUSH([Fortran 77])
-   AC_COMPILE_IFELSE([AC_LANG_CALL([],[MPI_Comm_rank])],
-                     [valid_mpif77=yes],[valid_mpif77=no]
+   AC_MSG_CHECKING([if MPIF77 is valid])
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[        include "mpif.h"
+        integer comm
+        comm = MPI_COMM_WORLD]])],
+                     [valid_mpif77=yes], [valid_mpif77=no]
    )
+   AC_MSG_RESULT($valid_mpif77)
    AC_LANG_POP([Fortran 77])
-   if test "x${valid_mpif77}" = xno && test "x${enable_fortran}" = xyes ; then
-      AC_MSG_ERROR([
+   if test "x${valid_mpif77}" = xno ; then
+      if test "x${enable_fortran}" = xyes ; then
+         AC_MSG_ERROR([
+            ------------------------------------------------------------
+              Invalid MPI Fortran 77 compiler specified: "${MPIF77}"
+              A working MPI compiler is required. Please specify the
+              location of one either with the MPIF77 environment
+              variable or the --with-mpi configure flag
+            ------------------------------------------------------------])
+      fi
+      AC_MSG_WARN([
          ------------------------------------------------------------
-           Invalid MPI Fortran 77 compiler specified: "${MPIF77}"
-           A working MPI compiler is required. Please specify the
-           location of one either with the MPIF77 environment
-           variable or the --with-mpi configure flag
+           MPI Fortran header file mpif.h is not valid:
+           Fortran feature is disabled
          ------------------------------------------------------------])
+      enable_fortran=no
    fi
 fi
 AC_SUBST(F77_SUPPORT_FREEFORM)
@@ -738,11 +771,11 @@ dnl the nonblocking routines build up lists of requests with MPI_Type_struct.
 dnl If MPI_Offset not the same size as MPI_Aint, the arrays passed around will
 dnl get mangled. 
 if test "$ac_cv_sizeof_MPI_Offset" -ne "$ac_cv_sizeof_MPI_Aint"; then
-   AC_MSG_WARN(MPI_Offset and MPI_Aint have different sizes: non-blocking APIs now behave like blocking ones)
-   enable_nonblocking=no
+   AC_MSG_WARN(MPI_Offset and MPI_Aint are detected of different sizes: the request aggregation in non-blocking APIs is thus disabled)
+   enable_aggregation=no
 else
-   AC_DEFINE(ENABLE_NONBLOCKING,,[Define if able to support nonblocking routines])
-   enable_nonblocking=yes
+   AC_DEFINE(ENABLE_REQ_AGGREGATION,,[Define if able to support request aggregation in nonblocking routines])
+   enable_aggregation=yes
 fi
 
 # check for MPI-2 only functions
@@ -1127,6 +1160,7 @@ AC_CONFIG_FILES(macros.make \
                 src/Makefile \
                 src/lib/Makefile \
                 src/lib/pnetcdf.h \
+                src/lib/pnetcdf.pc \
                 src/utils/Makefile \
                 src/utils/ncmpidump/Makefile \
                 src/utils/ncmpidiff/Makefile \
@@ -1159,6 +1193,7 @@ AC_CONFIG_FILES(macros.make \
                 examples/F77/Makefile \
                 examples/F90/Makefile \
                 src/libf90/Makefile \
+                src/libf90/pnetcdf.f90 \
                 src/libf90/api.f90 \
                 src/libf90/nfmpi_constants.f90 \
                 src/libf/Makefile \
@@ -1174,7 +1209,7 @@ AC_CONFIG_FILES(macros.make \
 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
 
 AC_OUTPUT
-echo "--------------------------------------------------------------------"
+echo "------------------------------------------------------------------------------"
 
 if test "x${enable_mpi_io_test}" = xno ; then
     AC_MSG_WARN([
@@ -1191,27 +1226,27 @@ echo \
 "
    ${PACKAGE_NAME} Version ${PACKAGE_VERSION}
 
-   Features:  Support for large files (> 4 GB) - ${msg_large_files}
-              Build C++ APIs                   - ${has_mpicxx}
-              Build Fortran APIs               - ${enable_fortran}
-              Build nonblocking APIs           - ${enable_nonblocking}
-              Build CDF-5 support              - ${enable_cdf5}
-              Build subfiling support          - ${enable_subfiling}"
+   Features:  Support for large files (> 4 GB)                  - ${msg_large_files}
+              Build C++ APIs                                    - ${has_mpicxx}
+              Build Fortran APIs                                - ${enable_fortran}
+              Enable request aggregation in nonblocking APIs    - ${enable_aggregation}
+              Build CDF-5 support                               - ${enable_cdf5}
+              Build subfiling support                           - ${enable_subfiling}"
 if test "x${ac_cv_c_bigendian}" = xno  && (test "x${in_place_swap}" = xno) ; then
    echo "\
-              Memory in-place byte swap        - disabled"
+              Memory in-place byte swap                         - disabled"
 fi
 if test "x${large_file_test}" = xyes; then
    echo "\
-              Testing large file/variable I/O  - enabled"
+              Testing large file/variable I/O                   - enabled"
 fi
 if test "x${debug}" = xyes; then
    echo "\
-              PnetCDF internal debug mode      - enabled"
+              PnetCDF internal debug mode                       - enabled"
 fi
 if test "x${enable_fortran}" = xyes && (test "x${F77_SUPPORT_FREEFORM}" = xno) ; then
    echo "\
-              Support free form in Fortran 77  - no"
+              Support free form in Fortran 77                   - no"
 fi
 
 echo "\
@@ -1265,5 +1300,5 @@ echo "\
            testing          - test PnetCDF build for sequential run
            ptest            - test PnetCDF build for parallel run
            install          - install PnetCDF
----------------------------------------------------------------------"
+------------------------------------------------------------------------------"
 
diff --git a/examples/C/block_cyclic.c b/examples/C/block_cyclic.c
index c2d056f..b5bd348 100644
--- a/examples/C/block_cyclic.c
+++ b/examples/C/block_cyclic.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: block_cyclic.c 2245 2015-12-20 18:39:52Z wkliao $ */
+/* $Id: block_cyclic.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * This example, generalized from column_wise.c, makes a number of nonblocking
@@ -101,6 +101,7 @@ int main(int argc, char** argv) {
     int ncid, cmode, varid, dimid[2], *reqs, *sts, **buf;
     MPI_Offset myNX, G_NX, myOff, block_start, block_len;
     MPI_Offset start[2], count[2];
+    MPI_Info info;
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -120,11 +121,18 @@ int main(int argc, char** argv) {
     argv += optind;
     if (argc == 1) filename = argv[0]; /* optional argument */
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     /* create a new file for writing ----------------------------------------*/
     cmode = NC_CLOBBER | NC_64BIT_DATA;
-    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, MPI_INFO_NULL, &ncid);
+    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, info, &ncid);
     ERR
 
+    MPI_Info_free(&info);
+
     /* the global array is NY * (NX * nprocs) */
     G_NX  = NX * nprocs;
     myOff = NX * rank;
diff --git a/examples/C/bput_varn_uint.c b/examples/C/bput_varn_uint.c
index 78e699e..c12a81a 100644
--- a/examples/C/bput_varn_uint.c
+++ b/examples/C/bput_varn_uint.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: bput_varn_uint.c 2245 2015-12-20 18:39:52Z wkliao $ */
+/* $Id: bput_varn_uint.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * This example tests nonblocking buffered write varn APIs, including
@@ -159,6 +159,7 @@ int main(int argc, char** argv)
     unsigned int *buffer[4];
     int num_segs[4], req_lens[4];
     MPI_Offset ***starts, ***counts;
+    MPI_Info info;
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -182,11 +183,18 @@ int main(int argc, char** argv)
     if (nprocs != 4 && rank == 0 && verbose)
         printf("Warning: %s is intended to run on 4 processes\n",exec);
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     /* create a new file for writing ----------------------------------------*/
     cmode = NC_CLOBBER | NC_64BIT_DATA;
-    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, MPI_INFO_NULL, &ncid);
+    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, info, &ncid);
     ERR
 
+    MPI_Info_free(&info);
+
     /* create a global array of size NY * NX */
     err = ncmpi_def_dim(ncid, "Y", NY, &dimid[0]); ERR
     err = ncmpi_def_dim(ncid, "X", NX, &dimid[1]); ERR
diff --git a/examples/C/column_wise.c b/examples/C/column_wise.c
index 9deeb27..b6dd4ba 100644
--- a/examples/C/column_wise.c
+++ b/examples/C/column_wise.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: column_wise.c 2245 2015-12-20 18:39:52Z wkliao $ */
+/* $Id: column_wise.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * This example makes a number of nonblocking API calls, each writes a single
@@ -88,6 +88,7 @@ int main(int argc, char** argv)
     int i, j, verbose=1, rank, nprocs, err, myNX, G_NX, myOff, num_reqs;
     int ncid, cmode, varid, dimid[2], *reqs, *sts, **buf;
     MPI_Offset start[2], count[2];
+    MPI_Info info;
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -107,10 +108,17 @@ int main(int argc, char** argv)
     argv += optind;
     if (argc == 1) filename = argv[0]; /* optional argument */
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     cmode = NC_CLOBBER | NC_64BIT_DATA;
-    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, MPI_INFO_NULL, &ncid);
+    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, info, &ncid);
     ERR
 
+    MPI_Info_free(&info);
+
     /* the global array is NY * (NX * nprocs) */
     G_NX  = NX * nprocs;
     myOff = NX * rank;
diff --git a/examples/C/i_varn_int64.c b/examples/C/i_varn_int64.c
index 1d7c1d8..5f735b6 100644
--- a/examples/C/i_varn_int64.c
+++ b/examples/C/i_varn_int64.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: i_varn_int64.c 2245 2015-12-20 18:39:52Z wkliao $ */
+/* $Id: i_varn_int64.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * This example tests nonblocking varn APIs, including
@@ -160,6 +160,7 @@ int main(int argc, char** argv)
     long long *buffer[4];
     int num_segs[4], req_lens[4];
     MPI_Offset ***starts, ***counts;
+    MPI_Info info;
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -183,11 +184,18 @@ int main(int argc, char** argv)
     if (nprocs != 4 && rank == 0 && verbose)
         printf("Warning: %s is intended to run on 4 processes\n",exec);
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     /* create a new file for writing ----------------------------------------*/
     cmode = NC_CLOBBER | NC_64BIT_DATA;
-    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, MPI_INFO_NULL, &ncid);
+    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, info, &ncid);
     ERR
 
+    MPI_Info_free(&info);
+
     /* create a global array of size NY * NX */
     err = ncmpi_def_dim(ncid, "Y", NY, &dimid[0]); ERR
     err = ncmpi_def_dim(ncid, "X", NX, &dimid[1]); ERR
diff --git a/examples/C/mput.c b/examples/C/mput.c
index fe0ad16..611d754 100644
--- a/examples/C/mput.c
+++ b/examples/C/mput.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: mput.c 1669 2014-05-24 18:28:16Z wkliao $ */
+/* $Id: mput.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * This example shows how to use a single call of ncmpi_mput_vara_all() to
@@ -75,6 +75,7 @@ int main(int argc, char** argv)
     int ncid, cmode, varid, dimid[2], num_reqs, *buffer, **bufs, *nvarids;
     MPI_Offset w_len, **starts, **counts, *bufcounts;
     MPI_Datatype *datatypes;
+    MPI_Info info;
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -97,11 +98,18 @@ int main(int argc, char** argv)
     if (nprocs != 4 && rank == 0 && verbose)
         printf("Warning: this program is intended to run on 4 processes\n");
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     /* create a new file for writing ----------------------------------------*/
     cmode = NC_CLOBBER | NC_64BIT_DATA;
-    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, MPI_INFO_NULL, &ncid);
+    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, info, &ncid);
     ERR
 
+    MPI_Info_free(&info);
+
     /* create a global array of size NY * NX */
     err = ncmpi_def_dim(ncid, "Y", NY, &dimid[0]);
     ERR
diff --git a/examples/C/nonblocking_write.c b/examples/C/nonblocking_write.c
index cf7bda2..f2e46a3 100644
--- a/examples/C/nonblocking_write.c
+++ b/examples/C/nonblocking_write.c
@@ -4,10 +4,9 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: nonblocking_write.c 2245 2015-12-20 18:39:52Z wkliao $ */
+/* $Id: nonblocking_write.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
-/* wkliao:
- *    This example is similar to collective_write.c but using nonblocking APIs.
+/*    This example is similar to collective_write.c but using nonblocking APIs.
  *    It creates a netcdf file in CD-5 format and writes a number of
  *    3D integer non-record variables. The measured write bandwidth is reported
  *    at the end. Usage: (for example)
@@ -97,7 +96,7 @@ int main(int argc, char **argv)
     int ncid, dimids[NDIMS], varids[NUM_VARS], req[NUM_VARS], st[NUM_VARS];
     MPI_Offset starts[NDIMS], counts[NDIMS], write_size, sum_write_size;
     MPI_Offset bbufsize;
-    MPI_Info info_used;
+    MPI_Info info, info_used;
 
     MPI_Init(&argc,&argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -144,15 +143,22 @@ int main(int argc, char **argv)
     MPI_Barrier(MPI_COMM_WORLD);
     write_timing = MPI_Wtime();
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     /* create the file */
     err = ncmpi_create(MPI_COMM_WORLD, filename, NC_CLOBBER|NC_64BIT_DATA,
-                       MPI_INFO_NULL, &ncid);
+                       info, &ncid);
     if (err != NC_NOERR) {
         printf("Error: ncmpi_create() file %s (%s)\n",filename,ncmpi_strerror(err));
         MPI_Abort(MPI_COMM_WORLD, -1);
         exit(1);
     }
 
+    MPI_Info_free(&info);
+
     /* define dimensions */
     for (i=0; i<NDIMS; i++) {
         sprintf(str, "%c", 'x'+i);
diff --git a/examples/C/nonblocking_write_in_def.c b/examples/C/nonblocking_write_in_def.c
index 6c66101..cddd953 100644
--- a/examples/C/nonblocking_write_in_def.c
+++ b/examples/C/nonblocking_write_in_def.c
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
     int ncid, dimids[NDIMS], varids[NUM_VARS];
     MPI_Offset start[NDIMS], count[NDIMS], write_size, sum_write_size;
     MPI_Offset bbufsize;
-    MPI_Info info_used;
+    MPI_Info info, info_used;
     MPI_Comm comm=MPI_COMM_WORLD;
 
     MPI_Init(&argc,&argv);
@@ -145,15 +145,21 @@ int main(int argc, char **argv)
     MPI_Barrier(comm);
     write_timing = MPI_Wtime();
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     /* create the file */
-    err = ncmpi_create(comm, filename, NC_CLOBBER|NC_64BIT_DATA, MPI_INFO_NULL,
-                       &ncid);
+    err = ncmpi_create(comm, filename, NC_CLOBBER|NC_64BIT_DATA, info, &ncid);
     if (err != NC_NOERR) {
         printf("Error: ncmpi_create() file %s (%s)\n",filename,ncmpi_strerror(err));
         MPI_Abort(comm, -1);
         exit(1);
     }
 
+    MPI_Info_free(&info);
+
     /* define dimensions */
     for (i=0; i<NDIMS; i++) {
         sprintf(str, "%c", 'x'+i);
diff --git a/examples/C/req_all.c b/examples/C/req_all.c
index 5704b0b..47b55c4 100644
--- a/examples/C/req_all.c
+++ b/examples/C/req_all.c
@@ -80,6 +80,7 @@ int main(int argc, char** argv)
     int i, j, verbose=1, rank, nprocs, err, myNX, G_NX, myOff;
     int ncid, cmode, varid, dimid[2], **buf;
     MPI_Offset start[2], count[2];
+    MPI_Info info;
 
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -99,10 +100,17 @@ int main(int argc, char** argv)
     argv += optind;
     if (argc == 1) filename = argv[0]; /* optional argument */
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     cmode = NC_CLOBBER;
-    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, MPI_INFO_NULL, &ncid);
+    err = ncmpi_create(MPI_COMM_WORLD, filename, cmode, info, &ncid);
     ERR
 
+    MPI_Info_free(&info);
+
     /* the global array is NY * (NX * nprocs) */
     G_NX  = NX * nprocs;
     myOff = NX * rank;
diff --git a/examples/C/transpose.c b/examples/C/transpose.c
index 6228ca0..ee9e1f2 100644
--- a/examples/C/transpose.c
+++ b/examples/C/transpose.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: transpose.c 1744 2014-08-23 19:19:58Z wkliao $ */
+/* $Id: transpose.c 2325 2016-02-28 07:49:13Z wkliao $ */
 
 /*
  *    This example shows how to use varm API to write six 3D integer array
@@ -67,6 +67,7 @@ int main(int argc, char **argv)
     int XYZ_id, XZY_id, YZX_id, YXZ_id, ZYX_id, ZXY_id;
     MPI_Offset gsizes[NDIMS], starts[NDIMS], counts[NDIMS], imap[NDIMS];
     MPI_Offset startsT[NDIMS], countsT[NDIMS];
+    MPI_Info info;
 
     MPI_Init(&argc,&argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -130,15 +131,22 @@ int main(int argc, char **argv)
                                        + (starts[1]+j)*gsizes[2]
                                        + (starts[2]+i);
 
+    /* set an MPI-IO hint to disable file offset alignment for fix-sized
+     * variables */
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_var_align_size", "1");
+
     /* create the file */
     err = ncmpi_create(MPI_COMM_WORLD, filename, NC_CLOBBER|NC_64BIT_DATA,
-                       MPI_INFO_NULL, &ncid);
+                       info, &ncid);
     if (err != NC_NOERR) {
         printf("Error: ncmpi_create() file %s (%s)\n",filename,ncmpi_strerror(err));
         MPI_Abort(MPI_COMM_WORLD, -1);
         exit(1);
     }
 
+    MPI_Info_free(&info);
+
     /* define dimensions */
     for (i=0; i<NDIMS; i++) {
         sprintf(str, "%c", 'Z'-i);
diff --git a/examples/F77/block_cyclic.f b/examples/F77/block_cyclic.f
index 66d3843..b912bc5 100644
--- a/examples/F77/block_cyclic.f
+++ b/examples/F77/block_cyclic.f
@@ -2,7 +2,7 @@
 !  Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: block_cyclic.f 2245 2015-12-20 18:39:52Z wkliao $
+! $Id: block_cyclic.f 2325 2016-02-28 07:49:13Z wkliao $
 
 
 ! This example, generalized from column_wise.f, makes a number of nonblocking
@@ -76,7 +76,7 @@
           integer*8 start(2), count(2)
           integer*8 malloc_size, sum_size
           logical verbose
-          integer dummy
+          integer dummy, info
 
           call MPI_Init(err)
           call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
@@ -96,12 +96,19 @@
           call MPI_Bcast(filename, 256, MPI_CHARACTER, 0,
      +                   MPI_COMM_WORLD, err)
 
+          ! set an MPI-IO hint to disable file offset alignment for fix-sized
+          ! variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
           err = nfmpi_create(MPI_COMM_WORLD, filename, cmode,
-     +                       MPI_INFO_NULL, ncid)
+     +                       info, ncid)
           call check(err, 'In nfmpi_create: ')
 
+          call MPI_Info_free(info, err)
+
           ! the global array is NX * (NY * nprocs) */
           G_NY  = NY * nprocs
           myOff = NY * rank
diff --git a/examples/F77/bput_varn_int8.f b/examples/F77/bput_varn_int8.f
index 6cb2a42..114b12c 100644
--- a/examples/F77/bput_varn_int8.f
+++ b/examples/F77/bput_varn_int8.f
@@ -2,7 +2,7 @@
 !   Copyright (C) 2014, Northwestern University
 !   See COPYRIGHT notice in top-level directory.
 !
-! $Id: bput_varn_int8.f 2224 2015-12-16 06:10:36Z wkliao $
+! $Id: bput_varn_int8.f 2325 2016-02-28 07:49:13Z wkliao $
 
 ! This example tests nonblocking varn API: nfmpi_bput_varn_int8()
 ! It writes a sequence of requests with arbitrary array indices and
@@ -113,7 +113,7 @@
           integer*8 req_len, bbufsize
           integer*8 buffer(NX*NY,4)
           logical verbose
-          integer dummy
+          integer dummy, info
 
           call MPI_Init(err)
           call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
@@ -138,10 +138,17 @@
      +        print*,'Warning: ',cmd,' is intended to run on ',
      +               '4 processes'
 
+          ! set an MPI-IO hint to disable file offset alignment for
+          ! fix-sized variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
+          call MPI_Info_free(info, err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
           err = nfmpi_create(MPI_COMM_WORLD, filename, cmode,
-     +                        MPI_INFO_NULL, ncid)
+     +                       info, ncid)
           call check(err, 'In nfmpi_create: ')
 
           ! define dimensions x and y
diff --git a/examples/F77/column_wise.f b/examples/F77/column_wise.f
index 613b5c7..ee32861 100644
--- a/examples/F77/column_wise.f
+++ b/examples/F77/column_wise.f
@@ -2,7 +2,7 @@
 !  Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: column_wise.f 2245 2015-12-20 18:39:52Z wkliao $
+! $Id: column_wise.f 2325 2016-02-28 07:49:13Z wkliao $
 
 ! This example makes a number of nonblocking API calls, each writes a single
 ! row of a 2D integer array. Each process writes NY rows and any two
@@ -78,7 +78,7 @@
           integer*8 start(2), count(2)
           integer*8 malloc_size, sum_size
           logical verbose
-          integer dummy
+          integer dummy, info
 
           call MPI_Init(err)
           call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
@@ -98,12 +98,19 @@
           call MPI_Bcast(filename, 256, MPI_CHARACTER, 0,
      +                   MPI_COMM_WORLD, err)
 
+          ! set an MPI-IO hint to disable file offset alignment for
+          ! fix-sized variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
           err = nfmpi_create(MPI_COMM_WORLD, filename, cmode,
      +                       MPI_INFO_NULL, ncid)
           call check(err, 'In nfmpi_create: ')
 
+          call MPI_Info_free(info, err)
+
           ! the global array is NX * (NY * nprocs) */
           G_NY  = NY * nprocs
           myOff = NY * rank
diff --git a/examples/F77/flexible_api.f b/examples/F77/flexible_api.f
index b82c0e3..55e1e97 100644
--- a/examples/F77/flexible_api.f
+++ b/examples/F77/flexible_api.f
@@ -2,7 +2,7 @@
 !   Copyright (C) 2013, Northwestern University
 !   See COPYRIGHT notice in top-level directory.
 !
-! $Id: flexible_api.f 2235 2015-12-18 03:38:49Z wkliao $
+! $Id: flexible_api.f 2325 2016-02-28 07:49:13Z wkliao $
 
 !
 ! This example shows how to use PnetCDF flexible API, nfmpi_put_vara_all()
@@ -134,7 +134,7 @@
           ! create file, truncate it if exists
           cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
           err = nfmpi_create(MPI_COMM_WORLD, filename, cmode,
-     +                        MPI_INFO_NULL, ncid)
+     +                       MPI_INFO_NULL, ncid)
           call check(err, 'In nfmpi_create: ')
 
           ! define dimensions x and y
diff --git a/examples/F77/i_varn_real.f b/examples/F77/i_varn_real.f
index bea1f0d..b659b9c 100644
--- a/examples/F77/i_varn_real.f
+++ b/examples/F77/i_varn_real.f
@@ -2,7 +2,7 @@
 !   Copyright (C) 2014, Northwestern University
 !   See COPYRIGHT notice in top-level directory.
 !
-! $Id: i_varn_real.f 2224 2015-12-16 06:10:36Z wkliao $
+! $Id: i_varn_real.f 2325 2016-02-28 07:49:13Z wkliao $
 
 ! This example tests nonblocking varn API, nfmpi_iput_varn_real()
 ! It writes a sequence of requests with arbitrary array indices and
@@ -113,7 +113,7 @@
           integer*8 malloc_size, sum_size, two
           real buffer(NX*NY,4)
           logical verbose
-          integer dummy
+          integer dummy, info
 
           call MPI_Init(err)
           call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
@@ -138,12 +138,19 @@
      +        print*,'Warning: ',cmd,' is intended to run on ',
      +               '4 processes'
 
+          ! set an MPI-IO hint to disable file offset alignment for
+          ! fix-sized variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
           err = nfmpi_create(MPI_COMM_WORLD, filename, cmode,
-     +                        MPI_INFO_NULL, ncid)
+     +                       info, ncid)
           call check(err, 'In nfmpi_create: ')
 
+          call MPI_Info_free(info, err)
+
           ! define dimensions x and y
           err = nfmpi_def_dim(ncid, "Y", NY, dimid(2))
           call check(err, 'In nfmpi_def_dim Y: ')
diff --git a/examples/F77/nonblocking_write.f b/examples/F77/nonblocking_write.f
index 0a1923e..47af878 100644
--- a/examples/F77/nonblocking_write.f
+++ b/examples/F77/nonblocking_write.f
@@ -2,7 +2,7 @@
 !  Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: nonblocking_write.f 2245 2015-12-20 18:39:52Z wkliao $
+! $Id: nonblocking_write.f 2325 2016-02-28 07:49:13Z wkliao $
 
 !    This example is the Fortran 77 version of nonblocking_write.c
 !    It creates a netcdf file in CD-5 format and writes a number of
@@ -41,7 +41,7 @@
           PARAMETER(NDIMS=3, NUM_VARS=10, BUFSIZE=1000)
 
           character*128 filename, cmd, str
-          integer i, j, cmode, err, ierr, get_args
+          integer i, j, cmode, err, ierr, get_args, info
           integer rank, nprocs, ncid, len
           integer buf(BUFSIZE, NUM_VARS), buf1d(BUFSIZE)
           integer psizes(NDIMS), dimids(NDIMS), varids(NUM_VARS)
@@ -101,12 +101,19 @@
              enddo
           enddo
 
+          ! set an MPI-IO hint to disable file offset alignment for
+          ! fix-sized variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF_CLOBBER, NF_64BIT_DATA)
           err = nfmpi_create(MPI_COMM_WORLD, filename, cmode,
-     +                       MPI_INFO_NULL, ncid)
+     +                       info, ncid)
           call check(err, 'In nfmpi_create: ')
 
+          call MPI_Info_free(info, err)
+
           ! define dimensions
           do i=1, NDIMS
              write(str,'(I1)') i-1
diff --git a/examples/F90/block_cyclic.f90 b/examples/F90/block_cyclic.f90
index 6ef74f5..c9dc450 100644
--- a/examples/F90/block_cyclic.f90
+++ b/examples/F90/block_cyclic.f90
@@ -2,7 +2,7 @@
 !  Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: block_cyclic.f90 2245 2015-12-20 18:39:52Z wkliao $
+! $Id: block_cyclic.f90 2325 2016-02-28 07:49:13Z wkliao $
 
 
 ! This example, generalized from column_wise.f, makes a number of nonblocking
@@ -76,6 +76,7 @@
           integer(kind=MPI_OFFSET_KIND) start(2), count(2)
           integer(kind=MPI_OFFSET_KIND) malloc_size, sum_size
           logical verbose
+          integer info
 
           call MPI_Init(err)
           call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
@@ -93,12 +94,19 @@
           call MPI_Bcast(verbose, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, err)
           call MPI_Bcast(filename, 256, MPI_CHARACTER, 0, MPI_COMM_WORLD, err)
 
+          ! set an MPI-IO hint to disable file offset alignment for
+          ! fix-sized variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF90_CLOBBER, NF90_64BIT_DATA)
           err = nf90mpi_create(MPI_COMM_WORLD, filename, cmode, &
-                               MPI_INFO_NULL, ncid)
+                               info, ncid)
           call check(err, 'In nf90mpi_create: ')
 
+          call MPI_Info_free(info, err)
+
           ! the global array is NX * (NY * nprocs) */
           G_NY  = NY * nprocs
           myOff = NY * rank
diff --git a/examples/F90/column_wise.f90 b/examples/F90/column_wise.f90
index 2ce5a13..ef0b3be 100644
--- a/examples/F90/column_wise.f90
+++ b/examples/F90/column_wise.f90
@@ -2,7 +2,7 @@
 !  Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: column_wise.f90 2245 2015-12-20 18:39:52Z wkliao $
+! $Id: column_wise.f90 2325 2016-02-28 07:49:13Z wkliao $
 
 ! This example makes a number of nonblocking API calls, each writes a single
 ! row of a 2D integer array. Each process writes NY rows and any two
@@ -79,6 +79,7 @@
           integer(kind=MPI_OFFSET_KIND) start(2), count(2)
           integer(kind=MPI_OFFSET_KIND) malloc_size, sum_size
           logical verbose
+          integer info
 
           call MPI_Init(err)
           call MPI_Comm_rank(MPI_COMM_WORLD, rank, err)
@@ -96,12 +97,19 @@
           call MPI_Bcast(verbose, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, err)
           call MPI_Bcast(filename, 256, MPI_CHARACTER, 0, MPI_COMM_WORLD, err)
 
+          ! set an MPI-IO hint to disable file offset alignment for
+          ! fix-sized variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF90_CLOBBER, NF90_64BIT_DATA)
           err = nf90mpi_create(MPI_COMM_WORLD, filename, cmode, &
-                               MPI_INFO_NULL, ncid)
+                               info, ncid)
           call check(err, 'In nf90mpi_create: ')
 
+          call MPI_Info_free(info, err)
+
           ! the global array is NX * (NY * nprocs) */
           G_NY  = NY * nprocs
           myOff = NY * rank
diff --git a/examples/F90/nonblocking_write.f90 b/examples/F90/nonblocking_write.f90
index bd28db3..24b6745 100644
--- a/examples/F90/nonblocking_write.f90
+++ b/examples/F90/nonblocking_write.f90
@@ -2,7 +2,7 @@
 !  Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: nonblocking_write.f90 2245 2015-12-20 18:39:52Z wkliao $
+! $Id: nonblocking_write.f90 2325 2016-02-28 07:49:13Z wkliao $
 
 !    This example is the Fortran 90 version of nonblocking_write.c
 !    It creates a netcdf file in CD-5 format and writes a number of
@@ -42,7 +42,7 @@
           PARAMETER(NDIMS=3, NUM_VARS=10)
 
           character(LEN=256) filename, cmd, str
-          integer i, cmode, err, ierr, get_args
+          integer i, cmode, err, ierr, get_args, info
           integer rank, nprocs, len, bufsize, ncid
           integer psizes(NDIMS), dimids(NDIMS), varids(NUM_VARS)
           integer req(NUM_VARS), st(NUM_VARS)
@@ -100,12 +100,19 @@
              buf(i)%p(:) = rank
           enddo
 
+          ! set an MPI-IO hint to disable file offset alignment for
+          ! fix-sized variables
+          call MPI_Info_create(info, err)
+          call MPI_Info_set(info, "nc_var_align_size", "1", err)
+
           ! create file, truncate it if exists
           cmode = IOR(NF90_CLOBBER, NF90_64BIT_DATA)
           err = nf90mpi_create(MPI_COMM_WORLD, filename, cmode, &
-                               MPI_INFO_NULL, ncid)
+                               info, ncid)
           call check(err, 'In nf90mpi_create: ')
 
+          call MPI_Info_free(info, err)
+
           ! define dimensions
           do i=1, NDIMS
              write(str,'(I2)') i
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 3a82558..1f07cbd 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2219 2015-12-11 22:30:03Z wkliao $
+# $Id: Makefile.in 2318 2016-02-04 00:18:26Z wkliao $
 #
 # @configure_input@
 
@@ -21,8 +21,10 @@ endif
 
 ifeq (@has_fortran@, yes)
 SUBDIRS += F77
+ifeq (@mpi_mod@, yes)
 SUBDIRS += F90
 endif
+endif
 
 PACKING_LIST = Makefile.in README
 
diff --git a/examples/tutorial/Makefile.in b/examples/tutorial/Makefile.in
index a0947d6..8043ad4 100644
--- a/examples/tutorial/Makefile.in
+++ b/examples/tutorial/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2237 2015-12-18 07:11:47Z wkliao $
+# $Id: Makefile.in 2318 2016-02-04 00:18:26Z wkliao $
 #
 # @configure_input@
 
@@ -41,9 +41,11 @@ OBJS   = $(C_SRCS:.c=.o)
 ifeq (@has_fortran@, yes)
 PROGS += $(F77_SRCS:.f=)
 OBJS  += $(F77_SRCS:.f=.o)
+ifeq (@mpi_mod@, yes)
 PROGS += $(F90_SRCS:.f90=)
 OBJS  += $(F90_SRCS:.f90=.o)
 endif
+endif
 
 GARBAGE      = $(PROGS) *.nc
 PACKING_LIST = $(C_SRCS) $(F77_SRCS) $(F90_SRCS) Makefile.in depend
diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in
index b4fd504..770e76c 100644
--- a/src/lib/Makefile.in
+++ b/src/lib/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2285 2015-12-30 20:48:25Z wkliao $
+# $Id: Makefile.in 2340 2016-03-03 19:45:09Z wkliao $
 #
 # @configure_input@
 
@@ -22,6 +22,7 @@ INCLUDES = -I. -I$(srcdir)
 
 LIBRARY  = libpnetcdf.a
 HEADER   = pnetcdf.h
+PKGCONFIG = pnetcdf.pc
 
 M4_SRCS   = getput.m4 \
             i_getput.m4 \
@@ -72,6 +73,7 @@ PACKING_LIST = $(LIB_CSRCS) \
                pnetcdf.h.in \
                depend \
                Makefile.in \
+               pnetcdf.pc.in \
                ncconfig.h.in
 
 ifeq (@enable_subfiling@, no)
@@ -82,7 +84,7 @@ LIB_OBJS   = $(LIB_CSRCS:.c=.o) $(M4_SRCS:.m4=.o)
 
 GARBAGE    = $(LIBRARY) $(M4_SRCS:.m4=.c)
 
-DIST_GARBAGE = ncconfig.h pnetcdf.h
+DIST_GARBAGE = ncconfig.h pnetcdf.h pnetcdf.pc
 
 all: $(LIBRARY)
 
@@ -95,8 +97,11 @@ install: $(LIBRARY)
 	$(INSTALL_DATA) $(LIBRARY) $(LIBDIR)/$(LIBRARY)
 	$(INSTALL) -d -m 755 $(INCDIR)
 	$(INSTALL_DATA) $(HEADER) $(INCDIR)/$(HEADER)
+	$(INSTALL) -d -m 755 $(LIBDIR)/pkgconfig
+	$(INSTALL_DATA) $(PKGCONFIG) $(LIBDIR)/pkgconfig/$(PKGCONFIG)
 
 uninstall:
+	$(RM) -f $(LIBDIR)/pkgconfig/$(PKGCONFIG)
 	$(RM) -f $(LIBDIR)/$(LIBRARY)
 	$(RM) -f $(INCDIR)/$(HEADER)
 
diff --git a/src/lib/attr.m4 b/src/lib/attr.m4
index 124c64b..2f1c59a 100644
--- a/src/lib/attr.m4
+++ b/src/lib/attr.m4
@@ -67,7 +67,7 @@ ncmpix_len_NC_attrV(nc_type    type,
         case NC_DOUBLE: return ncmpix_len_double(nelems);
         case NC_INT64:  return ncmpix_len_int64(nelems);
         case NC_UINT64: return ncmpix_len_uint64(nelems);
-        default: assert("ncmpix_len_NC_attr bad type" == 0);
+        default: fprintf(stderr, "Error: bad type(%d) in %s\n",type,__func__);
     }
     return 0;
 }
@@ -720,10 +720,9 @@ ncmpix_pad_getn_$1(const void **xpp,
             return ncmpix_pad_getn_$1_longlong (xpp, nelems, (longlong*)tp);
         case NC_UINT64:
             return ncmpix_pad_getn_$1_ulonglong(xpp, nelems, (ulonglong*)tp);
-        default:
-            assert("ncmpix_pad_getn_$1 invalid buffer type" == 0);
-            DEBUG_RETURN_ERROR(NC_EBADTYPE)
+        default: fprintf(stderr, "Error: bad buftype(%d) in %s\n",buftype,__func__);
     }
+    return NC_EBADTYPE;
 }
 ')dnl
 
@@ -766,10 +765,9 @@ ncmpix_getn_$1(const void **xpp,
             return ncmpix_getn_$1_longlong (xpp, nelems, (longlong*)tp);
         case NC_UINT64:
             return ncmpix_getn_$1_ulonglong(xpp, nelems, (ulonglong*)tp);
-        default:
-            assert("ncmpix_pad_getn_$1 invalid buffer type" == 0);
-            DEBUG_RETURN_ERROR(NC_EBADTYPE)
+        default: fprintf(stderr, "Error: bad buftype(%d) in %s\n",buftype,__func__);
     }
+    return NC_EBADTYPE;
 }
 ')dnl
 
@@ -814,10 +812,9 @@ ncmpix_pad_getn(const void **xpp,
             return ncmpix_getn_int64     (xpp, nelems, tp, buftype);
         case NC_UINT64:
             return ncmpix_getn_uint64    (xpp, nelems, tp, buftype);
-        default:
-            assert("ncmpix_pad_getn invalid filetype" == 0);
-            DEBUG_RETURN_ERROR(NC_EBADTYPE)
+        default: fprintf(stderr, "Error: bad filetype(%d) in %s\n",filetype,__func__);
     }
+    return NC_EBADTYPE;
 }
 
 /*----< ncmpii_get_att() >---------------------------------------------------*/
@@ -922,10 +919,9 @@ ncmpix_pad_putn_$1(void       **xpp,
             return ncmpix_pad_putn_$1_longlong (xpp, nelems, (longlong*)tp);
         case NC_UINT64:
             return ncmpix_pad_putn_$1_ulonglong(xpp, nelems, (ulonglong*)tp);
-        default:
-            assert("ncmpix_pad_putn_$1 invalid type" == 0);
-            DEBUG_RETURN_ERROR(NC_EBADTYPE)
+        default: fprintf(stderr, "Error: bad btype(%d) in %s\n",btype,__func__);
     }
+    return NC_EBADTYPE;
 }
 ')dnl
 
@@ -968,10 +964,9 @@ ncmpix_putn_$1(void       **xpp,
             return ncmpix_putn_$1_longlong (xpp, nelems, (longlong*)tp);
         case NC_UINT64:
             return ncmpix_putn_$1_ulonglong(xpp, nelems, (ulonglong*)tp);
-        default:
-            assert("ncmpix_putn_$1 invalid type" == 0);
-            DEBUG_RETURN_ERROR(NC_EBADTYPE)
+        default: fprintf(stderr, "Error: bad btype(%d) in %s\n",btype,__func__);
     }
+    return NC_EBADTYPE;
 }
 ')dnl
 
@@ -1016,10 +1011,9 @@ ncmpix_pad_putn(void       **xpp,
             return ncmpix_putn_int64     (xpp, nelems, tp, buftype);
         case NC_UINT64:
             return ncmpix_putn_uint64    (xpp, nelems, tp, buftype);
-        default:
-            assert("ncmpix_pad_putn invalid filetype" == 0);
-            DEBUG_RETURN_ERROR(NC_EBADTYPE)
+        default: fprintf(stderr, "Error: bad filetype(%d) in %s\n",filetype,__func__);
     }
+    return NC_EBADTYPE;
 }
 
 /*----< ncmpii_put_att() >---------------------------------------------------*/
@@ -1074,6 +1068,9 @@ ncmpii_put_att(int         ncid,
 
         if (nelems != 1)
             DEBUG_RETURN_ERROR(NC_EINVAL)
+
+        /* enable the fill mode for this variable */
+        varp->no_fill = 0;
     }
 
     /* get the file format version */
diff --git a/src/lib/bput.m4 b/src/lib/bput.m4
index 5e69fea..3bdea38 100644
--- a/src/lib/bput.m4
+++ b/src/lib/bput.m4
@@ -7,7 +7,7 @@ dnl
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: bput.m4 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: bput.m4 2320 2016-02-24 13:18:32Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -55,7 +55,7 @@ ncmpi_bput_var(int           ncid,
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)buf, bufcount, buftype, reqid,
                                  WRITE_REQ, 1, 0);
-    if (varp->ndims > 0) NCI_Free(start);
+    NCI_Free(start);
     return status;
 }
 
@@ -89,7 +89,7 @@ ncmpi_bput_var_$1(int       ncid,
     /* bput_var is a special case of bput_varm */
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)op, -1, $3, reqid, WRITE_REQ, 1, 0);
-    if (varp->ndims > 0) NCI_Free(start);
+    NCI_Free(start);
     return status;
 }
 ')dnl
@@ -135,7 +135,7 @@ ncmpi_bput_var1(int               ncid,
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)buf, bufcount, buftype, reqid,
                                  WRITE_REQ, 1, 0);
-    if (varp->ndims > 0) NCI_Free(count);
+    NCI_Free(count);
     return status;
 }
 
@@ -168,7 +168,7 @@ ncmpi_bput_var1_$1(int               ncid,
 
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)op, -1, $3, reqid, WRITE_REQ, 1, 0);
-    if (varp->ndims > 0) NCI_Free(count);
+    NCI_Free(count);
     return status;
 }
 ')dnl
diff --git a/src/lib/error.c b/src/lib/error.c
index e8a8384..5f0d1bd 100644
--- a/src/lib/error.c
+++ b/src/lib/error.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: error.c 2282 2015-12-26 17:44:27Z wkliao $ */
+/* $Id: error.c 2320 2016-02-24 13:18:32Z wkliao $ */
 
 /*LINTLIBRARY*/
 
@@ -604,6 +604,8 @@ nc_strerror(int ncerr1)
 	    "when netCDF was built.";
       case NC_EDISKLESS:
 	 return "NetCDF: Error in using diskless access";
+      case NC_EMPI:
+         return "MPI operation failed";
       default:
          return nc_unknown_err_msg;
    }
diff --git a/src/lib/filetype.c b/src/lib/filetype.c
index 2e94797..5a80642 100644
--- a/src/lib/filetype.c
+++ b/src/lib/filetype.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: filetype.c 2196 2015-11-27 22:31:05Z wkliao $ */
+/* $Id: filetype.c 2335 2016-03-03 14:55:12Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -164,16 +164,17 @@ ncmpii_get_offset(NC               *ncp,
     offset = varp->begin; /* beginning file offset of this variable */
     ndims  = varp->ndims; /* number of dimensions of this variable */
 
-    if (counts != NULL)
+    if (counts != NULL) {
         end_off = (MPI_Offset*) NCI_Malloc((size_t)ndims * SIZEOF_MPI_OFFSET);
 
-    if (counts != NULL && strides != NULL) {
-        for (i=0; i<ndims; i++)
-            end_off[i] = starts[i] + (counts[i] - 1) * strides[i];
-    }
-    else if (counts != NULL) { /* strides == NULL */
-        for (i=0; i<ndims; i++)
-            end_off[i] = starts[i] + counts[i] - 1;
+        if (strides != NULL) {
+            for (i=0; i<ndims; i++)
+                end_off[i] = starts[i] + (counts[i] - 1) * strides[i];
+        }
+        else { /* strides == NULL */
+            for (i=0; i<ndims; i++)
+                end_off[i] = starts[i] + counts[i] - 1;
+        }
     }
     else { /* when counts == NULL strides is of no use */
         end_off = (MPI_Offset*) starts;
@@ -185,6 +186,7 @@ ncmpii_get_offset(NC               *ncp,
 #ifdef CDEBUG
         printf("%s(): NC_start_count_stride_ck() fails\n",__func__);
 #endif
+        if (end_off != NULL && end_off != starts) NCI_Free(end_off);
         return status;
     }
 
@@ -818,8 +820,11 @@ ncmpii_vars_create_filetype(NC               *ncp,
     blockcounts[ndims-1] = (int)count[ndims-1];
     /* check 4-byte integer overflow (blockcounts in MPI_Type_hvector
        is of type int while count[] is of type MPI_Offset */
-    if (count[ndims-1] != blockcounts[ndims-1])
+    if (count[ndims-1] != blockcounts[ndims-1]) {
+        NCI_Free(blockstride);
+        NCI_Free(blockcounts);
         DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+    }
     /* blocklens[] is unlikely a big value */
     blocklens[ndims-1] = varp->xsz;
 
@@ -838,21 +843,30 @@ ncmpii_vars_create_filetype(NC               *ncp,
     }
 #if SIZEOF_MPI_AINT != SIZEOF_MPI_OFFSET
     /* check 4-byte integer overflow */
-    if (stride_off != blockstride[ndims-1])
+    if (stride_off != blockstride[ndims-1]) {
+        if (blockstride) NCI_Free(blockstride);
+        if (blockcounts) NCI_Free(blockcounts);
         DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+    }
 #endif
 
     for (dim=ndims-1; dim>=0; dim--) {
 #ifdef HAVE_MPI_TYPE_CREATE_HVECTOR
         err = MPI_Type_create_hvector(blockcounts[dim], blocklens[dim],
                                       blockstride[dim], tmptype, &filetype);
-        if (err != MPI_SUCCESS)
+        if (err != MPI_SUCCESS) {
+            NCI_Free(blockstride);
+            NCI_Free(blockcounts);
             return ncmpii_handle_error(err, "MPI_Type_create_hvector");
+        }
 #else
         err = MPI_Type_hvector(blockcounts[dim], blocklens[dim],
                                blockstride[dim], tmptype, &filetype);
-        if (err != MPI_SUCCESS)
+        if (err != MPI_SUCCESS) {
+            NCI_Free(blockstride);
+            NCI_Free(blockcounts);
             return ncmpii_handle_error(err, "MPI_Type_hvector");
+        }
 #endif
         MPI_Type_commit(&filetype);
         if (tmptype != MPI_BYTE)
@@ -863,8 +877,11 @@ ncmpii_vars_create_filetype(NC               *ncp,
             blocklens[dim-1]  = 1;
             blockcounts[dim-1] = (int)count[dim - 1];
             /* check 4-byte integer overflow */
-            if (count[dim-1] != blockcounts[dim-1])
+            if (count[dim-1] != blockcounts[dim-1]) {
+                NCI_Free(blockstride);
+                NCI_Free(blockcounts);
                 DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+            }
 
             if (dim-1 == 0 && IS_RECVAR(varp)) {
                 stride_off = stride[dim-1] * ncp->recsize;
@@ -877,8 +894,11 @@ ncmpii_vars_create_filetype(NC               *ncp,
             }
 #if SIZEOF_MPI_AINT != SIZEOF_MPI_OFFSET
             /* check 4-byte integer overflow */
-            if (stride_off != blockstride[dim-1])
+            if (stride_off != blockstride[dim-1]) {
+                NCI_Free(blockstride);
+                NCI_Free(blockcounts);
                 DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+            }
 #endif
         }
     }
diff --git a/src/lib/fill.c b/src/lib/fill.c
index 3da99cb..22b491b 100644
--- a/src/lib/fill.c
+++ b/src/lib/fill.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2015, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: fill.c 2198 2015-11-28 00:20:38Z wkliao $ */
+/* $Id: fill.c 2320 2016-02-24 13:18:32Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -132,9 +132,9 @@ ncmpii_fill_var_buf(const NC_var *varp,
 }
 
 /*----< ncmpii_fill_var() >--------------------------------------------------*/
-/* If the variable is fixed-size, then write the entire variable with fill
- * values and recno is ignored. If it is a record variable, then write one
- * record of that variable with fill values.
+/* For fixed-size variables, write the entire variable with fill values and
+ * ignore argument recno. For record variables, write one record of that
+ * variable with pre-defined/supplied fill value.
  */
 static int
 ncmpii_fill_var_rec(NC         *ncp,
@@ -173,10 +173,14 @@ ncmpii_fill_var_rec(NC         *ncp,
     /* allocate buffer space */
     buf = NCI_Malloc((size_t)(count * varp->xsz));
 
-    /* fill buffer with file values */
+    /* fill buffer with fill values */
     err = ncmpii_fill_var_buf(varp, count, buf);
-    if (err != NC_NOERR) return err;
+    if (err != NC_NOERR) {
+        NCI_Free(buf);
+        return err;
+    }
 
+    /* calculate the starting file offset for each process */
     offset = varp->begin;
     if (IS_RECVAR(varp))
         offset += ncp->recsize * recno;
@@ -190,6 +194,10 @@ ncmpii_fill_var_rec(NC         *ncp,
 
     count *= varp->xsz;
     if (count != (int)count) DEBUG_ASSIGN_ERROR(err, NC_EINTOVERFLOW)
+    if (err != NC_NOERR)
+        count = 0; /* participate collective write with 0-length request */
+
+    /* write to variable collectively */
     TRACE_IO(MPI_File_write_at_all)(fh, offset, buf, (int)count,
                                     MPI_BYTE, &mpistatus);
     NCI_Free(buf);
@@ -345,7 +353,11 @@ ncmpi_def_var_fill(int   ncid,
             /* user intends to use default fill value */
             fill_value = NCI_Malloc((size_t)varp->xsz);
             err = inq_default_fill_value(varp->type, fill_value);
-            if (err != NC_NOERR) return err;
+            if (err != NC_NOERR) {
+                NCI_Free(fill_value);
+                NCI_Free(root_fill_value);
+                return err;
+            }
             free_fill_value=1;
         }
         memcpy(root_fill_value, fill_value, (size_t)varp->xsz);
@@ -419,8 +431,9 @@ ncmpi_inq_var_fill(int   ncid,
     return NC_NOERR;
 }
 
+#ifdef FILL_ONE_VAR_AT_A_TIME
 /*----< fillerup() >---------------------------------------------------------*/
-/* fill the newly created variables */
+/* fill the newly created fixed-size variables */
 static int
 fillerup(NC *ncp)
 {
@@ -429,13 +442,16 @@ fillerup(NC *ncp)
     /* loop thru all variables */
     for (i=0; i<ncp->vars.ndefined; i++) {
         if (IS_RECVAR(ncp->vars.value[i]))
-            /* skip record variables */
+            /* skip record variables. In PnetCDF record variables mus be
+             * explicitly filled by calling ncmpi_fill_var_rec() */
             continue;
 
         /* check if _FillValue attribute is defined */
         indx = ncmpii_NC_findattr(&ncp->vars.value[i]->attrs, _FillValue);
 
-        /* only if filling this variable is requested */
+        /* only if filling this variable is requested. Fill mode can be
+         * enabled by 2 ways: explictly call to ncmpi_def_var_fill() or put
+         * the attribute named _FillValue */
         if (ncp->vars.value[i]->no_fill && indx == -1) continue;
 
         /* collectively fill the entire variable */
@@ -501,23 +517,281 @@ fill_added_recs(NC *ncp, NC *old_ncp)
     }
     return NC_NOERR;
 }
+#endif
+
+/*----< fillerup_aggregate() >-----------------------------------------------*/
+/* fill the newly created/added variables
+ * This version aggregates all writes into a single one
+ */
+static int
+fillerup_aggregate(NC *ncp, NC *old_ncp)
+{
+    int i, j, k, rank, nprocs, start_vid, nsegs, recno;
+    int nVarsFill, *blocklengths;
+    int mpireturn, err, status=NC_NOERR;
+    char *buf_ptr, *noFill;
+    void *buf;
+    size_t buf_len;
+    MPI_Offset var_len, nrecs, start, *count;
+    MPI_Aint *offset;
+    MPI_Datatype filetype;
+    MPI_File fh;
+    MPI_Status mpistatus;
+    NC_var *varp;
+
+    MPI_Comm_rank(ncp->nciop->comm, &rank);
+    MPI_Comm_size(ncp->nciop->comm, &nprocs);
+
+    /* find the starting vid for newly added variables */
+    start_vid = 0;
+    nrecs = 0;  /* the current number of records */
+    if (old_ncp != NULL) {
+        start_vid = old_ncp->vars.ndefined;
+        nrecs = NC_get_numrecs(old_ncp);
+    }
+
+    /* Because fill mode is not part of file header, we must broadcast root's
+     * variables' fill modes and overwrite local's if an inconsistency is found
+     * Note ncp->vars.ndefined is already made consistent by this point.
+     */
+    noFill = (char*) NCI_Malloc(ncp->vars.ndefined - start_vid);
+    for (i=start_vid; i<ncp->vars.ndefined; i++)
+        noFill[i-start_vid] = ncp->vars.value[i]->no_fill;
+
+    TRACE_COMM(MPI_Bcast)(noFill, (ncp->vars.ndefined - start_vid), MPI_BYTE, 0,
+                          ncp->nciop->comm);
+    nVarsFill = 0;
+    for (i=start_vid; i<ncp->vars.ndefined; i++) { /* overwrite local's mode */
+        ncp->vars.value[i]->no_fill = noFill[i-start_vid];
+        if (!noFill[i-start_vid]) nVarsFill++;
+    }
+    if (nVarsFill == 0) { /* no variables in fill mode */
+        NCI_Free(noFill);
+        return NC_NOERR;
+    }
+
+    /* find the number of write segments (upper bound) */
+    nsegs = ncp->vars.ndefined + ncp->vars.num_rec_vars * nrecs;
+    count  = (MPI_Offset*) NCI_Malloc(nsegs * sizeof(MPI_Offset));
+    offset = (MPI_Aint*)   NCI_Malloc(nsegs * sizeof(MPI_Aint));
+
+    /* calculate each segment's offset and count */
+    buf_len = 0; /* total write amount, used to allocate buffer */
+    j = 0;
+    for (i=start_vid; i<ncp->vars.ndefined; i++) {
+        if (noFill[i-start_vid]) continue;
+
+        varp = ncp->vars.value[i];
+
+        if (IS_RECVAR(varp)) continue; /* first, fixed-size variables only */
+
+        if (varp->ndims == 0) var_len = 1; /* scalar */
+        else                  var_len = varp->dsizes[0];
+
+        /* divide evenly total number of variable's elements among processes */
+        count[j] = var_len / nprocs;
+        start = count[j] * rank;
+        if (rank < var_len % nprocs) {
+            start += rank;
+            count[j]++;
+        }
+        else
+            start += var_len % nprocs;
+
+        /* calculate the starting file offset */
+        start *= varp->xsz;
+        start += varp->begin;
+        offset[j] = (MPI_Aint)start;
+        if (start != offset[j]) {
+            DEBUG_ASSIGN_ERROR(err, NC_EINTOVERFLOW)
+            if (status == NC_NOERR) status = err;
+            noFill[i-start_vid] = 1; /* skip this variable */
+            continue;
+        }
+        /* add up the buffer size */
+        buf_len += count[j] * varp->xsz;
+
+        j++;
+    }
+
+    /* loop thru all record variables to find the aggregated write amount */
+    for (recno=0; recno<nrecs; recno++) {
+        for (i=start_vid; i<ncp->vars.ndefined; i++) {
+            if (noFill[i-start_vid]) continue;
+
+            varp = ncp->vars.value[i];
+            if (!IS_RECVAR(varp)) continue; /* record variables only */
+
+            if (varp->ndims <= 1) var_len = 1;
+            else                  var_len = varp->dsizes[1];
+
+            /* divide total number of variable's elements among all processes */
+            count[j] = var_len / nprocs;
+            start = count[j] * rank;
+            if (rank < var_len % nprocs) {
+                start += rank;
+                count[j]++;
+            }
+            else
+                start += var_len % nprocs;
+
+            /* calculate the starting file offset */
+            start *= varp->xsz;
+            start += varp->begin + ncp->recsize * recno;
+            offset[j] = (MPI_Aint)start;
+            if (start != offset[j]) {
+                DEBUG_ASSIGN_ERROR(err, NC_EINTOVERFLOW)
+                if (status == NC_NOERR) status = err;
+                noFill[i-start_vid] = 1; /* skip this variable */
+                continue;
+            }
+            /* add up the buffer size */
+            buf_len += count[j] * varp->xsz;
+
+            j++;
+        }
+    }
+    /* j is now the number of valid write segments */
+
+    /* allocate one contiguous buffer space for all writes */
+    blocklengths = (int*) NCI_Malloc(j * sizeof(int));
+    buf = NCI_Malloc(buf_len);
+    buf_ptr = (char*)buf;
+
+    /* fill write buffers for fixed-size variables first */
+    j = k = 0;
+    for (i=start_vid; i<ncp->vars.ndefined; i++) {
+        if (noFill[i-start_vid]) continue;
+
+        varp = ncp->vars.value[i];
+        if (IS_RECVAR(varp)) continue;
+
+        if (k < j) {  /* coalesce count[] and offset[] */
+            count[k]  = count[j];
+            offset[k] = offset[j];
+        }
+        j++;
+        err = ncmpii_fill_var_buf(varp, count[k], buf_ptr);
+        if (err != NC_NOERR) {
+            if (status == NC_NOERR) status = err;
+            continue; /* skip this request */
+        }
+
+        count[k] *= varp->xsz;
+        if (count[k] != (int)count[k]) {
+            DEBUG_ASSIGN_ERROR(err, NC_EINTOVERFLOW)
+            if (status == NC_NOERR) status = err;
+            continue; /* skip this request */
+        }
+        buf_ptr += count[k];
+        blocklengths[k] = (int)count[k];
+        k++;
+    }
+    /* k is the number of valid write requests thus far */
+
+    /* loop thru all record variables to fill write buffers */
+    for (recno=0; recno<nrecs; recno++) {
+        for (i=start_vid; i<ncp->vars.ndefined; i++) {
+            if (noFill[i-start_vid]) continue;
+
+            varp = ncp->vars.value[i];
+            if (!IS_RECVAR(varp)) continue;
+
+            if (k < j) {  /* coalesce count[] and offset[] */
+                count[k]  = count[j];
+                offset[k] = offset[j];
+            }
+            j++;
+            err = ncmpii_fill_var_buf(varp, count[k], buf_ptr);
+            if (err != NC_NOERR) {
+                if (status == NC_NOERR) status = err;
+                continue; /* skip this request */
+            }
+
+            count[k] *= varp->xsz;
+            if (count[k] != (int)count[k]) {
+                DEBUG_ASSIGN_ERROR(err, NC_EINTOVERFLOW)
+                if (status == NC_NOERR) status = err;
+                continue; /* skip this request */
+            }
+            buf_ptr += count[k];
+            blocklengths[k] = (int)count[k];
+            k++;
+        }
+    }
+    /* k is the number of valid write requests */
+    NCI_Free(noFill);
+
+    /* create the fileview: a list of contiguous segment for each variable */
+#ifdef HAVE_MPI_TYPE_CREATE_HINDEXED
+    mpireturn = MPI_Type_create_hindexed(k, blocklengths, offset, MPI_BYTE,
+                                         &filetype);
+#else
+    mpireturn = MPI_Type_hindexed(k, blocklengths, offset, MPI_BYTE, &filetype);
+#endif
+    if (mpireturn != MPI_SUCCESS) {
+        int err = ncmpii_handle_error(mpireturn, "MPI_Type_hindexed");
+        /* return the first encountered error if there is any */
+        if (status == NC_NOERR) status = err;
+    }
+    else
+        MPI_Type_commit(&filetype);
+
+    NCI_Free(blocklengths);
+    NCI_Free(count);
+    NCI_Free(offset);
+
+    fh = ncp->nciop->collective_fh;
+
+    TRACE_IO(MPI_File_set_view)(fh, 0, MPI_BYTE, filetype, "native",
+                                MPI_INFO_NULL);
+    MPI_Type_free(&filetype);
+
+    /* write to variable collectively */
+    TRACE_IO(MPI_File_write_at_all)(fh, 0, buf, buf_len, MPI_BYTE, &mpistatus);
+
+    NCI_Free(buf);
+
+    TRACE_IO(MPI_File_set_view)(fh, 0, MPI_BYTE, MPI_BYTE, "native",
+                                MPI_INFO_NULL);
+
+    if (status != NC_NOERR) return status;
+
+    if (mpireturn != MPI_SUCCESS)
+        return ncmpii_handle_error(mpireturn, "MPI_File_write_at_all");
+
+    return NC_NOERR;
+}
 
 /*----< ncmpii_fill_vars() >-------------------------------------------------*/
 int
 ncmpii_fill_vars(NC *ncp)
 {
-    int status=NC_NOERR, err;
+    int status=NC_NOERR;
+
+#ifdef FILL_ONE_VAR_AT_A_TIME
+    int err;
 
     /* fill variables according to their fill mode settings */
-    if (NC_IsNew(ncp)) {
+    if (NC_IsNew(ncp))
+        /* file is just created */
         status = fillerup(ncp);
-    }
     else if (ncp->vars.ndefined > ncp->old->vars.ndefined) {
+        /* old file, but new variables have been added */
         status = fill_added(ncp, ncp->old);
 
         err = fill_added_recs(ncp, ncp->old);
         if (status == NC_NOERR) status = err;
     }
+#else
+    /* fill variables according to their fill mode settings */
+    if (NC_IsNew(ncp))
+        /* file is just created and never exits define mode */
+        status = fillerup_aggregate(ncp, NULL);
+    else
+        /* old file, but new variables have been added */
+        status = fillerup_aggregate(ncp, ncp->old);
+#endif
     return status;
 }
 
diff --git a/src/lib/getput.m4 b/src/lib/getput.m4
index 4d3cbe1..1506143 100644
--- a/src/lib/getput.m4
+++ b/src/lib/getput.m4
@@ -7,7 +7,7 @@ dnl
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: getput.m4 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: getput.m4 2322 2016-02-26 22:47:06Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -479,8 +479,8 @@ mpi_io:
                 err = ncmpii_handle_error(mpireturn, "MPI_File_write_at_all");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EWRITE : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EWRITE : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
@@ -491,8 +491,8 @@ mpi_io:
                 err = ncmpii_handle_error(mpireturn, "MPI_File_write_at");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EWRITE : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EWRITE : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
@@ -508,8 +508,8 @@ mpi_io:
                 err = ncmpii_handle_error(mpireturn, "MPI_File_read_at_all");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EREAD : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EREAD : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
@@ -520,8 +520,8 @@ mpi_io:
                 err = ncmpii_handle_error(mpireturn, "MPI_File_read_at");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EREAD : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EREAD : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
@@ -684,7 +684,7 @@ ncmpi_$1_var$2(int                ncid,
     status = ncmpii_getput_varm(ncp, varp, start, count, NULL, NULL, (void*)buf,
                                 bufcount, buftype, ReadWrite($1),
                                 CollIndep($2));
-    if (varp->ndims > 0) NCI_Free(start);
+    NCI_Free(start);
     return status;
 }
 ')dnl
@@ -720,7 +720,7 @@ ncmpi_$1_var_$3$2(int              ncid,
     /* $1_var is a special case of $1_varm */
     status = ncmpii_getput_varm(ncp, varp, start, count, NULL, NULL, (void*)op,
                                 -1, $5, ReadWrite($1), CollIndep($2));
-    if (varp->ndims > 0) NCI_Free(start);
+    NCI_Free(start);
     return status;
 }
 ')dnl
@@ -805,7 +805,7 @@ ncmpi_$1_var1$2(int                ncid,
     status = ncmpii_getput_varm(ncp, varp, start, count, NULL, NULL, (void*)buf,
                                 bufcount, buftype, ReadWrite($1),
                                 CollIndep($2));
-    if (varp->ndims > 0) NCI_Free(count);
+    NCI_Free(count);
     return status;
 }
 ')dnl
@@ -841,7 +841,7 @@ ncmpi_$1_var1_$3$2(int               ncid,
     /* $1_var1 is a special case of $1_varm */
     status = ncmpii_getput_varm(ncp, varp, start, count, NULL, NULL, (void*)op,
                                 -1, $5, ReadWrite($1), CollIndep($2));
-    if (varp->ndims > 0) NCI_Free(count);
+    NCI_Free(count);
     return status;
 }
 ')dnl
diff --git a/src/lib/header.c b/src/lib/header.c
index 0f0f4c0..06101fd 100644
--- a/src/lib/header.c
+++ b/src/lib/header.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: header.c 2299 2016-01-09 06:14:37Z wkliao $ */
+/* $Id: header.c 2322 2016-02-26 22:47:06Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -1068,7 +1068,8 @@ ncmpix_len_nctype(nc_type type) {
         case NC_DOUBLE: return X_SIZEOF_DOUBLE;
         case NC_INT64:
         case NC_UINT64: return X_SIZEOF_INT64;
-        default: assert("ncmpix_len_nctype bad type" == 0);
+        default: fprintf(stderr,"ncmpix_len_nctype bad type %d\n",type);
+                 assert(0);
     }
     return 0;
 }
@@ -1765,22 +1766,22 @@ ncmpii_hdr_get_NC(NC *ncp)
     } else if (magic[sizeof(ncmagic1)-1] == 0x2) {
         getbuf.version = 2;
         fSet(ncp->flags, NC_64BIT_OFFSET);
-        if (SIZEOF_MPI_OFFSET != 8) {
+#if SIZEOF_MPI_OFFSET < 8
             /* take the easy way out: if we can't support all CDF-2
              * files, return immediately */
             NCI_Free(getbuf.base);
             DEBUG_RETURN_ERROR(NC_ESMALL)
-        }
+#endif
     } else if (magic[sizeof(ncmagic1)-1] == 0x5) {
         getbuf.version = 5;
         fSet(ncp->flags, NC_64BIT_DATA);
-        if (SIZEOF_MPI_OFFSET != 8) {
+#if SIZEOF_MPI_OFFSET < 8
             NCI_Free(getbuf.base);
             DEBUG_RETURN_ERROR(NC_ESMALL)
-        }
+#endif
     } else {
         NCI_Free(getbuf.base);
-        DEBUG_RETURN_ERROR(NC_ENOTNC) /* not an netCDF file */
+        DEBUG_RETURN_ERROR(NC_ENOTNC) /* not a netCDF file */
     }
 
     /** Ensure that 'nextread' bytes (numrecs) are available. */
@@ -2160,7 +2161,7 @@ ncmpii_comp_vars(int          safe_mode,
                  NC_vararray *root_var,
                  NC_vararray *local_var)
 {
-    int i, j, err, status=NC_NOERR, no_fill;
+    int i, j, err, status=NC_NOERR;
     char *msg;
 
     /* check if the numbers of variables are the same */
@@ -2184,12 +2185,7 @@ ncmpii_comp_vars(int          safe_mode,
 
         NC_var *v1 = root_var->value[i];
         NC_var *v2 = local_var->value[i];
-        char name[128];
-        /* in PnetCDF, name->cp is always NULL character terminated */
-        strcpy(name, v1->name->cp);
-
-        /* preserve original local variable's no_fill setting */
-        no_fill = v2->no_fill;
+        char *name = v1->name->cp;
 
 #define VAR_WARN(msg, var, root, local) \
     if (safe_mode) printf(msg, WARN_STR, var, root, local);
@@ -2247,8 +2243,6 @@ ncmpii_comp_vars(int          safe_mode,
         if (ErrIsHeaderDiff(err)) {
             ncmpii_free_NC_var(local_var->value[i]);
             local_var->value[i] = dup_NC_var(root_var->value[i]);
-            /* restore original local variable's no_fill setting */
-            local_var->value[i]->no_fill = no_fill;
             /* note once a new var is created, one must call
              * ncmpii_NC_computeshapes() to recalculate the shape */
         }
@@ -2397,7 +2391,7 @@ ncmpii_hdr_check_NC(bufferinfo *getbuf, /* header from root */
                    WARN_STR, ncp->numrecs, root_ncp->numrecs);
         /* overwrite the local header's numrecs */
         ncp->numrecs = root_ncp->numrecs;
-        if (status == NC_NOERR) DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_NUMRECS)
+        if (status == NC_NOERR) DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE_NUMRECS)
     }
 
 #ifdef HAVE_MPI_GET_ADDRESS
@@ -2492,13 +2486,16 @@ int ncmpii_write_header(NC *ncp)
         /* copy header object to write buffer */
         status = ncmpii_hdr_put_NC(ncp, buf);
 
-        if (ncp->xsz != (int)ncp->xsz) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+        if (ncp->xsz != (int)ncp->xsz) {
+            NCI_Free(buf);
+            DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+        }
         TRACE_IO(MPI_File_write_at)(fh, 0, buf, (int)ncp->xsz, MPI_BYTE, &mpistatus);
         if (mpireturn != MPI_SUCCESS) {
             err = ncmpii_handle_error(mpireturn, "MPI_File_write_at");
             if (status == NC_NOERR) {
-                status = (err == NC_EFILE) ? NC_EWRITE : err;
-                DEBUG_ASSIGN_ERROR(status, status)
+                err = (err == NC_EFILE) ? NC_EWRITE : err;
+                DEBUG_ASSIGN_ERROR(status, err)
             }
         }
         else {
@@ -2515,6 +2512,10 @@ int ncmpii_write_header(NC *ncp)
         TRACE_COMM(MPI_Bcast)(&root_status, 1, MPI_INT, 0, ncp->nciop->comm);
         /* root's write has failed, which is serious */
         if (root_status == NC_EWRITE) DEBUG_ASSIGN_ERROR(status, NC_EWRITE)
+        if (mpireturn != MPI_SUCCESS) {
+            ncmpii_handle_error(mpireturn,"MPI_Bcast");
+            DEBUG_RETURN_ERROR(NC_EMPI)
+        }
     }
 
     /* update file header size */
@@ -2522,7 +2523,15 @@ int ncmpii_write_header(NC *ncp)
 
     if (NC_doFsync(ncp)) { /* NC_SHARE is set */
         TRACE_IO(MPI_File_sync)(fh);
+        if (mpireturn != MPI_SUCCESS) {
+            ncmpii_handle_error(mpireturn,"MPI_File_sync");
+            DEBUG_RETURN_ERROR(NC_EMPI)
+        }
         TRACE_COMM(MPI_Barrier)(ncp->nciop->comm);
+        if (mpireturn != MPI_SUCCESS) {
+            ncmpii_handle_error(mpireturn,"MPI_Barrier");
+            DEBUG_RETURN_ERROR(NC_EMPI)
+        }
     }
 
     return status;
diff --git a/src/lib/i_getput.m4 b/src/lib/i_getput.m4
index 6bf1a26..9ae93f1 100644
--- a/src/lib/i_getput.m4
+++ b/src/lib/i_getput.m4
@@ -7,7 +7,7 @@ dnl
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: i_getput.m4 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: i_getput.m4 2320 2016-02-24 13:18:32Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -63,7 +63,7 @@ ncmpi_i$1_var(int                ncid,
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)buf, bufcount, buftype, reqid,
                                  ReadWrite($1), 0, 0);
-    if (varp->ndims > 0) NCI_Free(start);
+    NCI_Free(start);
     return status;
 }
 ')dnl
@@ -99,7 +99,7 @@ ncmpi_i$1_var_$2(int              ncid,
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)buf, -1, $4, reqid,
                                  ReadWrite($1), 0, 0);
-    if (varp->ndims > 0) NCI_Free(start);
+    NCI_Free(start);
     return status;
 }
 ')dnl
@@ -161,7 +161,7 @@ ncmpi_i$1_var1(int                ncid,
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)buf, bufcount, buftype, reqid,
                                  ReadWrite($1), 0, 0);
-    if (varp->ndims > 0) NCI_Free(count);
+    NCI_Free(count);
     return status;
 }
 ')dnl
@@ -197,7 +197,7 @@ ncmpi_i$1_var1_$2(int               ncid,
     status = ncmpii_igetput_varm(ncp, varp, start, count, NULL, NULL,
                                  (void*)buf, -1, $4, reqid, ReadWrite($1), 0,
                                  0);
-    if (varp->ndims > 0) NCI_Free(count);
+    NCI_Free(count);
     return status;
 }
 ')dnl
@@ -643,6 +643,8 @@ ncmpii_igetput_varm(NC               *ncp,
          * not contiguous
          */
         if (!buftype_is_contig) { /* buftype is not contiguous */
+            if (bufcount != (int)bufcount) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+
             /* allocate lbuf */
             if (use_abuf && imaptype == MPI_DATATYPE_NULL && !need_convert) {
                 status = ncmpii_abuf_malloc(ncp, nbytes, &lbuf, &abuf_index);
@@ -651,8 +653,6 @@ ncmpii_igetput_varm(NC               *ncp,
             }
             else lbuf = NCI_Malloc((size_t)outsize);
 
-            if (bufcount != (int)bufcount) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
-
             /* pack buf into lbuf using buftype */
             position = 0;
             MPI_Pack(buf, (int)bufcount, buftype, lbuf, (int)outsize,
@@ -730,10 +730,11 @@ ncmpii_igetput_varm(NC               *ncp,
 
             if (need_swap) {
 #ifdef DISABLE_IN_PLACE_SWAP
-                if (xbuf == buf) {
+                if (xbuf == buf)
 #else
-                if (xbuf == buf && nbytes <= NC_BYTE_SWAP_BUFFER_SIZE) {
+                if (xbuf == buf && nbytes <= NC_BYTE_SWAP_BUFFER_SIZE)
 #endif
+                {
                     /* allocate xbuf and copy buf to xbuf, before byte-swap */
                     xbuf = NCI_Malloc((size_t)nbytes);
                     memcpy(xbuf, buf, (size_t)nbytes);
@@ -747,6 +748,7 @@ ncmpii_igetput_varm(NC               *ncp,
         }
         /* cbuf is no longer needed */
         if (cbuf != buf && cbuf != xbuf) NCI_Free(cbuf);
+        if (!isSameGroup) ncp->numPutReqs++;
     }
     else { /* rw_flag == READ_REQ */
         /* Type conversion and byte swap for read are done at wait call, we
@@ -756,6 +758,7 @@ ncmpii_igetput_varm(NC               *ncp,
             xbuf = buf;  /* there is no buffered read (bget_var, etc.) */
         else
             xbuf = NCI_Malloc((size_t)nbytes);
+        if (!isSameGroup) ncp->numGetReqs++;
     }
 
     /* allocate a new request object to store the write info */
diff --git a/src/lib/i_varn.m4 b/src/lib/i_varn.m4
index f3fa832..35248e9 100644
--- a/src/lib/i_varn.m4
+++ b/src/lib/i_varn.m4
@@ -7,7 +7,7 @@ dnl
  *  Copyright (C) 2014, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: i_varn.m4 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: i_varn.m4 2321 2016-02-24 21:50:14Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -232,7 +232,7 @@ ncmpii_igetput_varn(NC               *ncp,
     else { /* (bufcount > 0) flexible API is used */
         /* pack buf into cbuf, a contiguous buffer */
         int isderived, iscontig_of_ptypes;
-        MPI_Offset bnelems;
+        MPI_Offset bnelems=0;
 
         /* ptype (primitive MPI data type) from buftype
          * el_size is the element size of ptype
@@ -276,6 +276,7 @@ ncmpii_igetput_varn(NC               *ncp,
         _counts = (MPI_Offset**) counts;
 
     /* break buf into num pieces */
+    reqid = NC_REQ_NULL;
     isSameGroup=0;
     bufp = (char*)cbuf;
     for (i=0; i<num; i++) {
diff --git a/src/lib/m_getput_varx.m4 b/src/lib/m_getput_varx.m4
index 96575d9..04ef060 100644
--- a/src/lib/m_getput_varx.m4
+++ b/src/lib/m_getput_varx.m4
@@ -7,7 +7,7 @@ dnl
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: m_getput_varx.m4 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: m_getput_varx.m4 2320 2016-02-24 13:18:32Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -1007,7 +1007,7 @@ err_check:
                                       bufs[i], buflen, datatypes[i],
                                       &req_ids[i], rw_flag, 0, 0);
             if (status == NC_NOERR) status = err;
-            if (varp->ndims > 0) NCI_Free(start);
+            NCI_Free(start);
         } else if (counts == NULL) {  /* var1 */
             /* check whether starts[i] is valid */
             err = NC_start_count_stride_ck(ncp, varp, starts[i], NULL, NULL, rw_flag);
@@ -1021,7 +1021,7 @@ err_check:
                                       bufs[i], buflen, datatypes[i],
                                       &req_ids[i], rw_flag, 0, 0);
             if (status == NC_NOERR) status = err;
-            if (varp->ndims > 0) NCI_Free(count);
+            NCI_Free(count);
         } else if (strides == NULL) { /* vara */
             /* check whether starts[i] and counts[i] are valid */
             err = NC_start_count_stride_ck(ncp, varp, starts[i], counts[i], NULL, rw_flag);
diff --git a/src/lib/mpincio.c b/src/lib/mpincio.c
index 9ee5fce..3398461 100644
--- a/src/lib/mpincio.c
+++ b/src/lib/mpincio.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: mpincio.c 2196 2015-11-27 22:31:05Z wkliao $ */
+/* $Id: mpincio.c 2323 2016-02-26 23:04:46Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -175,13 +175,9 @@ ncmpiio_create(MPI_Comm     comm,
     int i, rank, mpireturn, err;
     int mpiomode = MPI_MODE_RDWR | MPI_MODE_CREATE;
 
-    /* TODO: check whether path are the same across all processes */
-    if (ncp->safe_mode) {
-        int isPathValid=1;
-        if (path == NULL || *path == 0) isPathValid = 0;
-        TRACE_COMM(MPI_Allreduce)(&isPathValid, &err, 1, MPI_INT, MPI_LAND, comm);
-        if (err == 0) DEBUG_RETURN_ERROR(NC_EINVAL)
-    }
+    assert(path != NULL);
+    assert(*path != '\0');
+    /* checking path consistency is expected done in MPI-IO */
 
     MPI_Comm_rank(comm, &rank);
 
@@ -321,13 +317,9 @@ ncmpiio_open(MPI_Comm     comm,
     int i, mpireturn;
     int mpiomode = fIsSet(ioflags, NC_WRITE) ? MPI_MODE_RDWR : MPI_MODE_RDONLY;
 
-    /* TODO: check whether path are the same across all processes */
-    if (ncp->safe_mode) {
-        int isPathValid=1, err;
-        if (path == NULL || *path == 0) isPathValid = 0;
-        TRACE_COMM(MPI_Allreduce)(&isPathValid, &err, 1, MPI_INT, MPI_LAND, comm);
-        if (err == 0) DEBUG_RETURN_ERROR(NC_EINVAL)
-    }
+    assert(path != NULL);
+    assert(*path != '\0');
+    /* checking path consistency is expected done in MPI-IO */
 
     /* When open an non-existing file for read, we can either call access() to
      * check and return error code NC_ENOENT, or call MPI_File_open and expect
@@ -470,7 +462,7 @@ ncmpiio_move(ncio *const nciop,
     while (nbytes > 0) {
         /* calculate how much to move at each time */
         bufcount = chunk_size;
-        if (nbytes < nprocs * chunk_size) {
+        if (nbytes < (MPI_Offset)nprocs * chunk_size) {
             /* handle the last group of chunks */
             MPI_Offset rem_chunks = nbytes / chunk_size;
             if (rank > rem_chunks) /* these processes do not read/write */
diff --git a/src/lib/mpinetcdf.c b/src/lib/mpinetcdf.c
index e0ac0f5..cab7790 100644
--- a/src/lib/mpinetcdf.c
+++ b/src/lib/mpinetcdf.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: mpinetcdf.c 2282 2015-12-26 17:44:27Z wkliao $ */
+/* $Id: mpinetcdf.c 2322 2016-02-26 22:47:06Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -197,7 +197,7 @@ ncmpi_create(MPI_Comm    comm,
              int        *ncidp)
 {
     int flag, err, status=NC_NOERR, safe_mode=0, mpireturn;
-    char *env_str=NULL, *hint_str, value[MPI_MAX_INFO_VAL];
+    char *env_str;
     MPI_Info   env_info;
     MPI_Offset chunksize=NC_DEFAULT_CHUNKSIZE;
     NC *ncp;
@@ -210,8 +210,7 @@ ncmpi_create(MPI_Comm    comm,
     /* get environment variable PNETCDF_SAFE_MODE
      * if it is set to 1, then we perform a strict parameter consistent test
      */
-    env_str = getenv("PNETCDF_SAFE_MODE");
-    if (env_str != NULL) {
+    if ((env_str = getenv("PNETCDF_SAFE_MODE")) != NULL) {
         if (*env_str == '0') safe_mode = 0;
         else                 safe_mode = 1;
         /* if PNETCDF_SAFE_MODE is set but without a value, *env_str can
@@ -264,27 +263,26 @@ ncmpi_create(MPI_Comm    comm,
      * If this environment variable is set, it  overrides any values that
      * were set by using calls to MPI_Info_set in the application code.
      */
-    env_str = getenv("PNETCDF_HINTS");
     env_info = info;
-    if (env_str != NULL) {
-        if (info == MPI_INFO_NULL)
+    if ((env_str = getenv("PNETCDF_HINTS")) != NULL) {
+        if (env_info == MPI_INFO_NULL)
             MPI_Info_create(&env_info); /* ignore error */
 
-        hint_str = strtok(env_str, ";");
-        while (hint_str != NULL && env_info != MPI_INFO_NULL) {
-            char key[128], *val;
-            strcpy(key, hint_str);
+        char *key = strtok(env_str, ";");
+        while (key != NULL) {
+            char *val;
             val = strchr(key, '=');
             *val = '\0';
             val++;
             /* printf("env hint: key=%s val=%s\n",key,val); */
-            MPI_Info_set(env_info, key, val); /* override */
-            hint_str = strtok(NULL, ";");
+            MPI_Info_set(env_info, key, val); /* override or add */
+            key = strtok(NULL, ";");
         }
     }
 
     /* get header chunk size from user info */
     if (env_info != MPI_INFO_NULL) {
+        char value[MPI_MAX_INFO_VAL];
         MPI_Info_get(env_info, "nc_header_read_chunk_size", MPI_MAX_INFO_VAL-1,
                      value, &flag);
         if (flag) chunksize = atoll(value);
@@ -300,6 +298,7 @@ ncmpi_create(MPI_Comm    comm,
 #ifdef ENABLE_SUBFILING
     ncp->subfile_mode = 1;
     if (env_info != MPI_INFO_NULL) {
+        char value[MPI_MAX_INFO_VAL];
         MPI_Info_get(env_info, "pnetcdf_subfiling", MPI_MAX_INFO_VAL-1,
                      value, &flag);
         if (flag && strcasecmp(value, "disable") == 0)
@@ -312,7 +311,9 @@ ncmpi_create(MPI_Comm    comm,
 
     /* set the file format version based on the create mode, cmode */
     if (fIsSet(cmode, NC_64BIT_DATA)) {
-        if (SIZEOF_MPI_OFFSET <  8) DEBUG_RETURN_ERROR(NC_ESMALL)
+#if SIZEOF_MPI_OFFSET <  8
+        DEBUG_RETURN_ERROR(NC_ESMALL)
+#endif
         fSet(ncp->flags, NC_64BIT_DATA);
     } else if (fIsSet(cmode, NC_64BIT_OFFSET)) {
         /* unlike serial netcdf, we will not bother to support
@@ -326,7 +327,9 @@ ncmpi_create(MPI_Comm    comm,
         int default_format;
         ncmpi_inq_default_format(&default_format);
         if (default_format == NC_FORMAT_CDF5) {
-            if (SIZEOF_MPI_OFFSET <  8) DEBUG_RETURN_ERROR(NC_ESMALL)
+#if SIZEOF_MPI_OFFSET <  8
+            DEBUG_RETURN_ERROR(NC_ESMALL)
+#endif
             fSet(ncp->flags, NC_64BIT_DATA);
         }
         else if (default_format == NC_FORMAT_CDF2) {
@@ -353,6 +356,8 @@ ncmpi_create(MPI_Comm    comm,
     /* the linked list storing the outstanding non-blocking requests */
     ncp->head = NULL;
     ncp->tail = NULL;
+    ncp->numGetReqs = 0;
+    ncp->numPutReqs = 0;
 
     /* add to the linked list of opened files */
     ncmpii_add_to_NCList(ncp);
@@ -372,7 +377,7 @@ ncmpi_open(MPI_Comm    comm,
            int        *ncidp)
 {
     int i, flag, err, status=NC_NOERR, safe_mode=0, mpireturn;
-    char *env_str=NULL, *hint_str, value[MPI_MAX_INFO_VAL];
+    char *env_str;
     MPI_Info   env_info;
     MPI_Offset chunksize=NC_DEFAULT_CHUNKSIZE;
     NC *ncp;
@@ -385,8 +390,7 @@ ncmpi_open(MPI_Comm    comm,
     /* get environment variable PNETCDF_SAFE_MODE
      * if it is set to 1, then we perform a strict parameter consistent test
      */
-    env_str = getenv("PNETCDF_SAFE_MODE");
-    if (env_str != NULL) {
+    if ((env_str = getenv("PNETCDF_SAFE_MODE")) != NULL) {
         if (*env_str == '0') safe_mode = 0;
         else                 safe_mode = 1;
         /* if PNETCDF_SAFE_MODE is set but without a value, *env_str can
@@ -421,27 +425,26 @@ ncmpi_open(MPI_Comm    comm,
      * If this environment variable is set, it  overrides any values that
      * were set by using calls to MPI_Info_set in the application code.
      */
-    env_str = getenv("PNETCDF_HINTS");
     env_info = info;
-    if (env_str != NULL) {
-        if (info == MPI_INFO_NULL)
+    if ((env_str = getenv("PNETCDF_HINTS")) != NULL) {
+        if (env_info == MPI_INFO_NULL)
             MPI_Info_create(&env_info); /* ignore error */
 
-        hint_str = strtok(env_str, ";");
-        while (hint_str != NULL && env_info != MPI_INFO_NULL) {
-            char key[128], *val;
-            strcpy(key, hint_str);
+        char *key = strtok(env_str, ";");
+        while (key != NULL) {
+            char *val;
             val = strchr(key, '=');
             *val = '\0';
             val++;
             /* printf("env hint: key=%s val=%s\n",key,val); */
-            MPI_Info_set(env_info, key, val); /* override */
-            hint_str = strtok(NULL, ";");
+            MPI_Info_set(env_info, key, val); /* override or add */
+            key = strtok(NULL, ";");
         }
     }
 
     /* get header chunk size from user info, if provided */
     if (env_info != MPI_INFO_NULL) {
+        char value[MPI_MAX_INFO_VAL];
         MPI_Info_get(env_info, "nc_header_read_chunk_size", MPI_MAX_INFO_VAL-1,
                      value, &flag);
         if (flag) chunksize = atoll(value);
@@ -456,6 +459,7 @@ ncmpi_open(MPI_Comm    comm,
 #ifdef ENABLE_SUBFILING
     ncp->subfile_mode = 1;
     if (env_info != MPI_INFO_NULL) {
+        char value[MPI_MAX_INFO_VAL];
         MPI_Info_get(env_info, "pnetcdf_subfiling", MPI_MAX_INFO_VAL-1,
                      value, &flag);
         if (flag && strcasecmp(value, "disable") == 0)
@@ -482,6 +486,8 @@ ncmpi_open(MPI_Comm    comm,
     }
     ncp->head = NULL;
     ncp->tail = NULL;
+    ncp->numGetReqs = 0;
+    ncp->numPutReqs = 0;
 
     ncmpii_add_to_NCList(ncp);
     *ncidp = ncp->nciop->fd;
diff --git a/src/lib/nc.c b/src/lib/nc.c
index b2f06ce..7bc11ca 100644
--- a/src/lib/nc.c
+++ b/src/lib/nc.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: nc.c 2299 2016-01-09 06:14:37Z wkliao $ */
+/* $Id: nc.c 2326 2016-03-01 17:21:03Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -112,7 +112,11 @@ NC_check_header(NC         *ncp,
      * due to the 2nd argument, count, of MPI_Bcast being of type int.
      * Possible solution is to broadcast in chunks of 2^31 bytes.
      */
-    if (ncp->xsz != (int)ncp->xsz) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+    if (ncp->xsz != (int)ncp->xsz) {
+        if (rank > 0) NCI_Free(cmpbuf);
+        DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+    }
+
     TRACE_COMM(MPI_Bcast)(cmpbuf, (int)ncp->xsz, MPI_BYTE, 0, ncp->nciop->comm);
 
     if (rank > 0 && (ncp->xsz != local_xsz || memcmp(buf, cmpbuf, (size_t)ncp->xsz))) {
@@ -141,8 +145,10 @@ NC_check_header(NC         *ncp,
     if (ncp->safe_mode) {
         TRACE_COMM(MPI_Allreduce)(&status, &g_status, 1, MPI_INT, MPI_MIN,
                                   ncp->nciop->comm);
-        if (mpireturn != MPI_SUCCESS)
+        if (mpireturn != MPI_SUCCESS) {
+            if (rank > 0) NCI_Free(cmpbuf);
             return ncmpii_handle_error(mpireturn, "MPI_Allreduce"); 
+        }
 
         if (g_status != NC_NOERR) { /* some headers are inconsistent */
             if (status == NC_NOERR) DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE)
@@ -683,12 +689,14 @@ ncmpii_sync_numrecs(NC         *ncp,
 
         if (ncp->flags & NC_64BIT_DATA) {
             len = X_SIZEOF_INT64;
-            status = ncmpix_put_uint64((void**)&buf, max_numrecs);
+            err = ncmpix_put_uint64((void**)&buf, max_numrecs);
+            if (status == NC_NOERR) status = err;
         }
         else {
             if (max_numrecs != (int)max_numrecs) DEBUG_ASSIGN_ERROR(status, NC_EINTOVERFLOW)
             len = X_SIZEOF_SIZE_T;
-            status = ncmpix_put_uint32((void**)&buf, (uint)max_numrecs);
+            err = ncmpix_put_uint32((void**)&buf, (uint)max_numrecs);
+            if (status == NC_NOERR) status = err;
         }
         /* ncmpix_put_xxx advances the 1st argument with size len */
 
@@ -795,9 +803,14 @@ write_NC(NC *ncp)
     err =  (status != NC_NOERR && !ErrIsHeaderDiff(status)) ? 1 : 0;
     max_err = err;
 
-    if (ncp->safe_mode == 1)
+    if (ncp->safe_mode == 1) {
         TRACE_COMM(MPI_Allreduce)(&err, &max_err, 1, MPI_INT, MPI_MAX,
                                   ncp->nciop->comm);
+        if (mpireturn != MPI_SUCCESS) {
+            ncmpii_handle_error(mpireturn,"MPI_Allreduce");
+            DEBUG_RETURN_ERROR(NC_EMPI)
+        }
+    }
 
     if (max_err == 1) { /* some processes encounter a fatal error */
         NCI_Free(buf);
@@ -1205,20 +1218,17 @@ ncmpii_inq_env_align_hints(MPI_Offset *h_align,
                            MPI_Offset *h_chunk,
                            MPI_Offset *r_align)
 {
-    char *env_str=NULL, *hint_str;
+    char *env_str;
 
     *h_align = 0;
     *v_align = 0;
     *h_chunk = 0;
     *r_align = 0;
 
-    env_str = getenv("PNETCDF_HINTS");
-    if (env_str != NULL) {
-        hint_str = strtok(env_str, ";");
-        while (hint_str != NULL) {
-            char key[128], *val;
-            strcpy(key, hint_str);
-            val = strchr(key, '=');
+    if ((env_str = getenv("PNETCDF_HINTS")) != NULL) {
+        char *key = strtok(env_str, ";");
+        while (key != NULL) {
+            char *val = strchr(key, '=');
             *val = '\0';
             val++;
             if (strcasecmp(key, "nc_header_align_size") == 0)
@@ -1229,7 +1239,7 @@ ncmpii_inq_env_align_hints(MPI_Offset *h_align,
                 *h_chunk = atoll(val);
             else if (strcasecmp(key, "nc_record_align_size") == 0)
                 *r_align = atoll(val);
-            hint_str = strtok(NULL, ";");
+            key = strtok(NULL, ";");
         }
     }
     return 1;
@@ -1395,8 +1405,7 @@ ncmpii__enddef(NC         *ncp,
 int
 ncmpii_close(NC *ncp)
 {
-    int num_reqs, err, status=NC_NOERR, *req_ids=NULL, *statuses=NULL;
-    NC_req *cur_req;
+    int err, status=NC_NOERR;
 
     if (NC_indef(ncp)) { /* currently in define mode */
         status = ncmpii_enddef(ncp); /* TODO: defaults */
@@ -1427,28 +1436,14 @@ ncmpii_close(NC *ncp)
         ncmpii_subfile_close(ncp);
 #endif
 
-    /* cancel or complete all outstanding nonblocking I/O */
-    num_reqs = 0;
-    cur_req = ncp->head;
-    while (cur_req != NULL) {
-        num_reqs++;
-        cur_req = cur_req->next;
-    }
-    if (num_reqs > 0) { /* fill in req_ids[] */
-        req_ids = (int*) NCI_Malloc((size_t)num_reqs * 2 * SIZEOF_INT);
-        statuses = req_ids + num_reqs;
-        num_reqs = 0;
-        cur_req = ncp->head;
-        while (cur_req != NULL) {
-            req_ids[num_reqs++] = cur_req->id;
-            cur_req = cur_req->next;
-        }
+    /* We can cancel or complete all outstanding nonblocking I/O.
+     * For now, cancelling makes more sense. */
+    if (ncp->head != NULL) {
 #ifdef COMPLETE_NONBLOCKING_IO
-        ncmpii_wait(ncp, COLL_IO, num_reqs, req_ids, statuses);
+        ncmpii_wait(ncp, INDEP_IO, NC_REQ_ALL, NULL, NULL);
 #else
-        ncmpii_cancel(ncp, num_reqs, req_ids, statuses);
+        ncmpii_cancel(ncp, NC_REQ_ALL, NULL, NULL);
 #endif
-        NCI_Free(req_ids);
     }
 
     /* If the user wants a stronger data consistency by setting NC_SHARE */
diff --git a/src/lib/nc.h b/src/lib/nc.h
index 2c322d9..a28945b 100644
--- a/src/lib/nc.h
+++ b/src/lib/nc.h
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: nc.h 2299 2016-01-09 06:14:37Z wkliao $ */
+/* $Id: nc.h 2319 2016-02-04 08:04:01Z wkliao $ */
 #ifndef _NC_H_
 #define _NC_H_
 
@@ -367,7 +367,7 @@ typedef struct {
                              total size in bytes of the array variable.
                              For record variable, this is the record size */
     MPI_Offset    begin;  /* starting file offset of this variable */
-    int           no_fill;
+    char          no_fill;
 #ifdef ENABLE_SUBFILING
     int           ndims_org;  /* ndims before subfiling */
     int          *dimids_org; /* dimids before subfiling */
@@ -535,6 +535,8 @@ struct NC {
     MPI_Offset    recsize;  /* length of 'record': sum of single record sizes
                                of all the record variables */
     MPI_Offset    numrecs;  /* number of 'records' allocated */
+    int           numGetReqs;  /* number of pending nonblocking get requests */
+    int           numPutReqs;  /* number of pending nonblocking put requests */
     NC_dimarray   dims;     /* dimensions defined */
     NC_attrarray  attrs;    /* global attributes defined */
     NC_vararray   vars;     /* variables defined */
diff --git a/src/lib/ncconfig.h.in b/src/lib/ncconfig.h.in
index 5337808..0fdb044 100644
--- a/src/lib/ncconfig.h.in
+++ b/src/lib/ncconfig.h.in
@@ -15,8 +15,8 @@
 /* Define if able to support CDF-5 file format */
 #undef ENABLE_CDF5
 
-/* Define if able to support nonblocking routines */
-#undef ENABLE_NONBLOCKING
+/* Define if able to support request aggregation in nonblocking routines */
+#undef ENABLE_REQ_AGGREGATION
 
 /* Define if to enable subfiling feature */
 #undef ENABLE_SUBFILING
diff --git a/src/lib/ncmpidtype.c b/src/lib/ncmpidtype.c
index bcd5745..fb5561a 100644
--- a/src/lib/ncmpidtype.c
+++ b/src/lib/ncmpidtype.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: ncmpidtype.c 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: ncmpidtype.c 2322 2016-02-26 22:47:06Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -462,7 +462,7 @@ int ncmpii_dtype_decode(MPI_Datatype dtype,
     case MPI_COMBINER_INDEXED_BLOCK:
 #endif
         *iscontig_of_ptypes = 0;
-        total_blocks = array_of_ints[0]*array_of_ints[1];
+        total_blocks = (MPI_Offset)array_of_ints[0]*array_of_ints[1];
         break;
 
     case MPI_COMBINER_HINDEXED:
diff --git a/src/lib/nonblocking.c b/src/lib/nonblocking.c
index 21086dd..1578de2 100644
--- a/src/lib/nonblocking.c
+++ b/src/lib/nonblocking.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: nonblocking.c 2214 2015-12-08 00:33:40Z wkliao $ */
+/* $Id: nonblocking.c 2330 2016-03-02 12:56:52Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -62,15 +62,15 @@ ncmpii_getput_zero_req(NC  *ncp,
         TRACE_IO(MPI_File_read_all)(fh, NULL, 0, MPI_BYTE, &mpistatus);
         if (mpireturn != MPI_SUCCESS) {
             err = ncmpii_handle_error(mpireturn, "MPI_File_read_all");
-            status = (err == NC_EFILE) ? NC_EREAD : err;
-            DEBUG_ASSIGN_ERROR(status, status)
+            err = (err == NC_EFILE) ? NC_EREAD : err;
+            DEBUG_ASSIGN_ERROR(status, err)
         }
     } else { /* WRITE_REQ */
         TRACE_IO(MPI_File_write_all)(fh, NULL, 0, MPI_BYTE, &mpistatus);
         if (mpireturn != MPI_SUCCESS) {
             err = ncmpii_handle_error(mpireturn, "MPI_File_write_all");
-            status = (err == NC_EFILE) ? NC_EWRITE : err;
-            DEBUG_ASSIGN_ERROR(status, status)
+            err = (err == NC_EFILE) ? NC_EWRITE : err;
+            DEBUG_ASSIGN_ERROR(status, err)
         }
     }
 
@@ -127,9 +127,11 @@ ncmpii_abuf_coalesce(NC *ncp)
 }
 
 /*----< ncmpi_cancel() >------------------------------------------------------*/
+/* argument num_req can be NC_REQ_ALL, NC_GET_REQ_ALL, NC_PUT_REQ_ALL, or
+ * non-negative value */
 int
 ncmpi_cancel(int  ncid,
-             int  num_req,  /* NC_REQ_ALL or non-negative value */
+             int  num_req,
              int *req_ids,  /* [num_req] */
              int *statuses) /* [num_req] */
 {
@@ -145,30 +147,75 @@ ncmpi_cancel(int  ncid,
 }
 
 /*----< ncmpii_cancel() >-----------------------------------------------------*/
+/* argument num_req can be NC_REQ_ALL, NC_GET_REQ_ALL, NC_PUT_REQ_ALL, or
+ * non-negative value */
 int
 ncmpii_cancel(NC  *ncp,
-              int  num_req,  /* NC_REQ_all means all pending requests */
+              int  num_req,
               int *req_ids,  /* [num_req]: IN/OUT */
               int *statuses) /* [num_req] can be NULL (ignore status) */
 {
     int i, j, status=NC_NOERR;
-    NC_req *pre_req, *cur_req;
+    NC_req *pre_req, *cur_req, *next_req;
 
     if (num_req == 0)
         return NC_NOERR;
 
-    /* cancel all pending requests, ignore req_ids and statuses */
     if (num_req == NC_REQ_ALL) {
+        /* cancel all pending requests, ignore req_ids and statuses */
         cur_req = ncp->head;
         while (cur_req != NULL) {
+            next_req = cur_req->next;
             FREE_REQUEST(cur_req)
             NCI_Free(cur_req);
-            cur_req = cur_req->next;
+            cur_req = next_req;
         }
         ncp->head = NULL;
         ncp->tail = NULL;
         return NC_NOERR;
     }
+    else if (num_req == NC_GET_REQ_ALL) {
+        /* cancel all pending get requests, ignore req_ids and statuses */
+        cur_req = ncp->head;
+        while (cur_req != NULL) {
+            next_req = cur_req->next;
+            if (cur_req->rw_flag == READ_REQ) {
+                if (cur_req == ncp->head)
+                    ncp->tail = ncp->head = next_req;
+                else
+                    ncp->tail->next = next_req;
+
+                FREE_REQUEST(cur_req)
+                NCI_Free(cur_req);
+            }
+            else { /* a put request */
+                ncp->tail = cur_req;
+            }
+            cur_req = next_req;
+        }
+        return NC_NOERR;
+    }
+    else if (num_req == NC_PUT_REQ_ALL) {
+        /* cancel all pending put requests, ignore req_ids and statuses */
+        cur_req = ncp->head;
+        while (cur_req != NULL) {
+            next_req = cur_req->next;
+            if (cur_req->rw_flag == WRITE_REQ) {
+                if (cur_req == ncp->head)
+                    ncp->tail = ncp->head = next_req;
+                else
+                    ncp->tail->next = next_req;
+
+                FREE_REQUEST(cur_req)
+                NCI_Free(cur_req);
+            }
+            else { /* a get request */
+                ncp->tail = cur_req;
+            }
+            cur_req = next_req;
+        }
+        return NC_NOERR;
+    }
 
     /* collect the requests from the linked list */
     for (i=0; i<num_req; i++) {
@@ -228,11 +275,11 @@ ncmpii_cancel(NC  *ncp,
 }
 
 /*----< ncmpi_inq_nreqs() >---------------------------------------------------*/
-/* TODO: add member num_reqs into NC_req to track this info */
 int
 ncmpi_inq_nreqs(int  ncid,
                 int *nreqs) /* OUT: number of pending requests */
 {
+#ifdef OLD_METHOD
     int     status, prev_id;
     NC     *ncp;
     NC_req *req_ptr;
@@ -240,6 +287,7 @@ ncmpi_inq_nreqs(int  ncid,
     status = ncmpii_NC_check_id(ncid, &ncp);
     if (status != NC_NOERR) return status;
 
+/* TODO: add member num_reqs into NC_req to track this info */
     req_ptr = ncp->head;
     *nreqs = 0;
     prev_id = NC_REQ_NULL;
@@ -253,16 +301,100 @@ ncmpi_inq_nreqs(int  ncid,
         }
         req_ptr = req_ptr->next;
     }
+#else
+    int  status;
+    NC  *ncp;
+
+    status = ncmpii_NC_check_id(ncid, &ncp);
+    if (status != NC_NOERR) return status;
+
+    *nreqs = ncp->numGetReqs + ncp->numPutReqs;
+#endif
 
     return NC_NOERR;
 }
 
+#ifndef ENABLE_REQ_AGGREGATION
+/*----< extract_reqs() >-----------------------------------------------------*/
+/* based on the request type, construct the request ID arrays.
+ * Input value of *num_reqs is NC_REQ_ALL, NC_GET_REQ_ALL, or NC_PUT_REQ_ALL
+ * The output of *num_reqs is the number of requests.
+ */
+static
+void extract_reqs(NC   *ncp,
+                  int  *num_reqs, /* IN/OUT */
+                  int **req_ids)  /* OUT */
+{
+    int req_type, prev_id = NC_REQ_NULL;
+    NC_req *req_ptr = ncp->head;
+
+    req_type = *num_reqs;
+
+    /* first while loop finds the number of requests to flush */
+    *num_reqs = 0;
+    while (req_ptr != NULL) {
+        /* some requests in the linked list may share the same ID, they were
+         * corresponding to the subrequests made from iput/iget/bput varn APIs.
+         */
+        if (req_type == NC_REQ_ALL) {
+            if (req_ptr->id != prev_id) {
+                prev_id = req_ptr->id;
+                (*num_reqs)++;
+            }
+        }
+        else if (req_type == NC_GET_REQ_ALL) {
+            if (req_ptr->rw_flag == READ_REQ && req_ptr->id != prev_id) {
+                prev_id = req_ptr->id;
+                (*num_reqs)++;
+            }
+        }
+        else if (req_type == NC_PUT_REQ_ALL) {
+            if (req_ptr->rw_flag == WRITE_REQ && req_ptr->id != prev_id) {
+                prev_id = req_ptr->id;
+                (*num_reqs)++;
+            }
+        }
+        req_ptr = req_ptr->next;
+    }
+
+    /* allocate ID array */
+    (*req_ids) = (int*) NCI_Malloc(*num_reqs * sizeof(int));
+
+    /* second while loop fills the request IDs */
+    req_ptr = ncp->head;
+    *num_reqs = 0;
+    prev_id = NC_REQ_NULL;
+    while (req_ptr != NULL) {
+        if (req_type == NC_REQ_ALL) {
+            if (req_ptr->id != prev_id) {
+                prev_id = req_ptr->id;
+                (*req_ids)[(*num_reqs)++] = prev_id;
+            }
+        }
+        else if (req_type == NC_GET_REQ_ALL) {
+            if (req_ptr->rw_flag == READ_REQ && req_ptr->id != prev_id) {
+                prev_id = req_ptr->id;
+                (*req_ids)[(*num_reqs)++] = prev_id;
+            }
+        }
+        else if (req_type == NC_PUT_REQ_ALL) {
+            if (req_ptr->rw_flag == WRITE_REQ && req_ptr->id != prev_id) {
+                prev_id = req_ptr->id;
+                (*req_ids)[(*num_reqs)++] = prev_id;
+            }
+        }
+        req_ptr = req_ptr->next;
+    }
+}
+#endif
+
 /*----< ncmpi_wait() >--------------------------------------------------------*/
 /* ncmpi_wait() is an independent call
  * Argument num_reqs can be NC_REQ_ALL which means to flush all pending
  * nonblocking requests. In this case, arguments req_ids and statuses will be
  * ignored.
- * Argument num_reqs must either be NC_REQ_ALL or a non-negative value.
+ * Argument num_reqs must either be NC_REQ_ALL, NC_GET_REQ_ALL, NC_PUT_REQ_ALL,
+ * or a non-negative value.
  * Argument statuses can be NULL, meaning the caller only cares about the
  * error code returned by this call, but not the statuses of individual
  * nonblocking requests.
@@ -281,44 +413,21 @@ ncmpi_wait(int ncid,
     status = ncmpii_NC_check_id(ncid, &ncp);
     if (status != NC_NOERR) return status;
 
-#ifdef ENABLE_NONBLOCKING
+#ifdef ENABLE_REQ_AGGREGATION
     return ncmpii_wait(ncp, INDEP_IO, num_reqs, req_ids, statuses);
 #else
     int i, err, *reqids=NULL;
-    if (num_reqs == NC_REQ_ALL) { /* flush all pending requests */
-        /* in this case, arguments req_ids and statuses are ignored */
-        int prev_id = NC_REQ_NULL;
-        NC_req *req_ptr = ncp->head;
-        num_reqs = 0;
-        while (req_ptr != NULL) {
-            /* some requests in the linked list may share the same ID, they were
-             * corresponding to the subrequests made from iput/iget/bput varn APIs.
-             */
-            if (req_ptr->id != prev_id) {
-                prev_id = req_ptr->id;
-                num_reqs++;
-            }
-            req_ptr = req_ptr->next;
-        }
-        /* allocate ID array */
-        reqids = (int*) NCI_Malloc(num_reqs * sizeof(int));
-        req_ptr = ncp->head;
-        num_reqs = 0;
-        prev_id = NC_REQ_NULL;
-        while (req_ptr != NULL) {
-            if (req_ptr->id != prev_id) {
-                prev_id = req_ptr->id;
-                reqids[num_reqs++] = prev_id;
-            }
-            req_ptr = req_ptr->next;
-        }
-        req_ids = reqids;
+    if (num_reqs <= NC_REQ_ALL) { /* flush all pending requests */
+        /* in this case, arguments req_ids[] and statuses[] are ignored */
+        /* construct request ID array, reqids */
+        extract_reqs(ncp, &num_reqs, &reqids);
     }
+
     for (i=0; i<num_reqs; i++) { /* serve one request at a time */
-        if (statuses == NULL)
-            err = ncmpii_wait(ncp, INDEP_IO, 1, &req_ids[i], NULL);
-        else
+        if (reqids == NULL)
             err = ncmpii_wait(ncp, INDEP_IO, 1, &req_ids[i], &statuses[i]);
+        else
+            err = ncmpii_wait(ncp, INDEP_IO, 1, &reqids[i], NULL);
         if (status == NC_NOERR) status = err;
     }
     if (reqids != NULL) NCI_Free(reqids);
@@ -332,7 +441,8 @@ ncmpi_wait(int ncid,
  * Argument num_reqs can be NC_REQ_ALL which means to flush all pending
  * nonblocking requests. In this case, arguments req_ids and statuses will be
  * ignored.
- * Argument num_reqs must either be NC_REQ_ALL or a non-negative value.
+ * Argument num_reqs must either be NC_REQ_ALL, NC_GET_REQ_ALL, NC_PUT_REQ_ALL,
+ * or a non-negative value.
  * Argument statuses can be NULL, meaning the caller only cares about the
  * error code returned by this call, but not the statuses of individual
  * nonblocking requests.
@@ -356,7 +466,7 @@ ncmpi_wait_all(int  ncid,
         /* must return the error now, parallel program might hang */
         return status;
 
-#ifdef ENABLE_NONBLOCKING
+#ifdef ENABLE_REQ_AGGREGATION
     return ncmpii_wait(ncp, COLL_IO, num_reqs, req_ids, statuses);
 #else
     int i, err, *reqids=NULL;
@@ -370,39 +480,17 @@ ncmpi_wait_all(int  ncid,
     err = ncmpi_begin_indep_data(ncid);
     if (status == NC_NOERR) status = err;
 
-    if (num_reqs == NC_REQ_ALL) { /* flush all pending requests */
-        int prev_id = NC_REQ_NULL;
-        NC_req *req_ptr = ncp->head;
-        num_reqs = 0;
-        while (req_ptr != NULL) {
-            /* some requests in the linked list may share the same ID, they were
-             * corresponding to the subrequests made from iput/iget/bput varn APIs.
-             */
-            if (req_ptr->id != prev_id) {
-                prev_id = req_ptr->id;
-                num_reqs++;
-            }
-            req_ptr = req_ptr->next;
-        }
-        /* allocate ID array */
-        reqids = (int*) NCI_Malloc(num_reqs * sizeof(int));
-        req_ptr = ncp->head;
-        num_reqs = 0;
-        prev_id = NC_REQ_NULL;
-        while (req_ptr != NULL) {
-            if (req_ptr->id != prev_id) {
-                prev_id = req_ptr->id;
-                reqids[num_reqs++] = prev_id;
-            }
-            req_ptr = req_ptr->next;
-        }
-        req_ids = reqids;
+    if (num_reqs <= NC_REQ_ALL) { /* flush all pending requests */
+        /* in this case, arguments req_ids[] and statuses[] are ignored */
+        /* construct request ID array, reqids */
+        extract_reqs(ncp, &num_reqs, &reqids);
     }
+
     for (i=0; i<num_reqs; i++) { /* serve one request at a time */
-        if (statuses == NULL)
-            err = ncmpii_wait(ncp, INDEP_IO, 1, &req_ids[i], NULL);
-        else
+        if (reqids == NULL)
             err = ncmpii_wait(ncp, INDEP_IO, 1, &req_ids[i], &statuses[i]);
+        else
+            err = ncmpii_wait(ncp, INDEP_IO, 1, &reqids[i], NULL);
         if (status == NC_NOERR) status = err;
     }
     if (reqids != NULL) NCI_Free(reqids);
@@ -711,8 +799,80 @@ ncmpii_wait(NC  *ncp,
             }
             cur_req = next_req;
         }
-        ncp->head = NULL;
-        ncp->tail = NULL;
+        ncp->head       = NULL;
+        ncp->tail       = NULL;
+        ncp->numGetReqs = 0;
+        ncp->numPutReqs = 0;
+        num_reqs        = 0; /* to skip the loop below */
+    }
+    else if (num_reqs == NC_GET_REQ_ALL) { /* flush all pending get requests */
+        /* in this case, arguments req_ids[] and statuses[] are ignored */
+        cur_req = ncp->head;
+        while (cur_req != NULL) {
+            next_req = cur_req->next;
+            if (cur_req->rw_flag == READ_REQ) {
+                cur_req->status = NULL; /* ignore status */
+                if (cur_req == ncp->head)
+                    ncp->tail = ncp->head = next_req;
+                else
+                    ncp->tail->next = next_req;
+
+                /* add cur_req to r_req_tail */
+                if (r_req_head == NULL) {
+                    r_req_head = cur_req;
+                    r_req_tail = cur_req;
+                }
+                else {
+                    r_req_tail->next = cur_req;
+                    r_req_tail = r_req_tail->next;
+                }
+                r_req_tail->next = NULL;
+                num_r_reqs += (cur_req->num_subreqs == 0) ?
+                              1 : cur_req->num_subreqs;
+                /* if this request is to a record variable, then count all
+                 * its subrequests (one for each individual record) */
+            }
+            else { /* a put request */
+                ncp->tail = cur_req;
+            }
+            cur_req = next_req;
+        }
+        ncp->numGetReqs = 0;
+        num_reqs = 0; /* to skip the loop below */
+    }
+    else if (num_reqs == NC_PUT_REQ_ALL) { /* flush all pending put requests */
+        /* in this case, arguments req_ids[] and statuses[] are ignored */
+        cur_req = ncp->head;
+        while (cur_req != NULL) {
+            next_req = cur_req->next;
+            if (cur_req->rw_flag == WRITE_REQ) {
+                cur_req->status = NULL; /* ignore status */
+                if (cur_req == ncp->head)
+                    ncp->tail = ncp->head = next_req;
+                else
+                    ncp->tail->next = next_req;
+
+                /* add cur_req to w_req_tail */
+                if (w_req_head == NULL) {
+                    w_req_head = cur_req;
+                    w_req_tail = cur_req;
+                }
+                else {
+                    w_req_tail->next = cur_req;
+                    w_req_tail = w_req_tail->next;
+                }
+                w_req_tail->next = NULL;
+                num_w_reqs += (cur_req->num_subreqs == 0) ?
+                              1 : cur_req->num_subreqs;
+                /* if this request is to a record variable, then count all
+                 * its subrequests (one for each individual record) */
+            }
+            else { /* a put request */
+                ncp->tail = cur_req;
+            }
+            cur_req = next_req;
+        }
+        ncp->numPutReqs = 0;
         num_reqs = 0; /* to skip the loop below */
     }
     /* extract the matched requests from the pending queue (a linked list
@@ -765,6 +925,8 @@ ncmpii_wait(NC  *ncp,
                 next_req = cur_req->next;
 
                 if (cur_req->rw_flag == READ_REQ) {
+                    if (found_id == -1) ncp->numGetReqs--;
+
                     /* add cur_req to r_req_tail */
                     if (r_req_head == NULL) {
                         r_req_head = cur_req;
@@ -781,6 +943,8 @@ ncmpii_wait(NC  *ncp,
                      * its subrequests (one for each individual record) */
                 }
                 else { /* add cur_req to w_req_tail */
+                    if (found_id == -1) ncp->numPutReqs--;
+
                     if (w_req_head == NULL) {
                         w_req_head = cur_req;
                         w_req_tail = cur_req;
@@ -821,10 +985,12 @@ ncmpii_wait(NC  *ncp,
         }
         else req_ids[i] = NC_REQ_NULL;
     }
-    /* make sure ncp->tail pointing to the tail of the pending request queue */
-    ncp->tail = ncp->head;
-    while (ncp->tail != NULL && ncp->tail->next != NULL)
-        ncp->tail = ncp->tail->next;
+    if (num_reqs > 0) {
+        /* make sure ncp->tail pointing to the tail of the pending request queue */
+        ncp->tail = ncp->head;
+        while (ncp->tail != NULL && ncp->tail->next != NULL)
+            ncp->tail = ncp->tail->next;
+    }
 
 err_check:
     if (io_method == COLL_IO) {
@@ -851,6 +1017,7 @@ err_check:
         do_read  = num_r_reqs;
         do_write = num_w_reqs;
     }
+
     /* carry out writes and reads separately (writes first) */
     if (do_write > 0)
         err = ncmpii_wait_getput(ncp, num_w_reqs, w_req_head, WRITE_REQ,
@@ -1374,11 +1541,18 @@ ncmpii_construct_off_len_type(MPI_Offset    nsegs,    /* no. off-len pairs */
     displacements = (MPI_Aint*) NCI_Malloc((size_t)(j+1) * SIZEOF_MPI_AINT);
 
     /* coalesce segs[].off and len to dispalcements[] and blocklengths[] */
-    if (segs[0].len != (int)segs[0].len) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+    if (segs[0].len != (int)segs[0].len) {
+        NCI_Free(displacements);
+        NCI_Free(blocklengths);
+        DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+    }
     displacements[0] =      segs[0].buf_addr;
     blocklengths[0]  = (int)segs[0].len;
     for (j=0,i=1; i<nsegs; i++) {
-        if (segs[i].len != (int)segs[i].len) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+        if (segs[i].len != (int)segs[i].len) {
+            NCI_Free(displacements);
+            DEBUG_RETURN_ERROR(NC_EINTOVERFLOW)
+        }
         if (displacements[j] + blocklengths[j] == segs[i].buf_addr)
             /* j and i are contiguous */
             blocklengths[j] += (int)segs[i].len;
@@ -1711,8 +1885,8 @@ ncmpii_req_aggregation(NC     *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_read_at_all");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EREAD : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EREAD : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         } else {
@@ -1722,8 +1896,8 @@ ncmpii_req_aggregation(NC     *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_read_at");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EREAD : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EREAD : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
@@ -1740,8 +1914,8 @@ ncmpii_req_aggregation(NC     *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_write_at_all");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EWRITE : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EWRITE : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         } else {
@@ -1751,8 +1925,8 @@ ncmpii_req_aggregation(NC     *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_write_at");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EWRITE : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EWRITE : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
@@ -2034,8 +2208,14 @@ ncmpii_mgetput(NC           *ncp,
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) status = err;
             }
-            else
+            else {
                 mpireturn = MPI_Type_commit(&buf_type);
+                if (mpireturn != MPI_SUCCESS) {
+                    err = ncmpii_handle_error(mpireturn,"MPI_Type_commit");
+                    /* return the first encountered error if there is any */
+                    if (status == NC_NOERR) status = err;
+                }
+            }
 
             len = 1;
         }
@@ -2052,8 +2232,8 @@ ncmpii_mgetput(NC           *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_read_at_all");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EREAD : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EREAD : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         } else {
@@ -2063,8 +2243,8 @@ ncmpii_mgetput(NC           *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_read_at");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EREAD : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EREAD : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
@@ -2081,8 +2261,8 @@ ncmpii_mgetput(NC           *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_write_at_all");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EWRITE : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EWRITE : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         } else {
@@ -2092,8 +2272,8 @@ ncmpii_mgetput(NC           *ncp,
                 err = ncmpii_handle_error(mpireturn, "MPI_File_write_at");
                 /* return the first encountered error if there is any */
                 if (status == NC_NOERR) {
-                    status = (err == NC_EFILE) ? NC_EWRITE : err;
-                    DEBUG_ASSIGN_ERROR(status, status)
+                    err = (err == NC_EFILE) ? NC_EWRITE : err;
+                    DEBUG_ASSIGN_ERROR(status, err)
                 }
             }
         }
diff --git a/src/lib/pnetcdf.h.in b/src/lib/pnetcdf.h.in
index eaaa3c6..b967db2 100644
--- a/src/lib/pnetcdf.h.in
+++ b/src/lib/pnetcdf.h.in
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: pnetcdf.h.in 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: pnetcdf.h.in 2319 2016-02-04 08:04:01Z wkliao $ */
 

 #ifndef _PNETCDF_
 #define _PNETCDF_
@@ -594,7 +594,9 @@ by the desired type. */
 #define NC_REQ_NULL -1
 
 /* indicate to flush all pending non-blocking requests */
-#define NC_REQ_ALL -1
+#define NC_REQ_ALL     -1
+#define NC_GET_REQ_ALL -2
+#define NC_PUT_REQ_ALL -3
 
 

 /*
diff --git a/src/lib/pnetcdf.pc.in b/src/lib/pnetcdf.pc.in
new file mode 100644
index 0000000..350548c
--- /dev/null
+++ b/src/lib/pnetcdf.pc.in
@@ -0,0 +1,33 @@
+# Name: A human-readable name for the library or package. This does not
+#      affect usage of the pkg-config tool, which uses the name of the .pc file.
+# Description: A brief description of the package.
+# URL: An URL where people can get more information about and download the
+#      package.
+# Version: A string specifically defining the version of the
+#	package.
+# Requires: A list of packages required by this package. The versions of these
+#           packages may be specified using the comparison operators =, <, >,
+#           <= or >=.
+# Requires.private: A list of private packages required by this package but not
+#                   exposed to applications. The version specific rules from
+#                   the Requires field also apply here.
+# Conflicts: An optional field describing packages that this one conflicts
+#            with. The version specific rules from the Requires field also
+#            apply here. This field also takes multiple instances of the same
+#            package. E.g., Conflicts: bar < 1.2.3, bar >= 1.3.0.
+# Cflags: The compiler flags specific to this package and any required
+#         libraries that don't support pkg-config. If the required libraries
+#         support pkg-config, they should be added to Requires or
+#         Requires.private.
+# Libs: The link flags specific to this package and any required libraries that
+#       don't support pkg-config. The same rule as Cflags applies here.
+# Libs.private: The link flags for private libraries required by this package
+#               but not exposed to applications. The same rule as Cflags
+#               applies here.
+
+Name: Parallel-NetCDF
+Description: Parallel-NetCDF (pnetcdf) provides parallel access to NetCDF files
+URL: http://cucis.ece.northwestern.edu/projects/PnetCDF/
+Version: @PNETCDF_VERSION@
+Cflags: -I at prefix@/include
+Libs: -L at prefix@/lib -lpnetcdf
diff --git a/src/lib/var.c b/src/lib/var.c
index dfd0915..dfa77fd 100644
--- a/src/lib/var.c
+++ b/src/lib/var.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: var.c 2196 2015-11-27 22:31:05Z wkliao $ */
+/* $Id: var.c 2322 2016-02-26 22:47:06Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -351,7 +351,8 @@ ncx_szof(nc_type type)
         case NC_INT64:  return X_SIZEOF_INT64;
         case NC_UINT64: return X_SIZEOF_UINT64;
         default:
-             assert("ncx_szof invalid type" == 0);
+             fprintf(stderr,"ncx_szof invalid type %d\n", type);
+             assert(0);
     }
     /* default */
     return 0;
@@ -523,8 +524,10 @@ ncmpi_def_var(int         ncid,
     status = ncmpii_cktype(file_ver, type);
     if (status != NC_NOERR) return status;
 
-    /* TODO: can ndims > 2^31-1 in CDF-5 ? */
+    /* TODO: make ndims of type MPI_Offset so ndims can be > 2^31-1 in CDF-5
     if ((ndims < 0) || ndims > X_INT_MAX) DEBUG_RETURN_ERROR(NC_EINVAL)
+    */
+    if (ndims < 0) DEBUG_RETURN_ERROR(NC_EINVAL)
 
     /* there is an upperbound for the number of variables defined in a file */
     if (ncp->vars.ndefined >= NC_MAX_VARS) DEBUG_RETURN_ERROR(NC_EMAXVARS)
diff --git a/src/lib/vard.c b/src/lib/vard.c
index 16b4076..8f79549 100644
--- a/src/lib/vard.c
+++ b/src/lib/vard.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2014, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: vard.c 2216 2015-12-08 05:47:19Z wkliao $ */
+/* $Id: vard.c 2338 2016-03-03 18:49:31Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -47,12 +47,13 @@ ncmpii_getput_vard(NC               *ncp,
 {
     void *cbuf=NULL;
     int i, isderived, el_size, mpireturn, status=NC_NOERR, err=NC_NOERR;
-    int buftype_is_contig, filetype_is_contig=1, need_swap=0, is_buf_swapped=0;
+    int buftype_is_contig=0, filetype_is_contig=1, need_swap=0, is_buf_swapped=0;
     int filetype_size=0, buftype_size;
-    MPI_Offset btnelems, bnelems=0, offset=0, orig_bufcount=bufcount;
+    MPI_Offset btnelems=0, bnelems=0, offset=0, orig_bufcount=bufcount;
     MPI_Status mpistatus;
     MPI_Datatype ptype, orig_buftype=buftype;
     MPI_File fh=MPI_FILE_NULL;
+    MPI_Aint lb, extent=0, true_lb, true_extent;
 
     if (filetype == MPI_DATATYPE_NULL) { /* this process does zero-length I/O */
         if (io_method == INDEP_IO) return NC_NOERR;
@@ -88,9 +89,7 @@ ncmpii_getput_vard(NC               *ncp,
         goto err_check;
     }
 
-    MPI_Aint true_lb, true_extent;
     MPI_Type_get_true_extent(filetype, &true_lb, &true_extent);
-    MPI_Aint lb, extent;
     MPI_Type_get_extent(filetype, &lb, &extent);
 
     if (!IS_RECVAR(varp)) {
diff --git a/src/lib/varn.m4 b/src/lib/varn.m4
index 1fd0993..56123e7 100644
--- a/src/lib/varn.m4
+++ b/src/lib/varn.m4
@@ -7,7 +7,7 @@ dnl
  *  Copyright (C) 2014, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: varn.m4 2290 2016-01-02 18:37:46Z wkliao $ */
+/* $Id: varn.m4 2320 2016-02-24 13:18:32Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include "ncconfig.h"
@@ -235,7 +235,7 @@ ncmpii_getput_varn(NC               *ncp,
     if (bufcount > 0) { /* flexible API is used */
         /* pack buf into cbuf, a contiguous buffer */
         int isderived, iscontig_of_ptypes;
-        MPI_Offset bnelems;
+        MPI_Offset bnelems=0;
 
         /* ptype (primitive MPI data type) from buftype
          * el_size is the element size of ptype
diff --git a/src/libcxx/ncmpiAtt.cpp b/src/libcxx/ncmpiAtt.cpp
index ec207f3..f5244c0 100644
--- a/src/libcxx/ncmpiAtt.cpp
+++ b/src/libcxx/ncmpiAtt.cpp
@@ -23,12 +23,16 @@ NcmpiAtt& NcmpiAtt::operator=(const NcmpiAtt& rhs)
 
 // Constructor generates a null object.
 NcmpiAtt::NcmpiAtt() : 
-  nullObject(true) 
+  nullObject(true),
+  groupId(-1),
+  varId(-1)
 {}
 
 // Constructor for non-null instances.
 NcmpiAtt::NcmpiAtt(bool nullObject): 
-  nullObject(nullObject)
+  nullObject(nullObject),
+  groupId(-1),
+  varId(-1)
 {}
 
 // The copy constructor.
diff --git a/src/libcxx/ncmpiDim.cpp b/src/libcxx/ncmpiDim.cpp
index cd29382..282c086 100644
--- a/src/libcxx/ncmpiDim.cpp
+++ b/src/libcxx/ncmpiDim.cpp
@@ -62,7 +62,9 @@ NcmpiGroup  NcmpiDim::getParentGroup() const {
 
 // Constructor generates a null object.
 NcmpiDim::NcmpiDim() : 
-  nullObject(true) 
+  nullObject(true),
+  myId(-1),
+  groupId(-1)
 {}
 
 // Constructor for a dimension (must already exist in the netCDF file.)
diff --git a/src/libcxx/ncmpiType.cpp b/src/libcxx/ncmpiType.cpp
index 74e93fd..9345b0d 100644
--- a/src/libcxx/ncmpiType.cpp
+++ b/src/libcxx/ncmpiType.cpp
@@ -41,7 +41,9 @@ NcmpiType::NcmpiType(const NcmpiType& rhs):
 
 // Constructor generates a null object.
 NcmpiType::NcmpiType() : 
-  nullObject(true) 
+  nullObject(true),
+  myId(-1),
+  groupId(-1)
 {}
 
 // constructor
diff --git a/src/libcxx/ncmpiVar.cpp b/src/libcxx/ncmpiVar.cpp
index 5e82abf..0919c25 100644
--- a/src/libcxx/ncmpiVar.cpp
+++ b/src/libcxx/ncmpiVar.cpp
@@ -62,8 +62,12 @@ bool NcmpiVar::operator!=(const NcmpiVar & rhs) const
 /////////////////
   
 // Constructor generates a null object.
-NcmpiVar::NcmpiVar() : nullObject(true) {}
-  
+NcmpiVar::NcmpiVar() :
+  nullObject(true),
+  myId(-1),
+  groupId(-1)
+{}
+
 // Constructor for a variable (must already exist in the netCDF file.)
 NcmpiVar::NcmpiVar (const NcmpiGroup& grp, const int& varId) :
   nullObject (false),
diff --git a/src/libf/pnetcdf.inc.in b/src/libf/pnetcdf.inc.in
index 09820d0..99891c5 100644
--- a/src/libf/pnetcdf.inc.in
+++ b/src/libf/pnetcdf.inc.in
@@ -695,6 +695,10 @@
 ! indicate to flush all pending non-blocking requests
       integer NF_REQ_ALL
       PARAMETER (NF_REQ_ALL = -1)
+      integer NF_GET_REQ_ALL
+      PARAMETER (NF_GET_REQ_ALL = -2)
+      integer NF_PUT_REQ_ALL
+      PARAMETER (NF_PUT_REQ_ALL = -3)
 
 !
 ! PnetCDF APIs
diff --git a/src/libf90/Makefile.in b/src/libf90/Makefile.in
index fe9a55e..f90bbd8 100644
--- a/src/libf90/Makefile.in
+++ b/src/libf90/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2013, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2285 2015-12-30 20:48:25Z wkliao $
+# $Id: Makefile.in 2318 2016-02-04 00:18:26Z wkliao $
 #
 # @configure_input@
 
@@ -43,22 +43,22 @@ F90_SRCS = nf90_constants.f90 \
            file.f90 \
            dims.f90 \
            attributes.f90 \
-           variables.f90 \
-           pnetcdf.f90
+           variables.f90
 
 SRCS     = $(F90_SRCS) $(M4_SRCS:.m4=.f90) \
-           api.f90 nfmpi_constants.f90
+           pnetcdf.f90 api.f90 nfmpi_constants.f90
 
 LIB_OBJS = pnetcdf.o
 
 PACKING_LIST = $(F90_SRCS) \
                $(M4_SRCS) \
                Makefile.in \
+               pnetcdf.f90.in \
                api.f90.in \
                nfmpi_constants.f90.in
 
 GARBAGE		= $(PNETCDF_MOD) $(M4_SRCS:.m4=.f90)
-DIST_GARBAGE	= api.f90 nfmpi_constants.f90
+DIST_GARBAGE	= pnetcdf.f90 api.f90 nfmpi_constants.f90
 
 %.mod: %.f90 $(SRCS)
 	$(COMPILE.f90) $<
diff --git a/src/libf90/api.f90.in b/src/libf90/api.f90.in
index a277c0a..192bab6 100644
--- a/src/libf90/api.f90.in
+++ b/src/libf90/api.f90.in
@@ -2,7 +2,7 @@
 !  Copyright (C) 2013, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: api.f90.in 2221 2015-12-12 00:39:15Z wkliao $
+! $Id: api.f90.in 2318 2016-02-04 00:18:26Z wkliao $
 !
 
 !
@@ -69,7 +69,7 @@ INTERFACE
     END FUNCTION   nfmpi_enddef
 
     INTEGER        FUNCTION nfmpi__enddef(ncid, h_minfree, v_align, v_minfree, r_align)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: h_minfree
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: v_align
@@ -161,7 +161,7 @@ INTERFACE
 !
 
     INTEGER        FUNCTION nfmpi_def_dim(ncid, name, len, dimid)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             CHARACTER(len=*),              INTENT(IN)  :: name
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: len
@@ -175,7 +175,7 @@ INTERFACE
     END FUNCTION   nfmpi_inq_dimid
 
     INTEGER        FUNCTION nfmpi_inq_dim(ncid, dimid, name, len)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: dimid
                             CHARACTER(len=*),              INTENT(OUT) :: name
@@ -189,7 +189,7 @@ INTERFACE
     END FUNCTION   nfmpi_inq_dimname
 
     INTEGER        FUNCTION nfmpi_inq_dimlen(ncid, dimid, len)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: dimid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: len
@@ -206,7 +206,7 @@ INTERFACE
 !
 
     INTEGER        FUNCTION nfmpi_inq_att(ncid, varid, name, xtype, len)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             CHARACTER(len=*),              INTENT(IN)  :: name
@@ -229,7 +229,7 @@ INTERFACE
     END FUNCTION   nfmpi_inq_atttype
 
     INTEGER        FUNCTION nfmpi_inq_attlen(ncid, varid, name, len)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             CHARACTER(len=*),              INTENT(IN)  :: name
@@ -269,7 +269,7 @@ INTERFACE
 !
 
     INTEGER        FUNCTION nfmpi_put_att_text(ncid, varid, name, len, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             CHARACTER(len=*),              INTENT(IN)  :: name
@@ -285,7 +285,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_att_text
 
     INTEGER        FUNCTION nfmpi_put_att_int1(ncid, varid, name, xtype, len, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -304,7 +304,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_att_int1
 
     INTEGER        FUNCTION nfmpi_put_att_int2(ncid, varid, name, xtype, len, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -323,7 +323,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_att_int2
 
     INTEGER        FUNCTION nfmpi_put_att_int(ncid, varid, name, xtype, len, IVALS)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             CHARACTER(len=*),              INTENT(IN)  :: name
@@ -340,7 +340,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_att_int
 
     INTEGER        FUNCTION nfmpi_put_att_real(ncid, varid, name, xtype, len, RVALS)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             CHARACTER(len=*),              INTENT(IN)  :: name
@@ -357,7 +357,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_att_real
 
     INTEGER        FUNCTION nfmpi_put_att_double(ncid, varid, name, xtype, len, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             CHARACTER(len=*),              INTENT(IN)  :: name
@@ -374,7 +374,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_att_double
 
     INTEGER        FUNCTION nfmpi_put_att_int8(ncid, varid, name, xtype, len, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -482,7 +482,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_inq_var_fill
 
     INTEGER        FUNCTION nfmpi_fill_var_rec(ncid, varid, recno)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: recno
@@ -698,7 +698,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_get_var1_all
 
     INTEGER        FUNCTION nfmpi_put_var1_text(ncid, varid, index, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -706,7 +706,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_text
 
     INTEGER        FUNCTION nfmpi_put_var1_text_all(ncid, varid, index, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -714,7 +714,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_text_all
 
     INTEGER        FUNCTION nfmpi_get_var1_text(ncid, varid, index, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -722,7 +722,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_text
 
     INTEGER        FUNCTION nfmpi_get_var1_text_all(ncid, varid, index, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -730,7 +730,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_text_all
 
     INTEGER        FUNCTION nfmpi_put_var1_int1(ncid, varid, index, i1val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -739,7 +739,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int1
 
     INTEGER        FUNCTION nfmpi_put_var1_int1_all(ncid, varid, index, i1val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -748,7 +748,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int1_all
 
     INTEGER        FUNCTION nfmpi_get_var1_int1(ncid, varid, index, i1val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -757,7 +757,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_int1
 
     INTEGER        FUNCTION nfmpi_get_var1_int1_all(ncid, varid, index, i1val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -766,7 +766,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_int1_all
 
     INTEGER        FUNCTION nfmpi_put_var1_int2(ncid, varid, index, i2val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -775,7 +775,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int2
 
     INTEGER        FUNCTION nfmpi_put_var1_int2_all(ncid, varid, index, i2val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -784,7 +784,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int2_all
 
     INTEGER        FUNCTION nfmpi_get_var1_int2(ncid, varid, index, i2val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -793,7 +793,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_int2
 
     INTEGER        FUNCTION nfmpi_get_var1_int2_all(ncid, varid, index, i2val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -802,7 +802,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_int2_all
 
     INTEGER        FUNCTION nfmpi_put_var1_int(ncid, varid, index, ival)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -810,7 +810,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int
 
     INTEGER        FUNCTION nfmpi_put_var1_int_all(ncid, varid, index, ival)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -818,7 +818,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int_all
 
     INTEGER        FUNCTION nfmpi_get_var1_int(ncid, varid, index, ival)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -826,7 +826,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_int
 
     INTEGER        FUNCTION nfmpi_get_var1_int_all(ncid, varid, index, ival)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -834,7 +834,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_int_all
 
     INTEGER        FUNCTION nfmpi_put_var1_real(ncid, varid, index, rval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -842,7 +842,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_real
 
     INTEGER        FUNCTION nfmpi_put_var1_real_all(ncid, varid, index, rval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -850,7 +850,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_real_all
 
     INTEGER        FUNCTION nfmpi_get_var1_real(ncid, varid, index, rval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -858,7 +858,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_real
 
     INTEGER        FUNCTION nfmpi_get_var1_real_all(ncid, varid, index, rval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -866,7 +866,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_real_all
 
     INTEGER        FUNCTION nfmpi_put_var1_double(ncid, varid, index, dval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -874,7 +874,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_double
 
     INTEGER        FUNCTION nfmpi_put_var1_double_all(ncid, varid, index, dval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -882,7 +882,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_double_all
 
     INTEGER        FUNCTION nfmpi_get_var1_double(ncid, varid, index, dval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -890,7 +890,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_double
 
     INTEGER        FUNCTION nfmpi_get_var1_double_all(ncid, varid, index, dval)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -898,7 +898,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_double_all
 
     INTEGER        FUNCTION nfmpi_put_var1_int8(ncid, varid, index, i8val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -907,7 +907,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int8
 
     INTEGER        FUNCTION nfmpi_put_var1_int8_all(ncid, varid, index, i8val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -916,7 +916,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_var1_int8_all
 
     INTEGER        FUNCTION nfmpi_get_var1_int8(ncid, varid, index, i8val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -925,7 +925,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_var1_int8
 
     INTEGER        FUNCTION nfmpi_get_var1_int8_all(ncid, varid, index, i8val)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -981,7 +981,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_get_vara_all
 
     INTEGER        FUNCTION nfmpi_put_vara_text(ncid, varid, start, count, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -990,7 +990,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_text
 
     INTEGER        FUNCTION nfmpi_put_vara_text_all(ncid, varid, start, count, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -999,7 +999,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_text_all
 
     INTEGER        FUNCTION nfmpi_get_vara_text(ncid, varid, start, count, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1008,7 +1008,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_text
 
     INTEGER        FUNCTION nfmpi_get_vara_text_all(ncid, varid, start, count, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1017,7 +1017,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_text_all
 
     INTEGER        FUNCTION nfmpi_put_vara_int1(ncid, varid, start, count, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1027,7 +1027,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int1
 
     INTEGER        FUNCTION nfmpi_put_vara_int1_all(ncid, varid, start, count, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1037,7 +1037,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int1_all
 
     INTEGER        FUNCTION nfmpi_get_vara_int1(ncid, varid, start, count, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1047,7 +1047,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_int1
 
     INTEGER        FUNCTION nfmpi_get_vara_int1_all(ncid, varid, start, count, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1057,7 +1057,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_int1_all
 
     INTEGER        FUNCTION nfmpi_put_vara_int2(ncid, varid, start, count, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1067,7 +1067,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int2
 
     INTEGER        FUNCTION nfmpi_put_vara_int2_all(ncid, varid, start, count, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1077,7 +1077,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int2_all
 
     INTEGER        FUNCTION nfmpi_get_vara_int2(ncid, varid, start, count, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1087,7 +1087,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_int2
 
     INTEGER        FUNCTION nfmpi_get_vara_int2_all(ncid, varid, start, count, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1097,7 +1097,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_int2_all
 
     INTEGER        FUNCTION nfmpi_put_vara_int(ncid, varid, start, count, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1106,7 +1106,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int
 
     INTEGER        FUNCTION nfmpi_put_vara_int_all(ncid, varid, start, count, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1115,7 +1115,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int_all
 
     INTEGER        FUNCTION nfmpi_get_vara_int(ncid, varid, start, count, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1124,7 +1124,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_int
 
     INTEGER        FUNCTION nfmpi_get_vara_int_all(ncid, varid, start, count, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1133,7 +1133,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_int_all
 
     INTEGER        FUNCTION nfmpi_put_vara_real(ncid, varid, start, count, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1142,7 +1142,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_real
 
     INTEGER        FUNCTION nfmpi_put_vara_real_all(ncid, varid, start, count, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1151,7 +1151,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_real_all
 
     INTEGER        FUNCTION nfmpi_get_vara_real(ncid, varid, start, count, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1160,7 +1160,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_real
 
     INTEGER        FUNCTION nfmpi_get_vara_real_all(ncid, varid, start, count, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1169,7 +1169,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_real_all
 
     INTEGER        FUNCTION nfmpi_put_vara_double(ncid, varid, start, count, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1178,7 +1178,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_double
 
     INTEGER        FUNCTION nfmpi_put_vara_double_all(ncid, varid, start, count, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1187,7 +1187,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_double_all
 
     INTEGER        FUNCTION nfmpi_get_vara_double(ncid, varid, start, count, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1196,7 +1196,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_double
 
     INTEGER        FUNCTION nfmpi_get_vara_double_all(ncid, varid, start, count, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1205,7 +1205,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_double_all
 
     INTEGER        FUNCTION nfmpi_put_vara_int8(ncid, varid, start, count, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1215,7 +1215,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int8
 
     INTEGER        FUNCTION nfmpi_put_vara_int8_all(ncid, varid, start, count, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1225,7 +1225,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vara_int8_all
 
     INTEGER        FUNCTION nfmpi_get_vara_int8(ncid, varid, start, count, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1235,7 +1235,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vara_int8
 
     INTEGER        FUNCTION nfmpi_get_vara_int8_all(ncid, varid, start, count, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1296,7 +1296,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_get_vars_all
 
     INTEGER        FUNCTION nfmpi_put_vars_text(ncid, varid, start, count, stride, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1306,7 +1306,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_text
 
     INTEGER        FUNCTION nfmpi_put_vars_text_all(ncid, varid, start, count, stride, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1316,7 +1316,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_text_all
 
     INTEGER        FUNCTION nfmpi_get_vars_text(ncid, varid, start, count, stride, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1326,7 +1326,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_text
 
     INTEGER        FUNCTION nfmpi_get_vars_text_all(ncid, varid, start, count, stride, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1336,7 +1336,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_text_all
 
     INTEGER        FUNCTION nfmpi_put_vars_int1(ncid, varid, start, count, stride, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1347,7 +1347,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int1
 
     INTEGER        FUNCTION nfmpi_put_vars_int1_all(ncid, varid, start, count, stride, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1358,7 +1358,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int1_all
 
     INTEGER        FUNCTION nfmpi_get_vars_int1(ncid, varid, start, count, stride, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1369,7 +1369,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_int1
 
     INTEGER        FUNCTION nfmpi_get_vars_int1_all(ncid, varid, start, count, stride, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1380,7 +1380,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_int1_all
 
     INTEGER        FUNCTION nfmpi_put_vars_int2(ncid, varid, start, count, stride, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1391,7 +1391,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int2
 
     INTEGER        FUNCTION nfmpi_put_vars_int2_all(ncid, varid, start, count, stride, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1402,7 +1402,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int2_all
 
     INTEGER        FUNCTION nfmpi_get_vars_int2(ncid, varid, start, count, stride, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1413,7 +1413,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_int2
 
     INTEGER        FUNCTION nfmpi_get_vars_int2_all(ncid, varid, start, count, stride, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1424,7 +1424,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_int2_all
 
     INTEGER        FUNCTION nfmpi_put_vars_int(ncid, varid, start, count, stride, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1434,7 +1434,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int
 
     INTEGER        FUNCTION nfmpi_put_vars_int_all(ncid, varid, start, count, stride, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1444,7 +1444,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int_all
 
     INTEGER        FUNCTION nfmpi_get_vars_int(ncid, varid, start, count, stride, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1454,7 +1454,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_int
 
     INTEGER        FUNCTION nfmpi_get_vars_int_all(ncid, varid, start, count, stride, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1464,7 +1464,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_int_all
 
     INTEGER        FUNCTION nfmpi_put_vars_real(ncid, varid, start, count, stride, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1474,7 +1474,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_real
 
     INTEGER        FUNCTION nfmpi_put_vars_real_all(ncid, varid, start, count, stride, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1484,7 +1484,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_real_all
 
     INTEGER        FUNCTION nfmpi_get_vars_real(ncid, varid, start, count, stride, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1494,7 +1494,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_real
 
     INTEGER        FUNCTION nfmpi_get_vars_real_all(ncid, varid, start, count, stride, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1504,7 +1504,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_real_all
 
     INTEGER        FUNCTION nfmpi_put_vars_double(ncid, varid, start, count, stride, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1514,7 +1514,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_double
 
     INTEGER        FUNCTION nfmpi_put_vars_double_all(ncid, varid, start, count, stride, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1524,7 +1524,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_double_all
 
     INTEGER        FUNCTION nfmpi_get_vars_double(ncid, varid, start, count, stride, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1534,7 +1534,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_double
 
     INTEGER        FUNCTION nfmpi_get_vars_double_all(ncid, varid, start, count, stride, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1544,7 +1544,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_double_all
 
     INTEGER        FUNCTION nfmpi_put_vars_int8(ncid, varid, start, count, stride, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1555,7 +1555,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int8
 
     INTEGER        FUNCTION nfmpi_put_vars_int8_all(ncid, varid, start, count, stride, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1566,7 +1566,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_vars_int8_all
 
     INTEGER        FUNCTION nfmpi_get_vars_int8(ncid, varid, start, count, stride, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1577,7 +1577,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_vars_int8
 
     INTEGER        FUNCTION nfmpi_get_vars_int8_all(ncid, varid, start, count, stride, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1643,7 +1643,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_get_varm_all
 
     INTEGER        FUNCTION nfmpi_put_varm_text(ncid, varid, start, count, stride, imap, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1654,7 +1654,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_text
 
     INTEGER        FUNCTION nfmpi_put_varm_text_all(ncid, varid, start, count, stride, imap, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1665,7 +1665,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_text_all
 
     INTEGER        FUNCTION nfmpi_get_varm_text(ncid, varid, start, count, stride, imap, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1676,7 +1676,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_text
 
     INTEGER        FUNCTION nfmpi_get_varm_text_all(ncid, varid, start, count, stride, imap, text)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1687,7 +1687,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_text_all
 
     INTEGER        FUNCTION nfmpi_put_varm_int1(ncid, varid, start, count, stride, imap, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1699,7 +1699,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int1
 
     INTEGER        FUNCTION nfmpi_put_varm_int1_all(ncid, varid, start, count, stride, imap, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1711,7 +1711,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int1_all
 
     INTEGER        FUNCTION nfmpi_get_varm_int1(ncid, varid, start, count, stride, imap, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1723,7 +1723,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_int1
 
     INTEGER        FUNCTION nfmpi_get_varm_int1_all(ncid, varid, start, count, stride, imap, i1vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1735,7 +1735,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_int1_all
 
     INTEGER        FUNCTION nfmpi_put_varm_int2(ncid, varid, start, count, stride, imap, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1747,7 +1747,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int2
 
     INTEGER        FUNCTION nfmpi_put_varm_int2_all(ncid, varid, start, count, stride, imap, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1759,7 +1759,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int2_all
 
     INTEGER        FUNCTION nfmpi_get_varm_int2(ncid, varid, start, count, stride, imap, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1771,7 +1771,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_int2
 
     INTEGER        FUNCTION nfmpi_get_varm_int2_all(ncid, varid, start, count, stride, imap, i2vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1783,7 +1783,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_int2_all
 
     INTEGER        FUNCTION nfmpi_put_varm_int (ncid, varid, start, count, stride, imap, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1794,7 +1794,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int
 
     INTEGER        FUNCTION nfmpi_put_varm_int_all(ncid, varid, start, count, stride, imap, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1805,7 +1805,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int_all
 
     INTEGER        FUNCTION nfmpi_get_varm_int (ncid, varid, start, count, stride, imap, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1816,7 +1816,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_int
 
     INTEGER        FUNCTION nfmpi_get_varm_int_all(ncid, varid, start, count, stride, imap, ivals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1827,7 +1827,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_int_all
 
     INTEGER        FUNCTION nfmpi_put_varm_real(ncid, varid, start, count, stride, imap, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1838,7 +1838,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_real
 
     INTEGER        FUNCTION nfmpi_put_varm_real_all(ncid, varid, start, count, stride, imap, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1849,7 +1849,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_real_all
 
     INTEGER        FUNCTION nfmpi_get_varm_real(ncid, varid, start, count, stride, imap, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1860,7 +1860,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_real
 
     INTEGER        FUNCTION nfmpi_get_varm_real_all(ncid, varid, start, count, stride, imap, rvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1871,7 +1871,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_real_all
 
     INTEGER        FUNCTION nfmpi_put_varm_double(ncid, varid, start, count, stride, imap, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1882,7 +1882,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_double
 
     INTEGER        FUNCTION nfmpi_put_varm_double_all(ncid, varid, start, count, stride, imap, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1893,7 +1893,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_double_all
 
     INTEGER        FUNCTION nfmpi_get_varm_double(ncid, varid, start, count, stride, imap, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1904,7 +1904,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_double
 
     INTEGER        FUNCTION nfmpi_get_varm_double_all(ncid, varid, start, count, stride, imap, dvals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -1915,7 +1915,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_double_all
 
     INTEGER        FUNCTION nfmpi_put_varm_int8(ncid, varid, start, count, stride, imap, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1927,7 +1927,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int8
 
     INTEGER        FUNCTION nfmpi_put_varm_int8_all(ncid, varid, start, count, stride, imap, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1939,7 +1939,7 @@ INTERFACE
     END FUNCTION   nfmpi_put_varm_int8_all
 
     INTEGER        FUNCTION nfmpi_get_varm_int8(ncid, varid, start, count, stride, imap, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -1951,7 +1951,7 @@ INTERFACE
     END FUNCTION   nfmpi_get_varm_int8
 
     INTEGER        FUNCTION nfmpi_get_varm_int8_all(ncid, varid, start, count, stride, imap, i8vals)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2124,7 +2124,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_iget_var1
 
     INTEGER        FUNCTION nfmpi_iput_var1_text(ncid, varid, index, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2133,7 +2133,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_var1_text
 
     INTEGER        FUNCTION nfmpi_iget_var1_text(ncid, varid, index, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2142,7 +2142,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_var1_text
 
     INTEGER        FUNCTION nfmpi_iput_var1_int1(ncid, varid, index, i1val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2152,7 +2152,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_var1_int1
 
     INTEGER        FUNCTION nfmpi_iget_var1_int1(ncid, varid, index, i1val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2162,7 +2162,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_var1_int1
 
     INTEGER        FUNCTION nfmpi_iput_var1_int2(ncid, varid, index, i2val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2172,7 +2172,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_var1_int2
 
     INTEGER        FUNCTION nfmpi_iget_var1_int2(ncid, varid, index, i2val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2182,7 +2182,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_var1_int2
 
     INTEGER        FUNCTION nfmpi_iput_var1_int(ncid, varid, index, ival, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2191,7 +2191,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_var1_int
 
     INTEGER        FUNCTION nfmpi_iget_var1_int(ncid, varid, index, ival, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2200,7 +2200,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_var1_int
 
     INTEGER        FUNCTION nfmpi_iput_var1_real(ncid, varid, index, rval, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2209,7 +2209,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_var1_real
 
     INTEGER        FUNCTION nfmpi_iget_var1_real(ncid, varid, index, rval, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2218,7 +2218,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_var1_real
 
     INTEGER        FUNCTION nfmpi_iput_var1_double(ncid, varid, index, dval, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2227,7 +2227,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_var1_double
 
     INTEGER        FUNCTION nfmpi_iget_var1_double(ncid, varid, index, dval, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2236,7 +2236,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_var1_double
 
     INTEGER        FUNCTION nfmpi_iput_var1_int8(ncid, varid, index, i8val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2246,7 +2246,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_var1_int8
 
     INTEGER        FUNCTION nfmpi_iget_var1_int8(ncid, varid, index, i8val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2285,7 +2285,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_iget_vara
 
     INTEGER        FUNCTION nfmpi_iput_vara_text(ncid, varid, start, count, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2295,7 +2295,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vara_text
 
     INTEGER        FUNCTION nfmpi_iget_vara_text(ncid, varid, start, count, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2305,7 +2305,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vara_text
 
     INTEGER        FUNCTION nfmpi_iput_vara_int1(ncid, varid, start, count, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2316,7 +2316,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vara_int1
 
     INTEGER        FUNCTION nfmpi_iget_vara_int1(ncid, varid, start, count, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2327,7 +2327,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vara_int1
 
     INTEGER        FUNCTION nfmpi_iput_vara_int2(ncid, varid, start, count, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2338,7 +2338,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vara_int2
 
     INTEGER        FUNCTION nfmpi_iget_vara_int2(ncid, varid, start, count, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2349,7 +2349,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vara_int2
 
     INTEGER        FUNCTION nfmpi_iput_vara_int(ncid, varid, start, count, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2359,7 +2359,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vara_int
 
     INTEGER        FUNCTION nfmpi_iget_vara_int(ncid, varid, start, count, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2369,7 +2369,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vara_int
 
     INTEGER        FUNCTION nfmpi_iput_vara_real(ncid, varid, start, count, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2379,7 +2379,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vara_real
 
     INTEGER        FUNCTION nfmpi_iget_vara_real(ncid, varid, start, count, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2389,7 +2389,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vara_real
 
     INTEGER        FUNCTION nfmpi_iput_vara_double(ncid, varid, start, count, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2399,7 +2399,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vara_double
 
     INTEGER        FUNCTION nfmpi_iget_vara_double(ncid, varid, start, count, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2409,7 +2409,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vara_double
 
     INTEGER        FUNCTION nfmpi_iput_vara_int8(ncid, varid, start, count, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2420,7 +2420,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vara_int8
 
     INTEGER        FUNCTION nfmpi_iget_vara_int8(ncid, varid, start, count, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2462,7 +2462,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_iget_vars
 
     INTEGER        FUNCTION nfmpi_iput_vars_text(ncid, varid, start, count, stride, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2473,7 +2473,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vars_text
 
     INTEGER        FUNCTION nfmpi_iget_vars_text(ncid, varid, start, count, stride, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2484,7 +2484,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vars_text
 
     INTEGER        FUNCTION nfmpi_iput_vars_int1(ncid, varid, start, count, stride, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2496,7 +2496,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vars_int1
 
     INTEGER        FUNCTION nfmpi_iget_vars_int1(ncid, varid, start, count, stride, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2508,7 +2508,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vars_int1
 
     INTEGER        FUNCTION nfmpi_iput_vars_int2(ncid, varid, start, count, stride, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2520,7 +2520,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vars_int2
 
     INTEGER        FUNCTION nfmpi_iget_vars_int2(ncid, varid, start, count, stride, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2532,7 +2532,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vars_int2
 
     INTEGER        FUNCTION nfmpi_iput_vars_int(ncid, varid, start, count, stride, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2543,7 +2543,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vars_int
 
     INTEGER        FUNCTION nfmpi_iget_vars_int(ncid, varid, start, count, stride, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2554,7 +2554,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vars_int
 
     INTEGER        FUNCTION nfmpi_iput_vars_real(ncid, varid, start, count, stride, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2565,7 +2565,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vars_real
 
     INTEGER        FUNCTION nfmpi_iget_vars_real(ncid, varid, start, count, stride, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2576,7 +2576,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vars_real
 
     INTEGER        FUNCTION nfmpi_iput_vars_double(ncid, varid, start, count, stride, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2587,7 +2587,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vars_double
 
     INTEGER        FUNCTION nfmpi_iget_vars_double(ncid, varid, start, count, stride, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2598,7 +2598,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_vars_double
 
     INTEGER        FUNCTION nfmpi_iput_vars_int8(ncid, varid, start, count, stride, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2610,7 +2610,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_vars_int8
 
     INTEGER        FUNCTION nfmpi_iget_vars_int8(ncid, varid, start, count, stride, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2655,7 +2655,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_iget_varm
 
     INTEGER        FUNCTION nfmpi_iput_varm_text(ncid, varid, start, count, stride, imap, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2667,7 +2667,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_varm_text
 
     INTEGER        FUNCTION nfmpi_iget_varm_text(ncid, varid, start, count, stride, imap, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2679,7 +2679,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_varm_text
 
     INTEGER        FUNCTION nfmpi_iput_varm_int1(ncid, varid, start, count, stride, imap, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2692,7 +2692,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_varm_int1
 
     INTEGER        FUNCTION nfmpi_iget_varm_int1(ncid, varid, start, count, stride, imap, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2705,7 +2705,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_varm_int1
 
     INTEGER        FUNCTION nfmpi_iput_varm_int2(ncid, varid, start, count, stride, imap, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2718,7 +2718,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_varm_int2
 
     INTEGER        FUNCTION nfmpi_iget_varm_int2(ncid, varid, start, count, stride, imap, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2731,7 +2731,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_varm_int2
 
     INTEGER        FUNCTION nfmpi_iput_varm_int (ncid, varid, start, count, stride, imap, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2743,7 +2743,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_varm_int
 
     INTEGER        FUNCTION nfmpi_iget_varm_int (ncid, varid, start, count, stride, imap, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2755,7 +2755,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_varm_int
 
     INTEGER        FUNCTION nfmpi_iput_varm_real(ncid, varid, start, count, stride, imap, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2767,7 +2767,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_varm_real
 
     INTEGER        FUNCTION nfmpi_iget_varm_real(ncid, varid, start, count, stride, imap, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2779,7 +2779,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_varm_real
 
     INTEGER        FUNCTION nfmpi_iput_varm_double(ncid, varid, start, count, stride, imap, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2791,7 +2791,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_varm_double
 
     INTEGER        FUNCTION nfmpi_iget_varm_double(ncid, varid, start, count, stride, imap, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -2803,7 +2803,7 @@ INTERFACE
     END FUNCTION   nfmpi_iget_varm_double
 
     INTEGER        FUNCTION nfmpi_iput_varm_int8(ncid, varid, start, count, stride, imap, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2816,7 +2816,7 @@ INTERFACE
     END FUNCTION   nfmpi_iput_varm_int8
 
     INTEGER        FUNCTION nfmpi_iget_varm_int8(ncid, varid, start, count, stride, imap, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2929,7 +2929,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_bget_var1
 
     INTEGER        FUNCTION nfmpi_bput_var1_text(ncid, varid, index, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2938,7 +2938,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_var1_text
 
     INTEGER        FUNCTION nfmpi_bput_var1_int1(ncid, varid, index, i1val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2948,7 +2948,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_var1_int1
 
     INTEGER        FUNCTION nfmpi_bput_var1_int2(ncid, varid, index, i2val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -2958,7 +2958,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_var1_int2
 
     INTEGER        FUNCTION nfmpi_bput_var1_int(ncid, varid, index, ival, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2967,7 +2967,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_var1_int
 
     INTEGER        FUNCTION nfmpi_bput_var1_real(ncid, varid, index, rval, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2976,7 +2976,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_var1_real
 
     INTEGER        FUNCTION nfmpi_bput_var1_double(ncid, varid, index, dval, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: index(*)
@@ -2985,7 +2985,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_var1_double
 
     INTEGER        FUNCTION nfmpi_bput_var1_int8(ncid, varid, index, i8val, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3020,7 +3020,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_bget_vara
 
     INTEGER        FUNCTION nfmpi_bput_vara_text(ncid, varid, start, count, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3030,7 +3030,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vara_text
 
     INTEGER        FUNCTION nfmpi_bput_vara_int1(ncid, varid, start, count, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3041,7 +3041,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vara_int1
 
     INTEGER        FUNCTION nfmpi_bput_vara_int2(ncid, varid, start, count, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3052,7 +3052,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vara_int2
 
     INTEGER        FUNCTION nfmpi_bput_vara_int(ncid, varid, start, count, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3062,7 +3062,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vara_int
 
     INTEGER        FUNCTION nfmpi_bput_vara_real(ncid, varid, start, count, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3072,7 +3072,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vara_real
 
     INTEGER        FUNCTION nfmpi_bput_vara_double(ncid, varid, start, count, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3082,7 +3082,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vara_double
 
     INTEGER        FUNCTION nfmpi_bput_vara_int8(ncid, varid, start, count, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3120,7 +3120,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_bget_vars
 
     INTEGER        FUNCTION nfmpi_bput_vars_text(ncid, varid, start, count, stride, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3131,7 +3131,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vars_text
 
     INTEGER        FUNCTION nfmpi_bput_vars_int1(ncid, varid, start, count, stride, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3143,7 +3143,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vars_int1
 
     INTEGER        FUNCTION nfmpi_bput_vars_int2(ncid, varid, start, count, stride, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3155,7 +3155,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vars_int2
 
     INTEGER        FUNCTION nfmpi_bput_vars_int(ncid, varid, start, count, stride, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3166,7 +3166,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vars_int
 
     INTEGER        FUNCTION nfmpi_bput_vars_real(ncid, varid, start, count, stride, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3177,7 +3177,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vars_real
 
     INTEGER        FUNCTION nfmpi_bput_vars_double(ncid, varid, start, count, stride, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3188,7 +3188,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_vars_double
 
     INTEGER        FUNCTION nfmpi_bput_vars_int8(ncid, varid, start, count, stride, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3229,7 +3229,7 @@ INTERFACE
 !   END FUNCTION   nfmpi_bget_varm
 
     INTEGER        FUNCTION nfmpi_bput_varm_text(ncid, varid, start, count, stride, imap, text, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3241,7 +3241,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_varm_text
 
     INTEGER        FUNCTION nfmpi_bput_varm_int1(ncid, varid, start, count, stride, imap, i1vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: OneByteInt = selected_int_kind(2)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3254,7 +3254,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_varm_int1
 
     INTEGER        FUNCTION nfmpi_bput_varm_int2(ncid, varid, start, count, stride, imap, i2vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: TwoByteInt = selected_int_kind(4)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3267,7 +3267,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_varm_int2
 
     INTEGER        FUNCTION nfmpi_bput_varm_int (ncid, varid, start, count, stride, imap, ivals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3279,7 +3279,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_varm_int
 
     INTEGER        FUNCTION nfmpi_bput_varm_real(ncid, varid, start, count, stride, imap, rvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3291,7 +3291,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_varm_real
 
     INTEGER        FUNCTION nfmpi_bput_varm_double(ncid, varid, start, count, stride, imap, dvals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: start(*)
@@ -3303,7 +3303,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_varm_double
 
     INTEGER        FUNCTION nfmpi_bput_varm_int8(ncid, varid, start, count, stride, imap, i8vals, req)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                    integer, parameter :: EightByteInt = selected_int_kind(18)
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
@@ -3316,7 +3316,7 @@ INTERFACE
     END FUNCTION   nfmpi_bput_varm_int8
 
     INTEGER        FUNCTION nfmpi_buffer_attach(ncid, bufsize)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN)  :: bufsize
     END FUNCTION   nfmpi_buffer_attach
@@ -3326,13 +3326,13 @@ INTERFACE
     END FUNCTION   nfmpi_buffer_detach
 
     INTEGER        FUNCTION nfmpi_inq_buffer_usage(ncid, usage)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: usage
     END FUNCTION   nfmpi_inq_buffer_usage
 
     INTEGER        FUNCTION nfmpi_inq_buffer_size(ncid, buf_size)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: buf_size
     END FUNCTION   nfmpi_inq_buffer_size
@@ -3363,31 +3363,31 @@ INTERFACE
     END FUNCTION   nfmpi_cancel
 
     INTEGER        FUNCTION nfmpi_inq_put_size(ncid, size)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: size
     END FUNCTION   nfmpi_inq_put_size
 
     INTEGER        FUNCTION nfmpi_inq_get_size(ncid, size)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: size
     END FUNCTION   nfmpi_inq_get_size
 
     INTEGER        FUNCTION nfmpi_inq_header_size(ncid, size)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: size
     END FUNCTION   nfmpi_inq_header_size
 
     INTEGER        FUNCTION nfmpi_inq_header_extent(ncid, extent)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: extent
     END FUNCTION   nfmpi_inq_header_extent
 
     INTEGER        FUNCTION nfmpi_inq_varoffset(ncid, varid, offset)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER,                       INTENT(IN)  :: varid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: offset
@@ -3399,12 +3399,12 @@ INTERFACE
     END FUNCTION   nfmpi_inq_nreqs
 
     INTEGER        FUNCTION nfmpi_inq_malloc_size(size)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: size
     END FUNCTION   nfmpi_inq_malloc_size
 
     INTEGER        FUNCTION nfmpi_inq_malloc_max_size(size)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: size
     END FUNCTION   nfmpi_inq_malloc_max_size
 
@@ -3417,7 +3417,7 @@ INTERFACE
     END FUNCTION   nfmpi_inq_files_opened
 
     INTEGER        FUNCTION nfmpi_inq_recsize(ncid, recsize)
-                   use mpi, only: MPI_OFFSET_KIND
+                   @USE_MPIF_HEADER@
                             INTEGER,                       INTENT(IN)  :: ncid
                             INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: recsize
     END FUNCTION   nfmpi_inq_recsize
@@ -3475,7 +3475,7 @@ INTERFACE
 
 
     INTEGER FUNCTION nfmpi_get_varn_text(ncid, varid, num, starts, counts, text)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3485,7 +3485,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_text
 
     INTEGER FUNCTION nfmpi_get_varn_int1(ncid, varid, num, starts, counts, i1vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: OneByteInt = selected_int_kind(2)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3496,7 +3496,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_int1
 
     INTEGER FUNCTION nfmpi_get_varn_int2(ncid, varid, num, starts, counts, i2vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: TwoByteInt = selected_int_kind(4)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3507,7 +3507,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_int2
 
     INTEGER FUNCTION nfmpi_get_varn_int(ncid, varid, num, starts, counts, ivals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3517,7 +3517,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_int
 
     INTEGER FUNCTION nfmpi_get_varn_real(ncid, varid, num, starts, counts, rvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3527,7 +3527,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_real
 
     INTEGER FUNCTION nfmpi_get_varn_double(ncid, varid, num, starts, counts, dvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3537,7 +3537,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_double
 
     INTEGER FUNCTION nfmpi_get_varn_int8(ncid, varid, num, starts, counts, i8vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: EightByteInt = selected_int_kind(18)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3548,7 +3548,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_int8
 
     INTEGER FUNCTION nfmpi_get_varn_text_all(ncid, varid, num, starts, counts, text)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3558,7 +3558,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_text_all
 
     INTEGER FUNCTION nfmpi_get_varn_int1_all(ncid, varid, num, starts, counts, i1vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: OneByteInt = selected_int_kind(2)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3569,7 +3569,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_int1_all
 
     INTEGER FUNCTION nfmpi_get_varn_int2_all(ncid, varid, num, starts, counts, i2vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: TwoByteInt = selected_int_kind(4)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3580,7 +3580,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_int2_all
 
     INTEGER FUNCTION nfmpi_get_varn_int_all(ncid, varid, num, starts, counts, ivals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3590,7 +3590,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_int_all
 
     INTEGER FUNCTION nfmpi_get_varn_real_all(ncid, varid, num, starts, counts, rvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3600,7 +3600,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_real_all
 
     INTEGER FUNCTION nfmpi_get_varn_double_all(ncid, varid, num, starts, counts, dvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3610,7 +3610,7 @@ INTERFACE
     END FUNCTION nfmpi_get_varn_double_all
 
     INTEGER FUNCTION nfmpi_get_varn_int8_all(ncid, varid, num, starts, counts, i8vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: EightByteInt = selected_int_kind(18)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3622,7 +3622,7 @@ INTERFACE
 
 
     INTEGER FUNCTION nfmpi_put_varn_text(ncid, varid, num, starts, counts, text)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3632,7 +3632,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_text
 
     INTEGER FUNCTION nfmpi_put_varn_int1(ncid, varid, num, starts, counts, i1vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: OneByteInt = selected_int_kind(2)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3643,7 +3643,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_int1
 
     INTEGER FUNCTION nfmpi_put_varn_int2(ncid, varid, num, starts, counts, i2vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: TwoByteInt = selected_int_kind(4)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3654,7 +3654,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_int2
 
     INTEGER FUNCTION nfmpi_put_varn_int(ncid, varid, num, starts, counts, ivals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3664,7 +3664,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_int
 
     INTEGER FUNCTION nfmpi_put_varn_real(ncid, varid, num, starts, counts, rvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3674,7 +3674,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_real
 
     INTEGER FUNCTION nfmpi_put_varn_double(ncid, varid, num, starts, counts, dvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3684,7 +3684,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_double
 
     INTEGER FUNCTION nfmpi_put_varn_int8(ncid, varid, num, starts, counts, i8vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: EightByteInt = selected_int_kind(18)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3695,7 +3695,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_int8
 
     INTEGER FUNCTION nfmpi_put_varn_text_all(ncid, varid, num, starts, counts, text)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3705,7 +3705,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_text_all
 
     INTEGER FUNCTION nfmpi_put_varn_int1_all(ncid, varid, num, starts, counts, i1vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: OneByteInt = selected_int_kind(2)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3716,7 +3716,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_int1_all
 
     INTEGER FUNCTION nfmpi_put_varn_int2_all(ncid, varid, num, starts, counts, i2vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: TwoByteInt = selected_int_kind(4)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3727,7 +3727,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_int2_all
 
     INTEGER FUNCTION nfmpi_put_varn_int_all(ncid, varid, num, starts, counts, ivals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3737,7 +3737,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_int_all
 
     INTEGER FUNCTION nfmpi_put_varn_real_all(ncid, varid, num, starts, counts, rvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3747,7 +3747,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_real_all
 
     INTEGER FUNCTION nfmpi_put_varn_double_all(ncid, varid, num, starts, counts, dvals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3757,7 +3757,7 @@ INTERFACE
     END FUNCTION nfmpi_put_varn_double_all
 
     INTEGER FUNCTION nfmpi_put_varn_int8_all(ncid, varid, num, starts, counts, i8vals)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: EightByteInt = selected_int_kind(18)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3795,7 +3795,7 @@ INTERFACE
 !   END FUNCTION nfmpi_iput_varn
 
     INTEGER FUNCTION nfmpi_iget_varn_text(ncid, varid, num, starts, counts, text, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3806,7 +3806,7 @@ INTERFACE
     END FUNCTION nfmpi_iget_varn_text
 
     INTEGER FUNCTION nfmpi_iget_varn_int1(ncid, varid, num, starts, counts, i1vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: OneByteInt = selected_int_kind(2)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3818,7 +3818,7 @@ INTERFACE
     END FUNCTION nfmpi_iget_varn_int1
 
     INTEGER FUNCTION nfmpi_iget_varn_int2(ncid, varid, num, starts, counts, i2vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: TwoByteInt = selected_int_kind(4)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3830,7 +3830,7 @@ INTERFACE
     END FUNCTION nfmpi_iget_varn_int2
 
     INTEGER FUNCTION nfmpi_iget_varn_int(ncid, varid, num, starts, counts, ivals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3841,7 +3841,7 @@ INTERFACE
     END FUNCTION nfmpi_iget_varn_int
 
     INTEGER FUNCTION nfmpi_iget_varn_real(ncid, varid, num, starts, counts, rvals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3852,7 +3852,7 @@ INTERFACE
     END FUNCTION nfmpi_iget_varn_real
 
     INTEGER FUNCTION nfmpi_iget_varn_double(ncid, varid, num, starts, counts, dvals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3863,7 +3863,7 @@ INTERFACE
     END FUNCTION nfmpi_iget_varn_double
 
     INTEGER FUNCTION nfmpi_iget_varn_int8(ncid, varid, num, starts, counts, i8vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: EightByteInt = selected_int_kind(18)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3875,7 +3875,7 @@ INTERFACE
     END FUNCTION nfmpi_iget_varn_int8
 
     INTEGER FUNCTION nfmpi_iput_varn_text(ncid, varid, num, starts, counts, text, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3886,7 +3886,7 @@ INTERFACE
     END FUNCTION nfmpi_iput_varn_text
 
     INTEGER FUNCTION nfmpi_iput_varn_int1(ncid, varid, num, starts, counts, i1vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: OneByteInt = selected_int_kind(2)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3898,7 +3898,7 @@ INTERFACE
     END FUNCTION nfmpi_iput_varn_int1
 
     INTEGER FUNCTION nfmpi_iput_varn_int2(ncid, varid, num, starts, counts, i2vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: TwoByteInt = selected_int_kind(4)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3910,7 +3910,7 @@ INTERFACE
     END FUNCTION nfmpi_iput_varn_int2
 
     INTEGER FUNCTION nfmpi_iput_varn_int(ncid, varid, num, starts, counts, ivals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3921,7 +3921,7 @@ INTERFACE
     END FUNCTION nfmpi_iput_varn_int
 
     INTEGER FUNCTION nfmpi_iput_varn_real(ncid, varid, num, starts, counts, rvals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3932,7 +3932,7 @@ INTERFACE
     END FUNCTION nfmpi_iput_varn_real
 
     INTEGER FUNCTION nfmpi_iput_varn_double(ncid, varid, num, starts, counts, dvals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3943,7 +3943,7 @@ INTERFACE
     END FUNCTION nfmpi_iput_varn_double
 
     INTEGER FUNCTION nfmpi_iput_varn_int8(ncid, varid, num, starts, counts, i8vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: EightByteInt = selected_int_kind(18)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3967,7 +3967,7 @@ INTERFACE
 !   END FUNCTION nfmpi_bput_varn
 
     INTEGER FUNCTION nfmpi_bput_varn_text(ncid, varid, num, starts, counts, text, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -3978,7 +3978,7 @@ INTERFACE
     END FUNCTION nfmpi_bput_varn_text
 
     INTEGER FUNCTION nfmpi_bput_varn_int1(ncid, varid, num, starts, counts, i1vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: OneByteInt = selected_int_kind(2)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -3990,7 +3990,7 @@ INTERFACE
     END FUNCTION nfmpi_bput_varn_int1
 
     INTEGER FUNCTION nfmpi_bput_varn_int2(ncid, varid, num, starts, counts, i2vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: TwoByteInt = selected_int_kind(4)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
@@ -4002,7 +4002,7 @@ INTERFACE
     END FUNCTION nfmpi_bput_varn_int2
 
     INTEGER FUNCTION nfmpi_bput_varn_int(ncid, varid, num, starts, counts, ivals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -4013,7 +4013,7 @@ INTERFACE
     END FUNCTION nfmpi_bput_varn_int
 
     INTEGER FUNCTION nfmpi_bput_varn_real(ncid, varid, num, starts, counts, rvals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -4024,7 +4024,7 @@ INTERFACE
     END FUNCTION nfmpi_bput_varn_real
 
     INTEGER FUNCTION nfmpi_bput_varn_double(ncid, varid, num, starts, counts, dvals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
                      INTEGER,                       INTENT(IN)  :: num
@@ -4035,7 +4035,7 @@ INTERFACE
     END FUNCTION nfmpi_bput_varn_double
 
     INTEGER FUNCTION nfmpi_bput_varn_int8(ncid, varid, num, starts, counts, i8vals, req)
-            use mpi, only: MPI_OFFSET_KIND
+            @USE_MPIF_HEADER@
             integer, parameter :: EightByteInt = selected_int_kind(18)
                      INTEGER,                       INTENT(IN)  :: ncid
                      INTEGER,                       INTENT(IN)  :: varid
diff --git a/src/libf90/nf90_constants.f90 b/src/libf90/nf90_constants.f90
index cc8caf2..93306b2 100644
--- a/src/libf90/nf90_constants.f90
+++ b/src/libf90/nf90_constants.f90
@@ -2,7 +2,7 @@
 !  Copyright (C) 2013, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: nf90_constants.f90 2195 2015-11-27 18:42:11Z wkliao $
+! $Id: nf90_constants.f90 2319 2016-02-04 08:04:01Z wkliao $
 !
 ! This file is taken from netcdf_constants.f90 with changes for PnetCDF use
 !
@@ -90,6 +90,8 @@
 
   ! indicate to flush all pending non-blocking requests
   integer, parameter, public :: nf90_req_all = -1
+  integer, parameter, public :: nf90_get_req_all = -2
+  integer, parameter, public :: nf90_put_req_all = -3
 
   !
   ! global attribute id:
diff --git a/src/libf90/nfmpi_constants.f90.in b/src/libf90/nfmpi_constants.f90.in
index 083f049..d72fa0f 100644
--- a/src/libf90/nfmpi_constants.f90.in
+++ b/src/libf90/nfmpi_constants.f90.in
@@ -2,7 +2,7 @@
 !  Copyright (C) 2013, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-! $Id: nfmpi_constants.f90.in 2195 2015-11-27 18:42:11Z wkliao $
+! $Id: nfmpi_constants.f90.in 2319 2016-02-04 08:04:01Z wkliao $
 !
 ! This file lists the Fortran constants used by PnetCDF
 !
@@ -295,7 +295,10 @@
 
 ! indicate to flush all pending non-blocking requests
       integer, parameter, public :: &
-      NF_REQ_ALL = -1
+      NF_REQ_ALL = -1, &
+      NF_GET_REQ_ALL = -2, &
+      NF_PUT_REQ_ALL = -3
+
 
 !ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 ! begin netcdf 2.4 backward compatibility:
diff --git a/src/libf90/pnetcdf.f90 b/src/libf90/pnetcdf.f90.in
similarity index 95%
rename from src/libf90/pnetcdf.f90
rename to src/libf90/pnetcdf.f90.in
index 3b1775c..0699429 100644
--- a/src/libf90/pnetcdf.f90
+++ b/src/libf90/pnetcdf.f90.in
@@ -8,9 +8,8 @@
 !
 !
  module pnetcdf
-  use mpi, only: MPI_OFFSET_KIND
+  @USE_MPIF_HEADER@
 
-  implicit none
   private
 
   integer, parameter ::   OneByteInt = selected_int_kind(2), &
diff --git a/src/utils/ncmpidump/ncmpidump.c b/src/utils/ncmpidump/ncmpidump.c
index d3dcac9..cf4695d 100644
--- a/src/utils/ncmpidump/ncmpidump.c
+++ b/src/utils/ncmpidump/ncmpidump.c
@@ -3,7 +3,7 @@
  *   See netcdf/README file for copying and redistribution conditions.
  *   $Header$
  *********************************************************************/
-/* $Id: ncmpidump.c 2060 2015-08-03 22:39:58Z wkliao $ */
+/* $Id: ncmpidump.c 2322 2016-02-26 22:47:06Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include <ncconfig.h>
@@ -609,13 +609,14 @@ set_sigdigs(const char *optarg)
         error("unreasonable value for float significant digits: %d",
               flt_digits);
 
-    if (*ptr1 == ',')
+    if (ptr1 && *ptr1 == ',') {
         dbl_digits = (int)strtol(ptr1+1, &ptr2, 10);
 
-    if (ptr2 == ptr1+1 || dbl_digits < 1 || dbl_digits > 20)
-        error("unreasonable value for double significant digits: %d",
-              dbl_digits);
-
+        if (ptr2 == ptr1+1 || dbl_digits < 1 || dbl_digits > 20) {
+            error("unreasonable value for double significant digits: %d",
+                  dbl_digits);
+        }
+    }
     set_formats(flt_digits, dbl_digits);
 }
 
@@ -642,15 +643,15 @@ set_precision(const char *optarg)
         error("unreasonable value for float significant digits: %d",
               flt_digits);
 
-    if (*ptr1 == ',') {
+    if (ptr1 && *ptr1 == ',') {
         dbl_digits = (int) strtol(ptr1+1, &ptr2, 10);
         double_precision_specified = 1;
+        if (ptr2 == ptr1+1 || dbl_digits < 1 || dbl_digits > 20) {
+            error("unreasonable value for double significant digits: %d",
+                  dbl_digits);
+        }
     }
 
-    if (ptr2 == ptr1+1 || dbl_digits < 1 || dbl_digits > 20)
-        error("unreasonable value for double significant digits: %d",
-              dbl_digits);
-
     set_formats(flt_digits, dbl_digits);
 }
 
diff --git a/src/utils/ncmpidump/vardata.c b/src/utils/ncmpidump/vardata.c
index 540d376..444e3b6 100644
--- a/src/utils/ncmpidump/vardata.c
+++ b/src/utils/ncmpidump/vardata.c
@@ -3,7 +3,7 @@
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
  *   $Header$
  *********************************************************************/
-/* $Id: vardata.c 1440 2013-10-05 03:47:56Z wkliao $ */
+/* $Id: vardata.c 2322 2016-02-26 22:47:06Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include <ncconfig.h>
@@ -730,7 +730,7 @@ vardata(
 
         /* to avoid residue contents from previous read, especially
            when read beyond the end of file (i.e. read size returned 0) */
-        memset(vals, 0, VALBUFSIZ);
+        if (vals) memset(vals, 0, VALBUFSIZ);
     }
     free(vals);
 
diff --git a/src/utils/ncmpigen/load.c b/src/utils/ncmpigen/load.c
index e7c8e14..0f4046a 100644
--- a/src/utils/ncmpigen/load.c
+++ b/src/utils/ncmpigen/load.c
@@ -1,7 +1,7 @@
 /*********************************************************************
  *   Copyright 1993, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: load.c 2243 2015-12-19 01:12:41Z wkliao $
+ *   $Id: load.c 2320 2016-02-24 13:18:32Z wkliao $
  *********************************************************************/
 
 #include <stdio.h>
@@ -81,6 +81,7 @@ gen_load_c(
     if (!vars[varnum].has_data)
 	return;
 
+    s2[0] = '\0';
     cline("");
     sprintf(stmnt, "   {\t\t\t/* store %s */", vars[varnum].name);
     cline(stmnt);
diff --git a/src/utils/ncmpivalid/ncmpivalid.c b/src/utils/ncmpivalid/ncmpivalid.c
index 9fbbf4a..59a9831 100644
--- a/src/utils/ncmpivalid/ncmpivalid.c
+++ b/src/utils/ncmpivalid/ncmpivalid.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: ncmpivalid.c 2299 2016-01-09 06:14:37Z wkliao $ */
+/* $Id: ncmpivalid.c 2335 2016-03-03 14:55:12Z wkliao $ */
 
 #if HAVE_CONFIG_H
 # include <ncconfig.h>
@@ -18,6 +18,7 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#include <errno.h>
 
 #include <mpi.h>
 
@@ -80,7 +81,10 @@ val_fetch(bufferinfo *gbp, MPI_Offset fsize) {
   gbp->pos = gbp->base;
   gbp->index = 0;
 
-  lseek(gbp->nciop->fd, gbp->offset-slack, SEEK_SET);
+  if (-1 == lseek(gbp->nciop->fd, gbp->offset-slack, SEEK_SET)) {
+      printf("Error at line %d: lseek %s\n",__LINE__,strerror(errno));
+      return -1;
+  }
   nn = read(gbp->nciop->fd, gbp->base, gbp->size);
   if (nn < gbp->size) {
       printf("Error: Unexpected EOF ");
diff --git a/src/utils/ncoffsets/ncoffsets.c b/src/utils/ncoffsets/ncoffsets.c
index 3eb876b..3c56294 100644
--- a/src/utils/ncoffsets/ncoffsets.c
+++ b/src/utils/ncoffsets/ncoffsets.c
@@ -2,7 +2,7 @@
  *  Copyright (C) 2015, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: ncoffsets.c 2302 2016-01-10 20:33:45Z wkliao $ */
+/* $Id: ncoffsets.c 2335 2016-03-03 14:55:12Z wkliao $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -169,7 +169,7 @@ typedef struct NC_vararray {
 
 typedef struct NC {
     int           flags;
-    char          path[1024];
+    char         *path;
     long long     xsz;      /* external size of this header, <= var[0].begin */
     long long     begin_var;/* file offset of the first (non-record) var */
     long long     begin_rec;/* file offset of the first 'record' */
@@ -1620,6 +1620,7 @@ ncmpii_free_NC(NC *ncp)
     ncmpii_free_NC_dimarray(&ncp->dims);
     ncmpii_free_NC_attrarray(&ncp->attrs);
     ncmpii_free_NC_vararray(&ncp->vars);
+    free(ncp->path);
 }
 
 const char *
@@ -1757,7 +1758,7 @@ usage(char *cmd)
 "                       the size of one record only\n"
 "       [-g]            Output gap from the previous variable\n"
 "       [-r]            Output offsets for all records\n"
-"       [-x]            Check gaps in fixed-size variables, ouput 1 if gaps\n"
+"       [-x]            Check gaps in fixed-size variables, output 1 if gaps\n"
 "                       are found, 0 for otherwise.\n"
 "       file            Input netCDF file name\n"
 "*Parallel netCDF library version 1.7.0\n";
@@ -1768,13 +1769,14 @@ usage(char *cmd)
 int main(int argc, char *argv[])
 {
     extern int optind;
-    char *filename, cmd[256], *env_str;
+    char *filename, *cmd, *env_str;
     int i, j, err, opt, nvars;
     int print_var_size=0, print_gap=0, check_gap=0, print_all_rec=0;
     NC *ncp;
     struct fspec *fspecp=NULL;
 
     fspecp = (struct fspec*) calloc(1, sizeof(struct fspec));
+    cmd = (char*) malloc(strlen(argv[0])+1);
     strcpy(cmd,argv[0]);
 
     /* get command-line arguments */
@@ -1808,6 +1810,7 @@ int main(int argc, char *argv[])
         free(fspecp);
         return 1;
     }
+    free(cmd);
     filename = argv[0]; /* required argument */
 
     verbose_debug = 0;
@@ -1825,6 +1828,7 @@ int main(int argc, char *argv[])
     }
 
     ncp = (NC*) calloc(1, sizeof(NC));
+    ncp->path = (char*) malloc(strlen(filename)+1);
     strcpy(ncp->path, filename);
 
     /* read the header from file */
diff --git a/test/Makefile.in b/test/Makefile.in
index a5fdd02..5ee7a0b 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2003, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2249 2015-12-20 20:36:46Z wkliao $
+# $Id: Makefile.in 2318 2016-02-04 00:18:26Z wkliao $
 #
 # @configure_input@
 
@@ -33,9 +33,11 @@ endif
 
 ifeq (@has_fortran@, yes)
 SUBDIRS += nf_test
+ifeq (@mpi_mod@, yes)
 SUBDIRS += nf90_test
 SUBDIRS += F90
 endif
+endif
 
 ifeq (@enable_subfiling@, yes)
 SUBDIRS += subfile
diff --git a/test/nc_test/test_get.m4 b/test/nc_test/test_get.m4
index 7d91848..ac393f3 100644
--- a/test/nc_test/test_get.m4
+++ b/test/nc_test/test_get.m4
@@ -8,7 +8,7 @@ dnl
  *  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
  *  See COPYRIGHT notice in top-level directory.
  */
-/* $Id: test_get.m4 2292 2016-01-04 05:30:45Z wkliao $ */
+/* $Id: test_get.m4 2311 2016-01-30 01:01:40Z wkliao $ */
 
 
 undefine(`index')dnl
@@ -918,7 +918,10 @@ test_ncmpi_get_att_$1(void)
                                 error("\n");
                                 error("varid: %d, ", i);
                                 error("att_name: %s, ", ATT_NAME(i,j));
-                                error("var_type: %s, ", s_nc_type(var_type[i]));
+                                if (i == -1)
+                                    error("var_type: GLOBAL, ");
+                                else
+                                    error("var_type: %s, ", s_nc_type(var_type[i]));
                                 error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
                                 error("element number: %d, ", k);
                                 error("expect: %g, ", expect[k]);
diff --git a/test/nonblocking/Makefile.in b/test/nonblocking/Makefile.in
index b65dc9c..c157254 100644
--- a/test/nonblocking/Makefile.in
+++ b/test/nonblocking/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2012, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2251 2015-12-20 21:13:42Z wkliao $
+# $Id: Makefile.in 2318 2016-02-04 00:18:26Z wkliao $
 #
 # @configure_input@
 
@@ -39,8 +39,12 @@ F90_SRCS = mcoll_testf.f90 \
 PROGS     = $(C_SRCS:.c=)
 OBJS      = $(C_SRCS:.c=.o)
 ifeq (@has_fortran@, yes)
-PROGS     += $(F77_SRCS:.f=)   $(F90_SRCS:.f90=)
-OBJS      += $(F77_SRCS:.f=.o) $(F90_SRCS:.f90=.o)
+PROGS     += $(F77_SRCS:.f=)
+OBJS      += $(F77_SRCS:.f=.o)
+ifeq (@mpi_mod@, yes)
+PROGS     += $(F90_SRCS:.f90=)
+OBJS      += $(F90_SRCS:.f90=.o)
+endif
 endif
 
 GARBAGE      = $(PROGS) *.nc
diff --git a/test/nonblocking/i_varn_indef.c b/test/nonblocking/i_varn_indef.c
index 84299dc..18093ba 100644
--- a/test/nonblocking/i_varn_indef.c
+++ b/test/nonblocking/i_varn_indef.c
@@ -4,7 +4,7 @@
  *  See COPYRIGHT notice in top-level directory.
  *
  *********************************************************************/
-/* $Id: i_varn_indef.c 2219 2015-12-11 22:30:03Z wkliao $ */
+/* $Id: i_varn_indef.c 2318 2016-02-04 00:18:26Z wkliao $ */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * This example tests posting nonblocking varn APIs, including
@@ -339,6 +339,7 @@ int main(int argc, char** argv)
 
     /* try with buffer being a single contiguous space ----------------------*/
     for (i=0; i<nreqs; i++) bufsize += req_lens[i];
+    cbuffer[0] = NULL;
     if (bufsize>0) cbuffer[0] = (long long*) malloc(bufsize * sizeof(long long));
     for (i=1; i<nreqs; i++) cbuffer[i] = cbuffer[i-1] + req_lens[i-1];
     for (i=0; i<bufsize; i++) cbuffer[0][i] = rank;
diff --git a/test/testcases/Makefile.in b/test/testcases/Makefile.in
index 0bcbe88..db72a97 100644
--- a/test/testcases/Makefile.in
+++ b/test/testcases/Makefile.in
@@ -2,7 +2,7 @@
 # Copyright (C) 2003, Northwestern University and Argonne National Laboratory
 # See COPYRIGHT notice in top-level directory.
 #
-# $Id: Makefile.in 2288 2016-01-02 08:14:49Z wkliao $
+# $Id: Makefile.in 2318 2016-02-04 00:18:26Z wkliao $
 #
 # @configure_input@
 
@@ -68,8 +68,12 @@ PROGS    = $(C_SRCS:.c=)
 OBJS     = $(C_SRCS:.c=.o)
 
 ifeq (@has_fortran@, yes)
-PROGS   += $(F77_SRCS:.f=)   $(F77F_SRCS:.F=)   $(F90_SRCS:.f90=)
-OBJS    += $(F77_SRCS:.f=.o) $(F77F_SRCS:.F=.o) $(F90_SRCS:.f90=.o)
+PROGS   += $(F77_SRCS:.f=)   $(F77F_SRCS:.F=)
+OBJS    += $(F77_SRCS:.f=.o) $(F77F_SRCS:.F=.o)
+ifeq (@mpi_mod@, yes)
+PROGS   += $(F90_SRCS:.f90=)
+OBJS    += $(F90_SRCS:.f90=.o)
+endif
 ifeq (@large_file_test@, yes)
 PROGS   += bigrecords
 OBJS    += bigrecords.o
diff --git a/test/testcases/bigrecords.f b/test/testcases/bigrecords.f
index eed43f9..75fdd46 100644
--- a/test/testcases/bigrecords.f
+++ b/test/testcases/bigrecords.f
@@ -2,7 +2,7 @@
 !  Copyright (C) 2003, Northwestern University and Argonne National Laboratory
 !  See COPYRIGHT notice in top-level directory.
 !
-!  $Id: bigrecords.f 2224 2015-12-16 06:10:36Z wkliao $
+!  $Id: bigrecords.f 2313 2016-02-01 21:24:42Z wkliao $
 
 !
 ! this test case came from Annette Koonts at PNNL
@@ -112,35 +112,35 @@
      +                       IOR(NF_CLOBBER,NF_64BIT_DATA), 
      +                       MPI_INFO_NULL, ncid)
 
-        call check_err("nfmpi_create(): ", iret)
+        call check_err(cmd,"nfmpi_create(): ", iret)
   
 ! define dimensions
 
         iret = nfmpi_def_dim(ncid, 'time', NFMPI_UNLIMITED, time_dim)
-        call check_err("nfmpi_def_dim(): time ", iret)
+        call check_err(cmd,"nfmpi_def_dim(): time ", iret)
 
         i8_size = 41943042
 
         iret = nfmpi_def_dim(ncid, 'cells', i8_size, cells_dim)
-        call check_err("nfmpi_def_dim(): cells ", iret)
+        call check_err(cmd,"nfmpi_def_dim(): cells ", iret)
 
         i8_size = 26
         iret = nfmpi_def_dim(ncid, 'interfaces', 
      +                       i8_size, interfaces_dim)
-        call check_err("nfmpi_def_dim(): interfaces ", iret)
+        call check_err(cmd,"nfmpi_def_dim(): interfaces ", iret)
 ! define variables
         time_dims(1) = time_dim
 
         iret = nfmpi_def_var(ncid, 'time', NF_DOUBLE, 
      +                       time_rank, time_dims, 
      +                       time_id)
-        call check_err("nfmpi_def_var(): time ", iret)
+        call check_err(cmd,"nfmpi_def_var(): time ", iret)
         interfaces_dims(1) = interfaces_dim
 
         iret = nfmpi_def_var(ncid, 'interfaces', NF_REAL, 
      +                       interfaces_rank, 
      +                       interfaces_dims, interfaces_id)
-        call check_err("nfmpi_def_var(): interfaces ", iret)
+        call check_err(cmd,"nfmpi_def_var(): interfaces ", iret)
 
         pressure_dims(3) = time_dim
         pressure_dims(2) = cells_dim
@@ -152,44 +152,44 @@
      +                     pressure_dims, 
      +                     pressure_id)
 
-        call check_err("nfmpi_def_var(): pressure ", iret)
+        call check_err(cmd,"nfmpi_def_var(): pressure ", iret)
 ! assign attributes
 
         longlen = 4
         iret = nfmpi_put_att_text(ncid, time_id, 'long_name', 
      +                            longlen, 'Time')
-        call check_err("nfmpi_put_att_text(): long_name ", iret)
+        call check_err(cmd,"nfmpi_put_att_text(): long_name ", iret)
         longlen = 21
         iret = nfmpi_put_att_text(ncid, time_id, 'units', 
      +                            longlen, 
      +                           'days since 1901-01-01')
-        call check_err("nfmpi_put_att_text(): units ", iret)
+        call check_err(cmd,"nfmpi_put_att_text(): units ", iret)
 
         longlen = 41
         iret = nfmpi_put_att_text(ncid, interfaces_id, 'long_name', 
      +                            longlen,
      +                     'Vertical interfaces, in terms of pressure')
-        call check_err("nfmpi_put_att_text(): long_name ", iret)
+        call check_err(cmd,"nfmpi_put_att_text(): long_name ", iret)
 
         longlen = 2
         iret = nfmpi_put_att_text(ncid, interfaces_id, 'units', 
      +                            longlen, 'Pa')
-        call check_err("nfmpi_put_att_text(): units ", iret)
+        call check_err(cmd,"nfmpi_put_att_text(): units ", iret)
 
         longlen = 8
         iret = nfmpi_put_att_text(ncid, pressure_id, 'long_name', 
      +                            longlen, 
      1                       'Pressure')
-        call check_err("nfmpi_put_att_text(): ", iret)
+        call check_err(cmd,"nfmpi_put_att_text(): ", iret)
 
         longlen = 2
         iret = nfmpi_put_att_text(ncid, pressure_id, 'units', 
      +                            longlen, 'Pa')
-        call check_err("nfmpi_put_att_text(): units ", iret)
+        call check_err(cmd,"nfmpi_put_att_text(): units ", iret)
 
 ! leave define mode
         iret = nfmpi_enddef(ncid)
-        call check_err("nfmpi_enddef(): ", iret)
+        call check_err(cmd,"nfmpi_enddef(): ", iret)
 
         start1d(1) = 1
         count1d(1) = 26
@@ -198,7 +198,7 @@
 ! store interfaces
         iret = nfmpi_put_vara_real_all(ncid, interfaces_id,
      +                                 start1d, count1d, interfaces)
-        call check_err("nfmpi_put_vara_real_all(): ", iret)
+        call check_err(cmd,"nfmpi_put_vara_real_all(): ", iret)
 
         time(1) = 0.0
         time(2) = 20.0
@@ -220,7 +220,7 @@
           iret = nfmpi_put_vara_double_all(ncid, time_id, 
      +                                     time_start, time_count,
      +                                     time(n))
-          call check_err("nfmpi_put_vara_double_all(): ", iret)
+          call check_err(cmd,"nfmpi_put_vara_double_all(): ", iret)
         enddo
 
         iret = nfmpi_close(ncid)
@@ -234,20 +234,20 @@
      +                   IOR(NF_CLOBBER,NF_64BIT_DATA),
      +                   MPI_INFO_NULL,
      +                   ncid)
-      call check_err("nfmpi_open(): ", iret)
+      call check_err(cmd,"nfmpi_open(): ", iret)
 
       iret = nfmpi_inq_varid(ncid, 'time', time_id);
-      call check_err("nfmpi_inq_varid(): time ", iret)
+      call check_err(cmd,"nfmpi_inq_varid(): time ", iret)
 
       ! deliberately want all processes to end up with the full time array
       time_start(1) = 1
       time_count(1) = 4
       iret = nfmpi_get_vara_double_all(ncid, time_id,
      +                               time_start, time_count, time);
-      call check_err("nfmpi_get_vara_double_all(): ", iret)
+      call check_err(cmd,"nfmpi_get_vara_double_all(): ", iret)
 
       iret = nfmpi_close(ncid)
-      call check_err("nfmpi_close(): ", iret)
+      call check_err(cmd,"nfmpi_close(): ", iret)
 
 !     write(6,*) "Time array: ", time
 !      if ( (time(1) .eq. 0) .and. (time(2) .eq. 20.0)
@@ -263,12 +263,13 @@
  999  call MPI_FINALIZE(ierr)
       end ! program main
        
-      subroutine writerecs(ncid,time_id)
+      subroutine writerecs(cmd,ncid,time_id)
 
       implicit none
       include "mpif.h"
       include "pnetcdf.inc"
        
+      character*(*) cmd
 ! netCDF id
       integer  ncid
 ! variable ids
@@ -316,17 +317,18 @@
      +                                   time_start, time_count,
      +                                   time)
 
-        call check_err("nfmpi_put_vara_double_all(): ", iret)
+        call check_err(cmd,"nfmpi_put_vara_double_all(): ", iret)
       enddo
        
       end ! subroutine writerecs
        
-      subroutine check_err(msg, iret)
+      subroutine check_err(cmd, msg, iret)
 
       include "pnetcdf.inc"
 
-      character*(*) msg
+      character*(*) cmd, msg
       integer iret
+      integer  XTRIM
 
       if (iret .ne. NF_NOERR) then
           print *, msg, nfmpi_strerror(iret)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pnetcdf.git



More information about the debian-science-commits mailing list