1!! Copyright (C) 2016 Micael Oliveira
2!! 2020 Susi Lehtola
3!! All rights reserved.
4!!
5!! This Source Code Form is subject to the terms of the Mozilla Public
6!! License, v. 2.0. If a copy of the MPL was not distributed with this
7!! file, You can obtain one at mozilla.org/MPL/2.0/.
8
9module xc_f90_lib_m
10  use, intrinsic :: iso_c_binding
11  implicit none
12
13  private
14  public :: &
15    ! version
16    xc_f90_version, &
17    xc_f90_version_string, &
18    ! literature reference
19    xc_f90_reference, &
20    xc_f90_reference_doi, &
21    ! func_info
22    xc_f90_func_info_t, &
23    xc_f90_func_info_get_number, &
24    xc_f90_func_info_get_kind, &
25    xc_f90_func_info_get_name, &
26    xc_f90_func_info_get_family, &
27    xc_f90_func_info_get_references, &
28    xc_f90_func_info_get_flags, &
29    xc_f90_func_info_get_n_ext_params, &
30    xc_f90_func_info_get_ext_params_name, &
31    xc_f90_func_info_get_ext_params_description, &
32    xc_f90_func_info_get_ext_params_default_value, &
33    ! func_reference
34    xc_f90_func_reference_t, &
35    xc_f90_func_reference_get_ref, &
36    xc_f90_func_reference_get_doi, &
37    xc_f90_func_reference_get_bibtex, &
38    ! func
39    xc_f90_func_t, &
40    xc_f90_func_init, &
41    xc_f90_func_end, &
42    xc_f90_func_get_info, &
43    xc_f90_functional_get_name, &
44    xc_f90_functional_get_number, &
45    xc_f90_family_from_id, &
46    xc_f90_number_of_functionals, &
47    xc_f90_maximum_name_length, &
48    xc_f90_available_functional_numbers, &
49    xc_f90_available_functional_names, &
50    xc_f90_func_set_dens_threshold, &
51    xc_f90_func_set_zeta_threshold, &
52    xc_f90_func_set_sigma_threshold, &
53    xc_f90_func_set_tau_threshold, &
54    xc_f90_func_set_ext_params, &
55    xc_f90_func_set_ext_params_name, &
56    ! lda
57    xc_f90_lda, &
58    xc_f90_lda_exc, &
59    xc_f90_lda_exc_vxc, &
60    xc_f90_lda_exc_vxc_fxc, &
61    xc_f90_lda_exc_vxc_fxc_kxc, &
62    xc_f90_lda_vxc, &
63    xc_f90_lda_vxc_fxc, &
64    xc_f90_lda_vxc_fxc_kxc, &
65    xc_f90_lda_fxc, &
66    xc_f90_lda_kxc, &
67    xc_f90_lda_lxc, &
68    ! gga
69    xc_f90_gga, &
70    xc_f90_gga_exc, &
71    xc_f90_gga_exc_vxc, &
72    xc_f90_gga_exc_vxc_fxc, &
73    xc_f90_gga_exc_vxc_fxc_kxc, &
74    xc_f90_gga_vxc, &
75    xc_f90_gga_vxc_fxc, &
76    xc_f90_gga_vxc_fxc_kxc, &
77    xc_f90_gga_fxc, &
78    xc_f90_gga_kxc, &
79    xc_f90_gga_lxc, &
80    xc_f90_gga_ak13_get_asymptotic, &
81    xc_f90_hyb_exx_coef, &
82    xc_f90_hyb_cam_coef, &
83    xc_f90_nlc_coef, &
84    ! mgga
85    xc_f90_mgga, &
86    xc_f90_mgga_exc, &
87    xc_f90_mgga_exc_vxc, &
88    xc_f90_mgga_exc_vxc_fxc, &
89    xc_f90_mgga_exc_vxc_fxc_kxc, &
90    xc_f90_mgga_vxc, &
91    xc_f90_mgga_vxc_fxc, &
92    xc_f90_mgga_vxc_fxc_kxc, &
93    xc_f90_mgga_fxc, &
94    xc_f90_mgga_kxc, &
95    xc_f90_mgga_lxc
96
97  integer(c_int), parameter, public :: &
98    XC_UNPOLARIZED = 1, & ! Spin unpolarized
99    XC_POLARIZED = 2 ! Spin polarized
100
101    integer(c_int), parameter, public :: &
102    XC_NON_RELATIVISTIC = 0, & ! Functional includes or not relativistic
103    XC_RELATIVISTIC = 1 ! corrections. Only available in some functionals.
104
105  ! Kinds
106  integer(c_int), parameter, public :: &
107    XC_EXCHANGE = 0, &
108    XC_CORRELATION = 1, &
109    XC_EXCHANGE_CORRELATION = 2, &
110    XC_KINETIC = 3
111
112  ! Families of xc functionals
113  integer(c_int), parameter, public :: &
114    XC_FAMILY_UNKNOWN = -1, &
115    XC_FAMILY_NONE = 0, &
116    XC_FAMILY_LDA = 1, &
117    XC_FAMILY_GGA = 2, &
118    XC_FAMILY_MGGA = 4, &
119    XC_FAMILY_LCA = 8, &
120    XC_FAMILY_OEP = 16, &
121    XC_FAMILY_HYB_GGA = 32, &
122    XC_FAMILY_HYB_MGGA = 64, &
123    XC_FAMILY_HYB_LDA = 128
124
125  integer(c_int), parameter, public :: &
126    XC_FLAGS_HAVE_EXC = 1, &
127    XC_FLAGS_HAVE_VXC = 2, &
128    XC_FLAGS_HAVE_FXC = 4, &
129    XC_FLAGS_HAVE_KXC = 8, &
130    XC_FLAGS_HAVE_LXC = 16, &
131    XC_FLAGS_HAVE_ALL = 31, & ! The most common case
132    XC_FLAGS_1D = 32, &
133    XC_FLAGS_2D = 64, &
134    XC_FLAGS_3D = 128, &
135    XC_FLAGS_HYB_CAM = 256, &
136    XC_FLAGS_HYB_CAMY = 512, &
137    XC_FLAGS_VV10 = 1024, &
138    XC_FLAGS_HYB_LC = 2048, &
139    XC_FLAGS_HYB_LCY = 4096, &
140    XC_FLAGS_STABLE = 8192, &
141    XC_FLAGS_DEVELOPMENT = 16384, &
142    XC_FLAGS_NEEDS_LAPLACIAN = 32768
143
144  integer(c_int), parameter, public :: &
145    XC_TAU_EXPLICIT = 0, &
146    XC_TAU_EXPANSION = 1
147
148  integer(c_int), parameter, public :: &
149    XC_MAX_REFERENCES = 5
150
151  ! List of functionals
152  integer(c_int), parameter, public :: XC_HYB_LDA_XC_LDA0 = 177 ! LDA0: hybrid LDA exchange
153  integer(c_int), parameter, public :: XC_HYB_LDA_XC_CAM_LDA0 = 178 ! CAM version of LDA0
154  integer(c_int), parameter, public :: XC_LDA_X = 1 ! Exchange
155  integer(c_int), parameter, public :: XC_LDA_C_WIGNER = 2 ! Wigner parametrization
156  integer(c_int), parameter, public :: XC_LDA_C_RPA = 3 ! Random Phase Approximation
157  integer(c_int), parameter, public :: XC_LDA_C_HL = 4 ! Hedin & Lundqvist
158  integer(c_int), parameter, public :: XC_LDA_C_GL = 5 ! Gunnarson & Lundqvist
159  integer(c_int), parameter, public :: XC_LDA_C_XALPHA = 6 ! Slater Xalpha
160  integer(c_int), parameter, public :: XC_LDA_C_VWN = 7 ! Vosko, Wilk, & Nusair (5)
161  integer(c_int), parameter, public :: XC_LDA_C_VWN_RPA = 8 ! Vosko, Wilk, & Nusair (RPA)
162  integer(c_int), parameter, public :: XC_LDA_C_PZ = 9 ! Perdew & Zunger
163  integer(c_int), parameter, public :: XC_LDA_C_PZ_MOD = 10 ! Perdew & Zunger (Modified)
164  integer(c_int), parameter, public :: XC_LDA_C_OB_PZ = 11 ! Ortiz & Ballone (PZ)
165  integer(c_int), parameter, public :: XC_LDA_C_PW = 12 ! Perdew & Wang
166  integer(c_int), parameter, public :: XC_LDA_C_PW_MOD = 13 ! Perdew & Wang (Modified)
167  integer(c_int), parameter, public :: XC_LDA_C_OB_PW = 14 ! Ortiz & Ballone (PW)
168  integer(c_int), parameter, public :: XC_LDA_C_2D_AMGB = 15 ! Attaccalite et al
169  integer(c_int), parameter, public :: XC_LDA_C_2D_PRM = 16 ! Pittalis, Rasanen & Marques correlation in 2D
170  integer(c_int), parameter, public :: XC_LDA_C_VBH = 17 ! von Barth & Hedin
171  integer(c_int), parameter, public :: XC_LDA_C_1D_CSC = 18 ! Casula, Sorella, and Senatore 1D correlation
172  integer(c_int), parameter, public :: XC_LDA_X_2D = 19 ! Exchange in 2D
173  integer(c_int), parameter, public :: XC_LDA_XC_TETER93 = 20 ! Teter 93 parametrization
174  integer(c_int), parameter, public :: XC_LDA_X_1D_SOFT = 21 ! Exchange in 1D for a soft-Coulomb interaction
175  integer(c_int), parameter, public :: XC_LDA_C_ML1 = 22 ! Modified LSD (version 1) of Proynov and Salahub
176  integer(c_int), parameter, public :: XC_LDA_C_ML2 = 23 ! Modified LSD (version 2) of Proynov and Salahub
177  integer(c_int), parameter, public :: XC_LDA_C_GOMBAS = 24 ! Gombas parametrization
178  integer(c_int), parameter, public :: XC_LDA_C_PW_RPA = 25 ! Perdew & Wang fit of the RPA
179  integer(c_int), parameter, public :: XC_LDA_C_1D_LOOS = 26 ! P-F Loos correlation LDA
180  integer(c_int), parameter, public :: XC_LDA_C_RC04 = 27 ! Ragot-Cortona
181  integer(c_int), parameter, public :: XC_LDA_C_VWN_1 = 28 ! Vosko, Wilk, & Nusair (1)
182  integer(c_int), parameter, public :: XC_LDA_C_VWN_2 = 29 ! Vosko, Wilk, & Nusair (2)
183  integer(c_int), parameter, public :: XC_LDA_C_VWN_3 = 30 ! Vosko, Wilk, & Nusair (3)
184  integer(c_int), parameter, public :: XC_LDA_C_VWN_4 = 31 ! Vosko, Wilk, & Nusair (4)
185  integer(c_int), parameter, public :: XC_LDA_XC_ZLP = 43 ! Zhao, Levy & Parr, Eq. (20)
186  integer(c_int), parameter, public :: XC_LDA_K_TF = 50 ! Thomas-Fermi kinetic energy functional
187  integer(c_int), parameter, public :: XC_LDA_K_LP = 51 ! Lee and Parr Gaussian ansatz
188  integer(c_int), parameter, public :: XC_LDA_XC_KSDT = 259 ! Karasiev et al. parametrization
189  integer(c_int), parameter, public :: XC_LDA_C_CHACHIYO = 287 ! Chachiyo simple 2 parameter correlation
190  integer(c_int), parameter, public :: XC_LDA_C_LP96 = 289 ! Liu-Parr correlation
191  integer(c_int), parameter, public :: XC_LDA_C_CHACHIYO_MOD = 307 ! Chachiyo simple 2 parameter correlation with modified scaling
192  integer(c_int), parameter, public :: XC_LDA_C_KARASIEV_MOD = 308 ! Karasiev reparameterization of Chachiyo with modified scaling
193  integer(c_int), parameter, public :: XC_LDA_X_REL = 532 ! Relativistic exchange
194  integer(c_int), parameter, public :: XC_LDA_XC_1D_EHWLRG_1 = 536 ! LDA constructed from slab-like systems of 1 electron
195  integer(c_int), parameter, public :: XC_LDA_XC_1D_EHWLRG_2 = 537 ! LDA constructed from slab-like systems of 2 electrons
196  integer(c_int), parameter, public :: XC_LDA_XC_1D_EHWLRG_3 = 538 ! LDA constructed from slab-like systems of 3 electrons
197  integer(c_int), parameter, public :: XC_LDA_X_ERF = 546 ! Attenuated exchange LDA (erf)
198  integer(c_int), parameter, public :: XC_LDA_XC_LP_A = 547 ! Lee-Parr reparametrization A
199  integer(c_int), parameter, public :: XC_LDA_XC_LP_B = 548 ! Lee-Parr reparametrization B
200  integer(c_int), parameter, public :: XC_LDA_X_RAE = 549 ! Rae self-energy corrected exchange
201  integer(c_int), parameter, public :: XC_LDA_K_ZLP = 550 ! kinetic energy version of ZLP
202  integer(c_int), parameter, public :: XC_LDA_C_MCWEENY = 551 ! McWeeny 76
203  integer(c_int), parameter, public :: XC_LDA_C_BR78 = 552 ! Brual & Rothstein 78
204  integer(c_int), parameter, public :: XC_LDA_C_PK09 = 554 ! Proynov and Kong 2009
205  integer(c_int), parameter, public :: XC_LDA_C_OW_LYP = 573 ! Wigner with corresponding LYP parameters
206  integer(c_int), parameter, public :: XC_LDA_C_OW = 574 ! Optimized Wigner
207  integer(c_int), parameter, public :: XC_LDA_XC_GDSMFB = 577 ! Groth et al. parametrization
208  integer(c_int), parameter, public :: XC_LDA_C_GK72 = 578 ! Gordon and Kim 1972
209  integer(c_int), parameter, public :: XC_LDA_C_KARASIEV = 579 ! Karasiev reparameterization of Chachiyo
210  integer(c_int), parameter, public :: XC_LDA_K_LP96 = 580 ! Liu-Parr kinetic
211  integer(c_int), parameter, public :: XC_LDA_XC_BN05 = 588 ! Baer and Neuhauser, gamma=1
212  integer(c_int), parameter, public :: XC_LDA_C_PMGB06 = 590 ! Long-range LDA correlation functional
213  integer(c_int), parameter, public :: XC_LDA_XC_TIH = 599 ! Neural network LDA from Tozer et al
214  integer(c_int), parameter, public :: XC_LDA_X_1D_EXPONENTIAL = 600 ! Exchange in 1D for an exponentially screened interaction
215  integer(c_int), parameter, public :: XC_LDA_C_UPW92 = 683 ! Ruggeri, Rios, and Alavi unrestricted fit
216  integer(c_int), parameter, public :: XC_LDA_C_RPW92 = 684 ! Ruggeri, Rios, and Alavi restricted fit
217  integer(c_int), parameter, public :: XC_LDA_X_SLOC = 692 ! simple local model for Slater potential
218  integer(c_int), parameter, public :: XC_HYB_GGA_X_N12_SX = 81 ! N12-SX functional from Minnesota
219  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B97_1P = 266 ! version of B97 by Cohen and Handy
220  integer(c_int), parameter, public :: XC_HYB_GGA_XC_PBE_MOL0 = 273 ! PBEmol0
221  integer(c_int), parameter, public :: XC_HYB_GGA_XC_PBE_SOL0 = 274 ! PBEsol0
222  integer(c_int), parameter, public :: XC_HYB_GGA_XC_PBEB0 = 275 ! PBEbeta0
223  integer(c_int), parameter, public :: XC_HYB_GGA_XC_PBE_MOLB0 = 276 ! PBEmolbeta0
224  integer(c_int), parameter, public :: XC_HYB_GGA_XC_PBE50 = 290 ! PBE0 with 50% exx
225  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HFLYP = 314 ! Hartree-Fock + LYP correlation
226  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAM_O3LYP = 395 ! range separated hybrid based on the optx functional
227  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WB97X_D3 = 399 ! Lin et al
228  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_BLYP = 400 ! Long-range corrected BLYP
229  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B3PW91 = 401 ! The original (ACM) hybrid of Becke
230  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B3LYP = 402 ! The (in)famous B3LYP
231  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B3P86 = 403 ! Perdew 86 hybrid similar to B3PW91
232  integer(c_int), parameter, public :: XC_HYB_GGA_XC_O3LYP = 404 ! hybrid using the optx functional
233  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MPW1K = 405 ! mixture of mPW91 and PW91 optimized for kinetics
234  integer(c_int), parameter, public :: XC_HYB_GGA_XC_PBEH = 406 ! aka PBE0 or PBE1PBE
235  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B97 = 407 ! Becke 97
236  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B97_1 = 408 ! Becke 97-1
237  integer(c_int), parameter, public :: XC_HYB_GGA_XC_APF = 409 ! APF hybrid density functional
238  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B97_2 = 410 ! Becke 97-2
239  integer(c_int), parameter, public :: XC_HYB_GGA_XC_X3LYP = 411 ! hybrid by Xu and Goddard
240  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B1WC = 412 ! Becke 1-parameter mixture of WC and PBE
241  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B97_K = 413 ! Boese-Martin for Kinetics
242  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B97_3 = 414 ! Becke 97-3
243  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MPW3PW = 415 ! mixture with the mPW functional
244  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B1LYP = 416 ! Becke 1-parameter mixture of B88 and LYP
245  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B1PW91 = 417 ! Becke 1-parameter mixture of B88 and PW91
246  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MPW1PW = 418 ! Becke 1-parameter mixture of mPW91 and PW91
247  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MPW3LYP = 419 ! mixture of mPW and LYP
248  integer(c_int), parameter, public :: XC_HYB_GGA_XC_SB98_1A = 420 ! Schmider-Becke 98 parameterization 1a
249  integer(c_int), parameter, public :: XC_HYB_GGA_XC_SB98_1B = 421 ! Schmider-Becke 98 parameterization 1b
250  integer(c_int), parameter, public :: XC_HYB_GGA_XC_SB98_1C = 422 ! Schmider-Becke 98 parameterization 1c
251  integer(c_int), parameter, public :: XC_HYB_GGA_XC_SB98_2A = 423 ! Schmider-Becke 98 parameterization 2a
252  integer(c_int), parameter, public :: XC_HYB_GGA_XC_SB98_2B = 424 ! Schmider-Becke 98 parameterization 2b
253  integer(c_int), parameter, public :: XC_HYB_GGA_XC_SB98_2C = 425 ! Schmider-Becke 98 parameterization 2c
254  integer(c_int), parameter, public :: XC_HYB_GGA_X_SOGGA11_X = 426 ! Hybrid based on SOGGA11 form
255  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HSE03 = 427 ! the 2003 version of the screened hybrid HSE
256  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HSE06 = 428 ! the 2006 version of the screened hybrid HSE
257  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HJS_PBE = 429 ! HJS hybrid screened exchange PBE version
258  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HJS_PBE_SOL = 430 ! HJS hybrid screened exchange PBE_SOL version
259  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HJS_B88 = 431 ! HJS hybrid screened exchange B88 version
260  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HJS_B97X = 432 ! HJS hybrid screened exchange B97x version
261  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAM_B3LYP = 433 ! CAM version of B3LYP
262  integer(c_int), parameter, public :: XC_HYB_GGA_XC_TUNED_CAM_B3LYP = 434 ! CAM version of B3LYP tuned for excitations
263  integer(c_int), parameter, public :: XC_HYB_GGA_XC_BHANDH = 435 ! Becke half-and-half or BHLYP
264  integer(c_int), parameter, public :: XC_HYB_GGA_XC_BHANDHLYP = 436 ! Becke half-and-half with B88 exchange
265  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MB3LYP_RC04 = 437 ! B3LYP with RC04 LDA
266  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MPWLYP1M = 453 ! MPW with 1 par. for metals/LYP
267  integer(c_int), parameter, public :: XC_HYB_GGA_XC_REVB3LYP = 454 ! Revised B3LYP
268  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAMY_BLYP = 455 ! BLYP with yukawa screening
269  integer(c_int), parameter, public :: XC_HYB_GGA_XC_PBE0_13 = 456 ! PBE0-1/3
270  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B3LYPS = 459 ! B3LYP* functional
271  integer(c_int), parameter, public :: XC_HYB_GGA_XC_QTP17 = 460 ! global hybrid for vertical ionization potentials
272  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B3LYP_MCM1 = 461 ! B3LYP reoptimized in 6-31+G(2df,p) for enthalpies of formation
273  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B3LYP_MCM2 = 462 ! B3LYP reoptimized in 6-31+G(2df,p) for enthalpies of formation
274  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WB97 = 463 ! Chai and Head-Gordon
275  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WB97X = 464 ! Chai and Head-Gordon
276  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LRC_WPBEH = 465 ! Long-range corrected functional by Rorhdanz et al
277  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WB97X_V = 466 ! Mardirossian and Head-Gordon
278  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LCY_PBE = 467 ! PBE with yukawa screening
279  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LCY_BLYP = 468 ! BLYP with yukawa screening
280  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_VV10 = 469 ! Vydrov and Van Voorhis
281  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAMY_B3LYP = 470 ! B3LYP with Yukawa screening
282  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WB97X_D = 471 ! Chai and Head-Gordon
283  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HPBEINT = 472 ! hPBEint
284  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LRC_WPBE = 473 ! Long-range corrected functional by Rorhdanz et al
285  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B3LYP5 = 475 ! B3LYP with VWN functional 5 instead of RPA
286  integer(c_int), parameter, public :: XC_HYB_GGA_XC_EDF2 = 476 ! Empirical functional from Lin, George and Gill
287  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAP0 = 477 ! Correct Asymptotic Potential hybrid
288  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_WPBE = 478 ! Long-range corrected functional by Vydrov and Scuseria
289  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HSE12 = 479 ! HSE12 by Moussa, Schultz and Chelikowsky
290  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HSE12S = 480 ! Short-range HSE12 by Moussa, Schultz, and Chelikowsky
291  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HSE_SOL = 481 ! HSEsol functional by Schimka, Harl, and Kresse
292  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAM_QTP_01 = 482 ! CAM-QTP-01
293  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MPW1LYP = 483 ! Becke 1-parameter mixture of mPW91 and LYP
294  integer(c_int), parameter, public :: XC_HYB_GGA_XC_MPW1PBE = 484 ! Becke 1-parameter mixture of mPW91 and PBE
295  integer(c_int), parameter, public :: XC_HYB_GGA_XC_KMLYP = 485 ! Kang-Musgrave hybrid
296  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_WPBE_WHS = 486 ! Long-range corrected functional by Weintraub, Henderson and Scuseria
297  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_WPBEH_WHS = 487 ! Long-range corrected functional by Weintraub, Henderson and Scuseria
298  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_WPBE08_WHS = 488 ! Long-range corrected functional by Weintraub, Henderson and Scuseria
299  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_WPBESOL_WHS = 489 ! Long-range corrected functional by Weintraub, Henderson and Scuseria
300  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAM_QTP_00 = 490 ! CAM-QTP-00
301  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAM_QTP_02 = 491 ! CAM-QTP-02
302  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_QTP = 492 ! LC-QTP
303  integer(c_int), parameter, public :: XC_HYB_GGA_X_S12H = 496 ! Swart 2012 GGA hybrid exchange
304  integer(c_int), parameter, public :: XC_HYB_GGA_XC_BLYP35 = 499 ! Becke 1-parameter mixture for mixed-valence systems
305  integer(c_int), parameter, public :: XC_HYB_GGA_XC_B5050LYP = 572 ! Like B3LYP but more exact exchange
306  integer(c_int), parameter, public :: XC_HYB_GGA_XC_APBE0 = 607 ! Hybrid based on APBE
307  integer(c_int), parameter, public :: XC_HYB_GGA_XC_HAPBE = 608 ! Hybrid based in APBE and zvPBEloc
308  integer(c_int), parameter, public :: XC_HYB_GGA_XC_RCAM_B3LYP = 610 ! Similar to CAM-B3LYP, but trying to reduce the many-electron self-interaction
309  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WC04 = 611 ! hybrid fitted to carbon NMR shifts
310  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WP04 = 612 ! hybrid fitted to proton NMR shifts
311  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAMH_B3LYP = 614 ! CAM version of B3LYP tuned for tddft
312  integer(c_int), parameter, public :: XC_HYB_GGA_XC_WHPBE0 = 615 ! Long-range corrected functional by Shao et al
313  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_BOP = 636 ! Long-range corrected B88 with B88OP correlation
314  integer(c_int), parameter, public :: XC_HYB_GGA_XC_LC_PBEOP = 637 ! Long-range corrected PBE with PBEOP correlation
315  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAM_PBEH = 681 ! CAM version of PBEH
316  integer(c_int), parameter, public :: XC_HYB_GGA_XC_CAMY_PBEH = 682 ! PBEH with Yukawa screening
317  integer(c_int), parameter, public :: XC_GGA_X_GAM = 32 ! GAM functional from Minnesota
318  integer(c_int), parameter, public :: XC_GGA_C_GAM = 33 ! GAM functional from Minnesota
319  integer(c_int), parameter, public :: XC_GGA_X_HCTH_A = 34 ! HCTH-A
320  integer(c_int), parameter, public :: XC_GGA_X_EV93 = 35 ! Engel and Vosko
321  integer(c_int), parameter, public :: XC_GGA_X_BCGP = 38 ! Burke, Cancio, Gould, and Pittalis
322  integer(c_int), parameter, public :: XC_GGA_C_ACGGA = 39 ! acGGA, asymptotically corrected GGA
323  integer(c_int), parameter, public :: XC_GGA_X_LAMBDA_OC2_N = 40 ! lambda_OC2(N) version of PBE
324  integer(c_int), parameter, public :: XC_GGA_X_B86_R = 41 ! Revised Becke 86 Xalpha,beta,gamma (with mod. grad. correction)
325  integer(c_int), parameter, public :: XC_GGA_X_LAMBDA_CH_N = 44 ! lambda_CH(N) version of PBE
326  integer(c_int), parameter, public :: XC_GGA_X_LAMBDA_LO_N = 45 ! lambda_LO(N) version of PBE
327  integer(c_int), parameter, public :: XC_GGA_X_HJS_B88_V2 = 46 ! HJS screened exchange corrected B88 version
328  integer(c_int), parameter, public :: XC_GGA_C_Q2D = 47 ! Chiodo et al
329  integer(c_int), parameter, public :: XC_GGA_X_Q2D = 48 ! Chiodo et al
330  integer(c_int), parameter, public :: XC_GGA_X_PBE_MOL = 49 ! Del Campo, Gazquez, Trickey and Vela (PBE-like)
331  integer(c_int), parameter, public :: XC_GGA_K_TFVW = 52 ! Thomas-Fermi plus von Weiszaecker correction
332  integer(c_int), parameter, public :: XC_GGA_K_REVAPBEINT = 53 ! interpolated version of REVAPBE
333  integer(c_int), parameter, public :: XC_GGA_K_APBEINT = 54 ! interpolated version of APBE
334  integer(c_int), parameter, public :: XC_GGA_K_REVAPBE = 55 ! revised APBE
335  integer(c_int), parameter, public :: XC_GGA_X_AK13 = 56 ! Armiento & Kuemmel 2013
336  integer(c_int), parameter, public :: XC_GGA_K_MEYER = 57 ! Meyer, Wang, and Young
337  integer(c_int), parameter, public :: XC_GGA_X_LV_RPW86 = 58 ! Berland and Hyldgaard
338  integer(c_int), parameter, public :: XC_GGA_X_PBE_TCA = 59 ! PBE revised by Tognetti et al
339  integer(c_int), parameter, public :: XC_GGA_X_PBEINT = 60 ! PBE for hybrid interfaces
340  integer(c_int), parameter, public :: XC_GGA_C_ZPBEINT = 61 ! spin-dependent gradient correction to PBEint
341  integer(c_int), parameter, public :: XC_GGA_C_PBEINT = 62 ! PBE for hybrid interfaces
342  integer(c_int), parameter, public :: XC_GGA_C_ZPBESOL = 63 ! spin-dependent gradient correction to PBEsol
343  integer(c_int), parameter, public :: XC_GGA_XC_OPBE_D = 65 ! oPBE_D functional of Goerigk and Grimme
344  integer(c_int), parameter, public :: XC_GGA_XC_OPWLYP_D = 66 ! oPWLYP-D functional of Goerigk and Grimme
345  integer(c_int), parameter, public :: XC_GGA_XC_OBLYP_D = 67 ! oBLYP-D functional of Goerigk and Grimme
346  integer(c_int), parameter, public :: XC_GGA_X_VMT84_GE = 68 ! VMT{8,4} with constraint satisfaction with mu = mu_GE
347  integer(c_int), parameter, public :: XC_GGA_X_VMT84_PBE = 69 ! VMT{8,4} with constraint satisfaction with mu = mu_PBE
348  integer(c_int), parameter, public :: XC_GGA_X_VMT_GE = 70 ! Vela, Medel, and Trickey with mu = mu_GE
349  integer(c_int), parameter, public :: XC_GGA_X_VMT_PBE = 71 ! Vela, Medel, and Trickey with mu = mu_PBE
350  integer(c_int), parameter, public :: XC_GGA_C_N12_SX = 79 ! N12-SX functional from Minnesota
351  integer(c_int), parameter, public :: XC_GGA_C_N12 = 80 ! N12 functional from Minnesota
352  integer(c_int), parameter, public :: XC_GGA_X_N12 = 82 ! N12 functional from Minnesota
353  integer(c_int), parameter, public :: XC_GGA_C_REGTPSS = 83 ! Regularized TPSS correlation (ex-VPBE)
354  integer(c_int), parameter, public :: XC_GGA_C_OP_XALPHA = 84 ! one-parameter progressive functional (XALPHA version)
355  integer(c_int), parameter, public :: XC_GGA_C_OP_G96 = 85 ! one-parameter progressive functional (G96 version)
356  integer(c_int), parameter, public :: XC_GGA_C_OP_PBE = 86 ! one-parameter progressive functional (PBE version)
357  integer(c_int), parameter, public :: XC_GGA_C_OP_B88 = 87 ! one-parameter progressive functional (B88 version)
358  integer(c_int), parameter, public :: XC_GGA_C_FT97 = 88 ! Filatov & Thiel correlation
359  integer(c_int), parameter, public :: XC_GGA_C_SPBE = 89 ! PBE correlation to be used with the SSB exchange
360  integer(c_int), parameter, public :: XC_GGA_X_SSB_SW = 90 ! Swart, Sola and Bickelhaupt correction to PBE
361  integer(c_int), parameter, public :: XC_GGA_X_SSB = 91 ! Swart, Sola and Bickelhaupt
362  integer(c_int), parameter, public :: XC_GGA_X_SSB_D = 92 ! Swart, Sola and Bickelhaupt dispersion
363  integer(c_int), parameter, public :: XC_GGA_XC_HCTH_407P = 93 ! HCTH/407+
364  integer(c_int), parameter, public :: XC_GGA_XC_HCTH_P76 = 94 ! HCTH p=7/6
365  integer(c_int), parameter, public :: XC_GGA_XC_HCTH_P14 = 95 ! HCTH p=1/4
366  integer(c_int), parameter, public :: XC_GGA_XC_B97_GGA1 = 96 ! Becke 97 GGA-1
367  integer(c_int), parameter, public :: XC_GGA_C_HCTH_A = 97 ! HCTH-A
368  integer(c_int), parameter, public :: XC_GGA_X_BPCCAC = 98 ! BPCCAC (GRAC for the energy)
369  integer(c_int), parameter, public :: XC_GGA_C_REVTCA = 99 ! Tognetti, Cortona, Adamo (revised)
370  integer(c_int), parameter, public :: XC_GGA_C_TCA = 100 ! Tognetti, Cortona, Adamo
371  integer(c_int), parameter, public :: XC_GGA_X_PBE = 101 ! Perdew, Burke & Ernzerhof exchange
372  integer(c_int), parameter, public :: XC_GGA_X_PBE_R = 102 ! Perdew, Burke & Ernzerhof exchange (revised)
373  integer(c_int), parameter, public :: XC_GGA_X_B86 = 103 ! Becke 86 Xalpha,beta,gamma
374  integer(c_int), parameter, public :: XC_GGA_X_HERMAN = 104 ! Herman et al original GGA
375  integer(c_int), parameter, public :: XC_GGA_X_B86_MGC = 105 ! Becke 86 Xalpha,beta,gamma (with mod. grad. correction)
376  integer(c_int), parameter, public :: XC_GGA_X_B88 = 106 ! Becke 88
377  integer(c_int), parameter, public :: XC_GGA_X_G96 = 107 ! Gill 96
378  integer(c_int), parameter, public :: XC_GGA_X_PW86 = 108 ! Perdew & Wang 86
379  integer(c_int), parameter, public :: XC_GGA_X_PW91 = 109 ! Perdew & Wang 91
380  integer(c_int), parameter, public :: XC_GGA_X_OPTX = 110 ! Handy & Cohen OPTX 01
381  integer(c_int), parameter, public :: XC_GGA_X_DK87_R1 = 111 ! dePristo & Kress 87 (version R1)
382  integer(c_int), parameter, public :: XC_GGA_X_DK87_R2 = 112 ! dePristo & Kress 87 (version R2)
383  integer(c_int), parameter, public :: XC_GGA_X_LG93 = 113 ! Lacks & Gordon 93
384  integer(c_int), parameter, public :: XC_GGA_X_FT97_A = 114 ! Filatov & Thiel 97 (version A)
385  integer(c_int), parameter, public :: XC_GGA_X_FT97_B = 115 ! Filatov & Thiel 97 (version B)
386  integer(c_int), parameter, public :: XC_GGA_X_PBE_SOL = 116 ! Perdew, Burke & Ernzerhof exchange (solids)
387  integer(c_int), parameter, public :: XC_GGA_X_RPBE = 117 ! Hammer, Hansen & Norskov (PBE-like)
388  integer(c_int), parameter, public :: XC_GGA_X_WC = 118 ! Wu & Cohen
389  integer(c_int), parameter, public :: XC_GGA_X_MPW91 = 119 ! Modified form of PW91 by Adamo & Barone
390  integer(c_int), parameter, public :: XC_GGA_X_AM05 = 120 ! Armiento & Mattsson 05 exchange
391  integer(c_int), parameter, public :: XC_GGA_X_PBEA = 121 ! Madsen (PBE-like)
392  integer(c_int), parameter, public :: XC_GGA_X_MPBE = 122 ! Adamo & Barone modification to PBE
393  integer(c_int), parameter, public :: XC_GGA_X_XPBE = 123 ! xPBE reparametrization by Xu & Goddard
394  integer(c_int), parameter, public :: XC_GGA_X_2D_B86_MGC = 124 ! Becke 86 MGC for 2D systems
395  integer(c_int), parameter, public :: XC_GGA_X_BAYESIAN = 125 ! Bayesian best fit for the enhancement factor
396  integer(c_int), parameter, public :: XC_GGA_X_PBE_JSJR = 126 ! JSJR reparametrization by Pedroza, Silva & Capelle
397  integer(c_int), parameter, public :: XC_GGA_X_2D_B88 = 127 ! Becke 88 in 2D
398  integer(c_int), parameter, public :: XC_GGA_X_2D_B86 = 128 ! Becke 86 Xalpha, beta, gamma
399  integer(c_int), parameter, public :: XC_GGA_X_2D_PBE = 129 ! Perdew, Burke & Ernzerhof exchange in 2D
400  integer(c_int), parameter, public :: XC_GGA_C_PBE = 130 ! Perdew, Burke & Ernzerhof correlation
401  integer(c_int), parameter, public :: XC_GGA_C_LYP = 131 ! Lee, Yang & Parr
402  integer(c_int), parameter, public :: XC_GGA_C_P86 = 132 ! Perdew 86
403  integer(c_int), parameter, public :: XC_GGA_C_PBE_SOL = 133 ! Perdew, Burke & Ernzerhof correlation SOL
404  integer(c_int), parameter, public :: XC_GGA_C_PW91 = 134 ! Perdew & Wang 91
405  integer(c_int), parameter, public :: XC_GGA_C_AM05 = 135 ! Armiento & Mattsson 05 correlation
406  integer(c_int), parameter, public :: XC_GGA_C_XPBE = 136 ! xPBE reparametrization by Xu & Goddard
407  integer(c_int), parameter, public :: XC_GGA_C_LM = 137 ! Langreth and Mehl correlation
408  integer(c_int), parameter, public :: XC_GGA_C_PBE_JRGX = 138 ! JRGX reparametrization by Pedroza, Silva & Capelle
409  integer(c_int), parameter, public :: XC_GGA_X_OPTB88_VDW = 139 ! Becke 88 reoptimized to be used with vdW functional of Dion et al
410  integer(c_int), parameter, public :: XC_GGA_X_PBEK1_VDW = 140 ! PBE reparametrization for vdW
411  integer(c_int), parameter, public :: XC_GGA_X_OPTPBE_VDW = 141 ! PBE reparametrization for vdW
412  integer(c_int), parameter, public :: XC_GGA_X_RGE2 = 142 ! Regularized PBE
413  integer(c_int), parameter, public :: XC_GGA_C_RGE2 = 143 ! Regularized PBE
414  integer(c_int), parameter, public :: XC_GGA_X_RPW86 = 144 ! refitted Perdew & Wang 86
415  integer(c_int), parameter, public :: XC_GGA_X_KT1 = 145 ! Exchange part of Keal and Tozer version 1
416  integer(c_int), parameter, public :: XC_GGA_XC_KT2 = 146 ! Keal and Tozer version 2
417  integer(c_int), parameter, public :: XC_GGA_C_WL = 147 ! Wilson & Levy
418  integer(c_int), parameter, public :: XC_GGA_C_WI = 148 ! Wilson & Ivanov
419  integer(c_int), parameter, public :: XC_GGA_X_MB88 = 149 ! Modified Becke 88 for proton transfer
420  integer(c_int), parameter, public :: XC_GGA_X_SOGGA = 150 ! Second-order generalized gradient approximation
421  integer(c_int), parameter, public :: XC_GGA_X_SOGGA11 = 151 ! Second-order generalized gradient approximation 2011
422  integer(c_int), parameter, public :: XC_GGA_C_SOGGA11 = 152 ! SOGGA11 correlation
423  integer(c_int), parameter, public :: XC_GGA_C_WI0 = 153 ! Wilson & Ivanov initial version
424  integer(c_int), parameter, public :: XC_GGA_XC_TH1 = 154 ! Tozer and Handy v. 1
425  integer(c_int), parameter, public :: XC_GGA_XC_TH2 = 155 ! Tozer and Handy v. 2
426  integer(c_int), parameter, public :: XC_GGA_XC_TH3 = 156 ! Tozer and Handy v. 3
427  integer(c_int), parameter, public :: XC_GGA_XC_TH4 = 157 ! Tozer and Handy v. 4
428  integer(c_int), parameter, public :: XC_GGA_X_C09X = 158 ! C09x to be used with the VdW of Rutgers-Chalmers
429  integer(c_int), parameter, public :: XC_GGA_C_SOGGA11_X = 159 ! SOGGA11-X correlation
430  integer(c_int), parameter, public :: XC_GGA_X_LB = 160 ! van Leeuwen & Baerends
431  integer(c_int), parameter, public :: XC_GGA_XC_HCTH_93 = 161 ! HCTH functional fitted to 93 molecules
432  integer(c_int), parameter, public :: XC_GGA_XC_HCTH_120 = 162 ! HCTH functional fitted to 120 molecules
433  integer(c_int), parameter, public :: XC_GGA_XC_HCTH_147 = 163 ! HCTH functional fitted to 147 molecules
434  integer(c_int), parameter, public :: XC_GGA_XC_HCTH_407 = 164 ! HCTH functional fitted to 407 molecules
435  integer(c_int), parameter, public :: XC_GGA_XC_EDF1 = 165 ! Empirical functionals from Adamson, Gill, and Pople
436  integer(c_int), parameter, public :: XC_GGA_XC_XLYP = 166 ! XLYP functional
437  integer(c_int), parameter, public :: XC_GGA_XC_KT1 = 167 ! Keal and Tozer version 1
438  integer(c_int), parameter, public :: XC_GGA_X_LSPBE = 168 ! PW91-like exchange with simple analytical form
439  integer(c_int), parameter, public :: XC_GGA_X_LSRPBE = 169 ! PW91-like modification of RPBE
440  integer(c_int), parameter, public :: XC_GGA_XC_B97_D = 170 ! Grimme functional to be used with C6 vdW term
441  integer(c_int), parameter, public :: XC_GGA_X_OPTB86B_VDW = 171 ! Becke 86 reoptimized for use with vdW functional of Dion et al
442  integer(c_int), parameter, public :: XC_GGA_XC_PBE1W = 173 ! Functionals fitted for water
443  integer(c_int), parameter, public :: XC_GGA_XC_MPWLYP1W = 174 ! Functionals fitted for water
444  integer(c_int), parameter, public :: XC_GGA_XC_PBELYP1W = 175 ! Functionals fitted for water
445  integer(c_int), parameter, public :: XC_GGA_C_ACGGAP = 176 ! Asymptotically corrected GGA +
446  integer(c_int), parameter, public :: XC_GGA_X_B88_6311G = 179 ! Becke 88 reoptimized with 6-311G** basis set
447  integer(c_int), parameter, public :: XC_GGA_X_NCAP = 180 ! Nearly correct asymptotic potential
448  integer(c_int), parameter, public :: XC_GGA_XC_NCAP = 181 ! Nearly correct asymptotic potential + P86 correlation
449  integer(c_int), parameter, public :: XC_GGA_X_LBM = 182 ! van Leeuwen & Baerends modified
450  integer(c_int), parameter, public :: XC_GGA_X_OL2 = 183 ! Exchange form based on Ou-Yang and Levy v.2
451  integer(c_int), parameter, public :: XC_GGA_X_APBE = 184 ! mu fixed from the semiclassical neutral atom
452  integer(c_int), parameter, public :: XC_GGA_K_APBE = 185 ! mu fixed from the semiclassical neutral atom
453  integer(c_int), parameter, public :: XC_GGA_C_APBE = 186 ! mu fixed from the semiclassical neutral atom
454  integer(c_int), parameter, public :: XC_GGA_K_TW1 = 187 ! Tran and Wesolowski set 1 (Table II)
455  integer(c_int), parameter, public :: XC_GGA_K_TW2 = 188 ! Tran and Wesolowski set 2 (Table II)
456  integer(c_int), parameter, public :: XC_GGA_K_TW3 = 189 ! Tran and Wesolowski set 3 (Table II)
457  integer(c_int), parameter, public :: XC_GGA_K_TW4 = 190 ! Tran and Wesolowski set 4 (Table II)
458  integer(c_int), parameter, public :: XC_GGA_X_HTBS = 191 ! Haas, Tran, Blaha, and Schwarz
459  integer(c_int), parameter, public :: XC_GGA_X_AIRY = 192 ! Constantin et al based on the Airy gas
460  integer(c_int), parameter, public :: XC_GGA_X_LAG = 193 ! Local Airy Gas
461  integer(c_int), parameter, public :: XC_GGA_XC_MOHLYP = 194 ! Functional for organometallic chemistry
462  integer(c_int), parameter, public :: XC_GGA_XC_MOHLYP2 = 195 ! Functional for barrier heights
463  integer(c_int), parameter, public :: XC_GGA_XC_TH_FL = 196 ! Tozer and Handy v. FL
464  integer(c_int), parameter, public :: XC_GGA_XC_TH_FC = 197 ! Tozer and Handy v. FC
465  integer(c_int), parameter, public :: XC_GGA_XC_TH_FCFO = 198 ! Tozer and Handy v. FCFO
466  integer(c_int), parameter, public :: XC_GGA_XC_TH_FCO = 199 ! Tozer and Handy v. FCO
467  integer(c_int), parameter, public :: XC_GGA_C_OPTC = 200 ! Optimized correlation functional of Cohen and Handy
468  integer(c_int), parameter, public :: XC_GGA_X_ECMV92 = 215 ! Engel, Chevary, Macdonald, and Vosko
469  integer(c_int), parameter, public :: XC_GGA_C_PBE_VWN = 216 ! Perdew, Burke & Ernzerhof correlation based on VWN LDA
470  integer(c_int), parameter, public :: XC_GGA_C_P86_FT = 217 ! Perdew 86 with a more accurate value for ftilde
471  integer(c_int), parameter, public :: XC_GGA_K_RATIONAL_P = 218 ! Lehtomaki and Lopez-Acevedo
472  integer(c_int), parameter, public :: XC_GGA_K_PG1 = 219 ! PG1 functional by Constantin, Fabiano, and Della Sala
473  integer(c_int), parameter, public :: XC_GGA_C_PBELOC = 246 ! Semilocal dynamical correlation
474  integer(c_int), parameter, public :: XC_GGA_C_P86VWN = 252 ! Perdew 86 based on the VWN5 LDA
475  integer(c_int), parameter, public :: XC_GGA_C_P86VWN_FT = 253 ! Perdew 86 based on the VWN5 LDA with a more accurate value for ftilde
476  integer(c_int), parameter, public :: XC_GGA_XC_VV10 = 255 ! Vydrov and Van Voorhis
477  integer(c_int), parameter, public :: XC_GGA_C_PBEFE = 258 ! PBE for formation energies
478  integer(c_int), parameter, public :: XC_GGA_C_OP_PW91 = 262 ! one-parameter progressive functional (PW91 version)
479  integer(c_int), parameter, public :: XC_GGA_X_PBEFE = 265 ! PBE for formation energies
480  integer(c_int), parameter, public :: XC_GGA_X_CAP = 270 ! Correct Asymptotic Potential
481  integer(c_int), parameter, public :: XC_GGA_X_EB88 = 271 ! Non-empirical (excogitated) B88 functional of Becke and Elliott
482  integer(c_int), parameter, public :: XC_GGA_C_PBE_MOL = 272 ! Del Campo, Gazquez, Trickey and Vela (PBE-like)
483  integer(c_int), parameter, public :: XC_GGA_K_ABSP3 = 277 ! gamma-TFvW form by Acharya et al [g = 1 - 1.513/N^0.35]
484  integer(c_int), parameter, public :: XC_GGA_K_ABSP4 = 278 ! gamma-TFvW form by Acharya et al [g = l = 1/(1 + 1.332/N^(1/3))]
485  integer(c_int), parameter, public :: XC_GGA_C_BMK = 280 ! Boese-Martin for kinetics
486  integer(c_int), parameter, public :: XC_GGA_C_TAU_HCTH = 281 ! correlation part of tau-hcth
487  integer(c_int), parameter, public :: XC_GGA_C_HYB_TAU_HCTH = 283 ! correlation part of hyb_tau-hcth
488  integer(c_int), parameter, public :: XC_GGA_X_BEEFVDW = 285 ! BEEF-vdW exchange
489  integer(c_int), parameter, public :: XC_GGA_XC_BEEFVDW = 286 ! BEEF-vdW exchange-correlation
490  integer(c_int), parameter, public :: XC_GGA_X_PBETRANS = 291 ! Gradient-based interpolation between PBE and revPBE
491  integer(c_int), parameter, public :: XC_GGA_X_CHACHIYO = 298 ! Chachiyo exchange
492  integer(c_int), parameter, public :: XC_GGA_C_CHACHIYO = 309 ! Chachiyo simple GGA correlation
493  integer(c_int), parameter, public :: XC_GGA_X_REVSSB_D = 312 ! Revised Swart, Sola and Bickelhaupt dispersion
494  integer(c_int), parameter, public :: XC_GGA_C_CCDF = 313 ! ccDF, coupled-cluster based density functional
495  integer(c_int), parameter, public :: XC_GGA_X_PW91_MOD = 316 ! Perdew & Wang 91, alternate version with more digits
496  integer(c_int), parameter, public :: XC_GGA_X_S12G = 495 ! Swart 2012 GGA exchange
497  integer(c_int), parameter, public :: XC_GGA_K_VW = 500 ! von Weiszaecker functional
498  integer(c_int), parameter, public :: XC_GGA_K_GE2 = 501 ! Second-order gradient expansion (l = 1/9)
499  integer(c_int), parameter, public :: XC_GGA_K_GOLDEN = 502 ! TF-lambda-vW form by Golden (l = 13/45)
500  integer(c_int), parameter, public :: XC_GGA_K_YT65 = 503 ! TF-lambda-vW form by Yonei and Tomishima (l = 1/5)
501  integer(c_int), parameter, public :: XC_GGA_K_BALTIN = 504 ! TF-lambda-vW form by Baltin (l = 5/9)
502  integer(c_int), parameter, public :: XC_GGA_K_LIEB = 505 ! TF-lambda-vW form by Lieb (l = 0.185909191)
503  integer(c_int), parameter, public :: XC_GGA_K_ABSP1 = 506 ! gamma-TFvW form by Acharya et al [g = 1 - 1.412/N^(1/3)]
504  integer(c_int), parameter, public :: XC_GGA_K_ABSP2 = 507 ! gamma-TFvW form by Acharya et al [g = 1 - 1.332/N^(1/3)]
505  integer(c_int), parameter, public :: XC_GGA_K_GR = 508 ! gamma-TFvW form by Gazquez and Robles
506  integer(c_int), parameter, public :: XC_GGA_K_LUDENA = 509 ! gamma-TFvW form by Ludena
507  integer(c_int), parameter, public :: XC_GGA_K_GP85 = 510 ! gamma-TFvW form by Ghosh and Parr
508  integer(c_int), parameter, public :: XC_GGA_K_PEARSON = 511 ! Pearson
509  integer(c_int), parameter, public :: XC_GGA_K_OL1 = 512 ! Ou-Yang and Levy v.1
510  integer(c_int), parameter, public :: XC_GGA_K_OL2 = 513 ! Ou-Yang and Levy v.2
511  integer(c_int), parameter, public :: XC_GGA_K_FR_B88 = 514 ! Fuentealba & Reyes (B88 version)
512  integer(c_int), parameter, public :: XC_GGA_K_FR_PW86 = 515 ! Fuentealba & Reyes (PW86 version)
513  integer(c_int), parameter, public :: XC_GGA_K_DK = 516 ! DePristo and Kress
514  integer(c_int), parameter, public :: XC_GGA_K_PERDEW = 517 ! Perdew
515  integer(c_int), parameter, public :: XC_GGA_K_VSK = 518 ! Vitos, Skriver, and Kollar
516  integer(c_int), parameter, public :: XC_GGA_K_VJKS = 519 ! Vitos, Johansson, Kollar, and Skriver
517  integer(c_int), parameter, public :: XC_GGA_K_ERNZERHOF = 520 ! Ernzerhof
518  integer(c_int), parameter, public :: XC_GGA_K_LC94 = 521 ! Lembarki & Chermette
519  integer(c_int), parameter, public :: XC_GGA_K_LLP = 522 ! Lee, Lee & Parr
520  integer(c_int), parameter, public :: XC_GGA_K_THAKKAR = 523 ! Thakkar 1992
521  integer(c_int), parameter, public :: XC_GGA_X_WPBEH = 524 ! short-range version of the PBE
522  integer(c_int), parameter, public :: XC_GGA_X_HJS_PBE = 525 ! HJS screened exchange PBE version
523  integer(c_int), parameter, public :: XC_GGA_X_HJS_PBE_SOL = 526 ! HJS screened exchange PBE_SOL version
524  integer(c_int), parameter, public :: XC_GGA_X_HJS_B88 = 527 ! HJS screened exchange B88 version
525  integer(c_int), parameter, public :: XC_GGA_X_HJS_B97X = 528 ! HJS screened exchange B97x version
526  integer(c_int), parameter, public :: XC_GGA_X_ITYH = 529 ! short-range recipe B88 functionals - erf
527  integer(c_int), parameter, public :: XC_GGA_X_SFAT = 530 ! short-range recipe for PBE functional
528  integer(c_int), parameter, public :: XC_GGA_X_SG4 = 533 ! Semiclassical GGA at fourth order
529  integer(c_int), parameter, public :: XC_GGA_C_SG4 = 534 ! Semiclassical GGA at fourth order
530  integer(c_int), parameter, public :: XC_GGA_X_GG99 = 535 ! Gilbert and Gill 1999
531  integer(c_int), parameter, public :: XC_GGA_X_PBEPOW = 539 ! PBE power
532  integer(c_int), parameter, public :: XC_GGA_X_KGG99 = 544 ! Gilbert and Gill 1999 (mixed)
533  integer(c_int), parameter, public :: XC_GGA_XC_HLE16 = 545 ! high local exchange 2016
534  integer(c_int), parameter, public :: XC_GGA_C_SCAN_E0 = 553 ! GGA component of SCAN
535  integer(c_int), parameter, public :: XC_GGA_C_GAPC = 555 ! GapC
536  integer(c_int), parameter, public :: XC_GGA_C_GAPLOC = 556 ! Gaploc
537  integer(c_int), parameter, public :: XC_GGA_C_ZVPBEINT = 557 ! another spin-dependent correction to PBEint
538  integer(c_int), parameter, public :: XC_GGA_C_ZVPBESOL = 558 ! another spin-dependent correction to PBEsol
539  integer(c_int), parameter, public :: XC_GGA_C_TM_LYP = 559 ! Takkar and McCarthy reparametrization
540  integer(c_int), parameter, public :: XC_GGA_C_TM_PBE = 560 ! Thakkar and McCarthy reparametrization
541  integer(c_int), parameter, public :: XC_GGA_C_W94 = 561 ! Wilson 94 (Eq. 25)
542  integer(c_int), parameter, public :: XC_GGA_C_CS1 = 565 ! A dynamical correlation functional
543  integer(c_int), parameter, public :: XC_GGA_X_B88M = 570 ! Becke 88 reoptimized to be used with mgga_c_tau1
544  integer(c_int), parameter, public :: XC_GGA_XC_KT3 = 587 ! Keal and Tozer version 3
545  integer(c_int), parameter, public :: XC_GGA_XC_LB07 = 589 ! Livshits and Baer, empirical functional
546  integer(c_int), parameter, public :: XC_GGA_K_GDS08 = 591 ! Combined analytical theory with Monte Carlo sampling
547  integer(c_int), parameter, public :: XC_GGA_K_GHDS10 = 592 ! As GDS08 but for an electron gas with spin
548  integer(c_int), parameter, public :: XC_GGA_K_GHDS10R = 593 ! Reparametrized GHDS10
549  integer(c_int), parameter, public :: XC_GGA_K_TKVLN = 594 ! Trickey, Karasiev, and Vela
550  integer(c_int), parameter, public :: XC_GGA_K_PBE3 = 595 ! Three parameter PBE-like expansion
551  integer(c_int), parameter, public :: XC_GGA_K_PBE4 = 596 ! Four parameter PBE-like expansion
552  integer(c_int), parameter, public :: XC_GGA_K_EXP4 = 597 ! Intermediate form between PBE3 and PBE4
553  integer(c_int), parameter, public :: XC_GGA_X_SFAT_PBE = 601 ! short-range recipe for PBE functional
554  integer(c_int), parameter, public :: XC_GGA_X_FD_LB94 = 604 ! Functional derivative recovered from the stray LB94 potential
555  integer(c_int), parameter, public :: XC_GGA_X_FD_REVLB94 = 605 ! Revised FD_LB94
556  integer(c_int), parameter, public :: XC_GGA_C_ZVPBELOC = 606 ! PBEloc variation with enhanced compatibility with exact exchange
557  integer(c_int), parameter, public :: XC_GGA_K_LKT = 613 ! Luo-Karasiev-Trickey kinetic GGA
558  integer(c_int), parameter, public :: XC_GGA_K_PBE2 = 616 ! Two parameter PBE-like expansion
559  integer(c_int), parameter, public :: XC_GGA_K_VT84F = 619 ! VT84F by Karasiev et al
560  integer(c_int), parameter, public :: XC_GGA_K_LGAP = 620 ! LGAP by Constantin et al
561  integer(c_int), parameter, public :: XC_GGA_X_ITYH_OPTX = 622 ! short-range OPTX functional
562  integer(c_int), parameter, public :: XC_GGA_X_ITYH_PBE = 623 ! short-range PBE functional
563  integer(c_int), parameter, public :: XC_GGA_K_LGAP_GE = 633 ! LGAP_GE by Constantin et al
564  integer(c_int), parameter, public :: XC_GGA_K_TFVW_OPT = 635 ! empirically optimized gamma-TFvW form
565  integer(c_int), parameter, public :: XC_GGA_C_MGGAC = 712 ! beta fitted to LC20 to be used with MGGAC
566  integer(c_int), parameter, public :: XC_HYB_MGGA_X_DLDF = 36 ! Dispersionless Density Functional
567  integer(c_int), parameter, public :: XC_HYB_MGGA_X_MS2H = 224 ! MS2 hybrid exchange of Sun, et al
568  integer(c_int), parameter, public :: XC_HYB_MGGA_X_MN12_SX = 248 ! MN12-SX hybrid exchange functional from Minnesota
569  integer(c_int), parameter, public :: XC_HYB_MGGA_X_SCAN0 = 264 ! SCAN hybrid exchange
570  integer(c_int), parameter, public :: XC_HYB_MGGA_X_MN15 = 268 ! MN15 hybrid exchange functional from Minnesota
571  integer(c_int), parameter, public :: XC_HYB_MGGA_X_BMK = 279 ! Boese-Martin for kinetics
572  integer(c_int), parameter, public :: XC_HYB_MGGA_X_TAU_HCTH = 282 ! Hybrid version of tau-HCTH
573  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M08_HX = 295 ! M08-HX exchange functional from Minnesota
574  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M08_SO = 296 ! M08-SO exchange functional from Minnesota
575  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M11 = 297 ! M11 hybrid exchange functional from Minnesota
576  integer(c_int), parameter, public :: XC_HYB_MGGA_X_REVM11 = 304 ! revM11 hybrid exchange functional from Minnesota
577  integer(c_int), parameter, public :: XC_HYB_MGGA_X_REVM06 = 305 ! revised M06 hybrid exchange functional from Minnesota
578  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M06_SX = 310 ! M06-SX exchange functional from Minnesota
579  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_TPSS0 = 396 ! TPSS hybrid with 25% exact exchange
580  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_B94_HYB = 398 ! Hybrid meta-GGA by Becke
581  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M05 = 438 ! M05 hybrid exchange functional from Minnesota
582  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M05_2X = 439 ! M05-2X hybrid exchange functional from Minnesota
583  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_B88B95 = 440 ! Mixture of B88 with BC95 (B1B95)
584  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_B86B95 = 441 ! Mixture of B86 with BC95
585  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_PW86B95 = 442 ! Mixture of PW86 with BC95
586  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_BB1K = 443 ! Mixture of B88 with BC95 from Zhao and Truhlar
587  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M06_HF = 444 ! M06-HF hybrid exchange functional from Minnesota
588  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_MPW1B95 = 445 ! Mixture of mPW91 with BC95 from Zhao and Truhlar
589  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_MPWB1K = 446 ! Mixture of mPW91 with BC95 for kinetics
590  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_X1B95 = 447 ! Mixture of X with BC95
591  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_XB1K = 448 ! Mixture of X with BC95 for kinetics
592  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M06 = 449 ! M06 hybrid exchange functional from Minnesota
593  integer(c_int), parameter, public :: XC_HYB_MGGA_X_M06_2X = 450 ! M06-2X hybrid exchange functional from Minnesota
594  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_PW6B95 = 451 ! Mixture of PW91 with BC95 from Zhao and Truhlar
595  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_PWB6K = 452 ! Mixture of PW91 with BC95 from Zhao and Truhlar for kinetics
596  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_TPSSH = 457 ! TPSS hybrid
597  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_REVTPSSH = 458 ! revTPSS hybrid
598  integer(c_int), parameter, public :: XC_HYB_MGGA_X_MVSH = 474 ! MVSh hybrid
599  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_WB97M_V = 531 ! Mardirossian and Head-Gordon
600  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_B0KCIS = 563 ! Hybrid based on KCIS
601  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_MPW1KCIS = 566 ! Modified Perdew-Wang + KCIS hybrid
602  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_MPWKCIS1K = 567 ! Modified Perdew-Wang + KCIS hybrid with more exact exchange
603  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_PBE1KCIS = 568 ! Perdew-Burke-Ernzerhof + KCIS hybrid
604  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_TPSS1KCIS = 569 ! TPSS hybrid with KCIS correlation
605  integer(c_int), parameter, public :: XC_HYB_MGGA_X_REVSCAN0 = 583 ! revised SCAN hybrid exchange
606  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_B98 = 598 ! Becke 98
607  integer(c_int), parameter, public :: XC_HYB_MGGA_XC_EDMGGAH = 695 ! Tao 2001 hybrid
608  integer(c_int), parameter, public :: XC_HYB_MGGA_X_JS18 = 705 ! a screened version of TM
609  integer(c_int), parameter, public :: XC_HYB_MGGA_X_PJS18 = 706 ! a screened version of TM
610  integer(c_int), parameter, public :: XC_MGGA_C_DLDF = 37 ! Dispersionless Density Functional
611  integer(c_int), parameter, public :: XC_MGGA_XC_ZLP = 42 ! Zhao, Levy & Parr, Eq. (21)
612  integer(c_int), parameter, public :: XC_MGGA_XC_OTPSS_D = 64 ! oTPSS_D functional of Goerigk and Grimme
613  integer(c_int), parameter, public :: XC_MGGA_C_CS = 72 ! Colle and Salvetti
614  integer(c_int), parameter, public :: XC_MGGA_C_MN12_SX = 73 ! MN12-SX correlation functional from Minnesota
615  integer(c_int), parameter, public :: XC_MGGA_C_MN12_L = 74 ! MN12-L correlation functional from Minnesota
616  integer(c_int), parameter, public :: XC_MGGA_C_M11_L = 75 ! M11-L correlation functional from Minnesota
617  integer(c_int), parameter, public :: XC_MGGA_C_M11 = 76 ! M11 correlation functional from Minnesota
618  integer(c_int), parameter, public :: XC_MGGA_C_M08_SO = 77 ! M08-SO correlation functional from Minnesota
619  integer(c_int), parameter, public :: XC_MGGA_C_M08_HX = 78 ! M08-HX correlation functional from Minnesota
620  integer(c_int), parameter, public :: XC_MGGA_C_REVM11 = 172 ! Revised M11 correlation functional from Minnesota
621  integer(c_int), parameter, public :: XC_MGGA_X_LTA = 201 ! Local tau approximation of Ernzerhof & Scuseria
622  integer(c_int), parameter, public :: XC_MGGA_X_TPSS = 202 ! Tao, Perdew, Staroverov & Scuseria exchange
623  integer(c_int), parameter, public :: XC_MGGA_X_M06_L = 203 ! M06-L exchange functional from Minnesota
624  integer(c_int), parameter, public :: XC_MGGA_X_GVT4 = 204 ! GVT4 from Van Voorhis and Scuseria
625  integer(c_int), parameter, public :: XC_MGGA_X_TAU_HCTH = 205 ! tau-HCTH from Boese and Handy
626  integer(c_int), parameter, public :: XC_MGGA_X_BR89 = 206 ! Becke-Roussel 89, gamma = 0.8
627  integer(c_int), parameter, public :: XC_MGGA_X_BJ06 = 207 ! Becke & Johnson correction to Becke-Roussel 89
628  integer(c_int), parameter, public :: XC_MGGA_X_TB09 = 208 ! Tran & Blaha correction to Becke & Johnson
629  integer(c_int), parameter, public :: XC_MGGA_X_RPP09 = 209 ! Rasanen, Pittalis, and Proetto correction to Becke & Johnson
630  integer(c_int), parameter, public :: XC_MGGA_X_2D_PRHG07 = 210 ! Pittalis, Rasanen, Helbig, Gross Exchange Functional
631  integer(c_int), parameter, public :: XC_MGGA_X_2D_PRHG07_PRP10 = 211 ! PRGH07 with PRP10 correction
632  integer(c_int), parameter, public :: XC_MGGA_X_REVTPSS = 212 ! revised Tao, Perdew, Staroverov & Scuseria exchange
633  integer(c_int), parameter, public :: XC_MGGA_X_PKZB = 213 ! Perdew, Kurth, Zupan, and Blaha
634  integer(c_int), parameter, public :: XC_MGGA_X_BR89_1 = 214 ! Becke-Roussel 89, gamma = 1.0
635  integer(c_int), parameter, public :: XC_MGGA_K_PGSL025 = 220 ! PGSL0.25 functional by Constantin, Fabiano, and Della Sala
636  integer(c_int), parameter, public :: XC_MGGA_X_MS0 = 221 ! MS exchange of Sun, Xiao, and Ruzsinszky
637  integer(c_int), parameter, public :: XC_MGGA_X_MS1 = 222 ! MS1 exchange of Sun, et al
638  integer(c_int), parameter, public :: XC_MGGA_X_MS2 = 223 ! MS2 exchange of Sun, et al
639  integer(c_int), parameter, public :: XC_MGGA_X_TH = 225 ! Tsuneda and Hirao
640  integer(c_int), parameter, public :: XC_MGGA_X_M11_L = 226 ! M11-L exchange functional from Minnesota
641  integer(c_int), parameter, public :: XC_MGGA_X_MN12_L = 227 ! MN12-L exchange functional from Minnesota
642  integer(c_int), parameter, public :: XC_MGGA_X_MS2_REV = 228 ! MS2 exchange of Sun, et al with a revised value for c
643  integer(c_int), parameter, public :: XC_MGGA_XC_CC06 = 229 ! Cancio and Chou 2006
644  integer(c_int), parameter, public :: XC_MGGA_X_MK00 = 230 ! Exchange for accurate virtual orbital energies
645  integer(c_int), parameter, public :: XC_MGGA_C_TPSS = 231 ! Tao, Perdew, Staroverov & Scuseria correlation
646  integer(c_int), parameter, public :: XC_MGGA_C_VSXC = 232 ! VSxc from Van Voorhis and Scuseria (correlation part)
647  integer(c_int), parameter, public :: XC_MGGA_C_M06_L = 233 ! M06-L correlation functional from Minnesota
648  integer(c_int), parameter, public :: XC_MGGA_C_M06_HF = 234 ! M06-HF correlation functional from Minnesota
649  integer(c_int), parameter, public :: XC_MGGA_C_M06 = 235 ! M06 correlation functional from Minnesota
650  integer(c_int), parameter, public :: XC_MGGA_C_M06_2X = 236 ! M06-2X correlation functional from Minnesota
651  integer(c_int), parameter, public :: XC_MGGA_C_M05 = 237 ! M05 correlation functional from Minnesota
652  integer(c_int), parameter, public :: XC_MGGA_C_M05_2X = 238 ! M05-2X correlation functional from Minnesota
653  integer(c_int), parameter, public :: XC_MGGA_C_PKZB = 239 ! Perdew, Kurth, Zupan, and Blaha
654  integer(c_int), parameter, public :: XC_MGGA_C_BC95 = 240 ! Becke correlation 95
655  integer(c_int), parameter, public :: XC_MGGA_C_REVTPSS = 241 ! revised TPSS correlation
656  integer(c_int), parameter, public :: XC_MGGA_XC_TPSSLYP1W = 242 ! Functionals fitted for water
657  integer(c_int), parameter, public :: XC_MGGA_X_MK00B = 243 ! Exchange for accurate virtual orbital energies (v. B)
658  integer(c_int), parameter, public :: XC_MGGA_X_BLOC = 244 ! functional with balanced localization
659  integer(c_int), parameter, public :: XC_MGGA_X_MODTPSS = 245 ! Modified Tao, Perdew, Staroverov & Scuseria exchange
660  integer(c_int), parameter, public :: XC_MGGA_C_TPSSLOC = 247 ! Semilocal dynamical correlation
661  integer(c_int), parameter, public :: XC_MGGA_X_MBEEF = 249 ! mBEEF exchange
662  integer(c_int), parameter, public :: XC_MGGA_X_MBEEFVDW = 250 ! mBEEF-vdW exchange
663  integer(c_int), parameter, public :: XC_MGGA_C_TM = 251 ! Tao and Mo 2016 correlation
664  integer(c_int), parameter, public :: XC_MGGA_XC_B97M_V = 254 ! Mardirossian and Head-Gordon
665  integer(c_int), parameter, public :: XC_MGGA_X_JK = 256 ! Jemmer-Knowles meta-GGA exchange
666  integer(c_int), parameter, public :: XC_MGGA_X_MVS = 257 ! MVS exchange of Sun, Perdew, and Ruzsinszky
667  integer(c_int), parameter, public :: XC_MGGA_X_MN15_L = 260 ! MN15-L exhange functional from Minnesota
668  integer(c_int), parameter, public :: XC_MGGA_C_MN15_L = 261 ! MN15-L correlation functional from Minnesota
669  integer(c_int), parameter, public :: XC_MGGA_X_SCAN = 263 ! SCAN exchange of Sun, Ruzsinszky, and Perdew
670  integer(c_int), parameter, public :: XC_MGGA_C_SCAN = 267 ! SCAN correlation
671  integer(c_int), parameter, public :: XC_MGGA_C_MN15 = 269 ! MN15 correlation functional from Minnesota
672  integer(c_int), parameter, public :: XC_MGGA_X_B00 = 284 ! Becke 2000
673  integer(c_int), parameter, public :: XC_MGGA_XC_HLE17 = 288 ! high local exchange 2017
674  integer(c_int), parameter, public :: XC_MGGA_C_SCAN_RVV10 = 292 ! SCAN correlation + rVV10 correlation
675  integer(c_int), parameter, public :: XC_MGGA_X_REVM06_L = 293 ! revised M06-L exchange functional from Minnesota
676  integer(c_int), parameter, public :: XC_MGGA_C_REVM06_L = 294 ! Revised M06-L correlation functional from Minnesota
677  integer(c_int), parameter, public :: XC_MGGA_X_RTPSS = 299 ! Revised TPSS exchange by Garza, Bell and Head-Gordon
678  integer(c_int), parameter, public :: XC_MGGA_X_MS2B = 300 ! MS2beta exchange by Furness and Sun
679  integer(c_int), parameter, public :: XC_MGGA_X_MS2BS = 301 ! MS2beta* exchange by Furness and Sun
680  integer(c_int), parameter, public :: XC_MGGA_X_MVSB = 302 ! MVSBeta exchange of Furness and Sun
681  integer(c_int), parameter, public :: XC_MGGA_X_MVSBS = 303 ! MVSBeta* exchange of Furness and Sun
682  integer(c_int), parameter, public :: XC_MGGA_C_REVM06 = 306 ! Revised M06 correlation functional from Minnesota
683  integer(c_int), parameter, public :: XC_MGGA_C_M06_SX = 311 ! M06-SX correlation functional from Minnesota
684  integer(c_int), parameter, public :: XC_MGGA_C_B94 = 397 ! Meta-GGA correlation by Becke
685  integer(c_int), parameter, public :: XC_MGGA_X_RSCAN = 493 ! Regularized SCAN exchange
686  integer(c_int), parameter, public :: XC_MGGA_C_RSCAN = 494 ! Regularized SCAN correlation
687  integer(c_int), parameter, public :: XC_MGGA_X_R2SCAN = 497 ! Re-regularized SCAN exchange
688  integer(c_int), parameter, public :: XC_MGGA_C_R2SCAN = 498 ! Re-regularized SCAN correlation
689  integer(c_int), parameter, public :: XC_MGGA_X_TM = 540 ! Tao and Mo 2016 exchange
690  integer(c_int), parameter, public :: XC_MGGA_X_VT84 = 541 ! meta-GGA version of VT{8,4} GGA
691  integer(c_int), parameter, public :: XC_MGGA_X_SA_TPSS = 542 ! TPSS with correct surface asymptotics
692  integer(c_int), parameter, public :: XC_MGGA_K_PC07 = 543 ! Perdew and Constantin 2007
693  integer(c_int), parameter, public :: XC_MGGA_C_KCIS = 562 ! Krieger, Chen, Iafrate, and Savin
694  integer(c_int), parameter, public :: XC_MGGA_XC_LP90 = 564 ! Lee & Parr, Eq. (56)
695  integer(c_int), parameter, public :: XC_MGGA_C_B88 = 571 ! Meta-GGA correlation by Becke
696  integer(c_int), parameter, public :: XC_MGGA_X_GX = 575 ! GX functional of Loos
697  integer(c_int), parameter, public :: XC_MGGA_X_PBE_GX = 576 ! PBE-GX functional of Loos
698  integer(c_int), parameter, public :: XC_MGGA_X_REVSCAN = 581 ! revised SCAN
699  integer(c_int), parameter, public :: XC_MGGA_C_REVSCAN = 582 ! revised SCAN correlation
700  integer(c_int), parameter, public :: XC_MGGA_C_SCAN_VV10 = 584 ! SCAN correlation + VV10 correlation
701  integer(c_int), parameter, public :: XC_MGGA_C_REVSCAN_VV10 = 585 ! revised SCAN correlation
702  integer(c_int), parameter, public :: XC_MGGA_X_BR89_EXPLICIT = 586 ! Becke-Roussel 89 with an explicit inversion of x(y), gamma = 0.8
703  integer(c_int), parameter, public :: XC_MGGA_X_BR89_EXPLICIT_1 = 602 ! Becke-Roussel 89 with an explicit inversion of x(y), gamma = 1.0
704  integer(c_int), parameter, public :: XC_MGGA_X_REGTPSS = 603 ! Regularized TPSS
705  integer(c_int), parameter, public :: XC_MGGA_X_2D_JS17 = 609 ! JS17 meta-GGA for 2D
706  integer(c_int), parameter, public :: XC_MGGA_K_L04 = 617 ! L0.4 by Laricchia et al
707  integer(c_int), parameter, public :: XC_MGGA_K_L06 = 618 ! L0.6 by Laricchia et al
708  integer(c_int), parameter, public :: XC_MGGA_K_RDA = 621 ! RDA by Karasiev et al
709  integer(c_int), parameter, public :: XC_MGGA_K_GEA2 = 627 ! Second-order gradient expansion
710  integer(c_int), parameter, public :: XC_MGGA_K_GEA4 = 628 ! Fourth-order gradient expansion
711  integer(c_int), parameter, public :: XC_MGGA_K_CSK1 = 629 ! mGGA-rev functional by Cancio, Stewart, and Kuna (a=1)
712  integer(c_int), parameter, public :: XC_MGGA_K_CSK4 = 630 ! mGGA-rev functional by Cancio, Stewart, and Kuna (a=4)
713  integer(c_int), parameter, public :: XC_MGGA_K_CSK_LOC1 = 631 ! mGGAloc-rev functional by Cancio, Stewart, and Kuna (a=1)
714  integer(c_int), parameter, public :: XC_MGGA_K_CSK_LOC4 = 632 ! mGGAloc-rev functional by Cancio, Stewart, and Kuna (a=4)
715  integer(c_int), parameter, public :: XC_MGGA_K_PC07_OPT = 634 ! Reoptimized version by Mejia-Rodriguez and Trickey
716  integer(c_int), parameter, public :: XC_MGGA_C_KCISK = 638 ! Krieger, Chen, and Kurth
717  integer(c_int), parameter, public :: XC_MGGA_X_TLDA = 685 ! LDA-type exchange with tau-dependent potential
718  integer(c_int), parameter, public :: XC_MGGA_X_EDMGGA = 686 ! Tao 2001
719  integer(c_int), parameter, public :: XC_MGGA_X_GDME_NV = 687 ! Generalized density-matrix with a=1/2
720  integer(c_int), parameter, public :: XC_MGGA_X_RLDA = 688 ! Reparametrized local-density approximation
721  integer(c_int), parameter, public :: XC_MGGA_X_GDME_0 = 689 ! Generalized density-matrix with a=0
722  integer(c_int), parameter, public :: XC_MGGA_X_GDME_KOS = 690 ! Generalized density-matrix with a=0.00638
723  integer(c_int), parameter, public :: XC_MGGA_X_GDME_VT = 691 ! Varied-terms (VT) mGGA of Koehl, Odom, and Scuseria
724  integer(c_int), parameter, public :: XC_MGGA_X_REVTM = 693 ! revised Tao and Mo 2016 exchange
725  integer(c_int), parameter, public :: XC_MGGA_C_REVTM = 694 ! revised Tao and Mo 2016 correlation
726  integer(c_int), parameter, public :: XC_MGGA_X_MBRXC_BG = 696 ! Modified Becke-Roussel for band gaps - cuspless hole
727  integer(c_int), parameter, public :: XC_MGGA_X_MBRXH_BG = 697 ! Modified Becke-Roussel for band gaps - hydrogen hole
728  integer(c_int), parameter, public :: XC_MGGA_X_HLTA = 698 ! Half-and-half by Lehtola and Marques
729  integer(c_int), parameter, public :: XC_MGGA_C_HLTAPW = 699 ! Meta-GGAized PW
730  integer(c_int), parameter, public :: XC_MGGA_X_SCANL = 700 ! Deorbitalized SCAN exchange
731  integer(c_int), parameter, public :: XC_MGGA_X_REVSCANL = 701 ! Deorbitalized revSCAN exchange
732  integer(c_int), parameter, public :: XC_MGGA_C_SCANL = 702 ! SCAN correlation
733  integer(c_int), parameter, public :: XC_MGGA_C_SCANL_RVV10 = 703 ! SCAN correlation + rVV10 correlation
734  integer(c_int), parameter, public :: XC_MGGA_C_SCANL_VV10 = 704 ! SCAN correlation + VV10 correlation
735  integer(c_int), parameter, public :: XC_MGGA_X_TASK = 707 ! TASK exchange of Aschebrock and Kuemmel
736  integer(c_int), parameter, public :: XC_MGGA_X_MGGAC = 711 ! MGGAC of Patras et al
737  integer(c_int), parameter, public :: XC_MGGA_X_MBR = 716 ! modified Becke-Roussel by Patra et al
738  integer(c_int), parameter, public :: XC_MGGA_X_R2SCANL = 718 ! Deorbitalized r^2SCAN exchange
739  integer(c_int), parameter, public :: XC_MGGA_C_R2SCANL = 719 ! Deorbitalized r^2SCAN correlation
740
741  ! These are old names kept for compatibility
742  integer(c_int), parameter, public :: &
743    XC_LDA_X_1D = 21, &
744    XC_GGA_X_BGCP = 38, &
745    XC_GGA_C_BGCP = 39, &
746    XC_GGA_C_BCGP = 39, &
747    XC_GGA_C_VPBE = 83, &
748    XC_GGA_XC_LB = 160, &
749    XC_MGGA_C_CC06 = 229, &
750    XC_GGA_K_ABSR1 = 506, &
751    XC_GGA_K_ABSR2 = 507, &
752    XC_LDA_C_LP_A = 547, &
753    XC_LDA_C_LP_B = 548, &
754    XC_MGGA_C_LP90 = 564
755
756  !----------------------------------------------------------------
757  interface
758    subroutine xc_version(major, minor, micro) bind(c)
759      import
760      integer(c_int), intent(out) :: major, minor, micro
761    end subroutine xc_version
762
763    type(c_ptr) function xc_version_string() bind(c)
764      import
765    end function xc_version_string
766
767    type(c_ptr) function xc_reference() bind(c)
768      import
769    end function xc_reference
770
771    type(c_ptr) function xc_reference_doi() bind(c)
772      import
773    end function xc_reference_doi
774  end interface
775
776
777  !----------------------------------------------------------------
778  type :: xc_f90_func_info_t
779    private
780    type(c_ptr) :: ptr = C_NULL_PTR
781  end type xc_f90_func_info_t
782
783  interface
784    integer(c_int) function xc_func_info_get_number(info) bind(c)
785      import
786      type(c_ptr), value :: info
787    end function xc_func_info_get_number
788
789    integer(c_int) function xc_func_info_get_kind(info) bind(c)
790      import
791      type(c_ptr), value :: info
792    end function xc_func_info_get_kind
793
794    type(c_ptr) function xc_func_info_get_name(info) bind(c)
795      import
796      type(c_ptr), value :: info
797    end function xc_func_info_get_name
798
799    integer(c_int) function xc_func_info_get_family(info) bind(c)
800      import
801      type(c_ptr), value :: info
802    end function xc_func_info_get_family
803
804    integer(c_int) function xc_func_info_get_flags(info) bind(c)
805      import
806      type(c_ptr), value :: info
807    end function xc_func_info_get_flags
808
809    type(c_ptr) function xc_func_info_get_references(info, number) bind(c)
810      import
811      type(c_ptr), value :: info
812      integer(c_int), value :: number
813    end function xc_func_info_get_references
814
815    integer(c_int) function xc_func_info_get_n_ext_params(info) bind(c)
816      import
817      type(c_ptr), value :: info
818    end function xc_func_info_get_n_ext_params
819
820    type(c_ptr) function xc_func_info_get_ext_params_name(info, number) bind(c)
821      import
822      type(c_ptr), value :: info
823      integer(c_int), value :: number
824    end function xc_func_info_get_ext_params_name
825
826    type(c_ptr) function xc_func_info_get_ext_params_description(info, number) bind(c)
827      import
828      type(c_ptr), value :: info
829      integer(c_int), value :: number
830    end function xc_func_info_get_ext_params_description
831
832    real(c_double) function xc_func_info_get_ext_params_default_value(info, number) bind(c)
833      import
834      type(c_ptr), value :: info
835      integer(c_int), value :: number
836    end function xc_func_info_get_ext_params_default_value
837
838  end interface
839
840  !----------------------------------------------------------------
841  type :: xc_f90_func_reference_t
842    private
843    type(c_ptr) :: ptr = C_NULL_PTR
844  end type xc_f90_func_reference_t
845
846  interface
847    type(c_ptr) function xc_func_reference_get_ref(reference) bind(c)
848      import
849      type(c_ptr), value :: reference
850    end function xc_func_reference_get_ref
851
852    type(c_ptr) function xc_func_reference_get_doi(reference) bind(c)
853      import
854      type(c_ptr), value :: reference
855    end function xc_func_reference_get_doi
856
857    type(c_ptr) function xc_func_reference_get_bibtex(reference) bind(c)
858      import
859      type(c_ptr), value :: reference
860    end function xc_func_reference_get_bibtex
861  end interface
862
863  !----------------------------------------------------------------
864  type :: xc_f90_func_t
865    private
866    type(c_ptr) :: ptr = C_NULL_PTR
867  end type xc_f90_func_t
868
869  interface
870    type(c_ptr) function xc_func_alloc() bind(c)
871      import
872    end function xc_func_alloc
873
874    integer(c_int) function xc_func_init(p, functional, nspin) bind(c)
875      import
876      type(c_ptr), value :: p
877      integer(c_int), value :: functional, nspin
878    end function xc_func_init
879
880    subroutine xc_func_end(p) bind(c)
881      import
882      type(c_ptr), value :: p
883    end subroutine xc_func_end
884
885    subroutine xc_func_free(p) bind(c)
886      import
887      type(c_ptr), value :: p
888    end subroutine xc_func_free
889
890    type(c_ptr) function xc_func_get_info(p) bind(c)
891      import
892      type(c_ptr), value :: p
893    end function xc_func_get_info
894
895    type(c_ptr) function xc_functional_get_name(number) bind(c)
896      import
897      integer(c_int), value :: number
898    end function xc_functional_get_name
899
900    integer(c_int) function xc_functional_get_number(func_string) bind(c)
901      import
902      character(kind=c_char), intent(in) :: func_string(*)
903    end function xc_functional_get_number
904
905    integer(c_int) function xc_family_from_id(id, family, number) bind(c)
906      import
907      integer(c_int), value :: id
908      type(c_ptr), value :: family, number
909    end function xc_family_from_id
910
911    integer(c_int) function xc_f90_number_of_functionals() bind(c, name="xc_number_of_functionals")
912      import
913    end function xc_f90_number_of_functionals
914
915    integer(c_int) function xc_f90_maximum_name_length() bind(c, name="xc_maximum_name_length")
916      import
917    end function xc_f90_maximum_name_length
918
919    subroutine xc_f90_available_functional_numbers(list) bind(c, name="xc_available_functional_numbers")
920      import
921      integer(c_int), intent(out) :: list(*)
922    end subroutine xc_f90_available_functional_numbers
923
924    subroutine xc_available_functional_names(list) bind(c)
925      import
926      type(c_ptr) :: list(*)
927    end subroutine xc_available_functional_names
928
929    subroutine xc_func_set_dens_threshold(p, dens_threshold) bind(c)
930      import
931      type(c_ptr), value :: p
932      real(c_double), value :: dens_threshold
933    end subroutine xc_func_set_dens_threshold
934
935    subroutine xc_func_set_zeta_threshold(p, zeta_threshold) bind(c)
936      import
937      type(c_ptr), value :: p
938      real(c_double), value :: zeta_threshold
939    end subroutine xc_func_set_zeta_threshold
940
941    subroutine xc_func_set_sigma_threshold(p, sigma_threshold) bind(c)
942      import
943      type(c_ptr), value :: p
944      real(c_double), value :: sigma_threshold
945    end subroutine xc_func_set_sigma_threshold
946
947    subroutine xc_func_set_tau_threshold(p, tau_threshold) bind(c)
948      import
949      type(c_ptr), value :: p
950      real(c_double), value :: tau_threshold
951    end subroutine xc_func_set_tau_threshold
952
953    subroutine xc_func_set_ext_params(p, ext_params) bind(c)
954      import
955      type(c_ptr), value :: p
956      real(c_double), intent(in) :: ext_params(*)
957    end subroutine xc_func_set_ext_params
958
959    subroutine xc_func_set_ext_params_name(p, name, par) bind(c)
960      import
961      type(c_ptr), value :: p
962      character(kind=c_char), intent(in) :: name(*)
963      real(c_double), value :: par
964    end subroutine xc_func_set_ext_params_name
965end interface
966
967  ! LDAs
968  !----------------------------------------------------------------
969  interface
970    subroutine xc_lda(p, np, rho, zk, vrho, v2rho2, v3rho3, v4rho4) bind(c)
971      import
972      type(c_ptr), value :: p
973      integer(c_size_t), value :: np
974      real(c_double), intent(in) :: rho(*)
975      real(c_double), intent(out) :: zk(*), vrho(*), v2rho2(*), v3rho3(*), v4rho4(*)
976    end subroutine xc_lda
977
978    subroutine xc_lda_exc(p, np, rho, zk) bind(c)
979      import
980      type(c_ptr), value :: p
981      integer(c_size_t), value :: np
982      real(c_double), intent(in) :: rho(*)
983      real(c_double), intent(out) :: zk(*)
984    end subroutine xc_lda_exc
985
986    subroutine xc_lda_exc_vxc(p, np, rho, zk, vrho) bind(c)
987      import
988      type(c_ptr), value :: p
989      integer(c_size_t), value :: np
990      real(c_double), intent(in) :: rho(*)
991      real(c_double), intent(out) :: zk(*), vrho(*)
992    end subroutine xc_lda_exc_vxc
993
994    subroutine xc_lda_exc_vxc_fxc(p, np, rho, zk, vrho, v2rho2) bind(c)
995      import
996      type(c_ptr), value :: p
997      integer(c_size_t), value :: np
998      real(c_double), intent(in) :: rho(*)
999      real(c_double), intent(out) :: zk(*), vrho(*), v2rho2(*)
1000    end subroutine xc_lda_exc_vxc_fxc
1001
1002    subroutine xc_lda_exc_vxc_fxc_kxc(p, np, rho, zk, vrho, v2rho2, v3rho3) bind(c)
1003      import
1004      type(c_ptr), value :: p
1005      integer(c_size_t), value :: np
1006      real(c_double), intent(in) :: rho(*)
1007      real(c_double), intent(out) :: zk(*), vrho(*), v2rho2(*), v3rho3(*)
1008    end subroutine xc_lda_exc_vxc_fxc_kxc
1009
1010    subroutine xc_lda_vxc(p, np, rho, vrho) bind(c)
1011      import
1012      type(c_ptr), value :: p
1013      integer(c_size_t), value :: np
1014      real(c_double), intent(in) :: rho(*)
1015      real(c_double), intent(out) :: vrho(*)
1016    end subroutine xc_lda_vxc
1017
1018    subroutine xc_lda_vxc_fxc(p, np, rho, vrho, v2rho2) bind(c)
1019      import
1020      type(c_ptr), value :: p
1021      integer(c_size_t), value :: np
1022      real(c_double), intent(in) :: rho(*)
1023      real(c_double), intent(out) :: vrho(*), v2rho2(*)
1024    end subroutine xc_lda_vxc_fxc
1025
1026    subroutine xc_lda_vxc_fxc_kxc(p, np, rho, vrho, v2rho2, v3rho3) bind(c)
1027      import
1028      type(c_ptr), value :: p
1029      integer(c_size_t), value :: np
1030      real(c_double), intent(in) :: rho(*)
1031      real(c_double), intent(out) :: vrho(*), v2rho2(*), v3rho3(*)
1032    end subroutine xc_lda_vxc_fxc_kxc
1033
1034    subroutine xc_lda_fxc(p, np, rho, v2rho2) bind(c)
1035      import
1036      type(c_ptr), value :: p
1037      integer(c_size_t), value :: np
1038      real(c_double), intent(in) :: rho(*)
1039      real(c_double), intent(out) :: v2rho2(*)
1040    end subroutine xc_lda_fxc
1041
1042    subroutine xc_lda_kxc(p, np, rho, v3rho3) bind(c)
1043      import
1044      type(c_ptr), value :: p
1045      integer(c_size_t), value :: np
1046      real(c_double), intent(in) :: rho(*)
1047      real(c_double), intent(out) :: v3rho3(*)
1048    end subroutine xc_lda_kxc
1049
1050    subroutine xc_lda_lxc(p, np, rho, v4rho4) bind(c)
1051      import
1052      type(c_ptr), value :: p
1053      integer(c_size_t), value :: np
1054      real(c_double), intent(in) :: rho(*)
1055      real(c_double), intent(out) :: v4rho4(*)
1056    end subroutine xc_lda_lxc
1057  end interface
1058
1059
1060  ! GGAs
1061  !----------------------------------------------------------------
1062  interface
1063    subroutine xc_gga(p, np, rho, sigma, zk, vrho, vsigma, &
1064         v2rho2, v2rhosigma, v2sigma2, &
1065         v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3, &
1066         v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4 &
1067         ) bind(c)
1068      import
1069      type(c_ptr), value :: p
1070      integer(c_size_t), value :: np
1071      real(c_double), intent(in) :: rho(*), sigma(*)
1072      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1073      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1074      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1075      real(c_double), intent(out) :: v4rho4(*), v4rho3sigma(*), v4rho2sigma2(*), v4rhosigma3(*), v4sigma4(*)
1076    end subroutine xc_gga
1077
1078    subroutine xc_gga_exc(p, np, rho, sigma, zk) bind(c)
1079      import
1080      type(c_ptr), value :: p
1081      integer(c_size_t), value :: np
1082      real(c_double), intent(in) :: rho(*), sigma(*)
1083      real(c_double), intent(out) :: zk(*)
1084    end subroutine xc_gga_exc
1085
1086    subroutine xc_gga_exc_vxc(p, np, rho, sigma, zk, vrho, vsigma) bind(c)
1087      import
1088      type(c_ptr), value :: p
1089      integer(c_size_t), value :: np
1090      real(c_double), intent(in) :: rho(*), sigma(*)
1091      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1092    end subroutine xc_gga_exc_vxc
1093
1094    subroutine xc_gga_exc_vxc_fxc(p, np, rho, sigma, zk, vrho, vsigma, &
1095         v2rho2, v2rhosigma, v2sigma2) bind(c)
1096      import
1097      type(c_ptr), value :: p
1098      integer(c_size_t), value :: np
1099      real(c_double), intent(in) :: rho(*), sigma(*)
1100      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1101      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1102    end subroutine xc_gga_exc_vxc_fxc
1103
1104    subroutine xc_gga_exc_vxc_fxc_kxc(p, np, rho, sigma, zk, vrho, vsigma, &
1105         v2rho2, v2rhosigma, v2sigma2, &
1106         v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3) bind(c)
1107      import
1108      type(c_ptr), value :: p
1109      integer(c_size_t), value :: np
1110      real(c_double), intent(in) :: rho(*), sigma(*)
1111      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1112      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1113      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1114    end subroutine xc_gga_exc_vxc_fxc_kxc
1115
1116    subroutine xc_gga_vxc(p, np, rho, sigma, vrho, vsigma) bind(c)
1117      import
1118      type(c_ptr), value :: p
1119      integer(c_size_t), value :: np
1120      real(c_double), intent(in) :: rho(*), sigma(*)
1121      real(c_double), intent(out) :: vrho(*), vsigma(*)
1122    end subroutine xc_gga_vxc
1123
1124    subroutine xc_gga_vxc_fxc(p, np, rho, sigma, vrho, vsigma, &
1125         v2rho2, v2rhosigma, v2sigma2) bind(c)
1126      import
1127      type(c_ptr), value :: p
1128      integer(c_size_t), value :: np
1129      real(c_double), intent(in) :: rho(*), sigma(*)
1130      real(c_double), intent(out) :: vrho(*), vsigma(*)
1131      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1132    end subroutine xc_gga_vxc_fxc
1133
1134    subroutine xc_gga_vxc_fxc_kxc(p, np, rho, sigma, vrho, vsigma, &
1135         v2rho2, v2rhosigma, v2sigma2, &
1136         v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3) bind(c)
1137      import
1138      type(c_ptr), value :: p
1139      integer(c_size_t), value :: np
1140      real(c_double), intent(in) :: rho(*), sigma(*)
1141      real(c_double), intent(out) :: vrho(*), vsigma(*)
1142      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1143      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1144    end subroutine xc_gga_vxc_fxc_kxc
1145
1146    subroutine xc_gga_fxc(p, np, rho, sigma, v2rho2, v2rhosigma, v2sigma2) bind(c)
1147      import
1148      type(c_ptr), value :: p
1149      integer(c_size_t), value :: np
1150      real(c_double), intent(in) :: rho(*), sigma(*)
1151      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1152    end subroutine xc_gga_fxc
1153
1154    subroutine xc_gga_kxc(p, np, rho, sigma, v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3) bind(c)
1155      import
1156      type(c_ptr), value :: p
1157      integer(c_size_t), value :: np
1158      real(c_double), intent(in) :: rho(*), sigma(*)
1159      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1160    end subroutine xc_gga_kxc
1161
1162    subroutine xc_gga_lxc(p, np, rho, sigma, v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4) bind(c)
1163      import
1164      type(c_ptr), value :: p
1165      integer(c_size_t), value :: np
1166      real(c_double), intent(in) :: rho(*), sigma(*)
1167      real(c_double), intent(out) :: v4rho4(*), v4rho3sigma(*), v4rho2sigma2(*), v4rhosigma3(*), v4sigma4(*)
1168    end subroutine xc_gga_lxc
1169
1170  end interface
1171
1172
1173  interface
1174    real(c_double) function xc_gga_ak13_get_asymptotic(homo) bind(c)
1175      import
1176      real(c_double), value :: homo
1177    end function xc_gga_ak13_get_asymptotic
1178  end interface
1179
1180
1181  interface
1182    real(c_double) function xc_hyb_exx_coef(p) bind(c)
1183      import
1184      type(c_ptr), value :: p
1185    end function xc_hyb_exx_coef
1186
1187    subroutine xc_hyb_cam_coef(p, omega, alpha, beta) bind(c)
1188      import
1189      type(c_ptr), value :: p
1190      real(c_double), intent(out) :: omega, alpha, beta
1191    end subroutine xc_hyb_cam_coef
1192
1193    subroutine xc_nlc_coef(p, nlc_b, nlc_c) bind(c)
1194      import
1195      type(c_ptr), value :: p
1196      real(c_double), intent(out) :: nlc_b, nlc_c
1197    end subroutine xc_nlc_coef
1198  end interface
1199
1200
1201  ! the meta-GGAs
1202  !----------------------------------------------------------------
1203  interface
1204    subroutine xc_mgga(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
1205         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1206         v2lapl2, v2lapltau, v2tau2, &
1207         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
1208         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
1209         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
1210         v3lapltau2, v3tau3, &
1211         v4rho4, v4rho3sigma, v4rho3lapl, v4rho3tau, v4rho2sigma2, v4rho2sigmalapl, &
1212         v4rho2sigmatau, v4rho2lapl2, v4rho2lapltau, v4rho2tau2, v4rhosigma3, &
1213         v4rhosigma2lapl, v4rhosigma2tau, v4rhosigmalapl2, v4rhosigmalapltau, &
1214         v4rhosigmatau2, v4rholapl3, v4rholapl2tau, v4rholapltau2, v4rhotau3, v4sigma4, &
1215         v4sigma3lapl, v4sigma3tau, v4sigma2lapl2, v4sigma2lapltau, v4sigma2tau2, &
1216         v4sigmalapl3, v4sigmalapl2tau, v4sigmalapltau2, v4sigmatau3, v4lapl4, &
1217         v4lapl3tau, v4lapl2tau2, v4lapltau3, v4tau4 &
1218         ) bind(c)
1219      import
1220      type(c_ptr), value :: p
1221      integer(c_size_t), value :: np
1222      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1223      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
1224      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
1225           v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
1226      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
1227           v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
1228           v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
1229           v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
1230           v3lapltau2(*), v3tau3(*)
1231      real(c_double), intent(out) :: &
1232           v4rho4(*), v4rho3sigma(*), v4rho3lapl(*), v4rho3tau(*), v4rho2sigma2(*), v4rho2sigmalapl(*), &
1233           v4rho2sigmatau(*), v4rho2lapl2(*), v4rho2lapltau(*), v4rho2tau2(*), v4rhosigma3(*), &
1234           v4rhosigma2lapl(*), v4rhosigma2tau(*), v4rhosigmalapl2(*), v4rhosigmalapltau(*), &
1235           v4rhosigmatau2(*), v4rholapl3(*), v4rholapl2tau(*), v4rholapltau2(*), v4rhotau3(*), v4sigma4(*), &
1236           v4sigma3lapl(*), v4sigma3tau(*), v4sigma2lapl2(*), v4sigma2lapltau(*), v4sigma2tau2(*), &
1237           v4sigmalapl3(*), v4sigmalapl2tau(*), v4sigmalapltau2(*), v4sigmatau3(*), v4lapl4(*), &
1238           v4lapl3tau(*), v4lapl2tau2(*), v4lapltau3(*), v4tau4(*)
1239    end subroutine xc_mgga
1240
1241    subroutine xc_mgga_exc(p, np, rho, sigma, lapl, tau, zk) bind(c)
1242      import
1243      type(c_ptr), value :: p
1244      integer(c_size_t), value :: np
1245      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1246      real(c_double), intent(out) :: zk(*)
1247    end subroutine xc_mgga_exc
1248
1249    subroutine xc_mgga_exc_vxc(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau) bind(c)
1250      import
1251      type(c_ptr), value :: p
1252      integer(c_size_t), value :: np
1253      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1254      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
1255    end subroutine xc_mgga_exc_vxc
1256
1257    subroutine xc_mgga_exc_vxc_fxc(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
1258         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1259         v2lapl2, v2lapltau, v2tau2) bind(c)
1260      import
1261      type(c_ptr), value :: p
1262      integer(c_size_t), value :: np
1263      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1264      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
1265      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
1266           v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
1267    end subroutine xc_mgga_exc_vxc_fxc
1268
1269    subroutine xc_mgga_exc_vxc_fxc_kxc(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
1270         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1271         v2lapl2, v2lapltau, v2tau2, &
1272         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
1273         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
1274         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
1275         v3lapltau2, v3tau3) bind(c)
1276      import
1277      type(c_ptr), value :: p
1278      integer(c_size_t), value :: np
1279      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1280      real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
1281      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
1282           v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
1283      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
1284           v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
1285           v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
1286           v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
1287           v3lapltau2(*), v3tau3(*)
1288    end subroutine xc_mgga_exc_vxc_fxc_kxc
1289
1290    subroutine xc_mgga_vxc(p, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau) bind(c)
1291      import
1292      type(c_ptr), value :: p
1293      integer(c_size_t), value :: np
1294      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1295      real(c_double), intent(out) :: vrho(*), vsigma(*), vlapl(*), vtau(*)
1296    end subroutine xc_mgga_vxc
1297
1298    subroutine xc_mgga_vxc_fxc(p, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau, &
1299         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1300         v2lapl2, v2lapltau, v2tau2) bind(c)
1301      import
1302      type(c_ptr), value :: p
1303      integer(c_size_t), value :: np
1304      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1305      real(c_double), intent(out) :: vrho(*), vsigma(*), vlapl(*), vtau(*)
1306      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
1307           v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
1308    end subroutine xc_mgga_vxc_fxc
1309
1310    subroutine xc_mgga_vxc_fxc_kxc(p, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau, &
1311         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1312         v2lapl2, v2lapltau, v2tau2, &
1313         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
1314         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
1315         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
1316         v3lapltau2, v3tau3) bind(c)
1317      import
1318      type(c_ptr), value :: p
1319      integer(c_size_t), value :: np
1320      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1321      real(c_double), intent(out) :: vrho(*), vsigma(*), vlapl(*), vtau(*)
1322      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
1323           v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
1324      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
1325           v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
1326           v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
1327           v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
1328           v3lapltau2(*), v3tau3(*)
1329    end subroutine xc_mgga_vxc_fxc_kxc
1330
1331    subroutine xc_mgga_fxc(p, np, rho, sigma, lapl, tau, &
1332         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1333         v2lapl2, v2lapltau, v2tau2) bind(c)
1334      import
1335      type(c_ptr), value :: p
1336      integer(c_size_t), value :: np
1337      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1338      real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
1339           v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
1340    end subroutine xc_mgga_fxc
1341
1342    subroutine xc_mgga_kxc(p, np, rho, sigma, lapl, tau, &
1343         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
1344         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
1345         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
1346         v3lapltau2, v3tau3) bind(c)
1347      import
1348      type(c_ptr), value :: p
1349      integer(c_size_t), value :: np
1350      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1351      real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
1352           v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
1353           v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
1354           v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
1355           v3lapltau2(*), v3tau3(*)
1356    end subroutine xc_mgga_kxc
1357
1358    subroutine xc_mgga_lxc(p, np, rho, sigma, lapl, tau, &
1359         v4rho4, v4rho3sigma, v4rho3lapl, v4rho3tau, v4rho2sigma2, v4rho2sigmalapl, &
1360         v4rho2sigmatau, v4rho2lapl2, v4rho2lapltau, v4rho2tau2, v4rhosigma3, &
1361         v4rhosigma2lapl, v4rhosigma2tau, v4rhosigmalapl2, v4rhosigmalapltau, &
1362         v4rhosigmatau2, v4rholapl3, v4rholapl2tau, v4rholapltau2, v4rhotau3, v4sigma4, &
1363         v4sigma3lapl, v4sigma3tau, v4sigma2lapl2, v4sigma2lapltau, v4sigma2tau2, &
1364         v4sigmalapl3, v4sigmalapl2tau, v4sigmalapltau2, v4sigmatau3, v4lapl4, &
1365         v4lapl3tau, v4lapl2tau2, v4lapltau3, v4tau4 &
1366         ) bind(c)
1367      import
1368      type(c_ptr), value :: p
1369      integer(c_size_t), value :: np
1370      real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1371      real(c_double), intent(out) :: &
1372           v4rho4(*), v4rho3sigma(*), v4rho3lapl(*), v4rho3tau(*), v4rho2sigma2(*), v4rho2sigmalapl(*), &
1373           v4rho2sigmatau(*), v4rho2lapl2(*), v4rho2lapltau(*), v4rho2tau2(*), v4rhosigma3(*), &
1374           v4rhosigma2lapl(*), v4rhosigma2tau(*), v4rhosigmalapl2(*), v4rhosigmalapltau(*), &
1375           v4rhosigmatau2(*), v4rholapl3(*), v4rholapl2tau(*), v4rholapltau2(*), v4rhotau3(*), v4sigma4(*), &
1376           v4sigma3lapl(*), v4sigma3tau(*), v4sigma2lapl2(*), v4sigma2lapltau(*), v4sigma2tau2(*), &
1377           v4sigmalapl3(*), v4sigmalapl2tau(*), v4sigmalapltau2(*), v4sigmatau3(*), v4lapl4(*), &
1378           v4lapl3tau(*), v4lapl2tau2(*), v4lapltau3(*), v4tau4(*)
1379    end subroutine xc_mgga_lxc
1380  end interface
1381
1382  contains
1383
1384  !----------------------------------------------------------------
1385  subroutine xc_f90_version(major, minor, micro)
1386    integer(c_int), intent(out) :: major, minor, micro
1387
1388    call xc_version(major, minor, micro)
1389
1390  end subroutine xc_f90_version
1391
1392  subroutine xc_f90_version_string(version)
1393    character(len=*), intent(out) :: version
1394
1395    type(c_ptr) :: c_version
1396
1397    c_version = xc_version_string()
1398    call c_to_f_string_ptr(c_version, version)
1399
1400  end subroutine xc_f90_version_string
1401
1402  subroutine xc_f90_reference(ref)
1403    character(len=*), intent(out) :: ref
1404
1405    type(c_ptr) :: c_ref
1406
1407    c_ref = xc_reference()
1408    call c_to_f_string_ptr(c_ref, ref)
1409
1410  end subroutine xc_f90_reference
1411
1412  subroutine xc_f90_reference_doi(doi)
1413    character(len=*), intent(out) :: doi
1414
1415    type(c_ptr) :: c_doi
1416
1417    c_doi = xc_reference_doi()
1418    call c_to_f_string_ptr(c_doi, doi)
1419
1420  end subroutine xc_f90_reference_doi
1421
1422  !----------------------------------------------------------------
1423  integer(c_int) function xc_f90_func_info_get_number(info) result(number)
1424    type(xc_f90_func_info_t), intent(in) :: info
1425
1426    number = xc_func_info_get_number(info%ptr)
1427
1428  end function xc_f90_func_info_get_number
1429
1430  integer(c_int) function xc_f90_func_info_get_kind(info) result(kind)
1431    type(xc_f90_func_info_t), intent(in) :: info
1432
1433    kind = xc_func_info_get_kind(info%ptr)
1434
1435  end function xc_f90_func_info_get_kind
1436
1437  character(len=128) function xc_f90_func_info_get_name(info) result(name)
1438    type(xc_f90_func_info_t), intent(in) :: info
1439
1440    call c_to_f_string_ptr(xc_func_info_get_name(info%ptr), name)
1441
1442  end function xc_f90_func_info_get_name
1443
1444  integer(c_int) function xc_f90_func_info_get_family(info) result(family)
1445    type(xc_f90_func_info_t), intent(in) :: info
1446
1447    family = xc_func_info_get_family(info%ptr)
1448
1449  end function xc_f90_func_info_get_family
1450
1451  integer(c_int) function xc_f90_func_info_get_flags(info) result(flags)
1452    type(xc_f90_func_info_t), intent(in) :: info
1453
1454    flags = xc_func_info_get_flags(info%ptr)
1455
1456  end function xc_f90_func_info_get_flags
1457
1458  type(xc_f90_func_reference_t) function xc_f90_func_info_get_references(info, number) result(reference)
1459    type(xc_f90_func_info_t), intent(in) :: info
1460    integer(c_int), intent(inout) :: number ! number of the reference. Must be 0 in the first call
1461
1462    type(c_ptr) :: next_ref
1463
1464    reference%ptr = xc_func_info_get_references(info%ptr, number)
1465    next_ref = xc_func_info_get_references(info%ptr, INT(number + 1, c_int))
1466    if (c_associated(next_ref)) then
1467      number = number + 1
1468    else
1469      number = -1
1470    end if
1471
1472  end function xc_f90_func_info_get_references
1473
1474  integer(c_int) function xc_f90_func_info_get_n_ext_params(info) result(n_ext_params)
1475    type(xc_f90_func_info_t), intent(in) :: info
1476
1477    n_ext_params = xc_func_info_get_n_ext_params(info%ptr)
1478
1479  end function xc_f90_func_info_get_n_ext_params
1480
1481  character(len=128) function xc_f90_func_info_get_ext_params_name(info, number) result(name)
1482    type(xc_f90_func_info_t), intent(in) :: info
1483    integer(c_int), intent(in) :: number
1484
1485    call c_to_f_string_ptr(xc_func_info_get_ext_params_name(info%ptr, number), name)
1486
1487  end function xc_f90_func_info_get_ext_params_name
1488
1489  character(len=128) function xc_f90_func_info_get_ext_params_description(info, number) result(description)
1490    type(xc_f90_func_info_t), intent(in) :: info
1491    integer(c_int), intent(in) :: number
1492
1493    call c_to_f_string_ptr(xc_func_info_get_ext_params_description(info%ptr, number), description)
1494
1495  end function xc_f90_func_info_get_ext_params_description
1496
1497  real(c_double) function xc_f90_func_info_get_ext_params_default_value(info, number) result(val)
1498    type(xc_f90_func_info_t), intent(in) :: info
1499    integer(c_int), intent(in) :: number
1500
1501    val = xc_func_info_get_ext_params_default_value(info%ptr, number)
1502
1503  end function xc_f90_func_info_get_ext_params_default_value
1504
1505  !----------------------------------------------------------------
1506  character(len=1024) function xc_f90_func_reference_get_ref(reference) result(ref)
1507    type(xc_f90_func_reference_t), intent(in) :: reference
1508
1509    call c_to_f_string_ptr(xc_func_reference_get_ref(reference%ptr), ref)
1510
1511  end function xc_f90_func_reference_get_ref
1512
1513  character(len=1024) function xc_f90_func_reference_get_doi(reference) result(doi)
1514    type(xc_f90_func_reference_t), intent(in) :: reference
1515
1516    call c_to_f_string_ptr(xc_func_reference_get_doi(reference%ptr), doi)
1517
1518  end function xc_f90_func_reference_get_doi
1519
1520  character(len=1024) function xc_f90_func_reference_get_bibtex(reference) result(bibtex)
1521    type(xc_f90_func_reference_t), intent(in) :: reference
1522
1523    call c_to_f_string_ptr(xc_func_reference_get_bibtex(reference%ptr), bibtex)
1524
1525  end function xc_f90_func_reference_get_bibtex
1526
1527
1528  !----------------------------------------------------------------
1529  subroutine xc_f90_func_init(p, functional, nspin, err)
1530    type(xc_f90_func_t), intent(inout) :: p
1531    integer(c_int), intent(in) :: functional
1532    integer(c_int), intent(in) :: nspin
1533    integer(c_int), optional, intent(out) :: err
1534
1535    integer(c_int) :: ierr
1536
1537    p%ptr = xc_func_alloc()
1538    ierr = xc_func_init(p%ptr, functional, nspin)
1539
1540    if(present(err)) err = ierr
1541  end subroutine xc_f90_func_init
1542
1543  subroutine xc_f90_func_end(p)
1544    type(xc_f90_func_t), intent(inout) :: p
1545
1546    call xc_func_end(p%ptr)
1547    call xc_func_free(p%ptr)
1548
1549  end subroutine xc_f90_func_end
1550
1551  type(xc_f90_func_info_t) function xc_f90_func_get_info(p) result(info)
1552    type(xc_f90_func_t), intent(in) :: p
1553
1554    info%ptr = xc_func_get_info(p%ptr)
1555
1556  end function xc_f90_func_get_info
1557
1558  character(len=128) function xc_f90_functional_get_name(number) result(name)
1559    integer(c_int), intent(in) :: number
1560
1561    call c_to_f_string_ptr(xc_functional_get_name(number), name)
1562
1563  end function xc_f90_functional_get_name
1564
1565  integer(c_int) function xc_f90_functional_get_number(func_string) result(number)
1566    character(len=*), intent(in) :: func_string
1567
1568    number = xc_functional_get_number(f_to_c_string(func_string))
1569
1570  end function xc_f90_functional_get_number
1571
1572  integer(c_int) function xc_f90_family_from_id(id, family, number)
1573    integer(c_int), intent(in) :: id
1574    integer(c_int), intent(out), optional, target :: family, number
1575
1576    type(c_ptr) c_family, c_number
1577    integer(c_int), pointer :: f_family, f_number
1578
1579    if (present(family)) then
1580      f_family => family
1581      call c_f_pointer(c_family, f_family)
1582    else
1583      c_family = C_NULL_PTR
1584    end if
1585    if (present(number)) then
1586      f_number => number
1587      call c_f_pointer(c_number, f_number)
1588    else
1589      c_number = C_NULL_PTR
1590    end if
1591
1592    xc_f90_family_from_id = xc_family_from_id(id, c_family, c_number)
1593
1594  end function xc_f90_family_from_id
1595
1596  subroutine xc_f90_available_functional_names(list)
1597    character(len=*), intent(out) :: list(*)
1598
1599    integer(c_int) :: n, i, maxlen
1600    character(kind=c_char), allocatable, target :: names(:,:)
1601    type(c_ptr), allocatable :: c_list(:)
1602
1603    n = xc_f90_number_of_functionals()
1604    maxlen = xc_f90_maximum_name_length()
1605
1606    allocate(names(maxlen, n))
1607    allocate(c_list(n))
1608    do i = 1, n
1609      c_list(i) = c_loc(names(1,i))
1610    end do
1611
1612    call xc_available_functional_names(c_list)
1613
1614    do i = 1, n
1615      call c_to_f_string_ptr(c_list(i), list(i))
1616    end do
1617
1618    deallocate(c_list)
1619    deallocate(names)
1620
1621  end subroutine xc_f90_available_functional_names
1622
1623
1624  subroutine xc_f90_func_set_dens_threshold(p, dens_threshold)
1625    type(xc_f90_func_t), intent(in) :: p
1626    real(c_double), intent(in) :: dens_threshold
1627
1628    call xc_func_set_dens_threshold(p%ptr, dens_threshold)
1629
1630  end subroutine xc_f90_func_set_dens_threshold
1631
1632  subroutine xc_f90_func_set_zeta_threshold(p, zeta_threshold)
1633    type(xc_f90_func_t), intent(in) :: p
1634    real(c_double), intent(in) :: zeta_threshold
1635
1636    call xc_func_set_zeta_threshold(p%ptr, zeta_threshold)
1637
1638  end subroutine xc_f90_func_set_zeta_threshold
1639
1640  subroutine xc_f90_func_set_sigma_threshold(p, sigma_threshold)
1641    type(xc_f90_func_t), intent(in) :: p
1642    real(c_double), intent(in) :: sigma_threshold
1643
1644    call xc_func_set_sigma_threshold(p%ptr, sigma_threshold)
1645
1646  end subroutine xc_f90_func_set_sigma_threshold
1647
1648  subroutine xc_f90_func_set_tau_threshold(p, tau_threshold)
1649    type(xc_f90_func_t), intent(in) :: p
1650    real(c_double), intent(in) :: tau_threshold
1651
1652    call xc_func_set_tau_threshold(p%ptr, tau_threshold)
1653
1654  end subroutine xc_f90_func_set_tau_threshold
1655
1656  subroutine xc_f90_func_set_ext_params(p, ext_params)
1657    type(xc_f90_func_t), intent(in) :: p
1658    real(c_double), intent(in) :: ext_params(*)
1659
1660    call xc_func_set_ext_params(p%ptr, ext_params)
1661
1662  end subroutine xc_f90_func_set_ext_params
1663
1664  subroutine xc_f90_func_set_ext_params_name(p, name, par)
1665    type(xc_f90_func_t), intent(in) :: p
1666    character(len=*), intent(in) :: name
1667    real(c_double), intent(in) :: par
1668
1669    call xc_func_set_ext_params_name(p%ptr, f_to_c_string(name), par)
1670
1671  end subroutine xc_f90_func_set_ext_params_name
1672
1673  ! LDAs
1674  !----------------------------------------------------------------
1675  subroutine xc_f90_lda(p, np, rho, zk, vrho, v2rho2, v3rho3, v4rho4)
1676    type(xc_f90_func_t), intent(in) :: p
1677    integer(c_size_t), intent(in) :: np
1678    real(c_double), intent(in) :: rho(*)
1679    real(c_double), intent(out) :: zk(*), vrho(*), v2rho2(*), v3rho3(*), v4rho4(*)
1680
1681    call xc_lda(p%ptr, np, rho, zk, vrho, v2rho2, v3rho3, v4rho4)
1682
1683  end subroutine xc_f90_lda
1684
1685  subroutine xc_f90_lda_exc(p, np, rho, zk)
1686    type(xc_f90_func_t), intent(in) :: p
1687    integer(c_size_t), intent(in) :: np
1688    real(c_double), intent(in) :: rho(*)
1689    real(c_double), intent(out) :: zk(*)
1690
1691    call xc_lda_exc(p%ptr, np, rho, zk)
1692
1693  end subroutine xc_f90_lda_exc
1694
1695  subroutine xc_f90_lda_exc_vxc(p, np, rho, zk, vrho)
1696    type(xc_f90_func_t), intent(in) :: p
1697    integer(c_size_t), intent(in) :: np
1698    real(c_double), intent(in) :: rho(*)
1699    real(c_double), intent(out) :: zk(*), vrho(*)
1700
1701    call xc_lda_exc_vxc(p%ptr, np, rho, zk, vrho)
1702
1703  end subroutine xc_f90_lda_exc_vxc
1704
1705  subroutine xc_f90_lda_exc_vxc_fxc(p, np, rho, zk, vrho, v2rho2)
1706    type(xc_f90_func_t), intent(in) :: p
1707    integer(c_size_t), intent(in) :: np
1708    real(c_double), intent(in) :: rho(*)
1709    real(c_double), intent(out) :: zk(*), vrho(*), v2rho2(*)
1710
1711    call xc_lda_exc_vxc_fxc(p%ptr, np, rho, zk, vrho, v2rho2)
1712
1713  end subroutine xc_f90_lda_exc_vxc_fxc
1714
1715  subroutine xc_f90_lda_exc_vxc_fxc_kxc(p, np, rho, zk, vrho, v2rho2, v3rho3)
1716    type(xc_f90_func_t), intent(in) :: p
1717    integer(c_size_t), intent(in) :: np
1718    real(c_double), intent(in) :: rho(*)
1719    real(c_double), intent(out) :: zk(*), vrho(*), v2rho2(*), v3rho3(*)
1720
1721    call xc_lda_exc_vxc_fxc_kxc(p%ptr, np, rho, zk, vrho, v2rho2, v3rho3)
1722
1723  end subroutine xc_f90_lda_exc_vxc_fxc_kxc
1724
1725  subroutine xc_f90_lda_vxc(p, np, rho, vrho)
1726    type(xc_f90_func_t), intent(in) :: p
1727    integer(c_size_t), intent(in) :: np
1728    real(c_double), intent(in) :: rho(*)
1729    real(c_double), intent(out) :: vrho(*)
1730
1731    call xc_lda_vxc(p%ptr, np, rho, vrho)
1732
1733  end subroutine xc_f90_lda_vxc
1734
1735  subroutine xc_f90_lda_vxc_fxc(p, np, rho, vrho, v2rho2)
1736    type(xc_f90_func_t), intent(in) :: p
1737    integer(c_size_t), intent(in) :: np
1738    real(c_double), intent(in) :: rho(*)
1739    real(c_double), intent(out) :: vrho(*), v2rho2(*)
1740
1741    call xc_lda_vxc_fxc(p%ptr, np, rho, vrho, v2rho2)
1742
1743  end subroutine xc_f90_lda_vxc_fxc
1744
1745  subroutine xc_f90_lda_vxc_fxc_kxc(p, np, rho, vrho, v2rho2, v3rho3)
1746    type(xc_f90_func_t), intent(in) :: p
1747    integer(c_size_t), intent(in) :: np
1748    real(c_double), intent(in) :: rho(*)
1749    real(c_double), intent(out) :: vrho(*), v2rho2(*), v3rho3(*)
1750
1751    call xc_lda_vxc_fxc_kxc(p%ptr, np, rho, vrho, v2rho2, v3rho3)
1752
1753  end subroutine xc_f90_lda_vxc_fxc_kxc
1754
1755  subroutine xc_f90_lda_fxc(p, np, rho, v2rho2)
1756    type(xc_f90_func_t), intent(in) :: p
1757    integer(c_size_t), intent(in) :: np
1758    real(c_double), intent(in) :: rho(*)
1759    real(c_double), intent(out) :: v2rho2(*)
1760
1761    call xc_lda_fxc(p%ptr, np, rho, v2rho2)
1762
1763  end subroutine xc_f90_lda_fxc
1764
1765  subroutine xc_f90_lda_kxc(p, np, rho, v3rho3)
1766    type(xc_f90_func_t), intent(in) :: p
1767    integer(c_size_t), intent(in) :: np
1768    real(c_double), intent(in) :: rho(*)
1769    real(c_double), intent(out) :: v3rho3(*)
1770
1771    call xc_lda_kxc(p%ptr, np, rho, v3rho3)
1772
1773  end subroutine xc_f90_lda_kxc
1774
1775  subroutine xc_f90_lda_lxc(p, np, rho, v4rho4)
1776    type(xc_f90_func_t), intent(in) :: p
1777    integer(c_size_t), intent(in) :: np
1778    real(c_double), intent(in) :: rho(*)
1779    real(c_double), intent(out) :: v4rho4(*)
1780
1781    call xc_lda_lxc(p%ptr, np, rho, v4rho4)
1782
1783  end subroutine xc_f90_lda_lxc
1784
1785  ! GGAs
1786  !----------------------------------------------------------------
1787  subroutine xc_f90_gga(p, np, rho, sigma, zk, vrho, vsigma, &
1788       v2rho2, v2rhosigma, v2sigma2, &
1789       v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3, &
1790       v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4 &
1791    )
1792    type(xc_f90_func_t), intent(in) :: p
1793    integer(c_size_t), intent(in) :: np
1794    real(c_double), intent(in) :: rho(*), sigma(*)
1795    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1796    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1797    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1798    real(c_double), intent(out) :: v4rho4(*), v4rho3sigma(*), v4rho2sigma2(*), v4rhosigma3(*), v4sigma4(*)
1799
1800    call xc_gga(p%ptr, np, rho, sigma, zk, vrho, vsigma, &
1801         v2rho2, v2rhosigma, v2sigma2, &
1802         v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3, &
1803         v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4 &
1804         )
1805
1806  end subroutine xc_f90_gga
1807
1808  subroutine xc_f90_gga_exc(p, np, rho, sigma, zk)
1809    type(xc_f90_func_t), intent(in) :: p
1810    integer(c_size_t), intent(in) :: np
1811    real(c_double), intent(in) :: rho(*), sigma(*)
1812    real(c_double), intent(out) :: zk(*)
1813
1814    call xc_gga_exc(p%ptr, np, rho, sigma, zk)
1815
1816  end subroutine xc_f90_gga_exc
1817
1818  subroutine xc_f90_gga_exc_vxc(p, np, rho, sigma, zk, vrho, vsigma)
1819    type(xc_f90_func_t), intent(in) :: p
1820    integer(c_size_t), intent(in) :: np
1821    real(c_double), intent(in) :: rho(*), sigma(*)
1822    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1823
1824    call xc_gga_exc_vxc(p%ptr, np, rho, sigma, zk, vrho, vsigma)
1825
1826  end subroutine xc_f90_gga_exc_vxc
1827
1828  subroutine xc_f90_gga_exc_vxc_fxc(p, np, rho, sigma, zk, vrho, vsigma, &
1829       v2rho2, v2rhosigma, v2sigma2)
1830    type(xc_f90_func_t), intent(in) :: p
1831    integer(c_size_t), intent(in) :: np
1832    real(c_double), intent(in) :: rho(*), sigma(*)
1833    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1834    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1835
1836    call xc_gga_exc_vxc_fxc(p%ptr, np, rho, sigma, zk, vrho, vsigma, &
1837         v2rho2, v2rhosigma, v2sigma2)
1838
1839  end subroutine xc_f90_gga_exc_vxc_fxc
1840
1841  subroutine xc_f90_gga_exc_vxc_fxc_kxc(p, np, rho, sigma, zk, vrho, vsigma, &
1842       v2rho2, v2rhosigma, v2sigma2, &
1843       v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3)
1844    type(xc_f90_func_t), intent(in) :: p
1845    integer(c_size_t), intent(in) :: np
1846    real(c_double), intent(in) :: rho(*), sigma(*)
1847    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*)
1848    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1849    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1850
1851    call xc_gga_exc_vxc_fxc_kxc(p%ptr, np, rho, sigma, zk, vrho, vsigma, &
1852         v2rho2, v2rhosigma, v2sigma2, &
1853         v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3)
1854
1855  end subroutine xc_f90_gga_exc_vxc_fxc_kxc
1856
1857  subroutine xc_f90_gga_vxc(p, np, rho, sigma, vrho, vsigma)
1858    type(xc_f90_func_t), intent(in) :: p
1859    integer(c_size_t), intent(in) :: np
1860    real(c_double), intent(in) :: rho(*), sigma(*)
1861    real(c_double), intent(out) :: vrho(*), vsigma(*)
1862
1863    call xc_gga_vxc(p%ptr, np, rho, sigma, vrho, vsigma)
1864
1865  end subroutine xc_f90_gga_vxc
1866
1867  subroutine xc_f90_gga_vxc_fxc(p, np, rho, sigma, vrho, vsigma, &
1868       v2rho2, v2rhosigma, v2sigma2)
1869    type(xc_f90_func_t), intent(in) :: p
1870    integer(c_size_t), intent(in) :: np
1871    real(c_double), intent(in) :: rho(*), sigma(*)
1872    real(c_double), intent(out) :: vrho(*), vsigma(*)
1873    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1874
1875    call xc_gga_vxc_fxc(p%ptr, np, rho, sigma, vrho, vsigma, &
1876         v2rho2, v2rhosigma, v2sigma2)
1877
1878  end subroutine xc_f90_gga_vxc_fxc
1879
1880  subroutine xc_f90_gga_vxc_fxc_kxc(p, np, rho, sigma, vrho, vsigma, &
1881       v2rho2, v2rhosigma, v2sigma2, &
1882       v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3)
1883    type(xc_f90_func_t), intent(in) :: p
1884    integer(c_size_t), intent(in) :: np
1885    real(c_double), intent(in) :: rho(*), sigma(*)
1886    real(c_double), intent(out) :: vrho(*), vsigma(*)
1887    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1888    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1889
1890    call xc_gga_vxc_fxc_kxc(p%ptr, np, rho, sigma, vrho, vsigma, &
1891         v2rho2, v2rhosigma, v2sigma2, &
1892         v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3)
1893
1894  end subroutine xc_f90_gga_vxc_fxc_kxc
1895
1896  subroutine xc_f90_gga_fxc(p, np, rho, sigma, v2rho2, v2rhosigma, v2sigma2)
1897    type(xc_f90_func_t), intent(in) :: p
1898    integer(c_size_t), intent(in) :: np
1899    real(c_double), intent(in) :: rho(*), sigma(*)
1900    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2sigma2(*)
1901
1902    call xc_gga_fxc(p%ptr, np, rho, sigma, v2rho2, v2rhosigma, v2sigma2)
1903
1904  end subroutine xc_f90_gga_fxc
1905
1906  subroutine xc_f90_gga_kxc(p, np, rho, sigma, v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3)
1907    type(xc_f90_func_t), intent(in) :: p
1908    integer(c_size_t), intent(in) :: np
1909    real(c_double), intent(in) :: rho(*), sigma(*)
1910    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rhosigma2(*), v3sigma3(*)
1911
1912    call xc_gga_kxc(p%ptr, np, rho, sigma, v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3)
1913
1914  end subroutine xc_f90_gga_kxc
1915
1916  subroutine xc_f90_gga_lxc(p, np, rho, sigma, v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4)
1917    type(xc_f90_func_t), intent(in) :: p
1918    integer(c_size_t), intent(in) :: np
1919    real(c_double), intent(in) :: rho(*), sigma(*)
1920    real(c_double), intent(out) :: v4rho4(*), v4rho3sigma(*), v4rho2sigma2(*), v4rhosigma3(*), v4sigma4(*)
1921
1922    call xc_gga_lxc(p%ptr, np, rho, sigma, v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4)
1923  end subroutine xc_f90_gga_lxc
1924
1925  real(c_double) function xc_f90_gga_ak13_get_asymptotic(homo) result(asymptotic)
1926    real(c_double), intent(in) :: homo
1927
1928    asymptotic = xc_gga_ak13_get_asymptotic(homo)
1929
1930  end function xc_f90_gga_ak13_get_asymptotic
1931
1932  real(c_double) function xc_f90_hyb_exx_coef(p) result(coef)
1933    type(xc_f90_func_t), intent(in) :: p
1934
1935    coef = xc_hyb_exx_coef(p%ptr)
1936
1937  end function xc_f90_hyb_exx_coef
1938
1939  subroutine xc_f90_hyb_cam_coef(p, omega, alpha, beta)
1940    type(xc_f90_func_t), intent(in) :: p
1941    real(c_double), intent(out) :: omega, alpha, beta
1942
1943    call xc_hyb_cam_coef(p%ptr, omega, alpha, beta)
1944
1945  end subroutine xc_f90_hyb_cam_coef
1946
1947  subroutine xc_f90_nlc_coef(p, nlc_b, nlc_c)
1948    type(xc_f90_func_t), intent(in) :: p
1949    real(c_double), intent(out) :: nlc_b, nlc_c
1950
1951    call xc_nlc_coef(p%ptr, nlc_b, nlc_c)
1952
1953  end subroutine xc_f90_nlc_coef
1954
1955
1956  ! the meta-GGAs
1957  !----------------------------------------------------------------
1958  subroutine xc_f90_mgga(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
1959         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1960         v2lapl2, v2lapltau, v2tau2, &
1961         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
1962         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
1963         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
1964         v3lapltau2, v3tau3, &
1965         v4rho4, v4rho3sigma, v4rho3lapl, v4rho3tau, v4rho2sigma2, v4rho2sigmalapl, &
1966         v4rho2sigmatau, v4rho2lapl2, v4rho2lapltau, v4rho2tau2, v4rhosigma3, &
1967         v4rhosigma2lapl, v4rhosigma2tau, v4rhosigmalapl2, v4rhosigmalapltau, &
1968         v4rhosigmatau2, v4rholapl3, v4rholapl2tau, v4rholapltau2, v4rhotau3, v4sigma4, &
1969         v4sigma3lapl, v4sigma3tau, v4sigma2lapl2, v4sigma2lapltau, v4sigma2tau2, &
1970         v4sigmalapl3, v4sigmalapl2tau, v4sigmalapltau2, v4sigmatau3, v4lapl4, &
1971         v4lapl3tau, v4lapl2tau2, v4lapltau3, v4tau4 &
1972         )
1973    type(xc_f90_func_t), intent(in) :: p
1974    integer(c_size_t), intent(in) :: np
1975    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
1976    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
1977    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
1978         v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
1979    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
1980         v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
1981         v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
1982         v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
1983         v3lapltau2(*), v3tau3(*)
1984    real(c_double), intent(out) :: &
1985           v4rho4(*), v4rho3sigma(*), v4rho3lapl(*), v4rho3tau(*), v4rho2sigma2(*), v4rho2sigmalapl(*), &
1986           v4rho2sigmatau(*), v4rho2lapl2(*), v4rho2lapltau(*), v4rho2tau2(*), v4rhosigma3(*), &
1987           v4rhosigma2lapl(*), v4rhosigma2tau(*), v4rhosigmalapl2(*), v4rhosigmalapltau(*), &
1988           v4rhosigmatau2(*), v4rholapl3(*), v4rholapl2tau(*), v4rholapltau2(*), v4rhotau3(*), v4sigma4(*), &
1989           v4sigma3lapl(*), v4sigma3tau(*), v4sigma2lapl2(*), v4sigma2lapltau(*), v4sigma2tau2(*), &
1990           v4sigmalapl3(*), v4sigmalapl2tau(*), v4sigmalapltau2(*), v4sigmatau3(*), v4lapl4(*), &
1991           v4lapl3tau(*), v4lapl2tau2(*), v4lapltau3(*), v4tau4(*)
1992
1993    call xc_mgga(p%ptr, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
1994         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
1995         v2lapl2, v2lapltau, v2tau2, &
1996         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
1997         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
1998         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
1999         v3lapltau2, v3tau3, &
2000         v4rho4, v4rho3sigma, v4rho3lapl, v4rho3tau, v4rho2sigma2, v4rho2sigmalapl, &
2001         v4rho2sigmatau, v4rho2lapl2, v4rho2lapltau, v4rho2tau2, v4rhosigma3, &
2002         v4rhosigma2lapl, v4rhosigma2tau, v4rhosigmalapl2, v4rhosigmalapltau, &
2003         v4rhosigmatau2, v4rholapl3, v4rholapl2tau, v4rholapltau2, v4rhotau3, v4sigma4, &
2004         v4sigma3lapl, v4sigma3tau, v4sigma2lapl2, v4sigma2lapltau, v4sigma2tau2, &
2005         v4sigmalapl3, v4sigmalapl2tau, v4sigmalapltau2, v4sigmatau3, v4lapl4, &
2006         v4lapl3tau, v4lapl2tau2, v4lapltau3, v4tau4 &
2007         )
2008  end subroutine xc_f90_mgga
2009
2010  subroutine xc_f90_mgga_exc(p, np, rho, sigma, lapl, tau, zk)
2011    type(xc_f90_func_t), intent(in) :: p
2012    integer(c_size_t), intent(in) :: np
2013    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2014    real(c_double), intent(out) :: zk(*)
2015
2016    call xc_mgga_exc(p%ptr, np, rho, sigma, lapl, tau, zk)
2017
2018  end subroutine xc_f90_mgga_exc
2019
2020  subroutine xc_f90_mgga_exc_vxc(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau)
2021    type(xc_f90_func_t), intent(in) :: p
2022    integer(c_size_t), intent(in) :: np
2023    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2024    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
2025
2026    call xc_mgga_exc_vxc(p%ptr, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau)
2027
2028  end subroutine xc_f90_mgga_exc_vxc
2029
2030  subroutine xc_f90_mgga_exc_vxc_fxc(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
2031         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2032         v2lapl2, v2lapltau, v2tau2)
2033    type(xc_f90_func_t), intent(in) :: p
2034    integer(c_size_t), intent(in) :: np
2035    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2036    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
2037    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
2038         v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
2039
2040    call xc_mgga_exc_vxc_fxc(p%ptr, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
2041         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2042         v2lapl2, v2lapltau, v2tau2)
2043  end subroutine xc_f90_mgga_exc_vxc_fxc
2044
2045  subroutine xc_f90_mgga_exc_vxc_fxc_kxc(p, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
2046         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2047         v2lapl2, v2lapltau, v2tau2, &
2048         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
2049         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
2050         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
2051         v3lapltau2, v3tau3)
2052    type(xc_f90_func_t), intent(in) :: p
2053    integer(c_size_t), intent(in) :: np
2054    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2055    real(c_double), intent(out) :: zk(*), vrho(*), vsigma(*), vlapl(*), vtau(*)
2056    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
2057         v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
2058    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
2059         v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
2060         v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
2061         v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
2062         v3lapltau2(*), v3tau3(*)
2063
2064    call xc_mgga_exc_vxc_fxc_kxc(p%ptr, np, rho, sigma, lapl, tau, zk, vrho, vsigma, vlapl, vtau, &
2065         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2066         v2lapl2, v2lapltau, v2tau2, &
2067         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
2068         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
2069         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
2070         v3lapltau2, v3tau3)
2071  end subroutine xc_f90_mgga_exc_vxc_fxc_kxc
2072
2073  subroutine xc_f90_mgga_vxc(p, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau)
2074    type(xc_f90_func_t), intent(in) :: p
2075    integer(c_size_t), intent(in) :: np
2076    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2077    real(c_double), intent(out) :: vrho(*), vsigma(*), vlapl(*), vtau(*)
2078
2079    call xc_mgga_vxc(p%ptr, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau)
2080
2081  end subroutine xc_f90_mgga_vxc
2082
2083  subroutine xc_f90_mgga_vxc_fxc(p, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau, &
2084         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2085         v2lapl2, v2lapltau, v2tau2)
2086    type(xc_f90_func_t), intent(in) :: p
2087    integer(c_size_t), intent(in) :: np
2088    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2089    real(c_double), intent(out) :: vrho(*), vsigma(*), vlapl(*), vtau(*)
2090    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
2091         v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
2092
2093    call xc_mgga_vxc_fxc(p%ptr, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau, &
2094         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2095         v2lapl2, v2lapltau, v2tau2)
2096  end subroutine xc_f90_mgga_vxc_fxc
2097
2098  subroutine xc_f90_mgga_vxc_fxc_kxc(p, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau, &
2099         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2100         v2lapl2, v2lapltau, v2tau2, &
2101         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
2102         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
2103         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
2104         v3lapltau2, v3tau3)
2105    type(xc_f90_func_t), intent(in) :: p
2106    integer(c_size_t), intent(in) :: np
2107    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2108    real(c_double), intent(out) :: vrho(*), vsigma(*), vlapl(*), vtau(*)
2109    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
2110         v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
2111    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
2112         v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
2113         v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
2114         v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
2115         v3lapltau2(*), v3tau3(*)
2116
2117    call xc_mgga_vxc_fxc_kxc(p%ptr, np, rho, sigma, lapl, tau, vrho, vsigma, vlapl, vtau, &
2118         v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2119         v2lapl2, v2lapltau, v2tau2, &
2120         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
2121         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
2122         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
2123         v3lapltau2, v3tau3)
2124  end subroutine xc_f90_mgga_vxc_fxc_kxc
2125
2126  subroutine xc_f90_mgga_fxc(p, np, rho, sigma, lapl, tau, &
2127       v2rho2, v2rhosigma, v2rholapl, v2rhotau, v2sigma2, v2sigmalapl, v2sigmatau, &
2128       v2lapl2, v2lapltau, v2tau2)
2129    type(xc_f90_func_t), intent(in) :: p
2130    integer(c_size_t), intent(in) :: np
2131    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2132    real(c_double), intent(out) :: v2rho2(*), v2rhosigma(*), v2rholapl(*), v2rhotau(*), &
2133         v2sigma2(*), v2sigmalapl(*), v2sigmatau(*), v2lapl2(*), v2lapltau(*), v2tau2(*)
2134
2135    call xc_mgga_fxc(p%ptr, np, rho, sigma, lapl, tau, &
2136      v2rho2, v2rhosigma, v2rholapl, v2rhotau, &
2137      v2sigma2, v2sigmalapl, v2sigmatau, v2lapl2, v2lapltau, v2tau2)
2138
2139  end subroutine xc_f90_mgga_fxc
2140
2141  subroutine xc_f90_mgga_kxc(p, np, rho, sigma, lapl, tau, &
2142       v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
2143       v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
2144       v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
2145       v3lapltau2, v3tau3)
2146    type(xc_f90_func_t), intent(in) :: p
2147    integer(c_size_t), intent(in) :: np
2148    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2149    real(c_double), intent(out) :: v3rho3(*), v3rho2sigma(*), v3rho2lapl(*), v3rho2tau(*), &
2150           v3rhosigma2(*), v3rhosigmalapl(*), v3rhosigmatau(*), v3rholapl2(*), &
2151           v3rholapltau(*), v3rhotau2(*), v3sigma3(*), v3sigma2lapl(*), v3sigma2tau(*), &
2152           v3sigmalapl2(*), v3sigmalapltau(*), v3sigmatau2(*), v3lapl3(*), v3lapl2tau(*), &
2153           v3lapltau2(*), v3tau3(*)
2154
2155    call xc_mgga_kxc(p%ptr, np, rho, sigma, lapl, tau, &
2156         v3rho3, v3rho2sigma, v3rho2lapl, v3rho2tau, v3rhosigma2, v3rhosigmalapl, &
2157         v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma3, v3sigma2lapl, &
2158         v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, &
2159         v3lapltau2, v3tau3)
2160  end subroutine xc_f90_mgga_kxc
2161
2162  subroutine xc_f90_mgga_lxc(p, np, rho, sigma, lapl, tau, &
2163       v4rho4, v4rho3sigma, v4rho3lapl, v4rho3tau, v4rho2sigma2, v4rho2sigmalapl, &
2164       v4rho2sigmatau, v4rho2lapl2, v4rho2lapltau, v4rho2tau2, v4rhosigma3, &
2165       v4rhosigma2lapl, v4rhosigma2tau, v4rhosigmalapl2, v4rhosigmalapltau, &
2166       v4rhosigmatau2, v4rholapl3, v4rholapl2tau, v4rholapltau2, v4rhotau3, v4sigma4, &
2167       v4sigma3lapl, v4sigma3tau, v4sigma2lapl2, v4sigma2lapltau, v4sigma2tau2, &
2168       v4sigmalapl3, v4sigmalapl2tau, v4sigmalapltau2, v4sigmatau3, v4lapl4, &
2169       v4lapl3tau, v4lapl2tau2, v4lapltau3, v4tau4 &
2170       )
2171    type(xc_f90_func_t), intent(in) :: p
2172    integer(c_size_t), intent(in) :: np
2173    real(c_double), intent(in) :: rho(*), sigma(*), lapl(*), tau(*)
2174    real(c_double), intent(out) :: &
2175         v4rho4(*), v4rho3sigma(*), v4rho3lapl(*), v4rho3tau(*), v4rho2sigma2(*), v4rho2sigmalapl(*), &
2176         v4rho2sigmatau(*), v4rho2lapl2(*), v4rho2lapltau(*), v4rho2tau2(*), v4rhosigma3(*), &
2177         v4rhosigma2lapl(*), v4rhosigma2tau(*), v4rhosigmalapl2(*), v4rhosigmalapltau(*), &
2178         v4rhosigmatau2(*), v4rholapl3(*), v4rholapl2tau(*), v4rholapltau2(*), v4rhotau3(*), v4sigma4(*), &
2179         v4sigma3lapl(*), v4sigma3tau(*), v4sigma2lapl2(*), v4sigma2lapltau(*), v4sigma2tau2(*), &
2180         v4sigmalapl3(*), v4sigmalapl2tau(*), v4sigmalapltau2(*), v4sigmatau3(*), v4lapl4(*), &
2181         v4lapl3tau(*), v4lapl2tau2(*), v4lapltau3(*), v4tau4(*)
2182
2183    call xc_mgga_lxc(p%ptr, np, rho, sigma, lapl, tau, &
2184         v4rho4, v4rho3sigma, v4rho3lapl, v4rho3tau, v4rho2sigma2, v4rho2sigmalapl, &
2185         v4rho2sigmatau, v4rho2lapl2, v4rho2lapltau, v4rho2tau2, v4rhosigma3, &
2186         v4rhosigma2lapl, v4rhosigma2tau, v4rhosigmalapl2, v4rhosigmalapltau, &
2187         v4rhosigmatau2, v4rholapl3, v4rholapl2tau, v4rholapltau2, v4rhotau3, v4sigma4, &
2188         v4sigma3lapl, v4sigma3tau, v4sigma2lapl2, v4sigma2lapltau, v4sigma2tau2, &
2189         v4sigmalapl3, v4sigmalapl2tau, v4sigmalapltau2, v4sigmatau3, v4lapl4, &
2190         v4lapl3tau, v4lapl2tau2, v4lapltau3, v4tau4 &
2191         )
2192  end subroutine xc_f90_mgga_lxc
2193
2194
2195  ! Helper functions to convert between C and Fortran strings
2196  ! Based on the routines by Joseph M. Krahn
2197  function f_to_c_string(f_string) result(c_string)
2198    character(len=*), intent(in) :: f_string
2199    character(kind=c_char,len=1) :: c_string(len_trim(f_string)+1)
2200
2201    integer :: i, strlen
2202
2203    strlen = len_trim(f_string)
2204
2205    forall (i=1:strlen)
2206      c_string(i) = f_string(i:i)
2207    end forall
2208    c_string(strlen+1) = C_NULL_CHAR
2209
2210  end function f_to_c_string
2211
2212  subroutine c_to_f_string(c_string, f_string)
2213    character(kind=c_char,len=1), intent(in) :: c_string(*)
2214    character(len=*), intent(out) :: f_string
2215
2216    integer :: i
2217
2218    i = 1
2219    do while(c_string(i) /= C_NULL_CHAR .and. i <= len(f_string))
2220      f_string(i:i) = c_string(i)
2221      i = i + 1
2222    end do
2223    if (i < len(f_string)) f_string(i:) = ' '
2224
2225  end subroutine c_to_f_string
2226
2227  subroutine c_to_f_string_ptr(c_string, f_string)
2228    type(c_ptr), intent(in) :: c_string
2229    character(len=*), intent(out) :: f_string
2230
2231    character(len=1, kind=c_char), pointer :: p_chars(:)
2232    integer :: i
2233
2234    if (.not. c_associated(c_string)) then
2235      f_string = ' '
2236    else
2237      call c_f_pointer(c_string, p_chars, [huge(0)])
2238      i = 1
2239      do while(p_chars(i) /= C_NULL_CHAR .and. i <= len(f_string))
2240        f_string(i:i) = p_chars(i)
2241        i = i + 1
2242      end do
2243      if (i < len(f_string)) f_string(i:) = ' '
2244    end if
2245
2246  end subroutine c_to_f_string_ptr
2247
2248end module xc_f90_lib_m
2249
2250!! Local Variables:
2251!! mode: f90
2252!! coding: utf-8
2253!! End:
2254
2255