LCOV - code coverage report
Current view: top level - src/xc - xc_libxc_wrap.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:66ce584) Lines: 92.3 % 117 108
Test Date: 2026-09-12 06:50:25 Functions: 90.0 % 10 9

            Line data    Source code
       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 Includes all necessary routines, functions and parameters from
      10              : !>        libxc. Provides CP2K routines/functions where the LibXC calling list
      11              : !>        is version dependent (>=4.0.3). The naming convention for such
      12              : !>        routines/functions is xc_f03_XXX --> 'xc_libxc_wrap_XXX'. All version
      13              : !>        independent routines/functions are just bypassed to higher level
      14              : !>        module file 'xc_libxc'.
      15              : !>
      16              : !> \par History
      17              : !>      08.2015 created [A. Gloess (agloess)]
      18              : !>      01.2018 refactoring [A. Gloess (agloess)]
      19              : !>      10.2018/04.2019 added hyb_mgga [S. Simko, included by F. Stein]
      20              : !> \author A. Gloess (agloess)
      21              : ! **************************************************************************************************
      22              : MODULE xc_libxc_wrap
      23              : #if defined (__LIBXC)
      24              : #include <xc_version.h>
      25              : ! check for LibXC version
      26              : #if (XC_MAJOR_VERSION < 5 || (XC_MAJOR_VERSION == 5 && XC_MINOR_VERSION < 1))
      27              :    This version of CP2K ONLY works with libxc versions 5.1.0 and above.
      28              :    Furthermore, -I${LIBXC_DIR}/include needs to be added to FCFLAGS.
      29              : #else
      30              :    USE kinds, ONLY: dp
      31              :    USE xc_f03_lib_m, ONLY: xc_f03_func_end, &
      32              :                            xc_f03_func_init, &
      33              :                            xc_f03_functional_get_name, &
      34              :                            xc_f03_func_set_ext_params, &
      35              :                            xc_f03_func_set_dens_threshold, &
      36              :                            xc_f03_func_set_tau_threshold, &
      37              :                            xc_f03_version_string, &
      38              :                            xc_f03_reference, &
      39              :                            xc_f03_reference_doi, &
      40              :                            xc_f03_functional_get_number, &
      41              :                            xc_f03_available_functional_numbers, &
      42              :                            xc_f03_available_functional_names, &
      43              :                            xc_f03_maximum_name_length, &
      44              :                            xc_f03_number_of_functionals, &
      45              :                            !
      46              :                            xc_f03_gga_exc, &
      47              :                            xc_f03_gga_exc_vxc, &
      48              :                            xc_f03_gga_exc_vxc_fxc, &
      49              :                            xc_f03_gga_exc_vxc_fxc_kxc, &
      50              :                            xc_f03_mgga_exc_vxc_fxc_kxc, &
      51              :                            xc_f03_mgga_vxc_fxc_kxc, &
      52              :                            xc_f03_gga_fxc, &
      53              :                            xc_f03_gga_vxc, &
      54              :                            xc_f03_gga_vxc_fxc, &
      55              :                            xc_f03_gga_vxc_fxc_kxc, &
      56              :                            !
      57              :                            xc_f03_func_get_info, &
      58              :                            xc_f03_func_info_get_family, &
      59              :                            xc_f03_func_info_get_kind, &
      60              :                            xc_f03_func_info_get_name, &
      61              :                            xc_f03_func_info_get_references, &
      62              :                            xc_f03_func_info_get_flags, &
      63              :                            xc_f03_func_info_get_n_ext_params, &
      64              :                            xc_f03_func_info_get_ext_params_name, &
      65              :                            xc_f03_func_info_get_ext_params_default_value, &
      66              :                            xc_f03_func_info_get_ext_params_description, &
      67              :                            !
      68              :                            xc_f03_func_reference_get_ref, &
      69              :                            xc_f03_func_reference_get_doi, &
      70              :                            !
      71              :                            xc_f03_lda => xc_f03_lda_exc_vxc_fxc_kxc, &
      72              :                            xc_f03_lda_exc, &
      73              :                            xc_f03_lda_exc_vxc, &
      74              :                            xc_f03_lda_exc_vxc_fxc, &
      75              :                            xc_f03_lda_fxc, &
      76              :                            xc_f03_lda_kxc, &
      77              :                            xc_f03_lda_vxc, &
      78              :                            !
      79              :                            xc_f03_mgga => xc_f03_mgga_exc_vxc_fxc, &
      80              :                            xc_f03_mgga_exc, &
      81              :                            xc_f03_mgga_exc_vxc, &
      82              :                            xc_f03_mgga_fxc, &
      83              :                            xc_f03_mgga_vxc, &
      84              :                            xc_f03_mgga_vxc_fxc, &
      85              :                            !
      86              :                            xc_f03_func_t, &
      87              :                            xc_f03_func_info_t, &
      88              :                            xc_f03_func_reference_t, &
      89              :                            !
      90              :                            XC_FAMILY_LDA, &
      91              :                            XC_FAMILY_GGA, &
      92              :                            XC_FAMILY_MGGA, &
      93              :                            XC_FAMILY_HYB_LDA, &
      94              :                            XC_FAMILY_HYB_GGA, &
      95              :                            XC_FAMILY_HYB_MGGA, &
      96              :                            !
      97              :                            XC_UNPOLARIZED, &
      98              :                            XC_POLARIZED, &
      99              :                            !
     100              :                            XC_EXCHANGE, &
     101              :                            XC_CORRELATION, &
     102              :                            XC_EXCHANGE_CORRELATION, &
     103              :                            XC_KINETIC, &
     104              :                            !
     105              :                            XC_FLAGS_NEEDS_LAPLACIAN, &
     106              :                            XC_FLAGS_HAVE_EXC, &
     107              :                            XC_FLAGS_DEVELOPMENT
     108              : 
     109              : #include "../base/base_uses.f90"
     110              : #endif
     111              :    IMPLICIT NONE
     112              :    PRIVATE
     113              : #if defined (__LIBXC)
     114              : 
     115              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xc_libxc_wrap'
     116              : 
     117              :    CHARACTER(LEN=*), PARAMETER, PUBLIC :: libxc_version = XC_VERSION
     118              : 
     119              :    PUBLIC :: xc_f03_func_t, xc_f03_func_info_t
     120              :    PUBLIC :: xc_f03_func_init, xc_f03_func_end, xc_f03_func_set_ext_params
     121              :    PUBLIC :: xc_f03_functional_get_name, xc_f03_available_functional_numbers, xc_f03_maximum_name_length, &
     122              :              xc_f03_number_of_functionals, xc_f03_available_functional_names
     123              :    PUBLIC :: xc_f03_func_get_info, xc_f03_func_info_get_family, xc_f03_func_info_get_kind, &
     124              :              xc_f03_func_info_get_name, xc_f03_func_info_get_ext_params_name, &
     125              :              xc_f03_func_info_get_ext_params_description, xc_f03_func_info_get_ext_params_default_value, &
     126              :              xc_f03_func_info_get_n_ext_params
     127              :    PUBLIC :: xc_f03_gga_exc, xc_f03_gga_exc_vxc, xc_f03_gga_exc_vxc_fxc, xc_f03_gga_fxc, &
     128              :              xc_f03_gga_vxc, xc_f03_gga_vxc_fxc, &
     129              :              xc_f03_gga_exc_vxc_fxc_kxc, xc_f03_gga_vxc_fxc_kxc
     130              :    PUBLIC :: xc_f03_mgga_exc_vxc_fxc_kxc, xc_f03_mgga_vxc_fxc_kxc
     131              :    PUBLIC :: xc_f03_lda, &
     132              :              xc_f03_lda_exc, xc_f03_lda_exc_vxc, xc_f03_lda_exc_vxc_fxc, &
     133              :              xc_f03_lda_fxc, xc_f03_lda_kxc, xc_f03_lda_vxc
     134              :    PUBLIC :: xc_f03_mgga, xc_f03_mgga_exc, xc_f03_mgga_exc_vxc, xc_f03_mgga_fxc, &
     135              :              xc_f03_mgga_vxc, xc_f03_mgga_vxc_fxc
     136              : 
     137              :    PUBLIC :: XC_FAMILY_LDA, XC_FAMILY_GGA, XC_FAMILY_MGGA, &
     138              :              XC_FAMILY_HYB_LDA, XC_FAMILY_HYB_GGA, XC_FAMILY_HYB_MGGA
     139              : 
     140              :    PUBLIC :: XC_UNPOLARIZED, XC_POLARIZED
     141              : 
     142              :    PUBLIC :: XC_EXCHANGE, XC_CORRELATION, XC_EXCHANGE_CORRELATION, XC_KINETIC
     143              : 
     144              : ! wrappers for routines
     145              :    PUBLIC :: xc_libxc_wrap_info_refs, &
     146              :              xc_libxc_wrap_version, &
     147              :              xc_libxc_wrap_library_reference, &
     148              :              xc_libxc_wrap_info_needs_laplace, &
     149              :              xc_libxc_wrap_info_no_exc, &
     150              :              xc_libxc_wrap_set_thresholds, &
     151              :              xc_libxc_wrap_functional_get_number, &
     152              :              xc_libxc_wrap_is_under_development, &
     153              :              xc_libxc_get_reference_length, &
     154              :              xc_libxc_check_functional
     155              : 
     156              : CONTAINS
     157              : 
     158              : ! **************************************************************************************************
     159              : !> \brief Provides the reference(s) for this functional.
     160              : !> \param xc_info func_info object of the functional
     161              : !> \return upper bound for the length of the reference string
     162              : !> \author F. Stein
     163              : ! **************************************************************************************************
     164          124 :    FUNCTION xc_libxc_get_reference_length(xc_info) RESULT(length)
     165              : 
     166              :       TYPE(xc_f03_func_info_t), INTENT(IN)               :: xc_info
     167              :       INTEGER                                            :: length
     168              : 
     169              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_get_reference_length'
     170              :       INTEGER, PARAMETER                                 :: maxlen = 67
     171              : 
     172              :       CHARACTER(LEN=128)                                 :: descr_string
     173              :       CHARACTER(LEN=1024)                                :: doi_string, ref_string
     174              :       INTEGER                                            :: i, i_ref, i_ref_old, n_params, handle
     175              :       TYPE(xc_f03_func_reference_t)                      :: xc_ref
     176              : 
     177          124 :       CALL timeset(routineN, handle)
     178              : 
     179              :       ! We are counting the number of necessary lines by carrying out a dry run of xc_libxc_wrap_info_refs
     180          124 :       i_ref = 0
     181          124 :       i_ref_old = -1
     182          124 :       length = 0
     183          248 :       DO WHILE (i_ref >= 0 .AND. i_ref /= i_ref_old)
     184              :          ! information about functional references
     185          124 :          xc_ref = xc_f03_func_info_get_references(xc_info, i_ref)
     186          124 :          ref_string = xc_f03_func_reference_get_ref(xc_ref)
     187          124 :          doi_string = xc_f03_func_reference_get_doi(xc_ref)
     188          124 :          length = length + LEN_TRIM(ref_string) + LEN_TRIM(doi_string) + 11
     189          124 :          IF (MOD(length, maxlen) /= 0) length = length + maxlen - MOD(length, maxlen)
     190              :          ! information about (optional) external parameters
     191          124 :          n_params = xc_f03_func_info_get_n_ext_params(xc_info)
     192          124 :          IF (n_params > 0) THEN
     193           97 :             length = length + maxlen
     194              :          END IF
     195          684 :          DO i = 1, n_params
     196          560 :             descr_string = xc_f03_func_info_get_ext_params_description(xc_info, i - 1)
     197          560 :             length = length + LEN_TRIM(descr_string) + 3
     198          684 :             IF (MOD(length, maxlen) /= 0) length = length + maxlen - MOD(length, maxlen)
     199              :          END DO
     200          124 :          i_ref_old = i_ref
     201              :       END DO
     202              :       ! two additional lines for spin polarization, scaling factor and buffer
     203          124 :       length = length + 2*maxlen
     204              : 
     205          124 :       CALL timestop(handle)
     206              : 
     207          124 :    END FUNCTION xc_libxc_get_reference_length
     208              : 
     209              : ! **************************************************************************************************
     210              : !> \brief Provides the reference(s) for this functional.
     211              : !> \param xc_info ...
     212              : !> \param polarized ...
     213              : !> \param sc ...
     214              : !> \param reference ...
     215              : !>
     216              : !> \author A. Gloess (agloess)
     217              : ! **************************************************************************************************
     218          124 :    SUBROUTINE xc_libxc_wrap_info_refs(xc_info, polarized, sc, reference)
     219              :       TYPE(xc_f03_func_info_t), INTENT(IN)               :: xc_info
     220              :       INTEGER, INTENT(IN)                                :: polarized
     221              :       REAL(KIND=dp), INTENT(IN)                          :: sc
     222              :       CHARACTER(LEN=*), INTENT(OUT)                      :: reference
     223              : 
     224              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_wrap_info_refs'
     225              :       INTEGER, PARAMETER                                 :: maxlen = 67
     226              : 
     227              :       CHARACTER(LEN=128)                                 :: descr_string
     228              :       CHARACTER(LEN=1028)                                :: doi_string, ref_string
     229              :       ! conservative estimate of the necessary length: 2*1028+11=2067
     230              :       CHARACTER(LEN=2067)                                :: tmp_string
     231              :       INTEGER                                            :: empty, first, handle, i, i_ref, i_ref_old, idx, &
     232              :                                                             last, n_params
     233              :       TYPE(xc_f03_func_reference_t)                      :: xc_ref
     234              : 
     235          124 :       CALL timeset(routineN, handle)
     236              : 
     237          124 :       i_ref = 0
     238          124 :       i_ref_old = -1
     239          124 :       idx = 1
     240          124 :       first = 1
     241          248 :       DO WHILE (i_ref >= 0 .AND. i_ref /= i_ref_old)
     242              :          ! information about functional references
     243          124 :          xc_ref = xc_f03_func_info_get_references(xc_info, i_ref)
     244          124 :          ref_string = xc_f03_func_reference_get_ref(xc_ref)
     245          124 :          doi_string = xc_f03_func_reference_get_doi(xc_ref)
     246          124 :          WRITE (tmp_string, '(a1,i1,a2,a,a7,a)') '[', idx, '] ', &
     247          248 :             TRIM(ref_string), ', doi: ', TRIM(doi_string)
     248          124 :          last = first + LEN_TRIM(tmp_string) - 1
     249          124 :          reference(first:last) = TRIM(tmp_string)
     250          124 :          first = last + 1
     251          124 :          empty = last + (maxlen - 1) - MOD(last - 1, maxlen)
     252              :          ! fill up line with 'spaces'
     253          124 :          IF (empty /= last) THEN
     254          124 :             reference(first:empty) = ' '
     255          124 :             first = empty + 1
     256              :          END IF
     257              :          ! information about (optional) external parameters
     258          124 :          n_params = xc_f03_func_info_get_n_ext_params(xc_info)
     259          124 :          IF (n_params > 0) THEN
     260           97 :             reference(first:first + maxlen - 1) = 'Optional external parameters:'//REPEAT(' ', maxlen - 28)
     261           97 :             first = first + maxlen
     262              :          END IF
     263          684 :          DO i = 1, n_params
     264          560 :             descr_string = xc_f03_func_info_get_ext_params_description(xc_info, i - 1)
     265          560 :             last = first + LEN_TRIM(descr_string) - 1 + 3
     266          560 :             reference(first:last) = ' * '//TRIM(descr_string)
     267          560 :             first = last + 1
     268          560 :             empty = last + (maxlen - 1) - MOD(last - 1, maxlen)
     269              :             ! fill up line with 'spaces'
     270              : 
     271          684 :             IF (empty /= last) THEN
     272          560 :                reference(first:empty) = ' '
     273          560 :                first = empty + 1
     274              :             END IF
     275              :          END DO
     276          124 :          idx = idx + 1
     277          124 :          i_ref_old = i_ref
     278              :       END DO
     279          188 :       SELECT CASE (polarized)
     280              :       CASE (XC_UNPOLARIZED)
     281           64 :          WRITE (tmp_string, "('{scale=',f5.3,', spin-unpolarized}')") sc
     282              :       CASE (XC_POLARIZED)
     283           60 :          WRITE (tmp_string, "('{scale=',f5.3,', spin-polarized}')") sc
     284              :       CASE default
     285          124 :          CPABORT("Unsupported value for variable 'polarized'.")
     286              :       END SELECT
     287          124 :       last = first + LEN_TRIM(tmp_string) - 1
     288          124 :       reference(first:last) = TRIM(tmp_string)
     289          124 :       first = last + 1
     290              :       ! fill with 'spaces'
     291          124 :       reference(first:LEN(reference)) = ' '
     292              : 
     293          124 :       IF (last > LEN(reference)) &
     294            0 :          CPABORT("Faulty reference length.")
     295              : 
     296          124 :       CALL timestop(handle)
     297              : 
     298          124 :    END SUBROUTINE xc_libxc_wrap_info_refs
     299              : 
     300              : ! **************************************************************************************************
     301              : !> \brief Provides the version of the LibXC library CP2K is running against.
     302              : !> \param version version string reported by the library at run time
     303              : !> \param compiled_version version of the headers CP2K was compiled against
     304              : !> \author A. Gloess (agloess)
     305              : !> \note The run-time and compile-time versions differ whenever CP2K is executed
     306              : !>       against a shared LibXC other than the one it was built with. Reporting
     307              : !>       the run-time version is what actually describes the numbers produced.
     308              : !>
     309              : ! **************************************************************************************************
     310           78 :    SUBROUTINE xc_libxc_wrap_version(version, compiled_version)
     311              :       CHARACTER(LEN=*), INTENT(OUT)                      :: version
     312              :       CHARACTER(LEN=*), INTENT(OUT), OPTIONAL            :: compiled_version
     313              : 
     314              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_wrap_version'
     315              : 
     316              :       INTEGER                                            :: handle
     317              : 
     318           78 :       CALL timeset(routineN, handle)
     319              : 
     320           78 :       CALL xc_f03_version_string(version)
     321           78 :       IF (PRESENT(compiled_version)) compiled_version = TRIM(libxc_version)
     322              : 
     323           78 :       CALL timestop(handle)
     324              : 
     325           78 :    END SUBROUTINE xc_libxc_wrap_version
     326              : 
     327              : ! **************************************************************************************************
     328              : !> \brief Provides the citation LibXC asks to be given for the library itself.
     329              : !> \param reference bibliographic reference
     330              : !> \param doi digital object identifier of that reference
     331              : !> \author S. Lehtola
     332              : !> \note Taken from the library at run time rather than hard-coded, so that the
     333              : !>       citation stays correct when LibXC updates its own self-citation.
     334              : !>
     335              : ! **************************************************************************************************
     336           78 :    SUBROUTINE xc_libxc_wrap_library_reference(reference, doi)
     337              :       CHARACTER(LEN=*), INTENT(OUT)                      :: reference, doi
     338              : 
     339              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_wrap_library_reference'
     340              : 
     341              :       INTEGER                                            :: handle
     342              : 
     343           78 :       CALL timeset(routineN, handle)
     344              : 
     345           78 :       CALL xc_f03_reference(reference)
     346           78 :       CALL xc_f03_reference_doi(doi)
     347              : 
     348           78 :       CALL timestop(handle)
     349              : 
     350           78 :    END SUBROUTINE xc_libxc_wrap_library_reference
     351              : 
     352              : ! **************************************************************************************************
     353              : !> \brief Applies the CP2K screening cutoffs to a LibXC functional object.
     354              : !> \param xc_func LibXC functional object
     355              : !> \param xc_info info object belonging to xc_func
     356              : !> \param epsilon_rho density cutoff (XC%DENSITY_CUTOFF)
     357              : !> \param epsilon_tau kinetic energy density cutoff (XC%TAU_CUTOFF)
     358              : !> \author S. Lehtola
     359              : !> \note LibXC screens every point against the density threshold internally, which
     360              : !>       is what allows CP2K to hand it whole blocks of points instead of filtering
     361              : !>       point by point. The sigma threshold is deliberately left at LibXC's own
     362              : !>       default: CP2K has no cutoff of its own on the gradient here, and raising
     363              : !>       it in step with the density cutoff would floor sigma for points with a
     364              : !>       small gradient that used to be evaluated as given.
     365              : !>
     366              : ! **************************************************************************************************
     367          498 :    SUBROUTINE xc_libxc_wrap_set_thresholds(xc_func, xc_info, epsilon_rho, epsilon_tau)
     368              :       TYPE(xc_f03_func_t), INTENT(INOUT)                 :: xc_func
     369              :       TYPE(xc_f03_func_info_t), INTENT(IN)               :: xc_info
     370              :       REAL(KIND=dp), INTENT(IN)                          :: epsilon_rho, epsilon_tau
     371              : 
     372              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_wrap_set_thresholds'
     373              : 
     374              :       INTEGER                                            :: handle
     375              : 
     376          498 :       CALL timeset(routineN, handle)
     377              : 
     378          498 :       CALL xc_f03_func_set_dens_threshold(xc_func, epsilon_rho)
     379              : 
     380          138 :       SELECT CASE (xc_f03_func_info_get_family(xc_info))
     381              :       CASE (XC_FAMILY_MGGA, XC_FAMILY_HYB_MGGA)
     382          498 :          CALL xc_f03_func_set_tau_threshold(xc_func, epsilon_tau)
     383              :       END SELECT
     384              : 
     385          498 :       CALL timestop(handle)
     386              : 
     387          498 :    END SUBROUTINE xc_libxc_wrap_set_thresholds
     388              : 
     389              : ! **************************************************************************************************
     390              : !> \brief Checks existence of functional in LibXC
     391              : !> \param func_string ...
     392              : !> \return ...
     393              : !> \author F. Stein
     394              : !> \note Remove prefix to keep compatibility, functionals can be specified (in
     395              : !>       LIBXC section) as:
     396              : !>       GGA_X_...  or  XC_GGA_X_...
     397              : !>       Starting from version 2.2.0 both name conventions are allowed, before
     398              : !>       the 'XC_' prefix was necessary.
     399              : !>
     400              : ! **************************************************************************************************
     401         4324 :    LOGICAL FUNCTION xc_libxc_check_functional(func_string) RESULT(exists)
     402              :       CHARACTER(LEN=*), INTENT(IN)                       :: func_string
     403              : 
     404              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_check_functional'
     405              : 
     406              :       INTEGER                                            :: func_id, handle
     407              : 
     408         4324 :       CALL timeset(routineN, handle)
     409              : 
     410         4324 :       IF (func_string(1:3) == "XC_") THEN
     411            0 :          func_id = xc_f03_functional_get_number(func_string(4:LEN_TRIM(func_string)))
     412              :       ELSE
     413         4324 :          func_id = xc_f03_functional_get_number(func_string(1:LEN_TRIM(func_string)))
     414              :       END IF
     415              : 
     416         4324 :       exists = .TRUE.
     417         4324 :       IF (func_id == -1) exists = .FALSE.
     418              : 
     419         4324 :       CALL timestop(handle)
     420              : 
     421         4324 :    END FUNCTION xc_libxc_check_functional
     422              : 
     423              : ! **************************************************************************************************
     424              : !> \brief Provides the functional ID.
     425              : !> \param func_string ...
     426              : !> \return ...
     427              : !> \author A. Gloess (agloess)
     428              : !> \note Remove prefix to keep compatibility, functionals can be specified (in
     429              : !>       LIBXC section) as:
     430              : !>       GGA_X_...  or  XC_GGA_X_...
     431              : !>       Starting from version 2.2.0 both name conventions are allowed, before
     432              : !>       the 'XC_' prefix was necessary.
     433              : !>
     434              : ! **************************************************************************************************
     435        40354 :    INTEGER FUNCTION xc_libxc_wrap_functional_get_number(func_string) RESULT(func_id)
     436              :       CHARACTER(LEN=*), INTENT(IN)                       :: func_string
     437              : 
     438              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_wrap_functional_get_number'
     439              : 
     440              :       INTEGER                                            :: handle
     441              : 
     442        40354 :       CALL timeset(routineN, handle)
     443              : 
     444        40354 :       IF (func_string(1:3) == "XC_") THEN
     445            0 :          func_id = xc_f03_functional_get_number(func_string(4:LEN_TRIM(func_string)))
     446              :       ELSE
     447        40354 :          func_id = xc_f03_functional_get_number(func_string(1:LEN_TRIM(func_string)))
     448              :       END IF
     449        40354 :       IF (func_id == -1) THEN
     450            0 :          CPABORT(TRIM(func_string)//": wrong functional name")
     451              :       END IF
     452              : 
     453        40354 :       CALL timestop(handle)
     454              : 
     455        40354 :    END FUNCTION xc_libxc_wrap_functional_get_number
     456              : 
     457              : ! **************************************************************************************************
     458              : !> \brief Wrapper to test wether functional is considered under development in Libxc
     459              : !> \param xc_info ...
     460              : !>
     461              : !> \return ...
     462              : !> \author F. Stein (fstein93)
     463              : ! **************************************************************************************************
     464            0 :    LOGICAL FUNCTION xc_libxc_wrap_is_under_development(xc_info)
     465              :       TYPE(xc_f03_func_info_t)                           :: xc_info
     466              : 
     467            0 :       IF (IAND(xc_f03_func_info_get_flags(xc_info), XC_FLAGS_DEVELOPMENT) == XC_FLAGS_DEVELOPMENT) THEN
     468              :          xc_libxc_wrap_is_under_development = .TRUE.
     469              :       ELSE
     470            0 :          xc_libxc_wrap_is_under_development = .FALSE.
     471              :       END IF
     472              : 
     473            0 :    END FUNCTION xc_libxc_wrap_is_under_development
     474              : 
     475              : ! **************************************************************************************************
     476              : !> \brief Wrapper for functionals that need the Laplacian, all others can use
     477              : !>        a dummy array.
     478              : !> \param xc_info info object of an already initialized functional
     479              : !>
     480              : !> \return ...
     481              : !> \author A. Gloess (agloess)
     482              : !> \note Reads the flag off an info object the caller already holds. Creating a
     483              : !>       throw-away functional object just to look at one flag used to cost an
     484              : !>       extra xc_f03_func_init/xc_f03_func_end pair per evaluated batch.
     485              : ! **************************************************************************************************
     486         5632 :    LOGICAL FUNCTION xc_libxc_wrap_info_needs_laplace(xc_info)
     487              :       ! Only some MGGA functionals needs the laplacian
     488              :       TYPE(xc_f03_func_info_t), INTENT(IN)               :: xc_info
     489              : 
     490         5632 :       IF (IAND(xc_f03_func_info_get_flags(xc_info), XC_FLAGS_NEEDS_LAPLACIAN) == XC_FLAGS_NEEDS_LAPLACIAN) THEN
     491              :          xc_libxc_wrap_info_needs_laplace = .TRUE.
     492              :       ELSE
     493         4222 :          xc_libxc_wrap_info_needs_laplace = .FALSE.
     494              :       END IF
     495              : 
     496         5632 :    END FUNCTION xc_libxc_wrap_info_needs_laplace
     497              : 
     498              : ! **************************************************************************************************
     499              : !> \brief Whether the functional does not provide the energy density.
     500              : !> \param xc_info info object of an already initialized functional
     501              : !>
     502              : !> \return .TRUE. when LibXC cannot supply Exc for this functional
     503              : !> \author S. Lehtola
     504              : ! **************************************************************************************************
     505          498 :    LOGICAL FUNCTION xc_libxc_wrap_info_no_exc(xc_info)
     506              :       TYPE(xc_f03_func_info_t), INTENT(IN)               :: xc_info
     507              : 
     508          498 :       IF (IAND(xc_f03_func_info_get_flags(xc_info), XC_FLAGS_HAVE_EXC) == XC_FLAGS_HAVE_EXC) THEN
     509              :          xc_libxc_wrap_info_no_exc = .FALSE.
     510              :       ELSE
     511            0 :          xc_libxc_wrap_info_no_exc = .TRUE.
     512              :       END IF
     513              : 
     514          498 :    END FUNCTION xc_libxc_wrap_info_no_exc
     515              : 
     516              : #endif
     517              : #endif
     518              : END MODULE xc_libxc_wrap
        

Generated by: LCOV version 2.0-1