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

Generated by: LCOV version 2.0-1