Documentation for module cp_units

unit conversion facility

source: cp_units.F
Loading...

public Types:

cp_unit_type
stores a unit
cp_unit_set_type
stores the default units to be used

public Subroutines/Functions:

FUNCTION
LOGICAL
cp_unit_compatible (ref_unit, unit)
returs true if the two units are compatible
SUBROUTINE
cp_unit_create (unit, string)
creates a unit parsing a string
returns the "name" of the given unit
converts from the internal cp2k units to the given unit
converts from the internal cp2k units to the given unit
SUBROUTINE
cp_unit_release (unit)
releases the given unit
SUBROUTINE
cp_unit_retain (unit)
retains the given unit
initializes the given unit set
releases the given unit set
converts to the internal cp2k units to the given unit
tranform a value to the internal cp2k units
Prints info on all available units in CP2K

Parameters:

INTEGER
:: cp_ukind_angle = 4
INTEGER
:: cp_ukind_energy = 1
INTEGER
:: cp_ukind_force = 10
INTEGER
:: cp_ukind_length = 2
INTEGER
:: cp_ukind_mass = 7
INTEGER
:: cp_ukind_max = 10
INTEGER
:: cp_ukind_none = 0
INTEGER
:: cp_ukind_potential = 9
INTEGER
:: cp_ukind_pressure = 5
INTEGER
:: cp_ukind_temperature = 3
INTEGER
:: cp_ukind_time = 6
INTEGER
:: cp_ukind_undef = 8
INTEGER
:: cp_units_amu = 111
INTEGER
:: cp_units_angstrom = 141
INTEGER
:: cp_units_atm = 162
INTEGER
:: cp_units_au = 101
INTEGER
:: cp_units_bar = 161
INTEGER
:: cp_units_bohr = 140
INTEGER
:: cp_units_deg = 171
INTEGER
:: cp_units_ev = 135
INTEGER
:: cp_units_fs = 180
INTEGER
:: cp_units_gpa = 166
INTEGER
:: cp_units_hartree = 130
INTEGER
:: cp_units_jmol = 137
INTEGER
:: cp_units_joule = 132
INTEGER
:: cp_units_k = 150
INTEGER
:: cp_units_kbar = 163
INTEGER
:: cp_units_kcalmol = 133
INTEGER
:: cp_units_kev = 138
INTEGER
:: cp_units_kg = 112
INTEGER
:: cp_units_kjmol = 136
INTEGER
:: cp_units_m = 142
INTEGER
:: cp_units_mnewton = 201
INTEGER
:: cp_units_mpa = 165
INTEGER
:: cp_units_m_e = 110
INTEGER
:: cp_units_newton = 200
INTEGER
:: cp_units_nm = 144
INTEGER
:: cp_units_none = 100
INTEGER
:: cp_units_pa = 164
INTEGER
:: cp_units_pm = 143
INTEGER
:: cp_units_ps = 183
INTEGER
:: cp_units_rad = 170
INTEGER
:: cp_units_ry = 134
INTEGER
:: cp_units_s = 181
INTEGER
:: cp_units_volt = 190
INTEGER
:: cp_units_wavenum = 131
INTEGER
:: cp_units_wn = 182
INTEGER
:: cp_unit_basic_desc_length = 15
INTEGER
:: cp_unit_desc_length = cp_unit_max_kinds*cp_unit_basic_desc_length
INTEGER
:: cp_unit_max_kinds = 8

public Types:

TYPE :: cp_unit_set_type

stores the default units to be used


INTEGER
:: id_nr ...
INTEGER
:: ref_count ...
DIMENSION(CP_UKIND_MAX) :: units ...

TYPE :: cp_unit_type

stores a unit


INTEGER
:: id_nr identification number (unique for each instance)
INTEGER
:: ref_count the reference count (see doc/ReferenceCounting.html)
INTEGER
:: n_kinds ...
INTEGER,
DIMENSION(CP_UNIT_MAX_KINDS) :: kind_id ...
INTEGER,
DIMENSION(CP_UNIT_MAX_KINDS) :: unit_id ...
INTEGER,
DIMENSION(CP_UNIT_MAX_KINDS) :: power ...

FUNCTIONcp_unit_compatible(ref_unit, unit)

returs true if the two units are compatible

Return Value ::
LOGICAL
Arguments:
POINTER
:: ref_unit ...
POINTER
:: unit ...

SUBROUTINEcp_unit_create(unit, string)

creates a unit parsing a string

Arguments:
POINTER
:: unit the unit to initialize
CHARACTER(*),
INTENT(in)
:: string the string containing the description of the unit

FUNCTIONcp_unit_desc(unit, defaults, accept_undefined)

returns the "name" of the given unit

Return Value ::
Arguments:
POINTER
:: unit the unit to describe
OPTIONAL, POINTER
:: defaults defaults for the undefined units, optional
LOGICAL,
INTENT(in),
OPTIONAL
:: accept_undefined if defaults is not present or is not associated whether undefined units should be accepted (defaults to false)

FUNCTIONcp_unit_from_cp2k(value, unit_str, defaults, power)

converts from the internal cp2k units to the given unit

Return Value ::
REAL(dp)
Arguments:
REAL(dp),
INTENT(in)
:: value the value to convert
CHARACTER(*),
INTENT(in)
:: unit_str the unit of the result as string
OPTIONAL, POINTER
:: defaults the defaults unit for those that are left free (cp_units_none)
INTEGER,
INTENT(in),
OPTIONAL
:: power the power of the unit (defaults to 1)

FUNCTIONcp_unit_from_cp2k1(value, unit, defaults, power)

converts from the internal cp2k units to the given unit

Return Value ::
REAL(dp)
Arguments:
REAL(dp),
INTENT(in)
:: value the value to convert
POINTER
:: unit the unit of the result
OPTIONAL, POINTER
:: defaults the defaults unit for those that are left free (cp_units_none)
INTEGER,
INTENT(in),
OPTIONAL
:: power the power of the unit (defaults to 1)

SUBROUTINEcp_unit_release(unit)

releases the given unit

Arguments:
POINTER
:: unit the unit to release

SUBROUTINEcp_unit_retain(unit)

retains the given unit

Arguments:
POINTER
:: unit the unit to retain

SUBROUTINEcp_unit_set_create(unit_set, name)

initializes the given unit set

Arguments:
POINTER
:: unit_set the set to initialize
CHARACTER(*),
INTENT(in)
:: name the name of the set, used for the dafault initialization of the various units

SUBROUTINEcp_unit_set_release(unit_set)

releases the given unit set

Arguments:
POINTER
:: unit_set the unit set to release

FUNCTIONcp_unit_to_cp2k(value, unit_str, defaults, power)

converts to the internal cp2k units to the given unit

Return Value ::
REAL(dp)
Arguments:
REAL(dp),
INTENT(in)
:: value the value to convert
CHARACTER(*),
INTENT(in)
:: unit_str the unit of the result as string
OPTIONAL, POINTER
:: defaults the defaults unit for those that are left free (cp_units_none)
INTEGER,
INTENT(in),
OPTIONAL
:: power the power of the unit (defaults to 1)

FUNCTIONcp_unit_to_cp2k1(value, unit, defaults, power)

tranform a value to the internal cp2k units

Return Value ::
REAL(dp)
Arguments:
REAL(dp),
INTENT(in)
:: value the value to convert
POINTER
:: unit the unit of the result
OPTIONAL, POINTER
:: defaults the defaults unit for those that are left free (cp_units_none)
INTEGER,
INTENT(in),
OPTIONAL
:: power the power of the unit (defaults to 1)

private Parameters/Types:

private Types:

TYPE :: cp_unit_p_type

represent a pointer to a unit (to build arrays of pointers)


POINTER :: unit the pointer to the unit