(git:fc9bb57)
Loading...
Searching...
No Matches
input_cp2k_check.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief checks the input and perform some automatic "magic" on it
10!> \par History
11!> 01.2006 created [fawzi]
12!> \author fawzi
13! **************************************************************************************************
19 USE cp_units, ONLY: cp_unit_set_create,&
22 USE input_constants, ONLY: &
30 USE input_section_types, ONLY: &
35 USE input_val_types, ONLY: logical_t
36 USE kinds, ONLY: default_path_length,&
38 dp
42#include "./base/base_uses.f90"
43
44 IMPLICIT NONE
45 PRIVATE
46
47 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
48 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_check'
49
51
52CONTAINS
53
54! **************************************************************************************************
55!> \brief performs further checks on an input that parsed successfully
56!> \param input_declaration ...
57!> \param input_file the parsed input
58!> \param para_env ...
59!> \param output_unit ...
60!> \author fawzi
61!> \note
62!> at the moment does nothing
63! **************************************************************************************************
64 SUBROUTINE check_cp2k_input(input_declaration, input_file, para_env, output_unit)
65 TYPE(section_type), POINTER :: input_declaration
66 TYPE(section_vals_type), POINTER :: input_file
67 TYPE(mp_para_env_type), POINTER :: para_env
68 INTEGER, INTENT(IN), OPTIONAL :: output_unit
69
70 CHARACTER(len=*), PARAMETER :: routinen = 'check_cp2k_input'
71
72 INTEGER :: force_eval_method, handle, iforce_eval, &
73 nforce_eval, run_type
74 LOGICAL :: apply_ext_potential, do_center, &
75 explicit, explicit_embed, explicit_mix
76 TYPE(section_vals_type), POINTER :: section, section1, section2, section3, &
77 section4, sections
78
79 CALL timeset(routinen, handle)
80 cpassert(ASSOCIATED(input_file))
81 cpassert(input_file%ref_count > 0)
82 ! ext_restart
83 IF (PRESENT(output_unit)) THEN
84 CALL handle_ext_restart(input_declaration, input_file, para_env, output_unit)
85 END IF
86
87 ! checks on force_eval section
88 sections => section_vals_get_subs_vals(input_file, "FORCE_EVAL")
89 CALL section_vals_get(sections, n_repetition=nforce_eval)
90
91 ! multiple force_eval only if present RESPA, or MIXED or EMBED calculation is performed
92 section2 => section_vals_get_subs_vals(input_file, "MOTION%MD%RESPA")
93 CALL section_vals_get(section2, explicit=explicit)
94 DO iforce_eval = 1, nforce_eval
95 section3 => section_vals_get_subs_vals(sections, "MIXED", &
96 i_rep_section=iforce_eval)
97 CALL section_vals_get(section3, explicit=explicit_mix)
98 IF (explicit_mix) EXIT
99 END DO
100 DO iforce_eval = 1, nforce_eval
101 section4 => section_vals_get_subs_vals(sections, "EMBED", &
102 i_rep_section=iforce_eval)
103 CALL section_vals_get(section4, explicit=explicit_embed)
104 IF (explicit_embed) EXIT
105 END DO
106 ! also allow multiple force_eval for NEGF run
107 CALL section_vals_val_get(input_file, "GLOBAL%RUN_TYPE", i_val=run_type)
108
109 IF (((explicit .AND. (nforce_eval == 1)) .OR. (.NOT. explicit .AND. (nforce_eval > 1))) .AND. run_type /= negf_run) THEN
110 IF ((explicit_mix .AND. (nforce_eval == 1)) .OR. (.NOT. explicit_mix .AND. (nforce_eval > 1))) THEN
111 IF ((explicit_embed .AND. (nforce_eval == 1)) .OR. (.NOT. explicit_embed .AND. (nforce_eval > 1))) THEN
112 CALL cp_abort(__location__, &
113 "Error multiple force_env without RESPA or MIXED or EMBED, or RESPA with one single "// &
114 "or MIXED with only two force_env section.")
115 END IF
116 END IF
117 END IF
118 DO iforce_eval = 1, nforce_eval
119 section => section_vals_get_subs_vals3(sections, "DFT", i_rep_section=iforce_eval)
120 ! xc: expand and fix default for tddfpt
121 section1 => section_vals_get_subs_vals(section, "XC")
122 section2 => section_vals_get_subs_vals(section, "XC%XC_FUNCTIONAL")
123 CALL xc_functionals_expand(section2, section1)
124 section1 => section_vals_get_subs_vals(section, "XAS_TDP%KERNEL")
125 section2 => section_vals_get_subs_vals(section, "XAS_TDP%KERNEL%XC_FUNCTIONAL")
126 CALL xc_functionals_expand(section2, section1)
127 section1 => section_vals_get_subs_vals(sections, "PROPERTIES%RIXS%XAS_TDP%KERNEL")
128 section2 => section_vals_get_subs_vals(sections, "PROPERTIES%RIXS%XAS_TDP%KERNEL%XC_FUNCTIONAL")
129 CALL xc_functionals_expand(section2, section1)
130 section1 => section_vals_get_subs_vals(section, "ACTIVE_SPACE%XC")
131 section2 => section_vals_get_subs_vals(section, "ACTIVE_SPACE%XC%XC_FUNCTIONAL")
132 CALL xc_functionals_expand(section2, section1)
133 END DO
134
135 ! additional checks for a MiMiC run
136 IF (run_type == mimic_run) THEN
137 ! disable CENTER_COORDINATES
138 CALL section_vals_val_get(sections, "SUBSYS%TOPOLOGY%CENTER_COORDINATES%_SECTION_PARAMETERS_", &
139 l_val=do_center)
140 IF (do_center) THEN
141 CALL section_vals_val_set(sections, &
142 "SUBSYS%TOPOLOGY%CENTER_COORDINATES%_SECTION_PARAMETERS_", &
143 l_val=.false.)
144 cpwarn("Turning off CENTER_COORDINATES for a MiMiC run.")
145 END IF
146
147 ! do not allow the use of external potential
148 section => section_vals_get_subs_vals(sections, "DFT%EXTERNAL_POTENTIAL")
149 CALL section_vals_get(section, explicit=apply_ext_potential)
150 IF (apply_ext_potential) THEN
151 cpabort("The EXTERNAL_POTENTIAL section is not allowed for the MiMiC runtype.")
152 END IF
153
154 ! force eval methods supported with MiMiC
155 CALL section_vals_val_get(sections, "METHOD", i_val=force_eval_method)
156 IF (force_eval_method /= do_qs) THEN
157 cpabort("At the moment, only Quickstep method is supported with MiMiC.")
158 END IF
159 END IF
160
161 CALL timestop(handle)
162 END SUBROUTINE check_cp2k_input
163
164! **************************************************************************************************
165!> \brief expand a shortcutted functional section
166!> \param functionals the functional section to expand
167!> \param xc_section ...
168!> \author fawzi
169! **************************************************************************************************
170 SUBROUTINE xc_functionals_expand(functionals, xc_section)
171 TYPE(section_vals_type), POINTER :: functionals, xc_section
172
173 CHARACTER(LEN=512) :: wrn_msg
174 INTEGER :: ifun, nfun, shortcut
175 TYPE(section_vals_type), POINTER :: xc_fun
176
177 CALL section_vals_val_get(functionals, "_SECTION_PARAMETERS_", &
178 i_val=shortcut)
179
180 ifun = 0
181 nfun = 0
182 DO
183 ifun = ifun + 1
184 xc_fun => section_vals_get_subs_vals2(functionals, i_section=ifun)
185 IF (.NOT. ASSOCIATED(xc_fun)) EXIT
186 nfun = nfun + 1
187 END DO
188!
189 IF (shortcut /= xc_funct_no_shortcut .AND. shortcut /= xc_none .AND. nfun > 0) THEN
190 WRITE (wrn_msg, '(A)') "User requested a shortcut while defining an explicit XC functional. "// &
191 "This is not recommended as it could lead to spurious behaviour. Please check input parameters."
192 cpwarn(wrn_msg)
193 END IF
194
195 SELECT CASE (shortcut)
197 ! nothing to expand
198 CASE (xc_funct_pbe0)
199 CALL section_vals_val_set(functionals, "PBE%_SECTION_PARAMETERS_", &
200 l_val=.true.)
201 CALL section_vals_val_set(functionals, "PBE%SCALE_X", &
202 r_val=0.75_dp)
203 CALL section_vals_val_set(functionals, "PBE%SCALE_C", &
204 r_val=1.0_dp)
205 ! Hartree Fock Exact Exchange
206 CALL section_vals_val_set(xc_section, "HF%FRACTION", &
207 r_val=0.25_dp)
208 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
210 CASE (xc_funct_beefvdw)
211 CALL section_vals_val_set(functionals, "PBE%_SECTION_PARAMETERS_", & !40% PBEc
212 l_val=.true.)
213 CALL section_vals_val_set(functionals, "PBE%SCALE_C", &
214 r_val=0.3998335231_dp)
215 CALL section_vals_val_set(functionals, "PBE%SCALE_X", & !no PBEx
216 r_val=0.0000000000_dp)
217
218 !PW92 correlation functional from libxc is required.
219 !The cp2k-native PW92 gives disagreeing results (in the 0.01E_H
220 !decimal) and yields inconsistent forces in a DEBUG run.
221 !(rk, 6.3.2014)
222 CALL section_vals_val_set(functionals, "LDA_C_PW%_SECTION_PARAMETERS_", & !60%LDA
223 l_val=.true.)
224 CALL section_vals_val_set(functionals, "LDA_C_PW%SCALE", &
225 r_val=0.6001664769_dp)
226
227 CALL section_vals_val_set(functionals, "BEEF%_SECTION_PARAMETERS_", & !BEEF exchange
228 l_val=.true.)
229
230 !NONLOCAL, LMKLL.
231 CALL section_vals_val_set(xc_section, "VDW_POTENTIAL%DISPERSION_FUNCTIONAL", &
232 i_val=xc_vdw_fun_nonloc)
233 CALL section_vals_val_set(xc_section, "VDW_POTENTIAL%NON_LOCAL%TYPE", &
234 i_val=vdw_nl_lmkll)
235 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
237 CASE (xc_funct_b3lyp)
238 CALL section_vals_val_set(functionals, "BECKE88%_SECTION_PARAMETERS_", &
239 l_val=.true.)
240 CALL section_vals_val_set(functionals, "BECKE88%SCALE_X", &
241 r_val=0.72_dp)
242 CALL section_vals_val_set(functionals, "LYP%_SECTION_PARAMETERS_", &
243 l_val=.true.)
244 CALL section_vals_val_set(functionals, "LYP%SCALE_C", &
245 r_val=0.81_dp)
246 CALL section_vals_val_set(functionals, "VWN%_SECTION_PARAMETERS_", &
247 l_val=.true.)
248 CALL section_vals_val_set(functionals, "VWN%FUNCTIONAL_TYPE", &
249 i_val=do_vwn5)
250 CALL section_vals_val_set(functionals, "VWN%SCALE_C", &
251 r_val=0.19_dp)
252 CALL section_vals_val_set(functionals, "XALPHA%_SECTION_PARAMETERS_", &
253 l_val=.true.)
254 CALL section_vals_val_set(functionals, "XALPHA%SCALE_X", &
255 r_val=0.08_dp)
256 ! Hartree Fock Exact Exchange
257 CALL section_vals_val_set(xc_section, "HF%FRACTION", &
258 r_val=0.20_dp)
259 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
261 CASE (xc_funct_blyp)
262 CALL section_vals_val_set(functionals, "BECKE88%_SECTION_PARAMETERS_", &
263 l_val=.true.)
264 CALL section_vals_val_set(functionals, "LYP%_SECTION_PARAMETERS_", &
265 l_val=.true.)
266 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
268 CASE (xc_funct_bp)
269 CALL section_vals_val_set(functionals, "BECKE88%_SECTION_PARAMETERS_", &
270 l_val=.true.)
271 CALL section_vals_val_set(functionals, "P86C%_SECTION_PARAMETERS_", &
272 l_val=.true.)
273 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
275 CASE (xc_funct_pade)
276 CALL section_vals_val_set(functionals, "PADE%_SECTION_PARAMETERS_", &
277 l_val=.true.)
278 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
280 CASE (xc_funct_pbe)
281 CALL section_vals_val_set(functionals, "PBE%_SECTION_PARAMETERS_", &
282 l_val=.true.)
283 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
285 CASE (xc_funct_xwpbe)
286 CALL section_vals_val_set(functionals, "XWPBE%_SECTION_PARAMETERS_", &
287 l_val=.true.)
288 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
290 CASE (xc_funct_tpss)
291 CALL section_vals_val_set(functionals, "TPSS%_SECTION_PARAMETERS_", &
292 l_val=.true.)
293 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
295 CASE (xc_funct_olyp)
296 CALL section_vals_val_set(functionals, "OPTX%_SECTION_PARAMETERS_", &
297 l_val=.true.)
298 CALL section_vals_val_set(functionals, "LYP%_SECTION_PARAMETERS_", &
299 l_val=.true.)
300 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
302 CASE (xc_funct_hcth120)
303 CALL section_vals_val_set(functionals, "HCTH%_SECTION_PARAMETERS_", &
304 l_val=.true.)
305 CALL section_vals_val_set(functionals, "HCTH%PARAMETER_SET", &
306 i_val=120)
307 CALL section_vals_val_set(functionals, "_SECTION_PARAMETERS_", &
309 CASE default
310 cpabort("unknown shortcut "//trim(adjustl(cp_to_string(shortcut))))
311 END SELECT
312 END SUBROUTINE xc_functionals_expand
313
314! **************************************************************************************************
315!> \brief Replaces the requested sections in the input with those found
316!> in the external restart (EXT_RESTART%RESTART_FILE_NAME).
317!> \param input_declaration ...
318!> \param input_file the input file to initialize
319!> \param para_env ...
320!> \param output_unit ...
321!> \author fawzi
322! **************************************************************************************************
323 SUBROUTINE handle_ext_restart(input_declaration, input_file, para_env, output_unit)
324 TYPE(section_type), POINTER :: input_declaration
325 TYPE(section_vals_type), POINTER :: input_file
326 TYPE(mp_para_env_type), POINTER :: para_env
327 INTEGER, INTENT(IN) :: output_unit
328
329 CHARACTER(len=*), PARAMETER :: routinen = 'handle_ext_restart'
330
331 CHARACTER(default_path_length) :: r_file_path
332 INTEGER :: handle
333 TYPE(section_vals_type), POINTER :: r_section
334
335 CALL timeset(routinen, handle)
336 ! Handle restart file
337 r_section => section_vals_get_subs_vals(input_file, "EXT_RESTART")
338 CALL section_vals_val_get(r_section, "RESTART_FILE_NAME", c_val=r_file_path)
339
340 IF (r_file_path /= " ") THEN
341 block
342 CHARACTER(default_path_length) :: binary_restart_file
343 CHARACTER(default_string_length) :: path
344 CHARACTER(LEN=default_string_length), &
345 DIMENSION(:), POINTER :: restarted_infos
346 INTEGER :: ensemble, i_rep_val, &
347 iforce_eval, myi, n_rep_val, &
348 nforce_eval1, nforce_eval2
349 INTEGER, DIMENSION(:), POINTER :: ivec, iwalkers_status, iwork, &
350 rwalkers_status
351 LOGICAL :: bsse_check, check, explicit1, explicit2, &
352 flag, flag2, qmmm_check, subsys_check
353 REAL(kind=dp) :: myt
354 REAL(kind=dp), DIMENSION(:), POINTER :: vec, work
355 TYPE(section_vals_type), POINTER :: rep_sections, restart_file, &
356 section, section1, section2, &
357 sections1, sections2
358
359 NULLIFY (restarted_infos, iwalkers_status, rwalkers_status, vec, ivec, work, iwork)
360 CALL section_vals_val_get(r_section, "BINARY_RESTART_FILE_NAME", c_val=binary_restart_file)
361
362 block
363 TYPE(cp_parser_type) :: cpparser
364 TYPE(cp_unit_set_type) :: default_units
365 ! parse the input
366 NULLIFY (restart_file)
367 CALL section_vals_create(restart_file, input_declaration)
368 CALL parser_create(cpparser, file_name=r_file_path, para_env=para_env)
369 CALL cp_unit_set_create(default_units, "OUTPUT")
370 CALL section_vals_parse(restart_file, cpparser, root_section=.false., &
371 default_units=default_units)
372 CALL cp_unit_set_release(default_units)
373 CALL parser_release(cpparser)
374 END block
375
376 ! Restart and input files same number of force_env sections
377 sections1 => section_vals_get_subs_vals(restart_file, "FORCE_EVAL")
378 CALL section_vals_get(sections1, n_repetition=nforce_eval1)
379 sections2 => section_vals_get_subs_vals(input_file, "FORCE_EVAL")
380 CALL section_vals_get(sections2, n_repetition=nforce_eval2)
381 IF (nforce_eval1 /= nforce_eval2) THEN
382 cpabort("Restart and input file MUST have the number of force_env sections")
383 END IF
384 ! Handle default restarts
385 CALL handle_defaults_restart(r_section)
386
387 ! Real restart of force_evals
388 DO iforce_eval = 1, nforce_eval1
389 section1 => section_vals_get_subs_vals3(sections1, "SUBSYS", &
390 i_rep_section=iforce_eval)
391 section2 => section_vals_get_subs_vals3(sections2, "SUBSYS", &
392 i_rep_section=iforce_eval)
393 ! Some care needs to be handled when treating multiple force_eval
394 ! Both subsys need to be consistently associated or not
395 ! Mixed stuff will be rejected for safety reason..
396 subsys_check = (ASSOCIATED(section1) .EQV. ASSOCIATED(section2))
397 IF (subsys_check) THEN
398 IF (ASSOCIATED(section1)) THEN
399 CALL section_vals_val_get(r_section, "RESTART_CELL", l_val=flag)
400 IF (flag) THEN
401 section => section_vals_get_subs_vals(section1, "CELL")
402 CALL section_vals_set_subs_vals(section2, "CELL", section)
403 CALL set_restart_info("CELL", restarted_infos)
404 END IF
405
406 CALL section_vals_val_get(r_section, "RESTART_POS", l_val=flag)
407 IF (flag) THEN
408 section => section_vals_get_subs_vals(section1, "COORD")
409 CALL section_vals_set_subs_vals(section2, "COORD", section)
410 CALL set_restart_info("COORDINATES", restarted_infos)
411 ! Copy over also the information on the multiple_unit_cell
412 CALL section_vals_val_get(section1, "TOPOLOGY%MULTIPLE_UNIT_CELL", i_vals=ivec)
413 ALLOCATE (iwork(3))
414 iwork = ivec
415 CALL section_vals_val_set(section2, "TOPOLOGY%MULTIPLE_UNIT_CELL", i_vals_ptr=iwork)
416 END IF
417
418 CALL section_vals_val_get(r_section, "RESTART_RANDOMG", l_val=flag)
419 IF (flag) THEN
420 section => section_vals_get_subs_vals(section1, "RNG_INIT")
421 CALL section_vals_set_subs_vals(section2, "RNG_INIT", section)
422 CALL set_restart_info("RANDOM NUMBER GENERATOR", restarted_infos)
423 END IF
424
425 CALL section_vals_val_get(r_section, "RESTART_VEL", l_val=flag)
426 IF (flag) THEN
427 section => section_vals_get_subs_vals(section1, "VELOCITY")
428 CALL section_vals_set_subs_vals(section2, "VELOCITY", section)
429 CALL set_restart_info("VELOCITIES", restarted_infos)
430 END IF
431
432 ! Core-Shell information "restarted" only when strictly necessary
433 CALL section_vals_val_get(r_section, "RESTART_SHELL_POS", l_val=flag)
434 IF (flag) THEN
435 section => section_vals_get_subs_vals(section1, "SHELL_COORD")
436 CALL section_vals_set_subs_vals(section2, "SHELL_COORD", section)
437 IF (check_restart(section1, section2, "SHELL_COORD")) THEN
438 CALL set_restart_info("SHELL COORDINATES", restarted_infos)
439 END IF
440 END IF
441 CALL section_vals_val_get(r_section, "RESTART_CORE_POS", l_val=flag)
442 IF (flag) THEN
443 section => section_vals_get_subs_vals(section1, "CORE_COORD")
444 CALL section_vals_set_subs_vals(section2, "CORE_COORD", section)
445 IF (check_restart(section1, section2, "CORE_COORD")) THEN
446 CALL set_restart_info("CORE COORDINATES", restarted_infos)
447 END IF
448 END IF
449 CALL section_vals_val_get(r_section, "RESTART_SHELL_VELOCITY", l_val=flag)
450 IF (flag) THEN
451 section => section_vals_get_subs_vals(section1, "SHELL_VELOCITY")
452 CALL section_vals_set_subs_vals(section2, "SHELL_VELOCITY", section)
453 IF (check_restart(section1, section2, "SHELL_VELOCITY")) THEN
454 CALL set_restart_info("SHELL VELOCITIES", restarted_infos)
455 END IF
456 END IF
457 CALL section_vals_val_get(r_section, "RESTART_CORE_VELOCITY", l_val=flag)
458 IF (flag) THEN
459 section => section_vals_get_subs_vals(section1, "CORE_VELOCITY")
460 CALL section_vals_set_subs_vals(section2, "CORE_VELOCITY", section)
461 IF (check_restart(section1, section2, "CORE_VELOCITY")) THEN
462 CALL set_restart_info("CORE VELOCITIES", restarted_infos)
463 END IF
464 END IF
465 END IF
466 ELSE
467 CALL cp_abort(__location__, &
468 "Error while reading the restart file. Two force_eval have incompatible"// &
469 " subsys.One of them has an allocated subsys while the other has not! Check your"// &
470 " input file or whether the restart file is compatible with the input!")
471 END IF
472 ! QMMM restarts
473 CALL section_vals_val_get(r_section, "RESTART_QMMM", l_val=flag)
474 section1 => section_vals_get_subs_vals3(sections1, "QMMM", i_rep_section=iforce_eval)
475 section2 => section_vals_get_subs_vals3(sections2, "QMMM", i_rep_section=iforce_eval)
476 CALL section_vals_get(section1, explicit=explicit1)
477 CALL section_vals_get(section2, explicit=explicit2)
478 qmmm_check = (explicit1 .AND. explicit2)
479 IF (flag .AND. qmmm_check) THEN
480 CALL set_restart_info("QMMM TRANSLATION VECTOR", restarted_infos)
481 CALL section_vals_val_get(section1, "INITIAL_TRANSLATION_VECTOR", r_vals=vec)
482 ALLOCATE (work(3))
483 work = vec
484 CALL section_vals_val_set(section2, "INITIAL_TRANSLATION_VECTOR", r_vals_ptr=work)
485 END IF
486 ! BSSE restarts
487 CALL section_vals_val_get(r_section, "RESTART_BSSE", l_val=flag)
488 section1 => section_vals_get_subs_vals3(sections1, "BSSE", i_rep_section=iforce_eval)
489 section2 => section_vals_get_subs_vals3(sections2, "BSSE", i_rep_section=iforce_eval)
490 CALL section_vals_get(section1, explicit=explicit1)
491 CALL section_vals_get(section2, explicit=explicit2)
492 bsse_check = (explicit1 .AND. explicit2)
493 IF (flag .AND. bsse_check) THEN
494 section => section_vals_get_subs_vals(section1, "FRAGMENT_ENERGIES")
495 CALL section_vals_set_subs_vals(section2, "FRAGMENT_ENERGIES", section)
496 CALL set_restart_info("BSSE FRAGMENT ENERGIES", restarted_infos)
497 END IF
498 END DO
499
500 CALL section_vals_val_get(r_section, "RESTART_COUNTERS", l_val=flag)
501 IF (flag) THEN
502 IF (check_restart(input_file, restart_file, "MOTION%MD")) THEN
503 CALL section_vals_val_get(restart_file, "MOTION%MD%STEP_START_VAL", i_val=myi)
504 CALL section_vals_val_set(input_file, "MOTION%MD%STEP_START_VAL", i_val=myi)
505 CALL section_vals_val_get(restart_file, "MOTION%MD%TIME_START_VAL", r_val=myt)
506 CALL section_vals_val_set(input_file, "MOTION%MD%TIME_START_VAL", r_val=myt)
507 CALL section_vals_val_get(restart_file, "MOTION%MD%ECONS_START_VAL", r_val=myt)
508 CALL section_vals_val_set(input_file, "MOTION%MD%ECONS_START_VAL", r_val=myt)
509 CALL set_restart_info("MD COUNTERS", restarted_infos)
510 END IF
511 !
512 IF (check_restart(input_file, restart_file, "MOTION%GEO_OPT")) THEN
513 ! GEO_OPT
514 CALL section_vals_val_get(restart_file, "MOTION%GEO_OPT%STEP_START_VAL", i_val=myi)
515 CALL section_vals_val_set(input_file, "MOTION%GEO_OPT%STEP_START_VAL", i_val=myi)
516 CALL set_restart_info("GEO_OPT COUNTERS", restarted_infos)
517 ! ROT_OPT
518 IF (check_restart(input_file, restart_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%ROT_OPT")) THEN
519 CALL section_vals_val_get(restart_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%ROT_OPT%STEP_START_VAL", &
520 i_val=myi)
521 CALL section_vals_val_set(input_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%ROT_OPT%STEP_START_VAL", &
522 i_val=myi)
523 CALL set_restart_info("ROT_OPT COUNTERS", restarted_infos)
524 END IF
525 END IF
526 !
527 IF (check_restart(input_file, restart_file, "MOTION%GEO_OPT")) THEN
528 ! CELL_OPT
529 CALL section_vals_val_get(restart_file, "MOTION%CELL_OPT%STEP_START_VAL", i_val=myi)
530 CALL section_vals_val_set(input_file, "MOTION%CELL_OPT%STEP_START_VAL", i_val=myi)
531 CALL set_restart_info("CELL_OPT COUNTERS", restarted_infos)
532 END IF
533 !
534 IF (check_restart(input_file, restart_file, "OPTIMIZE_INPUT")) THEN
535 CALL section_vals_val_get(restart_file, "OPTIMIZE_INPUT%ITER_START_VAL", i_val=myi)
536 CALL section_vals_val_set(input_file, "OPTIMIZE_INPUT%ITER_START_VAL", i_val=myi)
537 CALL set_restart_info("OPTIMIZE_INPUT ITERATION NUMBER", restarted_infos)
538 END IF
539 !
540 IF (check_restart(input_file, restart_file, "MOTION%PINT")) THEN
541 ! PINT
542 CALL section_vals_val_get(restart_file, "MOTION%PINT%ITERATION", i_val=myi)
543 CALL section_vals_val_set(input_file, "MOTION%PINT%ITERATION", i_val=myi)
544 CALL set_restart_info("PINT ITERATION NUMBER", restarted_infos)
545 END IF
546 !
547 CALL section_vals_val_get(r_section, "RESTART_METADYNAMICS", l_val=flag2)
548 IF (flag2 .AND. check_restart(input_file, restart_file, "MOTION%FREE_ENERGY%METADYN")) THEN
549 CALL section_vals_val_get(restart_file, &
550 "MOTION%FREE_ENERGY%METADYN%STEP_START_VAL", i_val=myi)
551 CALL section_vals_val_set(input_file, &
552 "MOTION%FREE_ENERGY%METADYN%STEP_START_VAL", i_val=myi)
553 CALL section_vals_val_get(restart_file, &
554 "MOTION%FREE_ENERGY%METADYN%NHILLS_START_VAL", i_val=myi)
555 CALL section_vals_val_set(input_file, &
556 "MOTION%FREE_ENERGY%METADYN%NHILLS_START_VAL", i_val=myi)
557 !RG Adaptive hills
558 CALL section_vals_val_get(restart_file, &
559 "MOTION%FREE_ENERGY%METADYN%OLD_HILL_NUMBER", i_val=myi)
560 CALL section_vals_val_set(input_file, &
561 "MOTION%FREE_ENERGY%METADYN%OLD_HILL_NUMBER", i_val=myi)
562 CALL section_vals_val_get(restart_file, &
563 "MOTION%FREE_ENERGY%METADYN%OLD_HILL_STEP", i_val=myi)
564 CALL section_vals_val_set(input_file, &
565 "MOTION%FREE_ENERGY%METADYN%OLD_HILL_STEP", i_val=myi)
566 !RG Adaptive hills
567 CALL set_restart_info("METADYNAMIC COUNTERS", restarted_infos)
568 END IF
569 END IF
570
571 CALL section_vals_val_get(r_section, "RESTART_AVERAGES", l_val=flag)
572 IF (flag) THEN
573 IF (check_restart(input_file, restart_file, "MOTION%MD")) THEN
574 rep_sections => section_vals_get_subs_vals(restart_file, "MOTION%MD%AVERAGES%RESTART_AVERAGES")
575 CALL section_vals_set_subs_vals(input_file, "MOTION%MD%AVERAGES%RESTART_AVERAGES", rep_sections)
576 CALL set_restart_info("MD AVERAGES", restarted_infos)
577 END IF
578 END IF
579
580 CALL section_vals_val_get(r_section, "RESTART_BAND", l_val=flag)
581 IF (flag .AND. check_restart(input_file, restart_file, "MOTION%BAND")) THEN
582 rep_sections => section_vals_get_subs_vals(restart_file, "MOTION%BAND%REPLICA")
583 CALL section_vals_set_subs_vals(input_file, "MOTION%BAND%REPLICA", rep_sections)
584 CALL set_restart_info("BAND CALCULATION", restarted_infos)
585 END IF
586
587 CALL section_vals_val_get(r_section, "RESTART_OPTIMIZE_INPUT_VARIABLES", l_val=flag)
588 IF (flag .AND. check_restart(input_file, restart_file, "OPTIMIZE_INPUT%VARIABLE")) THEN
589 rep_sections => section_vals_get_subs_vals(restart_file, "OPTIMIZE_INPUT%VARIABLE")
590 CALL section_vals_set_subs_vals(input_file, "OPTIMIZE_INPUT%VARIABLE", rep_sections)
591 CALL set_restart_info("OPTIMIZE_INPUT: VARIABLES", restarted_infos)
592 END IF
593
594 CALL section_vals_val_get(r_section, "RESTART_BAROSTAT", l_val=flag)
595 IF (flag .AND. check_restart(input_file, restart_file, "MOTION%MD%BAROSTAT")) THEN
596 section => section_vals_get_subs_vals(restart_file, &
597 "MOTION%MD%BAROSTAT%MASS")
598 CALL section_vals_set_subs_vals(input_file, "MOTION%MD%BAROSTAT%MASS", &
599 section)
600 section => section_vals_get_subs_vals(restart_file, &
601 "MOTION%MD%BAROSTAT%VELOCITY")
602 CALL section_vals_set_subs_vals(input_file, "MOTION%MD%BAROSTAT%VELOCITY", &
603 section)
604 CALL set_restart_info("BAROSTAT", restarted_infos)
605 END IF
606
607 flag = check_restart(input_file, restart_file, "MOTION%MD")
608 IF (flag) THEN
609 CALL section_vals_val_get(input_file, "MOTION%MD%ENSEMBLE", i_val=ensemble)
610 IF (ensemble == npt_i_ensemble .OR. ensemble == npt_f_ensemble .OR. ensemble == npt_ia_ensemble) THEN
611 CALL section_vals_val_get(r_section, "RESTART_BAROSTAT_THERMOSTAT", l_val=flag)
612 check = check_restart(input_file, restart_file, "MOTION%MD%BAROSTAT")
613 CALL restart_thermostat(flag, input_file, restart_file, "MOTION%MD%BAROSTAT%THERMOSTAT", &
614 check=check)
615 IF (flag .AND. check) CALL set_restart_info("THERMOSTAT OF BAROSTAT", restarted_infos)
616 END IF
617 END IF
618
619 check = check_restart(input_file, restart_file, "MOTION%MD%SHELL")
620 IF (check) THEN
621 CALL section_vals_val_get(r_section, "RESTART_SHELL_THERMOSTAT", l_val=flag)
622 CALL restart_thermostat(flag, input_file, restart_file, "MOTION%MD%SHELL%THERMOSTAT")
623 CALL set_restart_info("SHELL THERMOSTAT", restarted_infos)
624 END IF
625
626 CALL section_vals_val_get(r_section, "RESTART_THERMOSTAT", l_val=flag)
627 CALL restart_thermostat(flag, input_file, restart_file, "MOTION%MD%THERMOSTAT")
628 IF (flag) CALL set_restart_info("PARTICLE THERMOSTAT", restarted_infos)
629
630 CALL section_vals_val_get(r_section, "RESTART_CONSTRAINT", l_val=flag)
631 IF (flag .AND. check_restart(input_file, restart_file, "MOTION%CONSTRAINT")) THEN
632 section => section_vals_get_subs_vals(restart_file, "MOTION%CONSTRAINT")
633 CALL section_vals_set_subs_vals(input_file, "MOTION%CONSTRAINT", section)
634 CALL set_restart_info("CONSTRAINTS/RESTRAINTS", restarted_infos)
635 END IF
636
637 CALL section_vals_val_get(r_section, "RESTART_METADYNAMICS", l_val=flag)
638 IF (flag .AND. check_restart(input_file, restart_file, "MOTION%FREE_ENERGY%METADYN")) THEN
639 section => section_vals_get_subs_vals(restart_file, &
640 "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_POS")
641 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_POS", &
642 section)
643 section => section_vals_get_subs_vals(restart_file, &
644 "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_SCALE")
645 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_SCALE", &
646 section)
647 section => section_vals_get_subs_vals(restart_file, &
648 "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_HEIGHT")
649 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_HEIGHT", &
650 section)
651 section => section_vals_get_subs_vals(restart_file, &
652 "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_INVDT")
653 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%SPAWNED_HILLS_INVDT", &
654 section)
655 ! Extended Lagrangian
656 section => section_vals_get_subs_vals(restart_file, &
657 "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS0")
658 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS0", &
659 section)
660 section => section_vals_get_subs_vals(restart_file, &
661 "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_VVP")
662 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_VVP", &
663 section)
664 section => section_vals_get_subs_vals(restart_file, &
665 "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS")
666 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_SS", &
667 section)
668 section => section_vals_get_subs_vals(restart_file, &
669 "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_FS")
670 CALL section_vals_set_subs_vals(input_file, "MOTION%FREE_ENERGY%METADYN%EXT_LAGRANGE_FS", &
671 section)
672 CALL set_restart_info("METADYNAMICS", restarted_infos)
673 END IF
674
675 CALL section_vals_val_get(r_section, "RESTART_TEMPERATURE_ANNEALING", l_val=flag)
676 IF (flag .AND. check_restart(input_file, restart_file, "MOTION%MD")) THEN
677 CALL section_vals_val_get(input_file, "MOTION%MD%TEMPERATURE_ANNEALING", r_val=myt, explicit=explicit1)
678 IF ((.NOT. explicit1) .OR. (abs(1._dp - myt) <= 1.e-10_dp)) THEN
679 CALL cp_warn(__location__, &
680 "I'm about to override the input temperature "// &
681 "with the temperature found in external restart "// &
682 "but TEMPERATURE_ANNEALING isn't explicitly given or it is set to 1.")
683 END IF
684 CALL section_vals_val_get(restart_file, "MOTION%MD%TEMPERATURE", r_val=myt, explicit=explicit1)
685 IF (explicit1) THEN
686 CALL section_vals_val_get(input_file, "MOTION%MD%TEMPERATURE", r_val=myt)
687 ELSE
688 CALL cp_warn(__location__, &
689 "I'm not going to override the input temperature "// &
690 "since the temperature isn't explicitly given in the external restart.")
691 END IF
692 END IF
693
694 CALL section_vals_val_get(r_section, "RESTART_WALKERS", l_val=flag)
695 IF (flag .AND. check_restart(input_file, restart_file, "MOTION%FREE_ENERGY%METADYN%MULTIPLE_WALKERS")) THEN
696 CALL section_vals_val_get(restart_file, "MOTION%FREE_ENERGY%METADYN%MULTIPLE_WALKERS%WALKERS_STATUS", &
697 i_vals=rwalkers_status)
698 ALLOCATE (iwalkers_status(SIZE(rwalkers_status)))
699 iwalkers_status = rwalkers_status
700 CALL section_vals_val_set(input_file, "MOTION%FREE_ENERGY%METADYN%MULTIPLE_WALKERS%WALKERS_STATUS", &
701 i_vals_ptr=iwalkers_status)
702 CALL set_restart_info("WALKERS INFO", restarted_infos)
703 END IF
704
705 CALL section_vals_val_get(r_section, "RESTART_DIMER", l_val=flag)
706 IF (flag .AND. check_restart(input_file, restart_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER")) THEN
707 section => section_vals_get_subs_vals(restart_file, &
708 "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%DIMER_VECTOR")
709 CALL section_vals_set_subs_vals(input_file, "MOTION%GEO_OPT%TRANSITION_STATE%DIMER%DIMER_VECTOR", &
710 section)
711 CALL set_restart_info("DIMER TRANSITION STATE SEARCH", restarted_infos)
712 END IF
713
714 CALL section_vals_val_get(r_section, "CUSTOM_PATH", n_rep_val=n_rep_val)
715 DO i_rep_val = 1, n_rep_val
716 CALL section_vals_val_get(r_section, "CUSTOM_PATH", i_rep_val=i_rep_val, c_val=path)
717 IF (path /= " ") THEN
718 section => section_vals_get_subs_vals(restart_file, path)
719 CALL section_vals_set_subs_vals(input_file, path, section)
720 CALL set_restart_info("USER RESTART: "//trim(path), restarted_infos)
721 END IF
722 END DO
723
724 CALL section_vals_val_get(r_section, "RESTART_RTP", l_val=flag)
725 ! IF(flag.AND.check_restart(input_file, restart_file, "FORCE_EVAL%DFT%REAL_TIME_PROPAGATION")) THEN
726 IF (flag) THEN
727 section => section_vals_get_subs_vals(restart_file, &
728 "FORCE_EVAL%DFT%REAL_TIME_PROPAGATION")
729 CALL section_vals_val_get(section, "INITIAL_WFN", i_val=myi)
730 CALL section_vals_val_set(input_file, "FORCE_EVAL%DFT%REAL_TIME_PROPAGATION%INITIAL_WFN", &
731 i_val=myi)
732 CALL set_restart_info("REAL TIME PROPAGATION", restarted_infos)
733 END IF
734
735 ! PIMD
736 CALL section_vals_val_get(r_section, "RESTART_PINT_POS", l_val=flag)
737 IF (flag) THEN
738 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%BEADS%COORD")
739 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%BEADS%COORD", section)
740 CALL set_restart_info("PINT BEAD POSITIONS", restarted_infos)
741 END IF
742 CALL section_vals_val_get(r_section, "RESTART_PINT_VEL", l_val=flag)
743 IF (flag) THEN
744 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%BEADS%VELOCITY")
745 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%BEADS%VELOCITY", section)
746 CALL set_restart_info("PINT BEAD VELOCITIES", restarted_infos)
747 END IF
748 CALL section_vals_val_get(r_section, "RESTART_PINT_NOSE", l_val=flag)
749 IF (flag) THEN
750 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%NOSE%COORD")
751 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%NOSE%COORD", section)
752 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%NOSE%VELOCITY")
753 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%NOSE%VELOCITY", section)
754 CALL set_restart_info("PINT NOSE THERMOSTAT", restarted_infos)
755 END IF
756 CALL section_vals_val_get(r_section, "RESTART_PINT_GLE", l_val=flag)
757 IF (flag) THEN
758 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%GLE")
759 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%GLE", section)
760 CALL set_restart_info("PINT GLE THERMOSTAT", restarted_infos)
761 END IF
762
763 ! PIMC
764 !
765 CALL section_vals_val_get(r_section, "RESTART_HELIUM_POS", l_val=flag)
766 IF (flag) THEN
767 CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
768 explicit=explicit1)
769 IF (.NOT. explicit1) THEN
770 CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
771 CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
772 END IF
773 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%COORD")
774 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%COORD", section)
775 CALL set_restart_info("HELIUM BEAD POSITIONS", restarted_infos)
776 END IF
777 !
778 CALL section_vals_val_get(r_section, "RESTART_HELIUM_PERMUTATION", l_val=flag)
779 IF (flag) THEN
780 CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
781 explicit=explicit1)
782 IF (.NOT. explicit1) THEN
783 CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
784 CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
785 END IF
786 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%PERM")
787 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%PERM", section)
788 CALL set_restart_info("HELIUM PERMUTATION STATE", restarted_infos)
789 END IF
790 !
791 CALL section_vals_val_get(r_section, "RESTART_HELIUM_FORCE", l_val=flag)
792 IF (flag) THEN
793 CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
794 explicit=explicit1)
795 IF (.NOT. explicit1) THEN
796 CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
797 CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
798 END IF
799 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%FORCE")
800 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%FORCE", section)
801 CALL set_restart_info("HELIUM FORCES ON SOLUTE", restarted_infos)
802 END IF
803 !
804 CALL section_vals_val_get(r_section, "RESTART_HELIUM_RNG", l_val=flag)
805 IF (flag) THEN
806 CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
807 explicit=explicit1)
808 IF (.NOT. explicit1) THEN
809 CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
810 CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
811 END IF
812 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%RNG_STATE")
813 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%RNG_STATE", section)
814 CALL set_restart_info("HELIUM RNG STATE", restarted_infos)
815 END IF
816 !
817 !
818 CALL section_vals_val_get(r_section, "RESTART_HELIUM_DENSITIES", l_val=flag)
819 IF (flag) THEN
820 CALL section_vals_val_get(input_file, "MOTION%PINT%HELIUM%NUM_ENV", &
821 explicit=explicit1)
822 IF (.NOT. explicit1) THEN
823 CALL section_vals_val_get(restart_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
824 CALL section_vals_val_set(input_file, "MOTION%PINT%HELIUM%NUM_ENV", i_val=myi)
825 END IF
826 section => section_vals_get_subs_vals(restart_file, "MOTION%PINT%HELIUM%RHO")
827 CALL section_vals_set_subs_vals(input_file, "MOTION%PINT%HELIUM%RHO", section)
828 CALL set_restart_info("HELIUM DENSITIES", restarted_infos)
829 END IF
830 !
831 CALL section_vals_val_set(r_section, "RESTART_FILE_NAME", c_val=" ")
832 CALL section_vals_release(restart_file)
833 CALL release_restart_info(restarted_infos, r_file_path, binary_restart_file, &
834 output_unit)
835 END block
836 END IF
837 CALL timestop(handle)
838 END SUBROUTINE handle_ext_restart
839
840! **************************************************************************************************
841!> \brief store information on the restarted quantities
842!> \param label ...
843!> \param restarted_infos ...
844!> \author Teodoro Laino [tlaino] 09.2008 - University of Zurich
845! **************************************************************************************************
846 SUBROUTINE set_restart_info(label, restarted_infos)
847
848 CHARACTER(LEN=*), INTENT(IN) :: label
849 CHARACTER(LEN=default_string_length), &
850 DIMENSION(:), POINTER :: restarted_infos
851
852 INTEGER :: isize
853
854 isize = 0
855 IF (ASSOCIATED(restarted_infos)) isize = SIZE(restarted_infos)
856 isize = isize + 1
857 CALL reallocate(restarted_infos, 1, isize)
858 restarted_infos(isize) = trim(label)
859
860 END SUBROUTINE set_restart_info
861
862! **************************************************************************************************
863!> \brief dumps on output the information on the information effectively restarted
864!> \param restarted_infos ...
865!> \param r_file_path ...
866!> \param binary_restart_file ...
867!> \param output_unit ...
868!> \author Teodoro Laino [tlaino] 09.2008 - University of Zurich
869! **************************************************************************************************
870 SUBROUTINE release_restart_info(restarted_infos, r_file_path, &
871 binary_restart_file, output_unit)
872 CHARACTER(LEN=default_string_length), &
873 DIMENSION(:), POINTER :: restarted_infos
874 CHARACTER(LEN=*), INTENT(IN) :: r_file_path, binary_restart_file
875 INTEGER, INTENT(IN) :: output_unit
876
877 INTEGER :: i, j
878
879 IF (output_unit > 0 .AND. ASSOCIATED(restarted_infos)) THEN
880 WRITE (output_unit, '(1X,79("*"))')
881 WRITE (output_unit, '(1X,"*",T30,A,T80,"*")') " RESTART INFORMATION "
882 WRITE (output_unit, '(1X,79("*"))')
883 WRITE (output_unit, '(1X,"*",T80,"*")')
884 i = 1
885 WRITE (output_unit, '(1X,"*",A,T26,A,T80,"*")') " RESTART FILE NAME: ", &
886 r_file_path(53*(i - 1) + 1:53*i)
887 DO i = 2, ceiling(real(len_trim(r_file_path), kind=dp)/53.0_dp)
888 WRITE (output_unit, '(T1,1X,"*",T26,A,T80,"*")') r_file_path(53*(i - 1) + 1:53*i)
889 END DO
890 IF (len_trim(binary_restart_file) > 0) THEN
891 i = 1
892 WRITE (output_unit, '(1X,"*",A,T26,A,T80,"*")') " BINARY RESTART FILE: ", &
893 binary_restart_file(53*(i - 1) + 1:53*i)
894 DO i = 2, ceiling(real(len_trim(binary_restart_file), kind=dp)/53.0_dp)
895 WRITE (output_unit, '(T1,1X,"*",T26,A,T80,"*")') binary_restart_file(53*(i - 1) + 1:53*i)
896 END DO
897 END IF
898 WRITE (output_unit, '(1X,"*",T80,"*")')
899 WRITE (output_unit, '(1X,"*", A,T80,"*")') " RESTARTED QUANTITIES: "
900 DO j = 1, SIZE(restarted_infos)
901 DO i = 1, ceiling(real(len_trim(restarted_infos(j)), kind=dp)/53.0_dp)
902 WRITE (output_unit, '(T1,1X,"*",T26,A,T80,"*")') restarted_infos(j) (53*(i - 1) + 1:53*i)
903 END DO
904 END DO
905 WRITE (output_unit, '(1X,79("*"),/)')
906 END IF
907 IF (ASSOCIATED(restarted_infos)) THEN
908 DEALLOCATE (restarted_infos)
909 END IF
910 END SUBROUTINE release_restart_info
911
912! **************************************************************************************************
913!> \brief Possibly restart thermostats information
914!> \param flag ...
915!> \param input_file the input file to initialize
916!> \param restart_file ...
917!> \param path ...
918!> \param check ...
919!> \author Teodoro Laino [tlaino] 10.2007- University of Zurich
920! **************************************************************************************************
921 SUBROUTINE restart_thermostat(flag, input_file, restart_file, path, check)
922 LOGICAL, INTENT(IN) :: flag
923 TYPE(section_vals_type), POINTER :: input_file, restart_file
924 CHARACTER(LEN=*), INTENT(IN) :: path
925 LOGICAL, INTENT(IN), OPTIONAL :: check
926
927 INTEGER :: input_region, input_type, &
928 restart_region, restart_type
929 LOGICAL :: check_loc, skip_other_checks
930 TYPE(section_vals_type), POINTER :: section
931
932 check_loc = check_restart(input_file, restart_file, trim(path))
933 skip_other_checks = PRESENT(check)
934 IF (skip_other_checks) check_loc = check
935 IF (flag .AND. check_loc) THEN
936 ! Let's check if the thermostat type is different otherwise it does not make any
937 ! sense to do any kind of restart
938 CALL section_vals_val_get(input_file, trim(path)//"%TYPE", i_val=input_type)
939 CALL section_vals_val_get(restart_file, trim(path)//"%TYPE", i_val=restart_type)
940
941 IF (input_type == do_thermo_same_as_part) THEN
942 CALL section_vals_val_get(input_file, "MOTION%MD%THERMOSTAT%TYPE", i_val=input_type)
943 END IF
944
945 IF (skip_other_checks) THEN
946 input_region = do_region_global
947 restart_region = do_region_global
948 ELSE
949 ! Also the regions must be the same..
950 CALL section_vals_val_get(input_file, trim(path)//"%REGION", i_val=input_region)
951 CALL section_vals_val_get(restart_file, trim(path)//"%REGION", i_val=restart_region)
952 END IF
953
954 IF ((input_type == restart_type) .AND. (input_region == restart_region)) THEN
955 SELECT CASE (input_type)
956 CASE (do_thermo_nose)
957 section => section_vals_get_subs_vals(restart_file, trim(path)//"%NOSE%COORD")
958 CALL section_vals_set_subs_vals(input_file, trim(path)//"%NOSE%COORD", section)
959
960 section => section_vals_get_subs_vals(restart_file, trim(path)//"%NOSE%VELOCITY")
961 CALL section_vals_set_subs_vals(input_file, trim(path)//"%NOSE%VELOCITY", section)
962
963 section => section_vals_get_subs_vals(restart_file, trim(path)//"%NOSE%MASS")
964 CALL section_vals_set_subs_vals(input_file, trim(path)//"%NOSE%MASS", section)
965
966 section => section_vals_get_subs_vals(restart_file, trim(path)//"%NOSE%FORCE")
967 CALL section_vals_set_subs_vals(input_file, trim(path)//"%NOSE%FORCE", section)
968 CASE (do_thermo_csvr)
969 section => section_vals_get_subs_vals(restart_file, trim(path)//"%CSVR%THERMOSTAT_ENERGY")
970 CALL section_vals_set_subs_vals(input_file, trim(path)//"%CSVR%THERMOSTAT_ENERGY", section)
971 section => section_vals_get_subs_vals(restart_file, trim(path)//"%CSVR%RNG_INIT")
972 CALL section_vals_set_subs_vals(input_file, trim(path)//"%CSVR%RNG_INIT", section)
973 CASE (do_thermo_gle)
974 section => section_vals_get_subs_vals(restart_file, trim(path)//"%GLE%THERMOSTAT_ENERGY")
975 CALL section_vals_set_subs_vals(input_file, trim(path)//"%GLE%THERMOSTAT_ENERGY", section)
976 section => section_vals_get_subs_vals(restart_file, trim(path)//"%GLE%RNG_INIT")
977 CALL section_vals_set_subs_vals(input_file, trim(path)//"%GLE%RNG_INIT", section)
978 section => section_vals_get_subs_vals(restart_file, trim(path)//"%GLE%S")
979 CALL section_vals_set_subs_vals(input_file, trim(path)//"%GLE%S", section)
980 CASE (do_thermo_al)
981 section => section_vals_get_subs_vals(restart_file, trim(path)//"%AD_LANGEVIN%CHI")
982 CALL section_vals_set_subs_vals(input_file, trim(path)//"%AD_LANGEVIN%CHI", section)
983 section => section_vals_get_subs_vals(restart_file, trim(path)//"%AD_LANGEVIN%MASS")
984 CALL section_vals_set_subs_vals(input_file, trim(path)//"%AD_LANGEVIN%MASS", section)
985 END SELECT
986 ELSE
987 IF (input_type /= restart_type) THEN
988 CALL cp_warn(__location__, &
989 "Requested to restart thermostat: "//trim(path)//". The thermostat "// &
990 "specified in the input file and the information present in the restart "// &
991 "file do not match the same type of thermostat! Restarting is not possible! "// &
992 "Thermostat will not be restarted! ")
993 END IF
994 IF (input_region /= restart_region) THEN
995 CALL cp_warn(__location__, &
996 "Requested to restart thermostat: "//trim(path)//". The thermostat "// &
997 "specified in the input file and the information present in the restart "// &
998 "file do not match the same type of REGION! Restarting is not possible! "// &
999 "Thermostat will not be restarted! ")
1000 END IF
1001 END IF
1002 END IF
1003 END SUBROUTINE restart_thermostat
1004
1005! **************************************************************************************************
1006!> \brief Checks if there are the proper conditions to do a restart
1007!> \param input_file the input file to initialize
1008!> \param restart_file ...
1009!> \param tag_section ...
1010!> \return ...
1011!> \author teo
1012! **************************************************************************************************
1013 FUNCTION check_restart(input_file, restart_file, tag_section) RESULT(do_restart)
1014 TYPE(section_vals_type), POINTER :: input_file, restart_file
1015 CHARACTER(LEN=*), INTENT(IN) :: tag_section
1016 LOGICAL :: do_restart
1017
1018 CHARACTER(len=*), PARAMETER :: routinen = 'check_restart'
1019
1020 INTEGER :: handle
1021 LOGICAL :: explicit1, explicit2
1022 TYPE(section_vals_type), POINTER :: work_section
1023
1024 CALL timeset(routinen, handle)
1025 NULLIFY (work_section)
1026 work_section => section_vals_get_subs_vals(input_file, trim(tag_section))
1027 CALL section_vals_get(work_section, explicit=explicit1)
1028 work_section => section_vals_get_subs_vals(restart_file, trim(tag_section))
1029 CALL section_vals_get(work_section, explicit=explicit2)
1030
1031 do_restart = explicit1 .AND. explicit2
1032 CALL timestop(handle)
1033 END FUNCTION check_restart
1034
1035! **************************************************************************************************
1036!> \brief Removes section used to restart a calculation from an
1037!> input file in memory
1038!> \param input_file the input file to initialize
1039!> \author teo
1040! **************************************************************************************************
1041 SUBROUTINE remove_restart_info(input_file)
1042 TYPE(section_vals_type), POINTER :: input_file
1043
1044 CHARACTER(len=*), PARAMETER :: routinen = 'remove_restart_info'
1045
1046 INTEGER :: handle, iforce_eval, nforce_eval1
1047 LOGICAL :: explicit1
1048 TYPE(section_vals_type), POINTER :: md_section, motion_section, section1, &
1049 section_to_delete, sections1, &
1050 work_section
1051
1052 CALL timeset(routinen, handle)
1053
1054 NULLIFY (work_section)
1055 section_to_delete => section_vals_get_subs_vals(input_file, "EXT_RESTART")
1056 CALL section_vals_remove_values(section_to_delete)
1057 sections1 => section_vals_get_subs_vals(input_file, "FORCE_EVAL")
1058 CALL section_vals_get(sections1, n_repetition=nforce_eval1)
1059
1060 DO iforce_eval = 1, nforce_eval1
1061 section1 => section_vals_get_subs_vals3(sections1, "SUBSYS", i_rep_section=iforce_eval)
1062 section_to_delete => section_vals_get_subs_vals(section1, "COORD")
1063 CALL section_vals_remove_values(section_to_delete)
1064 section_to_delete => section_vals_get_subs_vals(section1, "VELOCITY")
1065 CALL section_vals_remove_values(section_to_delete)
1066 END DO
1067
1068 motion_section => section_vals_get_subs_vals(input_file, "MOTION")
1069 md_section => section_vals_get_subs_vals(motion_section, "MD")
1070 CALL section_vals_get(md_section, explicit=explicit1)
1071 IF (explicit1) THEN
1072 CALL section_vals_val_unset(md_section, "STEP_START_VAL")
1073 CALL section_vals_val_unset(md_section, "TIME_START_VAL")
1074 CALL section_vals_val_unset(md_section, "ECONS_START_VAL")
1075 END IF
1076 work_section => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN")
1077 CALL section_vals_get(work_section, explicit=explicit1)
1078 IF (explicit1) THEN
1079 CALL section_vals_val_unset(motion_section, "FREE_ENERGY%METADYN%STEP_START_VAL")
1080 CALL section_vals_val_unset(motion_section, "FREE_ENERGY%METADYN%NHILLS_START_VAL")
1081 END IF
1082 section_to_delete => section_vals_get_subs_vals(motion_section, "BAND%REPLICA")
1083 CALL section_vals_remove_values(section_to_delete)
1084 section_to_delete => section_vals_get_subs_vals(md_section, "AVERAGES%RESTART_AVERAGES")
1085 CALL section_vals_remove_values(section_to_delete)
1086 section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%COORD")
1087 CALL section_vals_remove_values(section_to_delete)
1088 section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%VELOCITY")
1089 CALL section_vals_remove_values(section_to_delete)
1090 section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%MASS")
1091 CALL section_vals_remove_values(section_to_delete)
1092 section_to_delete => section_vals_get_subs_vals(md_section, "THERMOSTAT%NOSE%FORCE")
1093 CALL section_vals_remove_values(section_to_delete)
1094 section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%MASS")
1095 CALL section_vals_remove_values(section_to_delete)
1096 section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%VELOCITY")
1097 CALL section_vals_remove_values(section_to_delete)
1098 section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%COORD")
1099 CALL section_vals_remove_values(section_to_delete)
1100 section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%VELOCITY")
1101 CALL section_vals_remove_values(section_to_delete)
1102 section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%MASS")
1103 CALL section_vals_remove_values(section_to_delete)
1104 section_to_delete => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT%NOSE%FORCE")
1105 CALL section_vals_remove_values(section_to_delete)
1106 section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%COORD")
1107 CALL section_vals_remove_values(section_to_delete)
1108 section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%VELOCITY")
1109 CALL section_vals_remove_values(section_to_delete)
1110 section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%MASS")
1111 CALL section_vals_remove_values(section_to_delete)
1112 section_to_delete => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT%NOSE%FORCE")
1113 CALL section_vals_remove_values(section_to_delete)
1114 ! Constrained/Restrained section
1115 section_to_delete => section_vals_get_subs_vals(motion_section, "CONSTRAINT%FIX_ATOM_RESTART")
1116 CALL section_vals_remove_values(section_to_delete)
1117 section_to_delete => section_vals_get_subs_vals(motion_section, "CONSTRAINT%COLVAR_RESTART")
1118 CALL section_vals_remove_values(section_to_delete)
1119 ! Free energies restarts
1120 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_POS")
1121 CALL section_vals_remove_values(section_to_delete)
1122 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_SCALE")
1123 CALL section_vals_remove_values(section_to_delete)
1124 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_HEIGHT")
1125 CALL section_vals_remove_values(section_to_delete)
1126 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%SPAWNED_HILLS_INVDT")
1127 CALL section_vals_remove_values(section_to_delete)
1128 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_SS0")
1129 CALL section_vals_remove_values(section_to_delete)
1130 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_VVP")
1131 CALL section_vals_remove_values(section_to_delete)
1132 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_SS")
1133 CALL section_vals_remove_values(section_to_delete)
1134 section_to_delete => section_vals_get_subs_vals(motion_section, "FREE_ENERGY%METADYN%EXT_LAGRANGE_FS")
1135 CALL section_vals_remove_values(section_to_delete)
1136 CALL timestop(handle)
1137 END SUBROUTINE remove_restart_info
1138
1139! **************************************************************************************************
1140!> \brief This subroutine controls the defaults for the restartable quantities..
1141!> \param r_section ...
1142!> \author teo - University of Zurich - 09.2007 [tlaino]
1143! **************************************************************************************************
1144 SUBROUTINE handle_defaults_restart(r_section)
1145 TYPE(section_vals_type), POINTER :: r_section
1146
1147 CHARACTER(len=*), PARAMETER :: routinen = 'handle_defaults_restart'
1148
1149 INTEGER :: handle, ik, nval
1150 LOGICAL :: restart_default
1151 TYPE(keyword_type), POINTER :: keyword
1152 TYPE(section_type), POINTER :: section
1153
1154 CALL timeset(routinen, handle)
1155 NULLIFY (keyword, section)
1156 CALL section_vals_get(r_section, section=section)
1157 CALL section_vals_val_get(r_section, "RESTART_DEFAULT", l_val=restart_default)
1158 DO ik = -1, section%n_keywords
1159 keyword => section%keywords(ik)%keyword
1160 IF (ASSOCIATED(keyword)) THEN
1161 IF (keyword%type_of_var == logical_t .AND. keyword%names(1) (1:8) == "RESTART_") THEN
1162 IF (trim(keyword%names(1)) == "RESTART_DEFAULT") cycle
1163 CALL section_vals_val_get(r_section, keyword%names(1), n_rep_val=nval)
1164 IF (nval == 0) THEN
1165 ! User didn't specify any value, use the value of the RESTART_DEFAULT keyword..
1166 CALL section_vals_val_set(r_section, keyword%names(1), l_val=restart_default)
1167 END IF
1168 END IF
1169 END IF
1170 END DO
1171 CALL timestop(handle)
1172
1173 END SUBROUTINE handle_defaults_restart
1174
1175END MODULE input_cp2k_check
various routines to log and control the output. The idea is that decisions about where to log should ...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
unit conversion facility
Definition cp_units.F:30
subroutine, public cp_unit_set_release(unit_set)
releases the given unit set
Definition cp_units.F:1374
subroutine, public cp_unit_set_create(unit_set, name)
initializes the given unit set
Definition cp_units.F:1300
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_thermo_nose
integer, parameter, public xc_funct_tpss
integer, parameter, public xc_funct_xwpbe
integer, parameter, public xc_funct_bp
integer, parameter, public xc_funct_olyp
integer, parameter, public xc_funct_pbe
integer, parameter, public xc_funct_no_shortcut
integer, parameter, public npt_i_ensemble
integer, parameter, public xc_vdw_fun_nonloc
integer, parameter, public xc_funct_pbe0
integer, parameter, public xc_funct_beefvdw
integer, parameter, public xc_funct_pade
integer, parameter, public xc_funct_blyp
integer, parameter, public do_thermo_al
integer, parameter, public do_thermo_csvr
integer, parameter, public mimic_run
integer, parameter, public vdw_nl_lmkll
integer, parameter, public do_thermo_gle
integer, parameter, public npt_ia_ensemble
integer, parameter, public npt_f_ensemble
integer, parameter, public do_region_global
integer, parameter, public negf_run
integer, parameter, public do_qs
integer, parameter, public xc_funct_b3lyp
integer, parameter, public xc_none
integer, parameter, public xc_funct_hcth120
integer, parameter, public do_thermo_same_as_part
checks the input and perform some automatic "magic" on it
subroutine, public check_cp2k_input(input_declaration, input_file, para_env, output_unit)
performs further checks on an input that parsed successfully
subroutine, public remove_restart_info(input_file)
Removes section used to restart a calculation from an input file in memory.
subroutine, public xc_functionals_expand(functionals, xc_section)
expand a shortcutted functional section
represents keywords in an input
routines that parse the input
recursive subroutine, public section_vals_parse(section_vals, parser, default_units, root_section)
...
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_unset(section_vals, keyword_name, i_rep_section, i_rep_val)
unsets (removes) the requested value (if it is a keyword repetitions removes the repetition,...
recursive subroutine, public section_vals_create(section_vals, section)
creates a object where to store the values of a section
subroutine, public section_vals_val_set(section_vals, keyword_name, i_rep_section, i_rep_val, val, l_val, i_val, r_val, c_val, l_vals_ptr, i_vals_ptr, r_vals_ptr, c_vals_ptr)
sets the requested value
type(section_vals_type) function, pointer, public section_vals_get_subs_vals2(section_vals, i_section, i_rep_section)
returns the values of the n-th non default subsection (null if no such section exists (not so many no...
subroutine, public section_vals_remove_values(section_vals)
removes the values of a repetition of the section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
type(section_vals_type) function, pointer, public section_vals_get_subs_vals3(section_vals, subsection_name, i_rep_section)
returns the values of the n-th non default subsection (null if no such section exists (not so many no...
subroutine, public section_vals_set_subs_vals(section_vals, subsection_name, new_section_vals, i_rep_section)
replaces of the requested subsection with the one given
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
recursive subroutine, public section_vals_release(section_vals)
releases the given object
a wrapper for basic fortran types.
integer, parameter, public logical_t
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Utility routines for the memory handling.
Interface to the message passing library MPI.
input constants for xc
integer, parameter, public do_vwn5
stores the default units to be used
Definition cp_units.F:155
represent a keyword in the input
represent a section of the input file
stores all the informations relevant to an mpi environment