(git:f2099e5)
Loading...
Searching...
No Matches
xc_write_output.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Writes information on XC functionals to output
10! **************************************************************************************************
12
13 USE input_constants, ONLY: xc_none
25#include "./base/base_uses.f90"
26
27 IMPLICIT NONE
28
29 PRIVATE
30
31 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xc_write_output'
32
33 PUBLIC :: xc_write
34
35CONTAINS
36
37! **************************************************************************************************
38!> \brief ...
39!> \param iounit ...
40!> \param xc_section ...
41!> \param lsd ...
42! **************************************************************************************************
43 SUBROUTINE xc_write(iounit, xc_section, lsd)
44 INTEGER, INTENT(IN) :: iounit
45 TYPE(section_vals_type), POINTER :: xc_section
46 LOGICAL, INTENT(IN) :: lsd
47
48 CHARACTER(LEN=2*default_string_length) :: shortform
49 CHARACTER(LEN=:), ALLOCATABLE :: reference
50 INTEGER :: ifun, il, myfun
51 LOGICAL :: libxc_used
52 TYPE(section_vals_type), POINTER :: xc_fun, xc_fun_section
53
54 IF (iounit > 0) THEN
55
56 xc_fun_section => section_vals_get_subs_vals(xc_section, &
57 "XC_FUNCTIONAL")
58 CALL section_vals_val_get(xc_fun_section, "_SECTION_PARAMETERS_", i_val=myfun)
59 IF (myfun /= xc_none) THEN
60
61 CALL xc_functionals_expand(xc_fun_section, xc_section)
62
63 ! Announce LibXC before the functionals it provides, so that the
64 ! version actually loaded and the citation it asks for are on record
65 ! next to the numbers they produced.
66 libxc_used = .false.
67 ifun = 0
68 DO
69 ifun = ifun + 1
70 xc_fun => section_vals_get_subs_vals2(xc_fun_section, i_section=ifun)
71 IF (.NOT. ASSOCIATED(xc_fun)) EXIT
72 IF (libxc_check_existence_in_libxc(xc_fun)) libxc_used = .true.
73 END DO
74 IF (libxc_used) CALL xc_write_libxc_info(iounit)
75
76 ifun = 0
77 DO
78 ifun = ifun + 1
79 xc_fun => section_vals_get_subs_vals2(xc_fun_section, i_section=ifun)
80 IF (.NOT. ASSOCIATED(xc_fun)) EXIT
81 IF (libxc_check_existence_in_libxc(xc_fun)) THEN
82 ALLOCATE (CHARACTER(LEN=libxc_get_reference_length(xc_fun, lsd)) :: reference)
83 ELSE
84 ALLOCATE (CHARACTER(LEN=20*default_string_length) :: reference)
85 END IF
86 CALL xc_functional_get_info(xc_fun, lsd=lsd, reference=reference, shortform=shortform)
87 WRITE (iounit, fmt="(' FUNCTIONAL| ',a,':')") &
88 trim(xc_fun%section%name)
89 DO il = 1, len_trim(reference), 67
90 WRITE (iounit, fmt="(' FUNCTIONAL| ',a67)") reference(il:)
91 END DO
92 DEALLOCATE (reference)
93 END DO
94 ELSE
95 WRITE (iounit, fmt="(' FUNCTIONAL| NO EXCHANGE-CORRELATION FUNCTIONAL USED.')")
96 END IF
97 END IF
98
99 END SUBROUTINE xc_write
100
101! **************************************************************************************************
102!> \brief Reports which LibXC is in use and how it asks to be cited.
103!> \param iounit ...
104!> \author S. Lehtola
105!> \note The version is the one reported by the library at run time, which is what
106!> describes the numbers in this output. It can differ from the version CP2K
107!> was compiled against when the binary picks up another shared LibXC, and
108!> that mismatch is worth saying out loud.
109! **************************************************************************************************
110 SUBROUTINE xc_write_libxc_info(iounit)
111 INTEGER, INTENT(IN) :: iounit
112
113 CHARACTER(LEN=10*default_string_length) :: reference
114 CHARACTER(LEN=default_string_length) :: compiled_version, doi, version
115 INTEGER :: il
116
117 CALL libxc_version_info(version, compiled_version)
118 CALL libxc_library_reference(reference, doi)
119
120 WRITE (iounit, fmt="(' FUNCTIONAL| LIBXC version ',a)") trim(version)
121 IF (trim(version) /= trim(compiled_version)) THEN
122 WRITE (iounit, fmt="(' FUNCTIONAL| LIBXC compiled against version ',a)") trim(compiled_version)
123 END IF
124 DO il = 1, len_trim(reference), 67
125 WRITE (iounit, fmt="(' FUNCTIONAL| ',a67)") reference(il:)
126 END DO
127 WRITE (iounit, fmt="(' FUNCTIONAL| doi: ',a)") trim(doi)
128
129 END SUBROUTINE xc_write_libxc_info
130
131END MODULE xc_write_output
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public xc_none
checks the input and perform some automatic "magic" on it
subroutine, public xc_functionals_expand(functionals, xc_section)
expand a shortcutted functional section
objects that represent the structure of input sections and the data contained in an input section
type(section_vals_type) function, pointer, public section_vals_get_subs_vals2(section_vals, i_section, i_rep_section)
returns the values of the n-th non default subsection (null if no such section exists (not so many no...
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public default_string_length
Definition kinds.F:57
subroutine, public xc_functional_get_info(functional, lsd, reference, shortform, needs, max_deriv, print_warn)
get the information about the given functional
calculates a functional from libxc and its derivatives
Definition xc_libxc.F:29
subroutine, public libxc_version_info(version, compiled_version)
info about the LibXC version
Definition xc_libxc.F:596
logical function, public libxc_check_existence_in_libxc(libxc_params)
This function checks whether a functional name belongs to LibXC.
Definition xc_libxc.F:197
integer function, public libxc_get_reference_length(libxc_params, lsd)
This function returns the maximum length of the reference string for a given LibXC functional.
Definition xc_libxc.F:223
subroutine, public libxc_library_reference(reference, doi)
Returns the citation LibXC asks for the library itself.
Definition xc_libxc.F:616
Writes information on XC functionals to output.
subroutine, public xc_write(iounit, xc_section, lsd)
...