Skip to content

fury_uom32 ​

FURY definition of unit of measure class with float32 real kind. FURY implementation of unit of measure class of generic kind.

Source: src/lib/fury_uom32.F90

Dependencies

Contents ​

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

NameTypeAttributesDescription
namecharacter(len=:)allocatableUnit name.
aliastype(uom_reference)allocatableAlias of the unit, e.g Pa (kg.m-1.s-2) for Pascal.
referencestype(uom_reference)allocatableReference units of the unit.
references_numberinteger(kind=I_P)References number.

Type-Bound Procedures

NameAttributesDescription
convertpass(self)Convert magnitude with respect another unit, reporting the success.
get_aliaspass(self)Return the alias.
get_main_referencepass(self)Return the main reference.
get_main_symbolpass(self)Return the main symbol.
get_referencespass(self)Return the references.
has_aliaspass(self)Check if the unit has an alias.
has_namepass(self)Check if the unit has a name.
has_referencepass(self)Check if the unit has a queried reference unit.
is_definedpass(self)Check if the unit is defined.
prefixedpass(self)Return prefixed unit.
setpass(self)Set the unit.
set_alias_conversionpass(self)Set alias conversion formula.
stringifypass(self)Return a string representation of the unit.
topass(self)Convert magnitude with respect another unit.
unsetpass(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_referencepass(self)Add a reference unit to unit.
is_equalpass(self)Check if unit is equal with another one.
is_not_equalpass(self)Check if unit is not equal with another one.
parsepass(self)Parse unit definition from an input string.
parse_aliaspass(self)Parse unit alias from an input string.
parse_namepass(self)Parse unit name from an input string.
parse_referencespass(self)Parse reference units from an input string.
update_references_numberpass(self)Update reference units number counter.
assign_uompass(lhs)uom = uom assignment.
addpass(lhs)uom + uom operator.
divpass(lhs)uom / uom operator.
mulpass(lhs)uom * uom operator.
subpass(lhs)uom - uom operator.
pow_R16Ppass(lhs)uom ** real(R16P) operator.
pow_R8Ppass(lhs)uom ** real(R8P) operator.
pow_R4Ppass(lhs)uom ** real(R4P) operator.
pow_I8Ppass(lhs)uom ** integer(I8P) operator.
pow_I4Ppass(lhs)uom ** integer(I4P) operator.
pow_I2Ppass(lhs)uom ** integer(I2P) operator.
pow_I1Ppass(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

fortran
subroutine remove_reference(references, id)

Arguments

NameTypeIntentAttributesDescription
referencestype(uom_reference)inoutallocatableReferences list.
idinteger(kind=I_P)inIndex of reference to remove.

get_alias ​

Return the alias.

Attributes: pure

fortran
subroutine get_alias(self, alias)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe uom.
aliastype(uom_reference)outUom main alias.

Call graph

get_references ​

Return the references.

Attributes: pure

fortran
subroutine get_references(self, references)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe uom.
referencestype(uom_reference)outallocatableUom references.

Call graph

set ​

Set the unit.

Attributes: pure

fortran
subroutine set(self, references, alias, name)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.
referencestype(uom_reference)inoptionalUnit references of the unit.
aliastype(uom_reference)inoptionalAlias of the unit, e.g Pa (kg.m-1.s-2) for Pascal [pressure].
namecharacter(len=*)inoptionalUnit name.

Call graph

set_alias_conversion ​

Set alias conversion formula.

Attributes: pure

fortran
subroutine set_alias_conversion(self, reference_index, alias_index, convert)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe uom reference.
reference_indexinteger(kind=I_P)inIndex of the reference to which set the conversion formula.
alias_indexinteger(kind=I_P)inIndex of the alias to which set the conversion formula.
convertclass(uom_converter)inGeneric 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

fortran
subroutine convert(self, other, magnitude, converted, is_converted)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe uom.
othertype(uom)inOther unit used for conversion.
magnitudereal(kind=RKP)inMagnitude to be converted.
convertedreal(kind=RKP)outConverted magnitude.
is_convertedlogicaloutTrue if the conversion has been found.

Call graph

unset ​

Unset the unit.

Attributes: elemental

fortran
subroutine unset(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.

Call graph

add_reference ​

Add reference unit to unit.

Attributes: elemental

fortran
subroutine add_reference(self, reference)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.
referencetype(uom_reference)inUnit reference to be added.

Call graph

parse ​

Parse unit definition form an input string.

fortran
subroutine parse(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.
sourcecharacter(len=*)inInput 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.

fortran
subroutine parse_alias(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.
sourcetype(string)inoutInput source string.

Call graph

parse_name ​

Parse unit name form an input string and return also the source string without the name data.

fortran
subroutine parse_name(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.
sourcetype(string)inoutInput source string.

Call graph

parse_references ​

Parse references units form an input string.

fortran
subroutine parse_references(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.
sourcetype(string)inInput source string.

Call graph

update_references_number ​

Update references number counter.

Attributes: elemental

fortran
subroutine update_references_number(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inoutThe unit.

Call graph

assign_uom ​

uom = uom assignment.

fortran
subroutine assign_uom(lhs, rhs)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inoutLeft hand side.
rhsclass(uom)inRight 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

fortran
subroutine convert_references(self_references, other_references, magnitude, converted, is_converted)

Arguments

NameTypeIntentAttributesDescription
self_referencestype(uom_reference)inReferences converted.
other_referencestype(uom_reference)inReferences of the conversion.
magnitudereal(kind=RKP)inMagnitude to be converted.
convertedreal(kind=RKP)outConverted magnitude, unchanged if not converted.
is_convertedlogicaloutTrue 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

fortran
subroutine merge_reference(references, reference)

Arguments

NameTypeIntentAttributesDescription
referencestype(uom_reference)inoutallocatableReferences.
referencetype(uom_reference)inReference 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

fortran
subroutine remove_null_references(references)

Arguments

NameTypeIntentAttributesDescription
referencestype(uom_reference)inoutallocatableReferences.

Call graph

Functions ​

creator_from_string ​

Create an instance of uom from an input source string.

Returns: type(uom)

fortran
function creator_from_string(source, alias, name) result(unit)

Arguments

NameTypeIntentAttributesDescription
sourcecharacter(len=*)inSource input string definition of the unit.
aliastype(uom_reference)inoptionalAlias of the unit, e.g Pa (kg.m-1.s-2) for Pascal [pressure].
namecharacter(len=*)inoptionalUnit 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)

fortran
function get_main_symbol(self) result(symbol)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe 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)

fortran
function get_main_reference(self) result(reference)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe uom.

Call graph

has_name ​

Check if the unit has a name.

Attributes: elemental

Returns: logical

fortran
function has_name(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.

Call graph

has_reference ​

Check if the unit has a queried reference unit.

Attributes: elemental

Returns: logical

fortran
function has_reference(self, reference)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.
referencetype(uom_reference)inReference 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

fortran
function is_defined(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.

Call graph

prefixed ​

Return prefixed unit.

Returns: type(uom)

fortran
function prefixed(self, prefixes)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.
prefixestype(uom_reference)inPrefixes data.

Call graph

stringify ​

Return a string representation of the unit.

Attributes: pure

Returns: character(len=:)

fortran
function stringify(self, with_dimensions, with_aliases, protect_aliases, with_name, compact_reals) result(raw)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.
with_dimensionslogicalinoptionalFlag to activate dimensions printing.
with_aliaseslogicalinoptionalFlag to activate aliases printing.
protect_aliaseslogicalinoptionalFlag to activate aliases printing in protected mode.
with_namelogicalinoptionalFlag to activate name printing.
compact_realslogicalinoptionalFlag 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)

fortran
function to(self, other, magnitude) result(converted)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe uom.
othertype(uom)inOther unit used for conversion.
magnitudereal(kind=RKP)inMagnitude to be converted.

Call graph

has_alias ​

Check if the unit has an alias.

Attributes: elemental

Returns: logical

fortran
function has_alias(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.

Call graph

is_equal ​

Check if unit is equal (has the same references units) with another one.

Attributes: elemental

Returns: logical

fortran
function is_equal(self, other)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.
otherclass(uom)inThe 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

fortran
function is_not_equal(self, other)

Arguments

NameTypeIntentAttributesDescription
selfclass(uom)inThe unit.
otherclass(uom)inThe other unit.

Call graph

add ​

uom + uom operator.

Returns: type(uom)

fortran
function add(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsclass(uom)inRight hand side.

Call graph

div ​

uom / uom operator.

Returns: type(uom)

fortran
function div(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsclass(uom)inRight hand side.

Call graph

mul ​

uom * uom operator.

Returns: type(uom)

fortran
function mul(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsclass(uom)inRight hand side.

Call graph

sub ​

uom - uom operator.

Returns: type(uom)

fortran
function sub(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsclass(uom)inRight hand side.

Call graph

pow_R16P ​

uom ** real(R16P) operator.

Returns: type(uom)

fortran
function pow_R16P(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsreal(kind=R16P)inRight hand side.

Call graph

pow_R8P ​

uom ** real(R8P) operator.

Returns: type(uom)

fortran
function pow_R8P(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsreal(kind=R8P)inRight hand side.

Call graph

pow_R4P ​

uom ** real(R4P) operator.

Returns: type(uom)

fortran
function pow_R4P(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsreal(kind=R4P)inRight hand side.

Call graph

pow_I8P ​

uom ** integer(I8P) operator.

Returns: type(uom)

fortran
function pow_I8P(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsinteger(kind=I8P)inRight hand side.

Call graph

pow_I4P ​

uom ** integer(I4P) operator.

Returns: type(uom)

fortran
function pow_I4P(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsinteger(kind=I4P)inRight hand side.

Call graph

pow_I2P ​

uom ** integer(I2P) operator.

Returns: type(uom)

fortran
function pow_I2P(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsinteger(kind=I2P)inRight hand side.

Call graph

pow_I1P ​

uom ** integer(I1P) operator.

Returns: type(uom)

fortran
function pow_I1P(lhs, rhs) result(opr)

Arguments

NameTypeIntentAttributesDescription
lhsclass(uom)inLeft hand side.
rhsinteger(kind=I1P)inRight hand side.

Call graph

Released under GPL v3, BSD 2-Clause, BSD 3-Clause or MIT, at your choice.