units Derived Type

type, public :: units

Morfeus universal base type for all units


Components

Type Visibility Attributes Name Initial
character(len=:), private, allocatable :: description
integer, private :: exponents_(num_fundamental) = dimensionless

Store the exponents for fundamental units

integer, private :: system = dimensionless

Default to SI units


Type-Bound Procedures

procedure, public :: add

  • interface

    private impure elemental module function add(lhs, rhs) result(total)

    result is the units of the sum of two dimensional quantities; includes operand consistency check

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: lhs
    class(units), intent(in) :: rhs

    Return Value type(units)

procedure, public :: assign_units

  • interface

    private pure module subroutine assign_units(lhs, rhs)

    copy units information

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(inout) :: lhs
    class(units), intent(in) :: rhs

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

procedure, public :: divide

  • interface

    private elemental module function divide(numerator, denominator) result(ratio)

    result is the units of the ratio of two dimensional quantities; includes units-sysetm consistency check

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: numerator
    class(units), intent(in) :: denominator

    Return Value type(units)

procedure, public :: get_system

  • interface

    private impure elemental module function get_system(this) result(system_of_units)

    result is enumerated value designating units system

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value integer

procedure, public :: get_units

  • interface

    private module function get_units(this) result(exponents)

    result holds the exponents of each unit in the argument (most useful when the actual argument is an expression)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value integer, (num_fundamental)

procedure, public :: has_density_units

  • interface

    private elemental module function has_density_units(this) result(density_units)

    Return true if units match kilograms (kg/m^3)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_energy_units

  • interface

    private elemental module function has_energy_units(this) result(energy_units)

    Return true if units match joules (J)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_length_units

  • interface

    private elemental module function has_length_units(this) result(length_units)

    Return true if units match meters (m)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_mass_units

  • interface

    private elemental module function has_mass_units(this) result(mass_units)

    Return true if units match kilograms (kg)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_power_units

  • interface

    private elemental module function has_power_units(this) result(power_units)

    Return true if units match Watts (W)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_specific_energy_units

  • interface

    private elemental module function has_specific_energy_units(this) result(specific_energy_units)

    Return true if units match Joules per kilogram (J/kg)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_stress_units

  • interface

    private elemental module function has_stress_units(this) result(stress_units)

    Return true if units match Newtons per square meter (N/m^2)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_temperature_units

  • interface

    private elemental module function has_temperature_units(this) result(temperature_units)

    Return true if units match degrees Kelvin (K)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_time_units

  • interface

    private elemental module function has_time_units(this) result(time_units)

    Return true if units match seconds (s)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: has_velocity_units

  • interface

    private elemental module function has_velocity_units(this) result(velocity_units)

    Return true if units match meters/second^2 (m/s^2)

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: integer_power

  • interface

    private impure elemental module function integer_power(this, exponent_) result(this_raised)

    result has units of the opearand raised to the power "exponent_"

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this
    integer, intent(in) :: exponent_

    Return Value type(units)

procedure, public :: is_dimensionless

  • interface

    private elemental module function is_dimensionless(this) result(nondimensional)

    Return true if all units exponents are zero; false otherwise.

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value logical

procedure, public :: multiply

  • interface

    private elemental module function multiply(lhs, rhs) result(product_)

    result is the units of the product of two dimensional quantities; includes units-system consistency check

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: lhs
    class(units), intent(in) :: rhs

    Return Value type(units)

procedure, public :: negate

  • interface

    private elemental module function negate(this) result(negative_this)

    result is the units of the negative of a dimensional quantities

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this

    Return Value type(units)

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

  • private interface multiply()

    Arguments

    None

generic, public :: operator(**) => integer_power, real_power

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

  • private interface add()

    Arguments

    None

generic, public :: operator(-) => subtract, negate

  • private interface subtract()

    Arguments

    None
  • private interface negate()

    Arguments

    None

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

  • private interface divide()

    Arguments

    None

procedure, public :: real_power

  • interface

    private impure elemental module function real_power(this, exponent_) result(this_raised)

    result is the units of the operand raised to the power "exponent_"; includes check that operand is dimensionless

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: this
    real, intent(in) :: exponent_

    Return Value type(units)

procedure, public :: set_units

  • interface

    private pure module subroutine set_units(this, exponents, system)

    define units

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(inout) :: this
    integer, intent(in) :: exponents(num_fundamental)
    integer, intent(in) :: system

procedure, public :: subtract

  • interface

    private impure elemental module function subtract(lhs, rhs) result(difference)

    result is the units of the difference of two dimensional quantities; includes operand consistency check

    Arguments

    Type IntentOptional Attributes Name
    class(units), intent(in) :: lhs
    class(units), intent(in) :: rhs

    Return Value type(units)