Skip to content

UDUNITS

UDUNITS is a package for managing physical quantities with units.

UDUNITS is available as a module on Apocrita. The package provides a library with C API and a command line utility. These are supported by a provided database of units, including conversion formulas between units.

Using UDUNITS

To access the default installed version of the UDUNITS package, load the udunits module:

module load udunits

On Apocrita, only version 2 of the UDUNITS package is available. The documentation details inconsistencies with version 1 of the API.

Using the command line utility

The command line utility udunits2 allows you to query a units database. Actions include displaying the definition of a unit in terms of SI base units or converting between units:

$ # See the definition of the W (Watt) unit
$ udunits2 -H W -W ''
    m²·kg·s⁻³
$ # Convert 1.3 miles (mi) to metres (m)
$ udunits2 -H 1.3mi -W m
    1.3 mi = 2092.15 m
    x/m = 1609.34*(x/mi)

Without further options, udunits2 queries the bundled units database. An alternative database may be given as an option to the command line. Usage of the utility is given with the -h option:

$ udunits2 -h
Usage:
    udunits2 -h
    udunits2 [-A|-L|-U] [-r] [-H have] [-W want] [XML_file]

...

Documentation

Documentation of the UDUNITS package is installed on Apocrita in Info format:

info udunits2
info udunits2lib

References