Define SI and British units of measurement and associated arithmetic operators
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=*), | public, | parameter | :: | British_units_names(num_fundamental) | = | [character(len=len("sec"))::"R", "ft", "lbm", "sec"] | |
| character(len=*), | public, | parameter | :: | SI_units_names(num_fundamental) | = | [character(len=len("sec"))::"K", "m", "kg", "sec"] | |
| integer, | public, | parameter | :: | num_fundamental | = | 4 | |
| character(len=*), | public, | parameter | :: | units_system_names(num_systems) | = | [character(len=len("British"))::"SI", "British"] | |
| integer, | private, | parameter | :: | num_systems | = | 2 |
| enumerator | :: | K | = | 1 | |
| enumerator | :: | m | = | 2 | |
| enumerator | :: | kg | = | 3 | |
| enumerator | :: | sec | = | 4 | |
| enumerator | :: | R | = | 1 | |
| enumerator | :: | ft | = | 2 | |
| enumerator | :: | lbm | = | 3 | |
| enumerator | :: | dimensionless | = | 0 | |
| enumerator | :: | SI | = | 1 | |
| enumerator | :: | British | = | 2 |
Enumerate the fundamental units for dimensional units quantities (meters, kilograms, seconds, and degrees Kelvin)
result is the units of the sum of two dimensional quantities; includes operand consistency check
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | lhs | |||
| class(units), | intent(in) | :: | rhs |
result is the units of the ratio of two dimensional quantities; includes units-sysetm consistency check
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | numerator | |||
| class(units), | intent(in) | :: | denominator |
result is enumerated value designating units system
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
result holds the exponents of each unit in the argument (most useful when the actual argument is an expression)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match kilograms (kg/m^3)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match joules (J)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match meters (m)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match kilograms (kg)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match Watts (W)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match Joules per kilogram (J/kg)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match Newtons per square meter (N/m^2)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match degrees Kelvin (K)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match seconds (s)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if units match meters/second^2 (m/s^2)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
Return true if all units exponents are zero; false otherwise.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this |
result is the units of the product of two dimensional quantities; includes units-system consistency check
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | lhs | |||
| class(units), | intent(in) | :: | rhs |
result is the units of the operand raised to the power "exponent_"; includes check that operand is dimensionless
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | this | |||
| real, | intent(in) | :: | exponent_ |
define units
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(inout) | :: | this | |||
| integer, | intent(in) | :: | exponents(num_fundamental) | |||
| integer, | intent(in) | :: | system |
result is the units of the difference of two dimensional quantities; includes operand consistency check
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(units), | intent(in) | :: | lhs | |||
| class(units), | intent(in) | :: | rhs |
Morfeus universal base type for all units
| 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 |
| procedure, public :: add | |
| procedure, public :: assign_units | |
| generic, public :: assignment(=) => assign_units | |
| procedure, public :: divide | |
| procedure, public :: get_system | |
| procedure, public :: get_units | |
| procedure, public :: has_density_units | |
| procedure, public :: has_energy_units | |
| procedure, public :: has_length_units | |
| procedure, public :: has_mass_units | |
| procedure, public :: has_power_units | |
| procedure, public :: has_specific_energy_units | |
| procedure, public :: has_stress_units | |
| procedure, public :: has_temperature_units | |
| procedure, public :: has_time_units | |
| procedure, public :: has_velocity_units | |
| procedure, public :: integer_power | |
| procedure, public :: is_dimensionless | |
| procedure, public :: multiply | |
| procedure, public :: negate | |
| generic, public :: operator(*) => multiply | |
| generic, public :: operator(**) => integer_power, real_power | |
| generic, public :: operator(+) => add | |
| generic, public :: operator(-) => subtract, negate | |
| generic, public :: operator(/) => divide | |
| procedure, public :: real_power | |
| procedure, public :: set_units | |
| procedure, public :: subtract |