1!--------------------------------------------------------------------------------------------------!
2!   CP2K: A general program to perform molecular dynamics simulations                              !
3!   Copyright (C) 2000 - 2019  CP2K developers group                                               !
4!--------------------------------------------------------------------------------------------------!
5
6! **************************************************************************************************
7!> \brief builds the input structure for cp2k
8!> \par History
9!>      06.2004 created [fawzi]
10!> \author fawzi
11! **************************************************************************************************
12MODULE input_cp2k
13   USE cp_eri_mme_interface,            ONLY: create_eri_mme_test_section
14   USE cp_output_handling,              ONLY: add_last_numeric,&
15                                              cp_print_key_section_create,&
16                                              low_print_level,&
17                                              medium_print_level,&
18                                              silent_print_level
19   USE dbcsr_api,                       ONLY: dbcsr_test_binary_io,&
20                                              dbcsr_test_mm,&
21                                              dbcsr_type_complex_4,&
22                                              dbcsr_type_complex_8,&
23                                              dbcsr_type_real_4,&
24                                              dbcsr_type_real_8
25   USE input_constants,                 ONLY: &
26        do_diag_syevd, do_diag_syevx, do_mat_random, do_mat_read, do_pwgrid_ns_fullspace, &
27        do_pwgrid_ns_halfspace, do_pwgrid_spherical, ehrenfest, numerical
28   USE input_cp2k_atom,                 ONLY: create_atom_section
29   USE input_cp2k_force_eval,           ONLY: create_force_eval_section
30   USE input_cp2k_global,               ONLY: create_global_section
31   USE input_cp2k_motion,               ONLY: create_motion_section
32   USE input_cp2k_negf,                 ONLY: create_negf_section
33   USE input_cp2k_rsgrid,               ONLY: create_rsgrid_section
34   USE input_cp2k_vib,                  ONLY: create_vib_section
35   USE input_keyword_types,             ONLY: keyword_create,&
36                                              keyword_release,&
37                                              keyword_type
38   USE input_optimize_basis,            ONLY: create_optimize_basis_section
39   USE input_optimize_input,            ONLY: create_optimize_input_section
40   USE input_section_types,             ONLY: section_add_keyword,&
41                                              section_add_subsection,&
42                                              section_create,&
43                                              section_release,&
44                                              section_type
45   USE input_val_types,                 ONLY: char_t,&
46                                              integer_t,&
47                                              lchar_t,&
48                                              logical_t
49   USE kinds,                           ONLY: dp
50   USE pw_grids,                        ONLY: do_pw_grid_blocked_false,&
51                                              do_pw_grid_blocked_free,&
52                                              do_pw_grid_blocked_true
53   USE shg_integrals_test,              ONLY: create_shg_integrals_test_section
54   USE string_utilities,                ONLY: newline,&
55                                              s2a
56   USE swarm_input,                     ONLY: create_swarm_section
57#include "../base/base_uses.f90"
58
59   IMPLICIT NONE
60   PRIVATE
61
62   LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
63   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k'
64
65   PUBLIC :: create_cp2k_root_section
66
67CONTAINS
68
69! **************************************************************************************************
70!> \brief creates the input structure of the file used by cp2k
71!> \param root_section the input structure to be created
72!> \author fawzi
73! **************************************************************************************************
74   SUBROUTINE create_cp2k_root_section(root_section)
75      TYPE(section_type), POINTER                        :: root_section
76
77      CHARACTER(len=*), PARAMETER :: routineN = 'create_cp2k_root_section', &
78         routineP = moduleN//':'//routineN
79
80      INTEGER                                            :: handle
81      TYPE(section_type), POINTER                        :: section
82
83      CALL timeset(routineN, handle)
84
85      CPASSERT(.NOT. ASSOCIATED(root_section))
86      CALL section_create(root_section, __LOCATION__, name="__ROOT__", &
87                          description="input file of cp2k", n_keywords=0, n_subsections=10, &
88                          repeats=.FALSE.)
89      NULLIFY (section)
90
91      CALL create_global_section(section)
92      CALL section_add_subsection(root_section, section)
93      CALL section_release(section)
94
95      CALL create_test_section(section)
96      CALL section_add_subsection(root_section, section)
97      CALL section_release(section)
98
99      CALL create_debug_section(section)
100      CALL section_add_subsection(root_section, section)
101      CALL section_release(section)
102
103      CALL create_motion_section(section)
104      CALL section_add_subsection(root_section, section)
105      CALL section_release(section)
106
107      CALL create_multi_force_section(section)
108      CALL section_add_subsection(root_section, section)
109      CALL section_release(section)
110
111      CALL create_force_eval_section(section)
112      CALL section_add_subsection(root_section, section)
113      CALL section_release(section)
114
115      CALL create_farming_section(section)
116      CALL section_add_subsection(root_section, section)
117      CALL section_release(section)
118
119      CALL create_optimize_input_section(section)
120      CALL section_add_subsection(root_section, section)
121      CALL section_release(section)
122
123      CALL create_optimize_basis_section(section)
124      CALL section_add_subsection(root_section, section)
125      CALL section_release(section)
126
127      CALL create_swarm_section(section)
128      CALL section_add_subsection(root_section, section)
129      CALL section_release(section)
130
131      CALL create_ext_restart_section(section)
132      CALL section_add_subsection(root_section, section)
133      CALL section_release(section)
134
135      CALL create_vib_section(section)
136      CALL section_add_subsection(root_section, section)
137      CALL section_release(section)
138
139      CALL create_negf_section(section)
140      CALL section_add_subsection(root_section, section)
141      CALL section_release(section)
142
143      CALL create_atom_section(section)
144      CALL section_add_subsection(root_section, section)
145      CALL section_release(section)
146      CALL timestop(handle)
147
148   END SUBROUTINE create_cp2k_root_section
149
150! **************************************************************************************************
151!> \brief section with the tests of the libraries or external code that cp2k uses
152!> \param section the section to be created
153!> \author fawzi
154! **************************************************************************************************
155   SUBROUTINE create_test_section(section)
156      TYPE(section_type), POINTER                        :: section
157
158      CHARACTER(len=*), PARAMETER :: routineN = 'create_test_section', &
159         routineP = moduleN//':'//routineN
160
161      TYPE(keyword_type), POINTER                        :: keyword
162      TYPE(section_type), POINTER                        :: print_key, subsection
163
164      CALL section_create(section, __LOCATION__, name="TEST", &
165                          description="Tests to perform on the supported libraries.", &
166                          n_keywords=7, n_subsections=0, repeats=.FALSE.)
167
168      NULLIFY (keyword, print_key)
169      CALL keyword_create(keyword, __LOCATION__, name="MEMORY", &
170                          description="Set the maximum amount of memory allocated for a given test (in bytes)", &
171                          usage="MEMORY <REAL>", default_r_val=256.e6_dp)
172      CALL section_add_keyword(section, keyword)
173      CALL keyword_release(keyword)
174
175      CALL keyword_create(keyword, __LOCATION__, name="COPY", &
176                          description="Tests the performance to copy two vectors."// &
177                          "The results of these tests allow to determine the size of the cache "// &
178                          "of the CPU. This can be used to optimize the performance of the"// &
179                          "FFTSG library. Tests are repeated the given number of times.", &
180                          usage="copy 10", default_i_val=0)
181      CALL section_add_keyword(section, keyword)
182      CALL keyword_release(keyword)
183
184      CALL keyword_create(keyword, __LOCATION__, name="MATMUL", &
185                          description="Tests the performance of different kinds of matrix matrix "// &
186                          "multiply kernels for the F95 INTRINSIC matmul. Matrices up to 2**N+1 will be tested. ", &
187                          usage="matmul 10", default_i_val=0)
188      CALL section_add_keyword(section, keyword)
189      CALL keyword_release(keyword)
190
191      CALL keyword_create(keyword, __LOCATION__, name="DGEMM", &
192                          description="Tests the performance of different kinds of matrix matrix "// &
193                          "multiply kernels for the BLAS INTRINSIC DGEMM. Matrices up to 2**N+1 will be tested. ", &
194                          usage="DGEMM 10", default_i_val=0)
195      CALL section_add_keyword(section, keyword)
196      CALL keyword_release(keyword)
197
198      CALL keyword_create(keyword, __LOCATION__, name="FFT", &
199                          description="Tests the performance of all available FFT libraries for "// &
200                          "3D FFTs Tests are repeated the given number of times.", &
201                          usage="fft 10", default_i_val=0)
202      CALL section_add_keyword(section, keyword)
203      CALL keyword_release(keyword)
204
205      CALL keyword_create(keyword, __LOCATION__, name="ERI", &
206                          description="Tests the performance and correctness of ERI libraries ", &
207                          usage="eri 1", default_i_val=0)
208      CALL section_add_keyword(section, keyword)
209      CALL keyword_release(keyword)
210
211      CALL keyword_create(keyword, __LOCATION__, name="CLEBSCH_GORDON", variants=(/"CLEBSCH"/), &
212                          description="Tests the Clebsch-Gordon Coefficients. "// &
213                          "Tests are repeated the given number of times.", &
214                          usage="clebsch_gordon 10", default_i_val=0)
215
216      CALL section_add_keyword(section, keyword)
217      CALL keyword_release(keyword)
218
219      CALL keyword_create(keyword, __LOCATION__, name="MPI", &
220                          description="Tests mpi, quickly adapted benchmark code,"// &
221                          "will ONLY work on an even number of CPUs. comm is the relevant, "// &
222                          "initialized communicator. This test will produce messages "// &
223                          "of the size 8*10**requested_size, where requested_size is the value "// &
224                          "given to this keyword", &
225                          usage="mpi 6", default_i_val=0)
226
227      CALL section_add_keyword(section, keyword)
228      CALL keyword_release(keyword)
229
230      CALL keyword_create(keyword, __LOCATION__, name="RANDOM_NUMBER_GENERATOR", variants=(/"rng"/), &
231                          description=" Tests the parallel random number generator (RNG)", &
232                          usage="rng 1000000", default_i_val=0)
233      CALL section_add_keyword(section, keyword)
234      CALL keyword_release(keyword)
235
236      CALL keyword_create(keyword, __LOCATION__, name="MINIMAX", &
237                          description="Tests validity of minimax coefficients for approximating 1/x "// &
238                          "as a sum of exponentials. "// &
239                          "Checks numerical error against tabulated error, testing "// &
240                          "the given number of different Rc values.", &
241                          usage="MINIMAX 1000", default_i_val=0)
242      CALL section_add_keyword(section, keyword)
243      CALL keyword_release(keyword)
244
245      CALL keyword_create(keyword, __LOCATION__, name="LEAST_SQ_FT", &
246                          description="Tests accuracy of the integration weights gamma_ik from Kaltak, "// &
247                          "Klimes, Kresse, JCTC 10, 2498 (2014), Eq. 30. Printed is the L1-error (=minimax "// &
248                          "error for a given range and a given number of grid points. The input parameter is "// &
249                          "the given number of different Rc values.", &
250                          usage="MINIMAX 1000", default_i_val=0)
251      CALL section_add_keyword(section, keyword)
252      CALL keyword_release(keyword)
253
254      CALL cp_print_key_section_create( &
255         print_key, __LOCATION__, "GRID_INFORMATION", &
256         description="Controls the printing of information regarding the PW and RS grid structures"// &
257         " (ONLY for TEST run).", &
258         print_level=medium_print_level, filename="__STD_OUT__")
259      CALL section_add_subsection(section, print_key)
260      CALL section_release(print_key)
261
262      CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
263                                       description="controls the printing of tests output", &
264                                       print_level=silent_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
265      CALL section_add_subsection(section, print_key)
266      CALL section_release(print_key)
267
268      NULLIFY (subsection)
269      CALL create_rs_pw_transfer_section(subsection)
270      CALL section_add_subsection(section, subsection)
271      CALL section_release(subsection)
272
273      CALL create_eigensolver_section(subsection)
274      CALL section_add_subsection(section, subsection)
275      CALL section_release(subsection)
276
277      CALL create_pw_transfer_section(subsection)
278      CALL section_add_subsection(section, subsection)
279      CALL section_release(subsection)
280
281      CALL create_cp_fm_gemm_section(subsection)
282      CALL section_add_subsection(section, subsection)
283      CALL section_release(subsection)
284
285      CALL create_cp_dbcsr_section(subsection)
286      CALL section_add_subsection(section, subsection)
287      CALL section_release(subsection)
288
289      CALL create_eri_mme_test_section(subsection)
290      CALL section_add_subsection(section, subsection)
291      CALL section_release(subsection)
292
293      CALL create_shg_integrals_test_section(subsection)
294      CALL section_add_subsection(section, subsection)
295      CALL section_release(subsection)
296
297   END SUBROUTINE create_test_section
298
299! **************************************************************************************************
300!> \brief section to setup debugging parameter
301!> \param section the section to be created
302!> \author teo
303! **************************************************************************************************
304   SUBROUTINE create_debug_section(section)
305      TYPE(section_type), POINTER                        :: section
306
307      CHARACTER(len=*), PARAMETER :: routineN = 'create_debug_section', &
308         routineP = moduleN//':'//routineN
309
310      TYPE(keyword_type), POINTER                        :: keyword
311      TYPE(section_type), POINTER                        :: print_key
312
313      CALL section_create(section, __LOCATION__, name="DEBUG", &
314                          description="Section to setup parameters for debug runs.", &
315                          n_keywords=7, n_subsections=0, repeats=.FALSE.)
316
317      NULLIFY (keyword, print_key)
318
319      CALL keyword_create(keyword, __LOCATION__, name="DEBUG_FORCES", &
320                          description="Activates the debugging of the atomic forces", &
321                          usage="DEBUG_FORCES {LOGICAL}", default_l_val=.TRUE., &
322                          lone_keyword_l_val=.TRUE.)
323      CALL section_add_keyword(section, keyword)
324      CALL keyword_release(keyword)
325
326      CALL keyword_create(keyword, __LOCATION__, name="DEBUG_STRESS_TENSOR", &
327                          description="Activates the debugging of the stress tensor", &
328                          usage="DEBUG_STRESS_TENSOR {LOGICAL}", default_l_val=.TRUE., &
329                          lone_keyword_l_val=.TRUE.)
330      CALL section_add_keyword(section, keyword)
331      CALL keyword_release(keyword)
332
333      CALL keyword_create(keyword, __LOCATION__, name="DEBUG_DIPOLE", &
334                          description="Activates the debugging of the dipole moment", &
335                          usage="DEBUG_DIPOLE {LOGICAL}", default_l_val=.FALSE., &
336                          lone_keyword_l_val=.TRUE.)
337      CALL section_add_keyword(section, keyword)
338      CALL keyword_release(keyword)
339
340      CALL keyword_create(keyword, __LOCATION__, name="DEBUG_POLARIZABILITY", &
341                          description="Activates the debugging of the polarizability", &
342                          usage="DEBUG_POLARIZABILITY {LOGICAL}", default_l_val=.FALSE., &
343                          lone_keyword_l_val=.TRUE.)
344      CALL section_add_keyword(section, keyword)
345      CALL keyword_release(keyword)
346
347      CALL keyword_create(keyword, __LOCATION__, name="DX", &
348                          description="Increment for the calculation of the numerical derivatives", &
349                          usage="DX {REAL}", default_r_val=0.001_dp)
350      CALL section_add_keyword(section, keyword)
351      CALL keyword_release(keyword)
352
353      CALL keyword_create(keyword, __LOCATION__, name="DE", &
354                          description="Increment for the calculation of the numerical electric field derivatives", &
355                          usage="DE {REAL}", default_r_val=0.0001_dp)
356      CALL section_add_keyword(section, keyword)
357      CALL keyword_release(keyword)
358
359      CALL keyword_create(keyword, __LOCATION__, name="EPS_NO_ERROR_CHECK", &
360                          description="The mismatch between the numerical and the "// &
361                          "analytical value is not checked for analytical "// &
362                          "values smaller than this threshold value", &
363                          usage="EPS_NO_ERROR_CHECK {REAL}", default_r_val=1.0E-5_dp)
364      CALL section_add_keyword(section, keyword)
365      CALL keyword_release(keyword)
366
367      CALL keyword_create(keyword, __LOCATION__, name="STOP_ON_MISMATCH", &
368                          description="Stop the debug run when a mismatch between the numerical and "// &
369                          "the analytical value is detected", &
370                          usage="STOP_ON_MISMATCH {LOGICAL}", default_l_val=.TRUE., &
371                          lone_keyword_l_val=.TRUE.)
372      CALL section_add_keyword(section, keyword)
373      CALL keyword_release(keyword)
374
375      CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
376                                       description="Controls the printing of the DEBUG specific output", &
377                                       print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
378      CALL section_add_subsection(section, print_key)
379      CALL section_release(print_key)
380
381   END SUBROUTINE create_debug_section
382
383! **************************************************************************************************
384!> \brief creates the multiple force_eval section
385!> \param section the section to be created
386!> \author fawzi
387! **************************************************************************************************
388   SUBROUTINE create_multi_force_section(section)
389      TYPE(section_type), POINTER                        :: section
390
391      CHARACTER(len=*), PARAMETER :: routineN = 'create_multi_force_section', &
392         routineP = moduleN//':'//routineN
393
394      TYPE(keyword_type), POINTER                        :: keyword
395
396      CPASSERT(.NOT. ASSOCIATED(section))
397      CALL section_create(section, __LOCATION__, name="MULTIPLE_FORCE_EVALS", &
398                          description="Describes how to handle multiple force_evals.", &
399                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
400
401      NULLIFY (keyword)
402      CALL keyword_create(keyword, __LOCATION__, name="FORCE_EVAL_ORDER", &
403                          description='Specify the orders of the different force_eval. When using a MIXED force_eval'// &
404                          " this does not need to be specified in this list, because it that takes into account only the real"// &
405                          " energy contributions", &
406                          usage="FORCE_EVAL_ORDER <INTEGER> .. <INTEGER>", type_of_var=integer_t, n_var=-1, &
407                          default_i_vals=(/1/))
408      CALL section_add_keyword(section, keyword)
409      CALL keyword_release(keyword)
410
411      CALL keyword_create(keyword, __LOCATION__, name="MULTIPLE_SUBSYS", &
412                          description="Specify if force_eval have different subsys. In case they share the same subsys,"// &
413                          " it needs to be specified only in the MIXED force_eval (if using MIXED) or"// &
414                          " in the force_eval corresponding to first force_eval of the previous order (when not using MIXED).", &
415                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
416      CALL section_add_keyword(section, keyword)
417      CALL keyword_release(keyword)
418
419   END SUBROUTINE create_multi_force_section
420
421! **************************************************************************************************
422!> \brief Creates the exteranal restart section
423!> \param section the section to create
424!> \author fawzi
425! **************************************************************************************************
426   SUBROUTINE create_ext_restart_section(section)
427      TYPE(section_type), POINTER                        :: section
428
429      CHARACTER(len=*), PARAMETER :: routineN = 'create_ext_restart_section', &
430         routineP = moduleN//':'//routineN
431
432      TYPE(keyword_type), POINTER                        :: keyword
433
434      CPASSERT(.NOT. ASSOCIATED(section))
435      CALL section_create(section, __LOCATION__, name="EXT_RESTART", &
436                          description="Section for external restart, specifies an external "// &
437                          "input file where to take positions, etc. "// &
438                          "By default they are all set to TRUE", &
439                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
440      NULLIFY (keyword)
441
442      CALL keyword_create(keyword, __LOCATION__, name="RESTART_FILE_NAME", variants=(/"EXTERNAL_FILE"/), &
443                          description="Specifies the name of restart file (or any other input file)"// &
444                          " to be read. Only fields relevant to a restart will be used"// &
445                          " (unless switched off with the keywords in this section)", &
446                          default_lc_val=" ")
447      CALL section_add_keyword(section, keyword)
448      CALL keyword_release(keyword)
449
450      CALL keyword_create(keyword, __LOCATION__, name="BINARY_RESTART_FILE_NAME", &
451                          variants=(/"BINARY_RESTART_FILE"/), &
452                          description="Specifies the name of an additional restart file "// &
453                          "from which selected input sections are read in binary format "// &
454                          "(see SPLIT_RESTART_FILE).", &
455                          default_lc_val="")
456      CALL section_add_keyword(section, keyword)
457      CALL keyword_release(keyword)
458
459      CALL keyword_create(keyword, __LOCATION__, name="RESTART_DEFAULT", &
460                          description="This keyword controls the default value for all possible "// &
461                          " restartable keywords, unless explicitly defined. For example setting"// &
462                          " this keyword to .FALSE. does not restart any quantity. If, at the "// &
463                          " same time, one keyword is set to .TRUE. only that quantity will be"// &
464                          " restarted.", default_l_val=.TRUE.)
465      CALL section_add_keyword(section, keyword)
466      CALL keyword_release(keyword)
467      CALL keyword_create(keyword, __LOCATION__, name="RESTART_COUNTERS", &
468                          description="Restarts the counters in MD schemes and optimization STEP", &
469                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
470      CALL section_add_keyword(section, keyword)
471      CALL keyword_release(keyword)
472      CALL keyword_create(keyword, __LOCATION__, name="RESTART_POS", &
473                          description="Takes the positions from the external file", &
474                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
475      CALL section_add_keyword(section, keyword)
476      CALL keyword_release(keyword)
477      CALL keyword_create(keyword, __LOCATION__, name="RESTART_VEL", &
478                          description="Takes the velocities from the external file", &
479                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
480      CALL section_add_keyword(section, keyword)
481      CALL keyword_release(keyword)
482      CALL keyword_create(keyword, __LOCATION__, name="RESTART_RANDOMG", &
483                          description="Restarts the random number generator from the external file", &
484                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
485      CALL section_add_keyword(section, keyword)
486      CALL keyword_release(keyword)
487
488      CALL keyword_create(keyword, __LOCATION__, name="RESTART_SHELL_POS", &
489                          description="Takes the positions of the shells from the external file (only if shell-model)", &
490                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
491      CALL section_add_keyword(section, keyword)
492      CALL keyword_release(keyword)
493      CALL keyword_create(keyword, __LOCATION__, name="RESTART_CORE_POS", &
494                          description="Takes the positions of the cores from the external file (only if shell-model)", &
495                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
496      CALL section_add_keyword(section, keyword)
497      CALL keyword_release(keyword)
498      CALL keyword_create(keyword, __LOCATION__, name="RESTART_OPTIMIZE_INPUT_VARIABLES", &
499                          description="Restart with the optimize input variables", &
500                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
501      CALL section_add_keyword(section, keyword)
502      CALL keyword_release(keyword)
503
504      CALL keyword_create(keyword, __LOCATION__, name="RESTART_SHELL_VELOCITY", &
505                          description="Takes the velocities of the shells from the external file (only if shell-model)", &
506                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
507      CALL section_add_keyword(section, keyword)
508      CALL keyword_release(keyword)
509      CALL keyword_create(keyword, __LOCATION__, name="RESTART_CORE_VELOCITY", &
510                          description="Takes the velocities of the shells from the external file (only if shell-model)", &
511                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
512      CALL section_add_keyword(section, keyword)
513      CALL keyword_release(keyword)
514      CALL keyword_create(keyword, __LOCATION__, name="RESTART_BAROSTAT", &
515                          description="Restarts the barostat from the external file", &
516                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
517      CALL section_add_keyword(section, keyword)
518      CALL keyword_release(keyword)
519      CALL keyword_create(keyword, __LOCATION__, name="RESTART_BAROSTAT_THERMOSTAT", &
520                          description="Restarts the barostat thermostat from the external file", &
521                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
522      CALL section_add_keyword(section, keyword)
523      CALL keyword_release(keyword)
524      CALL keyword_create(keyword, __LOCATION__, name="RESTART_SHELL_THERMOSTAT", &
525                          description="Restarts the shell thermostat from the external file", &
526                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
527      CALL section_add_keyword(section, keyword)
528      CALL keyword_release(keyword)
529      CALL keyword_create(keyword, __LOCATION__, name="RESTART_THERMOSTAT", &
530                          description="Restarts the nose thermostats of the particles "// &
531                          "from the EXTERNAL file", &
532                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
533      CALL section_add_keyword(section, keyword)
534      CALL keyword_release(keyword)
535      CALL keyword_create(keyword, __LOCATION__, name="RESTART_TEMPERATURE_ANNEALING", &
536                          description="Restarts external temperature when using TEMPERATURE_ANNEALING.", &
537                          type_of_var=logical_t, lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
538      CALL section_add_keyword(section, keyword)
539      CALL keyword_release(keyword)
540      CALL keyword_create(keyword, __LOCATION__, name="RESTART_CELL", &
541                          description="Restarts the cell (and cell_ref) "// &
542                          "from the EXTERNAL file", &
543                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
544      CALL section_add_keyword(section, keyword)
545      CALL keyword_release(keyword)
546      CALL keyword_create(keyword, __LOCATION__, name="RESTART_METADYNAMICS", &
547                          description="Restarts hills from a previous metadynamics run "// &
548                          "from the EXTERNAL file", &
549                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
550      CALL section_add_keyword(section, keyword)
551      CALL keyword_release(keyword)
552      CALL keyword_create(keyword, __LOCATION__, name="RESTART_WALKERS", &
553                          description="Restarts walkers informations from a previous metadynamics run "// &
554                          "from the EXTERNAL file", &
555                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
556      CALL section_add_keyword(section, keyword)
557      CALL keyword_release(keyword)
558      CALL keyword_create(keyword, __LOCATION__, name="RESTART_BAND", &
559                          description="Restarts positions and velocities of the Band.", &
560                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
561      CALL section_add_keyword(section, keyword)
562      CALL keyword_release(keyword)
563      CALL keyword_create(keyword, __LOCATION__, name="RESTART_QMMM", &
564                          description="Restarts the following specific QMMM info: translation vectors.", &
565                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
566      CALL section_add_keyword(section, keyword)
567      CALL keyword_release(keyword)
568      CALL keyword_create(keyword, __LOCATION__, name="RESTART_CONSTRAINT", &
569                          description="Restarts constraint section. It's necessary when doing restraint"// &
570                          " calculation to have a perfect energy conservation. For constraints only it's"// &
571                          " use is optional.", &
572                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
573      CALL section_add_keyword(section, keyword)
574      CALL keyword_release(keyword)
575      CALL keyword_create(keyword, __LOCATION__, name="RESTART_BSSE", &
576                          description="Restarts information for BSSE calculations.", &
577                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
578      CALL section_add_keyword(section, keyword)
579      CALL keyword_release(keyword)
580      CALL keyword_create(keyword, __LOCATION__, name="RESTART_DIMER", &
581                          description="Restarts information for DIMER geometry optimizations.", &
582                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
583      CALL section_add_keyword(section, keyword)
584      CALL keyword_release(keyword)
585      CALL keyword_create(keyword, __LOCATION__, name="RESTART_AVERAGES", &
586                          description="Restarts information for AVERAGES.", &
587                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
588      CALL section_add_keyword(section, keyword)
589      CALL keyword_release(keyword)
590      CALL keyword_create(keyword, __LOCATION__, name="RESTART_RTP", &
591                          description="Restarts information for REAL TIME PROPAGATION and EHRENFEST DYNAMICS.", &
592                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
593      CALL section_add_keyword(section, keyword)
594      CALL keyword_release(keyword)
595      CALL keyword_create(keyword, __LOCATION__, name="CUSTOM_PATH", &
596                          description="Restarts the given path from the EXTERNAL file. Allows a major flexibility for restarts.", &
597                          type_of_var=char_t, repeats=.TRUE.)
598      CALL section_add_keyword(section, keyword)
599      CALL keyword_release(keyword)
600
601      ! PIMD
602      CALL keyword_create(keyword, __LOCATION__, name="RESTART_PINT_POS", &
603                          description="Restart bead positions from PINT%BEADS%COORD.", &
604                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
605      CALL section_add_keyword(section, keyword)
606      CALL keyword_release(keyword)
607      CALL keyword_create(keyword, __LOCATION__, name="RESTART_PINT_VEL", &
608                          description="Restart bead velocities from PINT%BEADS%VELOCITY.", &
609                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
610      CALL section_add_keyword(section, keyword)
611      CALL keyword_release(keyword)
612      CALL keyword_create(keyword, __LOCATION__, name="RESTART_PINT_NOSE", &
613                          description="Restart Nose thermostat for beads from PINT%NOSE.", &
614                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
615      CALL section_add_keyword(section, keyword)
616      CALL keyword_release(keyword)
617      CALL keyword_create(keyword, __LOCATION__, name="RESTART_PINT_GLE", &
618                          description="Restart GLE thermostat for beads from PINT%GLE.", &
619                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
620      CALL section_add_keyword(section, keyword)
621      CALL keyword_release(keyword)
622
623      ! PIMC
624      CALL keyword_create(keyword, __LOCATION__, name="RESTART_HELIUM_POS", &
625                          description="Restart helium positions from PINT%HELIUM%COORD.", &
626                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
627      CALL section_add_keyword(section, keyword)
628      CALL keyword_release(keyword)
629      CALL keyword_create(keyword, __LOCATION__, name="RESTART_HELIUM_PERMUTATION", &
630                          description="Restart helium permutation state from PINT%HELIUM%PERM.", &
631                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
632      CALL section_add_keyword(section, keyword)
633      CALL keyword_release(keyword)
634      CALL keyword_create(keyword, __LOCATION__, name="RESTART_HELIUM_FORCE", &
635                          description="Restart helium forces exerted on the solute from PINT%HELIUM%FORCE.", &
636                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
637      CALL section_add_keyword(section, keyword)
638      CALL keyword_release(keyword)
639      CALL keyword_create(keyword, __LOCATION__, name="RESTART_HELIUM_RNG", &
640                          description="Restarts helium random number generators from PINT%HELIUM%RNG_STATE.", &
641                          type_of_var=logical_t, lone_keyword_l_val=.TRUE.)
642      CALL section_add_keyword(section, keyword)
643      CALL keyword_release(keyword)
644      CALL keyword_create(keyword, __LOCATION__, name="RESTART_HELIUM_DENSITIES", &
645                          description="Restarts helium density distributions from PINT%HELIUM%RHO.", &
646                          type_of_var=logical_t, lone_keyword_l_val=.TRUE., &
647                          default_l_val=.FALSE.)
648      CALL section_add_keyword(section, keyword)
649      CALL keyword_release(keyword)
650      CALL keyword_create(keyword, __LOCATION__, name="RESTART_HELIUM_AVERAGES", &
651                          description="Restarts average properties from PINT%HELIUM%AVERAGES.", &
652                          type_of_var=logical_t, lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
653      CALL section_add_keyword(section, keyword)
654      CALL keyword_release(keyword)
655
656   END SUBROUTINE create_ext_restart_section
657
658! **************************************************************************************************
659!> \brief creates the farming section
660!> \param section the section to create
661!> \author fawzi
662! **************************************************************************************************
663   SUBROUTINE create_farming_section(section)
664      TYPE(section_type), POINTER                        :: section
665
666      CHARACTER(len=*), PARAMETER :: routineN = 'create_farming_section', &
667         routineP = moduleN//':'//routineN
668
669      TYPE(keyword_type), POINTER                        :: keyword
670      TYPE(section_type), POINTER                        :: print_key, sub_section
671
672      CPASSERT(.NOT. ASSOCIATED(section))
673      CALL section_create(section, __LOCATION__, name="farming", &
674                          description="Describes a farming job, in which multiple inputs are executed."//newline// &
675                          "The RUN_TYPE in the global section has to be set to NONE for FARMING."//newline// &
676                          "The different groups are executed in parallel. The jobs inside the same groups in series.", &
677                          repeats=.FALSE.)
678      NULLIFY (keyword, print_key)
679
680      CALL keyword_create( &
681         keyword, __LOCATION__, name="MASTER_SLAVE", &
682         description="If a master-slave setup should be employed, in which one process is used to distribute the tasks. "// &
683         "This is most useful to load-balance if not all jobs have the same length, "// &
684         "and a lot of CPUs/groups are available.", &
685         usage="MASTER_SLAVE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
686      CALL section_add_keyword(section, keyword)
687      CALL keyword_release(keyword)
688
689      CALL keyword_create(keyword, __LOCATION__, name="NGROUPS", variants=(/"NGROUP"/), &
690                          description="Gives the preferred number of working groups.", &
691                          usage="ngroups 4", type_of_var=integer_t)
692      CALL section_add_keyword(section, keyword)
693      CALL keyword_release(keyword)
694
695      CALL keyword_create(keyword, __LOCATION__, name="GROUP_SIZE", &
696                          description="Gives the preferred size of a working group, "// &
697                          "groups will always be equal or larger than this size.", &
698                          usage="group_size 2", default_i_val=8)
699      CALL section_add_keyword(section, keyword)
700      CALL keyword_release(keyword)
701
702      CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
703                          description="Stride to be used when building working groups from the parent MPI comm."// &
704                          "Can be used to layout slave groups over nodes in advanced ways (1 rank per node / 2 groups per node).", &
705                          usage="STRIDE 2", default_i_val=1)
706      CALL section_add_keyword(section, keyword)
707      CALL keyword_release(keyword)
708
709      CALL keyword_create(keyword, __LOCATION__, name="GROUP_PARTITION", &
710                          description="gives the exact number of processors for each group.", &
711                          usage="group_partition  2 2 4 2 4 ", type_of_var=integer_t, n_var=-1)
712      CALL section_add_keyword(section, keyword)
713      CALL keyword_release(keyword)
714
715      CALL keyword_create(keyword, __LOCATION__, name="MAX_JOBS_PER_GROUP", &
716                          variants=(/"MAX_JOBS"/), &
717                          description="maximum number of jobs executed per group", &
718                          usage="max_step 4", default_i_val=65535)
719      CALL section_add_keyword(section, keyword)
720      CALL keyword_release(keyword)
721
722      CALL keyword_create( &
723         keyword, __LOCATION__, name="CYCLE", &
724         description="If farming should process all jobs in a cyclic way, stopping only if MAX_JOBS_PER_GROUP is exceeded.", &
725         usage="CYCLE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
726      CALL section_add_keyword(section, keyword)
727      CALL keyword_release(keyword)
728
729      CALL keyword_create( &
730         keyword, __LOCATION__, name="WAIT_TIME", &
731         description="Time to wait [s] for a new task if no task is currently available, make this zero if no clock is available", &
732         usage="WAIT_TIME 0.1", default_r_val=0.5_dp)
733      CALL section_add_keyword(section, keyword)
734      CALL keyword_release(keyword)
735
736      NULLIFY (sub_section)
737      CALL section_create(sub_section, __LOCATION__, name="JOB", &
738                          description="description of the jobs to be executed", &
739                          repeats=.TRUE.)
740
741      CALL keyword_create(keyword, __LOCATION__, name="DIRECTORY", &
742                          description="the directory in which the job should be executed", &
743                          usage="DIRECTORY /my/path", &
744                          default_lc_val=".")
745      CALL section_add_keyword(sub_section, keyword)
746      CALL keyword_release(keyword)
747
748      CALL keyword_create(keyword, __LOCATION__, name="INPUT_FILE_NAME", &
749                          description="the filename of the input file", &
750                          usage="INPUT_FILE_NAME my_input.inp", &
751                          default_lc_val="input.inp")
752      CALL section_add_keyword(sub_section, keyword)
753      CALL keyword_release(keyword)
754
755      CALL keyword_create( &
756         keyword, __LOCATION__, name="OUTPUT_FILE_NAME", &
757         description="the filename of the output file, if not specified will use the project name in the &GLOBAL section.", &
758         usage="OUTPUT_FILE_NAME my_input.inp", &
759         default_lc_val="")
760      CALL section_add_keyword(sub_section, keyword)
761      CALL keyword_release(keyword)
762
763      CALL keyword_create(keyword, __LOCATION__, name="JOB_ID", &
764                          description="An ID used to indentify a job in DEPENDENCIES. "// &
765                          "JOB_IDs do not need to be unique, dependencies will be on all jobs with a given ID. "// &
766                          "If no JOB_ID is given, the index of the &JOB section in the input file will be used. ", &
767                          usage="JOB_ID 13", type_of_var=integer_t)
768      CALL section_add_keyword(sub_section, keyword)
769      CALL keyword_release(keyword)
770
771      CALL keyword_create( &
772         keyword, __LOCATION__, name="DEPENDENCIES", &
773         description="specifies a list of JOB_IDs on which the current job depends. "// &
774         "The current job will not be executed before all the dependencies have finished. "// &
775         "The keyword requires a MASTER_SLAVE farming run. "// &
776         "Beyond the default case, some special cases might arise: "// &
777         "1) circular dependencies will lead to a deadlock. "// &
778         "2) This keyword is not compatible with CYCLE. "// &
779         "3) MAX_JOBS_PER_GROUP is ignored (though only a total of MAX_JOBS_PER_GROUP*NGROUPS jobs will be executed) "// &
780         "4) dependencies on jobs that will not be executed (due to RESTART or MAX_JOBS_PER_GROUP) are ignored. "// &
781         "Additionally, note that, on some file systems, "// &
782         " output (restart) files might not be immediately available on all compute nodes,"// &
783         "potentially resulting in unexpected failures.", &
784         usage="DEPENDENCIES 13 1 7", type_of_var=integer_t, n_var=-1)
785      CALL section_add_keyword(sub_section, keyword)
786      CALL keyword_release(keyword)
787      CALL section_add_subsection(section, sub_section)
788      CALL section_release(sub_section)
789
790      CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
791                                       description="controls the printing of FARMING specific output", &
792                                       print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
793      CALL section_add_subsection(section, print_key)
794      CALL section_release(print_key)
795
796      CALL keyword_create(keyword, __LOCATION__, name="DO_RESTART", &
797                          description="Restart a farming job (and should pick up where the previous left off)", &
798                          usage="DO_RESTART", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
799      CALL section_add_keyword(section, keyword)
800      CALL keyword_release(keyword)
801
802      CALL keyword_create(keyword, __LOCATION__, name="RESTART_FILE_NAME", &
803                          description="Name of the restart file to use for restarting a FARMING run. If not "// &
804                          "specified the name is determined from PROJECT name.", &
805                          usage="RESTART_FILE_NAME <FILENAME>", type_of_var=lchar_t)
806      CALL section_add_keyword(section, keyword)
807      CALL keyword_release(keyword)
808
809      CALL cp_print_key_section_create(print_key, __LOCATION__, "RESTART", &
810                                       description="controls the printing of the restart for FARMING.", &
811                                       print_level=low_print_level, add_last=add_last_numeric, filename="FARMING")
812      CALL section_add_subsection(section, print_key)
813      CALL section_release(print_key)
814
815   END SUBROUTINE create_farming_section
816
817! **************************************************************************************************
818!> \brief   creates the rs_pw_transfer section for use in the test section
819!> \param section ...
820!> \date    2008-03-09
821!> \author  Joost VandeVondele
822! **************************************************************************************************
823   SUBROUTINE create_rs_pw_transfer_section(section)
824      TYPE(section_type), POINTER                        :: section
825
826      CHARACTER(len=*), PARAMETER :: routineN = 'create_rs_pw_transfer_section', &
827         routineP = moduleN//':'//routineN
828
829      TYPE(keyword_type), POINTER                        :: keyword
830      TYPE(section_type), POINTER                        :: subsection
831
832      CPASSERT(.NOT. ASSOCIATED(section))
833      CALL section_create(section, __LOCATION__, name="RS_PW_TRANSFER", &
834                          description="Describes how to benchmark the rs_pw_transfer routines.", &
835                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
836
837      NULLIFY (keyword)
838      CALL keyword_create(keyword, __LOCATION__, name="GRID", &
839                          description="Specify the number of grid points (not all grid points are allowed)", &
840                          usage="GRID_DIMENSIONS 128 128 128", type_of_var=integer_t, n_var=3, &
841                          default_i_vals=(/128, 128, 128/))
842      CALL section_add_keyword(section, keyword)
843      CALL keyword_release(keyword)
844
845      CALL keyword_create(keyword, __LOCATION__, name="HALO_SIZE", &
846                          description="number of grid points of the halo", &
847                          usage="HALO_SIZE 17", default_i_val=17)
848      CALL section_add_keyword(section, keyword)
849      CALL keyword_release(keyword)
850
851      CALL keyword_create(keyword, __LOCATION__, name="N_LOOP", &
852                          description="Number of rs_pw_transfers being timed", &
853                          usage="N_LOOP 100", default_i_val=10)
854      CALL section_add_keyword(section, keyword)
855      CALL keyword_release(keyword)
856
857      CALL keyword_create(keyword, __LOCATION__, name="RS2PW", &
858                          description="should the direction be rs2pw (pw2rs otherwise)", &
859                          usage="rs2pw TRUE", default_l_val=.TRUE.)
860      CALL section_add_keyword(section, keyword)
861      CALL keyword_release(keyword)
862
863      NULLIFY (subsection)
864      CALL create_rsgrid_section(subsection)
865      CALL section_add_subsection(section, subsection)
866      CALL section_release(subsection)
867
868   END SUBROUTINE create_rs_pw_transfer_section
869
870! **************************************************************************************************
871!> \brief   creates the rs_pw_transfer section for use in the test section
872!> \param section ...
873!> \date    2008-03-09
874!> \author  Joost VandeVondele
875! **************************************************************************************************
876   SUBROUTINE create_pw_transfer_section(section)
877      TYPE(section_type), POINTER                        :: section
878
879      CHARACTER(len=*), PARAMETER :: routineN = 'create_pw_transfer_section', &
880         routineP = moduleN//':'//routineN
881
882      TYPE(keyword_type), POINTER                        :: keyword
883
884      CPASSERT(.NOT. ASSOCIATED(section))
885      CALL section_create(section, __LOCATION__, name="PW_TRANSFER", &
886                          description="Benchmark and test the pw_transfer routines.", &
887                          n_keywords=1, n_subsections=0, repeats=.TRUE.)
888
889      NULLIFY (keyword)
890      CALL keyword_create(keyword, __LOCATION__, name="GRID", &
891                          description="Specify the number of grid points (not all grid points are allowed)", &
892                          usage="GRID_DIMENSIONS 128 128 128", type_of_var=integer_t, n_var=3, &
893                          default_i_vals=(/128, 128, 128/))
894      CALL section_add_keyword(section, keyword)
895      CALL keyword_release(keyword)
896
897      CALL keyword_create(keyword, __LOCATION__, name="N_LOOP", &
898                          description="Number of pw_transfers (backward&forward) being timed", &
899                          usage="N_LOOP 100", default_i_val=100)
900      CALL section_add_keyword(section, keyword)
901      CALL keyword_release(keyword)
902
903      CALL keyword_create(keyword, __LOCATION__, name="PW_GRID", &
904                          description="What kind of PW_GRID should be employed", &
905                          usage="PW_GRID NS-FULLSPACE", &
906                          enum_c_vals=s2a("SPHERICAL", "NS-FULLSPACE", "NS-HALFSPACE"), &
907                          enum_desc=s2a("- not tested", " tested", " - not tested"), &
908                          enum_i_vals=(/do_pwgrid_spherical, do_pwgrid_ns_fullspace, do_pwgrid_ns_halfspace/), &
909                          default_i_val=do_pwgrid_ns_fullspace)
910      CALL section_add_keyword(section, keyword)
911      CALL keyword_release(keyword)
912
913      CALL keyword_create(keyword, __LOCATION__, name="PW_GRID_LAYOUT_ALL", &
914                          description="loop overal all PW_GRID_LAYOUTs that are compatible with a given number of CPUs ", &
915                          usage="PW_GRID_LAYOUT_ALL", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
916      CALL section_add_keyword(section, keyword)
917      CALL keyword_release(keyword)
918
919      CALL keyword_create(keyword, __LOCATION__, name="DEBUG", &
920                          description="Do the FFT in debug mode in all cases", &
921                          usage="DEBUG", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
922      CALL section_add_keyword(section, keyword)
923      CALL keyword_release(keyword)
924
925      CALL keyword_create(keyword, __LOCATION__, name="PW_GRID_LAYOUT", &
926                          description="Expert use only, leave the default..."// &
927                          "Can be used to set the distribution for ray-distributed FFT.", &
928                          usage="PW_GRID_LAYOUT", &
929                          repeats=.FALSE., n_var=2, &
930                          default_i_vals=(/-1, -1/))
931      CALL section_add_keyword(section, keyword)
932      CALL keyword_release(keyword)
933
934      CALL keyword_create(keyword, __LOCATION__, name="PW_GRID_BLOCKED", &
935                          description="Expert use only, leave the default..."// &
936                          "Can be used to set the distribution in g-space for the pw grids and their FFT.", &
937                          usage="PW_GRID_BLOCKED FREE", &
938                          enum_c_vals=s2a("FREE", "TRUE", "FALSE"), &
939                          enum_desc=s2a("CP2K will select the optimal value", "blocked", "not blocked"), &
940                          enum_i_vals=(/do_pw_grid_blocked_free, do_pw_grid_blocked_true, do_pw_grid_blocked_false/), &
941                          default_i_val=do_pw_grid_blocked_false)
942      CALL section_add_keyword(section, keyword)
943      CALL keyword_release(keyword)
944
945   END SUBROUTINE create_pw_transfer_section
946
947! **************************************************************************************************
948!> \brief   creates the cp_fm_gemm section for use in the test section
949!> \param section ...
950!> \date    2009-06-15
951!> \author  Joost VandeVondele
952! **************************************************************************************************
953   SUBROUTINE create_cp_fm_gemm_section(section)
954      TYPE(section_type), POINTER                        :: section
955
956      CHARACTER(len=*), PARAMETER :: routineN = 'create_cp_fm_gemm_section', &
957         routineP = moduleN//':'//routineN
958
959      TYPE(keyword_type), POINTER                        :: keyword
960
961      CPASSERT(.NOT. ASSOCIATED(section))
962      CALL section_create(section, __LOCATION__, name="CP_FM_GEMM", &
963                          description="Benchmark and test the cp_fm_gemm routines by multiplying C=A*B  ", &
964                          n_keywords=1, n_subsections=0, repeats=.TRUE.)
965
966      NULLIFY (keyword)
967      CALL keyword_create(keyword, __LOCATION__, name="N_LOOP", &
968                          description="Number of cp_fm_gemm operations being timed (useful for small matrices).", &
969                          usage="N_LOOP 10", default_i_val=10)
970      CALL section_add_keyword(section, keyword)
971      CALL keyword_release(keyword)
972
973      CALL keyword_create(keyword, __LOCATION__, name="K", &
974                          description="Dimension 1 of C", &
975                          usage="A 1024", default_i_val=256)
976      CALL section_add_keyword(section, keyword)
977      CALL keyword_release(keyword)
978      CALL keyword_create(keyword, __LOCATION__, name="M", &
979                          description="Inner dimension M   ", &
980                          usage="A 1024", default_i_val=256)
981      CALL section_add_keyword(section, keyword)
982      CALL keyword_release(keyword)
983      CALL keyword_create(keyword, __LOCATION__, name="N", &
984                          description="Dimension 2 of C", &
985                          usage="A 1024", default_i_val=256)
986      CALL section_add_keyword(section, keyword)
987      CALL keyword_release(keyword)
988
989      CALL keyword_create(keyword, __LOCATION__, name="NROW_BLOCK", &
990                          description="block_size for rows", &
991                          usage="nrow_block 64", default_i_val=32)
992      CALL section_add_keyword(section, keyword)
993      CALL keyword_release(keyword)
994
995      CALL keyword_create(keyword, __LOCATION__, name="NCOL_BLOCK", &
996                          description="block_size for cols", &
997                          usage="nrow_block 64", default_i_val=32)
998      CALL section_add_keyword(section, keyword)
999      CALL keyword_release(keyword)
1000
1001      CALL keyword_create(keyword, __LOCATION__, name="ROW_MAJOR", &
1002                          description="Use a row major blacs grid", &
1003                          usage="ROW_MAJOR .FALSE.", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
1004      CALL section_add_keyword(section, keyword)
1005      CALL keyword_release(keyword)
1006
1007      CALL keyword_create(keyword, __LOCATION__, name="FORCE_BLOCKSIZE", &
1008                          description="Forces the blocksize, even if this implies that a few processes might have no data", &
1009                          usage="FORCE_BLOCKSIZE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1010      CALL section_add_keyword(section, keyword)
1011      CALL keyword_release(keyword)
1012
1013      CALL keyword_create(keyword, __LOCATION__, name="GRID_2D", &
1014                          description="Explicitly set the blacs 2D processor layout."// &
1015                          " If the product differs from the number of MPI ranks,"// &
1016                          " it is ignored and a default nearly square layout is used.", n_var=2, &
1017                          usage="GRID_2D 64 16 ", default_i_vals=(/1, 1/))
1018      CALL section_add_keyword(section, keyword)
1019      CALL keyword_release(keyword)
1020
1021      CALL keyword_create(keyword, __LOCATION__, name="TRANSA", &
1022                          description="Transpose matrix A", &
1023                          usage="TRANSA", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1024      CALL section_add_keyword(section, keyword)
1025      CALL keyword_release(keyword)
1026
1027      CALL keyword_create(keyword, __LOCATION__, name="TRANSB", &
1028                          description="Transpose matrix B", &
1029                          usage="TRANSB", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1030      CALL section_add_keyword(section, keyword)
1031      CALL keyword_release(keyword)
1032
1033   END SUBROUTINE create_cp_fm_gemm_section
1034
1035! **************************************************************************************************
1036!> \brief   creates the eigensolver section for use in the test section
1037!> \param section ...
1038!> \date    2010-03-10
1039!> \author  Joost VandeVondele
1040! **************************************************************************************************
1041   SUBROUTINE create_eigensolver_section(section)
1042      TYPE(section_type), POINTER                        :: section
1043
1044      CHARACTER(len=*), PARAMETER :: routineN = 'create_eigensolver_section', &
1045         routineP = moduleN//':'//routineN
1046
1047      TYPE(keyword_type), POINTER                        :: keyword
1048
1049      CPASSERT(.NOT. ASSOCIATED(section))
1050      CALL section_create(section, __LOCATION__, name="EIGENSOLVER", &
1051                          description="Benchmark and test the eigensolver routines.", &
1052                          n_keywords=1, n_subsections=0, repeats=.TRUE.)
1053
1054      NULLIFY (keyword)
1055      CALL keyword_create(keyword, __LOCATION__, name="N", &
1056                          description="Dimension of the square matrix", &
1057                          usage="N 1024", default_i_val=256)
1058      CALL section_add_keyword(section, keyword)
1059      CALL keyword_release(keyword)
1060
1061      CALL keyword_create(keyword, __LOCATION__, name="N_LOOP", &
1062                          description="Number of operations being timed (useful for small matrices).", &
1063                          usage="N_LOOP 10", default_i_val=10)
1064      CALL section_add_keyword(section, keyword)
1065      CALL keyword_release(keyword)
1066
1067      CALL keyword_create(keyword, __LOCATION__, name="DIAG_METHOD", &
1068                          description="Diagonalization strategy", &
1069                          usage="DIAG_METHOD syevd", &
1070                          enum_c_vals=s2a("syevd", "syevx"), &
1071                          enum_desc=s2a("(sca)lapacks syevd", "(sca)lapacks syevx"), &
1072                          enum_i_vals=(/do_diag_syevd, do_diag_syevx/), &
1073                          default_i_val=do_diag_syevd)
1074      CALL section_add_keyword(section, keyword)
1075      CALL keyword_release(keyword)
1076
1077      CALL keyword_create(keyword, __LOCATION__, name="EIGENVALUES", &
1078                          description="number of eigenvalues to be computed (all=<0) ", &
1079                          usage="EIGENVALUES 13", default_i_val=-1)
1080      CALL section_add_keyword(section, keyword)
1081      CALL keyword_release(keyword)
1082
1083      CALL keyword_create(keyword, __LOCATION__, name="INIT_METHOD", &
1084                          description="Initialization approach", &
1085                          usage="INIT_METHOD RANDOM", &
1086                          enum_c_vals=s2a("random", "read"), &
1087                          enum_desc=s2a("use a random initial matrix", "read a matrix from file MATRIX"), &
1088                          enum_i_vals=(/do_mat_random, do_mat_read/), &
1089                          default_i_val=do_mat_random)
1090      CALL section_add_keyword(section, keyword)
1091      CALL keyword_release(keyword)
1092
1093   END SUBROUTINE create_eigensolver_section
1094
1095! **************************************************************************************************
1096!> \brief   creates the cp_dbcsr section for use in the test section
1097!> \param section ...
1098!> \date    2010-02-08
1099!> \author  Urban Borstnik
1100! **************************************************************************************************
1101   SUBROUTINE create_cp_dbcsr_section(section)
1102      TYPE(section_type), POINTER                        :: section
1103
1104      CHARACTER(len=*), PARAMETER :: routineN = 'create_cp_dbcsr_section', &
1105         routineP = moduleN//':'//routineN
1106
1107      TYPE(keyword_type), POINTER                        :: keyword
1108
1109      CPASSERT(.NOT. ASSOCIATED(section))
1110      CALL section_create(section, __LOCATION__, name="CP_DBCSR", &
1111                          description="Benchmark and test the cp_dbcsr routines", &
1112                          n_keywords=1, n_subsections=0, repeats=.TRUE.)
1113
1114      NULLIFY (keyword)
1115      CALL keyword_create(keyword, __LOCATION__, name="N_LOOP", &
1116                          description="Number of operations being timed (useful for small matrices).", &
1117                          usage="N_LOOP 10", default_i_val=10)
1118      CALL section_add_keyword(section, keyword)
1119      CALL keyword_release(keyword)
1120
1121      CALL keyword_create(keyword, __LOCATION__, name="DATA_TYPE", &
1122                          description="Data type of the matrices", &
1123                          usage="DATA_TYPE real_4", &
1124                          default_i_val=dbcsr_type_real_8, &
1125                          enum_c_vals=s2a("real_4", "real_8", "complex_4", "complex_8"), &
1126                          enum_i_vals=(/dbcsr_type_real_4, dbcsr_type_real_8, &
1127                                        dbcsr_type_complex_4, dbcsr_type_complex_8/), &
1128                          enum_desc=s2a( &
1129                          "Real (Single Precision)", &
1130                          "Real (Double Precision)", &
1131                          "Complex (Single Precision)", &
1132                          "Complex (Double Precision)"))
1133      CALL section_add_keyword(section, keyword)
1134      CALL keyword_release(keyword)
1135
1136      CALL keyword_create(keyword, __LOCATION__, name="TEST_TYPE", &
1137                          description="Which part of DBCSR is tested", &
1138                          usage="TEST_TYPE MM", &
1139                          default_i_val=dbcsr_test_mm, &
1140                          enum_c_vals=s2a("MM", "Binary_IO"), &
1141                          enum_i_vals=(/dbcsr_test_mm, dbcsr_test_binary_io/), &
1142                          enum_desc=s2a( &
1143                          "Run matrix multiplications", &
1144                          "Run binary IO checks"))
1145      CALL section_add_keyword(section, keyword)
1146      CALL keyword_release(keyword)
1147
1148      CALL keyword_create(keyword, __LOCATION__, name="M", &
1149                          description="Dimension 1 of C", &
1150                          usage="A 1024", default_i_val=256)
1151      CALL section_add_keyword(section, keyword)
1152      CALL keyword_release(keyword)
1153      CALL keyword_create(keyword, __LOCATION__, name="N", &
1154                          description="Dimension 2 of C", &
1155                          usage="A 1024", default_i_val=256)
1156      CALL section_add_keyword(section, keyword)
1157      CALL keyword_release(keyword)
1158      CALL keyword_create(keyword, __LOCATION__, name="K", &
1159                          description="Inner dimension M   ", &
1160                          usage="A 1024", default_i_val=256)
1161      CALL section_add_keyword(section, keyword)
1162      CALL keyword_release(keyword)
1163
1164      CALL keyword_create(keyword, __LOCATION__, name="TRANSA", &
1165                          description="Transpose matrix A", &
1166                          usage="TRANSA", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1167      CALL section_add_keyword(section, keyword)
1168      CALL keyword_release(keyword)
1169
1170      CALL keyword_create(keyword, __LOCATION__, name="TRANSB", &
1171                          description="Transpose matrix B", &
1172                          usage="TRANSB", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1173      CALL section_add_keyword(section, keyword)
1174      CALL keyword_release(keyword)
1175
1176      CALL keyword_create(keyword, __LOCATION__, name="BS_M", &
1177                          description="Row block sizes of C", n_var=-1, &
1178                          usage="BS_M 1 13 2 5", default_i_vals=(/1, 13, 2, 15/))
1179      CALL section_add_keyword(section, keyword)
1180      CALL keyword_release(keyword)
1181
1182      CALL keyword_create(keyword, __LOCATION__, name="BS_N", &
1183                          description="Column block sizes of C", n_var=-1, &
1184                          usage="BS_N 1 13 2 5", default_i_vals=(/1, 13, 2, 15/))
1185      CALL section_add_keyword(section, keyword)
1186      CALL keyword_release(keyword)
1187
1188      CALL keyword_create(keyword, __LOCATION__, name="BS_K", &
1189                          description="Block sizes of inner dimension", n_var=-1, &
1190                          usage="BS_K 1 13 2 5", default_i_vals=(/1, 13, 2, 15/))
1191      CALL section_add_keyword(section, keyword)
1192      CALL keyword_release(keyword)
1193
1194      CALL keyword_create(keyword, __LOCATION__, name="ATYPE", &
1195                          description="Matrix A type", &
1196                          usage="ATYPE N", default_c_val='N')
1197      CALL section_add_keyword(section, keyword)
1198      CALL keyword_release(keyword)
1199      CALL keyword_create(keyword, __LOCATION__, name="BTYPE", &
1200                          description="Matrix B type", &
1201                          usage="BTYPE N", default_c_val='N')
1202      CALL section_add_keyword(section, keyword)
1203      CALL keyword_release(keyword)
1204      CALL keyword_create(keyword, __LOCATION__, name="CTYPE", &
1205                          description="Matrix C type", &
1206                          usage="CTYPE N", default_c_val='N')
1207      CALL section_add_keyword(section, keyword)
1208      CALL keyword_release(keyword)
1209
1210      CALL keyword_create(keyword, __LOCATION__, name="NPROC", &
1211                          description="Number of processors to test", n_var=-1, &
1212                          usage="NPROC 128 16 1", default_i_vals=(/0/))
1213      CALL section_add_keyword(section, keyword)
1214      CALL keyword_release(keyword)
1215
1216      CALL keyword_create(keyword, __LOCATION__, name="KEEPSPARSE", &
1217                          description="Keep product sparse", &
1218                          usage="KEEPSPARSE", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1219      CALL section_add_keyword(section, keyword)
1220      CALL keyword_release(keyword)
1221
1222      CALL keyword_create(keyword, __LOCATION__, name="ASPARSITY", &
1223                          description="Sparsity of A matrix", &
1224                          usage="ASPARSITY 70", default_r_val=0.0_dp)
1225      CALL section_add_keyword(section, keyword)
1226      CALL keyword_release(keyword)
1227
1228      CALL keyword_create(keyword, __LOCATION__, name="BSPARSITY", &
1229                          description="Sparsity of B matrix", &
1230                          usage="ASPARSITY 80", default_r_val=0.0_dp)
1231      CALL section_add_keyword(section, keyword)
1232      CALL keyword_release(keyword)
1233
1234      CALL keyword_create(keyword, __LOCATION__, name="CSPARSITY", &
1235                          description="Sparsity of C matrix", &
1236                          usage="ASPARSITY 90", default_r_val=0.0_dp)
1237      CALL section_add_keyword(section, keyword)
1238      CALL keyword_release(keyword)
1239
1240      CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
1241                          description="Multiplication factor", &
1242                          usage="ALPHA 2.0", default_r_val=1.0_dp)
1243      CALL section_add_keyword(section, keyword)
1244      CALL keyword_release(keyword)
1245
1246      CALL keyword_create(keyword, __LOCATION__, name="BETA", &
1247                          description="Product premultiplication factor", &
1248                          usage="BETA 1.0", default_r_val=0.0_dp)
1249      CALL section_add_keyword(section, keyword)
1250      CALL keyword_release(keyword)
1251
1252      CALL keyword_create(keyword, __LOCATION__, name="FILTER_EPS", &
1253                          description="Threshold for on-the-fly and final filtering.", &
1254                          usage="FILTER_EPS 1.0", default_r_val=-1.0_dp)
1255      CALL section_add_keyword(section, keyword)
1256      CALL keyword_release(keyword)
1257
1258      CALL keyword_create(keyword, __LOCATION__, name="ALWAYS_CHECKSUM", &
1259                          description="perform a checksum after each multiplication", &
1260                          usage="ALWAYS_CHECKSUM", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
1261      CALL section_add_keyword(section, keyword)
1262      CALL keyword_release(keyword)
1263
1264   END SUBROUTINE create_cp_dbcsr_section
1265
1266END MODULE input_cp2k
1267