fury_uom64
FURY definition of unit of measure class with float64 real kind. FURY implementation of unit of measure class of generic kind.
Source: src/lib/fury_uom64.F90
Dependencies
Contents
- uom
- uom
- remove_reference
- get_alias
- get_references
- set
- set_alias_conversion
- convert
- unset
- add_reference
- parse
- parse_alias
- parse_name
- parse_references
- update_references_number
- assign_uom
- convert_references
- merge_reference
- remove_null_references
- creator_from_string
- get_main_symbol
- get_main_reference
- has_name
- has_reference
- is_defined
- prefixed
- stringify
- to
- has_alias
- is_equal
- is_not_equal
- add
- div
- mul
- sub
- pow_R16P
- pow_R8P
- pow_R4P
- pow_I8P
- pow_I4P
- pow_I2P
- pow_I1P
Derived Types
uom
Unit of measure (UOM) class.
The string format definition of a valid FURY unit is as following:
uom_referenceA.uom_referenceB.... (uom_referenceALIAS[dimensions_alias]) {name}
where
uom_referenceA, uom_referenceB, ...are the defined uom references that must follow uom_reference syntax.- the term
(uom_referenceALIAS[dimensions_alias])defines a unit alias that is optional and must come always after unit reference definition; - the term
{name}defines the unit name that is optional and must be always the last term.
For example, valid definition are:
kg [mass].m-1 = metre-1 = meter-1 [length-1].s-2 = seconds-2 = sec-2 [time-2] (Pa[pressure]) {pascal}km = 1000 * m [length].h-1 = 3600 s-1 [time-1] (km_h[speed]) {km/h}
The aliases definition for uom_reference term can be protected by means of < and > that are optional, but highly recommended, e.g.:
km< = 1000.0 * m> [length].h-1< = 3600.0 s-1> [time-1] (km_h[speed]) {km/h}
This protection allows disambiguation of . symbols that are used for uom_reference separation and for real offset/factor of aliases definition. Other valid definitions are:
kg.m-1.s-2a unit without specified dimensions, alias and name;kg.m-1.s-2(Pa)a unit without specified dimensions and name, but with an alias without alias dimension;kg.m-1.s-2(Pa[pressure])a unit without specified dimensions and name, but with an alias with alias dimension;kg.m-1.s-2{pascal}a unit without specified dimensions and alias, but with a name; èkg.m-1.s-2(Pa){pascal}a unit without specified dimensions, but with an alias without alias dimension and a name;
@note It is better to avoid to incomplete list of dimensions for references: define all dimensions for all references or avoid to define dimensions at all.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
name | character(len=:) | allocatable | Unit name. |
alias | type(uom_reference) | allocatable | Alias of the unit, e.g Pa (kg.m-1.s-2) for Pascal. |
references | type(uom_reference) | allocatable | Reference units of the unit. |
references_number | integer(kind=I_P) | References number. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
convert | pass(self) | Convert magnitude with respect another unit, reporting the success. |
get_alias | pass(self) | Return the alias. |
get_main_reference | pass(self) | Return the main reference. |
get_main_symbol | pass(self) | Return the main symbol. |
get_references | pass(self) | Return the references. |
has_alias | pass(self) | Check if the unit has an alias. |
has_name | pass(self) | Check if the unit has a name. |
has_reference | pass(self) | Check if the unit has a queried reference unit. |
is_defined | pass(self) | Check if the unit is defined. |
prefixed | pass(self) | Return prefixed unit. |
set | pass(self) | Set the unit. |
set_alias_conversion | pass(self) | Set alias conversion formula. |
stringify | pass(self) | Return a string representation of the unit. |
to | pass(self) | Convert magnitude with respect another unit. |
unset | pass(self) | unset the unit. |
assignment(=) | Overloading = operator. Generic: assign_uom | |
operator(+) | Overloading + operator. Generic: add | |
operator(/) | Overloading / operator. Generic: div | |
operator(*) | Overloading * operator. Generic: mul | |
operator(-) | Overloading - operator. Generic: sub | |
operator(**) | Overloading ** operator. Generic: pow_R8P, pow_R4P, pow_I8P, pow_I4P, pow_I2P, pow_I1P | |
operator(==) | Overloading == operator. Generic: is_equal | |
operator(/=) | Overloading /= operator. Generic: is_not_equal | |
add_reference | pass(self) | Add a reference unit to unit. |
is_equal | pass(self) | Check if unit is equal with another one. |
is_not_equal | pass(self) | Check if unit is not equal with another one. |
parse | pass(self) | Parse unit definition from an input string. |
parse_alias | pass(self) | Parse unit alias from an input string. |
parse_name | pass(self) | Parse unit name from an input string. |
parse_references | pass(self) | Parse reference units from an input string. |
update_references_number | pass(self) | Update reference units number counter. |
assign_uom | pass(lhs) | uom = uom assignment. |
add | pass(lhs) | uom + uom operator. |
div | pass(lhs) | uom / uom operator. |
mul | pass(lhs) | uom * uom operator. |
sub | pass(lhs) | uom - uom operator. |
pow_R16P | pass(lhs) | uom ** real(R16P) operator. |
pow_R8P | pass(lhs) | uom ** real(R8P) operator. |
pow_R4P | pass(lhs) | uom ** real(R4P) operator. |
pow_I8P | pass(lhs) | uom ** integer(I8P) operator. |
pow_I4P | pass(lhs) | uom ** integer(I4P) operator. |
pow_I2P | pass(lhs) | uom ** integer(I2P) operator. |
pow_I1P | pass(lhs) | uom ** integer(I1P) operator. |
Interfaces
uom
Ovearloading uom name with a set of creator functions.
Module procedures: creator_from_string
Subroutines
remove_reference
Remove a reference from the list of references.
Attributes: pure
subroutine remove_reference(references, id)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
references | type(uom_reference) | inout | allocatable | References list. |
id | integer(kind=I_P) | in | Index of reference to remove. |
get_alias
Return the alias.
Attributes: pure
subroutine get_alias(self, alias)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The uom. | |
alias | type(uom_reference) | out | Uom main alias. |
Call graph
get_references
Return the references.
Attributes: pure
subroutine get_references(self, references)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The uom. | |
references | type(uom_reference) | out | allocatable | Uom references. |
Call graph
set
Set the unit.
Attributes: pure
subroutine set(self, references, alias, name)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. | |
references | type(uom_reference) | in | optional | Unit references of the unit. |
alias | type(uom_reference) | in | optional | Alias of the unit, e.g Pa (kg.m-1.s-2) for Pascal [pressure]. |
name | character(len=*) | in | optional | Unit name. |
Call graph
set_alias_conversion
Set alias conversion formula.
Attributes: pure
subroutine set_alias_conversion(self, reference_index, alias_index, convert)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The uom reference. | |
reference_index | integer(kind=I_P) | in | Index of the reference to which set the conversion formula. | |
alias_index | integer(kind=I_P) | in | Index of the alias to which set the conversion formula. | |
convert | class(uom_converter) | in | Generic conversion alias formula user-supplied. |
Call graph
convert
Convert magnitude with respect another unit, reporting if the conversion has been found.
The references of the unit are matched with the ones of the other unit; the main alias of a unit is matched with the references of the other one too, e.g. "lbf = 4.4482216152605 * N" with "kg.m.s-2 (N[force])". The conversion is found only if every reference is converted: otherwise the magnitude is returned unchanged and is_converted is false.
Attributes: pure
subroutine convert(self, other, magnitude, converted, is_converted)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The uom. | |
other | type(uom) | in | Other unit used for conversion. | |
magnitude | real(kind=RKP) | in | Magnitude to be converted. | |
converted | real(kind=RKP) | out | Converted magnitude. | |
is_converted | logical | out | True if the conversion has been found. |
Call graph
unset
Unset the unit.
Attributes: elemental
subroutine unset(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. |
Call graph
add_reference
Add reference unit to unit.
Attributes: elemental
subroutine add_reference(self, reference)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. | |
reference | type(uom_reference) | in | Unit reference to be added. |
Call graph
parse
Parse unit definition form an input string.
subroutine parse(self, source)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. | |
source | character(len=*) | in | Input source string. |
Call graph
parse_alias
Parse unit alias form an input string and return also the source string without the alias data.
@note It is assumed that the optional unit name has been already parsed and trimmed out form the input string.
subroutine parse_alias(self, source)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. | |
source | type(string) | inout | Input source string. |
Call graph
parse_name
Parse unit name form an input string and return also the source string without the name data.
subroutine parse_name(self, source)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. | |
source | type(string) | inout | Input source string. |
Call graph
parse_references
Parse references units form an input string.
subroutine parse_references(self, source)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. | |
source | type(string) | in | Input source string. |
Call graph
update_references_number
Update references number counter.
Attributes: elemental
subroutine update_references_number(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | inout | The unit. |
Call graph
assign_uom
uom = uom assignment.
subroutine assign_uom(lhs, rhs)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | inout | Left hand side. | |
rhs | class(uom) | in | Right hand side. |
Call graph
convert_references
Convert a magnitude from a set of references to another one: each reference must be converted into a different reference of the other set.
Attributes: pure
subroutine convert_references(self_references, other_references, magnitude, converted, is_converted)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self_references | type(uom_reference) | in | References converted. | |
other_references | type(uom_reference) | in | References of the conversion. | |
magnitude | real(kind=RKP) | in | Magnitude to be converted. | |
converted | real(kind=RKP) | out | Converted magnitude, unchanged if not converted. | |
is_converted | logical | out | True if all the references have been converted. |
Call graph
merge_reference
Multiply a set of references by a reference: the reference is multiplied into the compatible one (same symbol), otherwise it is appended.
Attributes: pure
subroutine merge_reference(references, reference)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
references | type(uom_reference) | inout | allocatable | References. |
reference | type(uom_reference) | in | Reference multiplied. |
Call graph
remove_null_references
Remove the references with exponent 0, e.g. "m.s0" is "m"; a dimensionless set, e.g. "kg0.m0.s0", is kept as it is.
Attributes: pure
subroutine remove_null_references(references)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
references | type(uom_reference) | inout | allocatable | References. |
Call graph
Functions
creator_from_string
Create an instance of uom from an input source string.
Returns: type(uom)
function creator_from_string(source, alias, name) result(unit)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
source | character(len=*) | in | Source input string definition of the unit. | |
alias | type(uom_reference) | in | optional | Alias of the unit, e.g Pa (kg.m-1.s-2) for Pascal [pressure]. |
name | character(len=*) | in | optional | Unit name. |
Call graph
get_main_symbol
Return the main symbol, i.e. self%alias%aliases(1)%symbol_ if self%alias is defined or self%references(1)%aliases(1)%symbol_ if self has only 1 uom_reference.
Returns: type(string)
function get_main_symbol(self) result(symbol)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The uom. |
Call graph
get_main_reference
Return the main reference, i.e. self%alias if self%alias is defined or self%references(1) if self has only 1 uom_reference.
Attributes: pure
Returns: type(uom_reference)
function get_main_reference(self) result(reference)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The uom. |
Call graph
has_name
Check if the unit has a name.
Attributes: elemental
Returns: logical
function has_name(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. |
Call graph
has_reference
Check if the unit has a queried reference unit.
Attributes: elemental
Returns: logical
function has_reference(self, reference)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. | |
reference | type(uom_reference) | in | Reference unit to check the presence of. |
Call graph
is_defined
Check if the unit has been defined, namely it has defined references.
Attributes: elemental
Returns: logical
function is_defined(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. |
Call graph
prefixed
Return prefixed unit.
Returns: type(uom)
function prefixed(self, prefixes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. | |
prefixes | type(uom_reference) | in | Prefixes data. |
Call graph
stringify
Return a string representation of the unit.
Attributes: pure
Returns: character(len=:)
function stringify(self, with_dimensions, with_aliases, protect_aliases, with_name, compact_reals) result(raw)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. | |
with_dimensions | logical | in | optional | Flag to activate dimensions printing. |
with_aliases | logical | in | optional | Flag to activate aliases printing. |
protect_aliases | logical | in | optional | Flag to activate aliases printing in protected mode. |
with_name | logical | in | optional | Flag to activate name printing. |
compact_reals | logical | in | optional | Flag to activate real numbers compacting. |
Call graph
to
Convert magnitude with respect another unit, see convert: the magnitude is returned unchanged if the conversion has not been found.
Attributes: elemental
Returns: real(kind=RKP)
function to(self, other, magnitude) result(converted)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The uom. | |
other | type(uom) | in | Other unit used for conversion. | |
magnitude | real(kind=RKP) | in | Magnitude to be converted. |
Call graph
has_alias
Check if the unit has an alias.
Attributes: elemental
Returns: logical
function has_alias(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. |
Call graph
is_equal
Check if unit is equal (has the same references units) with another one.
Attributes: elemental
Returns: logical
function is_equal(self, other)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. | |
other | class(uom) | in | The other unit. |
Call graph
is_not_equal
Check if unit is not equal (has not the same references units) with another one.
Attributes: elemental
Returns: logical
function is_not_equal(self, other)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(uom) | in | The unit. | |
other | class(uom) | in | The other unit. |
Call graph
add
uom + uom operator.
Returns: type(uom)
function add(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | class(uom) | in | Right hand side. |
Call graph
div
uom / uom operator.
Returns: type(uom)
function div(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | class(uom) | in | Right hand side. |
Call graph
mul
uom * uom operator.
Returns: type(uom)
function mul(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | class(uom) | in | Right hand side. |
Call graph
sub
uom - uom operator.
Returns: type(uom)
function sub(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | class(uom) | in | Right hand side. |
Call graph
pow_R16P
uom ** real(R16P) operator.
Returns: type(uom)
function pow_R16P(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | real(kind=R16P) | in | Right hand side. |
Call graph
pow_R8P
uom ** real(R8P) operator.
Returns: type(uom)
function pow_R8P(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | real(kind=R8P) | in | Right hand side. |
Call graph
pow_R4P
uom ** real(R4P) operator.
Returns: type(uom)
function pow_R4P(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | real(kind=R4P) | in | Right hand side. |
Call graph
pow_I8P
uom ** integer(I8P) operator.
Returns: type(uom)
function pow_I8P(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | integer(kind=I8P) | in | Right hand side. |
Call graph
pow_I4P
uom ** integer(I4P) operator.
Returns: type(uom)
function pow_I4P(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | integer(kind=I4P) | in | Right hand side. |
Call graph
pow_I2P
uom ** integer(I2P) operator.
Returns: type(uom)
function pow_I2P(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | integer(kind=I2P) | in | Right hand side. |
Call graph
pow_I1P
uom ** integer(I1P) operator.
Returns: type(uom)
function pow_I1P(lhs, rhs) result(opr)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(uom) | in | Left hand side. | |
rhs | integer(kind=I1P) | in | Right hand side. |
Call graph