LCOV - code coverage report
Current view: top level - src - input_cp2k_global.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1be8651) Lines: 100.0 % 244 244
Test Date: 2026-11-24 01:22:08 Functions: 100.0 % 4 4

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief builds the global input section for cp2k
      10              : !> \par History
      11              : !>      06.2004 created [fawzi]
      12              : !>      03.2014 moved to separate file [Ole Schuett]
      13              : !>      10.2016 update seed input [Matthias Krack]
      14              : !> \author fawzi
      15              : ! **************************************************************************************************
      16              : MODULE input_cp2k_global
      17              :    USE bibliography,                    ONLY: Ceriotti2014,&
      18              :                                               Frigo2005,&
      19              :                                               Schonherr2014
      20              :    USE cp_blacs_env,                    ONLY: BLACS_GRID_COL,&
      21              :                                               BLACS_GRID_ROW,&
      22              :                                               BLACS_GRID_SQUARE
      23              :    USE cp_cfm_elpa,                     ONLY: elpa_c_kernel_descriptions,&
      24              :                                               elpa_c_kernel_ids,&
      25              :                                               elpa_c_kernel_names
      26              :    USE cp_dbcsr_cp2k_link,              ONLY: create_dbcsr_section
      27              :    USE cp_fm_cholesky,                  ONLY: FM_CHOLESKY_TYPE_DEFAULT,&
      28              :                                               FM_CHOLESKY_TYPE_DLAF,&
      29              :                                               FM_CHOLESKY_TYPE_SCALAPACK
      30              :    USE cp_fm_diag,                      ONLY: FM_DIAG_TYPE_CUSOLVER,&
      31              :                                               FM_DIAG_TYPE_DEFAULT,&
      32              :                                               FM_DIAG_TYPE_DLAF,&
      33              :                                               FM_DIAG_TYPE_ELPA,&
      34              :                                               FM_DIAG_TYPE_SCALAPACK
      35              :    USE cp_fm_elpa,                      ONLY: elpa_kernel_descriptions,&
      36              :                                               elpa_kernel_ids,&
      37              :                                               elpa_kernel_names,&
      38              :                                               elpa_one_stage,&
      39              :                                               elpa_print,&
      40              :                                               elpa_qr
      41              :    USE cp_fm_struct,                    ONLY: cp_fm_struct_get_ncol_block,&
      42              :                                               cp_fm_struct_get_nrow_block
      43              :    USE cp_iter_types,                   ONLY: iter_notice,&
      44              :                                               iter_silent,&
      45              :                                               iter_stack
      46              :    USE cp_output_handling,              ONLY: add_last_numeric,&
      47              :                                               cp_print_key_section_create,&
      48              :                                               debug_print_level,&
      49              :                                               high_print_level,&
      50              :                                               low_print_level,&
      51              :                                               medium_print_level,&
      52              :                                               silent_print_level
      53              :    USE fft_api,                         ONLY: FFT_LIBRARY_BACKEND_DEFAULT,&
      54              :                                               FFT_LIBRARY_BACKEND_FFTW,&
      55              :                                               FFT_LIBRARY_BACKEND_GPU,&
      56              :                                               FFT_LIBRARY_FFTW_MODE_ESTIMATE,&
      57              :                                               FFT_LIBRARY_FFTW_MODE_EXHAUSTIVE,&
      58              :                                               FFT_LIBRARY_FFTW_MODE_MEASURE,&
      59              :                                               FFT_LIBRARY_FFTW_MODE_PATIENT
      60              :    USE grid_api,                        ONLY: GRID_BACKEND_AUTO,&
      61              :                                               GRID_BACKEND_CPU,&
      62              :                                               GRID_BACKEND_DGEMM,&
      63              :                                               GRID_BACKEND_GPU,&
      64              :                                               GRID_BACKEND_REF
      65              :    USE input_constants,                 ONLY: &
      66              :         bsse_run, callgraph_all, callgraph_master, callgraph_none, cell_opt_run, debug_run, &
      67              :         do_atom, do_band, do_cosma, do_cp2k, do_dgemm_blas, do_dgemm_spla, do_farming, &
      68              :         do_opt_basis, do_optimize_input, do_scalapack, do_swarm, do_tamc, do_test, do_tree_mc, &
      69              :         do_tree_mc_ana, driver_run, ehrenfest, energy_force_run, energy_run, gaussian, &
      70              :         geo_opt_run, linear_response_run, mimic_run, mol_dyn_run, mon_car_run, mtlr_run, negf_run, &
      71              :         none_run, pint_run, real_time_propagation, tree_mc_run, vib_anal
      72              :    USE input_keyword_types,             ONLY: keyword_create,&
      73              :                                               keyword_release,&
      74              :                                               keyword_type
      75              :    USE input_section_types,             ONLY: section_add_keyword,&
      76              :                                               section_add_subsection,&
      77              :                                               section_create,&
      78              :                                               section_release,&
      79              :                                               section_type
      80              :    USE input_val_types,                 ONLY: char_t,&
      81              :                                               integer_t,&
      82              :                                               logical_t
      83              :    USE integral_library_types,          ONLY: default_coulomb_library,&
      84              :                                               library_libint,&
      85              :                                               library_native
      86              :    USE kinds,                           ONLY: dp
      87              :    USE string_utilities,                ONLY: s2a
      88              :    USE timings,                         ONLY: default_timings_level
      89              : #include "./base/base_uses.f90"
      90              : 
      91              :    IMPLICIT NONE
      92              :    PRIVATE
      93              : 
      94              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      95              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_global'
      96              : 
      97              :    PUBLIC :: create_global_section
      98              : 
      99              : CONTAINS
     100              : 
     101              : ! **************************************************************************************************
     102              : !> \brief section to hold global settings for the whole program
     103              : !> \param section the section to be created
     104              : !> \author fawzi
     105              : ! **************************************************************************************************
     106         7631 :    SUBROUTINE create_global_section(section)
     107              :       TYPE(section_type), POINTER                        :: section
     108              : 
     109              :       INTEGER                                            :: default_dgemm
     110              :       TYPE(keyword_type), POINTER                        :: keyword
     111              :       TYPE(section_type), POINTER                        :: print_key, sub_section
     112              : 
     113         7631 :       NULLIFY (print_key)
     114         7631 :       CPASSERT(.NOT. ASSOCIATED(section))
     115              :       CALL section_create(section, __LOCATION__, name="GLOBAL", &
     116              :                           description="Section with general information on which kind "// &
     117              :                           "of simulation to perform and parameters for the whole PROGRAM", &
     118         7631 :                           n_keywords=7, n_subsections=1, repeats=.FALSE.)
     119              : 
     120         7631 :       NULLIFY (keyword)
     121              :       CALL keyword_create(keyword, __LOCATION__, name="BLACS_GRID", &
     122              :                           description="how to distribute the processors on the 2d grid needed "// &
     123              :                           "by BLACS (and thus SCALAPACK)", usage="BLACS_GRID SQUARE", &
     124              :                           default_i_val=BLACS_GRID_SQUARE, enum_c_vals=s2a("SQUARE", "ROW", "COLUMN"), &
     125              :                           enum_desc=s2a("Distribution by matrix blocks", "Distribution by matrix rows", &
     126              :                                         "Distribution by matrix columns"), &
     127         7631 :                           enum_i_vals=[BLACS_GRID_SQUARE, BLACS_GRID_ROW, BLACS_GRID_COL])
     128         7631 :       CALL section_add_keyword(section, keyword)
     129         7631 :       CALL keyword_release(keyword)
     130              : 
     131              :       CALL keyword_create(keyword, __LOCATION__, name="BLACS_REPEATABLE", &
     132              :                           description="Use a topology for BLACS collectives that is guaranteed to be repeatable "// &
     133              :                           "on homogeneous architectures", &
     134              :                           usage="BLACS_REPEATABLE", &
     135         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     136         7631 :       CALL section_add_keyword(section, keyword)
     137         7631 :       CALL keyword_release(keyword)
     138              : 
     139              :       CALL keyword_create(keyword, __LOCATION__, name="PREFERRED_DIAG_LIBRARY", &
     140              :                           description="Specifies the diagonalization library to be used. If not available, "// &
     141              :                           "the ScaLAPACK library is used. Complex (k-point) matrices use ELPA only when it is "// &
     142              :                           "requested explicitly", &
     143              :                           usage="PREFERRED_DIAG_LIBRARY ELPA", &
     144              :                           enum_i_vals=[FM_DIAG_TYPE_ELPA, &
     145              :                                        FM_DIAG_TYPE_SCALAPACK, &
     146              :                                        FM_DIAG_TYPE_SCALAPACK, &
     147              :                                        FM_DIAG_TYPE_CUSOLVER, &
     148              :                                        FM_DIAG_TYPE_DLAF], &
     149              :                           enum_c_vals=s2a("ELPA", "ScaLAPACK", "SL", "CUSOLVER", "DLAF"), &
     150              :                           enum_desc=s2a("ELPA library", &
     151              :                                         "ScaLAPACK library", &
     152              :                                         "ScaLAPACK library (shorthand)", &
     153              :                                         "cuSOLVER (CUDA GPU library)", &
     154              :                                         "DLA-Future (CUDA/HIP GPU library)"), &
     155         7631 :                           default_i_val=FM_DIAG_TYPE_DEFAULT)
     156         7631 :       CALL section_add_keyword(section, keyword)
     157         7631 :       CALL keyword_release(keyword)
     158              : 
     159              :       CALL keyword_create(keyword, __LOCATION__, name="DIRECT_GENERALIZED_DIAGONALIZATION", &
     160              :                           description="Request direct generalized eigenvalue problem diagonalization "// &
     161              :                           "without a CP2K-side Cholesky reduction in supported dense matrix paths. "// &
     162              :                           "The eigensolver is still selected by PREFERRED_DIAG_LIBRARY.", &
     163              :                           usage="DIRECT_GENERALIZED_DIAGONALIZATION", &
     164         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     165         7631 :       CALL section_add_keyword(section, keyword)
     166         7631 :       CALL keyword_release(keyword)
     167              : 
     168              :       CALL keyword_create(keyword, __LOCATION__, name="PREFERRED_CHOLESKY_LIBRARY", &
     169              :                           description="Specifies Cholesky decomposition library to be used. If not available, "// &
     170              :                           "the ScaLAPACK library is used", &
     171              :                           usage="PREFERRED_CHOLESKY_LIBRARY DLAF", &
     172              :                           enum_i_vals=[FM_CHOLESKY_TYPE_SCALAPACK, &
     173              :                                        FM_CHOLESKY_TYPE_SCALAPACK, &
     174              :                                        FM_CHOLESKY_TYPE_DLAF], &
     175              :                           enum_c_vals=s2a("ScaLAPACK", "SL", "DLAF"), &
     176              :                           enum_desc=s2a("ScaLAPACK library", &
     177              :                                         "ScaLAPACK library (shorthand)", &
     178              :                                         "DLA-Future (CUDA/HIP GPU library)"), &
     179         7631 :                           default_i_val=FM_CHOLESKY_TYPE_DEFAULT)
     180         7631 :       CALL section_add_keyword(section, keyword)
     181         7631 :       CALL keyword_release(keyword)
     182              : 
     183              : #if defined(__SPLA) && defined(__OFFLOAD_GEMM)
     184              :       default_dgemm = do_dgemm_spla
     185              : #else
     186         7631 :       default_dgemm = do_dgemm_blas
     187              : #endif
     188              :       CALL keyword_create(keyword, __LOCATION__, name="PREFERRED_DGEMM_LIBRARY", &
     189              :                           description="Specifies the library for supported local real and complex matrix multiplications, "// &
     190              :                           "including wavefunction correlation and k-point calculations. SPLA enables GPU acceleration "// &
     191              :                           "when available; otherwise BLAS is used. This does not affect distributed matrix multiplications "// &
     192              :                           "(see keyword FM%TYPE_OF_MATRIX_MULTIPLICATION).", &
     193              :                           usage="PREFERRED_DGEMM_LIBRARY SPLA", &
     194              :                           default_i_val=default_dgemm, &
     195              :                           enum_i_vals=[do_dgemm_spla, do_dgemm_blas], &
     196              :                           enum_c_vals=s2a("SPLA", "BLAS"), &
     197         7631 :                           enum_desc=s2a("SPLA library", "BLAS library"))
     198         7631 :       CALL section_add_keyword(section, keyword)
     199         7631 :       CALL keyword_release(keyword)
     200              : 
     201              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_CHECK_DIAG", &
     202              :                           description="Check that the orthonormality of the eigenvectors after a diagonalization "// &
     203              :                           "fulfills the specified numerical accuracy. A negative threshold value disables the check.", &
     204              :                           usage="EPS_CHECK_DIAG 1.0E-14", &
     205         7631 :                           default_r_val=-1.0_dp)
     206         7631 :       CALL section_add_keyword(section, keyword)
     207         7631 :       CALL keyword_release(keyword)
     208              : 
     209              :       CALL keyword_create(keyword, __LOCATION__, name="ELPA_KERNEL", &
     210              :                           description="Specifies the kernel to be used when ELPA is in use for real "// &
     211              :                           "symmetric matrices", &
     212              :                           default_i_val=elpa_kernel_ids(1), &
     213              :                           enum_i_vals=elpa_kernel_ids, &
     214              :                           enum_c_vals=elpa_kernel_names, &
     215         7631 :                           enum_desc=elpa_kernel_descriptions)
     216         7631 :       CALL section_add_keyword(section, keyword)
     217         7631 :       CALL keyword_release(keyword)
     218              : 
     219              :       CALL keyword_create(keyword, __LOCATION__, name="ELPA_COMPLEX_KERNEL", &
     220              :                           description="Specifies the kernel to be used when ELPA is in use for complex "// &
     221              :                           "Hermitian matrices (k-points)", &
     222              :                           default_i_val=elpa_c_kernel_ids(1), &
     223              :                           enum_i_vals=elpa_c_kernel_ids, &
     224              :                           enum_c_vals=elpa_c_kernel_names, &
     225         7631 :                           enum_desc=elpa_c_kernel_descriptions)
     226         7631 :       CALL section_add_keyword(section, keyword)
     227         7631 :       CALL keyword_release(keyword)
     228              : 
     229              :       CALL keyword_create(keyword, __LOCATION__, name="ELPA_NEIGVEC_MIN", &
     230              :                           description="Minimum number of eigenvectors for the use of the eigensolver from "// &
     231              :                           "the ELPA library. The eigensolver from the ScaLAPACK library is used as fallback "// &
     232              :                           "for all smaller cases", &
     233              :                           usage="ELPA_NEIGVEC_MIN 32", &
     234         7631 :                           default_i_val=MIN(cp_fm_struct_get_nrow_block(), cp_fm_struct_get_ncol_block()))
     235         7631 :       CALL section_add_keyword(section, keyword)
     236         7631 :       CALL keyword_release(keyword)
     237              : 
     238              :       CALL keyword_create(keyword, __LOCATION__, name="ELPA_QR", &
     239              :                           description="For ELPA, enable a blocked QR step when reducing the input matrix "// &
     240              :                           "to banded form before diagonalization. Requires ELPA version 201505 or newer and "// &
     241              :                           "is automatically deactivated otherwise. QR is activated only when the matrix size "// &
     242              :                           "is suitable. Keyword ELPA_PRINT helps identify suitable cases. Can accelerate "// &
     243              :                           "diagonalization for suitable matrices.", &
     244              :                           usage="ELPA_QR", &
     245         7631 :                           default_l_val=elpa_qr, lone_keyword_l_val=.TRUE.)
     246         7631 :       CALL section_add_keyword(section, keyword)
     247         7631 :       CALL keyword_release(keyword)
     248              : 
     249              :       CALL keyword_create(keyword, __LOCATION__, name="ELPA_ONE_STAGE", &
     250              :                           description="For ELPA, enable the one-stage solver (instead of the two-stage solver). "// &
     251              :                           "Please note, ELPA_QR and ELPA_KERNEL settings may be ignored.", &
     252              :                           usage="ELPA_ONE_STAGE", &
     253         7631 :                           default_l_val=elpa_one_stage, lone_keyword_l_val=.TRUE.)
     254         7631 :       CALL section_add_keyword(section, keyword)
     255         7631 :       CALL keyword_release(keyword)
     256              : 
     257              :       CALL keyword_create(keyword, __LOCATION__, name="ELPA_PRINT", &
     258              :                           description="Controls the printing of ELPA diagonalization information. "// &
     259              :                           "Useful for testing purposes, especially together with keyword ELPA_QR.", &
     260         7631 :                           usage="ELPA_PRINT", default_l_val=elpa_print, lone_keyword_l_val=.TRUE.)
     261         7631 :       CALL section_add_keyword(section, keyword)
     262         7631 :       CALL keyword_release(keyword)
     263              : 
     264              :       CALL keyword_create(keyword, __LOCATION__, name="DLAF_NEIGVEC_MIN", &
     265              :                           description="Minimum number of eigenvectors for the use of the eigensolver from "// &
     266              :                           "the DLA-Future library. The eigensolver from the ScaLAPACK library is used as fallback "// &
     267              :                           "for all smaller cases", &
     268              :                           usage="DLAF_NEIGVEC_MIN 512", &
     269         7631 :                           default_i_val=1024)
     270         7631 :       CALL section_add_keyword(section, keyword)
     271         7631 :       CALL keyword_release(keyword)
     272              : 
     273              :       CALL keyword_create(keyword, __LOCATION__, name="DLAF_CHOLESKY_N_MIN", &
     274              :                           description="Minimum matrix size for the use of the Cholesky decomposition from "// &
     275              :                           "the DLA-Future library. The Cholesky decomposition from the ScaLAPACK library is used as fallback "// &
     276              :                           "for all smaller cases", &
     277              :                           usage="DLAF_CHOLESKY_N_MIN 512", &
     278         7631 :                           default_i_val=1024)
     279         7631 :       CALL section_add_keyword(section, keyword)
     280         7631 :       CALL keyword_release(keyword)
     281              : 
     282              :       CALL keyword_create( &
     283              :          keyword, __LOCATION__, name="PREFERRED_FFT_LIBRARY", &
     284              :          description="Specifies the preferred FFT library for local FFTs. "// &
     285              :          "Distributed FFTs are unaffected if CP2K was compiled with support for FFT offloading. "// &
     286              :          "Improved performance with FFTW3 can be obtained specifying a proper value for FFTW_PLAN_TYPE. ", &
     287              :          usage="PREFERRED_FFT_LIBRARY FFTW3", &
     288              :          citations=[Frigo2005], &
     289              :          default_i_val=FFT_LIBRARY_BACKEND_DEFAULT, &
     290              :          enum_i_vals=[FFT_LIBRARY_BACKEND_DEFAULT, FFT_LIBRARY_BACKEND_FFTW, FFT_LIBRARY_BACKEND_GPU], &
     291              :          enum_c_vals=s2a("DEFAULT", "FFTW3", "GPU"), &
     292              :          enum_desc=s2a("Equivalent to GPU if offloading was enabled, FFTW otherwise.", &
     293              :                        "A fast portable FFT library. Recommended. "// &
     294              :                        "See also the FFTW_PLAN_TYPE, and FFTW_WISDOM_FILE_NAME keywords.", &
     295        15262 :                        "CUFFT/HIPFFT-based backend if offloading was enabled."))
     296         7631 :       CALL section_add_keyword(section, keyword)
     297         7631 :       CALL keyword_release(keyword)
     298              : 
     299         7631 :       NULLIFY (sub_section)
     300              :       CALL section_create(sub_section, __LOCATION__, name="preferred_integral_library", &
     301              :                           description="Selects the implementation of individual Gaussian integral operations.", &
     302         7631 :                           n_keywords=2, n_subsections=0, repeats=.FALSE.)
     303              : 
     304              :       CALL keyword_create(keyword, __LOCATION__, name="COULOMB_2C", &
     305              :                           description="Preferred library for two-center Coulomb integrals (Coulomb_2c). "// &
     306              :                           "Libint is used by default when available; otherwise the native implementation is used.", &
     307              :                           usage="COULOMB_2C LIBINT", &
     308              :                           enum_c_vals=s2a("NATIVE", "LIBINT"), &
     309              :                           enum_i_vals=[library_native, library_libint], &
     310              :                           enum_desc=s2a("Use CP2K's native implementation.", &
     311              :                                         "Use the Libint implementation."), &
     312         7631 :                           default_i_val=default_coulomb_library)
     313         7631 :       CALL section_add_keyword(sub_section, keyword)
     314         7631 :       CALL keyword_release(keyword)
     315              : 
     316              :       CALL keyword_create(keyword, __LOCATION__, name="COULOMB_3C", &
     317              :                           description="Preferred library for three-center Coulomb integrals (Coulomb_3c). "// &
     318              :                           "Libint is used by default when available; otherwise the native implementation is used.", &
     319              :                           usage="COULOMB_3C LIBINT", &
     320              :                           enum_c_vals=s2a("NATIVE", "LIBINT"), &
     321              :                           enum_i_vals=[library_native, library_libint], &
     322              :                           enum_desc=s2a("Use CP2K's native implementation.", &
     323              :                                         "Use the Libint implementation."), &
     324         7631 :                           default_i_val=default_coulomb_library)
     325         7631 :       CALL section_add_keyword(sub_section, keyword)
     326         7631 :       CALL keyword_release(keyword)
     327              : 
     328         7631 :       CALL section_add_subsection(section, sub_section)
     329         7631 :       CALL section_release(sub_section)
     330              : 
     331              :       CALL keyword_create(keyword, __LOCATION__, name="FFTW_WISDOM_FILE_NAME", &
     332              :                           description="The name of the file that contains wisdom (pre-planned FFTs) for use with FFTW3. "// &
     333              :                           "Using wisdom can significantly speed up the FFTs (see the FFTW homepage for details). "// &
     334              :                           "Note that wisdom is not transferable between different computer (architectures). "// &
     335              :                           "Wisdom can be generated using the fftw-wisdom tool that is part of the fftw installation. "// &
     336              :                           "cp2k/tools/cp2k-wisdom is a script that contains some additional info, and can help "// &
     337              :                           "to generate a useful default for /etc/fftw/wisdom or particular values for a given simulation. "// &
     338              :                           "The wisdom is read from the file, if it exists. The updated wisdom is written back to "// &
     339              :                           "the file at the end of the run only if this keyword is specified explicitly.", &
     340         7631 :                           usage="FFTW_WISDOM_FILE_NAME wisdom.dat", default_lc_val="/etc/fftw/wisdom")
     341         7631 :       CALL section_add_keyword(section, keyword)
     342         7631 :       CALL keyword_release(keyword)
     343              : 
     344              :       CALL keyword_create(keyword, __LOCATION__, name="FFTW_PLAN_TYPE", &
     345              :                           description="FFTW can have improved performance if it is allowed to plan with "// &
     346              :                           "explicit measurements which strategy is best for a given FFT. "// &
     347              :                           "While a plan based on measurements is generally faster, "// &
     348              :                           "differences in machine load will lead to different plans for the same input file, "// &
     349              :                           "and thus numerics for the FFTs will be slightly different from run to run. "// &
     350              :                           "PATIENT planning is recommended for long ab initio MD runs. Ignored if PREFERRED_FFT_LIBRARY "// &
     351              :                           "was set to DEFAULT or GPU and offloading was enabled.", &
     352              :                           usage="FFTW_PLAN_TYPE PATIENT", &
     353              :                           citations=[Frigo2005], &
     354              :                           default_i_val=FFT_LIBRARY_FFTW_MODE_ESTIMATE, &
     355              :                           enum_i_vals=[FFT_LIBRARY_FFTW_MODE_ESTIMATE, FFT_LIBRARY_FFTW_MODE_MEASURE, &
     356              :                                        FFT_LIBRARY_FFTW_MODE_PATIENT, FFT_LIBRARY_FFTW_MODE_EXHAUSTIVE], &
     357              :                           enum_c_vals=s2a("ESTIMATE", &
     358              :                                           "MEASURE", &
     359              :                                           "PATIENT", &
     360              :                                           "EXHAUSTIVE"), &
     361              :                           enum_desc=s2a("Quick estimate, no runtime measurements.", &
     362              :                                         "Quick measurement, somewhat faster FFTs.", &
     363              :                                         "Measurements trying a wider range of possibilities.", &
     364        15262 :                                         "Measurements trying all possibilities - use with caution."))
     365         7631 :       CALL section_add_keyword(section, keyword)
     366         7631 :       CALL keyword_release(keyword)
     367              : 
     368              :       CALL keyword_create(keyword, __LOCATION__, name="FFTW_USE_GURU_INTERFACE", &
     369              :                           description="Use the FFTW guru interface for local FFTs when it is available. "// &
     370              :                           "This can enable additional optimized plans, but disabling it may help when "// &
     371              :                           "the regular FFTW interface is preferred.", &
     372              :                           usage="FFTW_USE_GURU_INTERFACE .TRUE.", &
     373         7631 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     374         7631 :       CALL section_add_keyword(section, keyword)
     375         7631 :       CALL keyword_release(keyword)
     376              : 
     377              :       CALL keyword_create(keyword, __LOCATION__, name="FFT_POOL_SCRATCH_LIMIT", &
     378              :                           description="Limits the memory usage of the FFT scratch pool, potentially reducing efficiency a bit", &
     379         7631 :                           usage="FFT_POOL_SCRATCH_LIMIT {INTEGER}", default_i_val=15)
     380         7631 :       CALL section_add_keyword(section, keyword)
     381         7631 :       CALL keyword_release(keyword)
     382              : 
     383              :       CALL keyword_create(keyword, __LOCATION__, name="ALLTOALL_SGL", &
     384              :                           description="All-to-all communication (FFT) should use single precision", &
     385              :                           usage="ALLTOALL_SGL YES", &
     386         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     387         7631 :       CALL section_add_keyword(section, keyword)
     388         7631 :       CALL keyword_release(keyword)
     389              : 
     390              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_LEVEL", &
     391              :                           variants=["IOLEVEL"], &
     392              :                           description="How much output is written out.", &
     393              :                           usage="PRINT_LEVEL HIGH", &
     394              :                           default_i_val=medium_print_level, enum_c_vals= &
     395              :                           s2a("SILENT", "LOW", "MEDIUM", "HIGH", "DEBUG"), &
     396              :                           enum_desc=s2a("Almost no output", &
     397              :                                         "Little output", "Quite some output", "Lots of output", &
     398              :                                         "Everything is written out, useful for debugging purposes only"), &
     399              :                           enum_i_vals=[silent_print_level, low_print_level, medium_print_level, &
     400        15262 :                                        high_print_level, debug_print_level])
     401         7631 :       CALL section_add_keyword(section, keyword)
     402         7631 :       CALL keyword_release(keyword)
     403              : 
     404              :       CALL keyword_create( &
     405              :          keyword, __LOCATION__, name="PROGRAM_NAME", &
     406              :          variants=["PROGRAM"], &
     407              :          description="Which program should be run", &
     408              :          usage="PROGRAM_NAME {STRING}", &
     409              :          enum_c_vals=s2a("ATOM", "FARMING", "TEST", "CP2K", "OPTIMIZE_INPUT", "OPTIMIZE_BASIS", "TMC", "MC_ANALYSIS", "SWARM"), &
     410              :          enum_desc=s2a("Runs single atom calculations", &
     411              :                        "Runs N independent jobs in a single run", &
     412              :                        "Do some benchmarking and testing", &
     413              :                        "Runs one of the CP2K package", &
     414              :                        "A tool to optimize parameters in a CP2K input", &
     415              :                        "A tool to create a MOLOPT or ADMM basis for a given set"// &
     416              :                        " of training structures", &
     417              :                        "Runs Tree Monte Carlo algorithm using additional input file(s)", &
     418              :                        "Runs (Tree) Monte Carlo trajectory file analysis", &
     419              :                        "Runs swarm based calculation"), &
     420              :          enum_i_vals=[do_atom, do_farming, do_test, do_cp2k, do_optimize_input, &
     421              :                       do_opt_basis, do_tree_mc, do_tree_mc_ana, do_swarm], &
     422        15262 :          default_i_val=do_cp2k)
     423         7631 :       CALL section_add_keyword(section, keyword)
     424         7631 :       CALL keyword_release(keyword)
     425              : 
     426              :       CALL keyword_create(keyword, __LOCATION__, name="PROJECT_NAME", &
     427              :                           variants=["PROJECT"], &
     428              :                           description="Name of the project (used to build the name of the "// &
     429              :                           "trajectory, and other files generated by the program)", &
     430              :                           usage="PROJECT_NAME {STRING}", &
     431        15262 :                           default_c_val="PROJECT")
     432         7631 :       CALL section_add_keyword(section, keyword)
     433         7631 :       CALL keyword_release(keyword)
     434              : 
     435              :       CALL keyword_create(keyword, __LOCATION__, name="OUTPUT_FILE_NAME", &
     436              :                           description="Name of the output file. "// &
     437              :                           "Relevant only if automatically started (through farming for example). "// &
     438              :                           "If empty uses the project name as basis for it.", &
     439         7631 :                           usage="OUTPUT_FILE_NAME {filename}", default_lc_val="")
     440         7631 :       CALL section_add_keyword(section, keyword)
     441         7631 :       CALL keyword_release(keyword)
     442              : 
     443              :       CALL keyword_create( &
     444              :          keyword, __LOCATION__, name="RUN_TYPE", &
     445              :          description="Selects the top-level task CP2K should run, such as an energy, "// &
     446              :          "energy-and-force, molecular dynamics, geometry optimization, or response calculation.", &
     447              :          usage="RUN_TYPE MD", &
     448              :          default_i_val=energy_force_run, &
     449              :          citations=[Ceriotti2014, Schonherr2014], &
     450              :          enum_c_vals=s2a("NONE", "ENERGY", "ENERGY_FORCE", "MD", "GEO_OPT", &
     451              :                          "MC", "DEBUG", "BSSE", "LR", "PINT", "VIBRATIONAL_ANALYSIS", &
     452              :                          "BAND", "CELL_OPT", "WFN_OPT", "WAVEFUNCTION_OPTIMIZATION", &
     453              :                          "MOLECULAR_DYNAMICS", "GEOMETRY_OPTIMIZATION", "MONTECARLO", &
     454              :                          "LINEAR_RESPONSE", "NORMAL_MODES", "RT_PROPAGATION", &
     455              :                          "EHRENFEST_DYN", "TAMC", "TMC", "DRIVER", "NEGF", "MIMIC", "RTP", &
     456              :                          "MTLR"), &
     457              :          enum_i_vals=[none_run, energy_run, energy_force_run, mol_dyn_run, &
     458              :                       geo_opt_run, mon_car_run, debug_run, &
     459              :                       bsse_run, linear_response_run, pint_run, vib_anal, do_band, &
     460              :                       cell_opt_run, energy_run, energy_run, mol_dyn_run, geo_opt_run, &
     461              :                       mon_car_run, linear_response_run, &
     462              :                       vib_anal, real_time_propagation, ehrenfest, do_tamc, tree_mc_run, &
     463              :                       driver_run, negf_run, mimic_run, real_time_propagation, mtlr_run], &
     464              :          enum_desc=s2a("Perform no tasks", "Computes energy", "Computes energy and forces", &
     465              :                        "Molecular Dynamics", "Geometry Optimization", "Monte Carlo", &
     466              :                        "Performs a Debug analysis", "Basis set superposition error", "Linear Response", &
     467              :                        "Path integral", "Vibrational analysis", "Band methods", &
     468              :                        "Cell optimization. Both cell vectors and atomic positions are optimised.", &
     469              :                        "Alias for ENERGY", "Alias for ENERGY", "Alias for MD", "Alias for GEO_OPT", &
     470              :                        "Alias for MC", "Alias for LR", "Alias for VIBRATIONAL_ANALYSIS", &
     471              :                        "Real Time propagation run (fixed ionic positions)", &
     472              :                        "Ehrenfest dynamics (using real time propagation of the wavefunction)", &
     473              :                        "Temperature Accelerated Monte Carlo (TAMC)", &
     474              :                        "Tree Monte Carlo (TMC), a pre-sampling MC algorithm", &
     475              :                        "i-PI driver mode", &
     476              :                        "Non-equilibrium Green's function method", &
     477              :                        "Run as a client in a simulation through the MiMiC framework", &
     478              :                        "Alias for RT_PROPAGATION", &
     479        22893 :                        "Minimum tracking linear response calculation for Hubbard U and Hund's J"))
     480         7631 :       CALL section_add_keyword(section, keyword)
     481         7631 :       CALL keyword_release(keyword)
     482              : 
     483              :       CALL keyword_create(keyword, __LOCATION__, name="WALLTIME", &
     484              :                           variants=["WALLTI"], &
     485              :                           description="Maximum execution time for this run. Time in seconds or in HH:MM:SS.", &
     486        15262 :                           usage="WALLTIME {real} or {HH:MM:SS}", default_lc_val="")
     487         7631 :       CALL section_add_keyword(section, keyword)
     488         7631 :       CALL keyword_release(keyword)
     489              : 
     490              :       CALL keyword_create(keyword, __LOCATION__, name="ECHO_INPUT", &
     491              :                           description="If the input should be echoed to the output with all the "// &
     492              :                           "defaults made explicit", &
     493         7631 :                           usage="ECHO_INPUT NO", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     494         7631 :       CALL section_add_keyword(section, keyword)
     495         7631 :       CALL keyword_release(keyword)
     496              : 
     497              :       CALL keyword_create(keyword, __LOCATION__, name="ECHO_ALL_HOSTS", &
     498              :                           description="Echo a list of hostname and pid for all MPI processes.", &
     499         7631 :                           usage="ECHO_ALL_HOSTS NO", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     500         7631 :       CALL section_add_keyword(section, keyword)
     501         7631 :       CALL keyword_release(keyword)
     502              : 
     503              :       CALL keyword_create(keyword, __LOCATION__, name="ENABLE_MPI_IO", &
     504              :                           description="Enable MPI parallelization for all supported I/O routines "// &
     505              :                           "Currently, only cube file writer/reader routines use MPI I/O. Disabling "// &
     506              :                           "this flag might speed up calculations dominated by I/O.", &
     507         7631 :                           usage="ENABLE_MPI_IO FALSE", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     508         7631 :       CALL section_add_keyword(section, keyword)
     509         7631 :       CALL keyword_release(keyword)
     510              : 
     511              :       CALL keyword_create(keyword, __LOCATION__, name="TRACE", &
     512              :                           description="If a debug trace of the execution of the program should be written", &
     513              :                           usage="TRACE", &
     514         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     515         7631 :       CALL section_add_keyword(section, keyword)
     516         7631 :       CALL keyword_release(keyword)
     517              : 
     518              :       CALL keyword_create(keyword, __LOCATION__, name="TRACE_MASTER", &
     519              :                           description="For parallel TRACEd runs: only the master node writes output.", &
     520              :                           usage="TRACE_MASTER", &
     521         7631 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     522         7631 :       CALL section_add_keyword(section, keyword)
     523         7631 :       CALL keyword_release(keyword)
     524              : 
     525              :       CALL keyword_create( &
     526              :          keyword, __LOCATION__, name="TRACE_MAX", &
     527              :          description="Limit the total number a given subroutine is printed in the trace. Accounting is not influenced.", &
     528         7631 :          usage="TRACE_MAX 100", default_i_val=HUGE(0))
     529         7631 :       CALL section_add_keyword(section, keyword)
     530         7631 :       CALL keyword_release(keyword)
     531              : 
     532              :       CALL keyword_create( &
     533              :          keyword, __LOCATION__, name="TRACE_ROUTINES", &
     534              :          description="A list of routines to trace. If left empty all routines are traced. Accounting is not influenced.", &
     535              :          usage="TRACE_ROUTINES {routine_name1} {routine_name2} ...", type_of_var=char_t, &
     536         7631 :          n_var=-1)
     537         7631 :       CALL section_add_keyword(section, keyword)
     538         7631 :       CALL keyword_release(keyword)
     539              : 
     540              :       CALL keyword_create( &
     541              :          keyword, __LOCATION__, name="FLUSH_SHOULD_FLUSH", &
     542              :          description="Flush output regularly, enabling this option might degrade performance significantly on certain machines.", &
     543              :          usage="FLUSH_SHOULD_FLUSH", &
     544         7631 :          default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     545         7631 :       CALL section_add_keyword(section, keyword)
     546         7631 :       CALL keyword_release(keyword)
     547              : 
     548              :       CALL keyword_create(keyword, __LOCATION__, name="ITER_LEVEL_VERBOSITY", &
     549              :                           description="Controls the verbosity of information about iteration levels "// &
     550              :                           "printed upon entry or exit of one. Iteration levels are defined by type "// &
     551              :                           "of task; the names and descriptions of iteration levels are listed under "// &
     552              :                           "the EACH section of printkeys. The default is dependent on PRINT_LEVEL: "// &
     553              :                           "SILENT for MEDIUM or lower, NOTICE for HIGH, STACK for DEBUG.", &
     554              :                           usage="ITER_LEVEL_VERBOSITY NOTICE", default_i_val=iter_silent, &
     555              :                           enum_c_vals=s2a("SILENT", "NOTICE", "STACK"), &
     556              :                           enum_desc=s2a("Do not print anything about iter levels", &
     557              :                                         "Print a notice when entering or exiting an iter level", &
     558              :                                         "Print a notice and also the full stack of iter levels"), &
     559         7631 :                           enum_i_vals=[iter_silent, iter_notice, iter_stack])
     560         7631 :       CALL section_add_keyword(section, keyword)
     561         7631 :       CALL keyword_release(keyword)
     562              : 
     563              :       CALL keyword_create(keyword, __LOCATION__, name="CALLGRAPH", &
     564              :                           description="At the end of the run write a callgraph to file, "// &
     565              :                           "which contains detailed timing informations. "// &
     566              :                           "This callgraph can be viewed e.g. with the open-source program kcachegrind.", &
     567              :                           usage="CALLGRAPH {NONE|MASTER|ALL}", &
     568              :                           default_i_val=CALLGRAPH_NONE, lone_keyword_i_val=CALLGRAPH_MASTER, &
     569              :                           enum_c_vals=s2a("NONE", "MASTER", "ALL"), &
     570              :                           enum_desc=s2a("No callgraph gets written", &
     571              :                                         "Only the master process writes his callgraph", &
     572              :                                         "All processes write their callgraph (into a separate files)."), &
     573         7631 :                           enum_i_vals=[CALLGRAPH_NONE, CALLGRAPH_MASTER, CALLGRAPH_ALL])
     574         7631 :       CALL section_add_keyword(section, keyword)
     575         7631 :       CALL keyword_release(keyword)
     576              : 
     577              :       CALL keyword_create(keyword, __LOCATION__, name="CALLGRAPH_FILE_NAME", &
     578              :                           description="Name of the callgraph file, which is written at the end of the run. "// &
     579              :                           "If not specified the project name will be used as filename.", &
     580         7631 :                           usage="CALLGRAPH_FILE_NAME {filename}", default_lc_val="")
     581         7631 :       CALL section_add_keyword(section, keyword)
     582         7631 :       CALL keyword_release(keyword)
     583              : 
     584              :       CALL keyword_create(keyword, __LOCATION__, name="SEED", &
     585              :                           description="Initial seed for the global (pseudo)random number generator "// &
     586              :                           "to create a stream of normally Gaussian distributed random numbers. "// &
     587              :                           "Exactly 1 or 6 positive integer values are expected. A single value is "// &
     588              :                           "replicated to fill up the full seed array with 6 numbers.", &
     589              :                           n_var=-1, &
     590              :                           type_of_var=integer_t, &
     591              :                           usage="SEED {INTEGER} .. {INTEGER}", &
     592         7631 :                           default_i_vals=[2000])
     593         7631 :       CALL section_add_keyword(section, keyword)
     594         7631 :       CALL keyword_release(keyword)
     595              : 
     596              :       CALL keyword_create(keyword, __LOCATION__, name="SAVE_MEM", &
     597              :                           description="Some sections of the input structure are deallocated when not needed,"// &
     598              :                           " and reallocated only when used. This reduces the required maximum memory.", &
     599              :                           usage="SAVE_MEM", &
     600         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     601         7631 :       CALL section_add_keyword(section, keyword)
     602         7631 :       CALL keyword_release(keyword)
     603              : 
     604              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "TIMINGS", description= &
     605              :                                        "Controls the printing of the timing report at the end of CP2K execution", &
     606         7631 :                                        print_level=silent_print_level, filename="__STD_OUT__")
     607              : 
     608              :       CALL keyword_create(keyword, __LOCATION__, name="THRESHOLD", &
     609              :                           description="Specify % of CPUTIME above which the contribution will be inserted in the"// &
     610              :                           " final timing report (e.g. 0.02 = 2%)", &
     611              :                           usage="THRESHOLD {REAL}", &
     612         7631 :                           default_r_val=0.02_dp)
     613         7631 :       CALL section_add_keyword(print_key, keyword)
     614         7631 :       CALL keyword_release(keyword)
     615              : 
     616              :       CALL keyword_create(keyword, __LOCATION__, name="SORT_BY_SELF_TIME", &
     617              :                           description="Sort the final timing report by the average self (exclusive) time instead of the "// &
     618              :                           "total (inclusive) time of a routine", &
     619              :                           usage="SORT_BY_SELF_TIME on", &
     620         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     621         7631 :       CALL section_add_keyword(print_key, keyword)
     622         7631 :       CALL keyword_release(keyword)
     623              : 
     624              :       CALL keyword_create(keyword, __LOCATION__, name="REPORT_MAXLOC", &
     625              :                           description="Report the rank with the slowest maximum self timing."// &
     626              :                           " Can be used to debug hard- or software."// &
     627              :                           " Also enables ECHO_ALL_HOSTS to link rank to hostname.", &
     628              :                           usage="REPORT_MAXLOC on", &
     629         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     630         7631 :       CALL section_add_keyword(print_key, keyword)
     631         7631 :       CALL keyword_release(keyword)
     632              : 
     633              :       CALL keyword_create(keyword, __LOCATION__, name="TIME_MPI", &
     634              :                           description="Include message_passing calls in the timing report (useful with CALLGRAPH).", &
     635              :                           usage="TIME_MPI .FALSE.", &
     636         7631 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     637         7631 :       CALL section_add_keyword(print_key, keyword)
     638         7631 :       CALL keyword_release(keyword)
     639              : 
     640              :       CALL keyword_create(keyword, __LOCATION__, name="TIMINGS_LEVEL", &
     641              :                           description="Specify the level of timings report. "// &
     642              :                           "Possible values are: 0 (report only CP2K root timer), 1 (all timers).", &
     643              :                           usage="TIMINGS_LEVEL 1", &
     644         7631 :                           default_i_val=default_timings_level, lone_keyword_i_val=default_timings_level)
     645         7631 :       CALL section_add_keyword(print_key, keyword)
     646         7631 :       CALL keyword_release(keyword)
     647              : 
     648         7631 :       CALL section_add_subsection(section, print_key)
     649         7631 :       CALL section_release(print_key)
     650              : 
     651              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "REFERENCES", description= &
     652              :                                        "Controls the printing of the references relevant to the calculations performed", &
     653         7631 :                                        print_level=silent_print_level, filename="__STD_OUT__")
     654         7631 :       CALL section_add_subsection(section, print_key)
     655         7631 :       CALL section_release(print_key)
     656              : 
     657              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
     658              :                                        description="controls the printing of  initialization controlled by the global section", &
     659         7631 :                                        print_level=silent_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     660         7631 :       CALL section_add_subsection(section, print_key)
     661         7631 :       CALL section_release(print_key)
     662              : 
     663              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PRINT", description= &
     664              :                                        "controls the printing of physical and mathematical constants", &
     665         7631 :                                        print_level=medium_print_level, filename="__STD_OUT__")
     666              : 
     667              :       CALL keyword_create(keyword, __LOCATION__, name="BASIC_DATA_TYPES", &
     668              :                           description="Controls the printing of the basic data types.", &
     669         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     670         7631 :       CALL section_add_keyword(print_key, keyword)
     671         7631 :       CALL keyword_release(keyword)
     672              :       CALL keyword_create(keyword, __LOCATION__, name="physcon", &
     673              :                           description="if the printkey is active prints the physical constants", &
     674         7631 :                           default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
     675         7631 :       CALL section_add_keyword(print_key, keyword)
     676         7631 :       CALL keyword_release(keyword)
     677              :       CALL keyword_create(keyword, __LOCATION__, name="SPHERICAL_HARMONICS", &
     678              :                           description="if the printkey is active prints the spherical harmonics", &
     679         7631 :                           default_i_val=-1, type_of_var=integer_t)
     680         7631 :       CALL section_add_keyword(print_key, keyword)
     681         7631 :       CALL keyword_release(keyword)
     682              :       CALL keyword_create(keyword, __LOCATION__, name="RNG_MATRICES", &
     683              :                           description="Prints the transformation matrices used by the  random number generator", &
     684              :                           default_l_val=.FALSE., &
     685         7631 :                           lone_keyword_l_val=.TRUE.)
     686         7631 :       CALL section_add_keyword(print_key, keyword)
     687         7631 :       CALL keyword_release(keyword)
     688              :       CALL keyword_create(keyword, __LOCATION__, name="RNG_CHECK", &
     689              :                           description="Performs a check of the global (pseudo)random "// &
     690              :                           "number generator (RNG) and prints the result", &
     691              :                           default_l_val=.FALSE., &
     692         7631 :                           lone_keyword_l_val=.TRUE.)
     693         7631 :       CALL section_add_keyword(print_key, keyword)
     694         7631 :       CALL keyword_release(keyword)
     695              :       CALL keyword_create(keyword, __LOCATION__, name="GLOBAL_GAUSSIAN_RNG", &
     696              :                           description="Prints the initial status of the global Gaussian "// &
     697              :                           "(pseudo)random number stream which is mostly used for "// &
     698              :                           "the velocity initialization", &
     699              :                           default_l_val=.FALSE., &
     700         7631 :                           lone_keyword_l_val=.TRUE.)
     701         7631 :       CALL section_add_keyword(print_key, keyword)
     702         7631 :       CALL keyword_release(keyword)
     703              : 
     704         7631 :       CALL section_add_subsection(section, print_key)
     705         7631 :       CALL section_release(print_key)
     706         7631 :       NULLIFY (sub_section)
     707              :       ! FM section
     708         7631 :       CALL create_fm_section(sub_section)
     709         7631 :       CALL section_add_subsection(section, sub_section)
     710         7631 :       CALL section_release(sub_section)
     711              :       ! DBCSR options
     712         7631 :       CALL create_dbcsr_section(sub_section)
     713         7631 :       CALL section_add_subsection(section, sub_section)
     714         7631 :       CALL section_release(sub_section)
     715              :       ! FM diagonalization redistribution rules
     716         7631 :       CALL create_fm_diag_rules_section(sub_section)
     717         7631 :       CALL section_add_subsection(section, sub_section)
     718         7631 :       CALL section_release(sub_section)
     719              :       ! Grid library
     720         7631 :       CALL create_grid_section(sub_section)
     721         7631 :       CALL section_add_subsection(section, sub_section)
     722         7631 :       CALL section_release(sub_section)
     723              : 
     724         7631 :    END SUBROUTINE create_global_section
     725              : 
     726              : ! **************************************************************************************************
     727              : !> \brief   Creates the dbcsr section for configuring FM
     728              : !> \param section ...
     729              : !> \date    2011-04-05
     730              : !> \author  Florian Schiffmann
     731              : ! **************************************************************************************************
     732         7631 :    SUBROUTINE create_fm_section(section)
     733              :       TYPE(section_type), POINTER                        :: section
     734              : 
     735              :       INTEGER                                            :: default_matmul
     736              :       TYPE(keyword_type), POINTER                        :: keyword
     737              : 
     738         7631 :       CPASSERT(.NOT. ASSOCIATED(section))
     739              :       CALL section_create(section, __LOCATION__, name="FM", &
     740              :                           description="Configuration options for the full matrices.", &
     741         7631 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     742              : 
     743         7631 :       NULLIFY (keyword)
     744              : 
     745              :       CALL keyword_create(keyword, __LOCATION__, name="NROW_BLOCKS", &
     746              :                           description="Defines the number of rows per scalapack block in "// &
     747              :                           "the creation of block cyclic dense matrices. "// &
     748              :                           "Use an internal default if zero or negative.", &
     749         7631 :                           default_i_val=cp_fm_struct_get_nrow_block())
     750         7631 :       CALL section_add_keyword(section, keyword)
     751         7631 :       CALL keyword_release(keyword)
     752              : 
     753              :       CALL keyword_create(keyword, __LOCATION__, name="NCOL_BLOCKS", &
     754              :                           description="Defines the number of columns per scalapack block in "// &
     755              :                           "the creation of vlock cyclic dense matrices. "// &
     756              :                           "Use an internal default if zero or negative.", &
     757         7631 :                           default_i_val=cp_fm_struct_get_ncol_block())
     758         7631 :       CALL section_add_keyword(section, keyword)
     759         7631 :       CALL keyword_release(keyword)
     760              : 
     761              :       CALL keyword_create(keyword, __LOCATION__, name="FORCE_BLOCK_SIZE", &
     762              :                           description="Ensure for small matrices that the layout is compatible "// &
     763              :                           "with bigger ones, i.e. no subdivision is performed (can break LAPACK).", &
     764              :                           usage="FORCE_BLOCK_SIZE", &
     765         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     766         7631 :       CALL section_add_keyword(section, keyword)
     767         7631 :       CALL keyword_release(keyword)
     768              : 
     769              : #if defined(__COSMA)
     770         7631 :       default_matmul = do_cosma
     771              : #else
     772              :       default_matmul = do_scalapack
     773              : #endif
     774              : 
     775              :       CALL keyword_create(keyword, __LOCATION__, name="TYPE_OF_MATRIX_MULTIPLICATION", &
     776              :                           description="Allows to switch between scalapack pxgemm and COSMA pxgemm. "// &
     777              :                           "COSMA reduces the communication costs but increases the memory demands. "// &
     778              :                           "For large dense products the COSMA buffers can set the peak memory; "// &
     779              :                           "the environment variable COSMA_CPU_MAX_MEMORY caps them per MPI rank "// &
     780              :                           "(in MB), at some cost in runtime. "// &
     781              :                           "The performance of Scalapack's pxgemm on GPU's depends "// &
     782              :                           "crucially on the BLOCK_SIZES. Make sure optimized kernels are available.", &
     783              :                           default_i_val=default_matmul, &
     784              :                           enum_i_vals=[do_scalapack, do_scalapack, do_cosma], &
     785              :                           enum_c_vals=s2a("SCALAPACK", "PDGEMM", "COSMA"), &
     786              :                           enum_desc=s2a("Standard ScaLAPACK pdgemm", &
     787              :                                         "Alias for ScaLAPACK", &
     788         7631 :                                         "COSMA is employed. See <https://github.com/eth-cscs/COSMA>."))
     789         7631 :       CALL section_add_keyword(section, keyword)
     790         7631 :       CALL keyword_release(keyword)
     791              : 
     792              :       !
     793         7631 :    END SUBROUTINE create_fm_section
     794              : ! **************************************************************************************************
     795              : !> \brief   Creates the input section used to define the heuristic rules which determine if
     796              : !>          a FM matrix should be redistributed before diagonalizing it.
     797              : !> \param section the input section to create
     798              : !> \author Nico Holmberg [01.2018]
     799              : ! **************************************************************************************************
     800         7631 :    SUBROUTINE create_fm_diag_rules_section(section)
     801              :       TYPE(section_type), POINTER                        :: section
     802              : 
     803              :       TYPE(keyword_type), POINTER                        :: keyword
     804              : 
     805         7631 :       CPASSERT(.NOT. ASSOCIATED(section))
     806              :       CALL section_create(section, __LOCATION__, name="FM_DIAG_SETTINGS", &
     807              :                           description="This section defines a set of heuristic rules which are "// &
     808              :                           "used to calculate the optimal number of CPUs, M, needed to diagonalize a "// &
     809              :                           "full matrix distributed on N processors (FM type). If M &lt N, the matrix "// &
     810              :                           "is redistributed onto M processors before it is diagonalized. "// &
     811              :                           "The optimal value is calculate according to M = ((K+a*x-1)/(a*x))*a, "// &
     812              :                           "where K is the size of the matrix, and {a, x} are integers defined below. "// &
     813              :                           "The default values have been selected based on timings on a Cray XE6. "// &
     814              :                           "Supports diagonalization libraries SL and ELPA (see keyword ELPA_FORCE_REDISTRIBUTE).", &
     815         7631 :                           n_keywords=3, n_subsections=0, repeats=.FALSE.)
     816              : 
     817         7631 :       NULLIFY (keyword)
     818              : 
     819              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETER_A", &
     820              :                           description="Parameter used for defining the rule which determines the optimal "// &
     821              :                           "number of CPUs needed to diagonalize a full distributed matrix. The optimal "// &
     822              :                           "number of CPUs will be an integer multiple of this variable.", &
     823              :                           usage="PARAMETER_A 4", type_of_var=integer_t, &
     824         7631 :                           default_i_val=4)
     825         7631 :       CALL section_add_keyword(section, keyword)
     826         7631 :       CALL keyword_release(keyword)
     827              : 
     828              :       CALL keyword_create(keyword, __LOCATION__, name="PARAMETER_X", &
     829              :                           description="Parameter used for defining the rule which determines the optimal "// &
     830              :                           "number of CPUs needed to diagonalize a full distributed matrix. The optimal "// &
     831              :                           "number of CPUs will be roughly proportional to this value.", &
     832              :                           usage="PARAMETER_X 60", type_of_var=integer_t, &
     833         7631 :                           default_i_val=60)
     834         7631 :       CALL section_add_keyword(section, keyword)
     835         7631 :       CALL keyword_release(keyword)
     836              : 
     837              :       CALL keyword_create(keyword, __LOCATION__, name="PRINT_FM_REDISTRIBUTE", &
     838              :                           description="Controls printing of information related to this section. For each "// &
     839              :                           "diagonalized matrix, prints the size of the matrix, the optimal number of CPUs, "// &
     840              :                           "as well as notifies if the matrix was redistributed. Useful for testing.", &
     841              :                           usage="PRINT_FM_REDISTRIBUTE", type_of_var=logical_t, &
     842         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     843         7631 :       CALL section_add_keyword(section, keyword)
     844         7631 :       CALL keyword_release(keyword)
     845              : 
     846              :       CALL keyword_create(keyword, __LOCATION__, name="ELPA_FORCE_REDISTRIBUTE", &
     847              :                           description="Controls how to perform redistribution when ELPA is used for diagonalization. "// &
     848              :                           "By default, matrices are redistributed only when required by the ELPA layout. "// &
     849              :                           "Turning on this keyword also applies the defined rules to reduce the number of "// &
     850              :                           "processors, using a layout without empty process rows or columns.", &
     851              :                           usage="ELPA_FORCE_REDISTRIBUTE", type_of_var=logical_t, &
     852         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     853         7631 :       CALL section_add_keyword(section, keyword)
     854         7631 :       CALL keyword_release(keyword)
     855              : 
     856         7631 :    END SUBROUTINE create_fm_diag_rules_section
     857              : 
     858              : ! **************************************************************************************************
     859              : !> \brief Creates the section for configuring the grid library
     860              : !> \param section ...
     861              : !> \author Ole Schuett
     862              : ! **************************************************************************************************
     863         7631 :    SUBROUTINE create_grid_section(section)
     864              :       TYPE(section_type), POINTER                        :: section
     865              : 
     866              :       TYPE(keyword_type), POINTER                        :: keyword
     867              : 
     868         7631 :       CPASSERT(.NOT. ASSOCIATED(section))
     869              :       CALL section_create(section, __LOCATION__, name="GRID", &
     870              :                           description="Configuration options for the grid library, "// &
     871              :                           "which performs e.g. the collocate and integrate of the GPW method.", &
     872         7631 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     873              : 
     874         7631 :       NULLIFY (keyword)
     875              :       CALL keyword_create(keyword, __LOCATION__, name="BACKEND", &
     876              :                           description="Selects the backed used by the grid library.", &
     877              :                           default_i_val=GRID_BACKEND_AUTO, &
     878              :                           enum_i_vals=[GRID_BACKEND_AUTO, GRID_BACKEND_REF, GRID_BACKEND_CPU, &
     879              :                                        GRID_BACKEND_DGEMM, GRID_BACKEND_GPU], &
     880              :                           enum_c_vals=s2a("AUTO", "REFERENCE", "CPU", "DGEMM", "GPU"), &
     881              :                           enum_desc=s2a("Let the grid library pick the backend automatically", &
     882              :                                         "Reference backend implementation", &
     883              :                                         "Optimized CPU backend", &
     884              :                                         "Alternative CPU backend based on DGEMM", &
     885         7631 :                                         "GPU backend optimized for NVIDIA and AMD GPU"))
     886         7631 :       CALL section_add_keyword(section, keyword)
     887         7631 :       CALL keyword_release(keyword)
     888              : 
     889              :       CALL keyword_create(keyword, __LOCATION__, name="VALIDATE", &
     890              :                           description="When enabled the reference backend is run in shadow mode "// &
     891              :                           "and its results are compared with those from the selected backend. "// &
     892              :                           "If the two results differ by too much then the calculation is aborted.", &
     893         7631 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     894         7631 :       CALL section_add_keyword(section, keyword)
     895         7631 :       CALL keyword_release(keyword)
     896              : 
     897              :       CALL keyword_create(keyword, __LOCATION__, name="APPLY_CUTOFF", &
     898              :                           description="When enabled the cpu backend "// &
     899              :                           "apply a spherical cutoff on the top of the cube. "// &
     900              :                           "There is a performance penalty using it in "// &
     901              :                           "combination with the cpu backend but it is on by "// &
     902              :                           "default for the regtests", default_l_val=.TRUE., &
     903         7631 :                           lone_keyword_l_val=.TRUE.)
     904         7631 :       CALL section_add_keyword(section, keyword)
     905         7631 :       CALL keyword_release(keyword)
     906              : 
     907         7631 :    END SUBROUTINE create_grid_section
     908              : 
     909              : END MODULE input_cp2k_global
        

Generated by: LCOV version 2.0-1