Line data Source code
1 : !--------------------------------------------------------------------------------------------------! 2 : ! CP2K: A general program to perform molecular dynamics simulations ! 3 : ! Copyright 2000-2024 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 : ! ************************************************************************************************** 11 : MODULE xc_write_output 12 : 13 : USE input_constants, ONLY: xc_none 14 : USE input_cp2k_check, ONLY: xc_functionals_expand 15 : USE input_section_types, ONLY: section_vals_get_subs_vals,& 16 : section_vals_get_subs_vals2,& 17 : section_vals_type,& 18 : section_vals_val_get 19 : USE kinds, ONLY: default_string_length 20 : USE xc_derivatives, ONLY: xc_functional_get_info 21 : USE xc_libxc, ONLY: libxc_check_existence_in_libxc,& 22 : libxc_get_reference_length 23 : #include "./base/base_uses.f90" 24 : 25 : IMPLICIT NONE 26 : 27 : PRIVATE 28 : 29 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xc_write_output' 30 : 31 : PUBLIC :: xc_write 32 : 33 : CONTAINS 34 : 35 : ! ************************************************************************************************** 36 : !> \brief ... 37 : !> \param iounit ... 38 : !> \param xc_section ... 39 : !> \param lsd ... 40 : ! ************************************************************************************************** 41 1615 : SUBROUTINE xc_write(iounit, xc_section, lsd) 42 : INTEGER, INTENT(IN) :: iounit 43 : TYPE(section_vals_type), POINTER :: xc_section 44 : LOGICAL, INTENT(IN) :: lsd 45 : 46 : CHARACTER(LEN=2*default_string_length) :: shortform 47 1615 : CHARACTER(LEN=:), ALLOCATABLE :: reference 48 : INTEGER :: ifun, il, myfun 49 : TYPE(section_vals_type), POINTER :: xc_fun, xc_fun_section 50 : 51 1615 : IF (iounit > 0) THEN 52 : 53 : xc_fun_section => section_vals_get_subs_vals(xc_section, & 54 1615 : "XC_FUNCTIONAL") 55 1615 : CALL section_vals_val_get(xc_fun_section, "_SECTION_PARAMETERS_", i_val=myfun) 56 1615 : IF (myfun /= xc_none) THEN 57 : 58 : !check if FUNCTIONAL_ROUTINE keyword present 59 : 60 1435 : CALL xc_functionals_expand(xc_fun_section, xc_section) 61 1435 : ifun = 0 62 1592 : DO 63 3027 : ifun = ifun + 1 64 3027 : xc_fun => section_vals_get_subs_vals2(xc_fun_section, i_section=ifun) 65 3027 : IF (.NOT. ASSOCIATED(xc_fun)) EXIT 66 1592 : IF (libxc_check_existence_in_libxc(xc_fun)) THEN 67 67 : ALLOCATE (CHARACTER(LEN=libxc_get_reference_length(xc_fun, lsd)) :: reference) 68 : ELSE 69 1525 : ALLOCATE (CHARACTER(LEN=20*default_string_length) :: reference) 70 : END IF 71 1592 : CALL xc_functional_get_info(xc_fun, lsd=lsd, reference=reference, shortform=shortform) 72 : WRITE (iounit, fmt="(' FUNCTIONAL| ',a,':')") & 73 1592 : TRIM(xc_fun%section%name) 74 4577 : DO il = 1, LEN_TRIM(reference), 67 75 4577 : WRITE (iounit, fmt="(' FUNCTIONAL| ',a67)") reference(il:) 76 : END DO 77 3027 : DEALLOCATE (reference) 78 : END DO 79 : ELSE 80 180 : WRITE (iounit, fmt="(' FUNCTIONAL| NO EXCHANGE-CORRELATION FUNCTIONAL USED.')") 81 : END IF 82 : END IF 83 : 84 1615 : END SUBROUTINE xc_write 85 : 86 : END MODULE xc_write_output