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