This manual describes the UDUNITS-2 package, which contains a C library for units of physical quantities and a unit-definition and value-conversion utility.
Copyright 2008, 2009 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.
The UDUNITS-2 package provides support for units of physical quantities. Its three main components are: 1) a C library for units of physical quantities; 2) a utility; for obtaining the definition of a unit and for converting numeric values between compatible units; and 3) an extensive database of units.
UDUNITS PackageThe UDUNIT-2 package differs from the original UDUNITS
package in the following ways:
UDUNITS
package only supports the ASCII character set. The UDUNITS-2
package supports the following character sets: ASCII, ISO 8859-1 (Latin-1),
and the UTF-8 encoding of ISO 10646 (Unicode). This means that unit
string specifications like "µ°F·Ω⁻¹" are now supported (your
viewer must support UTF-8 to display this string correctly).
0.1 lg(re 1 mW)" specifies a deciBel unit with a
one milliwatt reference level.
Such units are fully integrated into the package and all meaningful
operations and conversions are supported.
float, double, or
one-dimensional arrays of floats or doubles.
UDUNITS package. The new interface, however, is easily
understood and easy to use. To support backward comptibility,
the package does contain a version 1 C API, which uses the version 2
library.
One thing that has not changed is that almost all unit string specifications
understood by the original UDUNITS package are also
understood by the new UDUNITS-2 package. The one exception is
the symbol g, which in the original package was associated with
standard free fall (a unit of accelleration) but which is associated
with gram in the new package.
Get this package from its download-page at http://www.unidata.ucar.edu/downloads/udunits/ and unpack it in an appropriate place, e.g.,
cd /usr/local/src
gunzip -c udunits-2.1.9.tar.gz | pax -r
Not all development enviroments can build and install this package. See the long instructions in the next section for details.
The following assumes that you are familiar with autoconf-based package-installation. If you're not, then follow the long instructions in the next section.
./configure [--prefix=root] [--disable-shared] [CC=path]
make
make check # optional; requires CUNIT installation
make install
make install-info install-html install-pdf
make clean
By default, the installation root is /usr/local.
If you encounter problems, then follow the instructions in the next section.
cd udunits-2.1.9
make utilities cannot build this package correctly,
locate the operating system that is closest to yours in the following table
and determine the make utility that you will use.
O/S makeUtilityAIX 1 5/bin/makeAIX 1 5/opt/gnu/bin/makeAIX 1 5/usr/ccs/bin/makeDarwin 10.0.0/usr/bin/gnumakeDarwin 10.0.0/usr/bin/makeDarwin 8.11.0/usr/bin/gnumakeDarwin 8.11.0/usr/bin/makeHP-UX B.11.00/bin/makeHP-UX B.11.00/opt/gnu/bin/makeIRIX64 6.5/bin/makeIRIX64 6.5/opt/gnu/bin/makeLinux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/gmakeLinux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/makeLinux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/gmakeLinux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/makeOSF1 V5.1/bin/makeOSF1 V5.1/opt/gnu/bin/gmakeOSF1 V5.1/usr/bin/posix/makeOSF1 V5.1/usr/ccs/bin/makeSunOS 5.10/opt/csw/bin/gmakeSunOS 5.10/usr/ccs/bin/makeSunOS 5.10/usr/xpg4/bin/makeSunOS 5.9/opt/gnu/bin/gmakeSunOS 5.9/usr/ccs/bin/makeSunOS 5.9/usr/xpg4/bin/make
distclean target using the make utility from step 2:
make distclean
configure script.
O/S Compiler configureOptionAIX 1 5/opt/gnu/bin/gcc--disable-sharedAIX 1 5/usr/vac/bin/c89--disable-sharedAIX 1 5/usr/vac/bin/cc--disable-sharedAIX 1 5/usr/vac/bin/xlc--disable-sharedDarwin 10.0.0/usr/bin/c89--disable-sharedDarwin 10.0.0/usr/bin/ccDarwin 10.0.0/usr/bin/cc--disable-sharedDarwin 10.0.0/usr/bin/gccDarwin 10.0.0/usr/bin/gcc--disable-sharedDarwin 8.11.0/usr/bin/c89--disable-sharedDarwin 8.11.0/usr/bin/ccDarwin 8.11.0/usr/bin/cc--disable-sharedDarwin 8.11.0/usr/bin/gccDarwin 8.11.0/usr/bin/gcc--disable-sharedHP-UX B.11.00/bin/c89--disable-sharedHP-UX B.11.00/bin/cc--disable-sharedHP-UX B.11.00/opt/gnu/bin/gccHP-UX B.11.00/opt/gnu/bin/gcc--disable-sharedIRIX64 6.5/bin/c89IRIX64 6.5/bin/c89--disable-sharedIRIX64 6.5/bin/ccIRIX64 6.5/bin/cc--disable-sharedIRIX64 6.5/opt/gnu/bin/gccIRIX64 6.5/opt/gnu/bin/gcc--disable-sharedLinux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/c89Linux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/c89--disable-sharedLinux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/ccLinux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/cc--disable-sharedLinux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/gccLinux 2.6.27.24-78.2.53.fc9.x86_64/usr/bin/gcc--disable-sharedLinux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/c89Linux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/c89--disable-sharedLinux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/ccLinux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/cc--disable-sharedLinux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/gccLinux 2.6.27.25-170.2.72.fc10.x86_64/usr/bin/gcc--disable-sharedOSF1 V5.1/bin/c89OSF1 V5.1/bin/c89--disable-sharedOSF1 V5.1/bin/ccOSF1 V5.1/bin/cc--disable-sharedOSF1 V5.1/opt/gnu/bin/gccOSF1 V5.1/opt/gnu/bin/gcc--disable-sharedOSF1 V5.1/usr/ccs/bin/c89OSF1 V5.1/usr/ccs/bin/c89--disable-sharedOSF1 V5.1/usr/ccs/bin/ccOSF1 V5.1/usr/ccs/bin/cc--disable-sharedSunOS 5.10/opt/csw/gcc3/bin/gccSunOS 5.10/opt/csw/gcc3/bin/gcc--disable-sharedSunOS 5.10/opt/csw/gcc4/bin/gccSunOS 5.10/opt/csw/gcc4/bin/gcc--disable-sharedSunOS 5.10/opt/SUNWspro/bin/c89SunOS 5.10/opt/SUNWspro/bin/c89--disable-sharedSunOS 5.10/opt/SUNWspro/bin/ccSunOS 5.10/opt/SUNWspro/bin/cc--disable-sharedSunOS 5.9/opt/csw/gcc3/bin/gccSunOS 5.9/opt/csw/gcc3/bin/gcc--disable-sharedSunOS 5.9/opt/csw/gcc4/bin/gccSunOS 5.9/opt/csw/gcc4/bin/gcc--disable-sharedSunOS 5.9/opt/SUNWspro/bin/c89SunOS 5.9/opt/SUNWspro/bin/c89--disable-sharedSunOS 5.9/opt/SUNWspro/bin/ccSunOS 5.9/opt/SUNWspro/bin/cc--disable-shared
The option --disable-shared causes the build process to create
a static library only: a sharable library is not created.
This option is necessary if the libtool utility that's included
in this package can't build a sharable library using the given compiler.
The following table lists the build environments that do not work — so don't use them:
O/S Compiler configureOptionAIX 1 5/opt/gnu/bin/gccAIX 1 5/usr/vac/bin/c89AIX 1 5/usr/vac/bin/ccAIX 1 5/usr/vac/bin/xlcDarwin 10.0.0/usr/bin/c89Darwin 8.11.0/usr/bin/c89HP-UX B.11.00/bin/c89HP-UX B.11.00/bin/ccHP-UX B.11.00/usr/ccs/bin/ccHP-UX B.11.00/usr/ccs/bin/cc--disable-sharedSunOS 5.10/opt/SUNWspro/bin/c99SunOS 5.10/opt/SUNWspro/bin/c99--disable-sharedSunOS 5.9/opt/SUNWspro/bin/c99SunOS 5.9/opt/SUNWspro/bin/c99--disable-shared
configure script.
Specify the installation prefix, the compiler from the
previous step, and any required option.
For example, if you are on an HP-UX system and want to use
the /bin/c89 compiler and install under /opt,
then the following command is appropriate:
./configure --prefix=/opt --disable-shared CC=/bin/c89
If the installation prefix is not specified, then the default
is to install under /usr/local.
If the compiler isn't specified, then the default is to use
gcc.
make
check target using the
make utility from step 2:
make check
This step is only effective if the configure script found an
installed CUNIT unit-testing package. If that package wasn't
found, then the above command will quickly exit without testing this
package.
install target using the make utility from
step 2:
make install
make install-info install-html install-pdf
clean target using the make utility
from step 2:
make clean
By default, the following files are created or installed under the installation directory:
bin/:
udunits2 # Unit utility
include/:
converter.h # API for value converters
udunits2.h # API for units
lib/:
libudunits2.a # Static unit library
libudunits2.la # libtool(1) reference for unit library
libudunits2.so # Link to shared library
libudunits2.so.0 # Link to shared library
libudunits2.so.0.0.0 # Shared library
share/:
doc # Directory. Created if it doesn't exist
info # Directory. Created if it doesn't exist
udunits # Directory. Created if it doesn't exist
share/doc:
udunits # Directory. Created if it doesn't exist
share/doc/udunits:
udunits2.html # HTML documentation on this package
udunits2lib.html # HTML documentation on the unit library
udunits2lib.pdf # PDF documentation on the unit library
udunits2.pdf # PDF documentation on this package
udunits2prog.html # HTML documentation on the unit utility
udunits2prog.pdf # PDF documentation on the unit utility
share/info:
dir # Top-level "info" file. Created if it doesn't exist
udunits2.info # INFO documentation on this package
udunits2lib.info # INFO documentation on the unit library
udunits2prog.info # INFO documentation on the unit utility
share/udunits:
udunits2.xml # Default unit database
udunits2-accepted.xml # Units accepted for use with the SI
udunits2-base.xml # SI base units
udunits2-common.xml # Common, non-SI units
udunits2-derived.xml # Derived units of the SI
udunits2-prefixes.xml # SI unit prefixes
The home-page for this package can be found at http://www.unidata.ucar.edu/software/udunits/.
Bug reports should be sent to support-udunits@unidata.ucar.edu.