uom Derived Type

type, public :: uom

type~~uom~3~~InheritsGraph type~uom~3 uom type~uom_reference~3 uom_reference type~uom_reference~3->type~uom~3 alias, references type~uom_symbol~3 uom_symbol type~uom_symbol~3->type~uom_reference~3 aliases, dimensions type~uom_converter uom_converter type~uom_converter->type~uom_symbol~3 convert_ type~string string type~string->type~uom_symbol~3 symbol_
Help


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;

Inherited By

type~~uom~3~~InheritedByGraph type~uom~3 uom type~qreal~3 qreal type~uom~3->type~qreal~3 unit type~system_si~3 system_si type~uom~3->type~system_si~3 units type~system_abstract~3 system_abstract type~uom~3->type~system_abstract~3 units type~qreal~3->type~system_si~3 constants type~qreal~3->type~system_abstract~3 constants type~system_abstract~3->type~system_si~3
Help

Components

TypeVisibility AttributesNameInitial
character(len=:), public, allocatable:: name

Unit name.

type(uom_reference), private, allocatable:: alias

Alias of the unit, e.g Pa (kg.m-1.s-2) for Pascal.

type(uom_reference), private, allocatable:: references(:)

Reference units of the unit.

integer(kind=I_P), private :: references_number =0_I_P

References number.


Constructor

public interface uom

Ovearloading uom name with a set of creator functions.

  • private function creator_from_string(source, alias, name) result(unit)

    Create an instance of uom from an input source string.

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: source

    Source input string definition of the unit.

    type(uom_reference), intent(in), optional :: alias

    Alias of the unit, e.g Pa (kg.m-1.s-2) for Pascal [pressure].

    character(len=*), intent(in), optional :: name

    Unit name.

    Return Value type(uom)

    The unit.


Type-Bound Procedures

procedure, public, pass(self) :: get_alias

Return the alias.

  • private pure subroutine get_alias(self, alias)

    Return the alias.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The uom.

    type(uom_reference), intent(out) :: alias

    Uom main alias.

procedure, public, pass(self) :: get_main_reference

Return the main reference.

  • private pure function get_main_reference(self) result(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.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The uom.

    Return Value type(uom_reference)

    Main uom reference.

procedure, public, pass(self) :: get_main_symbol

Return the main symbol.

  • private function get_main_symbol(self) result(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.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The uom.

    Return Value type(string)

    Main alias symbol.

procedure, public, pass(self) :: get_references

Return the references.

  • private pure subroutine get_references(self, references)

    Return the references.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The uom.

    type(uom_reference), intent(out), allocatable:: references(:)

    Uom references.

procedure, public, pass(self) :: has_alias

Check if the unit has an alias.

  • private elemental function has_alias(self)

    Check if the unit has an alias.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    Return Value logical

    Check result.

procedure, public, pass(self) :: has_name

Check if the unit has a name.

  • private elemental function has_name(self)

    Check if the unit has a name.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    Return Value logical

    Name presence status.

procedure, public, pass(self) :: has_reference

Check if the unit has a queried reference unit.

  • private elemental function has_reference(self, reference)

    Check if the unit has a queried reference unit.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    type(uom_reference), intent(in) :: reference

    Reference unit to check the presence of.

    Return Value logical

    reference unit presence status.

procedure, public, pass(self) :: is_defined

Check if the unit is defined.

  • private elemental function is_defined(self)

    Check if the unit has been defined, namely it has defined references.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    Return Value logical

    Definition status.

procedure, public, pass(self) :: prefixed

Return prefixed unit.

  • private function prefixed(self, prefixes)

    Return prefixed unit.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    type(uom_reference), intent(in) :: prefixes

    Prefixes data.

    Return Value type(uom)

    Prefixed unit.

procedure, public, pass(self) :: set

Set the unit.

  • private pure subroutine set(self, references, alias, name)

    Set the unit.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

    type(uom_reference), intent(in), optional :: references(1:)

    Unit references of the unit.

    type(uom_reference), intent(in), optional :: alias

    Alias of the unit, e.g Pa (kg.m-1.s-2) for Pascal [pressure].

    character(len=*), intent(in), optional :: name

    Unit name.

procedure, public, pass(self) :: set_alias_conversion

Set alias conversion formula.

  • private pure subroutine set_alias_conversion(self, reference_index, alias_index, convert)

    Set alias conversion formula.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The uom reference.

    integer(kind=I_P), intent(in) :: reference_index

    Index of the reference to which set the conversion formula.

    integer(kind=I_P), intent(in) :: alias_index

    Index of the alias to which set the conversion formula.

    class(uom_converter), intent(in) :: convert

    Generic conversion alias formula user-supplied.

procedure, public, pass(self) :: stringify

Return a string representation of the unit.

  • private pure function stringify(self, with_dimensions, with_aliases, protect_aliases, with_name, compact_reals) result(raw)

    Return a string representation of the unit.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    logical, intent(in), optional :: with_dimensions

    Flag to activate dimensions printing.

    logical, intent(in), optional :: with_aliases

    Flag to activate aliases printing.

    logical, intent(in), optional :: protect_aliases

    Flag to activate aliases printing in protected mode.

    logical, intent(in), optional :: with_name

    Flag to activate name printing.

    logical, intent(in), optional :: compact_reals

    Flag to activate real numbers compacting.

    Return Value character(len=:), allocatable

    Raw characters data.

procedure, public, pass(self) :: to

Convert magnitude with respect another unit.

  • private elemental function to(self, other, magnitude) result(converted)

    Convert magnitude with respect another unit.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The uom.

    type(uom), intent(in) :: other

    Other unit used for conversion.

    real(kind=RKP), intent(in) :: magnitude

    Magnitude to be converted.

    Return Value real(kind=RKP)

    Converted magnitude.

procedure, public, pass(self) :: unset

unset the unit.

  • private elemental subroutine unset(self)

    Unset the unit.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

generic, public :: assignment(=) => assign_uom

Overloading = operator.

  • private subroutine assign_uom(lhs, rhs)

    uom = uom assignment.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

generic, public :: operator(+) => add

Overloading + operator.

  • private function add(lhs, rhs) result(opr)

    uom + uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

generic, public :: operator(/) => div

Overloading / operator.

  • private function div(lhs, rhs) result(opr)

    uom / uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

generic, public :: operator(*) => mul

Overloading * operator.

  • private function mul(lhs, rhs) result(opr)

    uom * uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

generic, public :: operator(-) => sub

Overloading - operator.

  • private function sub(lhs, rhs) result(opr)

    uom - uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

generic, public :: operator(**) => pow_R8P, pow_R4P, pow_I8P, pow_I4P, pow_I2P, pow_I1P

Overloading ** operator.

  • private function pow_R8P(lhs, rhs) result(opr)

    uom ** real(R8P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    real(kind=R8P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

  • private function pow_R4P(lhs, rhs) result(opr)

    uom ** real(R4P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    real(kind=R4P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

  • private function pow_I8P(lhs, rhs) result(opr)

    uom ** integer(I8P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I8P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

  • private function pow_I4P(lhs, rhs) result(opr)

    uom ** integer(I4P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I4P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

  • private function pow_I2P(lhs, rhs) result(opr)

    uom ** integer(I2P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I2P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

  • private function pow_I1P(lhs, rhs) result(opr)

    uom ** integer(I1P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I1P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

generic, public :: operator(==) => is_equal

Overloading == operator.

  • private elemental function is_equal(self, other)

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

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    class(uom), intent(in) :: other

    The other unit.

    Return Value logical

    Check result.

procedure, private, pass(self) :: add_reference

Add a reference unit to unit.

  • private elemental subroutine add_reference(self, reference)

    Add reference unit to unit.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

    type(uom_reference), intent(in) :: reference

    Unit reference to be added.

procedure, private, pass(self) :: is_equal

Check if unit is equal with another one.

  • private elemental function is_equal(self, other)

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

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: self

    The unit.

    class(uom), intent(in) :: other

    The other unit.

    Return Value logical

    Check result.

procedure, private, pass(self) :: parse

Parse unit definition from an input string.

  • private subroutine parse(self, source)

    Parse unit definition form an input string.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

    character(len=*), intent(in) :: source

    Input source string.

procedure, private, pass(self) :: parse_alias

Parse unit alias from an input string.

  • private subroutine parse_alias(self, source)

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

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

    type(string), intent(inout) :: source

    Input source string.

procedure, private, pass(self) :: parse_name

Parse unit name from an input string.

  • private subroutine parse_name(self, source)

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

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

    type(string), intent(inout) :: source

    Input source string.

procedure, private, pass(self) :: parse_references

Parse reference units from an input string.

  • private subroutine parse_references(self, source)

    Parse references units form an input string.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

    type(string), intent(in) :: source

    Input source string.

procedure, private, pass(self) :: update_references_number

Update reference units number counter.

  • private elemental subroutine update_references_number(self)

    Update references number counter.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: self

    The unit.

procedure, private, pass(lhs) :: assign_uom

uom = uom assignment.

  • private subroutine assign_uom(lhs, rhs)

    uom = uom assignment.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(inout) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

procedure, private, pass(lhs) :: add

uom + uom operator.

  • private function add(lhs, rhs) result(opr)

    uom + uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: div

uom / uom operator.

  • private function div(lhs, rhs) result(opr)

    uom / uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: mul

uom * uom operator.

  • private function mul(lhs, rhs) result(opr)

    uom * uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: sub

uom - uom operator.

  • private function sub(lhs, rhs) result(opr)

    uom - uom operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    class(uom), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: pow_R16P

uom ** real(R16P) operator.

  • private function pow_R16P(lhs, rhs) result(opr)

    uom ** real(R16P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    real(kind=R16P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: pow_R8P

uom ** real(R8P) operator.

  • private function pow_R8P(lhs, rhs) result(opr)

    uom ** real(R8P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    real(kind=R8P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: pow_R4P

uom ** real(R4P) operator.

  • private function pow_R4P(lhs, rhs) result(opr)

    uom ** real(R4P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    real(kind=R4P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: pow_I8P

uom ** integer(I8P) operator.

  • private function pow_I8P(lhs, rhs) result(opr)

    uom ** integer(I8P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I8P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: pow_I4P

uom ** integer(I4P) operator.

  • private function pow_I4P(lhs, rhs) result(opr)

    uom ** integer(I4P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I4P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: pow_I2P

uom ** integer(I2P) operator.

  • private function pow_I2P(lhs, rhs) result(opr)

    uom ** integer(I2P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I2P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.

procedure, private, pass(lhs) :: pow_I1P

uom ** integer(I1P) operator.

  • private function pow_I1P(lhs, rhs) result(opr)

    uom ** integer(I1P) operator.

    Arguments

    Type IntentOptional AttributesName
    class(uom), intent(in) :: lhs

    Left hand side.

    integer(kind=I1P), intent(in) :: rhs

    Right hand side.

    Return Value type(uom)

    Operator result.