Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

UDUNITS-2 Manual

Table of Contents


Next: , Previous: (dir), Up: (dir)

UDUNITS-2

This manual introduces the UDUNITS-2 package, which contains a C library for units of physical quantities and a unit-definition and value-conversion utility.

CVS keywords: $Date: 2007/07/23 19:09:27 $, Revision: 1.3 $

Copyright © 2007 University Corporation for Atmospheric Research

Permission to use, copy, modify, and distribute this software and its documentation for any purpose without fee is hereby granted, provided that the above copyright notice appears in all copies, that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the University Corporation for Atmospheric Research (UCAR) not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. UCAR makes no representations about the suitability of this software for any purpose. It is provided “as is” without express or implied warranty. It is provided with no support and without obligation on the part of UCAR to assist in its use, correction, modification, or enhancement.


Next: , Previous: Top, Up: Top

1 Introduction

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.


Next: , Previous: Introduction, Up: Top

2 How This Package Differs from the Original UDUNITS Package

The UDUNIT-2 package differs from the original UDUNITS package in the following ways:

One thing that has not changed is that all unit string specifications understood by the original UDUNITS package are also understood by the new UDUNITS-2 package.


Next: , Previous: Differences, Up: Top

3 Obtaining this 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.0.0.tar.gz | pax -r


Next: , Previous: Obtain, Up: Top

4 Installing this Package


Next: , Up: Install

4.1 Short Installation Instructions

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.


Next: , Previous: Short, Up: Install

4.2 Long Installation Instructions

  1. Go to the top-level source-directory of this package, e.g.,
              cd udunits-2.0.0
         
  2. Because some 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 make Utility
    AIX 1 5 /bin/make
    AIX 1 5 /opt/gnu/bin/make
    AIX 1 5 /usr/ccs/bin/make
    Darwin 8.8.0 /usr/bin/gnumake
    Darwin 8.8.0 /usr/bin/make
    HP-UX B.11.00 /bin/make
    HP-UX B.11.00 /opt/gnu/bin/make
    IRIX64 6.5 /bin/make
    IRIX64 6.5 /opt/gnu/bin/make
    Linux 2.6.18-1.2257.fc5smp /usr/bin/gmake
    Linux 2.6.18-1.2257.fc5smp /usr/bin/make
    Linux 2.6.20-1.2962.fc6 /usr/bin/gmake
    Linux 2.6.20-1.2962.fc6 /usr/bin/make
    OSF1 V5.1 /bin/make
    OSF1 V5.1 /opt/gnu/bin/gmake
    OSF1 V5.1 /usr/bin/posix/make
    OSF1 V5.1 /usr/ccs/bin/make
    SunOS 5.10 /opt/csw/bin/gmake
    SunOS 5.10 /usr/ccs/bin/make
    SunOS 5.10 /usr/xpg4/bin/make
    SunOS 5.9 /opt/gnu/bin/gmake
    SunOS 5.9 /usr/ccs/bin/make
    SunOS 5.9 /usr/xpg4/bin/make

  3. If necessary, clean-up from a previous installation attempt by making the distclean target using the make utility from step 2:
              make distclean
         
  4. Because some compilers cannot build this package correctly, locate the operating system closest to yours in the following table and determine the compiler that you will use and any required option for the configure script.

    O/S Compiler configure Option
    AIX 1 5 /opt/gnu/bin/gcc
    AIX 1 5 /usr/vac/bin/c89
    AIX 1 5 /usr/vac/bin/cc
    AIX 1 5 /usr/vac/bin/xlc
    Darwin 8.8.0 /usr/bin/cc
    Darwin 8.8.0 /usr/bin/gcc
    HP-UX B.11.00 /bin/c89 --disable-shared
    HP-UX B.11.00 /bin/cc --disable-shared
    HP-UX B.11.00 /opt/gnu/bin/gcc
    IRIX64 6.5 /bin/c89
    IRIX64 6.5 /bin/cc
    IRIX64 6.5 /opt/gnu/bin/gcc
    Linux 2.6.18-1.2257.fc5smp /usr/bin/c89
    Linux 2.6.18-1.2257.fc5smp /usr/bin/cc
    Linux 2.6.18-1.2257.fc5smp /usr/bin/gcc
    Linux 2.6.20-1.2962.fc6 /usr/bin/c89
    Linux 2.6.20-1.2962.fc6 /usr/bin/cc
    Linux 2.6.20-1.2962.fc6 /usr/bin/gcc
    OSF1 V5.1 /bin/c89
    OSF1 V5.1 /bin/cc
    OSF1 V5.1 /opt/gnu/bin/gcc
    OSF1 V5.1 /usr/ccs/bin/c89
    OSF1 V5.1 /usr/ccs/bin/cc
    SunOS 5.10 /opt/csw/gcc3/bin/gcc
    SunOS 5.10 /opt/csw/gcc4/bin/gcc
    SunOS 5.10 /opt/SUNWspro/bin/c89
    SunOS 5.10 /opt/SUNWspro/bin/cc
    SunOS 5.9 /opt/csw/gcc3/bin/gcc
    SunOS 5.9 /opt/csw/gcc4/bin/gcc
    SunOS 5.9 /opt/SUNWspro/bin/c89
    SunOS 5.9 /opt/SUNWspro/bin/cc

    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 configure Option
    Darwin 8.8.0 /usr/bin/c89
    Darwin 8.8.0 /usr/bin/c89 --disable-shared
    HP-UX B.11.00 /bin/c89
    HP-UX B.11.00 /bin/cc
    HP-UX B.11.00 /usr/ccs/bin/cc
    HP-UX B.11.00 /usr/ccs/bin/cc --disable-shared
    SunOS 5.10 /opt/SUNWspro/bin/c99
    SunOS 5.10 /opt/SUNWspro/bin/c99 --disable-shared
    SunOS 5.9 /opt/SUNWspro/bin/c99
    SunOS 5.9 /opt/SUNWspro/bin/c99 --disable-shared

  5. Execute the 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.

  6. Build this package by making the default target using the make utility from step 2:
              make
         
  7. If you wish to verify that this package works correctly, then make the 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.

  8. Install the library, utility, header-files, and units-database by making the install target using the make utility from step 2:
              make install
         
  9. If desired, install the documentation by making one or more of the following targets using the make utility from step 2:
              make install-info install-html install-pdf
         
  10. Clean up by making the clean target using the make utility from step 2:
              make clean
         


Previous: Long, Up: Install

4.3 What Gets Installed

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


Next: , Previous: Install, Up: Top

5 Support for this Package

Fora for this package can be found at http://www.unidata.ucar.edu/forums/.

Bug reports should be sent to support-udunits@unidata.ucar.edu.


Previous: Support, Up: Top

Index

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Office of Programs University Corporation for Atmospheric Research (UCAR)   Unidata is a member of the UCAR Office of Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690