[r-cran-rnetcdf] 01/06: New upstream version 1.8-2

Sebastian Gibb sgibb-guest at moszumanska.debian.org
Wed Feb 24 17:39:49 UTC 2016


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 974839424c5dd190b87f423daa26e73b96ecf37e
Author: Sebastian Gibb <mail at sebastiangibb.de>
Date:   Wed Feb 24 18:21:04 2016 +0100

    New upstream version 1.8-2
---
 DESCRIPTION          |   12 +-
 INSTALL              |   55 ++-
 LICENSE              |    2 +-
 MD5                  |   71 ++--
 NEWS                 |   66 +++
 R/RNetCDF.R          |   55 ++-
 cleanup              |    6 +-
 configure            | 1121 +++++++++++++++++++++-----------------------------
 configure.ac         |  163 ++++----
 man/00RNetCDF.Rd     |    4 +-
 man/att.copy.nc.Rd   |    2 +-
 man/att.delete.nc.Rd |    2 +-
 man/att.get.nc.Rd    |    2 +-
 man/att.inq.nc.Rd    |    2 +-
 man/att.put.nc.Rd    |    2 +-
 man/att.rename.nc.Rd |    2 +-
 man/close.nc.Rd      |    2 +-
 man/create.nc.Rd     |    2 +-
 man/dim.def.nc.Rd    |    2 +-
 man/dim.inq.nc.Rd    |    2 +-
 man/dim.rename.nc.Rd |    2 +-
 man/file.inq.nc.Rd   |    2 +-
 man/open.nc.Rd       |    2 +-
 man/print.nc.Rd      |    2 +-
 man/read.nc.Rd       |    2 +-
 man/sync.nc.Rd       |    2 +-
 man/utcal.nc.Rd      |    7 +-
 man/utinit.nc.Rd     |    2 +-
 man/utinvcal.nc.Rd   |   11 +-
 man/var.def.nc.Rd    |    2 +-
 man/var.get.nc.Rd    |    2 +-
 man/var.inq.nc.Rd    |    2 +-
 man/var.put.nc.Rd    |    2 +-
 man/var.rename.nc.Rd |    2 +-
 src/Makevars.in      |    3 +-
 src/RNetCDF.c        |   74 ++--
 tests/RNetCDF-test.R |   19 +-
 37 files changed, 808 insertions(+), 905 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 2f654c6..97ab0a7 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
 Package: RNetCDF
-Version: 1.7-3
-Date: 2015-05-09
+Version: 1.8-2
+Date: 2016-02-21
 Title: Interface to NetCDF Datasets
 Author: Pavel Michna, with contributions from Milton Woods
 Maintainer: Milton Woods <mwoods at users.r-forge.r-project.org>
@@ -21,7 +21,7 @@ URL: http://rnetcdf.r-forge.r-project.org
 NeedsCompilation: yes
 Repository: CRAN
 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
+Repository/R-Forge/Revision: 76
+Repository/R-Forge/DateTimeStamp: 2016-02-21 00:07:03
+Date/Publication: 2016-02-21 09:02:40
+Packaged: 2016-02-21 00:25:14 UTC; rforge
diff --git a/INSTALL b/INSTALL
index dbdbd21..057019c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -7,12 +7,10 @@ Software Requirements
 
 NetCDF library version 3.6.0 or greater (64-bit file support).
 
-UDUNITS library either version 1 or 2.1 or greater. RNetCDF uses however
-only the version 1 calendar functions.
+UDUNITS library either version 1 or 2.1 or greater.
 
 If the NetCDF library (version 4) is linked against HDF5, the HDF5 library
-must be included in the search path, optionally with the configure argument
-"--with-hdf5-lib=DIR".
+must be located in the library search path.
 
 If using Fink on Mac OS X, be sure that the corresponding R version (either
 i386 or x86_64) is used (R32 or R64). Compiling with R64 against i386 will
@@ -22,35 +20,60 @@ most likely lead to runtime errors.
 R CMD INSTALL Options
 =====================
 
---with-netcdf-include=DIR    location of netcdf header files
---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-hdf5-lib=DIR          location of hdf5 libraries (if installed)
+Libraries and include files are usually detected automatically by nc-config,
+which is part of most netcdf4 installations. If this causes problems,
+you can disable nc-config using --without-nc-config.
+
+The configure script can accept variables to define extra paths or libraries:
+
+CPPFLAGS='-I<incdir> [-I<incdir> ...]'  extra directories of header files
+LDFLAGS='-L<libdir> [-L<libdir> ...]'   extra directories for libraries
+LIBS='-l<libname> [-l<libname> ...]'    libraries to link
+
+Definitions for the above variables may be appended to the configure command line.
+
+Note that libraries may be specified in LIBS in a few different ways.
+The most common way is '-l<libname>' as shown above, and the compiler will
+typically search for a library called lib<libname>.so and then lib<libname>.a.
+But you can also specify the full pathname of a library if necessary,
+perhaps to force the use of a particular netcdf or udunits library
+on systems with multiple versions available.
 
 
 R CMD INSTALL Example
 =====================
 
-R CMD INSTALL --configure-args="--with-netcdf-include='/sw/include' \
-    --with-netcdf-lib='/sw/lib'" RNetCDF_1.7-3.tar.gz
+R CMD INSTALL --configure-args="CPPFLAGS=-I/sw/include \
+    LDFLAGS=-L/sw/lib LIBS=-lhdf5" RNetCDF_1.8-2.tar.gz
 
 
 LD_LIBRARY_PATH
 ===============
 
-If a runtime error happens, you might need to set or modify the environment
-variable LD_LIBRARY_PATH with the directories where the NetCDF and/or UDUNITS
-and/or HDF5 libraries are located (especially for non-standard installations):
+If a runtime error occurs indicating that shared libraries cannot be found,
+you may need to set or modify the library search path to include directories
+where NetCDF, HDF5 and/or UDUNITS libraries are stored.
+This is sometimes necessary for custom installations of the libraries.
+
+The library search path is typically influenced by the environment variable
+LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH for Mac OSX). For example:
 
 export LD_LIBRARY_PATH=/sw/lib:$LD_LIBRARY_PATH
 
+On some systems, it is possible to build R packages so that dependencies
+are found automatically at runtime. For example, some linkers provide an
+option such as '-rpath', which embeds the library search path when creating
+an executable or shared library. It may also be possible to avoid runtime
+dependencies by building your R package against static libraries (*.a),
+but this will only work if the functions in the libraries were compiled as
+position independent code (e.g. using the -fPIC option of gcc).
+
 
 R CMD check Example
 ===================
 
-R CMD check --install-args="--configure-args='--with-netcdf-include=/sw/include \
---with-netcdf-lib=/sw/lib'" RNetCDF_1.7-3.tar.gz
+R CMD check --install-args="--configure-args='CPPFLAGS=-I/sw/include \
+    LDFLAGS=-L/sw/lib'" RNetCDF_1.8-2.tar.gz
 
 
 Time units
diff --git a/LICENSE b/LICENSE
index 439418a..045923a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,7 +5,7 @@ Where possible individual files also carry brief copyright notices.
 RNetCDF
 =======
 
-All files except those indicated later are Copyright (C) 2004-2015 Pavel Michna.
+All files except those indicated later are Copyright (C) 2004-2016 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
diff --git a/MD5 b/MD5
index d816fff..707ac82 100644
--- a/MD5
+++ b/MD5
@@ -1,14 +1,15 @@
 393a5ca445f6965873eca0259a17f833 *COPYING
-13f5a8694b1bdcc97bdcc50fed9ec01b *DESCRIPTION
-e8c8f32aa6d7601ab109738ea86ef4bd *INSTALL
-7449ab54eea7e97ab5078b92950dfa55 *LICENSE
+567b9853bed1a5c7b6026e33ed32fabc *DESCRIPTION
+d74f5606c28fb76233b0056ac34d03b0 *INSTALL
+309308e661011d5e03c93b9327895273 *LICENSE
 c196fabc79f4cde31798923889f9495d *NAMESPACE
-8f7e1f11f99f691e999750606f86188b *R/RNetCDF.R
+1c7ae10b0cf948f444ae1f34b0505c6e *NEWS
+7c463f6005fa1bf65ab2a3782a10d72c *R/RNetCDF.R
 5716f2b03c6ab9c5014db5d46db9479c *R/load.R.in
 8331e1f8b5432768b1aaeab4778be57e *R/windows/load.R
-f641b8623599777eab63d8a8a8982216 *cleanup
-ca411868d1298966a4f78e9219ab5b1e *configure
-f0d031aa473a988888ec84804d8a28a7 *configure.ac
+2100a41a9be2344b53c15ae81bd84926 *cleanup
+bd0c255d95513da5c648a01c1999e2d8 *configure
+e5584fa0ced5a2c0b75370e8fab32a56 *configure.ac
 d41d8cd98f00b204e9800998ecf8427e *configure.win
 3242b668e27270c8bc626f37b48d1eaa *inst/udunits/udunits.dat
 451f7ff1707652b217043430842876ed *inst/udunits/udunits2-accepted.xml
@@ -17,32 +18,32 @@ d41d8cd98f00b204e9800998ecf8427e *configure.win
 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
-2d87ab789856f540b8344130e30a1705 *man/att.get.nc.Rd
-9b8d9f0552f347ca943ddd2b8dd01a6a *man/att.inq.nc.Rd
-c207e5e2d526acebb98ee1d879ad6cb6 *man/att.put.nc.Rd
-1564c70aaf17d3fcaedb6445c837ed0a *man/att.rename.nc.Rd
-50a388cb939022ea4203a44f40132319 *man/close.nc.Rd
-a3756749f0328ee4a891a8ef66605951 *man/create.nc.Rd
-6915bd4bb0299c165fbe7b179af8647b *man/dim.def.nc.Rd
-91dadf1ff816c253ffb9f44b0061640f *man/dim.inq.nc.Rd
-58b794db3e20e943552c951cc897068b *man/dim.rename.nc.Rd
-699b68ec0e39d4756f94f7bfeeb0c1f2 *man/file.inq.nc.Rd
-a4d96139a394dec8b98393a1ffefbb9a *man/open.nc.Rd
-eeb7dbde829ac75817480d437b6478fd *man/print.nc.Rd
-628aff11f7b4d6b410e1c71a590196ac *man/read.nc.Rd
-a3fc363579eaf8f10d7c0c259e2d2cf8 *man/sync.nc.Rd
-8cea1b6165ba10eafb218fad097dca62 *man/utcal.nc.Rd
-1138b2870cba027f2ab295ead28278d9 *man/utinit.nc.Rd
-986c385caf3aede6376860fdb74fdce4 *man/utinvcal.nc.Rd
-f0cc3ec1390b07c23b03c05eb351b29a *man/var.def.nc.Rd
-c037b40743cf7d12b3b2a97a1736c157 *man/var.get.nc.Rd
-61b92c68a0317e539c0707b64623b04a *man/var.inq.nc.Rd
-7b42a5222379d10f56fec0ae2c50dc4b *man/var.put.nc.Rd
-6e1cd213bcd53b0b68f5ca8473e26683 *man/var.rename.nc.Rd
-7c01c319eb30ec7a18bf81ea1f3732c3 *src/Makevars.in
+4f299a5f770eebee5d592cccc267b096 *man/00RNetCDF.Rd
+fdf5d8328c5161dfbe7d2c5af633992a *man/att.copy.nc.Rd
+453918350fb1c9735222222e3e2c6fc7 *man/att.delete.nc.Rd
+4c63e67ba5bd02c7b5072cfbb5412575 *man/att.get.nc.Rd
+994189f259575c75ef916c8b14dd09a3 *man/att.inq.nc.Rd
+0be798eb2ed1ea603ef7fa7a450f2ae7 *man/att.put.nc.Rd
+927fdb32346b4fdf5197bbb486716491 *man/att.rename.nc.Rd
+42a04bf8b4706de33b63dafc450e3be2 *man/close.nc.Rd
+c2ec5b4641bbf6fc8f4e6a18e871e2f9 *man/create.nc.Rd
+ce12bd36bc0644fc41173154a584956c *man/dim.def.nc.Rd
+a1e2d4c57a019ccaa70d914f1c6a4da9 *man/dim.inq.nc.Rd
+8d3095edec9c4dd483b3adf12a095283 *man/dim.rename.nc.Rd
+eb7e9db09e564019efd421455bb355fd *man/file.inq.nc.Rd
+994234425f6613f728309d40d3e1eebf *man/open.nc.Rd
+ba25d2b16f6f082a23644224c9fd14fa *man/print.nc.Rd
+ced116f185e811ae729d11ef1590bd7f *man/read.nc.Rd
+44d1ce06d4d0840d7fa14efcb2390392 *man/sync.nc.Rd
+04a91171d4af25b4b7737af60343a6c5 *man/utcal.nc.Rd
+6505965f2a1c120e5f980e25d9f66ce7 *man/utinit.nc.Rd
+5c41d44a51bfd90d742189aaa65d6dfb *man/utinvcal.nc.Rd
+1a5a76b85a885a7328c3e04ebb800f48 *man/var.def.nc.Rd
+9bdc7dc3ba0f59d8054729ab682adcfe *man/var.get.nc.Rd
+de4cccce076cbfd6f7345530ee204e9e *man/var.inq.nc.Rd
+0de6f468e5fed8d281369c557e404048 *man/var.put.nc.Rd
+7d884d3b0b720276727beea393069cc5 *man/var.rename.nc.Rd
+6cc969080e30d435ab12eb4cd6b30180 *src/Makevars.in
 9602df250b63fc636c1c6f7a1c6bb8cb *src/Makevars.win
-0438fa61c7cc022875d0729ae157a125 *src/RNetCDF.c
-aedb94602f1d9dec55ac06b2e6cd34a6 *tests/RNetCDF-test.R
+7fa39bbb523b7acdbc231d2c27d32f51 *src/RNetCDF.c
+c8aa1a2c96a3a5b049a7d5a20eead4fa *tests/RNetCDF-test.R
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..7d8e448
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,66 @@
+Version 1.8-2, 2016-02-21
+  * Add support for POSIXct timestamps to utcal.nc and utinvcal.nc.
+  * Use nc-config by default in configure to find netcdf build settings.
+  * Allow customisation of configure by variables CPPFLAGS, LDFLAGS and LIBS,
+    and remove the following options: --with-netcdf-include, --with-netcdf-lib,
+     --with-hdf5-lib, --with-udunits-include, --with-udunits-lib.
+
+Version 1.7-3, 2015-05-09
+  * Support reading/writing NC_CHAR as vectors of raw bytes
+  * Avoid intermediate copies of array data when possible
+  * Fix memory errors reported by valgrind for udunits2 calendar functions.
+  * Support compilation with udunits.h inside a udunits2 sub-directory.
+  * Add udunits data files to source package to ensure they can be found
+    when building binary packages for Windows and Mac.
+
+Version 1.6.3-1, 2014-09-01
+  * Allow reading of character vector or scalar
+
+Version 1.6.2-3, 2014-06-16
+  * Added HDF5 licence file for distribution
+
+Version 1.6.2-2, 2014-05-27
+  * Corrected potential memory leak in read/write of character arrays
+
+Version 1.6.1-2, 2012-07-20
+  * Added function read.nc
+  * Added packing/unpacking of data
+
+Version 1.5.3-1, 2012-02-15
+  * Optionally copy udunits data files during installation of RNetCDF.
+  * When loading RNetCDF in R, initialise udunits with copied data files.
+
+Version 1.5.2-2, 2011-01-06
+  * configure adds tests for extra libraries used by netcdf4 on some systems.
+  * Avoid repeated zeroing of character arrays in C interface.
+
+Version 1.5.0-1, 2010-12-30
+  * Add new modes (large, prefill, share) to nc_open and nc_create.
+  * Avoid unnecessary switching of define and data modes in C library
+    to prevent unwanted data movement within a file.
+  * configure script accepts optional path for hdf5 (for netcdf4 library).
+  * Added basic functional tests of package.
+
+Version 1.2-1.1, 2010-05-11
+  * Add build scripts for Windows.
+
+Version 1.2-1, 2006-07-26
+  * utcal.nc and utinvcal.nc optionally handle dates in string form.
+  * configure script accepts optional paths for netcdf and udunits.
+
+Version 1.1-3, 2005-03-21
+  * Minor bugfix for detection of udunits headers in configure script.
+
+Version 1.1-2, 2005-01-04
+  * Return proper error status in C functions R_nc_sync and R_nc_get_vara_text.
+
+Version 1.1-1, 2004-09-19
+  * Add option to collapse singleton dimensions when reading arrays.
+  * Allow reading of arrays without conversion of missing values.
+
+Version 1.0-4, 2004-09-11
+  * Search extra directories during configure.
+
+Version 1.0-3, 2004-08-01
+  * First release based on netcdf package by Thomas Lumley
+    and ncdf package by David Pierce.
diff --git a/R/RNetCDF.R b/R/RNetCDF.R
index fcc79b7..81cafaa 100644
--- a/R/RNetCDF.R
+++ b/R/RNetCDF.R
@@ -2,7 +2,7 @@
 #										#
 #  Name:       RNetCDF.R							#
 #										#
-#  Version:    1.7-3								#
+#  Version:    1.8-2								#
 #										#
 #  Purpose:    NetCDF interface for R.						#
 #										#
@@ -48,6 +48,7 @@
 #  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          #
+#  mw       24/01/16   Support conversion of timestamps to/from POSIXct         #
 #										#
 #===============================================================================#
 
@@ -1197,32 +1198,38 @@ utcal.nc <- function(unitstring, value, type="n")
     #-- Check args -------------------------------------------------------------#
     stopifnot(is.character(unitstring))
     stopifnot(is.numeric(value) && !any(is.na(value)))
-    stopifnot(type == "n" || type =="s")
+    stopifnot(type == "n" || type =="s" || type == "c" )
     
     count <- length(value)
-    
-    #-- C function call --------------------------------------------------------#
+   
+    #-- C function call to udunits calendar function -----------------------#
     ut <- .Call("R_ut_calendar", 
-		as.character(unitstring), 
+	        as.character(unitstring), 
 		as.integer(count),
 		as.double(value),
 		PACKAGE="RNetCDF")
 
-    #-- Return object if no error ----------------------------------------------#
+    #-- Return object if no error ------------------------------------------#
     if(ut$status == 0) {
-        if(type == "n") {
+	if(type == "n") {
 	    colnames(ut$value) <- c("year", "month", "day", "hour", 
 		"minute", "second")
-            return(ut$value)
-        } else {
+	    return(ut$value)
+	} else if (type == "s") {
 	    x <- apply(ut$value, 1, function(x){paste(x[1],"-",
-	               sprintf("%02g",x[2]),"-",sprintf("%02g",x[3])," ",
+		       sprintf("%02g",x[2]),"-",sprintf("%02g",x[3])," ",
 		       sprintf("%02g",x[4]),":",sprintf("%02g",x[5]),":",
 		       sprintf("%02g",x[6]),sep="")})
 	    return(x)
-	}
-    } else
-        stop(ut$errmsg, call.=FALSE)
+        } else if (type == "c") {
+            ct <- as.POSIXct(
+                        utinvcal.nc("seconds since 1970-01-01 00:00:00 +00:00",ut$value),
+                        tz="UTC", origin=ISOdatetime(1970,1,1,0,0,0,tz="UTC"))
+            return(ct)
+        }
+    } else {
+	stop(ut$errmsg, call.=FALSE)
+    }
 }
 
 
@@ -1249,17 +1256,20 @@ utinvcal.nc <- function(unitstring, value)
 {
     #-- Check args -------------------------------------------------------------#
     stopifnot(is.character(unitstring))
-    
-    if(is.character(value)) {
-	stopifnot(any(nchar(value) == 19))
+
+    if (is.character(value)) {
+	stopifnot(all(nchar(value) == 19))
 	value <- cbind(substr(value,1,4),
-                       substr(value,6,7),
+		       substr(value,6,7),
 		       substr(value,9,10),
 		       substr(value,12,13),
 		       substr(value,15,16),
 		       substr(value,18,19))
 
 	value <- matrix(as.numeric(value),ncol=6)
+    } else if (inherits(value,"POSIXct")) {
+        value <- utcal.nc("seconds since 1970-01-01 00:00:00 +00:00",
+                     as.numeric(value), 'n')
     }
 
     stopifnot(is.numeric(value) && !any(is.na(value)))
@@ -1270,7 +1280,7 @@ utinvcal.nc <- function(unitstring, value)
 	stop("length(value) not divisible by 6", call.=FALSE)
 
     if(is.matrix(value) && ncol(value) != 6) 
-        stop("ncol(value) not 6", call.=FALSE)
+	stop("ncol(value) not 6", call.=FALSE)
     
     #-- C function call --------------------------------------------------------#
     ut <- .Call("R_ut_inv_calendar", 
@@ -1280,10 +1290,11 @@ utinvcal.nc <- function(unitstring, value)
 		PACKAGE="RNetCDF")
 
     #-- Return object if no error ----------------------------------------------#
-    if(ut$status == 0)
-        return(ut$value)
-    else
-        stop(ut$errmsg, call.=FALSE)
+    if(ut$status == 0) {
+	return(ut$value)
+    } else {
+	stop(ut$errmsg, call.=FALSE)
+    }
 }
 
 
diff --git a/cleanup b/cleanup
index de6e978..ddd0ec1 100755
--- a/cleanup
+++ b/cleanup
@@ -1,5 +1,5 @@
 #!/bin/sh
 rm -rf *.cache
-rm -rf ./config.*
-rm -rf ./src/Makevars ./R/load.R
-rm -rf ./src/*.so ./src/*.o
+rm -f ./config.*
+rm -f ./src/Makevars ./R/load.R
+rm -f ./src/*.so ./src/*.o
diff --git a/configure b/configure
index cb42e22..ac66e77 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for RNetCDF 1.7-3.
+# Generated by GNU Autoconf 2.69 for RNetCDF 1.8-2.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='RNetCDF'
 PACKAGE_TARNAME='rnetcdf'
-PACKAGE_VERSION='1.7-3'
-PACKAGE_STRING='RNetCDF 1.7-3'
+PACKAGE_VERSION='1.8-2'
+PACKAGE_STRING='RNetCDF 1.8-2'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -633,6 +633,7 @@ CPPFLAGS
 LDFLAGS
 CFLAGS
 CC
+have_nc_config
 target_alias
 host_alias
 build_alias
@@ -674,11 +675,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
-with_netcdf_include
-with_netcdf_lib
-with_hdf5_lib
-with_udunits_include
-with_udunits_lib
+with_nc_config
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1229,7 +1226,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.7-3 to adapt to many kinds of systems.
+\`configure' configures RNetCDF 1.8-2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1290,20 +1287,14 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of RNetCDF 1.7-3:";;
+     short | recursive ) echo "Configuration of RNetCDF 1.8-2:";;
    esac
   cat <<\_ACEOF
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-netcdf-include=DIR
-                          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
-                          directory with udunits header files
-  --with-udunits-lib=DIR  directory with udunits libraries
+  --without-nc-config     do not use nc-config to get netcdf configuration
 
 Some influential environment variables:
   CC          C compiler command
@@ -1381,7 +1372,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-RNetCDF configure 1.7-3
+RNetCDF configure 1.8-2
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1433,52 +1424,6 @@ fi
 
 } # ac_fn_c_try_compile
 
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
 # ac_fn_c_try_cpp LINENO
 # ----------------------
 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1675,11 +1620,57 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
 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.7-3, which was
+It was created by RNetCDF $as_me 1.8-2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2028,64 +2019,75 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-
 #-------------------------------------------------------------------------------#
-#  Optional include paths for NetCDF and/or UDUNITS libraries    		#
+#  Find the compiler and compiler options to use   	                 	#
 #-------------------------------------------------------------------------------#
 
-#-- NetCDF include and library path --------------------------------------------#
-
-# Check whether --with-netcdf-include was given.
-if test "${with_netcdf_include+set}" = set; then :
-  withval=$with_netcdf_include; CPPFLAGS="-I${withval} ${CPPFLAGS}"
+: ${R_HOME=`R RHOME`}
+if test -z "${R_HOME}"; then
+  echo "could not determine R_HOME"
+  exit 1
 fi
+CC=`"${R_HOME}/bin/R" CMD config CC`
+CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
+R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
+CPPFLAGS="$CPPFLAGS $R_CPPFLAGS"
 
+#-------------------------------------------------------------------------------#
+#  Find NetCDF library and header files                                         #
+#-------------------------------------------------------------------------------#
 
 
-# Check whether --with-netcdf-lib was given.
-if test "${with_netcdf_lib+set}" = set; then :
-  withval=$with_netcdf_lib; LDFLAGS="-L${withval} ${LDFLAGS}"
+# Check whether --with-nc-config was given.
+if test "${with_nc_config+set}" = set; then :
+  withval=$with_nc_config;
+else
+  with_nc_config=yes
 fi
 
 
-#-- Optional include path for HDF5 ---------------------------------------------#
+if test "x$with_nc_config" != xno; then :
+  # Extract the first word of "nc-config", so it can be a program name with args.
+set dummy nc-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_have_nc_config+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$have_nc_config"; then
+  ac_cv_prog_have_nc_config="$have_nc_config" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_have_nc_config="yes"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-# Check whether --with-hdf5-lib was given.
-if test "${with_hdf5_lib+set}" = set; then :
-  withval=$with_hdf5_lib; LDFLAGS="-L${withval} ${LDFLAGS}"
+  test -z "$ac_cv_prog_have_nc_config" && ac_cv_prog_have_nc_config="no"
 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; CPPFLAGS="-I${withval} ${CPPFLAGS}"
 fi
-
-
-
-# Check whether --with-udunits-lib was given.
-if test "${with_udunits_lib+set}" = set; then :
-  withval=$with_udunits_lib; LDFLAGS="-L${withval} ${LDFLAGS}"
+have_nc_config=$ac_cv_prog_have_nc_config
+if test -n "$have_nc_config"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_nc_config" >&5
+$as_echo "$have_nc_config" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
-#-------------------------------------------------------------------------------#
-#  Find the compiler and compiler options to use   	                 	#
-#-------------------------------------------------------------------------------#
 
-: ${R_HOME=`R RHOME`}
-if test -z "${R_HOME}"; then
-    echo "Could not determine R_HOME"
-    exit 1
 fi
-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'
@@ -2802,557 +2804,79 @@ static char *e (p, i)
 }
 static char *f (char * (*g) (char **, int), char **p, ...)
 {
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $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="-lm  $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 cos ();
-int
-main ()
-{
-return cos ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_m_cos=yes
-else
-  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_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_LIBM 1
-_ACEOF
-
-  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.  */
-
-/* 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="-lz  $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 deflate ();
-int
-main ()
-{
-return deflate ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_z_deflate=yes
-else
-  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_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
-  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
-
-  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 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="-lhdf5  $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 H5open ();
-int
-main ()
-{
-return H5open ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_hdf5_H5open=yes
-else
-  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_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_LIBHDF5 1
-_ACEOF
-
-  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
-  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
-
-  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  $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 utScan ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_udunits2_utScan=yes
-else
-  ac_cv_lib_udunits2_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_udunits2_utScan" >&5
-$as_echo "$ac_cv_lib_udunits2_utScan" >&6; }
-if test "x$ac_cv_lib_udunits2_utScan" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUDUNITS2 1
-_ACEOF
-
-  LIBS="-ludunits2 $LIBS"
-
-else
-  have_udunits2=no
-fi
-
-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
-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 utScan ();
-  ;
-  return 0;
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
 }
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_udunits_utScan=yes
-else
-  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_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
-
-  LIBS="-ludunits $LIBS"
-
-else
-  have_udunits1=no
-fi
 
-    if test "$have_udunits1" == yes ; then
-        UDUNITS_LIB=udunits
-        UDUNITS_DBFILE=udunits.dat
-        UDUNITS_DBVAR="UDUNITS_PATH"
-    else
-        as_fn_error $? "\"neither udunits2 nor udunits library was found\"" "$LINENO" 5
-    fi
-fi
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
 
-# 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.  */
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
 
-/* 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 test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
 int
 main ()
 {
-return nc_open ();
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
   ;
   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
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
 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
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
 
-  LIBS="-lnetcdf $LIBS"
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
 
-else
-  as_fn_error $? "\"netcdf library not found\"" "$LINENO" 5
 fi
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-#-- Check for netcdf.h and udunits.h -------------------------------------------#
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -3751,7 +3275,26 @@ fi
 done
 
 
-for ac_header in netcdf.h
+if test "x$have_nc_config" == xyes; then :
+
+    # Find libraries and cflags used to build netcdf:
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf linker flags" >&5
+$as_echo_n "checking netcdf linker flags... " >&6; }
+    NETCDF_LIBS=`nc-config --libs`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NETCDF_LIBS" >&5
+$as_echo "$NETCDF_LIBS" >&6; }
+    LDFLAGS="$NETCDF_LIBS $LDFLAGS"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking netcdf pre-processor and compiler flags" >&5
+$as_echo_n "checking netcdf pre-processor and compiler flags... " >&6; }
+    NETCDF_CFLAGS=`nc-config --cflags`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NETCDF_CFLAGS" >&5
+$as_echo "$NETCDF_CFLAGS" >&6; }
+    CPPFLAGS="$NETCDF_CFLAGS $CPPFLAGS"
+
+else
+
+    # Check that netcdf header files can be compiled:
+    for ac_header in netcdf.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "netcdf.h" "ac_cv_header_netcdf_h" "$ac_includes_default"
 if test "x$ac_cv_header_netcdf_h" = xyes; then :
@@ -3760,55 +3303,311 @@ 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.h was not compiled - defining CPPFLAGS may help\"" "$LINENO" 5
 fi
 
 done
 
+    # Add netcdf library to LIBS if it can be linked (and is not already being linked):
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing nc_open" >&5
+$as_echo_n "checking for library containing nc_open... " >&6; }
+if ${ac_cv_search_nc_open+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.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
+/* 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
+for ac_lib in '' netcdf; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_nc_open=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_nc_open+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_nc_open+:} false; then :
 
 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
+  ac_cv_search_nc_open=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_nc_open" >&5
+$as_echo "$ac_cv_search_nc_open" >&6; }
+ac_res=$ac_cv_search_nc_open
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+  as_fn_error $? "\"netcdf library was not linked - defining LDFLAGS may help\"" "$LINENO" 5
+fi
+
+
+
+fi
+
+#-------------------------------------------------------------------------------#
+#  Find UDUNITS library and header files                                        #
+#-------------------------------------------------------------------------------#
+
+# If the expat library is available, prepend it to LIBS
+# so that udunits2 can be linked if it is installed.
+# If udunits2 contains its own expat functions,
+# these will be used in preference to the external library.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing XML_StopParser" >&5
+$as_echo_n "checking for library containing XML_StopParser... " >&6; }
+if ${ac_cv_search_XML_StopParser+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$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_StopParser ();
+int
+main ()
+{
+return XML_StopParser ();
+  ;
+  return 0;
+}
 _ACEOF
+for ac_lib in '' expat; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_XML_StopParser=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_XML_StopParser+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_XML_StopParser+:} false; then :
 
 else
-  as_fn_error $? "\"udunits2 headers not found\"" "$LINENO" 5
+  ac_cv_search_XML_StopParser=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_XML_StopParser" >&5
+$as_echo "$ac_cv_search_XML_StopParser" >&6; }
+ac_res=$ac_cv_search_XML_StopParser
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
 fi
 
+
+# Identify available version of udunits library (1 or 2),
+# and prepend the library to LIBS if it is not already linked.
+# Also check for udunits.h in places that depend on the udunits version,
+# and define macro HAVE_UDUNITS_H or HAVE_UDUNITS2_UDUNITS_H accordingly.
+udunits=0
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing utFree" >&5
+$as_echo_n "checking for library containing utFree... " >&6; }
+if ${ac_cv_search_utFree+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$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 utFree ();
+int
+main ()
+{
+return utFree ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' udunits2; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_utFree=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_utFree+:} false; then :
+  break
+fi
 done
+if ${ac_cv_search_utFree+:} false; then :
+
+else
+  ac_cv_search_utFree=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_utFree" >&5
+$as_echo "$ac_cv_search_utFree" >&6; }
+ac_res=$ac_cv_search_utFree
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
+    for ac_header in udunits2/udunits.h udunits.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ udunits=2; break
 fi
 
 done
 
+
+else
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing utScan" >&5
+$as_echo_n "checking for library containing utScan... " >&6; }
+if ${ac_cv_search_utScan+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$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 utScan ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' udunits; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_utScan=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_utScan+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_utScan+:} false; then :
+
 else
-  for ac_header in udunits.h
+  ac_cv_search_utScan=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_utScan" >&5
+$as_echo "$ac_cv_search_utScan" >&6; }
+ac_res=$ac_cv_search_utScan
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+        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
-
-else
-  as_fn_error $? "\"udunits headers not found\"" "$LINENO" 5
+ udunits=1; break
 fi
 
 done
 
+
+
+fi
+
+
+
+fi
+
+
+# Define variables UDUNITS_LIB, UDUNITS_DBFILE and UDUNITS_DBVAR,
+# based on the version of udunits detected above.
+# Also define preprocessor macro HAVE_LIBUDUNITS or HAVE_LIBUDUNITS2.
+if test $udunits == 2; then :
+
+    UDUNITS_LIB=udunits2
+    UDUNITS_DBFILE=udunits2.xml
+    UDUNITS_DBVAR="UDUNITS2_XML_PATH"
+    $as_echo "#define HAVE_LIBUDUNITS2 1" >>confdefs.h
+
+
+elif test $udunits == 1; then :
+
+    UDUNITS_LIB=udunits
+    UDUNITS_DBFILE=udunits.dat
+    UDUNITS_DBVAR="UDUNITS_PATH"
+    $as_echo "#define HAVE_LIBUDUNITS 1" >>confdefs.h
+
+
+else
+  as_fn_error $? "\"unable to use udunits2 or udunits\"" "$LINENO" 5
+
 fi
 
 #-------------------------------------------------------------------------------#
@@ -4362,7 +4161,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by RNetCDF $as_me 1.7-3, which was
+This file was extended by RNetCDF $as_me 1.8-2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4415,7 +4214,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-RNetCDF config.status 1.7-3
+RNetCDF config.status 1.8-2
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -4978,4 +4777,6 @@ fi
 
 
 #-------------------------------------------------------------------------------#
+#  Done                                                                         #
+#-------------------------------------------------------------------------------#
 
diff --git a/configure.ac b/configure.ac
index 2d69bbe..c454cc0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,40 +2,7 @@
 #  Initialize                                                    		#
 #-------------------------------------------------------------------------------#
 
-AC_INIT([RNetCDF], 1.7-3)
-
-
-#-------------------------------------------------------------------------------#
-#  Optional include paths for NetCDF and/or UDUNITS libraries    		#
-#-------------------------------------------------------------------------------#
-
-#-- NetCDF include and library path --------------------------------------------#
-AC_ARG_WITH([netcdf-include],
-    AC_HELP_STRING([--with-netcdf-include=DIR],
-                   [directory with netcdf header files]),
-    [CPPFLAGS="-I${withval} ${CPPFLAGS}"])
-
-AC_ARG_WITH([netcdf-lib],
-    AC_HELP_STRING([--with-netcdf-lib=DIR],
-                   [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],
-                   [directory with udunits header files]),
-    [CPPFLAGS="-I${withval} ${CPPFLAGS}"])
-
-AC_ARG_WITH([udunits-lib],
-    AC_HELP_STRING([--with-udunits-lib=DIR],
-                   [directory with udunits libraries]),
-    [LDFLAGS="-L${withval} ${LDFLAGS}"])
+AC_INIT([RNetCDF], [1.8-2])
 
 #-------------------------------------------------------------------------------#
 #  Find the compiler and compiler options to use   	                 	#
@@ -43,57 +10,95 @@ AC_ARG_WITH([udunits-lib],
 
 : ${R_HOME=`R RHOME`}
 if test -z "${R_HOME}"; then
-    echo "Could not determine R_HOME"
-    exit 1
+  echo "could not determine R_HOME"
+  exit 1
 fi
-CC=`${R_HOME}/bin/R CMD config CC`
-CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
+CC=`"${R_HOME}/bin/R" CMD config CC`
+CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
+R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
+CPPFLAGS="$CPPFLAGS $R_CPPFLAGS"
 
-#-- Check for NetCDF and UDUNITS library ---------------------------------------#
+#-------------------------------------------------------------------------------#
+#  Find NetCDF library and header files                                         #
+#-------------------------------------------------------------------------------#
 
-# 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)
+AC_ARG_WITH([nc-config],
+    AS_HELP_STRING([--without-nc-config],
+        [do not use nc-config to get netcdf configuration]),
+    [],
+    [with_nc_config=yes])
+
+AS_IF([test "x$with_nc_config" != xno],
+      [AC_CHECK_PROG(have_nc_config, nc-config, yes, no, [], [])]
+)
+
+AS_IF([test "x$have_nc_config" == xyes],
+  [
+    # Find libraries and cflags used to build netcdf:
+    AC_MSG_CHECKING(netcdf linker flags)
+    NETCDF_LIBS=`nc-config --libs`
+    AC_MSG_RESULT($NETCDF_LIBS)
+    LDFLAGS="$NETCDF_LIBS $LDFLAGS"
+    AC_MSG_CHECKING(netcdf pre-processor and compiler flags)
+    NETCDF_CFLAGS=`nc-config --cflags`
+    AC_MSG_RESULT($NETCDF_CFLAGS)
+    CPPFLAGS="$NETCDF_CFLAGS $CPPFLAGS"
+  ], [
+    # Check that netcdf header files can be compiled:
+    AC_CHECK_HEADERS(netcdf.h, [],
+       AC_MSG_ERROR("netcdf.h was not compiled - defining CPPFLAGS may help"))
+    # Add netcdf library to LIBS if it can be linked (and is not already being linked):
+    AC_SEARCH_LIBS(nc_open, netcdf, [],
+        AC_MSG_ERROR("netcdf library was not linked - defining LDFLAGS may help"))
+  ]
+)
 
-# Test udunits2 then udunits library:
-have_udunits2="yes"
-AC_CHECK_LIB(udunits2, utScan, [], [have_udunits2=no])
-if test "$have_udunits2" == yes; then
+#-------------------------------------------------------------------------------#
+#  Find UDUNITS library and header files                                        #
+#-------------------------------------------------------------------------------#
+
+# If the expat library is available, prepend it to LIBS
+# so that udunits2 can be linked if it is installed.
+# If udunits2 contains its own expat functions,
+# these will be used in preference to the external library.
+AC_SEARCH_LIBS(XML_StopParser, expat)
+
+# Identify available version of udunits library (1 or 2),
+# and prepend the library to LIBS if it is not already linked.
+# Also check for udunits.h in places that depend on the udunits version,
+# and define macro HAVE_UDUNITS_H or HAVE_UDUNITS2_UDUNITS_H accordingly.
+udunits=0
+AC_SEARCH_LIBS(utFree, udunits2,
+  [
+    AC_CHECK_HEADERS(udunits2/udunits.h udunits.h, [udunits=2; break])
+  ], [
+    AC_SEARCH_LIBS(utScan, udunits,
+      [
+        AC_CHECK_HEADERS(udunits.h, [udunits=1; break])
+      ]
+    )
+  ]
+)
+
+# Define variables UDUNITS_LIB, UDUNITS_DBFILE and UDUNITS_DBVAR,
+# based on the version of udunits detected above.
+# Also define preprocessor macro HAVE_LIBUDUNITS or HAVE_LIBUDUNITS2.
+AS_IF([test $udunits == 2],
+  [
     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
-        AC_MSG_ERROR("neither udunits2 nor udunits library was found")
-    fi
-fi
-
-# Test netcdf library:
-AC_CHECK_LIB(netcdf, nc_open, [],
-    AC_MSG_ERROR("netcdf library not found"))
-
-#-- Check for netcdf.h and udunits.h -------------------------------------------#
-
-AC_CHECK_HEADERS(netcdf.h, [], AC_MSG_ERROR("netcdf header netcdf.h not found"))
-
-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
+    AC_DEFINE(HAVE_LIBUDUNITS2)
+  ],
+  [test $udunits == 1],
+  [
+    UDUNITS_LIB=udunits
+    UDUNITS_DBFILE=udunits.dat
+    UDUNITS_DBVAR="UDUNITS_PATH"
+    AC_DEFINE(HAVE_LIBUDUNITS)
+  ],
+  [AC_MSG_ERROR("unable to use udunits2 or udunits")]
+)
 
 #-------------------------------------------------------------------------------#
 #  Do substitution                               	                 	#
@@ -106,4 +111,6 @@ AC_OUTPUT(R/load.R
           src/Makevars)
 
 #-------------------------------------------------------------------------------#
+#  Done                                                                         #
+#-------------------------------------------------------------------------------#
 
diff --git a/man/00RNetCDF.Rd b/man/00RNetCDF.Rd
index dec6fb3..0db9853 100644
--- a/man/00RNetCDF.Rd
+++ b/man/00RNetCDF.Rd
@@ -28,9 +28,9 @@ A high-level interface based on this library is the \code{ncvar} package by Juer
 }
 
 \references{
-  \url{http://www.unidata.ucar.edu/packages/netcdf/}
+  \url{http://www.unidata.ucar.edu/software/netcdf/}
   
-  \url{http://www.unidata.ucar.edu/packages/udunits/}
+  \url{http://www.unidata.ucar.edu/software/udunits/}
 }
 
 \note{The NetCDF and the UDUNITS library must be already installed on the system.}
diff --git a/man/att.copy.nc.Rd b/man/att.copy.nc.Rd
index e6c9819..fc7fed7 100644
--- a/man/att.copy.nc.Rd
+++ b/man/att.copy.nc.Rd
@@ -18,7 +18,7 @@
 
 \details{This function copies an attribute from one open NetCDF dataset to another. It can also be used to copy an attribute from one variable to another within the same NetCDF dataset.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/att.delete.nc.Rd b/man/att.delete.nc.Rd
index c10b7dc..b654557 100644
--- a/man/att.delete.nc.Rd
+++ b/man/att.delete.nc.Rd
@@ -16,7 +16,7 @@
 
 \details{This function deletes a NetCDF attribute from a NetCDF dataset open for writing.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/att.get.nc.Rd b/man/att.get.nc.Rd
index db50d9b..260804a 100644
--- a/man/att.get.nc.Rd
+++ b/man/att.get.nc.Rd
@@ -18,7 +18,7 @@
 
 \value{A vector of type \code{character} if the on-disk type is \code{NC_CHAR}, otherwise \code{numeric}. No distinction is made between the different storage types of numeric objects.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \note{\code{NC_BYTE} is always interpreted as signed.}
 
diff --git a/man/att.inq.nc.Rd b/man/att.inq.nc.Rd
index b5283af..5dfda4c 100644
--- a/man/att.inq.nc.Rd
+++ b/man/att.inq.nc.Rd
@@ -26,7 +26,7 @@
   \item{length}{Length of this attribute.}
 }
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/att.put.nc.Rd b/man/att.put.nc.Rd
index e2eb44d..65c5de7 100644
--- a/man/att.put.nc.Rd
+++ b/man/att.put.nc.Rd
@@ -18,7 +18,7 @@
 
 \details{Names commencing with underscore ("\code{_}") are reserved for use by the NetCDF library. Most generic applications that process NetCDF datasets assume standard attribute conventions and it is strongly recommended that these be followed unless there are good reasons for not doing so.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \note{\code{NC_BYTE} is always interpreted as signed.}
 
diff --git a/man/att.rename.nc.Rd b/man/att.rename.nc.Rd
index 97d94c7..c42b200 100644
--- a/man/att.rename.nc.Rd
+++ b/man/att.rename.nc.Rd
@@ -17,7 +17,7 @@
 
 \details{This function changes the name of an existing attribute in a NetCDF dataset open for writing. An attribute cannot be renamed to have the same name as another attribute of the same variable.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/close.nc.Rd b/man/close.nc.Rd
index 669f36a..acb57c7 100644
--- a/man/close.nc.Rd
+++ b/man/close.nc.Rd
@@ -15,7 +15,7 @@
 
 \details{This function closes an open NetCDF dataset. After an open NetCDF dataset is closed, its NetCDF ID may be reassigned to the next NetCDF dataset that is opened or created. Therefore, the passed object (\code{ncfile}) should be deleted by the user after calling this function.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/create.nc.Rd b/man/create.nc.Rd
index 6d836f4..bdd282a 100644
--- a/man/create.nc.Rd
+++ b/man/create.nc.Rd
@@ -20,7 +20,7 @@
 
 \value{Object of class "\code{NetCDF}" which points to the NetCDF dataset.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna, Milton Woods}
 
diff --git a/man/dim.def.nc.Rd b/man/dim.def.nc.Rd
index 6c0d037..1f2228f 100644
--- a/man/dim.def.nc.Rd
+++ b/man/dim.def.nc.Rd
@@ -17,7 +17,7 @@
 
 \details{This function creates a new NetCDF dimension. There is a suggested limit (100) to the number of dimensions. Ordinarily, the name and length of a dimension are fixed when the dimension is first defined. The name may be changed later, but the length of a dimension (other than the unlimited dimension) cannot be changed without copying all the data to a new NetCDF dataset with a redefined dimension length. A NetCDF dimension in an open NetCDF dataset is referred to by a small intege [...]
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/dim.inq.nc.Rd b/man/dim.inq.nc.Rd
index 9362f7e..89b0af6 100644
--- a/man/dim.inq.nc.Rd
+++ b/man/dim.inq.nc.Rd
@@ -23,7 +23,7 @@
   \item{unlim}{\code{TRUE} if it is the unlimited dimension, \code{FALSE} otherwise.} 
 }
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/dim.rename.nc.Rd b/man/dim.rename.nc.Rd
index 357625e..21bed94 100644
--- a/man/dim.rename.nc.Rd
+++ b/man/dim.rename.nc.Rd
@@ -16,7 +16,7 @@
 
 \details{This function renames an existing dimension in a NetCDF dataset open for writing. A dimension cannot be renamed to have the same name as another dimension.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/file.inq.nc.Rd b/man/file.inq.nc.Rd
index bd65485..ea8bbe3 100644
--- a/man/file.inq.nc.Rd
+++ b/man/file.inq.nc.Rd
@@ -22,7 +22,7 @@
   \item{unlimdimid}{ID of the unlimited dimension, if there is one for this NetCDF dataset. Otherwise \code{NA} will be returned.} 
 }
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/open.nc.Rd b/man/open.nc.Rd
index 5f58038..50dbbd9 100644
--- a/man/open.nc.Rd
+++ b/man/open.nc.Rd
@@ -22,7 +22,7 @@
 
 \value{Object of class "\code{NetCDF}" which points to the NetCDF dataset.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna, Milton Woods}
 
diff --git a/man/print.nc.Rd b/man/print.nc.Rd
index f96960f..2768cae 100644
--- a/man/print.nc.Rd
+++ b/man/print.nc.Rd
@@ -18,7 +18,7 @@
 The output of this function is almost identical with a \code{"ncdump -h"} call. Because arrays in R have their leftmost subscript varying fastest, the fastest varying dimensions are printed first.
 }
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/read.nc.Rd b/man/read.nc.Rd
index afe8913..94a92b6 100644
--- a/man/read.nc.Rd
+++ b/man/read.nc.Rd
@@ -22,7 +22,7 @@ Packed variables can optionally be returned in an unpacked state (see \code{\lin
 
 \value{A list with the list elements containing the variable data of the NetCDF dataset.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna, Milton Woods}
 
diff --git a/man/sync.nc.Rd b/man/sync.nc.Rd
index 7d4064b..d956a02 100644
--- a/man/sync.nc.Rd
+++ b/man/sync.nc.Rd
@@ -14,7 +14,7 @@
 
 \details{This function offers a way to synchronize the disk copy of a NetCDF dataset with in-memory buffers. There are two reasons one might want to synchronize after writes: To minimize data loss in case of abnormal termination, or to make data available to other processes for reading immediately after it is written.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/utcal.nc.Rd b/man/utcal.nc.Rd
index a73daa9..9f05c94 100644
--- a/man/utcal.nc.Rd
+++ b/man/utcal.nc.Rd
@@ -11,16 +11,16 @@
 \arguments{
   \item{unitstring}{A temporal unit with an origin (e.g., ``days since 1900-01-01'').}
   \item{value}{An amount (quantity) of the given temporal unit.}
-  \item{type}{Character string which determines the output type. Can be either \code{n} for numeric or \code{s} for output in string form.}
+  \item{type}{Character string which determines the output type. Can be \code{n} for numeric, \code{s} for string or \code{c} for POSIXct output.}
 }
 
 \details{Converts the amount, \code{value}, of the temporal unit, \code{unitstring}, into a UTC-referenced date and time.
        
 The UDUNITS package uses a mixed Gregorian/Julian calendar system. Dates prior to 1582-10-15 are assumed to use the Julian calendar, which was introduced by Julius Caesar in 46 BCE and is based on a year that is exactly 365.25 days long. Dates on and after 1582-10-15 are assumed to use the Gregorian calendar, which was introduced on that date and is based on a year that is exactly 365.2425 days long. (A year is actually approximately 365.242198781 days long.) Seemingly strange behavior o [...]
 
-\value{If the output type is set to numeric, a matrix containing the corresponding date(s) and time(s), with the following columns: year, month, day, hour, minute, second. Otherwise a vector of strings in the form \code{"YYYY-MM-DD hh:mm:ss"}.}
+\value{If the output type is set to numeric, result is a matrix containing the corresponding date(s) and time(s), with the following columns: year, month, day, hour, minute, second. If the output type is string, result is a vector of strings in the form \code{"YYYY-MM-DD hh:mm:ss"}. Otherwise result is a vector of POSIXct values.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/udunits/}}
+\references{\url{http://www.unidata.ucar.edu/software/udunits/}}
 
 \author{Pavel Michna}
 
@@ -28,6 +28,7 @@ The UDUNITS package uses a mixed Gregorian/Julian calendar system. Dates prior t
 ##  Convert units to UTC referenced time
 utcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(0:5))
 utcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(0:5), type="s")
+utcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(0:5), type="c")
 }
 
 \keyword{utilities}
diff --git a/man/utinit.nc.Rd b/man/utinit.nc.Rd
index 496a888..4464016 100644
--- a/man/utinit.nc.Rd
+++ b/man/utinit.nc.Rd
@@ -17,7 +17,7 @@
 If path is non-NULL and not empty, then it specifies a units file containing initializing unit definitions; otherwise, the environment variable \code{UDUNITS_PATH} is checked and, if it exists and is not empty, then it is assumed to contain the pathname of the units file; otherwise, a compile-time default pathname is used.      
 }
 
-\references{\url{http://www.unidata.ucar.edu/packages/udunits/}}
+\references{\url{http://www.unidata.ucar.edu/software/udunits/}}
 
 \author{Pavel Michna}
 
diff --git a/man/utinvcal.nc.Rd b/man/utinvcal.nc.Rd
index e0cabe0..9e30a46 100644
--- a/man/utinvcal.nc.Rd
+++ b/man/utinvcal.nc.Rd
@@ -10,18 +10,20 @@
 
 \arguments{
   \item{unitstring}{A temporal unit with an origin (e.g., ``days since 1900-01-01'').}
-  \item{value}{A vector or a matrix containing the dates to convert. Each row must contain year, month, day, hour, minute and second.}
+  \item{value}{Dates to convert as a numeric vector or array, or a vector of strings or POSIXct values.}
 }
 
-\value{A vector containing the amount(s) of the temporal unit(s) that the date(s) correspond(s) to.}
+\value{A vector containing the amount(s) of the temporal unit(s) corresponding to the given date(s).}
 
 \details{Converts a UTC-referenced date and time into the amount, \code{value}, of the temporal unit, \code{unitstring}.
        
 The UDUNITS package uses a mixed Gregorian/Julian calendar system. Dates prior to 1582-10-15 are assumed to use the Julian calendar, which was introduced by Julius Caesar in 46 BCE and is based on a year that is exactly 365.25 days long. Dates on and after 1582-10-15 are assumed to use the Gregorian calendar, which was introduced on that date and is based on a year that is exactly 365.2425 days long. (A year is actually approximately 365.242198781 days long.) Seemingly strange behavior o [...]
 
-If the dates are given in string form, the structure must be exactly \code{"YYYY-MM-DD hh:mm:ss"}.}
+If the dates are given in string form, the structure must be exactly \code{"YYYY-MM-DD hh:mm:ss"}.
 
-\references{\url{http://www.unidata.ucar.edu/packages/udunits/}}
+A vector of POSIXct values is also accepted as input. These are converted to the specified units by a linear transformation, without an intermediate separation into date components.}
+
+\references{\url{http://www.unidata.ucar.edu/software/udunits/}}
 
 \author{Pavel Michna}
 
@@ -29,6 +31,7 @@ If the dates are given in string form, the structure must be exactly \code{"YYYY
 ##  Convert UTC referenced time to other time units
 utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(1900,1,1,5,25,0))
 utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", "1900-01-01 05:25:00")
+utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", ISOdatetime(1900,1,1,5,25,0,tz="UTC"))
 }
 
 \keyword{utilities}
diff --git a/man/var.def.nc.Rd b/man/var.def.nc.Rd
index 73fcfc8..c036830 100644
--- a/man/var.def.nc.Rd
+++ b/man/var.def.nc.Rd
@@ -23,7 +23,7 @@ A NetCDF variable in an open NetCDF dataset is referred to by a small integer ca
 
 Attributes may be associated with a variable to specify such properties as units.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/var.get.nc.Rd b/man/var.get.nc.Rd
index 3cc93b1..191cefe 100644
--- a/man/var.get.nc.Rd
+++ b/man/var.get.nc.Rd
@@ -38,7 +38,7 @@ The dimension order in the R array is reversed relative to the order reported by
 
 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/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \note{\code{NC_BYTE} is always interpreted as signed.}
 
diff --git a/man/var.inq.nc.Rd b/man/var.inq.nc.Rd
index 739d1a6..a42cda2 100644
--- a/man/var.inq.nc.Rd
+++ b/man/var.inq.nc.Rd
@@ -25,7 +25,7 @@
   \item{natts}{Number of variable attributes assigned to this variable.}
 }
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/man/var.put.nc.Rd b/man/var.put.nc.Rd
index 6301f12..54a3168 100644
--- a/man/var.put.nc.Rd
+++ b/man/var.put.nc.Rd
@@ -30,7 +30,7 @@ Data in a NetCDF file is conceived as being a multi-dimensional array. The numbe
 
 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).}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \note{\code{NC_BYTE} is always interpreted as signed. For best performance, it is recommended that the definition of dimensions, variables and attributes is completed before variables are read or written.}
 
diff --git a/man/var.rename.nc.Rd b/man/var.rename.nc.Rd
index 7755de9..ec503f1 100644
--- a/man/var.rename.nc.Rd
+++ b/man/var.rename.nc.Rd
@@ -16,7 +16,7 @@
 
 \details{This function renames an existing variable in a NetCDF dataset open for writing. A variable cannot be renamed to have the same name as another variable.}
 
-\references{\url{http://www.unidata.ucar.edu/packages/netcdf/}}
+\references{\url{http://www.unidata.ucar.edu/software/netcdf/}}
 
 \author{Pavel Michna}
 
diff --git a/src/Makevars.in b/src/Makevars.in
index d341952..94379c0 100644
--- a/src/Makevars.in
+++ b/src/Makevars.in
@@ -1,4 +1,3 @@
 PKG_CPPFLAGS = @DEFS@ @CPPFLAGS@
-PKG_LDFLAGS = @LDFLAGS@
-PKG_LIBS = @LIBS@
+PKG_LIBS = @LDFLAGS@ @LIBS@
 
diff --git a/src/RNetCDF.c b/src/RNetCDF.c
index 15769dd..734fdb9 100644
--- a/src/RNetCDF.c
+++ b/src/RNetCDF.c
@@ -2,7 +2,7 @@
  *									       *
  *  Name:       RNetCDF.c						       *
  *									       *
- *  Version:    1.7-3							       *
+ *  Version:    1.8-2							       *
  *									       *
  *  Purpose:    NetCDF interface for R.					       *
  *									       *
@@ -57,6 +57,7 @@
  *  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.    *
+ *  mw       26/01/16   Fix memory leak from abnormal exit of calendar funcs.  *
  *									       *
 \*=============================================================================*/
 
@@ -1752,30 +1753,18 @@ SEXP R_ut_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
 
     status = utScan(CHAR(STRING_ELT(unitstring, 0)), &utunit);
     if(status != 0) {
-        R_ut_strerror(status, strerror);
-        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
-        REAL(VECTOR_ELT(retlist, 0))[0] = status;
-	UNPROTECT(2);
-	return(retlist);        
+        goto cleanup;
     }
   
     /*-- Check if unit is time and has origin ---------------------------------*/
-    status = utIsTime(&utunit);    
-    if(status == 0) {
-        R_ut_strerror(UT_ENOTTIME, strerror);
-        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
-	REAL(VECTOR_ELT(retlist, 0))[0] = UT_ENOTTIME;
-	UNPROTECT(2);
-	return(retlist);        
+    if ( !utIsTime(&utunit) ) {
+        status = UT_ENOTTIME;
+        goto cleanup;
     }
 
-    status = utHasOrigin(&utunit);    
-    if(status == 0) {
-        R_ut_strerror(UT_EINVALID, strerror);
-        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
-        REAL(VECTOR_ELT(retlist, 0))[0] = UT_EINVALID;
-	UNPROTECT(2);
-	return(retlist);        
+    if ( !utHasOrigin(&utunit) ) {
+        status = UT_EINVALID;
+        goto cleanup;
     }
 
     /*-- Convert values -------------------------------------------------------*/
@@ -1793,17 +1782,16 @@ SEXP R_ut_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
 	REAL(VECTOR_ELT(retlist, 2))[i+5*count] = (double)second;
     }
 
+    /*-- Returning the list ---------------------------------------------------*/
+cleanup:
 #ifdef HAVE_LIBUDUNITS2
     utFree(&utunit);
 #endif
-
-    /*-- Returning the list ---------------------------------------------------*/
+    REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	     
     if(status != 0) {
         R_ut_strerror(status, strerror);
-        SET_VECTOR_ELT(retlist, 1, mkString(strerror));
+        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
     }
-    
-    REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	     
     UNPROTECT(2);
     return(retlist);
 }
@@ -1896,30 +1884,18 @@ SEXP R_ut_inv_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
 
     status = utScan(CHAR(STRING_ELT(unitstring, 0)), &utunit);
     if(status != 0) {
-        R_ut_strerror(status, strerror);
-        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
-        REAL(VECTOR_ELT(retlist, 0))[0] = status;
-	UNPROTECT(2);
-	return(retlist);        
+        goto cleanup;
     }
 
     /*-- Check if unit is time and has origin ---------------------------------*/
-    status = utIsTime(&utunit);    
-    if(status == 0) {
-        R_ut_strerror(UT_ENOTTIME, strerror);
-        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
-        REAL(VECTOR_ELT(retlist, 0))[0] = UT_ENOTTIME;
-	UNPROTECT(2);
-	return(retlist);        
+    if ( !utIsTime(&utunit) ) {
+        status = UT_ENOTTIME;
+        goto cleanup;
     }
 
-    status = utHasOrigin(&utunit);    
-    if(status == 0) {
-        R_ut_strerror(UT_EINVALID, strerror);
-        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
-        REAL(VECTOR_ELT(retlist, 0))[0] = UT_EINVALID;
-	UNPROTECT(2);
-	return(retlist);        
+    if ( !utHasOrigin(&utunit) ) {
+        status = UT_EINVALID;
+        goto cleanup;
     }
   
     /*-- Convert values -------------------------------------------------------*/
@@ -1937,22 +1913,20 @@ SEXP R_ut_inv_calendar (SEXP unitstring, SEXP unitcount, SEXP values)
         REAL(VECTOR_ELT(retlist, 2))[i] = (double)utvalue;
     }
 
+    /*-- Returning the list ---------------------------------------------------*/
+cleanup:
 #ifdef HAVE_LIBUDUNITS2
     utFree(&utunit);
 #endif
-
-    /*-- Returning the list ---------------------------------------------------*/
+    REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	     
     if(status != 0) {
         R_ut_strerror(status, strerror);
-        SET_VECTOR_ELT(retlist, 1, mkString(strerror));
+        SET_VECTOR_ELT (retlist, 1, mkString(strerror));
     }
-    
-    REAL(VECTOR_ELT(retlist, 0))[0] = (double)status;	     
     UNPROTECT(2);
     return(retlist);
 }
 
-
 /*=============================================================================*/
  
 /*=============================================================================*\
diff --git a/tests/RNetCDF-test.R b/tests/RNetCDF-test.R
index 9655c4b..f750128 100644
--- a/tests/RNetCDF-test.R
+++ b/tests/RNetCDF-test.R
@@ -2,7 +2,7 @@
 #                                                                               #
 #  Name:       RNetCDF-test.R                                                   #
 #                                                                               #
-#  Version:    1.7-3                                                          #
+#  Version:    1.8-2                                                          #
 #                                                                               #
 #  Purpose:    Test functions to the NetCDF interface for R.                    #
 #                                                                               #
@@ -36,6 +36,7 @@
 #  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                #
+#  mw       26/01/16   Test utcal.nc and utinvcal.nc with POSIXct type          #
 #                                                                               #
 #===============================================================================#
 
@@ -233,6 +234,16 @@ x <- c("1899-12-31 23:00:00", "1900-01-01 00:00:00", "1900-01-01 01: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)
 
+cat("utcal.nc - POSIXct values ...")
+x <- ISOdatetime(c(1899,1900,1900,1900,1900,1900),
+                 c(  12,   1,   1,   1,   1,   1),
+                 c(  31,   1,   1,   1,   1,   1),
+                 c(  23,   0,   1,   2,   3,   4),
+                 c(   0,   0,   0,   0,   0,   0),
+                 c(   0,   0,   0,   0,   0,   0), tz="UTC")
+y <- utcal.nc("hours since 1900-01-01 00:00:00 +01:00", c(0:5), type="c")
+tally <- testfun(x,y,tally)
+
 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))
@@ -243,6 +254,12 @@ x <- 6.416667
 y <- utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00", "1900-01-01 05:25:00")
 tally <- testfun(x,y,tally)
 
+cat("utinvcal.nc - POSIXct values ...")
+x <- 6.416667
+y <- utinvcal.nc("hours since 1900-01-01 00:00:00 +01:00",
+         ISOdatetime(1900,1,1,5,25,0,tz="UTC"))
+tally <- testfun(x,y,tally)
+
 #-------------------------------------------------------------------------------#
 #  Overall summary                                                              #
 #-------------------------------------------------------------------------------#

-- 
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