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

Generated by: LCOV version 2.0-1