|Stable release||2.00 / July 2, 2012|
|Operating system||GNU/Linux, FreeBSD, NetBSD, OpenBSD, Windows|
GNU Units is a cross-platform computer program for conversion of units of quantities. It has a database of measurement units, including esoteric and historical units. This for instance allows conversion of velocities specified in furlongs per fortnight, and pressures specified in tons per acre. Output units are checked for consistency with the input, allowing verification of conversion of complex expressions.
units (UNIX utility)
UDUNITS is a similar utility program, except that it has an additional programming library interface and date conversion abilities. UDUNITS is considered the de facto program and library for variable unit conversion for netCDF files.
The GNU implementation
GNU units includes several extensions to the original version, including
- Exponents can be written with '
^' or '
- Exponents can be larger than 9 if written with '
^' or '
- Sums of units (e.g.,
btu + ft lbf) can be converted.
- Units that measure reciprocal dimensions can be converted (e.g.,
- Parentheses for grouping are supported. The original version allowed only one solidus ('
/'), which sometimes required rearrangement of complex expressions; the GNU version allows more natural expressions, such as in the example that follows.
- Roots of units (e.g.,
sqrt((lbf/inch) / lb)can be computed.
- Nonlinear units conversions (e.g., °F to °C) are supported.
- Functions such as sin, cos, and log are included.
The plain text database units.dat is a good reference in itself, as it is extensively commented and cites numerous sources.
The new release of GNU Units, version 2.0, has been released on July 2, 2012. It can calculate sums of units, such as hours and minutes or feet and inches. In addition, the software now uses the UTF-8 encoding. Since the new version can set units relative to environmental variables, units can be adjusted without changing the locale. In addition, the syntax has changed to define non-linear units, or also the database filename of your choice.
Units will output the result of the conversion in two lines. Usually the first line (multiplication) is the desired result. The second line is the same conversion expressed as a division.
If you attempt to convert types of measurements that are incompatible units will print a conformability error message and display a reduced form of each measurement.
The examples that follow show results from GNU units version 1.88; GNU units versions 1.84c and earlier defined a furlong in terms of the U.S. survey foot rather than international foot, and will give slightly different results than the examples that involve furlongs.
2526 units, 72 prefixes, 56 nonlinear units You have: 10 furlongs You want: miles * 1.25 / 0.8 You have: 1 gallon + 3 pints You want: quarts * 5.5 / 0.18181818 You have: sqrt(miles^2) Definition: 1609.344 m You have: 21 btu + 6500 ft lbf You want: btu * 29.352939 / 0.034068139 You have:
On the command line (non-interactive)=
C:\>units "ten furlongs per fortnight" "kilometers per hour" * 0.0059871429 / 167.02458
% units cup ounces conformability error 0.00023658824 m^3 0.028349523 kg
Complex units expressions
where ΔP is the pressure drop, ρ is the mass density, f is the (dimensionless) friction factor, L is the length of the pipe, Q is the volumetric flow rate, and d is the pipe diameter. It might be desirable to have the equation in the form
that would accept typical US units; the constant A1 could be determined manually using the unit-factor method, but it could be determined more quickly and easily using units:
$ units "(8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)" psi * 43.533969 / 0.022970568
Crane Technical Paper No. 410, Eq. 3-5, gives the multiplicative value as 43.5.
- Mariano, Adrian (2012-07-02). "GNU Units 2.00". lists.gnu.org. http://lists.gnu.org/archive/html/info-gnu/2012-07/msg00001.html. Retrieved 2012-07-3.
- Bell Telephone Laboratories, Incorporated (1979). "Unix Seventh Edition Manual". Murray Hill, NJ: Alcatel-Lucent Bell Labs. Retrieved 2011-04-23. Online archive of the manual pages included with the Seventh Edition Unix distribution tapes.
- As specified from several NetCDF conventions, e.g.:
- COARDS—"Conventions for the standardization of NetCDF files". 1995-02-10.
- CF—"NetCDF Climate and Forecast (CF) Metadata Conventions". 2003-10-28.
- (German language) « GNU Units 2.0 berechnet Feet und Inches », linux-magazin.de, July 3, 2012.
- Technical Paper No. 410, Flow of Fluids through Valves, Fittings, and Pipe. New York: Crane Co. 1985.