37 a_bohr,
atm,
bar,
bohr,
debye,
e_charge,
e_mass,
evolt,
femtoseconds,
joule,
kcalmol, &
42#include "../base/base_uses.f90"
47 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
48 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_units'
144 INTEGER :: n_kinds = -1
145 INTEGER,
DIMENSION(cp_unit_max_kinds):: kind_id = -1, unit_id = -1, power = -1
155 END TYPE cp_unit_p_type
162 TYPE(cp_unit_p_type),
DIMENSION(cp_ukind_max) :: units = cp_unit_p_type()
175 CHARACTER(len=*),
INTENT(in) :: string
177 CHARACTER(LEN=40) :: formatstr
178 CHARACTER(LEN=cp_unit_desc_length) :: desc
179 CHARACTER(LEN=LEN(string)) :: unit_string
180 INTEGER :: i_high, i_low, i_unit, len_string, &
182 INTEGER,
DIMENSION(cp_unit_max_kinds) :: kind_id, power, unit_id
189 len_string = len(string)
192 DO WHILE (i_low < len_string)
193 IF (string(i_low:i_low) /=
' ')
EXIT
197 DO WHILE (i_high <= len_string)
198 IF (string(i_high:i_high) ==
' ' .OR. string(i_high:i_high) ==
'^' .OR. &
199 string(i_high:i_high) ==
'*' .OR. string(i_high:i_high) ==
'/')
EXIT
203 IF (i_high <= i_low .OR. i_low > len_string)
EXIT
206 cpabort(
"Maximum number of combined units exceeded")
210 unit_string = string(i_low:i_high - 1)
212 SELECT CASE (trim(unit_string))
213 CASE (
"INTERNAL_CP2K")
222 CASE (
"WAVENUMBER_E")
324 CASE (
"WAVENUMBER_T")
360 CASE (
"MN",
"MNEWTON")
369 CASE (
"VM-1",
"VOLT_PER_M")
372 CASE (
"VNM-1",
"VOLT_PER_NM")
375 CASE (
"VA-1",
"VOLT_PER_ANGSTROM")
400 CALL cp_abort(__location__, &
401 "au unit without specifying its kind not accepted, use "// &
402 "(au_e, au_f, au_t, au_temp, au_l, au_m, au_p, au_pot, "// &
403 "au_efield, au_dip)")
405 cpabort(
"Unknown unit: "//string(i_low:i_high - 1))
407 power(i_unit) = next_power
410 DO WHILE (i_low <= len_string)
411 IF (string(i_low:i_low) /=
' ')
EXIT
415 DO WHILE (i_high <= len_string)
416 IF (string(i_high:i_high) ==
' ' .OR. string(i_high:i_high) ==
'^' .OR. &
417 string(i_high:i_high) ==
'*' .OR. string(i_high:i_high) ==
'/')
EXIT
420 IF (i_high < i_low .OR. i_low > len_string)
EXIT
422 IF (i_high <= len_string)
THEN
423 IF (string(i_low:i_high) ==
'^')
THEN
425 DO WHILE (i_low <= len_string)
426 IF (string(i_low:i_low) /=
' ')
EXIT
430 DO WHILE (i_high <= len_string)
431 SELECT CASE (string(i_high:i_high))
432 CASE (
'+',
'-',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9')
438 IF (i_high <= i_low .OR. i_low > len_string)
THEN
439 cpabort(
"an integer number is expected after a '^'")
443 READ (string(i_low:i_high - 1), formatstr) &
445 power(i_unit) = power(i_unit)*next_power
448 DO WHILE (i_low < len_string)
449 IF (string(i_low:i_low) /=
' ')
EXIT
453 DO WHILE (i_high <= len_string)
454 IF (string(i_high:i_high) ==
' ' .OR. string(i_high:i_high) ==
'^' .OR. &
455 string(i_high:i_high) ==
'*' .OR. string(i_high:i_high) ==
'/')
EXIT
460 IF (i_low > len_string)
EXIT
462 IF (i_high <= len_string)
THEN
463 IF (string(i_low:i_high) ==
"*" .OR. string(i_low:i_high) ==
'/')
THEN
464 IF (string(i_low:i_high) ==
'/') next_power = -1
466 DO WHILE (i_low <= len_string)
467 IF (string(i_low:i_low) /=
' ')
EXIT
471 DO WHILE (i_high <= len_string)
472 IF (string(i_high:i_high) ==
' ' .OR. string(i_high:i_high) ==
'^' .OR. &
473 string(i_high:i_high) ==
'*' .OR. string(i_high:i_high) ==
'/')
EXIT
479 CALL cp_unit_create2(unit, kind_id=kind_id, unit_id=unit_id, &
494 SUBROUTINE cp_unit_create2(unit, kind_id, unit_id, power)
496 INTEGER,
DIMENSION(:),
INTENT(in) :: kind_id, unit_id
497 INTEGER,
DIMENSION(:),
INTENT(in),
OPTIONAL :: power
499 INTEGER :: i, j, max_kind, max_pos
504 unit%kind_id(1:
SIZE(kind_id)) = kind_id
506 unit%unit_id(1:
SIZE(unit_id)) = unit_id
508 IF (
PRESENT(power))
THEN
509 unit%power(1:
SIZE(power)) = power
510 unit%power(
SIZE(power) + 1:) = 0
511 DO i = 1,
SIZE(unit%power)
512 IF (unit%power(i) == 0)
THEN
518 DO i = 1,
SIZE(unit%power)
519 IF (unit%unit_id(i) /= 0)
THEN
530 DO i = 1,
SIZE(unit%kind_id)
533 max_kind = unit%kind_id(i)
536 DO j = i + 1,
SIZE(unit%kind_id)
537 IF (unit%kind_id(j) >= max_kind)
THEN
538 IF (unit%kind_id(j) /= 0 .AND. unit%kind_id(j) == max_kind .AND. &
539 unit%unit_id(j) == unit%unit_id(max_pos))
THEN
540 unit%power(max_pos) = unit%power(max_pos) + unit%power(j)
544 IF (unit%power(max_pos) == 0)
THEN
547 unit%power(max_pos) = 0
551 ELSE IF (unit%kind_id(j) > max_kind .OR. &
552 (unit%kind_id(j) == max_kind .AND. &
553 unit%unit_id(j) > unit%unit_id(max_pos)))
THEN
554 max_kind = unit%kind_id(j)
559 IF (.NOT. repeat)
EXIT
561 IF (max_kind /= 0) unit%n_kinds = unit%n_kinds + 1
563 IF (max_pos /= i)
THEN
564 unit%kind_id(max_pos) = unit%kind_id(i)
565 unit%kind_id(i) = max_kind
566 max_kind = unit%unit_id(max_pos)
567 unit%unit_id(max_pos) = unit%unit_id(i)
568 unit%unit_id(i) = max_kind
569 max_kind = unit%power(max_pos)
570 unit%power(max_pos) = unit%power(i)
571 unit%power(i) = max_kind
574 CALL cp_basic_unit_check(basic_kind=unit%kind_id(i), &
575 basic_unit=unit%unit_id(i))
577 END SUBROUTINE cp_unit_create2
599 SUBROUTINE cp_basic_unit_check(basic_kind, basic_unit)
600 INTEGER,
INTENT(in) :: basic_kind, basic_unit
602 SELECT CASE (basic_kind)
604 SELECT CASE (basic_unit)
607 cpabort(
"unknown undef unit:"//trim(
cp_to_string(basic_unit)))
610 SELECT CASE (basic_unit)
615 cpabort(
"unknown energy unit:"//trim(
cp_to_string(basic_unit)))
618 SELECT CASE (basic_unit)
622 cpabort(
"unknown length unit:"//trim(
cp_to_string(basic_unit)))
625 SELECT CASE (basic_unit)
628 cpabort(
"unknown temperature unit:"//trim(
cp_to_string(basic_unit)))
631 SELECT CASE (basic_unit)
634 cpabort(
"unknown pressure unit:"//trim(
cp_to_string(basic_unit)))
637 SELECT CASE (basic_unit)
640 cpabort(
"unknown angle unit:"//trim(
cp_to_string(basic_unit)))
643 SELECT CASE (basic_unit)
646 cpabort(
"unknown time unit:"//trim(
cp_to_string(basic_unit)))
649 SELECT CASE (basic_unit)
652 cpabort(
"unknown mass unit:"//trim(
cp_to_string(basic_unit)))
655 SELECT CASE (basic_unit)
658 cpabort(
"unknown potential unit:"//trim(
cp_to_string(basic_unit)))
661 SELECT CASE (basic_unit)
664 cpabort(
"unknown force unit:"//trim(
cp_to_string(basic_unit)))
667 SELECT CASE (basic_unit)
671 cpabort(
"unknown electric field unit:"//trim(
cp_to_string(basic_unit)))
674 SELECT CASE (basic_unit)
677 cpabort(
"unknown dipole unit:"//trim(
cp_to_string(basic_unit)))
681 CALL cp_abort(__location__, &
682 "if the kind of the unit is none also unit must be undefined,not:" &
686 cpabort(
"unknown kind of unit:"//trim(
cp_to_string(basic_kind)))
688 END SUBROUTINE cp_basic_unit_check
699 FUNCTION cp_basic_unit_to_cp2k(value, basic_kind, basic_unit, power)
RESULT(res)
700 REAL(kind=
dp),
INTENT(in) ::
value
701 INTEGER,
INTENT(in) :: basic_kind, basic_unit
702 INTEGER,
INTENT(in),
OPTIONAL :: power
708 IF (
PRESENT(power)) my_power = power
711 CALL cp_abort(__location__, &
712 "unit not yet fully specified, unit of kind "// &
716 SELECT CASE (basic_kind)
718 SELECT CASE (basic_unit)
722 cpabort(
"unknown energy unit:"//trim(
cp_to_string(basic_unit)))
725 SELECT CASE (basic_unit)
731 res =
joule**(-my_power)*
value
733 res =
kcalmol**(-my_power)*
value
735 res =
kjmol**(-my_power)*
value
737 res = (
kjmol*1.0e+3_dp)**(-my_power)*
value
739 res = 0.5_dp**my_power*
value
741 res =
evolt**(-my_power)*
value
743 res = (1.0e-3_dp*
evolt)**(-my_power)*
value
745 res =
kelvin**(-my_power)*
value
747 cpabort(
"unknown energy unit:"//trim(
cp_to_string(basic_unit)))
750 SELECT CASE (basic_unit)
754 res =
value*(1.0e10_dp*
bohr)**my_power
756 res =
value*(0.01_dp*
bohr)**my_power
758 res =
value*(10.0_dp*
bohr)**my_power
760 res =
value*
bohr**my_power
762 cpabort(
"unknown length unit:"//trim(
cp_to_string(basic_unit)))
765 SELECT CASE (basic_unit)
767 res =
kelvin**(-my_power)*
value
771 cpabort(
"unknown temperature unit:"//trim(
cp_to_string(basic_unit)))
774 SELECT CASE (basic_unit)
776 res =
bar**(-my_power)*
value
778 res =
atm**(-my_power)*
value
780 res = (1.0e-3_dp*
bar)**(-my_power)*
value
782 res =
pascal**(-my_power)*
value
784 res = (1.0e-6_dp*
pascal)**(-my_power)*
value
786 res = (1.0e-9_dp*
pascal)**(-my_power)*
value
790 cpabort(
"unknown pressure unit:"//trim(
cp_to_string(basic_unit)))
793 SELECT CASE (basic_unit)
797 res =
value*(
radians)**my_power
799 cpabort(
"unknown angle unit:"//trim(
cp_to_string(basic_unit)))
802 SELECT CASE (basic_unit)
804 res =
value*
seconds**(-my_power)
814 cpabort(
"unknown time unit:"//trim(
cp_to_string(basic_unit)))
817 SELECT CASE (basic_unit)
819 res =
e_mass**my_power*
value
825 cpabort(
"unknown mass unit:"//trim(
cp_to_string(basic_unit)))
828 SELECT CASE (basic_unit)
830 res =
evolt**(-my_power)*
value
834 cpabort(
"unknown potential unit:"//trim(
cp_to_string(basic_unit)))
837 SELECT CASE (basic_unit)
839 res =
value*
newton**(-my_power)
841 res =
value*(1.0e+3_dp*
newton)**(-my_power)
845 cpabort(
"unknown force unit:"//trim(
cp_to_string(basic_unit)))
848 SELECT CASE (basic_unit)
850 res = (1.0e+10_dp*
evolt*
bohr)**(-my_power)*
value
852 res = (10.0_dp*
evolt*
bohr)**(-my_power)*
value
858 cpabort(
"unknown electric field unit:"//trim(
cp_to_string(basic_unit)))
861 SELECT CASE (basic_unit)
863 res =
debye**(-my_power)*
value
865 res =
value*
bohr**my_power
871 cpabort(
"unknown dipole unit:"//trim(
cp_to_string(basic_unit)))
874 CALL cp_abort(__location__, &
875 "if the kind of the unit is none also unit must be undefined,not:" &
878 cpabort(
"unknown kind of unit:"//trim(
cp_to_string(basic_kind)))
880 END FUNCTION cp_basic_unit_to_cp2k
891 FUNCTION cp_basic_unit_desc(basic_kind, basic_unit, power, accept_undefined) &
893 INTEGER,
INTENT(in) :: basic_kind, basic_unit
894 INTEGER,
INTENT(in),
OPTIONAL :: power
895 LOGICAL,
INTENT(in),
OPTIONAL :: accept_undefined
896 CHARACTER(len=cp_unit_basic_desc_length) :: res
898 INTEGER :: a, my_power
899 LOGICAL :: my_accept_undefined
903 my_accept_undefined = .false.
904 IF (accept_undefined) my_accept_undefined = accept_undefined
905 IF (
PRESENT(power)) my_power = power
907 IF (.NOT. my_accept_undefined .AND. basic_kind ==
cp_units_none)
THEN
908 CALL cp_abort(__location__,
"unit not yet fully specified, unit of kind "// &
912 SELECT CASE (basic_kind)
914 SELECT CASE (basic_unit)
916 res =
"internal_cp2k"
918 CALL cp_abort(__location__, &
919 "unit not yet fully specified, unit of kind "// &
923 SELECT CASE (basic_unit)
946 IF (.NOT. my_accept_undefined)
THEN
947 CALL cp_abort(__location__, &
948 "unit not yet fully specified, unit of kind "// &
952 cpabort(
"unknown energy unit:"//trim(
cp_to_string(basic_unit)))
955 SELECT CASE (basic_unit)
968 cpabort(
"unknown length unit:"//trim(
cp_to_string(basic_unit)))
971 SELECT CASE (basic_unit)
978 IF (.NOT. my_accept_undefined)
THEN
979 CALL cp_abort(__location__, &
980 "unit not yet fully specified, unit of kind "// &
984 cpabort(
"unknown temperature unit:"//trim(
cp_to_string(basic_unit)))
987 SELECT CASE (basic_unit)
1004 IF (.NOT. my_accept_undefined)
THEN
1005 CALL cp_abort(__location__, &
1006 "unit not yet fully specified, unit of kind "// &
1010 cpabort(
"unknown pressure unit:"//trim(
cp_to_string(basic_unit)))
1013 SELECT CASE (basic_unit)
1020 IF (.NOT. my_accept_undefined)
THEN
1021 CALL cp_abort(__location__, &
1022 "unit not yet fully specified, unit of kind "// &
1026 cpabort(
"unknown angle unit:"//trim(
cp_to_string(basic_unit)))
1029 SELECT CASE (basic_unit)
1039 res =
"wavenumber_t"
1042 IF (.NOT. my_accept_undefined)
THEN
1043 CALL cp_abort(__location__, &
1044 "unit not yet fully specified, unit of kind "// &
1048 cpabort(
"unknown time unit:"//trim(
cp_to_string(basic_unit)))
1051 SELECT CASE (basic_unit)
1060 IF (.NOT. my_accept_undefined)
THEN
1061 CALL cp_abort(__location__, &
1062 "unit not yet fully specified, unit of kind "// &
1066 cpabort(
"unknown mass unit:"//trim(
cp_to_string(basic_unit)))
1069 SELECT CASE (basic_unit)
1076 IF (.NOT. my_accept_undefined)
THEN
1077 CALL cp_abort(__location__, &
1078 "unit not yet fully specified, unit of kind "// &
1082 cpabort(
"unknown potential unit:"//trim(
cp_to_string(basic_unit)))
1085 SELECT CASE (basic_unit)
1094 IF (.NOT. my_accept_undefined)
THEN
1095 CALL cp_abort(__location__, &
1096 "unit not yet fully specified, unit of kind "// &
1100 cpabort(
"unknown potential unit:"//trim(
cp_to_string(basic_unit)))
1103 SELECT CASE (basic_unit)
1113 res =
"electric field"
1114 IF (.NOT. my_accept_undefined)
THEN
1115 CALL cp_abort(__location__, &
1116 "unit not yet fully specified, unit of kind "// &
1120 cpabort(
"unknown efield unit:"//trim(
cp_to_string(basic_unit)))
1123 SELECT CASE (basic_unit)
1134 IF (.NOT. my_accept_undefined)
THEN
1135 CALL cp_abort(__location__, &
1136 "unit not yet fully specified, unit of kind "// &
1140 cpabort(
"unknown dipole unit:"//trim(
cp_to_string(basic_unit)))
1143 CALL cp_abort(__location__, &
1144 "if the kind of the unit is none also unit must be undefined,not:" &
1147 cpabort(
"unknown kind of unit:"//trim(
cp_to_string(basic_kind)))
1149 IF (my_power /= 1)
THEN
1151 cpassert(len(res) - a >= 3)
1152 WRITE (res(a + 1:),
"('^',i3)") my_power
1155 END FUNCTION cp_basic_unit_desc
1170 LOGICAL,
INTENT(in),
OPTIONAL :: accept_undefined
1171 CHARACTER(len=cp_unit_desc_length) :: res
1173 INTEGER :: i, my_unit, pos
1174 LOGICAL :: check, has_defaults, my_accept_undefined
1178 my_accept_undefined = .false.
1179 IF (
PRESENT(accept_undefined)) my_accept_undefined = accept_undefined
1180 DO i = 1, unit%n_kinds
1181 cpassert(unit%kind_id(i) /= 0)
1182 cpassert(pos < len(res))
1183 my_unit = unit%unit_id(i)
1184 has_defaults = .false.
1185 IF (
PRESENT(defaults)) has_defaults =
ASSOCIATED(defaults%units(1)%unit)
1186 IF (my_unit == 0)
THEN
1187 IF (has_defaults)
THEN
1188 my_unit = defaults%units(unit%kind_id(i))%unit%unit_id(1)
1190 check = my_accept_undefined .OR. unit%kind_id(i) /= 0
1198 res(pos:) = trim(cp_basic_unit_desc(basic_kind=unit%kind_id(i), &
1199 basic_unit=my_unit, accept_undefined=my_accept_undefined, &
1200 power=unit%power(i)))
1201 pos = len_trim(res) + 1
1217 REAL(kind=
dp),
INTENT(in) ::
value
1220 INTEGER,
INTENT(in),
OPTIONAL :: power
1221 REAL(kind=
dp) :: res
1223 INTEGER :: i_unit, my_basic_unit, my_power
1226 IF (
PRESENT(power)) my_power = power
1228 DO i_unit = 1, unit%n_kinds
1229 cpassert(unit%kind_id(i_unit) > 0)
1230 my_basic_unit = unit%unit_id(i_unit)
1231 IF (my_basic_unit == 0 .AND. unit%kind_id(i_unit) /=
cp_ukind_undef)
THEN
1232 cpassert(
PRESENT(defaults))
1233 cpassert(
ASSOCIATED(defaults%units(unit%kind_id(i_unit))%unit))
1234 my_basic_unit = defaults%units(unit%kind_id(i_unit))%unit%unit_id(1)
1236 res = cp_basic_unit_to_cp2k(
value=res, basic_unit=my_basic_unit, &
1237 basic_kind=unit%kind_id(i_unit), &
1238 power=my_power*unit%power(i_unit))
1253 REAL(kind=
dp),
INTENT(in) ::
value
1256 INTEGER,
INTENT(in),
OPTIONAL :: power
1257 REAL(kind=
dp) :: res
1262 IF (
PRESENT(power)) my_power = power
1263 IF (
PRESENT(defaults))
THEN
1282 REAL(kind=
dp),
INTENT(in) ::
value
1283 CHARACTER(len=*),
INTENT(in) :: unit_str
1285 INTEGER,
INTENT(in),
OPTIONAL :: power
1286 REAL(kind=
dp) :: res
1291 IF (
PRESENT(defaults))
THEN
1311 REAL(kind=
dp),
INTENT(in) ::
value
1312 CHARACTER(len=*),
INTENT(in) :: unit_str
1314 INTEGER,
INTENT(in),
OPTIONAL :: power
1315 REAL(kind=
dp) :: res
1320 IF (
PRESENT(defaults))
THEN
1343 DO i = 1,
SIZE(ref_unit%kind_id)
1344 IF (ref_unit%kind_id(i) == unit%kind_id(i)) cycle
1361 CHARACTER(len=*),
INTENT(in) :: name
1363 CHARACTER(len=cp_unit_desc_length) :: my_name
1370 NULLIFY (unit_set%units(i)%unit)
1371 ALLOCATE (unit_set%units(i)%unit)
1375 CASE (
'ATOM',
'ATOMIC',
'INTERNAL',
'CP2K')
1377 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], &
1380 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], &
1386 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_none], &
1389 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_hartree], &
1392 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_angstrom], &
1395 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_k], &
1398 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_deg], &
1401 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_bar], &
1404 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_fs], &
1407 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_amu], &
1410 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_volt], &
1413 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_newton], &
1416 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_volt_per_m], &
1419 CALL cp_unit_create2(unit_set%units(i)%unit, kind_id=[i], unit_id=[
cp_units_debye], &
1426 cpabort(
'unknown parameter set name '//trim(name))
1441 DO i = 1,
SIZE(unit_set%units)
1443 DEALLOCATE (unit_set%units(i)%unit)
1454 INTEGER,
INTENT(IN) :: iw
1456 CALL format_units_as_xml(
"energy",
s2a(
"hartree",
"wavenumber_e",
"joule",
"kcalmol", &
1457 "kjmol",
"Ry",
"eV",
"keV",
"K_e"), iw)
1458 CALL format_units_as_xml(
"length",
s2a(
"bohr",
"m",
"pm",
"nm",
"angstrom"), iw)
1459 CALL format_units_as_xml(
"temperature",
s2a(
"K",
"au_temp"), iw)
1460 CALL format_units_as_xml(
"pressure",
s2a(
"bar",
"atm",
"kbar",
"Pa",
"MPa",
"GPa",
"au_p"), iw)
1461 CALL format_units_as_xml(
"angle",
s2a(
"rad",
"deg"), iw)
1462 CALL format_units_as_xml(
"time",
s2a(
"s",
"fs",
"ps",
"au_t",
"wavenumber_t"), iw)
1463 CALL format_units_as_xml(
"mass",
s2a(
"kg",
"amu",
"m_e"), iw)
1464 CALL format_units_as_xml(
"potential",
s2a(
"volt",
"au_pot"), iw)
1465 CALL format_units_as_xml(
"force",
s2a(
"N",
"Newton",
"mN",
"mNewton",
"au_f"), iw)
1466 CALL format_units_as_xml(
"efield",
s2a(
"Vm-1",
"Vnm-1",
"VA-1",
"volt_per_m",
"volt_per_nm", &
1467 "volt_per_angstrom",
"au_efield"), iw)
1468 CALL format_units_as_xml(
"dipole",
s2a(
"debye",
"e_angstrom",
"C_m",
"au_dip"), iw)
1479 SUBROUTINE format_units_as_xml(unit_kind, units_set, iw)
1480 CHARACTER(LEN=*),
INTENT(IN) :: unit_kind
1481 CHARACTER(LEN=*),
DIMENSION(:),
INTENT(IN) :: units_set
1482 INTEGER,
INTENT(IN) :: iw
1486 WRITE (iw, fmt=
'(T2,A)')
'<UNIT_KIND name="'//trim(unit_kind)//
'">'
1487 DO i = 1,
SIZE(units_set)
1488 WRITE (iw, fmt=
'(T3,A)')
'<UNIT>'//trim(units_set(i))//
'</UNIT>'
1490 WRITE (iw, fmt=
'(T3,A)')
'<UNIT>'//trim(unit_kind)//
'</UNIT>'
1491 WRITE (iw, fmt=
'(T2,A)')
'</UNIT_KIND>'
1492 END SUBROUTINE format_units_as_xml
various routines to log and control the output. The idea is that decisions about where to log should ...
integer, parameter, public cp_units_wavenum
integer, parameter, public cp_ukind_none
integer, parameter, public cp_units_fs
integer, parameter, public cp_units_kev
integer, parameter, public cp_units_m
integer, parameter, public cp_units_k
integer, parameter, public cp_ukind_potential
integer, parameter, public cp_units_mpa
integer, parameter, public cp_units_volt_per_angstrom
integer, parameter, public cp_ukind_undef
integer, parameter, public cp_units_none
integer, parameter, public cp_units_angstrom
integer, parameter, public cp_units_volt
character(len=cp_unit_desc_length) function, public cp_unit_desc(unit, defaults, accept_undefined)
returns the "name" of the given unit
real(kind=dp) function, public cp_unit_to_cp2k1(value, unit, defaults, power)
transform a value to the internal cp2k units
integer, parameter, public cp_units_au
integer, parameter, public cp_ukind_length
integer, parameter, public cp_ukind_temperature
real(kind=dp) function, public cp_unit_from_cp2k1(value, unit, defaults, power)
converts from the internal cp2k units to the given unit
integer, parameter, public cp_units_hartree
integer, parameter, public cp_units_nm
integer, parameter, public cp_units_bar
integer, parameter, public cp_units_amu
integer, parameter, public cp_ukind_time
integer, parameter, public cp_ukind_energy
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
integer, parameter, public cp_units_debye
integer, parameter, public cp_units_c_m
subroutine, public cp_unit_create(unit, string)
creates a unit parsing a string
integer, parameter, public cp_ukind_efield
integer, parameter, public cp_ukind_force
integer, parameter, public cp_unit_desc_length
integer, parameter, public cp_units_kbar
integer, parameter, public cp_units_newton
integer, parameter, public cp_units_ps
integer, parameter, public cp_units_ev
integer, parameter, public cp_ukind_max
integer, parameter, public cp_units_mnewton
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
integer, parameter, public cp_units_e_angstrom
integer, parameter, public cp_units_atm
integer, parameter, public cp_units_deg
subroutine, public cp_unit_set_release(unit_set)
releases the given unit set
integer, parameter, public cp_units_ry
integer, parameter, public cp_units_kcalmol
integer, parameter, public cp_units_rad
integer, parameter, public cp_units_pa
integer, parameter, public cp_units_jmol
integer, parameter, public cp_units_joule
integer, parameter, public cp_unit_basic_desc_length
subroutine, public cp_unit_set_create(unit_set, name)
initializes the given unit set
integer, parameter, public cp_units_volt_per_m
integer, parameter, public cp_units_gpa
integer, parameter, public cp_units_bohr
subroutine, public export_units_as_xml(iw)
Exports all available units as XML.
integer, parameter, public cp_units_volt_per_nm
integer, parameter, public cp_units_kjmol
integer, parameter, public cp_units_wn
integer, parameter, public cp_ukind_dipole
integer, parameter, public cp_units_m_e
integer, parameter, public cp_units_pm
integer, parameter, public cp_units_kg
integer, parameter, public cp_ukind_mass
logical function, public cp_unit_compatible(ref_unit, unit)
returs true if the two units are compatible
elemental subroutine, public cp_unit_release(unit)
releases the given unit
integer, parameter, public cp_ukind_angle
integer, parameter, public cp_units_s
integer, parameter, public cp_unit_max_kinds
integer, parameter, public cp_ukind_pressure
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public radians
real(kind=dp), parameter, public twopi
Definition of physical constants:
real(kind=dp), parameter, public a_bohr
real(kind=dp), parameter, public kcalmol
real(kind=dp), parameter, public e_charge
real(kind=dp), parameter, public femtoseconds
real(kind=dp), parameter, public atm
real(kind=dp), parameter, public joule
real(kind=dp), parameter, public kelvin
real(kind=dp), parameter, public newton
real(kind=dp), parameter, public seconds
real(kind=dp), parameter, public evolt
real(kind=dp), parameter, public e_mass
real(kind=dp), parameter, public picoseconds
real(kind=dp), parameter, public wavenumbers
real(kind=dp), parameter, public bar
real(kind=dp), parameter, public massunit
real(kind=dp), parameter, public kjmol
real(kind=dp), parameter, public pascal
real(kind=dp), parameter, public bohr
real(kind=dp), parameter, public debye
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
stores the default units to be used