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

Generated by: LCOV version 2.0-1