FNLMath : Utilities : CUNIT
CUNIT
Converts X in units XUNITS to Y in units YUNITS.
Required Arguments
X — Value to be converted. (Input)
XUNITS — Character string containing the name of the units for X. (Input)
See Comments for a description of units allowed.
Y — Value in YUNITS corresponding to X in XUNITS. (Output)
YUNITS — Character string containing the name of the units for Y. (Input)
See Comments for a description of units allowed.
FORTRAN 90 Interface
Generic: CALL CUNIT (X, XUNITS, Y, YUNITS [])
Specific: The specific interface names are S_CUNIT and D_CUNIT.
FORTRAN 77 Interface
Single: CALL CUNIT (X, XUNITS, Y, YUNITS)
Double The double precision name is DCUNIT.
Description
Routine CUNIT converts a value expressed in one set of units to a value expressed in another set of units.
The input and output units are checked for consistency unless the input unit is “SI”. SI means the Systeme International d’Unites. This is the meterkilogramsecond form of the metric system. If the input units are “SI”, then the input is assumed to be expressed in the SI units consistent with the output units.
Comments
1. Strings XUNITS and YUNITS have the form U1 * U2 *  * Um/V1  Vn, where Ui and Vi are the names of basic units or are the names of basic units raised to a power. Examples are, “METER * KILOGRAM/SECOND”, “M * KG/S”, “METER”, or “M/KG2”.
2. The case of the character string in XUNITS and YUNITS does not matter. The names “METER”, “Meter” and “meter” are equivalent.
3. If XUNITS is “SI”, then X is assumed to be in the standard international units corresponding to YUNITS. Similarly, if YUNITS is “SI”, then Y is assumed to be in the standard international units corresponding to XUNITS.
4. The basic unit names allowed are as follows:
Units of time
day, hour = hr, min = minute, s = sec = second, year
Units of frequency
Hertz = Hz
Units of mass
AMU, g = gram, lb = pound, ounce = oz, slug
Units of distance
Angstrom, AU, feet = foot = ft, in = inch, m = meter = metre, micron, mile, mill, parsec, yard
Units of area
acre
Units of volume
l = liter = litre
Units of force
dyne, N = Newton, poundal
Units of energy
BTU(thermochemical), Erg, J = Joule
Units of work
W = watt
Units of pressure
ATM = atomosphere, bar, Pascal
Units of temperature
degC = Celsius, degF = Fahrenheit, degK = Kelvin
Units of viscosity
poise, stoke
Units of charge
Abcoulomb, C = Coulomb, statcoulomb
Units of current
A = ampere, abampere, statampere,
Units of voltage
Abvolt, V = volt
Units of magnetic induction
T = Tesla, Wb = Weber
Other units
1, farad, mole, Gauss, Henry, Maxwell, Ohm
The following metric prefixes may be used with the above units. Note that the one or two letter prefixes may only be used with one letter unit abbreviations.
A
Atto
1.E 18
F
Femto
1.E 15
P
Pico
1.E 12
N
Nano
1.E 9
U
Micro
1.E 6
M
Milli
1.E 3
C
Centi
1.E 2
D
Deci
1.E 1
DK
Deca
1.E + 2
K
Kilo
1.E + 3
 
Myriad
1.E + 4 (no single letter prefix; M means milli
 
Mega
1.E + 6 (no single letter prefix; M means milli
G
Giga
1.E + 9
T
Tera
1.E + 12
5. Informational error
Type
Code
Description
3
8
A conversion of units of mass to units of force was required for consistency.
Example
The routine CONST is used to obtain the speed on light, c, in SI units. CUNIT is then used to convert c to mile/second and to parsec/year. An example involving substitution of force for mass is required in conversion of Newtons/Meter2 to Pound/Inch2.
 
USE CONST_INT
USE CUNIT_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER NOUT
REAL CMH, CMS, CPY, CPSI
! Get output unit number
CALL UMACH (2, NOUT)
! Get speed of light in SI (m/s)
CMS = CONST('SpeedLight')
WRITE (NOUT,*) 'Speed of Light = ', CMS, ' meter/second'
! Get speed of light in mile/second
CALL CUNIT (CMS, 'SI', CMH, 'Mile/Second')
WRITE (NOUT,*) 'Speed of Light = ', CMH, ' mile/second'
! Get speed of light in parsec/year
CALL CUNIT (CMS, 'SI', CPY, 'Parsec/Year')
WRITE (NOUT,*) 'Speed of Light = ', CPY, ' Parsec/Year'
! Convert Newton/Meter**2 to
! Pound/Inch**2.
CALL CUNIT(1.E0, 'Newton/Meter**2', CPSI, &
'Pound/Inch**2')
WRITE(NOUT,*)' Atmospheres, in Pound/Inch**2 = ',CPSI
END
Output
 
Speed of Light = 299792440.0 meter/second
Speed of Light = 186282.39 mile/second
Speed of Light = 0.3063872 Parsec/Year
 
*** WARNING ERROR 8 from CUNIT. A conversion of units of mass to units of
*** force was required for consistency.
Atmospheres, in Pound/Inch**2 = 1.4503773E-4
Published date: 03/19/2020
Last modified date: 03/19/2020