[r-cran-rnetcdf] 01/08: Imported Upstream version 1.7-3

Sebastian Gibb sgibb-guest at moszumanska.debian.org
Fri May 15 20:22:44 UTC 2015


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

sgibb-guest pushed a commit to branch master
in repository r-cran-rnetcdf.

commit a9ed87b1fa23a2c7d69e94c0fe3c51e9593fa512
Author: Sebastian Gibb <mail at sebastiangibb.de>
Date:   Fri May 15 20:14:49 2015 +0200

    Imported Upstream version 1.7-3
---
 DESCRIPTION                        |   39 +-
 INSTALL                            |   16 +-
 LICENSE                            |  235 +++++
 LICENSE.note                       |   73 --
 MD5                                |   38 +-
 NAMESPACE                          |    0
 R/RNetCDF.R                        |  400 +++++----
 R/load.R.in                        |   26 +-
 R/windows/load.R                   |   24 +-
 configure                          |  731 ++++++++++------
 configure.ac                       |  143 ++--
 configure.win                      |    2 -
 inst/HDF5_COPYING                  |   97 ---
 inst/udunits/udunits.dat           |  713 ++++++++++++++++
 inst/udunits/udunits2-accepted.xml |  198 +++++
 inst/udunits/udunits2-base.xml     |   86 ++
 inst/udunits/udunits2-common.xml   | 1662 ++++++++++++++++++++++++++++++++++++
 inst/udunits/udunits2-derived.xml  |  143 ++++
 inst/udunits/udunits2-prefixes.xml |   76 ++
 inst/udunits/udunits2.xml          |   16 +
 man/var.get.nc.Rd                  |   18 +-
 man/var.put.nc.Rd                  |    8 +-
 src/Makevars.in                    |    4 +-
 src/Makevars.win                   |   16 +-
 src/RNetCDF.c                      |  352 ++++----
 tests/RNetCDF-test.R               |  262 +++---
 26 files changed, 4266 insertions(+), 1112 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index c5f6953..2f654c6 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,22 +1,27 @@
 Package: RNetCDF
-Version: 1.6.3-1
-Date: 2014-05-26
-Title: R Interface to NetCDF Datasets
-Author: Pavel Michna
-Maintainer: Pavel Michna <michna at giub.unibe.ch>
-Depends: R (>= 2.4.0)
+Version: 1.7-3
+Date: 2015-05-09
+Title: Interface to NetCDF Datasets
+Author: Pavel Michna, with contributions from Milton Woods
+Maintainer: Milton Woods <mwoods at users.r-forge.r-project.org>
+Depends: R (>= 2.5.0)
 SystemRequirements: netcdf (>= 3.6.0), udunits (>= 1.11.7) or udunits2
         (>= 2.1.22)
-Description: This package provides an interface to Unidata's NetCDF
-        library functions (version 3) and furthermore access to
-        Unidata's UDUNITS calendar conversions. The routines and the
-        documentation follow the NetCDF and UDUNITS C interface, so the
-        corresponding manuals can be consulted for more detailed
-        information.
-License: GPL (>= 2)
-URL: http://www.unidata.ucar.edu/packages/netcdf/
-        http://www.unidata.ucar.edu/packages/udunits/
+Description: An interface to the NetCDF file format designed by Unidata
+  for efficient storage of array-oriented scientific data and descriptions.
+  The R interface is closely based on the C API of the NetCDF library,
+  and it includes calendar conversions from the Unidata UDUNITS library.
+  The current implementation supports all operations on NetCDF datasets
+  in classic and 64-bit offset file formats, and NetCDF4-classic format
+  is supported for reading and modification of existing files.
+License: GPL (>= 2) | file LICENSE
+URL: http://rnetcdf.r-forge.r-project.org
+        http://www.unidata.ucar.edu/software/netcdf/
+        http://www.unidata.ucar.edu/software/udunits/
 NeedsCompilation: yes
 Repository: CRAN
-Date/Publication: 2014-08-31 19:42:13
-Packaged: 2014-08-31 17:41:33 UTC; ripley
+Repository/R-Forge/Project: rnetcdf
+Repository/R-Forge/Revision: 63
+Repository/R-Forge/DateTimeStamp: 2015-05-09 09:41:28
+Date/Publication: 2015-05-11 08:48:00
+Packaged: 2015-05-09 09:45:50 UTC; rforge
diff --git a/INSTALL b/INSTALL
index 8cd342a..dbdbd21 100644
--- a/INSTALL
+++ b/INSTALL
@@ -26,17 +26,14 @@ R CMD INSTALL Options
 --with-netcdf-lib=DIR        location of netcdf libraries
 --with-udunits-include=DIR   location of udunits header files
 --with-udunits-lib=DIR       location of udunits libraries 
---with-udunits-dat=FILE      location of udunits.dat file
 --with-hdf5-lib=DIR          location of hdf5 libraries (if installed)
---enable-units-copy[=PATH]   place a local copy of units data file(s)
-                             in the package [no]
 
 
 R CMD INSTALL Example
 =====================
 
 R CMD INSTALL --configure-args="--with-netcdf-include='/sw/include' \
-    --with-netcdf-lib='/sw/lib'" RNetCDF_1.6.3-1.tar.gz
+    --with-netcdf-lib='/sw/lib'" RNetCDF_1.7-3.tar.gz
 
 
 LD_LIBRARY_PATH
@@ -53,5 +50,14 @@ R CMD check Example
 ===================
 
 R CMD check --install-args="--configure-args='--with-netcdf-include=/sw/include \
---with-netcdf-lib=/sw/lib'" RNetCDF_1.6.3-1.tar.gz
+--with-netcdf-lib=/sw/lib'" RNetCDF_1.7-3.tar.gz
+
+
+Time units
+==========
+
+Common udunits databases are distributed with RNetCDF, and these are used
+by default when RNetCDF is loaded by R. However, a different units database
+may be used by specifying the appropriate file in environment variables
+UDUNITS2_XML_PATH (udunits2) or UDUNITS_PATH (udunits1).
 
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..439418a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,235 @@
+This file is intended to clarify ownership, copyrights and licenses.
+Where possible individual files also carry brief copyright notices. 
+
+
+RNetCDF
+=======
+
+All files except those indicated later are Copyright (C) 2004-2015 Pavel Michna.
+They are licensed under the terms of the GNU General Public License:
+
+    This is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+See http://www.r-project.org/Licenses/GPL-2 for license details.
+
+
+NetCDF
+======
+
+The documentation of RNetCDF is based on the "NetCDF User's Guide for C",
+and installation of RNetCDF requires linking with the Unidata NetCDF library.
+These uses of NetCDF are allowed by the NetCDF copyright:
+
+    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+    2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
+    University Corporation for Atmospheric Research/Unidata.
+
+    Portions of this software were developed by the Unidata Program at the 
+    University Corporation for Atmospheric Research.
+
+    Access and use of this software shall impose the following obligations
+    and understandings on the user. The user is granted the right, without
+    any fee or cost, to use, copy, modify, alter, enhance and distribute
+    this software, and any derivative works thereof, and its supporting
+    documentation for any purpose whatsoever, provided that this entire
+    notice appears in all copies of the software, derivative works and
+    supporting documentation.  Further, UCAR requests that the user credit
+    UCAR/Unidata in any publications that result from the use of this
+    software or in any product that includes this software, although this
+    is not an obligation. The names UCAR and/or Unidata, however, may not
+    be used in any advertising or publicity to endorse or promote any
+    products or commercial entity unless specific written permission is
+    obtained from UCAR/Unidata. The user also understands that
+    UCAR/Unidata is not obligated to provide the user with any support,
+    consulting, training or assistance of any kind with regard to the use,
+    operation and performance of this software nor to provide the user
+    with any updates, revisions, new versions or "bug fixes."
+
+    THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
+    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
+    INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+    FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+    NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+    WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
+
+
+UDUNITS
+=======
+
+RNetCDF may be linked with the UDUNITS (version 1.x) library.
+To simplify distribution of RNetCDF in binary form,
+data files required by UDUNITS are included with RNetCDF,
+subject to the following license:
+
+    (C) Copyright 1992,1995 UCAR/Unidata
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose without fee is hereby granted, provided that
+    the above copyright notice appears in all copies, that both that copyright
+    notice and this permission notice appear in supporting documentation, and
+    that the name of UCAR/Unidata not be used in advertising or publicity
+    pertaining to distribution of the software without specific, written prior
+    permission.  UCAR makes no representations about the suitability of this
+    software for any purpose.  It is provided "as is" without express or
+    implied warranty.  It is provided with no support and without obligation on
+    the part of UCAR or Unidata, to assist in its use, correction,
+    modification, or enhancement.
+
+
+UDUNITS2
+========
+
+RNetCDF may be linked with the UDUNITS2 library.
+To simplify distribution of RNetCDF in binary form,
+data files required by UDUNITS2 are included with RNetCDF,
+subject to the following license:
+
+    Copyright 2014 University Corporation for Atmospheric Research and contributors.
+    All rights reserved.
+
+    This software was developed by the Unidata Program Center of the
+    University Corporation for Atmospheric Research (UCAR)
+    <http://www.unidata.ucar.edu>.
+
+    Redistribution and use in source and binary forms, with or without modification,
+    are permitted provided that the following conditions are met:
+
+       1) Redistributions of source code must retain the above copyright notice,
+	  this list of conditions and the following disclaimer.
+       2) Redistributions in binary form must reproduce the above copyright notice,
+	  this list of conditions and the following disclaimer in the documentation
+	  and/or other materials provided with the distribution.
+       3) Neither the names of the development group, the copyright holders, nor the
+	  names of contributors may be used to endorse or promote products derived
+	  from this software without specific prior written permission.
+       4) This license shall terminate automatically and you may no longer exercise
+	  any of the rights granted to you by this license as of the date you
+	  commence an action, including a cross-claim or counterclaim, against
+	  the copyright holders or any contributor alleging that this software
+	  infringes a patent. This termination provision shall not apply for an
+	  action alleging patent infringement by combinations of this software with
+	  other software or hardware.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+    FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS
+    OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
+
+
+NCSA HDF5
+=========
+
+Although the RNetCDF package does not use HDF5 directly,
+if statically linked to a build of netcdf with the netcdf4 feature enabled,
+it will link in code from HDF5. The license for such code is given below:
+
+    Copyright Notice and License Terms for 
+    HDF5 (Hierarchical Data Format 5) Software Library and Utilities
+    -----------------------------------------------------------------------------
+
+    HDF5 (Hierarchical Data Format 5) Software Library and Utilities
+    Copyright 2006-2014 by The HDF Group.
+
+    NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities
+    Copyright 1998-2006 by the Board of Trustees of the University of Illinois.
+
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without 
+    modification, are permitted for any purpose (including commercial purposes) 
+    provided that the following conditions are met:
+
+    1. Redistributions of source code must retain the above copyright notice, 
+       this list of conditions, and the following disclaimer.
+
+    2. Redistributions in binary form must reproduce the above copyright notice, 
+       this list of conditions, and the following disclaimer in the documentation 
+       and/or materials provided with the distribution.
+
+    3. In addition, redistributions of modified forms of the source or binary 
+       code must carry prominent notices stating that the original code was 
+       changed and the date of the change.
+
+    4. All publications or advertising materials mentioning features or use of 
+       this software are asked, but not required, to acknowledge that it was 
+       developed by The HDF Group and by the National Center for Supercomputing 
+       Applications at the University of Illinois at Urbana-Champaign and 
+       credit the contributors.
+
+    5. Neither the name of The HDF Group, the name of the University, nor the 
+       name of any Contributor may be used to endorse or promote products derived 
+       from this software without specific prior written permission from 
+       The HDF Group, the University, or the Contributor, respectively.
+
+    DISCLAIMER: 
+    THIS SOFTWARE IS PROVIDED BY THE HDF GROUP AND THE CONTRIBUTORS 
+    "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED.  In no 
+    event shall The HDF Group or the Contributors be liable for any damages 
+    suffered by the users arising out of the use of this software, even if 
+    advised of the possibility of such damage. 
+
+    -----------------------------------------------------------------------------
+    -----------------------------------------------------------------------------
+
+    Contributors:   National Center for Supercomputing Applications (NCSA) at 
+    the University of Illinois, Fortner Software, Unidata Program Center (netCDF), 
+    The Independent JPEG Group (JPEG), Jean-loup Gailly and Mark Adler (gzip), 
+    and Digital Equipment Corporation (DEC).
+
+    -----------------------------------------------------------------------------
+
+    Portions of HDF5 were developed with support from the Lawrence Berkeley 
+    National Laboratory (LBNL) and the United States Department of Energy 
+    under Prime Contract No. DE-AC02-05CH11231.
+
+    -----------------------------------------------------------------------------
+
+    Portions of HDF5 were developed with support from the University of 
+    California, Lawrence Livermore National Laboratory (UC LLNL).  
+    The following statement applies to those portions of the product and must 
+    be retained in any redistribution of source code, binaries, documentation, 
+    and/or accompanying materials:
+
+       This work was partially produced at the University of California, 
+       Lawrence Livermore National Laboratory (UC LLNL) under contract 
+       no. W-7405-ENG-48 (Contract 48) between the U.S. Department of Energy 
+       (DOE) and The Regents of the University of California (University) 
+       for the operation of UC LLNL.
+
+       DISCLAIMER: 
+       This work was prepared as an account of work sponsored by an agency of 
+       the United States Government. Neither the United States Government nor 
+       the University of California nor any of their employees, makes any 
+       warranty, express or implied, or assumes any liability or responsibility 
+       for the accuracy, completeness, or usefulness of any information, 
+       apparatus, product, or process disclosed, or represents that its use 
+       would not infringe privately- owned rights. Reference herein to any 
+       specific commercial products, process, or service by trade name, 
+       trademark, manufacturer, or otherwise, does not necessarily constitute 
+       or imply its endorsement, recommendation, or favoring by the United 
+       States Government or the University of California. The views and 
+       opinions of authors expressed herein do not necessarily state or reflect 
+       those of the United States Government or the University of California, 
+       and shall not be used for advertising or product endorsement purposes.
+    -----------------------------------------------------------------------------
+
+
+
+Pavel Michna
+
diff --git a/LICENSE.note b/LICENSE.note
deleted file mode 100644
index 1ec3c59..0000000
--- a/LICENSE.note
+++ /dev/null
@@ -1,73 +0,0 @@
-This file is intended to clarify ownership, copyright and license.
-Where possible individual files also carry brief copyright notices. 
-
-
-Copyrights
-==========
-
-All files of this package were created by Pavel Michna and are licensed under
-the terms of the GNU General Public License (see below).
-
-Because large parts of the documentation are taken from the "NetCDF User's Guide
-for C" and from the udunits(3) manpage, it is appropriate to cite Ucar's 
-copyright notice for the NetCDF library:
-
-    Copyright 1993-1999 University Corporation for Atmospheric Research/Unidata
-
-    Portions of this software were developed by the Unidata Program at the
-    University Corporation for Atmospheric Research.
-
-    Access and use of this software shall impose the following obligations
-    and understandings on the user. The user is granted the right, without
-    any fee or cost, to use, copy, modify, alter, enhance and distribute
-    this software, and any derivative works thereof, and its supporting
-    documentation for any purpose whatsoever, provided that this entire
-    notice appears in all copies of the software, derivative works and
-    supporting documentation.  Further, UCAR requests that the user credit
-    UCAR/Unidata in any publications that result from the use of this
-    software or in any product that includes this software. The names UCAR
-    and/or Unidata, however, may not be used in any advertising or publicity
-    to endorse or promote any products or commercial entity unless specific
-    written permission is obtained from UCAR/Unidata. The user also
-    understands that UCAR/Unidata is not obligated to provide the user with
-    any support, consulting, training or assistance of any kind with regard
-    to the use, operation and performance of this software nor to provide
-    the user with any updates, revisions, new versions or "bug fixes."
-
-    THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
-    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-    DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
-    INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
-    FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
-    NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
-    WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
-
-
-All other files not falling under Ucar's copyright (these are especially the
-R and C code files provided here) are copyright (C) 2004-2014 Pavel Michna.
-
-
-License
-=======
-
-    This is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-
-
-The file COPYING in the top-level directory is a copy of the 'GNU
-General Public License'.
-
-
-Pavel Michna
diff --git a/MD5 b/MD5
index f1dadb8..d816fff 100644
--- a/MD5
+++ b/MD5
@@ -1,16 +1,22 @@
 393a5ca445f6965873eca0259a17f833 *COPYING
-865ef98c3d907da04b6a7f81cb2e2fd6 *DESCRIPTION
-f9b92f1a88f31286175d1fbf378c5237 *INSTALL
-0ce6e107fa9731c61205876734fe6308 *LICENSE.note
+13f5a8694b1bdcc97bdcc50fed9ec01b *DESCRIPTION
+e8c8f32aa6d7601ab109738ea86ef4bd *INSTALL
+7449ab54eea7e97ab5078b92950dfa55 *LICENSE
 c196fabc79f4cde31798923889f9495d *NAMESPACE
-975295df039d5e13e4138d2408745e6f *R/RNetCDF.R
-b272869d34433d37562c1ba1650ccbaf *R/load.R.in
-b667edb2897875a3e0aac7c2f88732dd *R/windows/load.R
+8f7e1f11f99f691e999750606f86188b *R/RNetCDF.R
+5716f2b03c6ab9c5014db5d46db9479c *R/load.R.in
+8331e1f8b5432768b1aaeab4778be57e *R/windows/load.R
 f641b8623599777eab63d8a8a8982216 *cleanup
-87285075ce5c6951748757b6e7775f96 *configure
-6d1409a089d066a8dee8481f7128e0bc *configure.ac
-b6314d56e19a1a7161c9d45c1caf977d *configure.win
-871d490b497cfe022735a52cc03ad7c3 *inst/HDF5_COPYING
+ca411868d1298966a4f78e9219ab5b1e *configure
+f0d031aa473a988888ec84804d8a28a7 *configure.ac
+d41d8cd98f00b204e9800998ecf8427e *configure.win
+3242b668e27270c8bc626f37b48d1eaa *inst/udunits/udunits.dat
+451f7ff1707652b217043430842876ed *inst/udunits/udunits2-accepted.xml
+7db0c232db5e2b2421c66fc063422824 *inst/udunits/udunits2-base.xml
+726893d831df825837682e51cc4f89b6 *inst/udunits/udunits2-common.xml
+44ec695c87159365d902f9d8f358a0fd *inst/udunits/udunits2-derived.xml
+8d9cbc3bea12a8b3f594a17eececbfc3 *inst/udunits/udunits2-prefixes.xml
+43619d63e8dcd58f2c0034cfb4b50b59 *inst/udunits/udunits2.xml
 4543edd738c276fef8d5d8ce29224536 *man/00RNetCDF.Rd
 f68eff5de2d01cb473f7db38dad78b4f *man/att.copy.nc.Rd
 7c87392737abac372d8056f734659d6e *man/att.delete.nc.Rd
@@ -32,11 +38,11 @@ a3fc363579eaf8f10d7c0c259e2d2cf8 *man/sync.nc.Rd
 1138b2870cba027f2ab295ead28278d9 *man/utinit.nc.Rd
 986c385caf3aede6376860fdb74fdce4 *man/utinvcal.nc.Rd
 f0cc3ec1390b07c23b03c05eb351b29a *man/var.def.nc.Rd
-d75a9a15a26795ce64eef32187ee98de *man/var.get.nc.Rd
+c037b40743cf7d12b3b2a97a1736c157 *man/var.get.nc.Rd
 61b92c68a0317e539c0707b64623b04a *man/var.inq.nc.Rd
-5bc33e292668a9ba4ace29c4f12e0a47 *man/var.put.nc.Rd
+7b42a5222379d10f56fec0ae2c50dc4b *man/var.put.nc.Rd
 6e1cd213bcd53b0b68f5ca8473e26683 *man/var.rename.nc.Rd
-d62c4825a3abc101a04429d20703158d *src/Makevars.in
-ca120b06e11cace641f00dccd7f8c7e1 *src/Makevars.win
-cef882afd05cd56ec9708a5fdd2746d7 *src/RNetCDF.c
-7acffec9ab8f675c5862f2aef639410b *tests/RNetCDF-test.R
+7c01c319eb30ec7a18bf81ea1f3732c3 *src/Makevars.in
+9602df250b63fc636c1c6f7a1c6bb8cb *src/Makevars.win
+0438fa61c7cc022875d0729ae157a125 *src/RNetCDF.c
+aedb94602f1d9dec55ac06b2e6cd34a6 *tests/RNetCDF-test.R
diff --git a/NAMESPACE b/NAMESPACE
old mode 100644
new mode 100755
diff --git a/R/RNetCDF.R b/R/RNetCDF.R
index 8b00077..fcc79b7 100644
--- a/R/RNetCDF.R
+++ b/R/RNetCDF.R
@@ -2,7 +2,7 @@
 #										#
 #  Name:       RNetCDF.R							#
 #										#
-#  Version:    1.6.3-1								#
+#  Version:    1.7-3								#
 #										#
 #  Purpose:    NetCDF interface for R.						#
 #										#
@@ -46,6 +46,8 @@
 #  pm       02/06/12   Added function read.nc()                                 #
 #  pm       16/07/12   Added packing/unpacking of data (code from mw)           #
 #  mw       21/08/14   Allow reading of character vector or scalar              #
+#  mw       05/09/14   Support reading and writing raw character arrays         #
+#  mw       08/09/14   Handle reading and writing of zero-sized arrays          #
 #										#
 #===============================================================================#
 
@@ -752,7 +754,7 @@ var.def.nc <- function(ncfile, varname, vartype, dimensions)
 #-------------------------------------------------------------------------------#
 
 var.get.nc <- function(ncfile, variable, start=NA, count=NA, na.mode=0,
-                       collapse=TRUE, unpack=FALSE)
+                       collapse=TRUE, unpack=FALSE, rawchar=FALSE)
 {
     #-- Check args -------------------------------------------------------------#
     stopifnot(class(ncfile) == "NetCDF")
@@ -761,9 +763,9 @@ var.get.nc <- function(ncfile, variable, start=NA, count=NA, na.mode=0,
     stopifnot(is.numeric(count) || is.logical(count))
     stopifnot(is.logical(collapse))
     stopifnot(is.logical(unpack))
+    stopifnot(is.logical(rawchar))
     
-    if(!any(na.mode == c(0,1,2,3)))
-        stop("Wrong na.mode", call.=FALSE)
+    stopifnot(isTRUE(na.mode %in% c(0,1,2,3))) 
 
     #-- Inquire the variable ---------------------------------------------------#
     varinfo <- try(var.inq.nc(ncfile, variable))
@@ -771,129 +773,102 @@ var.get.nc <- function(ncfile, variable, start=NA, count=NA, na.mode=0,
     if(class(varinfo) == "try-error" || is.null(varinfo))
         return(invisible(NULL))
     
+    ndims      <- varinfo$ndims
+
     #-- Get the varid as integer if necessary ----------------------------------#
     ifelse(is.character(variable), varid <- varinfo$id, varid <- variable)
 
-    #-- Get the variable dimensions if start and count contain NAs -------------#
-    if(varinfo$ndims > 0) {
-	r.start <- vector()
-	r.count <- vector()
-	for(i in 1:varinfo$ndims) {
-            r.start[i] <- 1
-	    r.count[i] <- dim.inq.nc(ncfile, varinfo$dimids[i])$length
-	}
-
-        if(any(is.na(start)) && length(start) == 1)
-	    start <- rep(NA, varinfo$ndims)
-        if(any(is.na(count)) && length(count) == 1)
-	    count <- rep(NA, varinfo$ndims)
-	
-	start[is.na(start)] <- r.start[is.na(start)]
-	count[is.na(count)] <- r.count[is.na(count)]
+    #-- Replace NA by defined limits -------------------------------------------#
+    if(isTRUE(is.na(start))) {
+      start <- rep(NA, ndims)
     }
-
-    #-- Handle scalar variables ------------------------------------------------#
-    if(varinfo$ndims == 0) {
-	start[1] <- 1
-	count[1] <- 1
+    if(isTRUE(is.na(count))) {
+      count <- rep(NA, ndims)
     }
 
-    #-- Allocate memory for variable and get number of dimensions --------------#
-    varsize    <- vector()
-    varsize[1] <- prod(count)
-    varsize[2] <- count[1]                           ## Needed for character data
-    ndims      <- varinfo$ndims
+    if(length(start) != ndims || length(count) != ndims)
+      stop("Length of start/count is not ndims", call.=FALSE)
 
-    #-- Switch from R to C convention ------------------------------------------#
-    if(varinfo$ndims > 0) {
-	c.start <- start[length(start):1] - 1
-	c.count <- count[length(count):1]    
-    } else {
-        c.start <- 0
-	c.count <- 1
+    start[is.na(start)] <- 1
+    for (idim in seq_len(ndims)) {
+      if (is.na(count[idim])) {
+        count[idim] <- dim.inq.nc(ncfile, varinfo$dimids[idim])$length
+      }
     }
 
-    #-- Check for correct number of dimensions in start and count --------------#
-    if(varinfo$ndims > 0)
-	if(length(c.start) != ndims || length(c.count) != ndims)
-            stop("Length of start/count is not ndims", call.=FALSE)
+    #-- Switch from R to C convention ------------------------------------------#
+    c.start <- rev(start-1)
+    c.count <- rev(count)
 
     #-- C function calls -------------------------------------------------------#
-    if(varinfo$type != "NC_CHAR")
-	nc <- .Call("R_nc_get_vara_double",
+    if(varinfo$type == "NC_CHAR") {
+        nc <- .Call("R_nc_get_vara_text",
         	    as.integer(ncfile),
 		    as.integer(varid),
 		    as.integer(c.start),
 		    as.integer(c.count),
-		    as.integer(varsize),
+		    as.integer(ndims),
+                    as.integer(rawchar),
 		    PACKAGE="RNetCDF")
-    else
-        nc <- .Call("R_nc_get_vara_text",
+    } else {
+	nc <- .Call("R_nc_get_vara_double",
         	    as.integer(ncfile),
 		    as.integer(varid),
 		    as.integer(c.start),
 		    as.integer(c.count),
-		    as.integer(varsize),
+		    as.integer(ndims),
 		    PACKAGE="RNetCDF")
+    }
 
     #-- Adjust data ------------------------------------------------------------#
     if(nc$status == 0) {
 	
-	#-- Set dimensions, collapse degenerate dimensions ---------------------#
-        if (collapse) {
-          keep.dim <- (count > 1)
-        } else {
-          keep.dim <- rep(TRUE,ndims)
-        }
-        if ( varinfo$type == "NC_CHAR" && ndims > 0 ) {
-          # First dimension of character array becomes string length
-          keep.dim[1] <- FALSE
-        }
-        count.dim <- count[keep.dim]
-          
 	#-- Convert missing value to NA if defined in NetCDF file --------------#
-	tolerance <- 1*10^-5                              ## Allow rounding error
-	na.flag   <- 0
-
-        missval.flag <- 0
-	fillval.flag <- 0
-	
-        fillval <- try(att.inq.nc(ncfile, varinfo$name, "_FillValue"   ), 
-	    silent=TRUE)
-        missval <- try(att.inq.nc(ncfile, varinfo$name, "missing_value"), 
-	    silent=TRUE)
-
-        if(!(class(fillval) == "try-error"))
-	    if(!is.null(fillval))
-	        fillval.flag <- 1
-	if(!(class(missval) == "try-error"))
-	    if(!is.null(missval))
-		missval.flag <- 1
-
-       	if(na.mode == 0 && missval.flag == 1) {
-	    na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
-	    na.flag  <- 1
-	}
-	if(na.mode == 0 && fillval.flag == 1) {
-	    na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
-	    na.flag  <- 1
-	}
-
-       	if(na.mode == 1 && fillval.flag == 1) {
-	    na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
-	    na.flag  <- 1
-	}
-
-	if(na.mode == 2 && missval.flag == 1) {
-	    na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
-	    na.flag  <- 1
-	}
-
-        if(na.flag == 1 && na.mode != 3 && varinfo$type != "NC_CHAR")
-	    nc$data[abs(nc$data-na.value) < tolerance] <- NA 
+        if (is.numeric(nc$data) && na.mode < 3) { 
+	  tolerance <- 1*10^-5                              ## Allow rounding error
+	  na.flag   <- 0
+
+	  missval.flag <- 0
+	  fillval.flag <- 0
+	  
+	  fillval <- try(att.inq.nc(ncfile, varinfo$name, "_FillValue"   ), 
+	      silent=TRUE)
+	  missval <- try(att.inq.nc(ncfile, varinfo$name, "missing_value"), 
+	      silent=TRUE)
+
+	  if(!(class(fillval) == "try-error"))
+	      if(!is.null(fillval))
+		  fillval.flag <- 1
+	  if(!(class(missval) == "try-error"))
+	      if(!is.null(missval))
+		  missval.flag <- 1
+
+	  if(na.mode == 0 && missval.flag == 1) {
+	      na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
+	      na.flag  <- 1
+	  }
+	  if(na.mode == 0 && fillval.flag == 1) {
+	      na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
+	      na.flag  <- 1
+	  }
+
+	  if(na.mode == 1 && fillval.flag == 1) {
+	      na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
+	      na.flag  <- 1
+	  }
+
+	  if(na.mode == 2 && missval.flag == 1) {
+	      na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
+	      na.flag  <- 1
+	  }
+
+	  if(na.flag == 1) {
+	      nc$data[abs(nc$data-as.numeric(na.value)) < tolerance] <- NA 
+	  }
+        }
 
 	#-- Unpack variables if requested (missing values are preserved) -------#
-        if(unpack) {
+        if(unpack && is.numeric(nc$data)) {
             offset <- try(att.inq.nc(ncfile, varinfo$name, "add_offset"),
                           silent=TRUE)
             scale  <- try(att.inq.nc(ncfile, varinfo$name, "scale_factor"),
@@ -905,9 +880,26 @@ var.get.nc <- function(ncfile, variable, start=NA, count=NA, na.mode=0,
                 nc$data      <- nc$data*scale_factor+add_offset
             }
         }
-	
+
+	#-- Set dimensions, collapse degenerate dimensions ---------------------#
+        if (is.character(nc$data) && ndims > 0) {
+          # Drop string length dimension
+          datadim <- count[-1]
+        } else {
+          datadim <- count
+        }
+        if (collapse) {
+          # Drop singleton dimensions
+          datadim <- datadim[datadim!=1]
+        }
+        if (length(datadim)<1) {
+          # For compatibility with code written for RNetCDF<=1.6.x,
+          # scalars and vectors always have a dimension attribute:
+          datadim <- length(nc$data)
+        }
+        dim(nc$data) <- datadim
+
     #-- Return object if no error ----------------------------------------------#
-	ifelse(length(count.dim) == 0, dim(nc$data) <- (1), dim(nc$data) <- count.dim)
 	return(nc$data)
     } else
         stop(nc$errmsg, call.=FALSE)
@@ -965,13 +957,12 @@ var.put.nc <- function(ncfile, variable, data, start=NA, count=NA, na.mode=0,
     #-- Check args -------------------------------------------------------------#
     stopifnot(class(ncfile) == "NetCDF")
     stopifnot(is.character(variable) || is.numeric(variable))
-    stopifnot(is.numeric(data) || is.character(data) || is.logical(data))
+    stopifnot(is.numeric(data) || is.character(data) || is.raw(data) || is.logical(data))
     stopifnot(is.numeric(start) || is.logical(start))
     stopifnot(is.numeric(count) || is.logical(count))
     stopifnot(is.logical(pack))
-    
-    if(!any(na.mode == c(0,1,2)))
-        stop("Wrong na.mode", call.=FALSE)
+
+    stopifnot(isTRUE(na.mode %in% c(0,1,2))) 
 
     #-- Inquire the variable ---------------------------------------------------#
     varinfo <- try(var.inq.nc(ncfile, variable))
@@ -981,6 +972,10 @@ var.put.nc <- function(ncfile, variable, data, start=NA, count=NA, na.mode=0,
 
     ndims <- varinfo$ndims
 
+    if ((is.character(data) || is.raw(data)) && varinfo$type != "NC_CHAR") {
+        stop("R character data can only be written to NC_CHAR variable",call.=FALSE)
+    }
+
     #-- Get the varid as integer if necessary ----------------------------------#
     ifelse(is.character(variable), varid <- varinfo$id, varid <- variable)
 
@@ -992,70 +987,52 @@ var.put.nc <- function(ncfile, variable, data, start=NA, count=NA, na.mode=0,
 	    mode(data) <- "numeric"
     }
 
-    #-- Get the data dimensions if start and count contain NAs -----------------#
-    if(varinfo$ndims == 0) {
-	start[1] <- 1
-	count[1] <- 1
-    }
-    
-    if(any(is.na(start)) && length(start) > 1)
-        stop("start contains NAs and length(start) not 1", call.=FALSE)
-    if(any(is.na(count)) && length(count) > 1)
-        stop("count contains NAs and length(count) not 1", call.=FALSE)
-
-    if(any(is.na(start)) && varinfo$ndims > 0)
-        start <- rep(1, ndims)
-    if(any(is.na(count)) && varinfo$ndims > 0) {
-        if(is.null(dim(data)))
-	    count <- length(data)
-	else 
-	    count <- dim(data)
-
-        if(varinfo$type == "NC_CHAR")
-	    count <- c(max(nchar(data)), count)
+    #-- Check length of character strings --------------------------------------#
+    if (is.character(data)) {
+      if (ndims > 0) {
+        strlen <- dim.inq.nc(ncfile, varinfo$dimids[1])$length
+      } else {
+        strlen <- 1
+      }
+      if (max(nchar(data,type="bytes")) > strlen) {
+        stop("String length exceeds netcdf dimension", call.=FALSE)
+      }
     }
 
-    #-- Switch from R to C convention ------------------------------------------#
-    if(varinfo$ndims > 0) {
-	c.start <- start[length(start):1] - 1
-	c.count <- count[length(count):1]    
-    } else {
-        c.start <- 0
-	c.count <- 1
-	
-	if(length(data) > 1)
-	    stop("Edge+start exceeds dimension bound", call.=FALSE)
+    #-- Replace NA by dimensions of data ---------------------------------------#
+    if (any(is.na(start))) {
+      start <- rep(1, ndims)
     }
 
-    #-- Check for correct number of dimensions in start and count --------------#
-    if(varinfo$ndims > 0)
-	if(length(c.start) != ndims || length(c.count) != ndims)
-            stop("Length of start/count is not ndims", call.=FALSE)
-
-    #-- Check if length of data and count match (numeric data) -----------------#
-    if(is.numeric(data) && length(data) != prod(c.count))
-        stop("Mismatch in count and length(data)", call.=FALSE)
+    if (any(is.na(count))) {
+      if (!is.null(dim(data))) {
+	count <- dim(data)
+      } else if (ndims > 0) {
+	count <- length(data)
+      } else {
+	count <- integer(0)
+      }
+      if (is.character(data) && ndims > 0) {
+        count <- c(strlen, count)
+      }
+    }
 
-    #-- Checks and definitions for character data ------------------------------#
-    if(is.character(data) && varinfo$ndims > 0) {
-        lastdim   <- varinfo$dimids[1]                       ## R to C convention
-	maxstrlen <- dim.inq.nc(ncfile, lastdim)$length
-    
-        if(length(data) != prod(c.count[1:(ndims-1)]))    ## already C convention
-	    stop("Mismatch in count and length(data)", call.=FALSE)
-	
-	if(max(nchar(data)) > maxstrlen)
-	    stop("max(nchar(data)) exceeding variable limits", call.=FALSE)
+    if(length(start) != ndims || length(count) != ndims) {
+      stop("Length of start/count is not ndims", call.=FALSE)
     }
 
-    if(is.character(data)) {
-	varsize    <- vector()
-	varsize[1] <- prod(count)
-	varsize[2] <- count[1]
+    #-- Check that length of data and count match ------------------------------#
+    if (is.character(data) && ndims > 0) {
+      numelem <- prod(count[-1])
+    } else {
+      numelem <- prod(count)
+    }
+    if (length(data) != numelem) {
+      stop("Mismatch between count and length(data)", call.=FALSE)
     }
 
     #-- Pack variables if requested (missing values are preserved) -------------#
-    if(pack) {
+    if(pack && is.numeric(data)) {
         offset <- try(att.inq.nc(ncfile, varinfo$name, "add_offset"),
 		      silent=TRUE)
         scale  <- try(att.inq.nc(ncfile, varinfo$name, "scale_factor"),
@@ -1069,69 +1046,78 @@ var.put.nc <- function(ncfile, variable, data, start=NA, count=NA, na.mode=0,
     }
 
     #-- Convert missing value to NA if defined in NetCDF file ------------------#
-    if(is.numeric(data)) {
-        if(any(is.na(data))) {
-	    na.flag <- 0
-
-            missval.flag <- 0
-	    fillval.flag <- 0
-
-            fillval <- try(att.inq.nc(ncfile, varinfo$name, "_FillValue"   ), 
-	        silent=TRUE)
-            missval <- try(att.inq.nc(ncfile, varinfo$name, "missing_value"),
-	        silent=TRUE)
-
-            if(!(class(fillval) == "try-error"))
-		if(!is.null(fillval))
-	            fillval.flag <- 1
-	    if(!(class(missval) == "try-error"))
-		if(!is.null(missval))
-		    missval.flag <- 1
-
-       	    if(na.mode == 0 && missval.flag == 1) {
-		na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
-		na.flag  <- 1
-	    }
-	    if(na.mode == 0 && fillval.flag == 1) {
-		na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
-		na.flag  <- 1
-	    }
-
-       	    if(na.mode == 1 && fillval.flag == 1) {
-		na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
-		na.flag  <- 1
-	    }
-
-	    if(na.mode == 2 && missval.flag == 1) {
-		na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
-		na.flag  <- 1
-	    }
-
-            if(na.flag == 1)
-		data[is.na(data)] <- na.value
-	    else
-	        stop("Found NAs but no missing value attribute", call.=FALSE)
-        }
+    if(is.numeric(data) && any(is.na(data))) {
+      na.flag <- 0
+
+      missval.flag <- 0
+      fillval.flag <- 0
+
+      fillval <- try(att.inq.nc(ncfile, varinfo$name, "_FillValue"   ), 
+	  silent=TRUE)
+      missval <- try(att.inq.nc(ncfile, varinfo$name, "missing_value"),
+	  silent=TRUE)
+
+      if(!(class(fillval) == "try-error"))
+	  if(!is.null(fillval))
+	      fillval.flag <- 1
+      if(!(class(missval) == "try-error"))
+	  if(!is.null(missval))
+	      missval.flag <- 1
+
+      if(na.mode == 0 && missval.flag == 1) {
+	  na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
+	  na.flag  <- 1
+      }
+      if(na.mode == 0 && fillval.flag == 1) {
+	  na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
+	  na.flag  <- 1
+      }
+
+      if(na.mode == 1 && fillval.flag == 1) {
+	  na.value <- att.get.nc(ncfile, varinfo$name, "_FillValue")
+	  na.flag  <- 1
+      }
+
+      if(na.mode == 2 && missval.flag == 1) {
+	  na.value <- att.get.nc(ncfile, varinfo$name, "missing_value")
+	  na.flag  <- 1
+      }
+
+      if(na.flag == 1)
+	  data[is.na(data)] <- as.numeric(na.value)
+      else
+	  stop("Found NAs but no missing value attribute", call.=FALSE)
     }
 
+    #-- Switch from R to C convention ------------------------------------------#
+    c.start <- rev(start-1)
+    c.count <- rev(count)
+
     #-- C function calls -------------------------------------------------------#
-    if(is.numeric(data))
+    if(is.numeric(data)) {
+        if (!is.double(data)) {
+          data <- as.double(data)
+        }
 	nc <- .Call("R_nc_put_vara_double",
         	    as.integer(ncfile),
 		    as.integer(varid),
 		    as.integer(c.start),
 		    as.integer(c.count),
-		    as.double(data),
+		    as.integer(ndims),
+		    data,
 		    PACKAGE="RNetCDF")
-    else
+    } else {
+        stopifnot(is.character(data) || is.raw(data))
         nc <- .Call("R_nc_put_vara_text",
         	    as.integer(ncfile),
 		    as.integer(varid),
 		    as.integer(c.start),
 		    as.integer(c.count),
-		    as.character(data),
-		    as.integer(varsize),
+		    as.integer(ndims),
+                    as.integer(is.raw(data)),
+		    data,
 		    PACKAGE="RNetCDF")
+    }
 		    
     if(nc$status != 0)
         stop(nc$errmsg, call.=FALSE)
diff --git a/R/load.R.in b/R/load.R.in
index 0e79a67..3b18b7c 100644
--- a/R/load.R.in
+++ b/R/load.R.in
@@ -1,10 +1,20 @@
 ".onLoad" <- function(lib, pkg) {
-    datfile <- system.file("udunits.dat", package=pkg)
-    if(nzchar(datfile))
-        Sys.setenv("UDUNITS_PATH"=datfile)
-    xmlfile <- system.file("udunits", "udunits2.xml", package=pkg)
-    if(nzchar(xmlfile))
-        Sys.setenv("UDUNITS2_XML_PATH"=xmlfile)
-
-    utinit.nc("@udunits_dat_file@")
+
+    # Check environment for name of @UDUNITS_LIB@ database requested by user:
+    envdb <- Sys.getenv("@UDUNITS_DBVAR@", unset=NA)
+
+    if (is.na(envdb)) {
+        # Initialise @UDUNITS_LIB@ library with database packaged in RNetCDF:
+        datafile <- system.file("udunits", "@UDUNITS_DBFILE@", package=pkg, lib.loc=lib)
+        if ("@UDUNITS_LIB@" == "udunits2") {
+            # udunits2 ignores argument passed to utInit C function
+            Sys.setenv(@UDUNITS_DBVAR@=datafile)
+        }
+        utinit.nc(datafile)
+    } else {
+        # Initialise @UDUNITS_LIB@ library with user-specified database:
+        utinit.nc("")
+    }
+
 }
+
diff --git a/R/windows/load.R b/R/windows/load.R
old mode 100644
new mode 100755
index 57d1911..3e254f1
--- a/R/windows/load.R
+++ b/R/windows/load.R
@@ -1,4 +1,22 @@
-".onLoad" <- function(libname, pkgname) {
-    Sys.setenv(UDUNITS2_XML_PATH = file.path(libname, pkgname, "share/udunits/udunits2.xml"))
-    utinit.nc("")
+# Assume that RNetCDF is linked with udunits2 library on Windows.
+
+".onLoad" <- function(lib, pkg) {
+
+    # Check environment for name of udunits2 database requested by user:
+    envdb <- Sys.getenv("UDUNITS2_XML_PATH", unset=NA)
+
+    if (is.na(envdb)) {
+        # Initialise udunits2 library with database packaged in RNetCDF:
+        datafile <- system.file("udunits", "udunits2.xml", package=pkg, lib.loc=lib)
+        if ("udunits2" == "udunits2") {
+            # udunits2 ignores argument passed to utInit C function
+            Sys.setenv(UDUNITS2_XML_PATH=datafile)
+        }
+        utinit.nc(datafile)
+    } else {
+        # Initialise udunits2 library with user-specified database:
+        utinit.nc("")
+    }
+
 }
+
diff --git a/configure b/configure
index 05f3ce0..cb42e22 100755
--- a/configure
+++ b/configure
@@ -1,13 +1,9 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for RNetCDF 1.6.3-1.
+# Generated by GNU Autoconf 2.69 for RNetCDF 1.7-3.
 #
-# Report bugs to <michna at giub.unibe.ch>.
 #
-#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -136,6 +132,31 @@ export LANGUAGE
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -169,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -214,21 +236,25 @@ IFS=$as_save_IFS
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-	# neutralization value for shells without unset; and this also
-	# works around shells that cannot unset nonexistent variables.
-	# Preserve -v and -x to the replacement shell.
-	BASH_ENV=/dev/null
-	ENV=/dev/null
-	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-	export CONFIG_SHELL
-	case $- in # ((((
-	  *v*x* | *x*v* ) as_opts=-vx ;;
-	  *v* ) as_opts=-v ;;
-	  *x* ) as_opts=-x ;;
-	  * ) as_opts= ;;
-	esac
-	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
 fi
 
     if test x$as_have_required = xno; then :
@@ -238,11 +264,10 @@ fi
     $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
     $as_echo "$0: be upgraded to zsh 4.3.4 or later."
   else
-    $as_echo "$0: Please tell bug-autoconf at gnu.org and
-$0: michna at giub.unibe.ch about your system, including any
-$0: error possibly output before this message. Then install
-$0: a modern shell, or manually run the script under such a
-$0: shell if you do have one."
+    $as_echo "$0: Please tell bug-autoconf at gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
   fi
   exit 1
 fi
@@ -331,6 +356,14 @@ $as_echo X"$as_dir" |
 
 
 } # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -452,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -486,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -507,28 +544,8 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -560,9 +577,9 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='RNetCDF'
 PACKAGE_TARNAME='rnetcdf'
-PACKAGE_VERSION='1.6.3-1'
-PACKAGE_STRING='RNetCDF 1.6.3-1'
-PACKAGE_BUGREPORT='michna at giub.unibe.ch'
+PACKAGE_VERSION='1.7-3'
+PACKAGE_STRING='RNetCDF 1.7-3'
+PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
 # Factoring default headers for most tests.
@@ -603,17 +620,19 @@ ac_includes_default="\
 
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
-udunits_dat_file
+UDUNITS_DBVAR
+UDUNITS_DBFILE
+UDUNITS_LIB
 EGREP
 GREP
 CPP
 OBJEXT
 EXEEXT
 ac_ct_CC
+CPPFLAGS
 LDFLAGS
 CFLAGS
 CC
-CPPFLAGS
 target_alias
 host_alias
 build_alias
@@ -657,11 +676,9 @@ ac_user_opts='
 enable_option_checking
 with_netcdf_include
 with_netcdf_lib
+with_hdf5_lib
 with_udunits_include
 with_udunits_lib
-with_udunits_dat
-with_hdf5_lib
-enable_units_copy
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1127,8 +1144,6 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1214,7 +1229,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 RNetCDF 1.6.3-1 to adapt to many kinds of systems.
+\`configure' configures RNetCDF 1.7-3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1275,29 +1290,20 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of RNetCDF 1.6.3-1:";;
+     short | recursive ) echo "Configuration of RNetCDF 1.7-3:";;
    esac
   cat <<\_ACEOF
 
-Optional Features:
-  --disable-option-checking  ignore unrecognized --enable/--with options
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --enable-units-copy[=PATH]
-                          place a local copy of units data file(s) in the
-                          package [no]
-
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-netcdf-include=DIR
-                          location of netcdf header files
-  --with-netcdf-lib=DIR   location of netcdf libraries
+                          directory with netcdf header files
+  --with-netcdf-lib=DIR   directory with netcdf libraries
+  --with-hdf5-lib=DIR     directory with hdf5 libraries
   --with-udunits-include=DIR
-                          location of udunits header files
-  --with-udunits-lib=DIR  location of udunits libraries
-  --with-udunits-dat=FILE location of udunits.dat file
-  --with-hdf5-lib=DIR     location of hdf5 libraries
+                          directory with udunits header files
+  --with-udunits-lib=DIR  directory with udunits libraries
 
 Some influential environment variables:
   CC          C compiler command
@@ -1312,7 +1318,7 @@ Some influential environment variables:
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
-Report bugs to <michna at giub.unibe.ch>.
+Report bugs to the package provider.
 _ACEOF
 ac_status=$?
 fi
@@ -1375,10 +1381,10 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-RNetCDF configure 1.6.3-1
-generated by GNU Autoconf 2.68
+RNetCDF configure 1.7-3
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1454,7 +1460,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1580,10 +1586,6 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
 $as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## ----------------------------------- ##
-## Report this to michna at giub.unibe.ch ##
-## ----------------------------------- ##"
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
@@ -1677,8 +1679,8 @@ 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 RNetCDF $as_me 1.6.3-1, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+It was created by RNetCDF $as_me 1.7-3, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -2035,77 +2037,39 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 # Check whether --with-netcdf-include was given.
 if test "${with_netcdf_include+set}" = set; then :
-  withval=$with_netcdf_include; netcdf_include_path=$withval
+  withval=$with_netcdf_include; CPPFLAGS="-I${withval} ${CPPFLAGS}"
 fi
 
-if test  -n "$netcdf_include_path"  ; then
-   CPPFLAGS="-I${netcdf_include_path} ${CPPFLAGS}"
-
-fi
 
 
 # Check whether --with-netcdf-lib was given.
 if test "${with_netcdf_lib+set}" = set; then :
-  withval=$with_netcdf_lib; netcdf_lib_path=$withval
+  withval=$with_netcdf_lib; LDFLAGS="-L${withval} ${LDFLAGS}"
 fi
 
-if test  -n "$netcdf_lib_path"  ; then
-   LIBS="-L${netcdf_lib_path} ${LIBS}"
 
+#-- Optional include path for HDF5 ---------------------------------------------#
+
+# Check whether --with-hdf5-lib was given.
+if test "${with_hdf5_lib+set}" = set; then :
+  withval=$with_hdf5_lib; LDFLAGS="-L${withval} ${LDFLAGS}"
 fi
 
+
 #-- UDUNITS include and library path -------------------------------------------#
 
 # Check whether --with-udunits-include was given.
 if test "${with_udunits_include+set}" = set; then :
-  withval=$with_udunits_include; udunits_include_path=$withval
+  withval=$with_udunits_include; CPPFLAGS="-I${withval} ${CPPFLAGS}"
 fi
 
-if test  -n "$udunits_include_path"  ; then
-   CPPFLAGS="-I${udunits_include_path} ${CPPFLAGS}"
-
-fi
 
 
 # Check whether --with-udunits-lib was given.
 if test "${with_udunits_lib+set}" = set; then :
-  withval=$with_udunits_lib; udunits_lib_path=$withval
+  withval=$with_udunits_lib; LDFLAGS="-L${withval} ${LDFLAGS}"
 fi
 
-if test  -n "$udunits_lib_path"  ; then
-   LIBS="-L${udunits_lib_path} ${LIBS}"
-
-fi
-
-#-- Optional include path for udunits.dat (UDUNITS 1) --------------------------#
-
-# Check whether --with-udunits-dat was given.
-if test "${with_udunits_dat+set}" = set; then :
-  withval=$with_udunits_dat; udunits_dat_file=$withval
-fi
-
-
-#-- Optional include path for HDF5 ---------------------------------------------#
-
-# Check whether --with-hdf5-lib was given.
-if test "${with_hdf5_lib+set}" = set; then :
-  withval=$with_hdf5_lib; hdf5_lib_path=$withval
-fi
-
-if test  -n "$hdf5_lib_path"  ; then
-   LIBS="-L${hdf5_lib_path} ${LIBS}"
-
-fi
-
-#-- Optional local copy of units file(s) (UDUNITS 1 and 2) ---------------------#
-# Check whether --enable-units-copy was given.
-if test "${enable_units_copy+set}" = set; then :
-  enableval=$enable_units_copy; do_units_copy="${enableval}"
-else
-  do_units_copy=no
-fi
-
-
 
 #-------------------------------------------------------------------------------#
 #  Find the compiler and compiler options to use   	                 	#
@@ -2120,6 +2084,8 @@ CC=`${R_HOME}/bin/R CMD config CC`
 CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
 
 #-- Check for NetCDF and UDUNITS library ---------------------------------------#
+
+# Test for libraries that may be needed for linking.
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -2142,7 +2108,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2182,7 +2148,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2235,7 +2201,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2276,7 +2242,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -2334,7 +2300,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2378,7 +2344,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2824,8 +2790,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -2911,13 +2876,13 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nc_open in -lnetcdf" >&5
-$as_echo_n "checking for nc_open in -lnetcdf... " >&6; }
-if ${ac_cv_lib_netcdf_nc_open+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5
+$as_echo_n "checking for cos in -lm... " >&6; }
+if ${ac_cv_lib_m_cos+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnetcdf  $LIBS"
+LIBS="-lm  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -2927,42 +2892,87 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char nc_open ();
+char cos ();
 int
 main ()
 {
-return nc_open ();
+return cos ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_netcdf_nc_open=yes
+  ac_cv_lib_m_cos=yes
 else
-  ac_cv_lib_netcdf_nc_open=no
+  ac_cv_lib_m_cos=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_netcdf_nc_open" >&5
-$as_echo "$ac_cv_lib_netcdf_nc_open" >&6; }
-if test "x$ac_cv_lib_netcdf_nc_open" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5
+$as_echo "$ac_cv_lib_m_cos" >&6; }
+if test "x$ac_cv_lib_m_cos" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBNETCDF 1
+#define HAVE_LIBM 1
 _ACEOF
 
-  LIBS="-lnetcdf $LIBS"
+  LIBS="-lm $LIBS"
 
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nc_create in -lnetcdf" >&5
-$as_echo_n "checking for nc_create in -lnetcdf... " >&6; }
-if ${ac_cv_lib_netcdf_nc_create+:} false; then :
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflate in -lz" >&5
+$as_echo_n "checking for deflate in -lz... " >&6; }
+if ${ac_cv_lib_z_deflate+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnetcdf -lhdf5 -lhdf5_hl -lcurl -lz $LIBS"
+LIBS="-lz  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -2972,46 +2982,132 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char nc_create ();
+char deflate ();
 int
 main ()
 {
-return nc_create ();
+return deflate ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_netcdf_nc_create=yes
+  ac_cv_lib_z_deflate=yes
 else
-  ac_cv_lib_netcdf_nc_create=no
+  ac_cv_lib_z_deflate=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_netcdf_nc_create" >&5
-$as_echo "$ac_cv_lib_netcdf_nc_create" >&6; }
-if test "x$ac_cv_lib_netcdf_nc_create" = xyes; then :
-  have_netcdf_hdf5=TRUE
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflate" >&5
+$as_echo "$ac_cv_lib_z_deflate" >&6; }
+if test "x$ac_cv_lib_z_deflate" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBZ 1
+_ACEOF
+
+  LIBS="-lz $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for curl_easy_init in -lcurl" >&5
+$as_echo_n "checking for curl_easy_init in -lcurl... " >&6; }
+if ${ac_cv_lib_curl_curl_easy_init+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcurl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char curl_easy_init ();
+int
+main ()
+{
+return curl_easy_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_curl_curl_easy_init=yes
 else
-  as_fn_error $? "netcdf library not found" "$LINENO" 5
+  ac_cv_lib_curl_curl_easy_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curl_curl_easy_init" >&5
+$as_echo "$ac_cv_lib_curl_curl_easy_init" >&6; }
+if test "x$ac_cv_lib_curl_curl_easy_init" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBCURL 1
+_ACEOF
 
-    if test "${have_netcdf_hdf5}" = TRUE; then
-        LIBS="${LIBS} -lnetcdf -lhdf5 -lhdf5_hl -lcurl -lz"
-    fi
+  LIBS="-lcurl $LIBS"
+
+fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML_Parse in -lexpat" >&5
+$as_echo_n "checking for XML_Parse in -lexpat... " >&6; }
+if ${ac_cv_lib_expat_XML_Parse+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lexpat  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char XML_Parse ();
+int
+main ()
+{
+return XML_Parse ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_expat_XML_Parse=yes
+else
+  ac_cv_lib_expat_XML_Parse=no
 fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_expat_XML_Parse" >&5
+$as_echo "$ac_cv_lib_expat_XML_Parse" >&6; }
+if test "x$ac_cv_lib_expat_XML_Parse" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBEXPAT 1
+_ACEOF
+
+  LIBS="-lexpat $LIBS"
 
+fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for utInit in -ludunits2" >&5
-$as_echo_n "checking for utInit in -ludunits2... " >&6; }
-if ${ac_cv_lib_udunits2_utInit+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for H5open in -lhdf5" >&5
+$as_echo_n "checking for H5open in -lhdf5... " >&6; }
+if ${ac_cv_lib_hdf5_H5open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-ludunits2  $LIBS"
+LIBS="-lhdf5  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -3021,45 +3117,90 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char utInit ();
+char H5open ();
 int
 main ()
 {
-return utInit ();
+return H5open ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_udunits2_utInit=yes
+  ac_cv_lib_hdf5_H5open=yes
 else
-  ac_cv_lib_udunits2_utInit=no
+  ac_cv_lib_hdf5_H5open=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_udunits2_utInit" >&5
-$as_echo "$ac_cv_lib_udunits2_utInit" >&6; }
-if test "x$ac_cv_lib_udunits2_utInit" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_H5open" >&5
+$as_echo "$ac_cv_lib_hdf5_H5open" >&6; }
+if test "x$ac_cv_lib_hdf5_H5open" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUDUNITS2 1
+#define HAVE_LIBHDF5 1
 _ACEOF
 
-  LIBS="-ludunits2 $LIBS"
+  LIBS="-lhdf5 $LIBS"
 
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for H5DSset_scale in -lhdf5_hl" >&5
+$as_echo_n "checking for H5DSset_scale in -lhdf5_hl... " >&6; }
+if ${ac_cv_lib_hdf5_hl_H5DSset_scale+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  have_udunits=FALSE
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lhdf5_hl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char H5DSset_scale ();
+int
+main ()
+{
+return H5DSset_scale ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_hdf5_hl_H5DSset_scale=yes
+else
+  ac_cv_lib_hdf5_hl_H5DSset_scale=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_hl_H5DSset_scale" >&5
+$as_echo "$ac_cv_lib_hdf5_hl_H5DSset_scale" >&6; }
+if test "x$ac_cv_lib_hdf5_hl_H5DSset_scale" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBHDF5_HL 1
+_ACEOF
 
-if test "${have_udunits}" = FALSE; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for utScan in -ludunits2" >&5
+  LIBS="-lhdf5_hl $LIBS"
+
+fi
+
+
+# Test udunits2 then udunits library:
+have_udunits2="yes"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for utScan in -ludunits2" >&5
 $as_echo_n "checking for utScan in -ludunits2... " >&6; }
 if ${ac_cv_lib_udunits2_utScan+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-ludunits2 -lexpat $LIBS"
+LIBS="-ludunits2  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -3097,13 +3238,18 @@ _ACEOF
   LIBS="-ludunits2 $LIBS"
 
 else
-  have_udunits_expat=FALSE
+  have_udunits2=no
 fi
 
-    if test "${have_udunits_expat}" = FALSE; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ludunits" >&5
-$as_echo_n "checking for main in -ludunits... " >&6; }
-if ${ac_cv_lib_udunits_main+:} false; then :
+if test "$have_udunits2" == yes; then
+    UDUNITS_LIB=udunits2
+    UDUNITS_DBFILE=udunits2.xml
+    UDUNITS_DBVAR="UDUNITS2_XML_PATH"
+else
+    have_udunits1="yes"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for utScan in -ludunits" >&5
+$as_echo_n "checking for utScan in -ludunits... " >&6; }
+if ${ac_cv_lib_udunits_utScan+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -3111,27 +3257,33 @@ LIBS="-ludunits  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char utScan ();
 int
 main ()
 {
-return main ();
+return utScan ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_udunits_main=yes
+  ac_cv_lib_udunits_utScan=yes
 else
-  ac_cv_lib_udunits_main=no
+  ac_cv_lib_udunits_utScan=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_udunits_main" >&5
-$as_echo "$ac_cv_lib_udunits_main" >&6; }
-if test "x$ac_cv_lib_udunits_main" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_udunits_utScan" >&5
+$as_echo "$ac_cv_lib_udunits_utScan" >&6; }
+if test "x$ac_cv_lib_udunits_utScan" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBUDUNITS 1
 _ACEOF
@@ -3139,15 +3291,69 @@ _ACEOF
   LIBS="-ludunits $LIBS"
 
 else
-  as_fn_error $? "udunits library not found" "$LINENO" 5
+  have_udunits1=no
 fi
 
+    if test "$have_udunits1" == yes ; then
+        UDUNITS_LIB=udunits
+        UDUNITS_DBFILE=udunits.dat
+        UDUNITS_DBVAR="UDUNITS_PATH"
     else
-        LIBS="${LIBS} -lexpat"
+        as_fn_error $? "\"neither udunits2 nor udunits library was found\"" "$LINENO" 5
     fi
 fi
 
+# Test netcdf library:
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nc_open in -lnetcdf" >&5
+$as_echo_n "checking for nc_open in -lnetcdf... " >&6; }
+if ${ac_cv_lib_netcdf_nc_open+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnetcdf  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char nc_open ();
+int
+main ()
+{
+return nc_open ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_netcdf_nc_open=yes
+else
+  ac_cv_lib_netcdf_nc_open=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_netcdf_nc_open" >&5
+$as_echo "$ac_cv_lib_netcdf_nc_open" >&6; }
+if test "x$ac_cv_lib_netcdf_nc_open" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBNETCDF 1
+_ACEOF
+
+  LIBS="-lnetcdf $LIBS"
+
+else
+  as_fn_error $? "\"netcdf library not found\"" "$LINENO" 5
+fi
+
+
 #-- Check for netcdf.h and udunits.h -------------------------------------------#
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3302,7 +3508,7 @@ do
     for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+      as_fn_executable_p "$ac_path_GREP" || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -3368,7 +3574,7 @@ do
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+      as_fn_executable_p "$ac_path_EGREP" || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -3554,13 +3760,23 @@ if test "x$ac_cv_header_netcdf_h" = xyes; then :
 _ACEOF
 
 else
-  as_fn_error $? "netcdf header netcdf.h not found" "$LINENO" 5
+  as_fn_error $? "\"netcdf header netcdf.h not found\"" "$LINENO" 5
 fi
 
 done
 
 
-for ac_header in udunits.h
+if test "$have_udunits2" == yes; then
+  for ac_header in udunits2/udunits.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "udunits2/udunits.h" "ac_cv_header_udunits2_udunits_h" "$ac_includes_default"
+if test "x$ac_cv_header_udunits2_udunits_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UDUNITS2_UDUNITS_H 1
+_ACEOF
+
+else
+  for ac_header in udunits.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "udunits.h" "ac_cv_header_udunits_h" "$ac_includes_default"
 if test "x$ac_cv_header_udunits_h" = xyes; then :
@@ -3569,40 +3785,31 @@ if test "x$ac_cv_header_udunits_h" = xyes; then :
 _ACEOF
 
 else
-  as_fn_error $? "udunits header udunits.h not found" "$LINENO" 5
+  as_fn_error $? "\"udunits2 headers not found\"" "$LINENO" 5
 fi
 
 done
 
+fi
 
-#-- Make local copy of units file(s) (UDUNITS 1 and 2) if requested ------------#
-if test "${do_units_copy}" != no ; then
-    if test "${do_units_copy}" = yes ; then
-        do_units_copy="${udunits_dat_file}"
-    fi
+done
 
-    if test -z "${do_units_copy}" ; then
-        for dir in /usr/share/udunits /usr/local/share/udunits \
-             /usr/etc/udunits.dat /usr/local/etc/udunits.dat ; do
-            if test -e "${dir}" ; then
-	        do_units_copy="${dir}"
-	        break
-	    fi
-        done
-        if test -z "${do_units_copy}" ; then
-	    as_fn_error $? "cannot find units file(s) to copy - use --enable-units-copy=PATH" "$LINENO" 5
-        fi
-    fi
+else
+  for ac_header in udunits.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "udunits.h" "ac_cv_header_udunits_h" "$ac_includes_default"
+if test "x$ac_cv_header_udunits_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UDUNITS_H 1
+_ACEOF
 
-    if test -d "${do_units_copy}" ; then
-        mkdir -p inst/udunits 2>/dev/null
-        cp -p "${do_units_copy}"/udunits*.xml inst/udunits/
-    else
-        mkdir inst 2>/dev/null
-        cp -p "${do_units_copy}" inst/udunits.dat
-    fi
+else
+  as_fn_error $? "\"udunits headers not found\"" "$LINENO" 5
 fi
 
+done
+
+fi
 
 #-------------------------------------------------------------------------------#
 #  Do substitution                               	                 	#
@@ -4056,16 +4263,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -4125,28 +4332,16 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -4167,8 +4362,8 @@ 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 RNetCDF $as_me 1.6.3-1, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+This file was extended by RNetCDF $as_me 1.7-3, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -4214,17 +4409,17 @@ Usage: $0 [OPTION]... [TAG]...
 Configuration files:
 $config_files
 
-Report bugs to <michna at giub.unibe.ch>."
+Report bugs to the package provider."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-RNetCDF config.status 1.6.3-1
-configured by $0, generated by GNU Autoconf 2.68,
+RNetCDF config.status 1.7-3
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -4301,7 +4496,7 @@ fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
diff --git a/configure.ac b/configure.ac
old mode 100755
new mode 100644
index 7488bae..2d69bbe
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 #  Initialize                                                    		#
 #-------------------------------------------------------------------------------#
 
-AC_INIT([RNetCDF], 1.6.3-1, [michna at giub.unibe.ch])
+AC_INIT([RNetCDF], 1.7-3)
 
 
 #-------------------------------------------------------------------------------#
@@ -12,58 +12,30 @@ AC_INIT([RNetCDF], 1.6.3-1, [michna at giub.unibe.ch])
 #-- NetCDF include and library path --------------------------------------------#
 AC_ARG_WITH([netcdf-include],
     AC_HELP_STRING([--with-netcdf-include=DIR],
-                   [location of netcdf header files]),
-    [netcdf_include_path=$withval])
-if test [ -n "$netcdf_include_path" ] ; then
-   AC_SUBST([CPPFLAGS],["-I${netcdf_include_path} ${CPPFLAGS}"])
-fi
+                   [directory with netcdf header files]),
+    [CPPFLAGS="-I${withval} ${CPPFLAGS}"])
 
 AC_ARG_WITH([netcdf-lib],
     AC_HELP_STRING([--with-netcdf-lib=DIR],
-                   [location of netcdf libraries]),
-    [netcdf_lib_path=$withval])
-if test [ -n "$netcdf_lib_path" ] ; then
-   AC_SUBST([LIBS],["-L${netcdf_lib_path} ${LIBS}"])
-fi
+                   [directory with netcdf libraries]),
+    [LDFLAGS="-L${withval} ${LDFLAGS}"])
+
+#-- Optional include path for HDF5 ---------------------------------------------#
+AC_ARG_WITH([hdf5-lib],
+    AC_HELP_STRING([--with-hdf5-lib=DIR],
+                   [directory with hdf5 libraries]),
+    [LDFLAGS="-L${withval} ${LDFLAGS}"])
 
 #-- UDUNITS include and library path -------------------------------------------#
 AC_ARG_WITH([udunits-include],
     AC_HELP_STRING([--with-udunits-include=DIR],
-                   [location of udunits header files]),
-    [udunits_include_path=$withval])
-if test [ -n "$udunits_include_path" ] ; then
-   AC_SUBST([CPPFLAGS],["-I${udunits_include_path} ${CPPFLAGS}"])
-fi
+                   [directory with udunits header files]),
+    [CPPFLAGS="-I${withval} ${CPPFLAGS}"])
 
 AC_ARG_WITH([udunits-lib],
     AC_HELP_STRING([--with-udunits-lib=DIR],
-                   [location of udunits libraries]),
-    [udunits_lib_path=$withval])
-if test [ -n "$udunits_lib_path" ] ; then
-   AC_SUBST([LIBS],["-L${udunits_lib_path} ${LIBS}"])
-fi
-
-#-- Optional include path for udunits.dat (UDUNITS 1) --------------------------#
-AC_ARG_WITH([udunits-dat],
-    AC_HELP_STRING([--with-udunits-dat=FILE],
-                   [location of udunits.dat file]),
-    [udunits_dat_file=$withval])
-
-#-- Optional include path for HDF5 ---------------------------------------------#
-AC_ARG_WITH([hdf5-lib],
-    AC_HELP_STRING([--with-hdf5-lib=DIR],
-                   [location of hdf5 libraries]),
-    [hdf5_lib_path=$withval])
-if test [ -n "$hdf5_lib_path" ] ; then
-   AC_SUBST([LIBS],["-L${hdf5_lib_path} ${LIBS}"])
-fi
-
-#-- Optional local copy of units file(s) (UDUNITS 1 and 2) ---------------------#
-AC_ARG_ENABLE([units-copy],
-    AC_HELP_STRING([--enable-units-copy@<:@=PATH@:>@],
-                   [place a local copy of units data file(s) in the package @<:@no@:>@]),
-    [do_units_copy="${enableval}"], [do_units_copy=no])
-
+                   [directory with udunits libraries]),
+    [LDFLAGS="-L${withval} ${LDFLAGS}"])
 
 #-------------------------------------------------------------------------------#
 #  Find the compiler and compiler options to use   	                 	#
@@ -78,67 +50,58 @@ CC=`${R_HOME}/bin/R CMD config CC`
 CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
 
 #-- Check for NetCDF and UDUNITS library ---------------------------------------#
-AC_CHECK_LIB(netcdf, nc_open, [],
-[
-    AC_CHECK_LIB(netcdf, nc_create, [have_netcdf_hdf5=TRUE],
-                 AC_MSG_ERROR(netcdf library not found),
-                 [-lhdf5 -lhdf5_hl -lcurl -lz])
-    if test "${have_netcdf_hdf5}" = TRUE; then
-        LIBS="${LIBS} -lnetcdf -lhdf5 -lhdf5_hl -lcurl -lz"
-    fi
-])
 
-AC_CHECK_LIB(udunits2, utInit, [], [have_udunits=FALSE])
-if test "${have_udunits}" = FALSE; then
-    AC_CHECK_LIB(udunits2, utScan, [], [have_udunits_expat=FALSE], [-lexpat])
-    if test "${have_udunits_expat}" = FALSE; then
-        AC_CHECK_LIB(udunits, main, [], AC_MSG_ERROR(udunits library not found))
+# Test for libraries that may be needed for linking.
+AC_CHECK_LIB(m,cos)
+AC_CHECK_LIB(dl,dlopen)
+AC_CHECK_LIB(z,deflate)
+AC_CHECK_LIB(curl,curl_easy_init)
+AC_CHECK_LIB(expat,XML_Parse)
+AC_CHECK_LIB(hdf5,H5open)
+AC_CHECK_LIB(hdf5_hl,H5DSset_scale)
+
+# Test udunits2 then udunits library:
+have_udunits2="yes"
+AC_CHECK_LIB(udunits2, utScan, [], [have_udunits2=no])
+if test "$have_udunits2" == yes; then
+    UDUNITS_LIB=udunits2
+    UDUNITS_DBFILE=udunits2.xml
+    UDUNITS_DBVAR="UDUNITS2_XML_PATH"
+else
+    have_udunits1="yes"
+    AC_CHECK_LIB(udunits, utScan, [], [have_udunits1=no])
+    if test "$have_udunits1" == yes ; then
+        UDUNITS_LIB=udunits
+        UDUNITS_DBFILE=udunits.dat
+        UDUNITS_DBVAR="UDUNITS_PATH"
     else
-        LIBS="${LIBS} -lexpat"
+        AC_MSG_ERROR("neither udunits2 nor udunits library was found")
     fi
 fi
 
-#-- Check for netcdf.h and udunits.h -------------------------------------------#
-AC_CHECK_HEADERS(netcdf.h, [], AC_MSG_ERROR(netcdf header netcdf.h not found))
+# Test netcdf library:
+AC_CHECK_LIB(netcdf, nc_open, [],
+    AC_MSG_ERROR("netcdf library not found"))
 
-AC_CHECK_HEADERS(udunits.h, [], AC_MSG_ERROR(udunits header udunits.h not found))
+#-- Check for netcdf.h and udunits.h -------------------------------------------#
 
-#-- Make local copy of units file(s) (UDUNITS 1 and 2) if requested ------------#
-if test "${do_units_copy}" != no ; then
-    if test "${do_units_copy}" = yes ; then 
-        do_units_copy="${udunits_dat_file}"
-    fi
-     
-    if test -z "${do_units_copy}" ; then
-        for dir in /usr/share/udunits /usr/local/share/udunits \
-             /usr/etc/udunits.dat /usr/local/etc/udunits.dat ; do
-            if test -e "${dir}" ; then
-	        do_units_copy="${dir}"
-	        break
-	    fi
-        done
-        if test -z "${do_units_copy}" ; then
-	    AC_MSG_ERROR([cannot find units file(s) to copy - use --enable-units-copy=PATH])
-        fi
-    fi
+AC_CHECK_HEADERS(netcdf.h, [], AC_MSG_ERROR("netcdf header netcdf.h not found"))
 
-    if test -d "${do_units_copy}" ; then
-        mkdir -p inst/udunits 2>/dev/null
-        cp -p "${do_units_copy}"/udunits*.xml inst/udunits/
-    else
-        mkdir inst 2>/dev/null
-        cp -p "${do_units_copy}" inst/udunits.dat
-    fi
+if test "$have_udunits2" == yes; then
+  AC_CHECK_HEADERS(udunits2/udunits.h, [],
+    AC_CHECK_HEADERS(udunits.h, [],
+      AC_MSG_ERROR("udunits2 headers not found")))
+else
+  AC_CHECK_HEADERS(udunits.h, [], AC_MSG_ERROR("udunits headers not found"))
 fi
 
-
 #-------------------------------------------------------------------------------#
 #  Do substitution                               	                 	#
 #-------------------------------------------------------------------------------#
 
-AC_SUBST(CPPFLAGS)
-AC_SUBST(LIBS)
-AC_SUBST(udunits_dat_file)
+AC_SUBST(UDUNITS_LIB)
+AC_SUBST(UDUNITS_DBFILE)
+AC_SUBST(UDUNITS_DBVAR)
 AC_OUTPUT(R/load.R
           src/Makevars)
 
diff --git a/configure.win b/configure.win
index 156807a..e69de29 100755
--- a/configure.win
+++ b/configure.win
@@ -1,2 +0,0 @@
-mkdir -p ${R_PACKAGE_DIR}/share
-cp -r ${UDUNITS2_HOME}/share/udunits ${R_PACKAGE_DIR}/share
diff --git a/inst/HDF5_COPYING b/inst/HDF5_COPYING
deleted file mode 100644
index c9e8165..0000000
--- a/inst/HDF5_COPYING
+++ /dev/null
@@ -1,97 +0,0 @@
-Although this package does not itself use HDF5, if statically linked
-to a build of netcdf with the netcdf4 feature included it will link in
-code from HDF5, in which case the following licence applies to such code.
-
-=======================================================================
-
-Copyright Notice and License Terms for 
-HDF5 (Hierarchical Data Format 5) Software Library and Utilities
------------------------------------------------------------------------------
-
-HDF5 (Hierarchical Data Format 5) Software Library and Utilities
-Copyright 2006-2012 by The HDF Group.
-
-NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities
-Copyright 1998-2006 by the Board of Trustees of the University of Illinois.
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without 
-modification, are permitted for any purpose (including commercial purposes) 
-provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, 
-   this list of conditions, and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice, 
-   this list of conditions, and the following disclaimer in the documentation 
-   and/or materials provided with the distribution.
-
-3. In addition, redistributions of modified forms of the source or binary 
-   code must carry prominent notices stating that the original code was 
-   changed and the date of the change.
-
-4. All publications or advertising materials mentioning features or use of 
-   this software are asked, but not required, to acknowledge that it was 
-   developed by The HDF Group and by the National Center for Supercomputing 
-   Applications at the University of Illinois at Urbana-Champaign and 
-   credit the contributors.
-
-5. Neither the name of The HDF Group, the name of the University, nor the 
-   name of any Contributor may be used to endorse or promote products derived 
-   from this software without specific prior written permission from 
-   The HDF Group, the University, or the Contributor, respectively.
-
-DISCLAIMER: 
-THIS SOFTWARE IS PROVIDED BY THE HDF GROUP AND THE CONTRIBUTORS 
-"AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED.  In no 
-event shall The HDF Group or the Contributors be liable for any damages 
-suffered by the users arising out of the use of this software, even if 
-advised of the possibility of such damage. 
-
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-
-Contributors:   National Center for Supercomputing Applications (NCSA) at 
-the University of Illinois, Fortner Software, Unidata Program Center (netCDF), 
-The Independent JPEG Group (JPEG), Jean-loup Gailly and Mark Adler (gzip), 
-and Digital Equipment Corporation (DEC).
-
------------------------------------------------------------------------------
-
-Portions of HDF5 were developed with support from the Lawrence Berkeley 
-National Laboratory (LBNL) and the United States Department of Energy 
-under Prime Contract No. DE-AC02-05CH11231.
-
------------------------------------------------------------------------------
-
-Portions of HDF5 were developed with support from the University of 
-California, Lawrence Livermore National Laboratory (UC LLNL).  
-The following statement applies to those portions of the product and must 
-be retained in any redistribution of source code, binaries, documentation, 
-and/or accompanying materials:
-
-   This work was partially produced at the University of California, 
-   Lawrence Livermore National Laboratory (UC LLNL) under contract 
-   no. W-7405-ENG-48 (Contract 48) between the U.S. Department of Energy 
-   (DOE) and The Regents of the University of California (University) 
-   for the operation of UC LLNL.
-
-   DISCLAIMER: 
-   This work was prepared as an account of work sponsored by an agency of 
-   the United States Government. Neither the United States Government nor 
-   the University of California nor any of their employees, makes any 
-   warranty, express or implied, or assumes any liability or responsibility 
-   for the accuracy, completeness, or usefulness of any information, 
-   apparatus, product, or process disclosed, or represents that its use 
-   would not infringe privately- owned rights. Reference herein to any 
-   specific commercial products, process, or service by trade name, 
-   trademark, manufacturer, or otherwise, does not necessarily constitute 
-   or imply its endorsement, recommendation, or favoring by the United 
-   States Government or the University of California. The views and 
-   opinions of authors expressed herein do not necessarily state or reflect 
-   those of the United States Government or the University of California, 
-   and shall not be used for advertising or product endorsement purposes.
------------------------------------------------------------------------------
-
-
diff --git a/inst/udunits/udunits.dat b/inst/udunits/udunits.dat
new file mode 100644
index 0000000..e9c9aa1
--- /dev/null
+++ b/inst/udunits/udunits.dat
@@ -0,0 +1,713 @@
+# $Id: udunits.dat,v 1.19 2009/09/17 16:23:50 steve Exp $
+#
+# The first column is the unit name.  The second column indicates whether or
+# not the unit name has a plural form (i.e. with an 's' appended).  
+# A 'P' indicates that the unit has a plural form, whereas, a 'S' indicates
+# that the unit has a singular form only.  The remainder of the line is the 
+# definition for the unit.
+#
+# '#' is the to-end-of-line comment-character.
+#
+# NB: When adding to this table, be *very* careful to distinquish between
+# the letter 'O' and the numeral zero '0'.  For example, the following two
+# entries don't do what one might otherwise expect:
+#
+#	mercury_0C		mercury_32F
+#	millimeter_Hg_0C	mm mercury_OC
+
+#
+# BASE UNITS.  These must be first and are identified by a nil definition.
+#
+ampere			P			# electric current
+count			P			# dimensionless decimal number
+candela			P			# luminous intensity
+kelvin			P			# thermodynamic temperature
+kilogram		P			# mass
+meter			P			# length
+mole			P			# amount of substance
+second			P			# time
+radian			P			# plane angle
+
+#
+# CONSTANTS
+#
+percent			S 0.01
+PI			S 3.14159265358979323846
+bakersdozen		S 13
+pair			P 2
+ten			P 10
+dozen			S 12
+score			S 20
+hundred			P 100
+thousand		P 1.0e3
+million			P 1.0e6
+
+%			S percent
+pi			S PI
+
+#
+# NB: All subsequent definitions must be given in terms of
+# earlier definitions.  Forward referencing is not permitted.
+#
+
+#
+# The following are non-base units of the fundamental quantities
+#
+
+bit			P count			# unit of information
+
+#
+# UNITS OF ELECTRIC CURRENT
+#
+A			S ampere
+amp			P ampere
+abampere		P 10 ampere		# exact
+gilbert			P 7.957747e-1 ampere
+statampere		P 3.335640e-10 ampere
+biot			P 10 ampere
+
+#
+# UNITS OF LUMINOUS INTENSITY
+#
+cd			S candela
+candle			P candela
+
+#
+# UNITS OF THERMODYNAMIC TEMPERATURE
+#
+degree_Kelvin		P kelvin
+degree_Celsius		S kelvin @ 273.15
+degree_Rankine		P kelvin/1.8
+degree_Fahrenheit	P degree_Rankine @ 459.67
+
+#C			S degree_Celsius	# `C' means `coulomb'
+Celsius			S degree_Celsius
+celsius			S degree_Celsius
+degree_centigrade	S degree_Celsius	# approx. was just `centigrade'
+degC			S degree_Celsius
+degreeC			S degree_Celsius
+degree_C		S degree_Celsius
+degree_c		S degree_Celsius
+deg_C			S degree_Celsius
+deg_c			S degree_Celsius
+degK			S kelvin
+degreeK			S kelvin
+degree_K		S kelvin
+degree_k		S kelvin
+deg_K			S kelvin
+deg_k			S kelvin
+K			S kelvin
+Kelvin			P kelvin
+
+degF			S degree_Fahrenheit
+degreeF			S degree_Fahrenheit
+degree_F		S degree_Fahrenheit
+degree_f		S degree_Fahrenheit
+deg_F			S degree_Fahrenheit
+deg_f			S degree_Fahrenheit
+F			S degree_Fahrenheit
+Fahrenheit		P degree_Fahrenheit
+fahrenheit		P degree_Fahrenheit
+
+degR			S degree_Rankine
+degreeR			S degree_Rankine
+degree_R		S degree_Rankine
+degree_r		S degree_Rankine
+deg_R			S degree_Rankine
+deg_r			S degree_Rankine
+#R			S degree_Rankine	# `R' means `roentgen'
+Rankine			P degree_Rankine
+rankine			P degree_Rankine
+
+#
+# UNITS OF MASS
+#
+assay_ton		P 2.916667e-2 kilogram	# was 2.916667e2 (typo!)
+avoirdupois_ounce	P 2.834952e-2 kilogram
+avoirdupois_pound	P 4.5359237e-1 kilogram	# exact
+carat			P 2e-4 kilogram
+grain			P 6.479891e-5 kilogram	# exact
+gram			P 1e-3 kilogram		# exact
+g                       S gram
+kg			S kilogram
+long_hundredweight	P 5.080235e1 kilogram
+metric_ton		P 1e3 kilogram		# exact
+pennyweight		P 1.555174e-3 kilogram
+short_hundredweight	P 4.535924e1 kilogram
+slug			P 14.59390 kilogram
+troy_ounce		P 3.110348e-2 kilogram
+troy_pound		P 3.732417e-1 kilogram
+atomic_mass_unit	P 1.66054e-27 kilogram	# was 1.66044e-27
+
+tonne			P metric_ton
+apothecary_ounce	P troy_ounce
+apothecary_pound	P troy_pound
+pound			P avoirdupois_pound
+metricton		P metric_ton
+gr			S grain
+scruple			P 20 grain
+apdram			P 60 grain
+apounce			P 480 grain
+appound			P 5760 grain
+atomicmassunit		P atomic_mass_unit
+amu			P atomic_mass_unit
+
+t			S tonne
+lb			P pound
+bag			P 94 pound
+short_ton		P 2000 pound
+long_ton		P 2240 pound
+
+ton			P short_ton
+shortton		P short_ton
+longton			P long_ton
+
+#
+# UNITS OF LENGTH
+#
+angstrom		P decinanometer
+astronomical_unit	P 1.495979e11 meter
+fermi			P 1e-15 meter		# exact
+m			S meter
+metre			P meter
+light_year		P 9.46073e15 meter	# was ASTM's 9.46055e15 meter
+micron			P 1e-6 meter		# exact
+mil			P 2.54e-5 meter		# exact
+nautical_mile		P 1.852000e3 meter	# exact
+parsec			P 3.085678e16 meter
+printers_point		P 3.514598e-4 meter
+
+# God help us!  There's an international foot and a US survey foot and
+# they're not the same!
+
+# US Survey foot stuff:
+US_survey_foot		S (1200/3937) meter	# exact
+US_survey_feet		S US_survey_foot	# alias
+US_survey_yard		P 3 US_survey_feet	# exact
+US_survey_mile		P 5280 US_survey_feet	# exact
+US_statute_mile		P US_survey_mile	# alias
+rod			P 16.5 US_survey_feet	# exact
+pole			P rod			# alias
+perch			S rod			# alias
+perches			S perch			# alias
+furlong			P 660 US_survey_feet	# exact
+fathom			P 6 US_survey_feet	# exact
+
+# International foot stuff:
+international_inch	S 2.54 cm		# exact
+international_inches	S international_inch	# alias
+international_foot	S 12 international_inches	# exact
+international_feet	S international_foot	# alias
+international_yard	P 3 international_feet	# exact
+international_mile	P 5280 international_feet	# exact
+
+# Alias unspecified units to the international units:
+inch			S international_inch	# alias
+foot			S international_foot	# alias
+yard			P international_yard	# alias
+mile			P international_mile	# alias
+
+# The following should hold regardless:
+inches			S inch			# alias
+in			S inches		# alias
+feet			S foot			# alias
+ft			S feet			# alias
+yd			S yard			# alias
+mi			S mile			# alias
+
+chain			P 2.011684e1 meter
+
+printers_pica		P 12 printers_point	# exact
+astronomicalunit	P astronomical_unit
+au			S astronomical_unit
+nmile			P nautical_mile
+nmi			S nautical_mile
+
+pica			P printers_pica
+big_point		P inch/72		# exact
+barleycorn		P inch/3
+
+arpentlin		P 191.835 foot
+
+#
+# UNITS OF AMOUNT OF SUBSTANCE
+#
+mol			S mole
+
+#
+# UNITS OF TIME
+#
+day			P 8.64e4 second		# exact
+hour			P 3.6e3 second		# exact
+minute			P 60 second		# exact
+s			S second
+sec			P second
+shake			P 1e-8 second		# exact
+sidereal_day		P 8.616409e4 second
+sidereal_hour		P 3.590170e3 second
+sidereal_minute		P 5.983617e1 second
+sidereal_second		P 0.9972696 second
+sidereal_year		P 3.155815e7 second
+# Interval between 2 successive passages of sun through vernal equinox
+# (365.242198781 days -- see 
+# http://www.ast.cam.ac.uk/pubinfo/leaflets/,
+# http://aa.usno.navy.mil/AA/
+# and http://adswww.colorado.edu/adswww/astro_coord.html):
+tropical_year		P 3.15569259747e7 second
+lunar_month		P 29.530589 day
+
+common_year		P 365 day		# exact: 3.153600e7 seconds
+leap_year		P 366 day		# exact
+Julian_year		P 365.25 day		# exact
+Gregorian_year		P 365.2425 day		# exact
+sidereal_month		P 27.321661 day
+tropical_month		P 27.321582 day
+d			S day
+min			P minute
+hr			P hour
+h			S hour
+fortnight		P 14 day		# exact
+week			P 7 day			# exact
+jiffy			S 0.01 second		# believe it or not!
+jiffies			S jiffy			# assumed plural spelling
+
+year			P tropical_year
+
+yr			P year
+a			S year			# "anno"
+eon			P 1e9 year		# fuzzy
+month			P year/12		# on average
+
+#
+# UNITS OF PLANE ANGLE
+#
+#rad			P radian		# `rad' means `1e-2 gray'
+circle			P 2 pi radian
+angular_degree		P (pi/180) radian
+
+turn			P circle
+degree			P angular_degree
+degree_north		S angular_degree
+degree_east		S angular_degree
+degree_true		S angular_degree
+arcdeg			P angular_degree
+angular_minute		P angular_degree/60
+angular_second		P angular_minute/60
+grade			P 0.9 angular_degree	# exact
+
+degrees_north		S degree_north
+degreeN			S degree_north
+degree_N		S degree_north
+degreesN		S degree_north
+degrees_N		S degree_north
+
+degrees_east		S degree_east
+degreeE			S degree_east
+degree_E		S degree_east
+degreesE		S degree_east
+degrees_E		S degree_east
+
+degree_west             S -1 degree_east
+degrees_west            S degree_west
+degreeW                 S degree_west
+degree_W                S degree_west
+degreesW                S degree_west
+degrees_W               S degree_west
+
+degrees_true		S degree_true
+degreeT			S degree_true
+degree_T		S degree_true
+degreesT		S degree_true
+degrees_T		S degree_true
+
+arcminute		P angular_minute
+arcsecond		P angular_second
+
+arcmin			P arcminute
+arcsec			P arcsecond
+
+#
+# The following are derived units with special names.  They are useful for
+# defining other derived units.
+#
+steradian		P radian2
+hertz			S 1/second
+newton			P kilogram.meter/second2
+coulomb			P ampere.second
+lumen			P candela steradian
+becquerel		P 1/second		# SI unit of activity of a 
+#						# radionuclide
+standard_free_fall	S 9.806650 meter/second2	# exact
+
+pascal			P newton/meter2
+joule			P newton.meter
+Hz			S hertz
+sr			S steradian
+force			S standard_free_fall
+gravity			S standard_free_fall
+free_fall		S standard_free_fall
+lux			S lumen/meter2
+sphere			P 4 pi steradian
+
+luxes			S lux
+watt			P joule/second
+gray			P joule/kilogram	# absorbed dose. derived unit
+sievert			P joule/kilogram	# dose equivalent. derived unit
+conventional_mercury	S gravity 13595.10 kg/m3
+mercury_0C		S gravity 13595.1 kg/m3	# was 13595.065
+mercury_60F		S gravity 13556.8 kg/m3	# was 13556.806
+conventional_water	S gravity 1000 kg/m3	# exact
+water_4C		S gravity 999.972 kg/m3	# was 999.97226
+water_60F		S gravity 999.001 kg/m3	# was 999.00072
+
+volt			P watt/ampere
+mercury_32F		S mercury_0C
+water_39F		S water_4C		# actually 39.2 F
+mercury			S conventional_mercury	# was mercury_32F
+water			S conventional_water	# was water_4C
+
+farad			P coulomb/volt
+ohm			P volt/ampere
+siemens			S ampere/volt
+weber			P volt.second
+Hg			S mercury
+hg			S mercury
+H2O			S water
+h2o			S water
+
+tesla			P weber/meter2
+henry			P weber/ampere
+
+#
+# The following are compound units: units whose definitions consist 
+# of two or more base units.  They may now be defined in terms of the 
+# preceding units.
+#
+
+#
+# ACCELERATION
+#
+gal			P 1e-2 meter/second2	# exact
+
+#
+# Area
+#
+are			P 1e2 m2		# exact
+barn			P 1e-28 m2		# exact
+circular_mil		P 5.067075e-10 m2
+darcy			P 9.869233e-13 m2	# permeability of porous solids
+hectare			P 1e4 m2		# exact
+acre			P 160 rod2		# exact
+
+b                       S barn
+
+#
+# ELECTRICITY AND MAGNETISM
+#
+abfarad			P 1e9 farad		# exact
+abhenry			P 1e-9 henry		# exact
+abmho			P 1e9 siemens		# exact
+abohm			P 1e-9 ohm		# exact
+abvolt			P 1e-8 volt		# exact
+C			S coulomb
+e			S 1.60217733-19 coulomb	# was 1.6021917e-19
+chemical_faraday	P 9.64957e4 coulomb
+physical_faraday	P 9.65219e4 coulomb
+C12_faraday		P 9.648531e4 coulomb
+gamma			P 1e-9 tesla		# exact
+gauss			S 1e-4 tesla		# exact
+H			S henry
+maxwell			P 1e-8 weber		# exact
+oersted			P 7.957747e1 ampere/meter
+S			S siemens
+statcoulomb		P 3.335640e-10 coulomb
+statfarad		P 1.112650e-12 farad
+stathenry		P 8.987554e11 henry
+statmho			P 1.112650e-12 siemens
+statohm			P 8.987554e11 ohm
+statvolt		P 2.997925e2 volt
+T			S tesla
+unit_pole		P 1.256637e-7 weber
+V			S volt
+Wb			S weber
+mho			P siemens
+Oe			S oersted
+faraday			P C12_faraday		# charge of 1 mole of 
+#						# electrons
+
+#
+# ENERGY (INCLUDES WORK)
+#
+electronvolt		P 1.602177e-19 joule
+erg			P 1e-7 joule		# exact
+IT_Btu			P 1.05505585262e3 joule	# exact, was 1.055056e3
+EC_therm		P 1.05506e8 joule	# exact
+thermochemical_calorie	P 4.184000 joule	# exact
+IT_calorie		P 4.1868 joule		# exact
+J			S joule
+ton_TNT			S 4.184e9 joule
+US_therm		P 1.054804e8 joule	# exact
+watthour		P watt hour
+
+therm			P US_therm
+Wh			S watthour
+Btu			P IT_Btu
+calorie			P IT_calorie
+electron_volt		P electronvolt
+
+thm			S therm
+cal			S calorie
+eV			S electronvolt
+bev			S gigaelectron_volt
+
+#
+# FORCE
+#
+dyne			P 1e-5 newton		# exact
+pond			P 9.806650e-3 newton	# exact, was 1.806650e-3 (typo)
+force_kilogram		S 9.806650 newton	# exact
+force_ounce		S 2.780139e-1 newton
+force_pound		S 4.4482216152605 newton# exact
+poundal			P 1.382550e-1 newton
+N			S newton
+gf			S gram force
+
+force_gram		P 1e-3 force_kilogram
+force_ton		P 2000 force_pound	# exact
+lbf			S force_pound
+ounce_force		S force_ounce
+kilogram_force		S force_kilogram
+pound_force		S force_pound
+ozf			S force_ounce
+kgf			S force_kilogram
+
+kip			P 1000 lbf
+ton_force		S force_ton
+gram_force		S force_gram
+
+#
+# HEAT
+#
+clo			P 1.55e-1 kelvin.meter2/watt
+
+#
+# LIGHT
+#
+lm			S lumen
+lx			S lux
+footcandle		P 1.076391e-1 lux
+footlambert		P 3.426259 candela/meter2
+lambert			P (1e4/PI) candela/meter2	# exact
+stilb			P 1e4 candela/meter2	# exact
+phot			P 1e4 lumen/meter2	# exact
+nit			P 1 candela/meter2	# exact
+langley			P 4.184000e4 joule/meter2	# exact
+blondel			P candela/(pi meter2)
+
+apostilb		P blondel
+nt			S nit
+ph			S phot
+sb			S stilb
+
+#
+# MASS PER UNIT LENGTH
+#
+denier			P 1.111111e-7 kilogram/meter
+tex			P 1e-6 kilogram/meter	# exact
+
+#
+# MASS PER UNIT TIME (INCLUDES FLOW)
+#
+perm_0C			S 5.72135e-11 kg/(pascal second meter2)
+perm_23C		S 5.74525e-11 kg/(pascal second meter2)
+
+#
+# POWER
+#
+voltampere		P volt ampere
+VA			S volt ampere
+boiler_horsepower	P 9.80950e3 watt
+shaft_horsepower	P 7.456999e2 watt
+metric_horsepower	P 7.35499e2 watt
+electric_horsepower	P 7.460000e2 watt	# exact
+W			S watt
+water_horsepower	P 7.46043e2 watt
+UK_horsepower		P 7.4570e2 watt
+refrigeration_ton	P 12000 Btu/hour
+
+horsepower		P shaft_horsepower
+ton_of_refrigeration	P refrigeration_ton
+
+hp			S horsepower
+
+#
+# PRESSURE OR STRESS
+#
+bar			P 1e5 pascal		# exact
+standard_atmosphere	P 1.01325e5 pascal	# exact
+technical_atmosphere	P 1 kg gravity/cm2	# exact
+inch_H2O_39F		S inch water_39F
+inch_H2O_60F		S inch water_60F
+inch_Hg_32F		S inch mercury_32F
+inch_Hg_60F		S inch mercury_60F
+millimeter_Hg_0C	S mm mercury_0C
+footH2O			S foot water
+cmHg			S cm Hg
+cmH2O			S cm water
+Pa			S pascal
+inch_Hg			S inch Hg
+inch_hg			S inch Hg
+inHg			S inch Hg
+in_Hg			S inch Hg
+in_hg			S inch Hg
+millimeter_Hg		S mm Hg
+mmHg			S mm Hg
+mm_Hg			S mm Hg
+mm_hg			S mm Hg
+torr			P mm Hg
+foot_H2O		S foot water
+ftH2O			S foot water
+psi			S 1 pound gravity/in2
+ksi			S kip/in2
+barie			P 0.1 newton/meter2
+
+at			S technical_atmosphere
+atmosphere		P standard_atmosphere
+atm			P standard_atmosphere
+barye			P barie
+
+#
+# RADIATION UNITS
+#
+Bq			S becquerel
+curie			P 3.7e10 becquerel	# exact
+rem			P 1e-2 sievert		# dose equivalent. exact
+rad			P 1e-2 gray		# absorbed dose. exact
+roentgen		P 2.58e-4 coulomb/kg	# exact
+Sv			S sievert
+Gy			S gray
+
+Ci			S curie
+R			S roentgen
+rd			S rad
+
+#
+# VELOCITY (INCLUDES SPEED)
+#
+c			S 2.997925e+8 meter/sec
+knot			P nautical_mile/hour
+
+knot_international	S knot
+international_knot	S knot
+kt			P knot
+
+#
+# VISCOSITY
+#
+poise			S 1e-1 pascal second	# absolute viscosity. 
+#						# exact
+stokes			S 1e-4 meter2/second	# exact
+rhe			S 10/(pascal second)	# exact
+
+St			S stokes
+
+#
+# VOLUME (INCLUDES CAPACITY)
+#
+acre_foot		S 1.233489e3 m3	# but `acre foot' is 1233.4867714897 meters^3. Odd.
+board_foot		S 2.359737e-3 m3
+bushel			P 3.523907e-2 m3
+UK_liquid_gallon	P 4.546090e-3 m3	# exact. was 4.546092e-3
+Canadian_liquid_gallon	P 4.546090e-3 m3	# exact
+US_dry_gallon		P 4.404884e-3 m3
+US_liquid_gallon	P 3.785412e-3 m3
+cc			S cm3
+liter			P 1e-3 m3		# exact. However, from 1901 to 
+#						# 1964, 1 liter = 1.000028 dm3
+stere			P 1 m3			# exact
+register_ton		P 2.831685 m3		# was 3.831685 (typo!)
+
+US_dry_quart		P US_dry_gallon/4
+US_dry_pint		P US_dry_gallon/8
+
+US_liquid_quart		P US_liquid_gallon/4
+US_liquid_pint		P US_liquid_gallon/8
+US_liquid_cup		P US_liquid_gallon/16
+US_liquid_gill		P US_liquid_gallon/32
+US_fluid_ounce		P US_liquid_gallon/128
+US_liquid_ounce		P US_fluid_ounce
+
+UK_liquid_quart		P UK_liquid_gallon/4
+UK_liquid_pint		P UK_liquid_gallon/8
+UK_liquid_cup		P UK_liquid_gallon/16
+UK_liquid_gill		P UK_liquid_gallon/32
+UK_fluid_ounce		P UK_liquid_gallon/160
+UK_liquid_ounce		P UK_fluid_ounce
+
+liquid_gallon		P US_liquid_gallon
+fluid_ounce		P US_fluid_ounce
+#liquid_gallon		P UK_liquid_gallon
+#fluid_ounce		P UK_fluid_ounce
+
+dry_quart		P US_dry_quart
+dry_pint		P US_dry_pint
+
+liquid_quart		P liquid_gallon/4
+liquid_pint		P liquid_gallon/8
+
+gallon			P liquid_gallon
+barrel			P 42 US_liquid_gallon	# petroleum industry definition
+quart			P liquid_quart
+pint			P liquid_pint
+cup			P liquid_gallon/16
+gill			P liquid_gallon/32
+tablespoon		P US_fluid_ounce/2
+teaspoon		P tablespoon/3
+peck			P bushel/4
+
+oz			P fluid_ounce
+floz			S fluid_ounce
+acre_feet		S acre_foot
+board_feet		S board_foot
+Tbl			P tablespoon
+Tbsp			S tablespoon
+tbsp			S tablespoon
+Tblsp			S tablespoon
+tblsp			S tablespoon
+litre			P liter
+L			S liter
+l			S liter
+tsp			S teaspoon
+pk			S peck
+bu			S bushel
+
+fldr			S floz/8
+dram			P floz/16
+
+bbl			S barrel
+firkin			P barrel/4		# exact but barrel is vague
+pt			S pint
+dr			S dram
+
+
+#
+# COMPUTERS AND COMMUNICATION
+#
+baud			S 1/second		# exact
+bps			S bit/second
+cps			S hertz
+
+Bd			S baud
+
+#
+# MISC
+#
+kayser			P 1e2/meter		# exact
+rps			S hertz
+rpm			S hertz/60
+geopotential		S gravity
+work_year		P 2056 hours
+work_month		P work_year/12
+
+gp			S geopotential
+dynamic			S geopotential
diff --git a/inst/udunits/udunits2-accepted.xml b/inst/udunits/udunits2-accepted.xml
new file mode 100644
index 0000000..acf8589
--- /dev/null
+++ b/inst/udunits/udunits2-accepted.xml
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!--
+Copyright 2008, 2009 University Corporation for Atmospheric Research
+
+This file is part of the UDUNITS-2 package.  See the file COPYRIGHT
+in the top-level source-directory of the package for copying and
+redistribution conditions.
+
+Units accepted for use with the SI
+-->
+<unit-system>
+    <!-- Hour, degree, liter, and the like -->
+        <unit>
+            <def>60 s</def>
+            <name><singular>minute</singular></name>
+            <symbol>min</symbol>
+        </unit>
+        <unit>
+            <def>60 min</def>
+            <name><singular>hour</singular></name>
+            <symbol>h</symbol>
+            <aliases> <symbol>hr</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>24 h</def>
+            <name><singular>day</singular></name>
+            <symbol>d</symbol>
+        </unit>
+        <unit>
+            <!-- This "unit" is useful in the definition of subsequent
+                 units.  -->
+            <def>3.141592653589793238462643383279</def>
+            <aliases>
+                <name><singular>pi</singular><noplural/></name>
+                <symbol>&#x3c0;</symbol>        <!-- GREEK SMALL LETTER PI -->
+            </aliases>
+        </unit>
+        <unit>
+            <def>(pi/180) rad</def>
+            <name><singular>arc_degree</singular></name>
+            <symbol>&#xB0;</symbol>             <!-- DEGREE SIGN -->
+            <aliases>
+                <name><singular>angular_degree</singular></name>
+                <name><singular>degree</singular></name>
+                <name><singular>arcdeg</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>&#xB0;/60</def>                <!-- DEGREE SIGN -->
+            <name><singular>arc_minute</singular></name>
+            <symbol>'</symbol>
+            <symbol>&#x2032;</symbol>           <!-- PRIME -->
+            <aliases>
+                <name><singular>angular_minute</singular></name>
+                <name><singular>arcminute</singular></name>
+                <name><singular>arcmin</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>'/60</def>
+            <name><singular>arc_second</singular></name>
+            <symbol>"</symbol>
+            <symbol>&#x2033;</symbol>           <!-- DOUBLE PRIME -->
+            <aliases>
+                <name><singular>angular_second</singular></name>
+                <name><singular>arcsecond</singular></name>
+                <name><singular>arcsec</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <!-- The following is exact.  From 1901 to 1964, however, 1
+                 liter was 1.000028 dm^3 -->
+            <def>dm^3</def>		        <!-- exact -->
+            <name><singular>liter</singular></name>
+            <symbol>L</symbol>                  <!-- NIST recommendation -->
+            <aliases>
+                <name><singular>litre</singular></name>
+                <symbol>l</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1000 kg</def>
+            <name><singular>metric_ton</singular></name>
+            <symbol>t</symbol>
+            <aliases> <name><singular>tonne</singular></name> </aliases>
+        </unit>
+
+    <!-- Units whose values are obtained experimentally -->
+        <unit>
+            <def>1.60217733e-19 J</def>
+            <name><singular>electronvolt</singular></name>
+            <symbol>eV</symbol>
+            <aliases>
+                <name><singular>electron_volt</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.6605402e-27 kg</def>
+            <name><singular>unified_atomic_mass_unit</singular></name>
+            <symbol>u</symbol>
+            <aliases>
+                <name> <singular>atomic_mass_unit</singular> </name>
+                <name> <singular>atomicmassunit</singular> </name>
+                <name> <singular>amu</singular><noplural/></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.495979e11 m</def>
+            <aliases>
+                <name><singular>astronomical_unit</singular></name>
+                <symbol>ua</symbol>
+            </aliases>
+        </unit>
+
+    <!-- Units temporarily accepted for use with the SI.  NB: <name>
+         and <symbol> elements appear only within <aliases>. -->
+        <unit>
+            <def>1852 m</def>
+            <aliases>
+                <name><singular>nautical_mile</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>nautical_mile/hour</def>
+            <aliases>
+                <name><singular>international_knot</singular></name>
+                <name><singular>knot_international</singular></name>
+                <name><singular>knot</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-10 m</def>
+            <aliases>
+                <name><singular>angstrom</singular></name>
+                <name><singular>&#xE5;ngstr&#xF6;m</singular></name>
+                <symbol>&#xC5;</symbol>         <!-- LATIN CAPITAL LETTER A
+                                                     WITH RING ABOVE -->
+                <symbol>&#x212B;</symbol>       <!-- ANGSTROM SIGN -->
+            </aliases>
+        </unit>
+        <unit>
+            <def>dam^2</def>
+            <aliases>
+                <name><singular>are</singular></name>
+                <symbol>a</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>100 are</def>
+            <aliases> <name><singular>hectare</singular></name> </aliases>
+        </unit>
+        <unit>
+            <def>100 fm^2</def>			<!-- exact -->
+            <aliases>
+                <name><singular>barn</singular></name>
+                <symbol>b</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1000 hPa</def>
+            <aliases>
+                <name><singular>bar</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>cm/s^2</def>
+            <aliases>
+                <name><singular>gal</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.7e10 Bq</def>
+            <aliases>
+                <name><singular>curie</singular></name>
+                <symbol>Ci</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.58e-4 C/kg</def>
+            <aliases>
+                <name><singular>roentgen</singular></name>
+                <symbol>R</symbol>
+            </aliases>
+        </unit>
+        <!-- The following is commented-out because "rad" has already
+             been mapped to "radian"
+        <unit>
+            <def>cGy</def>
+            <aliases> <name><singular>rad</singular></name> </aliases>
+        </unit>
+        -->
+        <unit>
+            <def>cSv</def>
+            <aliases>
+                <name><singular>rem</singular></name>
+            </aliases>
+        </unit>
+</unit-system>
diff --git a/inst/udunits/udunits2-base.xml b/inst/udunits/udunits2-base.xml
new file mode 100644
index 0000000..f463013
--- /dev/null
+++ b/inst/udunits/udunits2-base.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!--
+Copyright 2008, 2009 University Corporation for Atmospheric Research
+
+This file is part of the UDUNITS-2 package.  See the file COPYRIGHT
+in the top-level source-directory of the package for copying and
+redistribution conditions.
+
+SI base units.
+-->
+<unit-system>
+    <unit>
+        <!--
+            The meter is the length of the path travelled by light in vacuum
+            during a time interval of 1/299 792 458 of a second.
+        -->
+        <base/>
+        <name><singular>meter</singular></name>
+        <symbol>m</symbol>
+        <aliases> <name><singular>metre</singular></name> </aliases>
+    </unit>
+    <unit>
+        <!-- The kilogram is the unit of mass; it is equal to the mass of the
+             international prototype of the kilogram. -->
+        <base/>
+        <name><singular>kilogram</singular></name>
+        <symbol>kg</symbol>
+    </unit>
+    <unit>
+        <!--
+            The second is the duration of 9 192 631 770 periods of the
+            radiation corresponding to the transition between the two hyperfine
+            levels of the ground state of the cesium 133 atom.
+        -->
+        <base/>
+        <name><singular>second</singular></name>
+        <symbol>s</symbol>
+    </unit>
+    <unit>
+        <!--
+            The ampere is that constant current which, if maintained in two
+            straight parallel conductors of infinite length, of negligible
+            circular cross-section, and placed 1 meter apart in vacuum, would
+            produce between these conductors a force equal to 2e-7 newton
+            per meter of length.
+        -->
+        <base/>
+        <name><singular>ampere</singular></name>
+        <symbol>A</symbol>
+    </unit>
+    <unit>
+        <!--
+            The kelvin, unit of thermodynamic temperature, is the fraction
+            1/273.16 of the thermodynamic temperature of the triple point of
+            water.
+        -->
+        <base/>
+        <name><singular>kelvin</singular></name>
+        <symbol>K</symbol>
+    </unit>
+    <unit>
+        <!--
+            1. The mole is the amount of substance of a system which contains
+            as many elementary entities as there are atoms in 0.012 kilogram of
+            carbon 12.
+
+            2. When the mole is used, the elementary entities must be specified
+            and may be atoms, molecules, ions, electrons, other particles, or
+            specified groups of such particles. 
+        -->
+        <base/>
+        <name><singular>mole</singular></name>
+        <symbol>mol</symbol>
+    </unit>
+    <unit>
+        <!--
+            The candela is the luminous intensity, in a given direction, of a
+            source that emits monochromatic radiation of frequency 540e12
+            hertz and that has a radiant intensity in that direction of 1/683
+            watt per steradian.
+        -->
+        <base/>
+        <name><singular>candela</singular></name>
+        <symbol>cd</symbol>
+    </unit>
+</unit-system>
diff --git a/inst/udunits/udunits2-common.xml b/inst/udunits/udunits2-common.xml
new file mode 100644
index 0000000..250868a
--- /dev/null
+++ b/inst/udunits/udunits2-common.xml
@@ -0,0 +1,1662 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!--
+Copyright 2008, 2009 University Corporation for Atmospheric Research
+
+This file is part of the UDUNITS-2 package.  See the file COPYRIGHT
+in the top-level source-directory of the package for copying and
+redistribution conditions.
+
+Units not accepted for use with the SI.  NB: <name> and <symbol>
+elements appear only within <aliases>.
+-->
+<unit-system>
+    <!-- Synonyms for SI Units -->
+        <unit>
+            <def>s</def>
+            <aliases> <name> <singular>sec</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>A</def>
+            <aliases> <name> <singular>amp</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>K</def>
+            <aliases>
+                <symbol>&#xB0;K</symbol>        <!-- DEGREE SIGN -->
+                <name>
+                    <singular>degree_kelvin</singular>
+                    <plural>degrees_kelvin</plural>
+                </name>
+                <name>
+                    <singular>degree_K</singular>
+                    <plural>degrees_K</plural>
+                </name>
+                <name>
+                    <singular>degreeK</singular>
+                    <plural>degreesK</plural>
+                </name>
+                <name>
+                    <singular>deg_K</singular>
+                    <plural>degs_K</plural>
+                </name>
+                <name>
+                    <singular>degK</singular>
+                    <plural>degsK</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>cd</def>
+            <aliases> <name> <singular>candle</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>mole</def>
+            <aliases> <name> <singular>einstein</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>Hz</def>
+            <aliases>
+                <name> <singular>baud</singular> </name>
+                <symbol>Bd</symbol>
+                <symbol>bps</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>degree_Celsius</def>
+            <aliases>
+                <symbol>&#x2103;</symbol>       <!-- DEGREE CELSIUS -->
+                <name> <singular>celsius</singular> </name>
+                <name>
+                    <singular>degree_C</singular>
+                    <plural>degrees_C</plural>
+                </name>
+                <name>
+                    <singular>degreeC</singular>
+                    <plural>degreesC</plural>
+                </name>
+                <name>
+                    <singular>deg_C</singular>
+                    <plural>degs_C</plural>
+                </name>
+                <name>
+                    <singular>degC</singular>
+                    <plural>degsC</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>knot</def>
+            <aliases>
+                <symbol>kt</symbol>
+                <symbol>kts</symbol>
+            </aliases>
+        </unit>
+
+    <!-- Constants -->
+        <unit>
+            <def>6.02214179e23/mol</def>        <!-- +-30e15 -->
+            <aliases>
+                <name><singular>avogadro_constant</singular></name>
+                <noplural/>
+            </aliases>
+        </unit>
+        <unit>
+            <def>0.01</def>
+            <aliases>
+                <name><singular>percent</singular></name>
+                <noplural/>
+                <symbol>%</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-6</def>
+            <aliases>
+                <symbol>ppm</symbol>
+                <symbol>ppmv</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-9</def>
+            <aliases>
+                <symbol>ppb</symbol>
+                <symbol>ppbv</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-12</def>
+            <aliases>
+                <symbol>ppt</symbol>
+                <symbol>pptv</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-15</def>
+            <aliases>
+                <symbol>ppq</symbol>
+                <symbol>ppqv</symbol>
+            </aliases>
+        </unit>
+
+    <!-- Plane Angle -->
+        <unit>
+            <def>0.9 arc_degree</def>
+            <aliases> <name><singular>grade</singular></name> </aliases>
+        </unit>
+        <unit>
+            <def>2 pi rad</def>
+            <aliases>
+                <name><singular>circle</singular></name>
+                <name><singular>cycle</singular></name>
+                <name><singular>turn</singular></name>
+                <name><singular>revolution</singular></name>
+                <name><singular>rotation</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>arc_degree</def>
+            <aliases>
+                <name>
+                    <singular>degree_north</singular>
+                    <plural>degrees_north</plural>
+                </name>
+                <name>
+                    <singular>degree_N</singular>
+                    <plural>degrees_N</plural>
+                </name>
+                <name>
+                    <singular>degreeN</singular>
+                    <plural>degreesN</plural>
+                </name>
+                <name>
+                    <singular>degree_east</singular>
+                    <plural>degrees_east</plural>
+                </name>
+                <name>
+                    <singular>degree_E</singular>
+                    <plural>degrees_E</plural>
+                </name>
+                <name>
+                    <singular>degreeE</singular>
+                    <plural>degreesE</plural>
+                </name>
+                <name>
+                    <singular>degree_true</singular>
+                    <plural>degrees_true</plural>
+                </name>
+                <name>
+                    <singular>degree_T</singular>
+                    <plural>degrees_T</plural>
+                </name>
+                <name>
+                    <singular>degreeT</singular>
+                    <plural>degreesT</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>-1 degree_east</def>
+            <aliases>
+                <name>
+                    <singular>degree_west</singular>
+                    <plural>degrees_west</plural>
+                </name>
+                <name>
+                    <singular>degree_W</singular>
+                    <plural>degrees_W</plural>
+                </name>
+                <name>
+                    <singular>degreeW</singular>
+                    <plural>degreesW</plural>
+                </name>
+            </aliases>
+        </unit>
+
+    <!-- Mass -->
+        <unit>
+            <def>2.916667e-2 kg</def>
+            <aliases>
+                <name> <singular>assay_ton</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.834952e-2 kg</def>
+            <aliases>
+                <name> <singular>avoirdupois_ounce</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.5359237e-1 kg</def>
+            <aliases>
+                <name> <singular>avoirdupois_pound</singular> </name>
+                <name> <singular>pound</singular> </name>
+                <symbol>lb</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2e-4 kg</def>
+            <aliases>
+                <name> <singular>carat</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>6.479891e-5 kg</def>
+            <aliases>
+                <name> <singular>grain</singular> </name>
+                <symbol>gr</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>5.080235e1 kg</def>
+            <aliases>
+                <name> <singular>long_hundredweight</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.555174e-3 kg</def>
+            <aliases>
+                <name> <singular>pennyweight</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.535924e1 kg</def>
+            <aliases>
+                <name> <singular>short_hundredweight</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>14.59390 kg</def>
+            <aliases>
+                <name> <singular>slug</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.110348e-2 kg</def>
+            <aliases>
+                <name> <singular>troy_ounce</singular> </name>
+                <name> <singular>apothecary_ounce</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.732417e-1 kg</def>
+            <aliases>
+                <name> <singular>troy_pound</singular> </name>
+                <name> <singular>apothecary_pound</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>20 grain</def>
+            <aliases> <name> <singular>scruple</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>60 grain</def>
+            <aliases> <name> <singular>apdram</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>480 grain</def>
+            <aliases> <name> <singular>apounce</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>5760 grain</def>
+            <aliases> <name> <singular>appound</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>94 pound</def>
+            <aliases> <name> <singular>bag</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>2000 pound</def>
+            <aliases>
+                <name> <singular>short_ton</singular> </name>
+                <name> <singular>ton</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2240 pound</def>
+            <aliases>
+                <name> <singular>long_ton</singular> </name>
+            </aliases>
+        </unit>
+
+    <!-- Length -->
+        <unit>
+            <def>1e-15 m</def>
+            <aliases>
+                <name> <singular>fermi</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>9.46073e15 m</def>
+            <aliases>
+                <name> <singular>light_year</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-6 m</def>
+            <aliases>
+                <name> <singular>micron</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.54e-5 m</def>
+            <aliases>
+                <name> <singular>mil</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.085678e16 m</def>
+            <aliases>
+                <name> <singular>parsec</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.514598e-4 m</def>
+            <aliases>
+                <name> <singular>printers_point</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.011684e1 m</def>
+            <aliases>
+                <name> <singular>chain</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>12 printers_point</def>
+            <aliases>
+                <name> <singular>printers_pica</singular> </name>
+                <name> <singular>pica</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>nautical_mile</def>
+            <aliases>
+                <name> <singular>nmile</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>(1200/3937) m</def>
+            <aliases>
+                <name>
+                    <singular>US_survey_foot</singular>
+                    <plural>US_survey_feet</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3 US_survey_feet</def>
+            <aliases>
+                <name> <singular>US_survey_yard</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>5280 US_survey_feet</def>
+            <aliases>
+                <name> <singular>US_survey_mile</singular> </name>
+                <name> <singular>US_statute_mile</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>16.5 US_survey_feet</def>
+            <aliases>
+                <name> <singular>rod</singular> </name>
+                <name> <singular>pole</singular> </name>
+                <name> <singular>perch</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>660 US_survey_feet</def>
+            <aliases> <name> <singular>furlong</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>6 US_survey_feet</def>
+            <aliases> <name> <singular>fathom</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>2.54 cm</def>
+            <aliases>
+                <name> <singular>international_inch</singular> </name>
+                <name> <singular>inch</singular> </name>
+                <symbol>in</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>12 international_inches</def>
+            <aliases>
+                <name>
+                    <singular>international_foot</singular>
+                    <plural>international_feet</plural>
+                </name>
+                <name>
+                    <singular>foot</singular>
+                    <plural>feet</plural>
+                </name>
+                <symbol>ft</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3 international_feet</def>
+            <aliases>
+                <name> <singular>international_yard</singular> </name>
+                <name> <singular>yard</singular> </name>
+                <symbol>yd</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>5280 international_feet</def>
+            <aliases>
+                <name> <singular>international_mile</singular> </name>
+                <name> <singular>mile</singular> </name>
+                <symbol>mi</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>inch/72</def>
+            <aliases>
+                <name> <singular>big_point</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>inch/3</def>
+            <aliases>
+                <name> <singular>barleycorn</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>191.835 foot</def>
+            <aliases>
+                <name> <singular>arpentlin</singular> </name>
+            </aliases>
+        </unit>
+
+    <!-- Angular Velocity -->
+        <unit>
+            <def>rotation/second</def>		<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>rotation_per_second</singular>
+                    <plural>rotations_per_second</plural>
+                </name>
+                <symbol>rps</symbol>
+                <symbol>cps</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>rotation/minute</def>		<!-- exact -->
+            <aliases> <symbol>rpm</symbol> </aliases>
+        </unit>
+
+    <!-- Lineic Mass -->
+        <unit>
+            <def>1.111111e-7 kg/m</def>
+            <aliases>
+                <name> <singular>denier</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-6 kg/m</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>tex</singular> </name>
+            </aliases>
+        </unit>
+
+    <!-- Mass per unit time (includes flow) -->
+        <unit>
+            <def>5.72135e-11 kg/(Pa.s.m^2)</def>
+            <aliases>
+                <name>
+                    <singular>perm_0C</singular>
+                    <plural>perms_0C</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>5.74525e-11 kg/(Pa.s.m^2)</def>
+            <aliases>
+                <name>
+                    <singular>perm_23C</singular>
+                    <plural>perms_23C</plural>
+                </name>
+            </aliases>
+        </unit>
+
+    <!-- Area -->
+        <unit>
+            <def>5.067075e-10 m^2</def>
+            <aliases>
+                <name> <singular>circular_mil</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>9.869233e-13 m^2</def> <!-- porous solid permeability -->
+            <aliases> <name> <singular>darcy</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>160 rod^2</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>acre</singular> </name>
+            </aliases>
+        </unit>
+
+    <!-- Volume -->
+        <unit>
+            <def>1.233489e3 m^3</def>
+            <!-- An "acre.foot", however, is 1233.4867714897 m^3.  Odd. -->
+            <aliases>
+                <name>
+                    <singular>acre_foot</singular>
+                    <plural>acre_feet</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.359737e-3 m^3</def>
+            <aliases>
+                <name>
+                    <singular>board_foot</singular>
+                    <plural>board_feet</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.523907e-2 m^3</def>
+            <aliases>
+                <name> <singular>bushel</singular> </name>
+                <symbol>bu</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>bushel/4</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>peck</singular> </name>
+                <symbol>pk</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.546090e-3 m^3</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>Canadian_liquid_gallon</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.404884e-3 m^3</def>
+            <aliases>
+                <name> <singular>US_dry_gallon</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>cm^3</def>				<!-- exact -->
+            <aliases> <symbol>cc</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>1 m^3</def>				<!-- exact -->
+            <aliases>
+                <name> <singular>stere</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.831685 m^3</def>
+            <aliases>
+                <name> <singular>register_ton</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_dry_gallon/4</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>US_dry_quart</singular> </name>
+                <name> <singular>dry_quart</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_dry_gallon/8</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>US_dry_pint</singular> </name>
+                <name> <singular>dry_pint</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.785412e-3 m^3</def>
+            <aliases>
+                <name> <singular>US_liquid_gallon</singular> </name>
+                <name> <singular>liquid_gallon</singular> </name>
+                <name> <singular>gallon</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <!-- The following is the definition of the petroleum industry
+            -->
+            <def>42 US_liquid_gallon</def>
+            <aliases>
+                <name> <singular>barrel</singular> </name>
+                <symbol>bbl</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <!-- The following is exact regardless of the definition of
+            "barrel" -->
+            <def>barrel/4</def>
+            <aliases>
+                <name> <singular>firkin</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_liquid_gallon/4</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>US_liquid_quart</singular> </name>
+                <name> <singular>liquid_quart</singular> </name>
+                <name> <singular>quart</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_liquid_gallon/8</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>US_liquid_pint</singular> </name>
+                <name> <singular>liquid_pint</singular> </name>
+                <name> <singular>pint</singular> </name>
+                <symbol>pt</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_liquid_gallon/16</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>US_liquid_cup</singular> </name>
+                <name> <singular>liquid_cup</singular> </name>
+                <name> <singular>cup</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_liquid_gallon/32</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>US_liquid_gill</singular> </name>
+                <name> <singular>liquid_gill</singular> </name>
+                <name> <singular>gill</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_liquid_gallon/128</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>US_fluid_ounce</singular> </name>
+                <name> <singular>US_liquid_ounce</singular> </name>
+                <name> <singular>fluid_ounce</singular> </name>
+                <name> <singular>liquid_ounce</singular> </name>
+                <symbol>oz</symbol>
+                <symbol>floz</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_fluid_ounce/2</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>tablespoon</singular> </name>
+                <symbol>Tbl</symbol>
+                <symbol>Tbsp</symbol>
+                <symbol>tbsp</symbol>
+                <symbol>Tblsp</symbol>
+                <symbol>tblsp</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>US_fluid_ounce/8</def>		<!-- exact -->
+            <aliases> <symbol>fldr</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>US_fluid_ounce/16</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>dram</singular> </name>
+                <symbol>dr</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>tablespoon/3</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>teaspoon</singular> </name>
+                <symbol>tsp</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.546090e-3 m^3</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>UK_liquid_gallon</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>UK_liquid_gallon/4</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>UK_liquid_quart</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>UK_liquid_gallon/8</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>UK_liquid_pint</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>UK_liquid_gallon/16</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>UK_liquid_cup</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>UK_liquid_gallon/32</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>UK_liquid_gill</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>UK_liquid_gallon/160</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>UK_fluid_ounce</singular> </name>
+                <name> <singular>UK_liquid_ounce</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>lg(re (1e-6 m)^3)</def>
+            <aliases> <symbol>BZ</symbol> </aliases>
+        </unit>
+
+    <!-- Time -->
+        <unit>
+            <def>1e-8 s</def>
+            <aliases> <name> <singular>shake</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>8.616409e4 s</def>
+            <aliases>
+                <name> <singular>sidereal_day</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.590170e3 s</def>
+            <aliases>
+                <name> <singular>sidereal_hour</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>5.983617e1 s</def>
+            <aliases>
+                <name> <singular>sidereal_minute</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>0.9972696 s</def>
+            <aliases>
+                <name> <singular>sidereal_second</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.155815e7 s</def>
+            <aliases>
+                <name> <singular>sidereal_year</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <!--
+                Interval between 2 successive passages of sun
+                through vernal equinox (365.242198781 days.  See
+                <http://www.ast.cam.ac.uk/pubinfo/leaflets/>,
+                <http://aa.usno.navy.mil/AA/>, and
+                <http://adswww.colorado.edu/adswww/astro_coord.html>):
+            -->
+            <def>3.15569259747e7 s</def>
+            <aliases>
+                <name> <singular>tropical_year</singular> </name>
+                <name> <singular>year</singular> </name>
+                <!-- The following is commented-out because "a" already
+                     maps to "are"
+                <symbol>a</symbol>
+                -->
+                <symbol>yr</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>29.530589 day</def>
+            <aliases>
+                <name> <singular>lunar_month</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>365 day</def>
+            <aliases>
+                <name> <singular>common_year</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>366 day</def>
+            <aliases>
+                <name> <singular>leap_year</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>365.25 day</def>
+            <aliases>
+                <name> <singular>Julian_year</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>365.2425 day</def>
+            <aliases>
+                <name> <singular>Gregorian_year</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>27.321661 day</def>
+            <aliases>
+                <name> <singular>sidereal_month</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>27.321582 day</def>
+            <aliases>
+                <name> <singular>tropical_month</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>14 day</def>
+            <aliases>
+                <name> <singular>fortnight</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>7 day</def>
+            <aliases> <name> <singular>week</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>0.01 s</def>
+            <aliases> <name> <singular>jiffy</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>1e9 year</def>
+            <aliases> <name> <singular>eon</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>year/12</def>
+            <aliases> <name> <singular>month</singular> </name> </aliases>
+        </unit>
+
+    <!-- Volume per time -->
+        <unit>
+            <def>1e6 m^3/s</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>sverdrup</singular> </name>
+                <!-- The following is commented-out because "Sv" means
+                     "sievert" in the SI unit-system.
+                <symbol>Sv</symbol>
+                -->
+            </aliases>
+        </unit>
+
+    <!-- Acceleration -->
+        <unit>
+            <def>9.806650 m/s^2</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>standard_free_fall</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>standard_free_fall</def>		<!-- should be local -->
+            <aliases> <name> <singular>gravity</singular> </name> </aliases>
+        </unit>
+
+    <!-- Some "units" that make subsequent definitions easier -->
+        <unit>
+            <def>gravity 1000 kg/m^3</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>conventional_water</singular> </name>
+                <name> <singular>water</singular> </name>
+                <symbol>H2O</symbol>
+                <symbol>h2o</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>gravity 999.972 kg/m^3</def>
+            <aliases>
+                <name>
+                    <singular>water_4C</singular>
+                    <plural>waters_4C</plural>
+                </name>
+                <name>
+                    <singular>water_39F</singular>	<!-- act. 39.2 F -->
+                    <plural>waters_39F</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>gravity 999.001 kg/m^3</def>
+            <aliases>
+                <name>
+                    <singular>water_60F</singular>
+                    <plural>waters_60F</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>gravity 13595.10 kg/m^3</def>
+            <aliases>
+                <name>
+                    <singular>mercury_0C</singular>
+                    <plural>mercuries_0C</plural>
+                </name>
+                <name>
+                    <singular>mercury_32F</singular>
+                    <plural>mercuries_32F</plural>
+                </name>
+                <name>
+                    <singular>conventional_mercury</singular>
+                    <plural>conventional_mercuries</plural>
+                </name>
+                <symbol>Hg</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>gravity 13556.8 kg/m^3</def>
+            <aliases>
+                <name>
+                    <singular>mercury_60F</singular>
+                    <plural>mercuries_60F</plural>
+                </name>
+            </aliases>
+        </unit>
+
+    <!-- Force -->
+        <unit>
+            <def>standard_free_fall</def>
+            <aliases> <name> <singular>force</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>1e-5 N</def>			<!-- exact -->
+            <aliases> <name> <singular>dyne</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>9.806650e-3 N</def>		<!-- exact -->
+            <aliases> <name> <singular>pond</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>9.806650 N</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>force_kilogram</singular> </name>
+                <name>
+                    <singular>kilogram_force</singular>
+                    <plural>kilograms_force</plural>
+                </name>
+                <symbol>kgf</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.780139e-1 N</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>force_ounce</singular> </name>
+                <name>
+                    <singular>ounce_force</singular>
+                    <plural>ounces_force</plural>
+                </name>
+                <symbol>ozf</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.4482216152605 N</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>force_pound</singular> </name>
+                <name>
+                    <singular>pound_force</singular>
+                    <plural>pounds_force</plural>
+                </name>
+                <symbol>lbf</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.382550e-1 N</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>poundal</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>gram force</def>			<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>gram_force</singular>
+                    <plural>grams_force</plural>
+                </name>
+                <name>
+                    <singular>force_gram</singular>
+                </name>
+                <symbol>gf</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2000 force_pound</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>force_ton</singular> </name>
+                <name>
+                    <singular>ton_force</singular>
+                    <plural>tons_force</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1000 lbf</def>			<!-- exact -->
+            <aliases> <name><singular>kip</singular></name> </aliases>
+        </unit>
+
+    <!-- Pressure, Stress -->
+        <unit>
+            <def>1.01325e5 Pa</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>standard_atmosphere</singular> </name>
+                <name> <singular>atmosphere</singular> </name>
+                <symbol>atm</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1 kg gravity/cm2</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>technical_atmosphere</singular> </name>
+                <symbol>at</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>cm H2O</def>
+            <aliases>
+                <symbol>cm_H2O</symbol>
+                <symbol>cmH2O</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>inch water_39F</def>		<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>inch_H2O_39F</singular>
+                    <plural>inches_H2O_39F</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>inch water_60F</def>		<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>inch_H2O_60F</singular>
+                    <plural>inches_H2O_60F</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>foot water</def>
+            <aliases>
+                <name>
+                    <singular>foot_water</singular>
+                    <plural>feet_water</plural>
+                </name>
+                <name>
+                    <singular>foot_H2O</singular>
+                    <plural>feet_H2O</plural>
+                </name>
+                <name>
+                    <singular>footH2O</singular>
+                    <plural>feetH2O</plural>
+                </name>
+                <symbol>ftH2O</symbol>
+                <symbol>fth2o</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>cm Hg</def>
+            <aliases>
+                <symbol>cm_Hg</symbol>
+                <symbol>cmHg</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>mm mercury_0C</def>		<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>millimeter_Hg_0C</singular>
+                    <plural>millimeters_Hg_0C</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>inch mercury_32F</def>		<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>inch_Hg_32F</singular>
+                    <plural>inches_Hg_32F</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>inch mercury_60F</def>		<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>inch_Hg_60F</singular>
+                    <plural>inches_Hg_60F</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>mm Hg</def>
+            <aliases>
+                <name>
+                    <singular>millimeter_Hg</singular>
+                    <plural>millimeters_Hg</plural>
+                </name>
+                <name> <singular>torr</singular> </name>
+                <symbol>mm_Hg</symbol>
+                <symbol>mm_hg</symbol>
+                <symbol>mmHg</symbol>
+                <symbol>mmhg</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>inch Hg</def>
+            <aliases>
+                <name>
+                    <singular>inch_Hg</singular>
+                    <plural>inches_Hg</plural>
+                </name>
+                <symbol>in_Hg</symbol>
+                <symbol>inHg</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1 pound gravity/in^2</def>		<!-- exact -->
+            <aliases> <symbol>psi</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>kip/in^2</def>			<!-- exact -->
+            <aliases> <symbol>ksi</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>0.1 N/m^2</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>barie</singular> </name>
+                <name> <singular>barye</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>lg(re 20e-6 Pa)</def>      <!-- sound pressure level -->
+            <aliases> <symbol>B_SPL</symbol> </aliases>
+        </unit>
+
+    <!-- Viscosity -->
+        <unit>
+            <def>1e-1 Pa.s</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>poise</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-4 m^2/s</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>stokes</singular> </name>
+                <symbol>St</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>10/(Pa.s)</def>			<!-- exact -->
+            <aliases> <name> <singular>rhe</singular> </name> </aliases>
+        </unit>
+
+    <!-- Energy, Work, Quantity of Heat -->
+        <unit>
+            <def>1e-7 J</def>			<!-- exact -->
+            <aliases> <name> <singular>erg</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>1.05505585262e3 J</def>		<!-- exact -->
+            <aliases>
+                <name>
+                    <singular>IT_Btu</singular>
+                    <plural>IT_Btus</plural>
+                </name>
+                <name>
+                    <singular>Btu</singular>
+                    <plural>Btus</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.05506e8 J</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>EC_therm</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.184000 J</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>thermochemical_calorie</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.1868 J</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>IT_calorie</singular> </name>
+                <name> <singular>calorie</singular> </name>
+                <symbol>cal</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.184 MJ/kg</def>			<!-- by definition -->
+            <aliases>
+                <name> <singular>TNT</singular><noplural/></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.184e9 J</def>			<!-- by definition -->
+            <aliases>
+                <name>
+                    <singular>ton_TNT</singular>
+                    <plural>tons_TNT</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.054804e8 J</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>US_therm</singular> </name>
+                <name> <singular>therm</singular> </name>
+                <symbol>thm</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>watt.hour</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>watthour</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e9 eV</def>			<!-- exact -->
+            <aliases> <symbol>bev</symbol> </aliases>
+        </unit>
+
+    <!-- Power, Radiant Flux -->
+        <unit>
+            <def>V.A</def>				<!-- exact -->
+            <aliases>
+                <name> <singular>voltampere</singular> </name>
+                <symbol>VA</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>9.80950e3 W</def>
+            <aliases>
+                <name> <singular>boiler_horsepower</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>7.456999e2 W</def>
+            <aliases>
+                <name> <singular>shaft_horsepower</singular> </name>
+                <name> <singular>horsepower</singular> </name>
+                <symbol>hp</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>7.35499e2 W</def>
+            <aliases>
+                <name> <singular>metric_horsepower</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>7.460000e2 W</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>electric_horsepower</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>7.46043e2 W</def>
+            <aliases>
+                <name> <singular>water_horsepower</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>7.4570e2 W</def>
+            <aliases>
+                <name> <singular>UK_horsepower</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>12000 Btu/hr</def>
+            <aliases>
+                <name> <singular>refrigeration_ton</singular> </name>
+                <name>
+                    <singular>ton_of_refrigeration</singular>
+                    <plural>tons_of_refrigeration</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>lg(re 1 W)</def>
+            <aliases> <symbol>BW</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>lg(re 1 mW)</def>
+            <aliases> <symbol>Bm</symbol> </aliases>
+        </unit>
+
+    <!-- Heat -->
+        <unit>
+            <def>1.55e-1 K.m^2/W</def>
+            <aliases> <name> <singular>clo</singular> </name> </aliases>
+        </unit>
+
+    <!-- Electricity and Magnetism -->
+        <unit>
+            <def>10 A</def>
+            <aliases> <name><singular>abampere</singular></name> </aliases>
+        </unit>
+        <unit>
+            <def>7.957747e-1 A</def>
+            <aliases> <name><singular>gilbert</singular></name> </aliases>
+        </unit>
+        <unit>
+            <def>3.335640e-10 A</def>
+            <aliases>
+                <name><singular>statampere</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>10 A</def>
+            <aliases> <name><singular>biot</singular></name> </aliases>
+        </unit>
+        <unit>
+            <def>1e9 F</def>			<!-- exact -->
+            <aliases> <name> <singular>abfarad</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>1e-9 H</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>abhenry</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e9 S</def>			<!-- exact -->
+            <aliases> <name> <singular>abmho</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>1e-9 ohm</def>			<!-- exact -->
+            <aliases> <name> <singular>abohm</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>1e-8 V</def>			<!-- exact -->
+            <aliases> <name> <singular>abvolt</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>1.602176487e-19 C</def>
+            <aliases> <symbol>e</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>9.64957e4 C</def>
+            <aliases>
+                <name> <singular>chemical_faraday</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>9.65219e4 C</def>
+            <aliases>
+                <name> <singular>physical_faraday</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>9.648531e4 C</def>
+            <aliases>
+                <name> <singular>C12_faraday</singular> </name>
+                <name> <singular>faraday</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-9 T</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>gamma</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-4 T</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>gauss</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-8 Wb</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>maxwell</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>7.957747e1 A/m</def>
+            <aliases>
+                <name> <singular>oersted</singular> </name>
+                <symbol>Oe</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.335640e-10 C</def>
+            <aliases>
+                <name> <singular>statcoulomb</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.112650e-12 F</def>
+            <aliases>
+                <name> <singular>statfarad</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>8.987554e11 H</def>
+            <aliases>
+                <name> <singular>stathenry</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.112650e-12 S</def>
+            <aliases>
+                <name> <singular>statmho</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>8.987554e11 ohm</def>
+            <aliases>
+                <name> <singular>statohm</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2.997925e2 V</def>
+            <aliases>
+                <name> <singular>statvolt</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1.256637e-7 Wb</def>
+            <aliases>
+                <name> <singular>unit_pole</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>lg(re 1 V)</def>
+            <aliases> <symbol>BV</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>lg(re 0.775 V)</def>       <!-- rms voltage -->
+            <aliases> <symbol>Bv</symbol> </aliases>
+        </unit>
+        <unit>
+            <def>lg(re 1e-6 V)</def>
+            <aliases> <symbol>B&#xB5;V</symbol> </aliases>
+                                            <!-- uses MICRO SIGN -->
+        </unit>
+
+    <!-- Thermodynamic Temperature -->
+        <unit>
+            <def>K/1.8</def>
+            <aliases>
+                <symbol>&#xB0;R</symbol>    <!-- DEGREE SIGN -->
+                <name>
+                    <singular>degree_rankine</singular>
+                    <plural>degrees_rankine</plural>
+                </name>
+                <name>
+                    <singular>degreeR</singular>
+                    <plural>degreesR</plural>
+                </name>
+                <name>
+                    <singular>degree_R</singular>
+                    <plural>degrees_R</plural>
+                </name>
+                <name>
+                    <singular>degR</singular>
+                    <plural>degsR</plural>
+                </name>
+                <name>
+                    <singular>deg_R</singular>
+                    <plural>degs_R</plural>
+                </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>&#xB0;R @ 459.67</def>     <!-- DEGREE SIGN -->
+            <aliases>
+                <symbol>&#xB0;F</symbol>    <!-- DEGREE SIGN -->
+                <symbol>&#x2109;</symbol>   <!-- DEGREE FAHRENHEIT -->
+                <name> <singular>fahrenheit</singular> </name>
+                <name>
+                    <singular>degree_fahrenheit</singular>
+                    <plural>degrees_fahrenheit</plural>
+                </name>
+                <name>
+                    <singular>degreeF</singular>
+                    <plural>degreesF</plural>
+                </name>
+                <name>
+                    <singular>degree_F</singular>
+                    <plural>degrees_F</plural>
+                </name>
+                <name>
+                    <singular>degF</singular>
+                    <plural>degsF</plural>
+                </name>
+                <name>
+                    <singular>deg_F</singular>
+                    <plural>degs_F</plural>
+                </name>
+            </aliases>
+        </unit>
+
+    <!-- Illumination -->
+        <unit>
+            <def>1.076391e-1 lx</def>
+            <aliases>
+                <name> <singular>footcandle</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>3.426259 cd/m^2</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>footlambert</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>(1e4/pi) cd/m^2</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>lambert</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e4 cd/m^2</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>stilb</singular> </name>
+                <symbol>sb</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e4 lm/m^2</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>phot</singular> </name>
+                <symbol>ph</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1 cd/m^2</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>nit</singular> </name>
+                <symbol>nt</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>4.184000e4 J/m^2</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>langley</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>cd/(pi m^2)</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>blondel</singular> </name>
+                <name> <singular>apostilb</singular> </name>
+            </aliases>
+        </unit>
+
+    <!-- Miscellaneous -->
+        <unit>
+            <def>100/m</def>			<!-- exact -->
+            <aliases> <name> <singular>kayser</singular> </name> </aliases>
+        </unit>
+        <unit>
+            <def>gravity</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>geopotential</singular> </name>
+                <name> <singular>dynamic</singular> </name>
+                <symbol>gp</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>2056 hours</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>work_year</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>work_year/12</def>			<!-- exact -->
+            <aliases>
+                <name> <singular>work_month</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1e-6 m^2 s^-1 K kg^-1</def>		<!-- exact -->
+            <aliases>
+                <name> <singular>potential_vorticity_unit</singular> </name>
+                <symbol>PVU</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1</def>
+            <aliases>
+                <name> <singular>count</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>1</def>
+            <aliases>
+                <name> <singular>bit</singular> </name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>8</def>
+            <aliases>
+                <name><singular>octet</singular></name>
+                <name><singular>byte</singular></name>
+            </aliases>
+        </unit>
+        <unit>
+            <def>446.2 micromoles/meter^2</def>
+            <aliases>
+                <name> <singular>dobson</singular> </name>
+                <symbol>DU</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>mol/6.02214129e23</def> <!-- NIST 20130402 -->
+            <name><singular>molecule</singular></name>
+            <aliases>
+                <name><singular>molec</singular></name>
+                <name><singular>nucleon</singular></name>
+                <name><singular>nuc</singular></name>
+            </aliases>
+        </unit>
+</unit-system>
diff --git a/inst/udunits/udunits2-derived.xml b/inst/udunits/udunits2-derived.xml
new file mode 100644
index 0000000..735fe84
--- /dev/null
+++ b/inst/udunits/udunits2-derived.xml
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!--
+Copyright 2008, 2009 University Corporation for Atmospheric Research
+
+This file is part of the UDUNITS-2 package.  See the file COPYRIGHT
+in the top-level source-directory of the package for copying and
+redistribution conditions.
+
+SI derived units with special names and symbols
+-->
+<unit-system>
+    <unit>
+        <dimensionless/>
+        <name><singular>radian</singular></name>
+        <symbol>rad</symbol>
+    </unit>
+    <unit>
+        <def>rad^2</def>
+        <name><singular>steradian</singular></name>
+        <symbol>sr</symbol>
+    </unit>
+    <unit>
+        <def>1/s</def>
+        <name><singular>hertz</singular></name>
+        <symbol>Hz</symbol>
+    </unit>
+    <unit>
+        <def>1e-3 kg</def>
+        <name><singular>gram</singular></name>
+        <symbol>g</symbol>
+    </unit>
+    <unit>
+        <def>m.kg/s^2</def>
+        <name><singular>newton</singular></name>
+        <symbol>N</symbol>
+    </unit>
+    <unit>
+        <def>N/m^2</def>
+        <name><singular>pascal</singular></name>
+        <symbol>Pa</symbol>
+    </unit>
+    <unit>
+        <def>N.m</def>
+        <name><singular>joule</singular></name>
+        <symbol>J</symbol>
+    </unit>
+    <unit>
+        <def>J/s</def>
+        <name><singular>watt</singular></name>
+        <symbol>W</symbol>
+    </unit>
+    <unit>
+        <def>s.A</def>
+        <name><singular>coulomb</singular></name>
+        <symbol>C</symbol>
+    </unit>
+    <unit>
+        <def>W/A</def>
+        <name><singular>volt</singular></name>
+        <symbol>V</symbol>
+    </unit>
+    <unit>
+        <def>C/V</def>
+        <name><singular>farad</singular></name>
+        <symbol>F</symbol>
+    </unit>
+    <unit>
+        <def>V/A</def>
+        <name><singular>ohm</singular></name>
+        <symbol>&#x3A9;</symbol>        <!-- Greek capital letter omega
+                                             (preferred) -->
+        <aliases>
+            <symbol>&#x2126;</symbol>   <!-- OHM SIGN -->
+        </aliases>
+    </unit>
+    <unit>
+        <def>A/V</def>
+        <name> <singular>siemens</singular> </name>
+        <symbol>S</symbol>
+    </unit>
+    <unit>
+        <def>V.s</def>
+        <name><singular>weber</singular></name>
+        <symbol>Wb</symbol>
+    </unit>
+    <unit>
+        <def>Wb/m^2</def>
+        <name><singular>tesla</singular></name>
+        <symbol>T</symbol>
+    </unit>
+    <unit>
+        <def>Wb/A</def>
+        <name><singular>henry</singular></name>
+        <symbol>H</symbol>
+    </unit>
+    <unit>
+        <def>K @ 273.15</def>
+        <name>
+            <singular>degree_Celsius</singular>
+            <plural>degrees_Celsius</plural>
+        </name>
+        <symbol>&#xB0;C</symbol>            <!-- DEGREE SIGN -->
+    </unit>
+    <unit>
+        <def>cd.sr</def>
+        <name><singular>lumen</singular></name>
+        <symbol>lm</symbol>
+    </unit>
+    <unit>
+        <def>lm/m^2</def>
+        <name><singular>lux</singular></name>
+        <symbol>lx</symbol>
+    </unit>
+    <unit>
+        <def>mol/s</def>
+        <name><singular>katal</singular></name>
+        <symbol>kat</symbol>
+    </unit>
+
+    <!-- SI derived units with special names and symbols admitted for
+    reasons of safeguarding human health -->
+        <unit>
+            <def>1/s</def>
+            <aliases>
+                <!-- The following are aliases because "1/s" is already
+                mapped to "hertz" and "Hz" -->
+                <name><singular>becquerel</singular></name>
+                <symbol>Bq</symbol>
+            </aliases>
+        </unit>
+        <unit>
+            <def>J/kg</def>
+            <name><singular>gray</singular></name>
+            <symbol>Gy</symbol>
+        </unit>
+        <unit>
+            <def>J/kg</def>
+            <aliases>
+                <name><singular>sievert</singular></name>
+                <symbol>Sv</symbol>
+            </aliases>
+        </unit>
+</unit-system>
diff --git a/inst/udunits/udunits2-prefixes.xml b/inst/udunits/udunits2-prefixes.xml
new file mode 100644
index 0000000..859a11d
--- /dev/null
+++ b/inst/udunits/udunits2-prefixes.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!--
+Copyright 2008, 2009 University Corporation for Atmospheric Research
+
+This file is part of the UDUNITS-2 package.  See the file COPYRIGHT
+in the top-level source-directory of the package for copying and
+redistribution conditions.
+
+SI prefixes
+-->
+<unit-system>
+    <prefix>
+        <value>1e24</value> <name>yotta</name>	<symbol>Y</symbol>
+    </prefix>
+    <prefix>
+        <value>1e21</value> <name>zetta</name>	<symbol>Z</symbol>
+    </prefix>
+    <prefix>
+        <value>1e18</value> <name>exa</name>	<symbol>E</symbol>
+    </prefix>
+    <prefix>
+        <value>1e15</value> <name>peta</name>	<symbol>P</symbol>
+    </prefix>
+    <prefix>
+        <value>1e12</value> <name>tera</name>	<symbol>T</symbol>
+    </prefix>
+    <prefix>
+        <value>1e9</value> <name>giga</name>	<symbol>G</symbol>
+    </prefix>
+    <prefix>
+        <value>1e6</value> <name>mega</name>	<symbol>M</symbol>
+    </prefix>
+    <prefix>
+        <value>1e3</value> <name>kilo</name>	<symbol>k</symbol>
+    </prefix>
+    <prefix>
+        <value>100</value> <name>hecto</name>	<symbol>h</symbol>
+    </prefix>
+    <prefix>
+        <value>10</value> <name>deka</name>	<symbol>da</symbol>
+    </prefix>
+    <prefix>
+        <value>.1</value> <name>deci</name>	<symbol>d</symbol>
+    </prefix>
+    <prefix>
+        <value>.01</value> <name>centi</name>	<symbol>c</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-3</value> <name>milli</name>	<symbol>m</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-6</value>
+        <name>micro</name>
+        <symbol>&#xB5;</symbol>         <!-- MICRO SIGN -->
+        <symbol>&#x3BC;</symbol>	<!-- Greek small letter "mu" -->
+        <symbol>u</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-9</value> <name>nano</name>	<symbol>n</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-12</value> <name>pico</name>	<symbol>p</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-15</value> <name>femto</name>	<symbol>f</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-18</value> <name>atto</name>	<symbol>a</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-21</value> <name>zepto</name>	<symbol>z</symbol>
+    </prefix>
+    <prefix>
+        <value>1e-24</value> <name>yocto</name>	<symbol>y</symbol>
+    </prefix>
+</unit-system>
diff --git a/inst/udunits/udunits2.xml b/inst/udunits/udunits2.xml
new file mode 100644
index 0000000..faba8f7
--- /dev/null
+++ b/inst/udunits/udunits2.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!--
+Copyright 2008, 2009 University Corporation for Atmospheric Research
+
+This file is part of the UDUNITS-2 package.  See the file COPYRIGHT
+in the top-level source-directory of the package for copying and
+redistribution conditions.
+-->
+
+<unit-system>
+    <import>udunits2-prefixes.xml</import>
+    <import>udunits2-base.xml</import>
+    <import>udunits2-derived.xml</import>
+    <import>udunits2-accepted.xml</import>
+    <import>udunits2-common.xml</import>
+</unit-system>
diff --git a/man/var.get.nc.Rd b/man/var.get.nc.Rd
index 5af09d3..3cc93b1 100644
--- a/man/var.get.nc.Rd
+++ b/man/var.get.nc.Rd
@@ -6,23 +6,25 @@
 
 \description{Read the contents of a NetCDF variable.}
 
-\usage{var.get.nc(ncfile, variable, start=NA, count=NA, na.mode=0, collapse=TRUE, unpack=FALSE)}
+\usage{var.get.nc(ncfile, variable, start=NA, count=NA,
+        na.mode=0, collapse=TRUE, unpack=FALSE, rawchar=FALSE)}
 
 \arguments{
   \item{ncfile}{Object of class "\code{NetCDF}" which points to the NetCDF dataset (as returned from \code{\link[RNetCDF]{open.nc}}).}
   \item{variable}{ID or name of the variable.}
   \item{start}{A vector of indices indicating where to start reading the values (beginning at 1). The length of this vector must equal the number of dimensions the variable has. Order is leftmost varying fastest (as got from \code{\link[RNetCDF]{print.nc}}; opposite to the CDL conventions). If not specified (\code{start=NA}), reading starts at index 1.}
   \item{count}{A vector of integers indicating the count of values to read along each dimension. Order is leftmost varying fastest (as got from \code{\link[RNetCDF]{print.nc}}; opposite to the CDL conventions). The length of this vector must equal the number of dimensions the variable has. If not specified (\code{count=NA}), the entire variable or all values along the corresponding dimension(s) are read.}
-  \item{na.mode}{Set the mode how missing values (\code{NA}) are handled: 0=accept \code{_FillValue} or \code{missing_value} attribute, 1=accept only \code{_FillValue} attribute, 2=accept only \code{missing_value} attribute, 3=no missing value conversion.}
+  \item{na.mode}{Set the mode for handling missing values (\code{NA}) in numeric variables: 0=accept \code{_FillValue} or \code{missing_value} attribute, 1=accept only \code{_FillValue} attribute, 2=accept only \code{missing_value} attribute, 3=no missing value conversion.}
   \item{collapse}{\code{TRUE} if degenerated dimensions (length=1) should be omitted.}
   \item{unpack}{Packed variables are unpacked if \code{unpack=TRUE} and the attributes \code{add_offset} and \code{scale_factor} are defined. Default is \code{FALSE}.}
+  \item{rawchar}{This option only relates to NetCDF variables of type \code{NC_CHAR}. When \code{rawchar} is \code{FALSE} (default), a NetCDF variable of type \code{NC_CHAR} is converted to a \code{character} array in R. The \code{character} values are from the fastest-varying dimension of the NetCDF variable, so that the R \code{character} array has one fewer dimensions than the \code{NC_CHAR} array. If \code{rawchar} is \code{TRUE}, the bytes of \code{NC_CHAR} data are read into an R \ [...]
 }
 
-\details{This function returns the value of a variable. Returned values are always in ordinary R double precision (apart from character variables), no matter what precision they are in the on-disk dataset. 
+\details{This function returns the value of a variable. Numeric variables are always returned in R double precision, no matter what precision they have in the on-disk dataset. NetCDF variables of type \code{NC_CHAR} are returned as R \code{character} or \code{raw} variables, as specified by argument \code{rawchar}.
 
-Values of \code{NA} are supported; values in the data file that match the variable's missing value attribute (as defined in \code{na.mode}) are automatically converted to \code{NA} before being returned to the user. If \code{na.mode=0} and both attributes are defined, the value of \code{_FillValue} is used.
+Values of \code{NA} are supported in numeric variables. Values in the data file that match the variable's missing value attribute (as defined in \code{na.mode}) are automatically converted to \code{NA} before being returned to the user. If \code{na.mode=0} and both attributes are defined, the value of \code{_FillValue} is used.
 
-To reduce the storage space required by a NetCDF file, numeric variables are sometimes "packed" into types of lower precision. The original data can be recovered (approximately) by multiplication of the stored values by attribute \code{scale_factor} followed by addition of attribute \code{add_offset}. This unpacking operation is performed automatically for variables with attributes \code{scale_factor} and \code{add_offset} if argument \code{unpack} is set to \code{TRUE}. If \code{unpack} [...]
+To reduce the storage space required by a NetCDF file, numeric variables are sometimes "packed" into types of lower precision. The original data can be recovered (approximately) by multiplication of the stored values by attribute \code{scale_factor} followed by addition of attribute \code{add_offset}. This unpacking operation is performed automatically for variables with attributes \code{scale_factor} and \code{add_offset} if argument \code{unpack} is set to \code{TRUE}. If \code{unpack} [...]
 
 Data in a NetCDF file is conceived as being a multi-dimensional array. The number and length of dimensions is determined when the variable is created. The \code{start} and \code{count} indices that this routine takes indicate where the reading starts along each dimension, and the count of values along each dimension to read. 
 
@@ -30,7 +32,11 @@ The argument \code{collapse} allows to keep degenerated dimensions (if set to \c
 
 Awkwardness arises mainly from one thing: NetCDF data are written with the last dimension varying fastest, whereas R works opposite. Thus, the order of the dimensions according to the CDL conventions (e.g., time, latitude, longitude) is reversed in the R array (e.g., longitude, latitude, time).}
 
-\value{A multidimensional array of type \code{numeric} or \code{character} if the data type is \code{NC_CHAR}. No distinction is made between the different storage types of numeric objects. The dimension order according to the CDL conventions is swapped in the R array, because NetCDF data are written with the last dimension varying fastest, whereas R works opposite. Arrays of type \code{character} lose their first dimension, because strings can be indexed with one dimension in R and the  [...]
+\value{A multidimensional array with a data type that depends on the NetCDF variable. For NetCDF variables of type \code{NC_CHAR}, the R type is either \code{character} or \code{raw}, as specified by argument \code{rawchar}. All other NetCDF variables are returned to R as type \code{numeric} (double precision).
+
+The dimension order in the R array is reversed relative to the order reported by NetCDF commands such as \code{ncdump}, because NetCDF arrays are stored in row-major (C) order whereas R arrays are stored in column-major (Fortran) order.
+
+Arrays of type \code{character} drop the fastest-varying dimension of the corresponding \code{NC_CHAR} array, because this dimension corresponds to the length of the individual \code{character} elements. For example, an \code{NC_CHAR} array with dimensions (5,10) would be returned as a \code{character} vector containing 5 elements, each with a maximum length of 10 characters.}
 
 \references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
 
diff --git a/man/var.put.nc.Rd b/man/var.put.nc.Rd
index 1f23cd5..6301f12 100644
--- a/man/var.put.nc.Rd
+++ b/man/var.put.nc.Rd
@@ -14,15 +14,15 @@
   \item{data}{The (multidimensional) array containing the data to write.}
   \item{start}{A vector of indices indicating where to start writing the passed values (beginning at 1). The length of this vector must equal the number of dimensions the variable has. Order is leftmost varying fastest (as got from \code{\link[RNetCDF]{print.nc}}; opposite to the CDL conventions). If set to \code{NA}, writing starts for each dimension at position 1.}
   \item{count}{A vector of integers indicating the count of values to write along each dimension. Order is leftmost varying fastest (as got from \code{\link[RNetCDF]{print.nc}}; opposite to the CDL conventions). The length of this vector must equal the number of dimensions the variable has. If set to \code{NA}, the dimesions are taken from \code{data}.}
-  \item{na.mode}{Set the mode how missing values (\code{NA}) are handled: 0=accept \code{_FillValue} or \code{missing_value} attribute, 1=accept only \code{_FillValue} attribute, 2=accept only \code{missing_value} attribute.}
+  \item{na.mode}{Set the mode for handling missing values (\code{NA}) in numeric variables: 0=accept \code{_FillValue} or \code{missing_value} attribute, 1=accept only \code{_FillValue} attribute, 2=accept only \code{missing_value} attribute.}
   \item{pack}{Variables are packed if \code{pack=TRUE} and the attributes \code{add_offset} and \code{scale_factor} are defined. Default is \code{FALSE}.}
 }
 
-\details{This function writes values to a NetCDF variable. Type conversion is done by the NetCDF library itself. This means, that double precision values are passed from R to the corresponding C-function, no matter which type the variable has. 
+\details{This function writes values to a NetCDF variable. Type conversion is performed by the NetCDF library, so that numeric values in R are automatically converted to the correct type of NetCDF variable.
 
-Only the R type \code{character} is treated separately. When writing values of type \code{NC_CHAR}, it is mandatory that the first element of \code{count} contains the value of this dimension's length (usually \code{max_string_length}), the maximum string length is given by this value. R arrays of type \code{character} need therefore one additional dimension when written to a NetCDF dataset.
+However, text represented by R types \code{raw} and \code{character} can only be written to NetCDF type \code{NC_CHAR}. The dimensions of R \code{raw} variables map directly to NetCDF dimensions, but \code{character} variables have an implied dimension corresponding to the string length. This implied dimension must be defined explicitly as the fastest-varying dimension of the \code{NC_CHAR} variable, and it must be included as the first element of arguments \code{start} and \code{count}  [...]
 
-Values of \code{NA} are supported if the variable's missing value attribute (as defined in \code{na.mode}) is set. They are converted to the corresponding value before written to disk. If \code{na.mode=0} and both attributes are defined, the value of \code{_FillValue} is used.
+Values of \code{NA} are supported in numeric variables if the variable's missing value attribute (as defined in \code{na.mode}) is set. They are converted to the corresponding value before writing to disk. If \code{na.mode=0} and both attributes are defined, the value of \code{_FillValue} is used.
 
 To reduce the storage space required by a NetCDF file, numeric variables can be "packed" into types of lower precision. The packing operation involves subtraction of attribute \code{add_offset} before division by attribute \code{scale_factor}. This packing operation is performed automatically for variables defined with the two attributes \code{add_offset} and \code{scale_factor} if argument \code{pack} is set to \code{TRUE}. If \code{pack} is \code{FALSE}, \code{data} values are assumed  [...]
 
diff --git a/src/Makevars.in b/src/Makevars.in
index bf4af28..d341952 100644
--- a/src/Makevars.in
+++ b/src/Makevars.in
@@ -1,2 +1,4 @@
-PKG_CPPFLAGS = @CPPFLAGS@
+PKG_CPPFLAGS = @DEFS@ @CPPFLAGS@
+PKG_LDFLAGS = @LDFLAGS@
 PKG_LIBS = @LIBS@
+
diff --git a/src/Makevars.win b/src/Makevars.win
old mode 100644
new mode 100755
index 2c95c7e..fec5b47
--- a/src/Makevars.win
+++ b/src/Makevars.win
@@ -1,2 +1,14 @@
-PKG_CPPFLAGS=-I$(NETCDF)/libsrc -I$(UDUNITS2_HOME)/include
-PKG_LIBS=-L$(NETCDF)/libsrc -lnetcdf -L$(UDUNITS2_HOME)$(R_ARCH) -ludunits2 -lexpat
+# Assume Rtools is installed from
+#   http://cran.r-project.org/bin/windows/Rtools/
+# and external software is installed from
+#   http://www.stats.ox.ac.uk/pub/Rtools/libs.html
+#
+# Note that the installation location of the external software 
+# should ideally be set in makefiles used by R when building packages.
+# For example, R/3.1 contains a file $R_HOME/etc/{i386,x64}/Makeconf
+# where the relevant variables are LOCAL_SOFT, LOCAL_CPPFLAGS and LOCAL_LIBS.
+# Please consult the R Installation and Administration manual of your R version.
+
+PKG_CPPFLAGS = -DHAVE_LIBUDUNITS2
+PKG_LIBS=-lnetcdf -ludunits2 -lexpat
+
diff --git a/src/RNetCDF.c b/src/RNetCDF.c
index 5618960..15769dd 100644
--- a/src/RNetCDF.c
+++ b/src/RNetCDF.c
@@ -2,7 +2,7 @@
  *									       *
  *  Name:       RNetCDF.c						       *
  *									       *
- *  Version:    1.6.3-1							       *
+ *  Version:    1.7-3							       *
  *									       *
  *  Purpose:    NetCDF interface for R.					       *
  *									       *
@@ -50,6 +50,13 @@
  *  pm       04/01/11   Corrected string handling in R_nc_get_vara_text        *
  *  pm       05/01/11   Removed extra zeroing after Calloc                     *
  *  pm       26/05/14   Corrected memory leak issue (lines 1338 and 1593)      *
+ *  mw       05/09/14   Support reading and writing raw character arrays,      *
+ *                      avoid temporary arrays when reading/writing variables  *
+ *  mw       08/09/14   Handle reading and writing of zero-sized arrays        *
+ *  mw       01/02/15   Remove redundant ut_read_xml from R_ut_init            *
+ *  mw       24/04/15   Initialise and free utunit when using udunits2,        *
+ *                      to fix memory errors reported by valgrind.             *
+ *                      Allow udunits2 headers to be in udunits2 directory.    *
  *									       *
 \*=============================================================================*/
 
@@ -62,7 +69,12 @@
 #include <string.h>
 
 #include <netcdf.h>
-#include <udunits.h>
+
+#ifdef HAVE_UDUNITS2_UDUNITS_H
+  #include <udunits2/udunits.h>
+#else
+  #include <udunits.h>
+#endif
 
 #include <R.h>
 #include <Rinternals.h>
@@ -1173,18 +1185,25 @@ SEXP R_nc_def_var (SEXP ncid, SEXP varname, SEXP type, SEXP ndims, SEXP dimids)
 \*-----------------------------------------------------------------------------*/
 
 SEXP R_nc_get_vara_double (SEXP ncid, SEXP varid, SEXP start, 
-                           SEXP count, SEXP varsize)
+                           SEXP count, SEXP ndims)
 {
-    int    ndims, i, status;
-    double *data;
-    size_t s_start[MAX_NC_DIMS], s_count[MAX_NC_DIMS];
+    int    i, status;
+    size_t s_start[MAX_NC_DIMS], s_count[MAX_NC_DIMS], varsize;
     SEXP   retlist, retlistnames;
 
+    /*-- Copy dims from int to size_t, calculate total array size -------------*/
+    varsize = 1;
+    for(i=0; i<INTEGER(ndims)[0]; i++) {
+	s_start[i] = (size_t)INTEGER(start)[i];
+	s_count[i] = (size_t)INTEGER(count)[i];
+	varsize *= s_count[i];
+    }
+	
     /*-- Create output object and initialize return values --------------------*/
     PROTECT(retlist = allocVector(VECSXP, 3));
     SET_VECTOR_ELT(retlist, 0, allocVector(REALSXP, 1));
     SET_VECTOR_ELT(retlist, 1, allocVector(STRSXP,  1));
-    SET_VECTOR_ELT(retlist, 2, allocVector(REALSXP, INTEGER(varsize)[0]));
+    SET_VECTOR_ELT(retlist, 2, allocVector(REALSXP, varsize));
 
     PROTECT(retlistnames = allocVector(STRSXP, 3)); 
     SET_STRING_ELT(retlistnames, 0, mkChar("status")); 
@@ -1192,62 +1211,32 @@ SEXP R_nc_get_vara_double (SEXP ncid, SEXP varid, SEXP start,
     SET_STRING_ELT(retlistnames, 2, mkChar("data")); 
     setAttrib(retlist, R_NamesSymbol, retlistnames); 
 
-    data = Calloc(INTEGER(varsize)[0], double);
-
     status = -1;
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	 
     SET_VECTOR_ELT (retlist, 1, mkString(""));
 
-    /*-- Get ndims for this var -----------------------------------------------*/
-    status = nc_inq_varndims(INTEGER(ncid)[0], INTEGER(varid)[0], &ndims);
-    if(status != NC_NOERR) {
-        SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
-	REAL(VECTOR_ELT(retlist, 0))[0] = status;
-        UNPROTECT(2);
-	Free(data);
-	return(retlist);
-    }
-
-    /*-- Copy over from int to size_t, handle scalar variables ----------------*/
-    if(ndims > 0) {
-	for(i=0; i<ndims; i++) {
-	    s_start[i] = (size_t)INTEGER(start)[i];
-	    s_count[i] = (size_t)INTEGER(count)[i];
-	}
-    }
-    else {
-        s_start[0] = 0;
-	s_count[0] = 1;
-    }
-		
     /*-- Enter data mode (if necessary) ---------------------------------------*/
     status = nc_enddef(INTEGER(ncid)[0]);
     if((status != NC_NOERR) && (status != NC_ENOTINDEFINE)) {
         SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
         REAL(VECTOR_ELT(retlist, 0))[0] = status;
 	UNPROTECT(2);
-	Free(data);
 	return(retlist);
     }
 
-    /*-- Get the var ----------------------------------------------------------*/
-    status = nc_get_vara_double(INTEGER(ncid)[0], INTEGER(varid)[0],
-        s_start, s_count, data);
-    if(status != NC_NOERR) {
-        SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
-	REAL(VECTOR_ELT(retlist, 0))[0] = status;
-        UNPROTECT(2);
-	Free(data);
-	return(retlist);
+    /*-- Read variable from file ----------------------------------------------*/
+    if (varsize > 0) {
+      /* Some netcdf versions cannot handle zero-sized arrays */
+      status = nc_get_vara_double(INTEGER(ncid)[0], INTEGER(varid)[0],
+        s_start, s_count, REAL(VECTOR_ELT(retlist, 2)));
+    } else {
+      status = NC_NOERR;
     }
    
-    /*-- Copy from C to R object ----------------------------------------------*/
-    for(i=0; i<INTEGER(varsize)[0]; i++)
-        REAL(VECTOR_ELT(retlist, 2))[i] = (double)data[i];
-
-    Free(data);
-
     /*-- Returning the list ---------------------------------------------------*/
+    if(status != NC_NOERR) {
+      SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
+    }
     REAL(VECTOR_ELT(retlist, 0))[0] = status;
     UNPROTECT(2);
     return(retlist);
@@ -1259,21 +1248,42 @@ SEXP R_nc_get_vara_double (SEXP ncid, SEXP varid, SEXP start,
 \*-----------------------------------------------------------------------------*/
 
 SEXP R_nc_get_vara_text (SEXP ncid, SEXP varid, SEXP start, 
-                         SEXP count, SEXP varsize)
+                         SEXP count, SEXP ndims, SEXP rawchar)
 {
-    int    ndims, tx_len, tx_num, i, j, status;
+    int    i, status;
     char   *data, *tx_str;
     size_t s_start[MAX_NC_DIMS], s_count[MAX_NC_DIMS];
+    size_t tx_len, tx_num, varsize;
     SEXP   retlist, retlistnames;
 
+    /*-- Copy dims from int to size_t, calculate number and length of strings -*/
+    for(i=0; i<INTEGER(ndims)[0]; i++) {
+	s_start[i] = (size_t)INTEGER(start)[i];
+	s_count[i] = (size_t)INTEGER(count)[i];
+    }
+
+    if(INTEGER(ndims)[0] > 0) {
+        tx_num = 1;
+	for(i=0; i<INTEGER(ndims)[0]-1; i++) {
+            tx_num *= s_count[i];
+	}
+        tx_len = s_count[INTEGER(ndims)[0]-1];
+    } else {
+        tx_num = 1;
+        tx_len = 1;
+    }
+    varsize = tx_num*tx_len;
+
     /*-- Create output object and initialize return values --------------------*/
-    tx_len = INTEGER(varsize)[1];
-    tx_num = INTEGER(varsize)[0]/tx_len;
-    
     PROTECT(retlist = allocVector(VECSXP, 3));
     SET_VECTOR_ELT(retlist, 0, allocVector(REALSXP, 1));
     SET_VECTOR_ELT(retlist, 1, allocVector(STRSXP,  1));
-    SET_VECTOR_ELT(retlist, 2, allocVector(STRSXP,  tx_num));
+
+    if (INTEGER(rawchar)[0] > 0) {
+      SET_VECTOR_ELT(retlist, 2, allocVector(RAWSXP, varsize));
+    } else {
+      SET_VECTOR_ELT(retlist, 2, allocVector(STRSXP, tx_num));
+    }
 
     PROTECT(retlistnames = allocVector(STRSXP, 3)); 
     SET_STRING_ELT(retlistnames, 0, mkChar("status")); 
@@ -1285,64 +1295,44 @@ SEXP R_nc_get_vara_text (SEXP ncid, SEXP varid, SEXP start,
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	 
     SET_VECTOR_ELT (retlist, 1, mkString(""));
 
-    data = Calloc(INTEGER(varsize)[0], char);                 /*-- Is zeroed --*/
-
-    /*-- Get ndims for this var -----------------------------------------------*/
-    status = nc_inq_varndims(INTEGER(ncid)[0], INTEGER(varid)[0], &ndims);
-    if(status != NC_NOERR) {
-        SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
-	REAL(VECTOR_ELT(retlist, 0))[0] = status;
-        UNPROTECT(2);
-	Free(data);
-	return(retlist);
-    }
-
-    /*-- Copy over from int to size_t, handle scalar variables ----------------*/
-    if(ndims > 0) {
-	for(i=0; i<ndims; i++) {
-	    s_start[i] = (size_t)INTEGER(start)[i];
-	    s_count[i] = (size_t)INTEGER(count)[i];
-	}
-    }
-    else {
-        s_start[0] = 0;
-	s_count[0] = 1;
-    }
-
     /*-- Enter data mode (if necessary) ---------------------------------------*/
     status = nc_enddef(INTEGER(ncid)[0]);
     if((status != NC_NOERR) && (status != NC_ENOTINDEFINE)) {
         SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
         REAL(VECTOR_ELT(retlist, 0))[0] = status;
 	UNPROTECT(2);
-	Free(data);
 	return(retlist);
     }
 
-    /*-- Get the var ----------------------------------------------------------*/
-    status = nc_get_vara_text(INTEGER(ncid)[0], INTEGER(varid)[0],
+    /*-- Read variable from file ----------------------------------------------*/
+    if (INTEGER(rawchar)[0] > 0) {
+      data = (char *) RAW(VECTOR_ELT(retlist, 2));
+    } else {
+      data = (char *) R_alloc(varsize, sizeof(char));
+    }
+
+    if (varsize > 0) {
+      /* Some netcdf versions cannot handle zero-sized arrays */
+      status = nc_get_vara_text(INTEGER(ncid)[0], INTEGER(varid)[0],
         s_start, s_count, data);
-    if(status != NC_NOERR) {
-        SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
-	REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;
-        UNPROTECT(2);
-	Free(data);
-	return(retlist);
+    } else {
+      status = NC_NOERR;
     }
-   
-    /*-- Copy from C to R object ----------------------------------------------*/
-    tx_str = Calloc(tx_len+1, char);                    /*-- String handling --*/
-    for(i=0; i<tx_num; i++) {
-        for(j=0; j<tx_len; j++)
-            tx_str[j] = data[i*tx_len+j];
-	tx_str[j] = '\0';                               /*-- String handling --*/
+
+    /*-- Copy from C to R character vector (if specified) ---------------------*/
+    if (status == NC_NOERR && INTEGER(rawchar)[0] <= 0) {
+      tx_str = (char *) R_alloc(tx_len+1, sizeof(char));
+      tx_str[tx_len] = '\0'; /* Final null character is never modified */
+      for(i=0; i<tx_num; i++) {
+        strncpy(tx_str, data+i*tx_len, tx_len);
 	SET_STRING_ELT(VECTOR_ELT(retlist, 2), i, mkChar(tx_str));
+      }
     }
 
-    Free(data);
-    Free(tx_str);
-
     /*-- Returning the list ---------------------------------------------------*/
+    if (status != NC_NOERR) {
+      SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
+    }
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;
     UNPROTECT(2);
     return(retlist);
@@ -1475,12 +1465,20 @@ SEXP R_nc_inq_var (SEXP ncid, SEXP varid, SEXP varname, SEXP nameflag)
 \*-----------------------------------------------------------------------------*/
 
 SEXP R_nc_put_vara_double (SEXP ncid, SEXP varid, SEXP start, 
-                           SEXP count, SEXP data)
+                           SEXP count, SEXP ndims, SEXP data)
 {
-    int    ndims, i, status;
-    size_t s_start[MAX_NC_DIMS], s_count[MAX_NC_DIMS];
+    int    i, status;
+    size_t s_start[MAX_NC_DIMS], s_count[MAX_NC_DIMS], varsize;
     SEXP   retlist, retlistnames;
 
+    /*-- Copy dims from int to size_t -----------------------------------------*/
+    varsize = 1;
+    for(i=0; i<INTEGER(ndims)[0]; i++) {
+	s_start[i] = (size_t)INTEGER(start)[i];
+	s_count[i] = (size_t)INTEGER(count)[i];
+        varsize *= s_count[i];
+    }
+
     /*-- Create output object and initialize return values --------------------*/
     PROTECT(retlist = allocVector(VECSXP, 2));
     SET_VECTOR_ELT(retlist, 0, allocVector(REALSXP, 1));
@@ -1495,27 +1493,6 @@ SEXP R_nc_put_vara_double (SEXP ncid, SEXP varid, SEXP start,
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	 
     SET_VECTOR_ELT (retlist, 1, mkString(""));
 
-    /*-- Get ndims for this var -----------------------------------------------*/
-    status = nc_inq_varndims(INTEGER(ncid)[0], INTEGER(varid)[0], &ndims);
-    if(status != NC_NOERR) {
-        SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
-        REAL(VECTOR_ELT(retlist, 0))[0] = status;	 
-	UNPROTECT(2);
-	return(retlist);
-    }
-
-    /*-- Copy over from int to size_t, handle scalar variables ----------------*/
-    if(ndims > 0) {
-	for(i=0; i<ndims; i++) {
-	    s_start[i] = (size_t)INTEGER(start)[i];
-	    s_count[i] = (size_t)INTEGER(count)[i];
-	}
-    }
-    else {
-        s_start[0] = 0;
-	s_count[0] = 1;
-    }
-
     /*-- Enter data mode (if necessary) ---------------------------------------*/
     status = nc_enddef(INTEGER(ncid)[0]);
     if((status != NC_NOERR) && (status != NC_ENOTINDEFINE)) {
@@ -1526,12 +1503,18 @@ SEXP R_nc_put_vara_double (SEXP ncid, SEXP varid, SEXP start,
     }
 
     /*-- Put the var ----------------------------------------------------------*/
-    status = nc_put_vara_double(INTEGER(ncid)[0], INTEGER(varid)[0],
+    if (varsize > 0) {
+      /* Some netcdf versions cannot handle zero-sized arrays */
+      status = nc_put_vara_double(INTEGER(ncid)[0], INTEGER(varid)[0],
         s_start, s_count, REAL(data));
-    if(status != NC_NOERR)
-        SET_VECTOR_ELT(retlist, 1, mkString(nc_strerror(status)));
+    } else {
+      status = NC_NOERR;
+    }
 
     /*-- Returning the list ---------------------------------------------------*/
+    if (status != NC_NOERR) {
+      SET_VECTOR_ELT(retlist, 1, mkString(nc_strerror(status)));
+    }
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	 
     UNPROTECT(2);
     return(retlist);
@@ -1543,17 +1526,33 @@ SEXP R_nc_put_vara_double (SEXP ncid, SEXP varid, SEXP start,
 \*-----------------------------------------------------------------------------*/
 
 SEXP R_nc_put_vara_text (SEXP ncid, SEXP varid, SEXP start, 
-                         SEXP count, SEXP data, SEXP varsize)
+                         SEXP count, SEXP ndims, SEXP rawchar, SEXP data)
 {
-    int    ndims, tx_num, tx_len, i, j, status;
-    char   *ncdata, *tx_str;
+    int    i, status;
+    char   *ncdata;
     size_t s_start[MAX_NC_DIMS], s_count[MAX_NC_DIMS];
+    size_t tx_len, tx_num, varsize;
     SEXP   retlist, retlistnames;
 
+    /*-- Copy dims from int to size_t, calculate number and length of strings -*/
+    for(i=0; i<INTEGER(ndims)[0]; i++) {
+	s_start[i] = (size_t)INTEGER(start)[i];
+	s_count[i] = (size_t)INTEGER(count)[i];
+    }
+
+    if (INTEGER(ndims)[0] > 0) {
+	tx_num = 1;
+	for(i=0; i<INTEGER(ndims)[0]-1; i++) {
+	    tx_num *= s_count[i];
+	}
+	tx_len = s_count[INTEGER(ndims)[0]-1];
+    } else {
+	tx_num = 1;
+	tx_len = 1;
+    }
+    varsize = tx_num*tx_len;
+
     /*-- Create output object and initialize return values --------------------*/
-    tx_len = INTEGER(varsize)[1];
-    tx_num = INTEGER(varsize)[0]/tx_len;
-    
     PROTECT(retlist = allocVector(VECSXP, 2));
     SET_VECTOR_ELT(retlist, 0, allocVector(REALSXP, 1));
     SET_VECTOR_ELT(retlist, 1, allocVector(STRSXP,  1));
@@ -1567,60 +1566,38 @@ SEXP R_nc_put_vara_text (SEXP ncid, SEXP varid, SEXP start,
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	 
     SET_VECTOR_ELT (retlist, 1, mkString(""));
 
-    /*-- Get ndims for this var -----------------------------------------------*/
-    status = nc_inq_varndims(INTEGER(ncid)[0], INTEGER(varid)[0], &ndims);
-    if(status != NC_NOERR) {
-        SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
-        REAL(VECTOR_ELT(retlist, 0))[0] = status;	 
-	UNPROTECT(2);
-	return(retlist);
-    }
-
-    /*-- Copy over from int to size_t, handle scalar variables ----------------*/
-    if(ndims > 0) {
-	for(i=0; i<ndims; i++) {
-	    s_start[i] = (size_t)INTEGER(start)[i];
-	    s_count[i] = (size_t)INTEGER(count)[i];
-	}
-    }
-    else {
-        s_start[0] = 0;
-	s_count[0] = 1;
-    }
-
-    /*-- Copy from R to C object ----------------------------------------------*/
-    ncdata = Calloc(tx_len*tx_num, char);                     /*-- Is zeroed --*/
-    tx_str = Calloc(tx_len+1, char);                          /*-- Is zeroed --*/
-        
-    for(i=0; i<tx_num; i++) {
-        strcpy(tx_str, CHAR(STRING_ELT(data, i)));
-	for(j=0; j<tx_len; j++) {
-            ncdata[i*tx_len+j] = tx_str[j];
-	    tx_str[j] = '\0';
-	}
-    }
-
     /*-- Enter data mode (if necessary) ---------------------------------------*/
     status = nc_enddef(INTEGER(ncid)[0]);
     if((status != NC_NOERR) && (status != NC_ENOTINDEFINE)) {
         SET_VECTOR_ELT (retlist, 1, mkString(nc_strerror(status)));
         REAL(VECTOR_ELT(retlist, 0))[0] = status;
 	UNPROTECT(2);
-	Free(ncdata);
-	Free(tx_str);
 	return(retlist);
     }
 
-    /*-- Put the var ----------------------------------------------------------*/
-    status = nc_put_vara_text(INTEGER(ncid)[0], INTEGER(varid)[0],
-        s_start, s_count, ncdata);
-    if(status != NC_NOERR)
-        SET_VECTOR_ELT(retlist, 1, mkString(nc_strerror(status)));
-
-    Free(ncdata);
-    Free(tx_str);
+    /*-- Prepare output array -------------------------------------------------*/
+    if (INTEGER(rawchar)[0] > 0) {
+      ncdata = (char *) RAW(data);
+    } else {
+      ncdata = (char *) R_alloc(varsize, sizeof(char));
+      for(i=0; i<tx_num; i++) {
+	  strncpy(ncdata+i*tx_len, CHAR(STRING_ELT(data, i)), tx_len);
+      }
+    }
+ 
+    /*-- Write variable to file -----------------------------------------------*/
+    if (varsize > 0) {
+      /* Some netcdf versions cannot handle zero-sized arrays */
+      status = nc_put_vara_text(INTEGER(ncid)[0], INTEGER(varid)[0],
+	  s_start, s_count, ncdata);
+    } else {
+      status = NC_NOERR;
+    }
 
     /*-- Returning the list ---------------------------------------------------*/
+    if(status != NC_NOERR) {
+      SET_VECTOR_ELT(retlist, 1, mkString(nc_strerror(status)));
+    }
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	 
     UNPROTECT(2);
     return(retlist);
@@ -1769,6 +1746,10 @@ SEXP R_ut_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
     SET_VECTOR_ELT (retlist, 1, mkString(""));
     
     /*-- Scan unitstring ------------------------------------------------------*/
+#ifdef HAVE_LIBUDUNITS2
+    utIni(&utunit);
+#endif
+
     status = utScan(CHAR(STRING_ELT(unitstring, 0)), &utunit);
     if(status != 0) {
         R_ut_strerror(status, strerror);
@@ -1812,6 +1793,10 @@ SEXP R_ut_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
 	REAL(VECTOR_ELT(retlist, 2))[i+5*count] = (double)second;
     }
 
+#ifdef HAVE_LIBUDUNITS2
+    utFree(&utunit);
+#endif
+
     /*-- Returning the list ---------------------------------------------------*/
     if(status != 0) {
         R_ut_strerror(status, strerror);
@@ -1835,12 +1820,9 @@ SEXP R_ut_init (SEXP path)
     SEXP  retlist, retlistnames;
 
     /*-- Avoid "overriding default" messages from UDUNITS-2 (1/2) -------------*/
-    #ifdef UT_UNITS2_H_INCLUDED
-        ut_system* unitSystem;
-
-        ut_set_error_message_handler(ut_ignore);
-        unitSystem = ut_read_xml(NULL);
-    #endif
+#ifdef HAVE_LIBUDUNITS2
+    ut_set_error_message_handler(ut_ignore);
+#endif
 
     /*-- Create output object and initialize return values --------------------*/
     PROTECT(retlist = allocVector(VECSXP, 2));
@@ -1864,9 +1846,9 @@ SEXP R_ut_init (SEXP path)
     }
 
     /*-- Avoid "overriding default" messages from UDUNITS-2 (2/2) -------------*/
-    #ifdef UT_UNITS2_H_INCLUDED
-        ut_set_error_message_handler(ut_write_to_stderr);
-    #endif
+#ifdef HAVE_LIBUDUNITS2
+    ut_set_error_message_handler(ut_write_to_stderr);
+#endif
 
     /*-- Returning the list ---------------------------------------------------*/
     REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;
@@ -1908,6 +1890,10 @@ SEXP R_ut_inv_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
     SET_VECTOR_ELT (retlist, 1, mkString(""));
     
     /*-- Scan unitstring ------------------------------------------------------*/
+#ifdef HAVE_LIBUDUNITS2
+    utIni(&utunit);
+#endif
+
     status = utScan(CHAR(STRING_ELT(unitstring, 0)), &utunit);
     if(status != 0) {
         R_ut_strerror(status, strerror);
@@ -1951,6 +1937,10 @@ SEXP R_ut_inv_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
         REAL(VECTOR_ELT(retlist, 2))[i] = (double)utvalue;
     }
 
+#ifdef HAVE_LIBUDUNITS2
+    utFree(&utunit);
+#endif
+
     /*-- Returning the list ---------------------------------------------------*/
     if(status != 0) {
         R_ut_strerror(status, strerror);
diff --git a/tests/RNetCDF-test.R b/tests/RNetCDF-test.R
index 1f73ac7..9655c4b 100644
--- a/tests/RNetCDF-test.R
+++ b/tests/RNetCDF-test.R
@@ -2,7 +2,7 @@
 #                                                                               #
 #  Name:       RNetCDF-test.R                                                   #
 #                                                                               #
-#  Version:    1.6.3-1                                                          #
+#  Version:    1.7-3                                                          #
 #                                                                               #
 #  Purpose:    Test functions to the NetCDF interface for R.                    #
 #                                                                               #
@@ -34,6 +34,8 @@
 #  ------   ----       -----------                                              #
 #  pm       29/12/10   First implementation                                     #
 #  mw       18/07/12   Test packed variables                                    #
+#  mw       02/09/14   Test 1D character arrays and character scalars           #
+#  mw       05/09/14   Test reading/writing NC_CHAR as raw bytes                #
 #                                                                               #
 #===============================================================================#
 
@@ -55,20 +57,43 @@ library(RNetCDF)
 
 #--Initialize ------------------------------------------------------------------#
 cat("Starting NetCDF tests...\n")
-nccount <- 0
 
-##  Create a new NetCDF dataset and define two dimensions
+testfun <- function(x,y,tally=NULL) {
+  if (is.null(tally)) {
+    tally <- c(pass=0,fail=0)
+  }
+  # Compare numeric values with single precision tolerance:
+  if (isTRUE(all.equal(x,y,tolerance=2^(-23)))) {
+    cat("OK\n")
+    return(tally+c(1,0))
+  } else {
+    cat("failed\n")
+    return(tally+c(0,1))
+  }
+}
+
+##  Create a new NetCDF dataset and define dimensions
 nc <- create.nc("foo.nc")
 
-dim.def.nc(nc, "station", 5)
-dim.def.nc(nc, "time", unlim=TRUE)
-dim.def.nc(nc, "max_string_length", 32)
+nstation <- 5
+ntime <- 2
+nstring <- 32
+nempty <- 0
+
+dim.def.nc(nc, "station", nstation)
+dim.def.nc(nc, "time", ntime)
+dim.def.nc(nc, "max_string_length", nstring)
+dim.def.nc(nc, "empty", unlim=TRUE)
 
-##  Create three variables, one as coordinate variable
+##  Define variables
 var.def.nc(nc, "time", "NC_INT", "time")
 var.def.nc(nc, "temperature", "NC_DOUBLE", c(0,1))
 var.def.nc(nc, "packvar", "NC_BYTE", c("station"))
 var.def.nc(nc, "name", "NC_CHAR", c("max_string_length", "station"))
+var.def.nc(nc, "qcflag", "NC_CHAR", c("station"))
+var.def.nc(nc, "int0", "NC_INT", NA)
+var.def.nc(nc, "char0", "NC_CHAR", NA)
+var.def.nc(nc, "numempty", "NC_FLOAT", c("station","empty"))
 
 ##  Put some missing_value attribute for temperature
 att.put.nc(nc, "temperature", "missing_value", "NC_DOUBLE", -99999.9)
@@ -79,100 +104,108 @@ att.put.nc(nc, "packvar", "add_offset", "NC_DOUBLE", -5)
 
 ##  Define variable values
 mytime        <- c(1:2)
-mytemperature <- c(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, NA, NA, 9.9)
+mytemperature <- matrix(c(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, NA, NA, 9.9),ncol=ntime)
 mypackvar     <- seq_len(5)*10-5
 myname        <- c("alfa", "bravo", "charlie", "delta", "echo")
+myqcflag      <- "ABCDE"
+myint0        <- 12345
+mychar0       <- "?"
 
 ##  Put the data
 var.put.nc(nc, "time", mytime, 1, length(mytime))
-var.put.nc(nc, "temperature", mytemperature, c(1,1), c(5,2))
+var.put.nc(nc, "temperature", mytemperature, c(1,1), c(nstation,ntime))
 var.put.nc(nc, "packvar", mypackvar, pack=TRUE)
-var.put.nc(nc, "name", myname, c(1,1), c(32,5))
+var.put.nc(nc, "name", myname, c(1,1), c(nstring,nstation))
+var.put.nc(nc, "qcflag", charToRaw(myqcflag))
+var.put.nc(nc, "int0", myint0)
+var.put.nc(nc, "char0", mychar0)
 
 sync.nc(nc)
 
-#-- Test 1 (read) --------------------------------------------------------------#
-cat("Test 1 ... ")
-
-x <- c(1, 2)
+## Read tests
+cat("Read numeric vector ... ")
+x <- mytime
+dim(x) <- length(x)
 y <- var.get.nc(nc, 0)
+tally <- testfun(x,y)
 
-if(sum(y %in% x) == 2) {
-    cat("OK\n")
-    nccount <- nccount + 1
-} else
-    cat("failed\n")
-
-#-- Test 2 (read) --------------------------------------------------------------#
-cat("Test 2 ... ")
-
-x <- matrix(data=c(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, NA, NA, 9.9), ncol=2)
+cat("Read numeric matrix ... ")
+x <- mytemperature
 y <- var.get.nc(nc, "temperature")
+tally <- testfun(x,y,tally)
 
-if(sum(y %in% x) == 10) {
-    cat("OK\n")
-    nccount <- nccount + 1
-} else
-    cat("failed\n")
-
-#-- Test 3 (read) --------------------------------------------------------------#
-cat("Test 3 ... ")
-
-x <- c(6.6, 7.7, NA, NA, 9.9)
+cat("Read numeric matrix slice ... ")
+x <- mytemperature[,2]
+dim(x) <- length(x)
 y <- var.get.nc(nc, "temperature", c(NA,2), c(NA,1))
-
-if(sum(y %in% x) == 5) {
-    cat("OK\n")
-    nccount <- nccount + 1
-} else
-    cat("failed\n")
-
-#-- Test 4 (read) --------------------------------------------------------------#
-cat("Test 4 ... ")
-
-x <- c("alfa", "bravo", "charlie", "delta", "echo" )
+tally <- testfun(x,y,tally)
+
+cat("Read numeric matrix empty slice ... ")
+x <- numeric(0)
+dim(x) <- c(0,1)
+y <- var.get.nc(nc, "temperature", c(NA,2), c(0,1),collapse=FALSE)
+tally <- testfun(x,y,tally)
+
+cat("Read numeric scalar ... ")
+x <- myint0
+dim(x) <- 1
+y <- var.get.nc(nc, "int0")
+tally <- testfun(x,y,tally)
+
+cat("Read numeric empty array ... ")
+x <- numeric(0)
+dim(x) <- c(nstation,nempty)
+y <- var.get.nc(nc, "numempty")
+tally <- testfun(x,y,tally)
+
+cat("Read 2D char array ... ")
+x <- myname
+dim(x) <- length(x)
 y <- var.get.nc(nc, "name")
+tally <- testfun(x,y,tally)
 
-if(sum(y %in% x) == 5) {
-    cat("OK\n")
-    nccount <- nccount + 1
-} else
-    cat("failed\n")
-
-#-- Test 5 (read) --------------------------------------------------------------#
-cat("Test 5 ... ")
-
-x <- c("brav", "char")
+cat("Read 2D char slice ... ")
+x <- substring(myname[2:3],1,4)
+dim(x) <- length(x)
 y <- var.get.nc(nc, "name", c(1,2), c(4,2))
-
-if(sum(y %in% x) == 2) {
-    cat("OK\n")
-    nccount <- nccount + 1
-} else
-    cat("failed\n")
-
-#-- Test 6 (read) --------------------------------------------------------------#
-cat("Test 6 ... ")
-
-x <- c("bravo", "charlie")
+tally <- testfun(x,y,tally)
+
+cat("Read 2D char slice as raw bytes ... ")
+x <- substring(myname[2:3],1,4)
+dim(x) <- length(x)
+x <- apply(x,MARGIN=1,FUN=charToRaw)
+y <- var.get.nc(nc, "name", c(1,2), c(4,2), rawchar=TRUE)
+tally <- testfun(x,y,tally)
+
+cat("Read 2D char slice as characters ... ")
+x <- myname[2:3]
+dim(x) <- length(x)
 y <- var.get.nc(nc, "name", c(1,2), c(NA,2))
-
-if(sum(y %in% x) == 2) {
-    cat("OK\n")
-    nccount <- nccount + 1
-} else
-    cat("failed\n")
-
-#-- Test 7 (read unpacked) -----------------------------------------------------#
-cat("Test 7 ... ")
-
+tally <- testfun(x,y,tally)
+
+cat("Read empty 2D char array ... ")
+x <- character(0)
+dim(x) <- 0
+y <- var.get.nc(nc, "name", NA, c(0,0),collapse=FALSE)
+tally <- testfun(x,y,tally)
+
+cat("Read 1D char slice ... ")
+x <- substring(myqcflag,2,3)
+dim(x) <- 1
+y <- var.get.nc(nc, "qcflag", c(2), c(2))
+tally <- testfun(x,y,tally)
+
+cat("Read scalar char ... ")
+x <- mychar0
+dim(x) <- 1
+y <- var.get.nc(nc, "char0")
+tally <- testfun(x,y,tally)
+
+cat("Read and unpack numeric array ... ")
+x <- mypackvar
+dim(x) <- length(x)
 y <- var.get.nc(nc, "packvar", unpack=TRUE)
-
-if(isTRUE(all.equal(mypackvar, as.vector(y)))) {
-    cat("OK\n")
-    nccount <- nccount + 1
-} else
-    cat("failed\n")
+tally <- testfun(x,y,tally)
 
 #-- Close file -----------------------------------------------------------------#
 close.nc(nc)
@@ -182,13 +215,7 @@ close.nc(nc)
 #  UDUNITS calendar functions                                                   #
 #-------------------------------------------------------------------------------#
 
-#--Initialize ------------------------------------------------------------------#
-cat("Starting UDUNITS tests...\n")
-utcount <- 0
-
-#-- Test 1 (utcal.nc() - numeric values) ---------------------------------------#
-cat("Test 1 ... ")
-
+cat("utcal.nc - numeric values ...")
 x <- matrix(data=c(1899, 1900, 1900, 1900, 1900, 1900,
                      12,    1,    1,    1,    1,    1,
 		     31,    1,    1,    1,    1,    1,
@@ -196,65 +223,36 @@ x <- matrix(data=c(1899, 1900, 1900, 1900, 1900, 1900,
 		      0,    0,    0,    0,    0,    0,
 		      0,    0,    0,    0,    0,    0),
 	    ncol=6)
+colnames(x) <- c("year","month","day","hour","minute","second")
 y <- utcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(0:5))
+tally <- testfun(x,y,tally)
 
-if(sum(y == x) == 36) {
-    cat("OK\n")
-    utcount <- utcount + 1
-} else
-    cat("failed\n")
-
-#-- Test 2 (utcal.nc() - string values) ----------------------------------------#
-cat("Test 2 ... ")
-
+cat("utcal.nc - string values ...")
 x <- c("1899-12-31 23:00:00", "1900-01-01 00:00:00", "1900-01-01 01:00:00",
        "1900-01-01 02:00:00", "1900-01-01 03:00:00", "1900-01-01 04:00:00")
 y <- utcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(0:5), type="s")
+tally <- testfun(x,y,tally)
 
-if(sum(y == x) == 6) {
-    cat("OK\n")
-    utcount <- utcount + 1
-} else
-    cat("failed\n")
-
-#-- Test 3 (utinvcal.nc() - numeric values) ------------------------------------#
-cat("Test 3 ... ")
-
+cat("utinvcal.nc - numeric values ...")
 x <- 6.416667
 y <- utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(1900,1,1,5,25,0))
+tally <- testfun(x,y,tally)
 
-if(round(x, 6) == round(y, 6)) {
-    cat("OK\n")
-    utcount <- utcount + 1
-} else
-    cat("failed\n")
-
-#-- Test 4 (utinvcal.nc() - string values) -------------------------------------#
-cat("Test 4 ... ")
-
+cat("utinvcal.nc - string values ...")
 x <- 6.416667
 y <- utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", "1900-01-01 05:25:00")
-
-if(round(x, 6) == round(y, 6)) {
-    cat("OK\n")
-    utcount <- utcount + 1
-} else
-    cat("failed\n")
-
+tally <- testfun(x,y,tally)
 
 #-------------------------------------------------------------------------------#
 #  Overall summary                                                              #
 #-------------------------------------------------------------------------------#
-cat("Totally ", nccount+utcount, "/ 11 tests passed. ")
-
-if(nccount != 7)
-    stop("Some NetCDF tests failed.", call.=FALSE)
-
-if(utcount != 4)
-    stop("Some UDUNITS tests failed.", call.=FALSE)
-
-cat("Package seems to work properly.\n")
+cat("Summary:", tally["pass"], "pass /", tally["fail"], "fail. ")
 
+if (tally["fail"]==0) {
+  cat("Package seems to work properly.\n")
+} else {
+  cat("Some problems were detected.\n")
+}
 
 #===============================================================================#
 

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



More information about the debian-science-commits mailing list