(git:3d5d2e5)
Loading...
Searching...
No Matches
xc_gauxc_interface.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8#ifdef __GAUXC
9#include "gauxc/gauxc_config.f"
10#endif
11
12#define GAUXC_RETURN_IF_ERROR(status) IF (status%status%code /= 0) RETURN
13
14MODULE xc_gauxc_interface
15
16 USE iso_fortran_env, ONLY: &
17 error_unit
18#if defined (__HAS_IEEE_EXCEPTIONS)
19 USE ieee_exceptions, ONLY: &
20 ieee_all, &
21 ieee_get_halting_mode, &
22 ieee_set_halting_mode
23#endif
24 USE iso_c_binding, ONLY: &
25 c_associated, &
26 c_bool, &
27 c_char, &
28 c_double, &
29 c_f_pointer, &
30 c_int, &
31 c_int32_t, &
32 c_int64_t, &
33 c_null_char, &
34 c_null_ptr, &
35 c_ptr, &
36 c_size_t
37 USE particle_types, ONLY: &
39 USE qs_kind_types, ONLY: &
42 USE cp_dbcsr_api, ONLY: &
44 USE cp_log_handling, ONLY: &
46
47#ifdef __GAUXC
48
49 USE kinds, ONLY: &
52 dp
53 USE physcon, ONLY: &
54 bohr
55 USE atomic_kind_types, ONLY: &
59 USE qs_integral_utils, ONLY: &
61 USE basis_set_types, ONLY: &
65 USE periodic_table, ONLY: &
67 USE gauxc_status, ONLY: &
68 gauxc_status_message, &
69 gauxc_status_type
70 USE gauxc_enums, ONLY: &
71 gauxc_atomicgridsizedefault, &
72 gauxc_executionspace, &
73 gauxc_pruningscheme, &
74 gauxc_radialquad
75 USE gauxc_runtime_environment, ONLY: &
76 gauxc_runtime_environment_delete, &
77 gauxc_runtime_environment_new, &
78 gauxc_runtime_environment_type
79#ifdef GAUXC_HAS_DEVICE
80 USE gauxc_runtime_environment, ONLY: &
81 gauxc_device_runtime_environment_new
82#endif
83#if defined(GAUXC_HAS_DEVICE) && defined(__LIBTORCH)
85#endif
86 USE gauxc_molecule, ONLY: &
87 gauxc_delete, &
88 gauxc_molecule_new_from_atoms, &
89 gauxc_molecule_type
90 USE gauxc_atom, ONLY: &
91 gauxc_atom_type
92 USE gauxc_basisset, ONLY: &
93 gauxc_basisset_new, &
94 gauxc_basisset_new_from_shells, &
95 gauxc_basisset_type, &
96 gauxc_delete
97 USE gauxc_shell, ONLY: &
98 gauxc_shell_type
99 USE gauxc_molgrid, ONLY: &
100 gauxc_delete, &
101 gauxc_molgrid_new_default, &
102 gauxc_molgrid_type
103 USE gauxc_load_balancer, ONLY: &
104 gauxc_delete, &
105 gauxc_load_balancer_factory_get_instance, &
106 gauxc_load_balancer_factory_new, &
107 gauxc_load_balancer_factory_type, &
108 gauxc_load_balancer_type
109 USE gauxc_molecular_weights, ONLY: &
110 gauxc_delete, &
111 gauxc_get_instance, &
112 gauxc_molecular_weights_factory_new, &
113 gauxc_molecular_weights_factory_type, &
114 gauxc_molecular_weights_modify_weights, &
115 gauxc_molecular_weights_settings, &
116 gauxc_molecular_weights_type
117 USE gauxc_xc_functional, ONLY: &
118 gauxc_delete, &
119 gauxc_functional_from_string, &
120 gauxc_functional_type
121 USE gauxc_integrator, ONLY: &
122 gauxc_delete, &
123 gauxc_integrator_eval_exc_grad_rks, &
124 gauxc_integrator_eval_exc_grad_uks, &
125 gauxc_integrator_eval_exc_vxc_rks, &
126 gauxc_integrator_eval_exc_vxc_uks, &
127 gauxc_integrator_new, &
128 gauxc_integrator_type
129#ifdef GAUXC_HAS_ONEDFT
130 USE gauxc_integrator, ONLY: &
131 gauxc_integrator_eval_exc_grad_onedft_uks, &
132 gauxc_integrator_eval_exc_vxc_onedft_uks
133 USE omp_lib, ONLY: &
134 omp_get_max_threads, &
135 omp_set_num_threads
136#endif
137#ifdef GAUXC_HAS_HDF5
138 USE gauxc_external_hdf5_write, ONLY: &
139 gauxc_write_hdf5_record
140#endif
141 USE string_utilities, ONLY: &
143#endif
144
145#include "../base/base_uses.f90"
146
147 IMPLICIT NONE
148 PRIVATE
149
150#ifndef __GAUXC
151
152 ! The module still exists as an empty shell when compiling without GauXC.
153
154 TYPE cp_gauxc_molecule_type
155 END TYPE cp_gauxc_molecule_type
156
157 TYPE cp_gauxc_basisset_type
158 INTEGER :: max_l = -1
159 END TYPE cp_gauxc_basisset_type
160
161 TYPE cp_gauxc_grid_type
162 END TYPE cp_gauxc_grid_type
163
164 TYPE cp_gauxc_integrator_type
165 END TYPE cp_gauxc_integrator_type
166
167 TYPE cp_gauxc_status_type
168 END TYPE cp_gauxc_status_type
169
170#else
171
172 ! TODO can we make the single fields private somehow?
173
174 TYPE cp_gauxc_molecule_type
175 TYPE(gauxc_molecule_type) :: molecule
176 END TYPE cp_gauxc_molecule_type
177
178 TYPE cp_gauxc_basisset_type
179 TYPE(gauxc_basisset_type) :: basis
180 INTEGER :: max_l = -1
181 END TYPE cp_gauxc_basisset_type
182
183 TYPE cp_gauxc_grid_type
184 TYPE(gauxc_molgrid_type) :: grid
185 TYPE(gauxc_load_balancer_type) :: lb
186 TYPE(gauxc_load_balancer_factory_type) :: lbf
187 TYPE(gauxc_molecular_weights_type) :: mw
188 TYPE(gauxc_molecular_weights_factory_type) :: mwf
189 TYPE(gauxc_runtime_environment_type) :: rt
190 LOGICAL :: owns_rt = .false.
191 LOGICAL :: uses_device_runtime = .false.
192 END TYPE cp_gauxc_grid_type
193
194 TYPE cp_gauxc_integrator_type
195 TYPE(gauxc_functional_type) :: func
196 TYPE(gauxc_integrator_type) :: integrator
197 END TYPE cp_gauxc_integrator_type
198
199 TYPE cp_gauxc_status_type
200 TYPE(gauxc_status_type) :: status
201 END TYPE cp_gauxc_status_type
202
203 TYPE(gauxc_runtime_environment_type) :: rt
204 INTEGER :: rt_mpi_comm = -1
205 LOGICAL :: rt_has_mpi_comm = .false.
206
207#endif
208
209 TYPE cp_gauxc_xc_type
210 REAL(c_double) :: exc = 0.0_c_double
211 REAL(c_double), DIMENSION(:, :), ALLOCATABLE :: vxc_scalar, vxc_zeta
212 END TYPE cp_gauxc_xc_type
213
214 TYPE cp_gauxc_xc_gradient_type
215 REAL(c_double), ALLOCATABLE, DIMENSION(:) :: exc_grad
216 END TYPE cp_gauxc_xc_gradient_type
217
218 CHARACTER(LEN=*), PARAMETER :: no_gauxc_message = "Compile CP2K with GauXC to use this functionality!"
219
220 PUBLIC :: &
221 cp_gauxc_basisset_type, &
222 cp_gauxc_grid_type, &
223 cp_gauxc_integrator_type, &
224 cp_gauxc_molecule_type, &
225 cp_gauxc_status_type, &
226 cp_gauxc_xc_gradient_type, &
227 cp_gauxc_xc_type, &
228 gauxc_check_status, &
229 gauxc_compute_xc_gradient, &
230 gauxc_compute_xc, &
231 gauxc_create_basisset, &
232 gauxc_create_grid, &
233 gauxc_create_integrator, &
234 gauxc_create_molecule, &
235 gauxc_destroy_basisset, &
236 gauxc_destroy_grid, &
237 gauxc_destroy_integrator, &
238 gauxc_destroy_molecule, &
239 gauxc_finalize, &
240 gauxc_init, &
241 gauxc_write_basisset_hdf5, &
242 gauxc_write_molecule_hdf5
243CONTAINS
244
245! **************************************************************************************************
246!> \brief ...
247!> \param status ...
248! **************************************************************************************************
249 SUBROUTINE print_gauxc_status_message(status)
250 ! IMPORT :: c_ptr
251 TYPE(cp_gauxc_status_type) :: status
252
253#ifdef __GAUXC
254 CHARACTER(KIND=c_char), POINTER :: s(:)
255 CHARACTER(LEN=32) :: stderr_env
256 INTEGER :: i, ierr, iw
257 LOGICAL :: print_to_stderr
258 INTEGER, PARAMETER :: status_message_length = 4096
259
261 ierr = error_unit
262 CALL get_environment_variable("CP2K_GAUXC_STATUS_STDERR", stderr_env)
263 CALL uppercase(stderr_env)
264 SELECT CASE (trim(stderr_env))
265 CASE ("", "0", "FALSE", "F", "OFF", "NO")
266 print_to_stderr = .false.
267 CASE ("1", "TRUE", "T", "ON", "YES")
268 print_to_stderr = .true.
269 CASE DEFAULT
270 print_to_stderr = .true.
271 END SELECT
272 IF (iw > 0) THEN
273 WRITE (unit=iw, fmt='(a,1x,i0)') "GauXC returned with status code", status%status%code
274 IF (c_associated(status%status%message)) THEN
275 WRITE (unit=iw, fmt='(a)', advance='no') "GauXC status message: ["
276
277 CALL c_f_pointer(status%status%message, s, [status_message_length])
278 DO i = 1, SIZE(s)
279 IF (s(i) == c_null_char) EXIT
280 WRITE (unit=iw, fmt='(A)', advance='no') s(i)
281 END DO
282
283 WRITE (unit=iw, fmt='(a)') "]"
284 ELSE
285 WRITE (unit=iw, fmt='(a)') "GauXC status message: [null]"
286 END IF
287 END IF
288 IF (print_to_stderr) THEN
289 WRITE (unit=ierr, fmt='(a,1x,i0)') "GauXC returned with status code", status%status%code
290 IF (c_associated(status%status%message)) THEN
291 WRITE (unit=ierr, fmt='(a)', advance='no') "GauXC status message: ["
292
293 CALL c_f_pointer(status%status%message, s, [status_message_length])
294 DO i = 1, SIZE(s)
295 IF (s(i) == c_null_char) EXIT
296 WRITE (unit=ierr, fmt='(A)', advance='no') s(i)
297 END DO
298
299 WRITE (unit=ierr, fmt='(a)') "]"
300 ELSE
301 WRITE (unit=ierr, fmt='(a)') "GauXC status message: [null]"
302 END IF
303 END IF
304#else
305 mark_used(status)
306#endif
307 END SUBROUTINE print_gauxc_status_message
308
309! **************************************************************************************************
310!> \brief ...
311!> \param mpi_comm ...
312!> \param status ...
313! **************************************************************************************************
314 SUBROUTINE gauxc_init(mpi_comm, status)
315 INTEGER, INTENT(IN), OPTIONAL :: mpi_comm
316 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
317
318#ifdef __GAUXC
319#if defined(GAUXC_HAS_MPI) && defined(__parallel)
320 IF (PRESENT(mpi_comm)) THEN
321 rt = gauxc_runtime_environment_new(status%status, mpi_comm)
322 rt_mpi_comm = mpi_comm
323 rt_has_mpi_comm = .true.
324 ELSE
325 rt = gauxc_runtime_environment_new(status%status)
326 rt_mpi_comm = -1
327 rt_has_mpi_comm = .false.
328 END IF
329#else
330 mark_used(mpi_comm)
331 rt = gauxc_runtime_environment_new(status%status)
332 rt_mpi_comm = -1
333 rt_has_mpi_comm = .false.
334#endif
335 gauxc_return_if_error(status)
336#else
337 mark_used(mpi_comm)
338 mark_used(status)
339#endif
340 END SUBROUTINE gauxc_init
341
342! **************************************************************************************************
343!> \brief ...
344!> \param status ...
345! **************************************************************************************************
346 SUBROUTINE gauxc_finalize(status)
347 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
348
349#ifdef __GAUXC
350 CALL gauxc_runtime_environment_delete(status%status, rt)
351 gauxc_return_if_error(status)
352 rt_mpi_comm = -1
353 rt_has_mpi_comm = .false.
354#else
355 mark_used(status)
356#endif
357 END SUBROUTINE gauxc_finalize
358
359! **************************************************************************************************
360!> \brief ...
361!> \param particle_set ...
362!> \param status ...
363!> \return ...
364! **************************************************************************************************
365 FUNCTION gauxc_create_molecule(particle_set, status) RESULT(res)
366 TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particle_set
367 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
368 TYPE(cp_gauxc_molecule_type) :: res
369
370#ifdef __GAUXC
371 CHARACTER(LEN=2) :: element_symbol
372 INTEGER :: atomic_number, i, natoms
373 TYPE(atomic_kind_type), POINTER :: atomic_kind
374 TYPE(gauxc_atom_type), ALLOCATABLE, DIMENSION(:) :: atoms
375
376 natoms = SIZE(particle_set)
377 ALLOCATE (atoms(natoms))
378
379 DO i = 1, natoms
380 atomic_kind => particle_set(i)%atomic_kind
381 CALL get_atomic_kind(atomic_kind, element_symbol=element_symbol)
382 CALL get_ptable_info(element_symbol, number=atomic_number)
383 atoms(i)%atomic_number = int(atomic_number, c_int64_t)
384 atoms(i)%x = real(particle_set(i)%r(1), c_double)
385 atoms(i)%y = real(particle_set(i)%r(2), c_double)
386 atoms(i)%z = real(particle_set(i)%r(3), c_double)
387 END DO
388
389 res%molecule = gauxc_molecule_new_from_atoms(status%status, atoms, int(natoms, c_size_t))
390 gauxc_return_if_error(status)
391
392 DEALLOCATE (atoms)
393#else
394 mark_used(particle_set)
395 mark_used(res)
396 mark_used(status)
397 cpabort(no_gauxc_message)
398#endif
399 END FUNCTION gauxc_create_molecule
400
401! **************************************************************************************************
402!> \brief ...
403!> \param qs_kind_set ...
404!> \param particle_set ...
405!> \param status ...
406!> \return ...
407! **************************************************************************************************
408 FUNCTION gauxc_create_basisset(qs_kind_set, particle_set, status) RESULT(res)
409 TYPE(qs_kind_type), DIMENSION(:), INTENT(IN), &
410 POINTER :: qs_kind_set
411 TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particle_set
412 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
413 TYPE(cp_gauxc_basisset_type) :: res
414
415#ifdef __GAUXC
416 INTEGER :: iatom, ikind, iprim, iset, ishell, lval, &
417 nkind, npgf, nset, nshell, &
418 nshell_total, shell_index, natoms
419 REAL(c_double), DIMENSION(3) :: shell_origin
420 TYPE(atomic_kind_type), POINTER :: atomic_kind
421 TYPE(gauxc_shell_type), ALLOCATABLE, DIMENSION(:) :: shells
422 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_list
423 TYPE(gto_basis_set_type), POINTER :: gto_basis
424
425 nkind = SIZE(qs_kind_set)
426 natoms = SIZE(particle_set)
427
428 ALLOCATE (basis_set_list(nkind))
429 CALL basis_set_list_setup(basis_set_list, "ORB", qs_kind_set)
430
431 nshell_total = 0
432 DO iatom = 1, natoms
433 atomic_kind => particle_set(iatom)%atomic_kind
434 CALL get_atomic_kind(atomic_kind, kind_number=ikind)
435 gto_basis => basis_set_list(ikind)%gto_basis_set
436 cpassert(ASSOCIATED(gto_basis))
437 ! CALL write_gto_basis_set(gto_basis, 6, "–––––GAUXC-CREATE-BASISSET–––––")
438 nshell_total = nshell_total + sum(gto_basis%nshell)
439 END DO
440
441 ALLOCATE (shells(nshell_total))
442
443 shell_index = 0
444 res%max_l = -1
445 DO iatom = 1, natoms ! for each atom
446 atomic_kind => particle_set(iatom)%atomic_kind
447 CALL get_atomic_kind(atomic_kind, kind_number=ikind)
448 gto_basis => basis_set_list(ikind)%gto_basis_set
449 cpassert(ASSOCIATED(gto_basis))
450
451 shell_origin(1) = real(particle_set(iatom)%r(1), c_double)
452 shell_origin(2) = real(particle_set(iatom)%r(2), c_double)
453 shell_origin(3) = real(particle_set(iatom)%r(3), c_double)
454
455 nset = gto_basis%nset
456 cpassert(nset == SIZE(gto_basis%nshell))
457 DO iset = 1, nset ! for each shell group
458 nshell = gto_basis%nshell(iset)
459 npgf = gto_basis%npgf(iset) ! corresponds with nprim of gauxc
460
461 DO ishell = 1, gto_basis%nshell(iset) ! for each shell within the shell group
462 shell_index = shell_index + 1 ! global shell index, flattened over atoms and groups
463 lval = gto_basis%l(ishell, iset)
464 res%max_l = max(res%max_l, lval)
465 shells(shell_index)%l = int(lval, c_int32_t)
466 ! FIXME hardcoded true param
467 ! pure=1: spherical Gaussians; pure=0: cartesian Gaussians
468 shells(shell_index)%pure = .true._c_bool
469 shells(shell_index)%nprim = int(npgf, c_int32_t)
470 shells(shell_index)%origin = shell_origin
471
472 DO iprim = 1, npgf
473 shells(shell_index)%exponents(iprim) = &
474 REAL(gto_basis%zet(iprim, iset), c_double)
475 shells(shell_index)%coefficients(iprim) = &
476 REAL(gto_basis%norm_cgf(gto_basis%first_cgf(ishell, iset))* &
477 gto_basis%gcc(iprim, ishell, iset), c_double)
478 END DO
479 END DO
480 END DO
481 END DO
482
483 res%basis = gauxc_basisset_new_from_shells( &
484 status%status, &
485 shells, &
486 normalize=.false.)
487 gauxc_return_if_error(status)
488
489 DEALLOCATE (shells)
490 DEALLOCATE (basis_set_list)
491
492#else
493 mark_used(particle_set)
494 mark_used(qs_kind_set)
495 mark_used(res)
496 mark_used(status)
497 cpabort(no_gauxc_message)
498#endif
499 END FUNCTION gauxc_create_basisset
500
501! **************************************************************************************************
502!> \brief ...
503!> \param molecule ...
504!> \param basis ...
505!> \param grid_type ...
506!> \param radial_quadrature ...
507!> \param pruning_scheme ...
508!> \param lb_exec_space ...
509!> \param batch_size ...
510!> \param device_runtime_fill_fraction ...
511!> \param status ...
512!> \param mpi_comm optional communicator for a grid-local GauXC runtime
513!> \param force_new_runtime force creation of a grid-local GauXC runtime
514!> \param int_exec_space optional integrator execution space; a DEVICE
515!> integrator also requires a device runtime even when the load
516!> balancer stays on the host
517!> \return ...
518! **************************************************************************************************
519 FUNCTION gauxc_create_grid( &
520 molecule, &
521 basis, &
522 grid_type, &
523 radial_quadrature, &
524 pruning_scheme, &
525 lb_exec_space, &
526 batch_size, &
527 device_runtime_fill_fraction, &
528 status, &
529 mpi_comm, &
530 force_new_runtime, &
531 int_exec_space) RESULT(res)
532
533 TYPE(cp_gauxc_molecule_type), INTENT(IN) :: molecule
534 TYPE(cp_gauxc_basisset_type), INTENT(IN) :: basis
535 CHARACTER(LEN=*) :: grid_type, lb_exec_space, &
536 pruning_scheme, radial_quadrature
537 INTEGER :: batch_size
538 REAL(c_double), INTENT(IN) :: device_runtime_fill_fraction
539 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
540 INTEGER, INTENT(IN), OPTIONAL :: mpi_comm
541 LOGICAL, INTENT(IN), OPTIONAL :: force_new_runtime
542 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: int_exec_space
543 TYPE(cp_gauxc_grid_type) :: res
544
545#ifdef __GAUXC
546 INTEGER(c_int) :: grid_type_local, int_exec_space_local, &
547 int_exec_requested, &
548 lb_exec_space_local, &
549 pruning_scheme_local, radial_quad_local
550 LOGICAL :: force_new_runtime_local, &
551 use_device_runtime
552
553 grid_type_local = read_atomic_grid_size(grid_type)
554 radial_quad_local = read_radial_quad(radial_quadrature)
555 pruning_scheme_local = read_pruning_scheme(pruning_scheme)
556 lb_exec_space_local = read_execution_space(lb_exec_space)
557 int_exec_requested = read_execution_space("host")
558 IF (PRESENT(int_exec_space)) int_exec_requested = read_execution_space(int_exec_space)
559 use_device_runtime = (lb_exec_space_local == gauxc_executionspace%device) .OR. &
560 (int_exec_requested == gauxc_executionspace%device)
561 IF (use_device_runtime) THEN
562 int_exec_space_local = gauxc_executionspace%device
563 ELSE
564 int_exec_space_local = gauxc_executionspace%host
565 END IF
566#if defined(GAUXC_HAS_DEVICE) && defined(__LIBTORCH)
567 IF (use_device_runtime) THEN
568 IF (.NOT. torch_cuda_is_available() .OR. torch_cuda_device_count() <= 0) THEN
569 CALL cp_abort(__location__, &
570 "GPU execution was requested for GauXC, but no usable CUDA device was found. "// &
571 "Set GAUXC%USE_GPU HOST to force host-only execution.")
572 END IF
573 END IF
574#endif
575 force_new_runtime_local = .false.
576 IF (PRESENT(force_new_runtime)) force_new_runtime_local = force_new_runtime
577 res%owns_rt = .false.
578 res%uses_device_runtime = .false.
579
580 IF (use_device_runtime) THEN
581#ifdef GAUXC_HAS_DEVICE
582#if defined(GAUXC_HAS_MPI) && defined(__parallel)
583 IF (PRESENT(mpi_comm)) THEN
584 res%rt = gauxc_device_runtime_environment_new( &
585 status%status, mpi_comm, device_runtime_fill_fraction)
586 ELSE
587 res%rt = gauxc_device_runtime_environment_new( &
588 status%status, device_runtime_fill_fraction)
589 END IF
590#else
591 mark_used(mpi_comm)
592 res%rt = gauxc_device_runtime_environment_new( &
593 status%status, device_runtime_fill_fraction)
594#endif
595 gauxc_return_if_error(status)
596 res%owns_rt = .true.
597 res%uses_device_runtime = .true.
598#else
599 mark_used(device_runtime_fill_fraction)
600 cpabort("GauXC was built without device runtime support")
601#endif
602 ELSE
603#if defined(GAUXC_HAS_MPI) && defined(__parallel)
604 IF (PRESENT(mpi_comm)) THEN
605 ! Reuse the global runtime when the requested communicator matches
606 ! the communicator used during gauxc_init.
607 IF (force_new_runtime_local .OR. .NOT. rt_has_mpi_comm .OR. &
608 mpi_comm /= rt_mpi_comm) THEN
609 res%rt = gauxc_runtime_environment_new(status%status, mpi_comm)
610 gauxc_return_if_error(status)
611 res%owns_rt = .true.
612 END IF
613 END IF
614#else
615 mark_used(mpi_comm)
616 mark_used(force_new_runtime)
617#endif
618 END IF
619
620 res%grid = gauxc_molgrid_new_default( &
621 status%status, &
622 molecule%molecule, &
623 pruning_scheme_local, &
624 int(batch_size, c_int64_t), &
625 radial_quad_local, &
626 grid_type_local)
627 gauxc_return_if_error(status)
628
629 res%lbf = gauxc_load_balancer_factory_new( &
630 status%status, &
631 lb_exec_space_local)
632 gauxc_return_if_error(status)
633
634 IF (res%owns_rt) THEN
635 res%lb = gauxc_load_balancer_factory_get_instance( &
636 status%status, &
637 res%lbf, &
638 res%rt, &
639 molecule%molecule, &
640 res%grid, &
641 basis%basis)
642 ELSE
643 res%lb = gauxc_load_balancer_factory_get_instance( &
644 status%status, &
645 res%lbf, &
646 rt, &
647 molecule%molecule, &
648 res%grid, &
649 basis%basis)
650 END IF
651 gauxc_return_if_error(status)
652
653 res%mwf = gauxc_molecular_weights_factory_new( &
654 status%status, &
655 int_exec_space_local)
656 gauxc_return_if_error(status)
657
658 res%mw = gauxc_get_instance( &
659 status%status, &
660 res%mwf)
661 gauxc_return_if_error(status)
662
663 CALL gauxc_molecular_weights_modify_weights( &
664 status%status, &
665 res%mw, &
666 res%lb)
667 gauxc_return_if_error(status)
668
669#else
670 mark_used(basis)
671 mark_used(batch_size)
672 mark_used(device_runtime_fill_fraction)
673 mark_used(grid_type)
674 mark_used(int_exec_space)
675 mark_used(lb_exec_space)
676 mark_used(mpi_comm)
677 mark_used(force_new_runtime)
678 mark_used(int_exec_space)
679 mark_used(molecule)
680 mark_used(pruning_scheme)
681 mark_used(radial_quadrature)
682 mark_used(res)
683 mark_used(status)
684 cpabort(no_gauxc_message)
685#endif
686 END FUNCTION gauxc_create_grid
687
688! **************************************************************************************************
689!> \brief ...
690!> \param xc_functional_name ...
691!> \param grid ...
692!> \param int_exec_space ...
693!> \param lwd_kernel ...
694!> \param nspins ...
695!> \param status ...
696!> \return ...
697! **************************************************************************************************
698 FUNCTION gauxc_create_integrator( &
699 xc_functional_name, &
700 grid, &
701 int_exec_space, &
702 lwd_kernel, &
703 nspins, &
704 status) RESULT(res)
705
706 CHARACTER(LEN=*), INTENT(IN) :: xc_functional_name, int_exec_space, &
707 lwd_kernel
708 TYPE(cp_gauxc_grid_type), INTENT(IN) :: grid
709 INTEGER, INTENT(IN) :: nspins
710 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
711 TYPE(cp_gauxc_integrator_type) :: res
712
713#ifdef __GAUXC
714 INTEGER(c_int) :: int_exec_space_local
715 LOGICAL(c_bool) :: polarized
716
717 polarized = (nspins == 2)
718 res%func = gauxc_functional_from_string( &
719 status%status, &
720 xc_functional_name, &
721 polarized)
722 gauxc_return_if_error(status)
723
724 int_exec_space_local = read_execution_space(int_exec_space)
725 res%integrator = gauxc_integrator_new( &
726 status%status, &
727 res%func, &
728 grid%lb, &
729 int_exec_space_local, &
730 local_work_kernel_name=trim(lwd_kernel))
731 gauxc_return_if_error(status)
732
733#else
734 mark_used(grid)
735 mark_used(int_exec_space)
736 mark_used(lwd_kernel)
737 mark_used(nspins)
738 mark_used(res)
739 mark_used(status)
740 mark_used(xc_functional_name)
741 cpabort(no_gauxc_message)
742#endif
743 END FUNCTION gauxc_create_integrator
744
745! **************************************************************************************************
746!> \brief ...
747!> \param integrator ...
748!> \param density_scalar ...
749!> \param density_zeta ...
750!> \param nspins ...
751!> \param status ...
752!> \param model ...
753!> \return ...
754! **************************************************************************************************
755 FUNCTION gauxc_compute_xc( &
756 integrator, &
757 density_scalar, &
758 density_zeta, &
759 nspins, &
760 status, &
761 model) RESULT(res)
762
763 TYPE(cp_gauxc_integrator_type), INTENT(IN) :: integrator
764 REAL(c_double), DIMENSION(:, :), INTENT(IN) :: density_scalar
765 REAL(c_double), DIMENSION(:, :), INTENT(IN), &
766 OPTIONAL :: density_zeta
767 INTEGER, INTENT(IN) :: nspins
768 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
769 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: model
770 TYPE(cp_gauxc_xc_type) :: res
771
772#ifdef __GAUXC
773 CHARACTER(LEN=default_path_length) :: model_key
774 LOGICAL :: use_gauxc_model
775 REAL(c_double), ALLOCATABLE, DIMENSION(:, :) :: density_scalar_rks
776#ifdef GAUXC_HAS_ONEDFT
777 REAL(c_double), ALLOCATABLE, DIMENSION(:, :) :: density_zeta_zero
778#if defined (__HAS_IEEE_EXCEPTIONS)
779 LOGICAL, DIMENSION(5) :: ieee_halt
780#endif
781 INTEGER :: omp_max_threads_restore
782#endif
783
784 use_gauxc_model = .false.
785 IF (PRESENT(model)) THEN
786 model_key = adjustl(model)
787 CALL uppercase(model_key)
788 use_gauxc_model = (trim(model_key) /= "" .AND. trim(model_key) /= "NONE")
789 END IF
790
791 IF (.NOT. ALLOCATED(res%vxc_scalar)) THEN
792 ALLOCATE (res%vxc_scalar, mold=density_scalar)
793 ELSE
794 cpassert(all(shape(res%vxc_scalar) == shape(density_scalar)))
795 END IF
796 res%vxc_scalar = 0._dp
797
798 IF (use_gauxc_model) THEN
799#ifndef GAUXC_HAS_ONEDFT
800 cpabort("GauXC lacks Skala support")
801#else
802 ! Skala may change the OpenMP team size for later parallel regions.
803 ! Restore max threads only; omp_get_num_threads() is 1 here.
804 omp_max_threads_restore = omp_get_max_threads()
805#if defined (__HAS_IEEE_EXCEPTIONS)
806 CALL ieee_get_halting_mode(ieee_all, ieee_halt)
807 CALL ieee_set_halting_mode(ieee_all, .false.)
808#endif
809 IF (.NOT. ALLOCATED(res%vxc_zeta)) THEN
810 ALLOCATE (res%vxc_zeta, mold=density_scalar)
811 ELSE
812 cpassert(all(shape(res%vxc_zeta) == shape(density_scalar)))
813 END IF
814 res%vxc_zeta = 0._dp
815
816 IF (nspins == 1) THEN
817 ALLOCATE (density_zeta_zero, mold=density_scalar)
818 density_zeta_zero = 0._dp
819 CALL gauxc_integrator_eval_exc_vxc_onedft_uks( &
820 status%status, &
821 integrator%integrator, &
822 density_scalar, &
823 density_zeta_zero, &
824 trim(model), &
825 res%exc, &
826 res%vxc_scalar, &
827 res%vxc_zeta)
828 DEALLOCATE (density_zeta_zero)
829 ELSE
830 cpassert(PRESENT(density_zeta))
831 CALL gauxc_integrator_eval_exc_vxc_onedft_uks( &
832 status%status, &
833 integrator%integrator, &
834 density_scalar, &
835 density_zeta, &
836 trim(model), &
837 res%exc, &
838 res%vxc_scalar, &
839 res%vxc_zeta)
840 END IF
841#if defined (__HAS_IEEE_EXCEPTIONS)
842 CALL ieee_set_halting_mode(ieee_all, ieee_halt)
843#endif
844 CALL omp_set_num_threads(omp_max_threads_restore)
845 gauxc_return_if_error(status)
846 RETURN
847#endif
848 END IF
849
850 IF (nspins == 1) THEN
851 ! xmat factor 2 is applied by both CP2K and GauXC
852 ! "unapply" it here to even things back out.
853 ! This is NOT necessary in the Skala branch.
854 ALLOCATE (density_scalar_rks, mold=density_scalar)
855 density_scalar_rks(:, :) = 0.5_dp*density_scalar
856 CALL gauxc_integrator_eval_exc_vxc_rks( &
857 status%status, &
858 integrator%integrator, &
859 density_scalar_rks, &
860 res%exc, &
861 res%vxc_scalar)
862 DEALLOCATE (density_scalar_rks)
863 ELSE
864 cpassert(PRESENT(density_zeta))
865
866 IF (.NOT. ALLOCATED(res%vxc_zeta)) THEN
867 ALLOCATE (res%vxc_zeta, mold=density_zeta)
868 ELSE
869 cpassert(all(shape(res%vxc_zeta) == shape(density_scalar)))
870 END IF
871 res%vxc_zeta = 0._dp
872
873 CALL gauxc_integrator_eval_exc_vxc_uks( &
874 status%status, &
875 integrator%integrator, &
876 density_scalar, &
877 density_zeta, &
878 res%exc, &
879 res%vxc_scalar, &
880 res%vxc_zeta)
881 END IF
882 gauxc_return_if_error(status)
883
884#else
885 mark_used(integrator)
886 mark_used(density_scalar)
887 mark_used(density_zeta)
888 mark_used(nspins)
889 mark_used(status)
890 mark_used(model)
891 cpabort(no_gauxc_message)
892#endif
893 END FUNCTION gauxc_compute_xc
894
895! **************************************************************************************************
896!> \brief ...
897!> \param integrator ...
898!> \param density_scalar ...
899!> \param density_zeta ...
900!> \param nspins ...
901!> \param natom ...
902!> \param status ...
903!> \param model ...
904!> \return ...
905! **************************************************************************************************
906 FUNCTION gauxc_compute_xc_gradient( &
907 integrator, &
908 density_scalar, &
909 density_zeta, &
910 nspins, &
911 natom, &
912 status, &
913 model) RESULT(res)
914
915 TYPE(cp_gauxc_integrator_type), INTENT(IN) :: integrator
916 REAL(c_double), DIMENSION(:, :), INTENT(IN) :: density_scalar
917 REAL(c_double), DIMENSION(:, :), INTENT(IN), &
918 OPTIONAL :: density_zeta
919 INTEGER, INTENT(IN) :: nspins, natom
920 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
921 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: model
922 TYPE(cp_gauxc_xc_gradient_type) :: res
923
924#ifdef __GAUXC
925 CHARACTER(LEN=default_path_length) :: model_key
926 LOGICAL :: use_gauxc_model
927 REAL(c_double), ALLOCATABLE, DIMENSION(:, :) :: density_scalar_rks
928#ifdef GAUXC_HAS_ONEDFT
929 REAL(c_double), ALLOCATABLE, DIMENSION(:, :) :: density_zeta_zero
930#if defined (__HAS_IEEE_EXCEPTIONS)
931 LOGICAL, DIMENSION(5) :: ieee_halt
932#endif
933 INTEGER :: omp_max_threads_restore
934#endif
935
936 ALLOCATE (res%exc_grad(3*natom))
937 res%exc_grad = 0._dp
938
939 use_gauxc_model = .false.
940 IF (PRESENT(model)) THEN
941 model_key = adjustl(model)
942 CALL uppercase(model_key)
943 use_gauxc_model = (trim(model_key) /= "" .AND. trim(model_key) /= "NONE")
944 END IF
945
946 IF (use_gauxc_model) THEN
947#ifndef GAUXC_HAS_ONEDFT
948 cpabort("GauXC lacks Skala support")
949#else
950 ! Skala may change the OpenMP team size for later parallel regions.
951 ! Restore max threads only; omp_get_num_threads() is 1 here.
952 omp_max_threads_restore = omp_get_max_threads()
953#if defined (__HAS_IEEE_EXCEPTIONS)
954 CALL ieee_get_halting_mode(ieee_all, ieee_halt)
955 CALL ieee_set_halting_mode(ieee_all, .false.)
956#endif
957 IF (nspins == 1) THEN
958 ALLOCATE (density_zeta_zero, mold=density_scalar)
959 density_zeta_zero = 0._dp
960 CALL gauxc_integrator_eval_exc_grad_onedft_uks( &
961 status%status, &
962 integrator%integrator, &
963 density_scalar, &
964 density_zeta_zero, &
965 trim(model), &
966 res%exc_grad)
967 DEALLOCATE (density_zeta_zero)
968 ELSE
969 cpassert(PRESENT(density_zeta))
970 CALL gauxc_integrator_eval_exc_grad_onedft_uks( &
971 status%status, &
972 integrator%integrator, &
973 density_scalar, &
974 density_zeta, &
975 trim(model), &
976 res%exc_grad)
977 END IF
978#if defined (__HAS_IEEE_EXCEPTIONS)
979 CALL ieee_set_halting_mode(ieee_all, ieee_halt)
980#endif
981 CALL omp_set_num_threads(omp_max_threads_restore)
982 gauxc_return_if_error(status)
983 RETURN
984#endif
985 END IF
986
987 IF (nspins == 1) THEN
988 ALLOCATE (density_scalar_rks, mold=density_scalar)
989 density_scalar_rks(:, :) = 0.5_dp*density_scalar
990 CALL gauxc_integrator_eval_exc_grad_rks( &
991 status%status, &
992 integrator%integrator, &
993 density_scalar_rks, &
994 res%exc_grad)
995 DEALLOCATE (density_scalar_rks)
996 ELSE
997 cpassert(PRESENT(density_zeta))
998 CALL gauxc_integrator_eval_exc_grad_uks( &
999 status%status, &
1000 integrator%integrator, &
1001 density_scalar, &
1002 density_zeta, &
1003 res%exc_grad)
1004 END IF
1005 gauxc_return_if_error(status)
1006
1007#else
1008 mark_used(density_scalar)
1009 mark_used(density_zeta)
1010 mark_used(res)
1011 mark_used(integrator)
1012 mark_used(model)
1013 mark_used(natom)
1014 mark_used(nspins)
1015 mark_used(status)
1016 cpabort(no_gauxc_message)
1017#endif
1018 END FUNCTION gauxc_compute_xc_gradient
1019
1020! **************************************************************************************************
1021!> \brief ...
1022!> \param molecule ...
1023!> \param status ...
1024! **************************************************************************************************
1025 SUBROUTINE gauxc_destroy_molecule(molecule, status)
1026 TYPE(cp_gauxc_molecule_type), INTENT(INOUT) :: molecule
1027 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
1028
1029#ifdef __GAUXC
1030 CALL gauxc_delete(status%status, molecule%molecule)
1031 gauxc_return_if_error(status)
1032#else
1033 mark_used(molecule)
1034 mark_used(status)
1035 cpabort(no_gauxc_message)
1036#endif
1037 END SUBROUTINE gauxc_destroy_molecule
1038
1039! **************************************************************************************************
1040!> \brief ...
1041!> \param basis ...
1042!> \param status ...
1043! **************************************************************************************************
1044 SUBROUTINE gauxc_destroy_basisset(basis, status)
1045 TYPE(cp_gauxc_basisset_type), INTENT(INOUT) :: basis
1046 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
1047
1048#ifdef __GAUXC
1049 CALL gauxc_delete(status%status, basis%basis)
1050 gauxc_return_if_error(status)
1051#else
1052 mark_used(basis)
1053 mark_used(status)
1054 cpabort(no_gauxc_message)
1055#endif
1056 END SUBROUTINE gauxc_destroy_basisset
1057
1058! **************************************************************************************************
1059!> \brief ...
1060!> \param grid_result ...
1061!> \param status ...
1062! **************************************************************************************************
1063 SUBROUTINE gauxc_destroy_grid(grid_result, status)
1064 TYPE(cp_gauxc_grid_type), INTENT(INOUT) :: grid_result
1065 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
1066
1067#ifdef __GAUXC
1068 CALL gauxc_delete(status%status, grid_result%mw)
1069 gauxc_return_if_error(status)
1070 CALL gauxc_delete(status%status, grid_result%mwf)
1071 gauxc_return_if_error(status)
1072 CALL gauxc_delete(status%status, grid_result%lb)
1073 gauxc_return_if_error(status)
1074 CALL gauxc_delete(status%status, grid_result%lbf)
1075 gauxc_return_if_error(status)
1076 CALL gauxc_delete(status%status, grid_result%grid)
1077 gauxc_return_if_error(status)
1078 IF (grid_result%owns_rt) THEN
1079 CALL gauxc_runtime_environment_delete(status%status, grid_result%rt)
1080 gauxc_return_if_error(status)
1081 grid_result%owns_rt = .false.
1082 END IF
1083#else
1084 mark_used(grid_result)
1085 mark_used(status)
1086 cpabort(no_gauxc_message)
1087#endif
1088 END SUBROUTINE gauxc_destroy_grid
1089
1090! **************************************************************************************************
1091!> \brief ...
1092!> \param integrator_result ...
1093!> \param status ...
1094! **************************************************************************************************
1095 SUBROUTINE gauxc_destroy_integrator(integrator_result, status)
1096 TYPE(cp_gauxc_integrator_type), INTENT(INOUT) :: integrator_result
1097 TYPE(cp_gauxc_status_type), INTENT(OUT) :: status
1098
1099#ifdef __GAUXC
1100 CALL gauxc_delete(status%status, integrator_result%integrator)
1101 gauxc_return_if_error(status)
1102 CALL gauxc_delete(status%status, integrator_result%func)
1103 gauxc_return_if_error(status)
1104#else
1105 mark_used(integrator_result)
1106 mark_used(status)
1107 cpabort(no_gauxc_message)
1108#endif
1109 END SUBROUTINE gauxc_destroy_integrator
1110
1111! **************************************************************************************************
1112!> \brief Checks gauxc status and prints error message before aborting
1113!> \param status the gauxc status to check
1114! **************************************************************************************************
1115 SUBROUTINE gauxc_check_status(status)
1116 TYPE(cp_gauxc_status_type), INTENT(IN) :: status
1117
1118#ifdef __GAUXC
1119 IF (status%status%code /= 0) THEN
1120 CALL print_gauxc_status_message(status)
1121 cpabort("GauXC returned with non-zero status code")
1122 END IF
1123#else
1124 mark_used(status)
1125#endif
1126 END SUBROUTINE gauxc_check_status
1127
1128!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1129! From here on, it's private helpers !
1130!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1131
1132#ifdef __GAUXC
1133
1134! **************************************************************************************************
1135!> \brief ...
1136!> \param spec ...
1137!> \return ...
1138! **************************************************************************************************
1139 PURE FUNCTION read_execution_space(spec) RESULT(val)
1140 CHARACTER(LEN=*), INTENT(IN) :: spec
1141 INTEGER(c_int) :: val
1142
1143 CHARACTER(LEN=LEN(spec)) :: spec_upper
1144
1145 spec_upper = spec
1146 CALL uppercase(spec_upper)
1147
1148 SELECT CASE (spec_upper)
1149 CASE ("HOST")
1150 val = gauxc_executionspace%host
1151 CASE ("DEVICE")
1152 val = gauxc_executionspace%device
1153 CASE DEFAULT
1154 val = gauxc_executionspace%host
1155 END SELECT
1156 END FUNCTION read_execution_space
1157
1158! **************************************************************************************************
1159!> \brief ...
1160!> \param spec ...
1161!> \return ...
1162! **************************************************************************************************
1163 PURE FUNCTION read_atomic_grid_size(spec) RESULT(val)
1164 CHARACTER(LEN=*), INTENT(IN) :: spec
1165 INTEGER(c_int) :: val
1166
1167 CHARACTER(LEN=LEN(spec)) :: spec_upper
1168
1169 spec_upper = spec
1170 CALL uppercase(spec_upper)
1171
1172 SELECT CASE (spec_upper)
1173 CASE ("FINE")
1174 val = gauxc_atomicgridsizedefault%finegrid
1175 CASE ("ULTRAFINE")
1176 val = gauxc_atomicgridsizedefault%ultrafinegrid
1177 CASE ("SUPERFINE")
1178 val = gauxc_atomicgridsizedefault%superfinegrid
1179 CASE ("GM3")
1180 val = gauxc_atomicgridsizedefault%gm3
1181 CASE ("GM5")
1182 val = gauxc_atomicgridsizedefault%gm5
1183 CASE DEFAULT
1184 val = gauxc_atomicgridsizedefault%finegrid
1185 END SELECT
1186 END FUNCTION read_atomic_grid_size
1187
1188! **************************************************************************************************
1189!> \brief ...
1190!> \param spec ...
1191!> \return ...
1192! **************************************************************************************************
1193 PURE FUNCTION read_radial_quad(spec) RESULT(val)
1194 CHARACTER(LEN=*), INTENT(IN) :: spec
1195 INTEGER(c_int) :: val
1196
1197 CHARACTER(LEN=LEN(spec)) :: spec_upper
1198
1199 spec_upper = spec
1200 CALL uppercase(spec_upper)
1201
1202 SELECT CASE (spec_upper)
1203 CASE ("BECKE")
1204 val = gauxc_radialquad%becke
1205 CASE ("MURAKNOWLES")
1206 val = gauxc_radialquad%mura_knowles
1207 CASE ("TREUTLERAHLRICHS")
1208 val = gauxc_radialquad%treutler_ahlrichs
1209 CASE ("MURRAYHANDYLAMING")
1210 val = gauxc_radialquad%murray_handy_laming
1211 CASE DEFAULT
1212 val = gauxc_radialquad%mura_knowles
1213 END SELECT
1214 END FUNCTION read_radial_quad
1215
1216! **************************************************************************************************
1217!> \brief ...
1218!> \param spec ...
1219!> \return ...
1220! **************************************************************************************************
1221 PURE FUNCTION read_pruning_scheme(spec) RESULT(val)
1222 CHARACTER(LEN=*), INTENT(IN) :: spec
1223 INTEGER(c_int) :: val
1224
1225 CHARACTER(LEN=LEN(spec)) :: spec_upper
1226
1227 spec_upper = spec
1228 CALL uppercase(spec_upper)
1229
1230 SELECT CASE (spec_upper)
1231 CASE ("UNPRUNED")
1232 val = gauxc_pruningscheme%unpruned
1233 CASE ("ROBUST")
1234 val = gauxc_pruningscheme%robust
1235 CASE ("TREUTLER")
1236 val = gauxc_pruningscheme%treutler
1237 CASE DEFAULT
1238 val = gauxc_pruningscheme%robust
1239 END SELECT
1240 END FUNCTION read_pruning_scheme
1241
1242#endif
1243
1244! **************************************************************************************************
1245!> \brief Write molecule data to HDF5 file for debugging
1246!> \param molecule ...
1247!> \param output_path ...
1248!> \param filename ...
1249!> \param dataset ...
1250!> \param status ...
1251! **************************************************************************************************
1252 SUBROUTINE gauxc_write_molecule_hdf5(molecule, output_path, filename, dataset, status)
1253 TYPE(cp_gauxc_molecule_type), INTENT(IN) :: molecule
1254 CHARACTER(LEN=*), INTENT(IN) :: output_path, filename, dataset
1255 TYPE(cp_gauxc_status_type), INTENT(INOUT) :: status
1256
1257#if defined(__GAUXC) && defined(GAUXC_HAS_HDF5)
1258 CHARACTER(LEN=default_path_length) :: full_path
1259
1260 full_path = trim(output_path)//"/"//trim(filename)
1261 CALL gauxc_write_hdf5_record(status%status, molecule%molecule, full_path, dataset)
1262#else
1263 mark_used(molecule)
1264 mark_used(output_path)
1265 mark_used(filename)
1266 mark_used(dataset)
1267 mark_used(status)
1268 cpabort("GauXC HDF5 output requires GauXC to be built with HDF5 support.")
1269#endif
1270 END SUBROUTINE gauxc_write_molecule_hdf5
1271
1272! **************************************************************************************************
1273!> \brief Write basis set data to HDF5 file for debugging
1274!> \param basis ...
1275!> \param output_path ...
1276!> \param filename ...
1277!> \param dataset ...
1278!> \param status ...
1279! **************************************************************************************************
1280 SUBROUTINE gauxc_write_basisset_hdf5(basis, output_path, filename, dataset, status)
1281 TYPE(cp_gauxc_basisset_type), INTENT(IN) :: basis
1282 CHARACTER(LEN=*), INTENT(IN) :: output_path, filename, dataset
1283 TYPE(cp_gauxc_status_type), INTENT(INOUT) :: status
1284
1285#if defined(__GAUXC) && defined(GAUXC_HAS_HDF5)
1286 CHARACTER(LEN=default_path_length) :: full_path
1287
1288 full_path = trim(output_path)//"/"//trim(filename)
1289 CALL gauxc_write_hdf5_record(status%status, basis%basis, full_path, dataset)
1290#else
1291 mark_used(basis)
1292 mark_used(output_path)
1293 mark_used(filename)
1294 mark_used(dataset)
1295 mark_used(status)
1296 cpabort("GauXC HDF5 output requires GauXC to be built with HDF5 support.")
1297#endif
1298 END SUBROUTINE gauxc_write_basisset_hdf5
1299
1300END MODULE xc_gauxc_interface
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public write_gto_basis_set(gto_basis_set, output_unit, header)
Write a Gaussian-type orbital (GTO) basis set data set to the output unit.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
Provides integrator routines (velocity verlet) for all the ensemble types.
Definition integrator.F:26
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Define the data structure for the particle information.
Periodic Table related data definitions.
subroutine, public get_ptable_info(symbol, number, amass, ielement, covalent_radius, metallic_radius, vdw_radius, found)
Pass information about the kind given the element symbol.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public bohr
Definition physcon.F:147
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
integer function, public torch_cuda_device_count()
Return the number of CUDA devices visible to Torch.
Definition torch_api.F:2352
logical function, public torch_cuda_is_available()
Returns true iff the Torch CUDA backend is available.
Definition torch_api.F:2331
Provides all information about an atomic kind.
Provides all information about a quickstep kind.
subroutine print_gauxc_status_message(status)
...