(git:374b731)
Loading...
Searching...
No Matches
cp2k_runs.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
10 USE atom, ONLY: atom_code
11 USE bibliography, ONLY: hutter2014,&
12 cite_reference
13 USE bsse, ONLY: do_bsse_calculation
14 USE cell_opt, ONLY: cp_cell_opt
16 USE cp2k_info, ONLY: compile_date,&
24 USE cp_files, ONLY: close_file,&
39 USE cp_units, ONLY: cp_unit_set_create,&
43 USE dbcsr_api, ONLY: dbcsr_finalize_lib,&
44 dbcsr_init_lib,&
45 dbcsr_print_config,&
46 dbcsr_print_statistics
48 USE environment, ONLY: cp2k_finalize,&
49 cp2k_init,&
50 cp2k_read,&
54 f77_default_para_env => default_para_env,&
58 USE farming_methods, ONLY: do_deadlock,&
60 do_wait,&
71 USE geo_opt, ONLY: cp_geo_opt
77 USE input_constants, ONLY: &
90 USE input_section_types, ONLY: &
94 USE ipi_driver, ONLY: run_driver
95 USE kinds, ONLY: default_path_length,&
97 dp,&
98 int_8
99 USE library_tests, ONLY: lib_test
100 USE machine, ONLY: default_output_unit,&
101 m_chdir,&
102 m_flush,&
103 m_getcwd,&
104 m_memory,&
107 USE mc_run, ONLY: do_mon_car
108 USE md_run, ONLY: qs_mol_dyn
109 USE message_passing, ONLY: mp_any_source,&
113 USE mscfg_methods, ONLY: do_mol_loop,&
115 USE neb_methods, ONLY: neb
116 USE negf_methods, ONLY: do_negf
121 USE pint_methods, ONLY: do_pint_run
122 USE pw_fpga, ONLY: pw_fpga_finalize,&
124 USE pw_gpu, ONLY: pw_gpu_finalize,&
134 USE swarm, ONLY: run_swarm
135 USE tamc_run, ONLY: qs_tamc
136 USE tmc_setup, ONLY: do_analyze_files,&
137 do_tmc
139#include "../base/base_uses.f90"
140
141 IMPLICIT NONE
142
143 PRIVATE
144
145 PUBLIC :: write_xml_file, run_input
146
147 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp2k_runs'
148
149CONTAINS
150
151! **************************************************************************************************
152!> \brief performs an instance of a cp2k run
153!> \param input_declaration ...
154!> \param input_file_name name of the file to be opened for input
155!> \param output_unit unit to which output should be written
156!> \param mpi_comm ...
157!> \param initial_variables key-value list of initial preprocessor variables
158!> \author Joost VandeVondele
159!> \note
160!> para_env should be a valid communicator
161!> output_unit should be writeable by at least the lowest rank of the mpi group
162!>
163!> recursive because a given run_type might need to be able to perform
164!> another cp2k_run as part of its job (e.g. farming, classical equilibration, ...)
165!>
166!> the idea is that a cp2k instance should be able to run with just three
167!> arguments, i.e. a given input file, output unit, mpi communicator.
168!> giving these three to cp2k_run should produce a valid run.
169!> the only task of the PROGRAM cp2k is to create valid instances of the
170!> above arguments. Ideally, anything that is called afterwards should be
171!> able to run simultaneously / multithreaded / sequential / parallel / ...
172!> and able to fail safe
173! **************************************************************************************************
174 RECURSIVE SUBROUTINE cp2k_run(input_declaration, input_file_name, output_unit, mpi_comm, initial_variables)
175 TYPE(section_type), POINTER :: input_declaration
176 CHARACTER(LEN=*), INTENT(IN) :: input_file_name
177 INTEGER, INTENT(IN) :: output_unit
178
179 CLASS(mp_comm_type) :: mpi_comm
180 CHARACTER(len=default_path_length), &
181 DIMENSION(:, :), INTENT(IN) :: initial_variables
182
183 INTEGER :: f_env_handle, grid_backend, ierr, &
184 iter_level, method_name_id, &
185 new_env_id, prog_name_id, run_type_id
186 INTEGER(KIND=int_8) :: m_memory_max_mpi
187 LOGICAL :: echo_input, grid_apply_cutoff, &
188 grid_validate, I_was_ionode
189 TYPE(cp_logger_type), POINTER :: logger, sublogger
190 TYPE(mp_para_env_type), POINTER :: para_env
191 TYPE(dft_control_type), POINTER :: dft_control
192 TYPE(f_env_type), POINTER :: f_env
193 TYPE(force_env_type), POINTER :: force_env
194 TYPE(global_environment_type), POINTER :: globenv
195 TYPE(section_vals_type), POINTER :: glob_section, input_file, root_section
196
197 NULLIFY (para_env, f_env, dft_control)
198 ALLOCATE (para_env)
199 para_env = mpi_comm
200
201#if defined(__DBCSR_ACC)
202 IF (offload_get_device_count() > 0) THEN
203 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit, &
204 accdrv_active_device_id=offload_get_chosen_device())
205 ELSE
206 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit)
207 END IF
208#else
209 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit)
210#endif
211
212 CALL pw_gpu_init()
213 CALL pw_fpga_init()
214
215 CALL cp_dlaf_initialize()
216
217 NULLIFY (globenv, force_env)
218
220
221 ! parse the input
222 input_file => read_input(input_declaration, input_file_name, initial_variables=initial_variables, &
223 para_env=para_env)
224
225 CALL para_env%sync()
226
227 glob_section => section_vals_get_subs_vals(input_file, "GLOBAL")
228 CALL section_vals_val_get(glob_section, "ECHO_INPUT", l_val=echo_input)
229 logger => cp_get_default_logger()
230 IF (echo_input) THEN
231 CALL section_vals_write(input_file, &
232 unit_nr=cp_logger_get_default_io_unit(logger), &
233 hide_root=.true., hide_defaults=.false.)
234 END IF
235
236 CALL check_cp2k_input(input_declaration, input_file, para_env=para_env, output_unit=output_unit)
237 root_section => input_file
238 CALL section_vals_val_get(input_file, "GLOBAL%PROGRAM_NAME", &
239 i_val=prog_name_id)
240 CALL section_vals_val_get(input_file, "GLOBAL%RUN_TYPE", &
241 i_val=run_type_id)
242 CALL section_vals_val_get(root_section, "FORCE_EVAL%METHOD", i_val=method_name_id)
243
244 IF (prog_name_id /= do_cp2k) THEN
245 ! initial setup (cp2k does in in the creation of the force_env)
246 CALL globenv_create(globenv)
247 CALL section_vals_retain(input_file)
248 CALL cp2k_init(para_env, output_unit, globenv, input_file_name=input_file_name)
249 CALL cp2k_read(root_section, para_env, globenv)
250 CALL cp2k_setup(root_section, para_env, globenv)
251 END IF
252
253 CALL cp_dbcsr_config(root_section)
254 IF (output_unit > 0 .AND. &
256 CALL dbcsr_print_config(unit_nr=output_unit)
257 WRITE (unit=output_unit, fmt='()')
258 END IF
259
260 ! Configure the grid library.
261 CALL section_vals_val_get(root_section, "GLOBAL%GRID%BACKEND", i_val=grid_backend)
262 CALL section_vals_val_get(root_section, "GLOBAL%GRID%VALIDATE", l_val=grid_validate)
263 CALL section_vals_val_get(root_section, "GLOBAL%GRID%APPLY_CUTOFF", l_val=grid_apply_cutoff)
264
265 CALL grid_library_set_config(backend=grid_backend, &
266 validate=grid_validate, &
267 apply_cutoff=grid_apply_cutoff)
268
269 SELECT CASE (prog_name_id)
270 CASE (do_atom)
271 globenv%run_type_id = none_run
272 CALL atom_code(root_section)
273 CASE (do_optimize_input)
274 CALL run_optimize_input(input_declaration, root_section, para_env)
275 CASE (do_swarm)
276 CALL run_swarm(input_declaration, root_section, para_env, globenv, input_file_name)
277 CASE (do_farming)
278 ! Hack: DBCSR should be uninitialized when entering farming.
279 ! But, we don't want to change the public f77_interface.
280 ! TODO: refactor cp2k's startup code
281 CALL dbcsr_finalize_lib()
282 IF (method_name_id == do_sirius) CALL cp_sirius_finalize()
283
284 CALL cp_dlaf_finalize()
285
286 CALL pw_gpu_finalize()
287 CALL pw_fpga_finalize()
288 CALL farming_run(input_declaration, root_section, para_env, initial_variables)
289#if defined(__DBCSR_ACC)
290 IF (offload_get_device_count() > 0) THEN
291 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit, &
292 accdrv_active_device_id=offload_get_chosen_device())
293 ELSE
294 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit)
295 END IF
296#else
297 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit)
298#endif
299
300 CALL pw_gpu_init()
301 CALL pw_fpga_init()
302 IF (method_name_id == do_sirius) CALL cp_sirius_init()
303 CASE (do_opt_basis)
304 CALL run_optimize_basis(input_declaration, root_section, para_env)
305 globenv%run_type_id = none_run
306 CASE (do_cp2k)
307 IF (method_name_id == do_sirius) CALL cp_sirius_init()
308 CALL create_force_env(new_env_id, &
309 input_declaration=input_declaration, &
310 input_path=input_file_name, &
311 output_path="__STD_OUT__", mpi_comm=para_env, &
312 output_unit=output_unit, &
313 owns_out_unit=.false., &
314 input=input_file, ierr=ierr)
315 cpassert(ierr == 0)
316 CALL f_env_add_defaults(new_env_id, f_env, handle=f_env_handle)
317 force_env => f_env%force_env
318 CALL force_env_get(force_env, globenv=globenv)
319 CASE (do_test)
320 CALL lib_test(root_section, para_env, globenv)
321 CASE (do_tree_mc) ! TMC entry point
322 CALL do_tmc(input_declaration, root_section, para_env, globenv)
323 CASE (do_tree_mc_ana)
324 CALL do_analyze_files(input_declaration, root_section, para_env)
325 CASE default
326 cpabort("")
327 END SELECT
328 CALL section_vals_release(input_file)
329
330 SELECT CASE (globenv%run_type_id)
331 CASE (pint_run)
332 CALL do_pint_run(para_env, root_section, input_declaration, globenv)
333 CASE (none_run, tree_mc_run)
334 ! do nothing
335 CASE (driver_run)
336 CALL run_driver(force_env, globenv)
338 IF (method_name_id /= do_qs .AND. &
339 method_name_id /= do_sirius .AND. &
340 method_name_id /= do_qmmm .AND. &
341 method_name_id /= do_mixed .AND. &
342 method_name_id /= do_nnp .AND. &
343 method_name_id /= do_embed .AND. &
344 method_name_id /= do_fist) &
345 cpabort("Energy/Force run not available for all methods ")
346
347 sublogger => cp_get_default_logger()
348 CALL cp_add_iter_level(sublogger%iter_info, "JUST_ENERGY", &
349 n_rlevel_new=iter_level)
350
351 ! loop over molecules to generate a molecular guess
352 ! this procedure is initiated here to avoid passing globenv deep down
353 ! the subroutine stack
354 IF (do_mol_loop(force_env=force_env)) &
355 CALL loop_over_molecules(globenv, force_env)
356
357 SELECT CASE (globenv%run_type_id)
358 CASE (energy_run)
359 CALL force_env_calc_energy_force(force_env, calc_force=.false.)
360 CASE (energy_force_run)
361 CALL force_env_calc_energy_force(force_env, calc_force=.true.)
362 CASE default
363 cpabort("")
364 END SELECT
365 CALL cp_rm_iter_level(sublogger%iter_info, level_name="JUST_ENERGY", n_rlevel_att=iter_level)
366 CASE (mol_dyn_run)
367 CALL qs_mol_dyn(force_env, globenv)
368 CASE (geo_opt_run)
369 CALL cp_geo_opt(force_env, globenv)
370 CASE (cell_opt_run)
371 CALL cp_cell_opt(force_env, globenv)
372 CASE (mon_car_run)
373 CALL do_mon_car(force_env, globenv, input_declaration, input_file_name)
374 CASE (do_tamc)
375 CALL qs_tamc(force_env, globenv)
377 IF (method_name_id /= do_qs) &
378 cpabort("Electron spectra available only with Quickstep. ")
379 CALL force_env_calc_energy_force(force_env, calc_force=.false.)
380 CALL tddfpt_calculation(force_env%qs_env)
382 IF (method_name_id /= do_qs) &
383 cpabort("Real time propagation needs METHOD QS. ")
384 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
385 dft_control%rtp_control%fixed_ions = .true.
386 CALL rt_prop_setup(force_env)
387 CASE (ehrenfest)
388 IF (method_name_id /= do_qs) &
389 cpabort("Ehrenfest dynamics needs METHOD QS ")
390 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
391 dft_control%rtp_control%fixed_ions = .false.
392 CALL qs_mol_dyn(force_env, globenv)
393 CASE (bsse_run)
394 CALL do_bsse_calculation(force_env, globenv)
396 IF (method_name_id /= do_qs .AND. &
397 method_name_id /= do_qmmm) &
398 cpabort("Property calculations by Linear Response only within the QS or QMMM program ")
399 ! The Ground State is needed, it can be read from Restart
400 CALL force_env_calc_energy_force(force_env, calc_force=.false., linres=.true.)
401 CALL linres_calculation(force_env)
402 CASE (debug_run)
403 SELECT CASE (method_name_id)
404 CASE (do_qs, do_qmmm, do_fist)
405 CALL cp2k_debug_energy_and_forces(force_env)
406 CASE DEFAULT
407 cpabort("Debug run available only with QS, FIST, and QMMM program ")
408 END SELECT
409 CASE (vib_anal)
410 CALL vb_anal(root_section, input_declaration, para_env, globenv)
411 CASE (do_band)
412 CALL neb(root_section, input_declaration, para_env, globenv)
413 CASE (negf_run)
414 CALL do_negf(force_env)
415 CASE default
416 cpabort("")
417 END SELECT
418
419 !sample peak memory
420 CALL m_memory()
421
422 IF (method_name_id == do_sirius) CALL cp_sirius_finalize()
423
424 CALL pw_gpu_finalize()
425 CALL pw_fpga_finalize()
426
427 CALL cp_dlaf_finalize()
428
429 CALL dbcsr_print_statistics()
430
431 CALL dbm_library_print_stats(mpi_comm=mpi_comm, output_unit=output_unit)
432 CALL grid_library_print_stats(mpi_comm=mpi_comm, output_unit=output_unit)
433
434 m_memory_max_mpi = m_memory_max
435 CALL mpi_comm%max(m_memory_max_mpi)
436 IF (output_unit > 0) THEN
437 WRITE (output_unit, *)
438 WRITE (output_unit, '(T2,"MEMORY| Estimated peak process memory [MiB]",T73,I8)') &
439 (m_memory_max_mpi + (1024*1024) - 1)/(1024*1024)
440 END IF
441
442 IF (prog_name_id == do_cp2k) THEN
443 f_env%force_env => force_env ! for mc
444 IF (ASSOCIATED(force_env%globenv)) THEN
445 IF (.NOT. ASSOCIATED(force_env%globenv, globenv)) THEN
446 CALL globenv_release(force_env%globenv) !mc
447 END IF
448 END IF
449 force_env%globenv => globenv !mc
450 CALL f_env_rm_defaults(f_env, ierr=ierr, &
451 handle=f_env_handle)
452 cpassert(ierr == 0)
453 CALL destroy_force_env(new_env_id, ierr=ierr)
454 cpassert(ierr == 0)
455 ELSE
456 i_was_ionode = para_env%is_source()
457 CALL cp2k_finalize(root_section, para_env, globenv)
458 cpassert(globenv%ref_count == 1)
459 CALL section_vals_release(root_section)
460 CALL globenv_release(globenv)
461 END IF
462
463 CALL dbcsr_finalize_lib()
464
465 CALL mp_para_env_release(para_env)
466
467 END SUBROUTINE cp2k_run
468
469! **************************************************************************************************
470!> \brief performs a farming run that performs several independent cp2k_runs
471!> \param input_declaration ...
472!> \param root_section ...
473!> \param para_env ...
474!> \param initial_variables ...
475!> \author Joost VandeVondele
476!> \note
477!> needs to be part of this module as the cp2k_run -> farming_run -> cp2k_run
478!> calling style creates a hard circular dependency
479! **************************************************************************************************
480 RECURSIVE SUBROUTINE farming_run(input_declaration, root_section, para_env, initial_variables)
481 TYPE(section_type), POINTER :: input_declaration
482 TYPE(section_vals_type), POINTER :: root_section
483 TYPE(mp_para_env_type), POINTER :: para_env
484 CHARACTER(len=default_path_length), DIMENSION(:, :), INTENT(IN) :: initial_variables
485
486 CHARACTER(len=*), PARAMETER :: routineN = 'farming_run'
487 INTEGER, PARAMETER :: minion_status_done = -3, &
488 minion_status_wait = -4
489
490 CHARACTER(len=7) :: label
491 CHARACTER(LEN=default_path_length) :: output_file
492 CHARACTER(LEN=default_string_length) :: str
493 INTEGER :: dest, handle, i, i_job_to_restart, ierr, ijob, ijob_current, &
494 ijob_end, ijob_start, iunit, n_jobs_to_run, new_output_unit, &
495 new_rank, ngroups, num_minions, output_unit, primus_minion, &
496 minion_rank, source, tag, todo
497 INTEGER, DIMENSION(:), POINTER :: group_distribution, &
498 captain_minion_partition, &
499 minion_distribution, &
500 minion_status
501 LOGICAL :: found, captain, minion
502 REAL(KIND=dp) :: t1, t2
503 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: waittime
504 TYPE(cp_logger_type), POINTER :: logger
505 TYPE(cp_parser_type), POINTER :: my_parser
506 TYPE(cp_unit_set_type) :: default_units
507 TYPE(farming_env_type), POINTER :: farming_env
508 TYPE(section_type), POINTER :: g_section
509 TYPE(section_vals_type), POINTER :: g_data
510 TYPE(mp_comm_type) :: minion_group, new_group
511
512 ! the primus of all minions, talks to the captain on topics concerning all minions
513 CALL timeset(routinen, handle)
514 NULLIFY (my_parser, g_section, g_data)
515
516 logger => cp_get_default_logger()
517 output_unit = cp_print_key_unit_nr(logger, root_section, "FARMING%PROGRAM_RUN_INFO", &
518 extension=".log")
519
520 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A)") "FARMING| Hi, welcome on this farm!"
521
522 ALLOCATE (farming_env)
523 CALL init_farming_env(farming_env)
524 ! remember where we started
525 CALL m_getcwd(farming_env%cwd)
526 CALL farming_parse_input(farming_env, root_section, para_env)
527
528 ! the full mpi group is first split in a minion group and a captain group, the latter being at most 1 process
529 minion = .true.
530 captain = .false.
531 IF (farming_env%captain_minion) THEN
532 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A)") "FARMING| Using a Captain-Minion setup"
533
534 ALLOCATE (captain_minion_partition(0:1))
535 captain_minion_partition = (/1, para_env%num_pe - 1/)
536 ALLOCATE (group_distribution(0:para_env%num_pe - 1))
537
538 CALL minion_group%from_split(para_env, ngroups, group_distribution, &
539 n_subgroups=2, group_partition=captain_minion_partition)
540 DEALLOCATE (captain_minion_partition)
541 DEALLOCATE (group_distribution)
542 num_minions = minion_group%num_pe
543 minion_rank = minion_group%mepos
544
545 IF (para_env%mepos == 0) THEN
546 minion = .false.
547 captain = .true.
548 ! on the captain node, num_minions corresponds to the size of the captain group
549 cpassert(num_minions == 1)
550 num_minions = para_env%num_pe - 1
551 minion_rank = -1
552 END IF
553 cpassert(num_minions == para_env%num_pe - 1)
554 ELSE
555 ! all processes are minions
556 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A)") "FARMING| Using a Minion-only setup"
557 CALL minion_group%from_dup(para_env)
558 num_minions = minion_group%num_pe
559 minion_rank = minion_group%mepos
560 END IF
561 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A,I0)") "FARMING| Number of Minions ", num_minions
562
563 ! keep track of which para_env rank is which minion/captain
564 ALLOCATE (minion_distribution(0:para_env%num_pe - 1))
565 minion_distribution = 0
566 minion_distribution(para_env%mepos) = minion_rank
567 CALL para_env%sum(minion_distribution)
568 ! we do have a primus inter pares
569 primus_minion = 0
570 DO i = 1, para_env%num_pe - 1
571 IF (minion_distribution(i) == 0) primus_minion = i
572 END DO
573
574 ! split the current communicator for the minions
575 ! in a new_group, new_size and new_rank according to the number of groups required according to the input
576 ALLOCATE (group_distribution(0:num_minions - 1))
577 group_distribution = -1
578 IF (minion) THEN
579 IF (farming_env%group_size_wish_set) THEN
580 farming_env%group_size_wish = min(farming_env%group_size_wish, para_env%num_pe)
581 CALL new_group%from_split(minion_group, ngroups, group_distribution, &
582 subgroup_min_size=farming_env%group_size_wish, stride=farming_env%stride)
583 ELSE IF (farming_env%ngroup_wish_set) THEN
584 IF (ASSOCIATED(farming_env%group_partition)) THEN
585 CALL new_group%from_split(minion_group, ngroups, group_distribution, &
586 n_subgroups=farming_env%ngroup_wish, &
587 group_partition=farming_env%group_partition, stride=farming_env%stride)
588 ELSE
589 CALL new_group%from_split(minion_group, ngroups, group_distribution, &
590 n_subgroups=farming_env%ngroup_wish, stride=farming_env%stride)
591 END IF
592 ELSE
593 cpabort("must set either group_size_wish or ngroup_wish")
594 END IF
595 new_rank = new_group%mepos
596 END IF
597
598 ! transfer the info about the minion group distribution to the captain
599 IF (farming_env%captain_minion) THEN
600 IF (para_env%mepos == primus_minion) THEN
601 tag = 1
602 CALL para_env%send(group_distribution, 0, tag)
603 tag = 2
604 CALL para_env%send(ngroups, 0, tag)
605 END IF
606 IF (para_env%mepos == 0) THEN
607 tag = 1
608 CALL para_env%recv(group_distribution, primus_minion, tag)
609 tag = 2
610 CALL para_env%recv(ngroups, primus_minion, tag)
611 END IF
612 END IF
613
614 ! write info on group distribution
615 IF (output_unit > 0) THEN
616 WRITE (output_unit, fmt="(T2,A,T71,I10)") "FARMING| Number of created MPI (Minion) groups:", ngroups
617 WRITE (output_unit, fmt="(T2,A)", advance="NO") "FARMING| MPI (Minion) process to group correspondence:"
618 DO i = 0, num_minions - 1
619 IF (modulo(i, 4) == 0) WRITE (output_unit, *)
620 WRITE (output_unit, fmt='(A3,I6,A3,I6,A1)', advance="NO") &
621 " (", i, " : ", group_distribution(i), ")"
622 END DO
623 WRITE (output_unit, *)
624 CALL m_flush(output_unit)
625 END IF
626
627 ! protect about too many jobs being run in single go. Not more jobs are allowed than the number in the input file
628 ! and determine the future restart point
629 IF (farming_env%cycle) THEN
630 n_jobs_to_run = farming_env%max_steps*ngroups
631 i_job_to_restart = modulo(farming_env%restart_n + n_jobs_to_run - 1, farming_env%njobs) + 1
632 ELSE
633 n_jobs_to_run = min(farming_env%njobs, farming_env%max_steps*ngroups)
634 n_jobs_to_run = min(n_jobs_to_run, farming_env%njobs - farming_env%restart_n + 1)
635 i_job_to_restart = n_jobs_to_run + farming_env%restart_n
636 END IF
637
638 ! and write the restart now, that's the point where the next job starts, even if this one is running
639 iunit = cp_print_key_unit_nr(logger, root_section, "FARMING%RESTART", &
640 extension=".restart")
641 IF (iunit > 0) THEN
642 WRITE (iunit, *) i_job_to_restart
643 END IF
644 CALL cp_print_key_finished_output(iunit, logger, root_section, "FARMING%RESTART")
645
646 ! this is the job range to be executed.
647 ijob_start = farming_env%restart_n
648 ijob_end = ijob_start + n_jobs_to_run - 1
649 IF (output_unit > 0 .AND. ijob_end - ijob_start < 0) THEN
650 WRITE (output_unit, fmt="(T2,A)") "FARMING| --- WARNING --- NO JOBS NEED EXECUTION ? "
651 WRITE (output_unit, fmt="(T2,A)") "FARMING| is the cycle keyword required ?"
652 WRITE (output_unit, fmt="(T2,A)") "FARMING| or is a stray RESTART file present ?"
653 WRITE (output_unit, fmt="(T2,A)") "FARMING| or is the group_size requested smaller than the number of CPUs?"
654 END IF
655
656 ! actual executions of the jobs in two different modes
657 IF (farming_env%captain_minion) THEN
658 IF (minion) THEN
659 ! keep on doing work until captain has decided otherwise
660 todo = do_wait
661 DO
662 IF (new_rank == 0) THEN
663 ! the head minion tells the captain he's done or ready to start
664 ! the message tells what has been done lately
665 tag = 1
666 dest = 0
667 CALL para_env%send(todo, dest, tag)
668
669 ! gets the new todo item
670 tag = 2
671 source = 0
672 CALL para_env%recv(todo, source, tag)
673
674 ! and informs his peer minions
675 CALL new_group%bcast(todo, 0)
676 ELSE
677 CALL new_group%bcast(todo, 0)
678 END IF
679
680 ! if the todo is do_nothing we are flagged to quit. Otherwise it is the job number
681 SELECT CASE (todo)
682 CASE (do_wait, do_deadlock)
683 ! go for a next round, but we first wait a bit
684 t1 = m_walltime()
685 DO
686 t2 = m_walltime()
687 IF (t2 - t1 > farming_env%wait_time) EXIT
688 END DO
689 CASE (do_nothing)
690 EXIT
691 CASE (1:)
692 CALL execute_job(todo)
693 END SELECT
694 END DO
695 ELSE ! captain
696 ALLOCATE (minion_status(0:ngroups - 1))
697 minion_status = minion_status_wait
698 ijob_current = ijob_start - 1
699
700 DO
701 IF (all(minion_status == minion_status_done)) EXIT
702
703 ! who's the next minion waiting for work
704 tag = 1
705 source = mp_any_source
706 CALL para_env%recv(todo, source, tag) ! updates source
707 IF (todo > 0) THEN
708 farming_env%Job(todo)%status = job_finished
709 IF (output_unit > 0) THEN
710 WRITE (output_unit, fmt=*) "Job finished: ", todo
711 CALL m_flush(output_unit)
712 END IF
713 END IF
714
715 ! get the next job in line, this could be do_nothing, if we're finished
716 CALL get_next_job(farming_env, ijob_start, ijob_end, ijob_current, todo)
717 dest = source
718 tag = 2
719 CALL para_env%send(todo, dest, tag)
720
721 IF (todo > 0) THEN
722 farming_env%Job(todo)%status = job_running
723 IF (output_unit > 0) THEN
724 WRITE (output_unit, fmt=*) "Job: ", todo, " Dir: ", trim(farming_env%Job(todo)%cwd), &
725 " assigned to group ", group_distribution(minion_distribution(dest))
726 CALL m_flush(output_unit)
727 END IF
728 ELSE
729 IF (todo == do_nothing) THEN
730 minion_status(group_distribution(minion_distribution(dest))) = minion_status_done
731 IF (output_unit > 0) THEN
732 WRITE (output_unit, fmt=*) "group done: ", group_distribution(minion_distribution(dest))
733 CALL m_flush(output_unit)
734 END IF
735 END IF
736 IF (todo == do_deadlock) THEN
737 IF (output_unit > 0) THEN
738 WRITE (output_unit, fmt=*) ""
739 WRITE (output_unit, fmt=*) "FARMING JOB DEADLOCKED ... CIRCULAR DEPENDENCIES"
740 WRITE (output_unit, fmt=*) ""
741 CALL m_flush(output_unit)
742 END IF
743 cpassert(todo .NE. do_deadlock)
744 END IF
745 END IF
746
747 END DO
748
749 DEALLOCATE (minion_status)
750
751 END IF
752 ELSE
753 ! this is the non-captain-minion mode way of executing the jobs
754 ! the i-th job in the input is always executed by the MODULO(i-1,ngroups)-th group
755 ! (needed for cyclic runs, we don't want two groups working on the same job)
756 IF (output_unit > 0) THEN
757 IF (ijob_end - ijob_start >= 0) THEN
758 WRITE (output_unit, fmt="(T2,A)") "FARMING| List of jobs : "
759 DO ijob = ijob_start, ijob_end
760 i = modulo(ijob - 1, farming_env%njobs) + 1
761 WRITE (output_unit, fmt=*) "Job: ", i, " Dir: ", trim(farming_env%Job(i)%cwd), " Input: ", &
762 trim(farming_env%Job(i)%input), " MPI group:", modulo(i - 1, ngroups)
763 END DO
764 END IF
765 CALL m_flush(output_unit)
766 END IF
767
768 DO ijob = ijob_start, ijob_end
769 i = modulo(ijob - 1, farming_env%njobs) + 1
770 ! this farms out the jobs
771 IF (modulo(i - 1, ngroups) == group_distribution(minion_rank)) THEN
772 IF (output_unit > 0) THEN
773 WRITE (output_unit, fmt="(T2,A,I5.5,A)", advance="NO") " Running Job ", i, &
774 " in "//trim(farming_env%Job(i)%cwd)//"."
775 CALL m_flush(output_unit)
776 END IF
777 CALL execute_job(i)
778 IF (output_unit > 0) THEN
779 WRITE (output_unit, fmt="(A)") " Done, output in "//trim(output_file)
780 CALL m_flush(output_unit)
781 END IF
782 END IF
783 END DO
784 END IF
785
786 ! keep information about how long each process has to wait
787 ! i.e. the load imbalance
788 t1 = m_walltime()
789 CALL para_env%sync()
790 t2 = m_walltime()
791 ALLOCATE (waittime(0:para_env%num_pe - 1))
792 waittime = 0.0_dp
793 waittime(para_env%mepos) = t2 - t1
794 CALL para_env%sum(waittime)
795 IF (output_unit > 0) THEN
796 WRITE (output_unit, '(T2,A)') "Process idle times [s] at the end of the run"
797 DO i = 0, para_env%num_pe - 1
798 WRITE (output_unit, fmt='(A2,I6,A3,F8.3,A1)', advance="NO") &
799 " (", i, " : ", waittime(i), ")"
800 IF (mod(i + 1, 4) == 0) WRITE (output_unit, '(A)') ""
801 END DO
802 CALL m_flush(output_unit)
803 END IF
804 DEALLOCATE (waittime)
805
806 ! give back the communicators of the split groups
807 IF (minion) CALL new_group%free()
808 CALL minion_group%free()
809
810 ! and message passing deallocate structures
811 DEALLOCATE (group_distribution)
812 DEALLOCATE (minion_distribution)
813
814 ! clean the farming env
815 CALL deallocate_farming_env(farming_env)
816
817 CALL cp_print_key_finished_output(output_unit, logger, root_section, &
818 "FARMING%PROGRAM_RUN_INFO")
819
820 CALL timestop(handle)
821
822 CONTAINS
823! **************************************************************************************************
824!> \brief ...
825!> \param i ...
826! **************************************************************************************************
827 RECURSIVE SUBROUTINE execute_job(i)
828 INTEGER :: i
829
830 ! change to the new working directory
831
832 CALL m_chdir(trim(farming_env%Job(i)%cwd), ierr)
833 IF (ierr .NE. 0) &
834 cpabort("Failed to change dir to: "//trim(farming_env%Job(i)%cwd))
835
836 ! generate a fresh call to cp2k_run
837 IF (new_rank == 0) THEN
838
839 IF (farming_env%Job(i)%output == "") THEN
840 ! generate the output file
841 WRITE (output_file, '(A12,I5.5)') "FARMING_OUT_", i
842 ALLOCATE (my_parser)
843 CALL parser_create(my_parser, file_name=trim(farming_env%Job(i)%input))
844 label = "&GLOBAL"
845 CALL parser_search_string(my_parser, label, ignore_case=.true., found=found)
846 IF (found) THEN
847 CALL create_global_section(g_section)
848 CALL section_vals_create(g_data, g_section)
849 CALL cp_unit_set_create(default_units, "OUTPUT")
850 CALL section_vals_parse(g_data, my_parser, default_units)
851 CALL cp_unit_set_release(default_units)
852 CALL section_vals_val_get(g_data, "PROJECT", &
853 c_val=str)
854 IF (str .NE. "") output_file = trim(str)//".out"
855 CALL section_vals_val_get(g_data, "OUTPUT_FILE_NAME", &
856 c_val=str)
857 IF (str .NE. "") output_file = str
858 CALL section_vals_release(g_data)
859 CALL section_release(g_section)
860 END IF
861 CALL parser_release(my_parser)
862 DEALLOCATE (my_parser)
863 ELSE
864 output_file = farming_env%Job(i)%output
865 END IF
866
867 CALL open_file(file_name=trim(output_file), &
868 file_action="WRITE", &
869 file_status="UNKNOWN", &
870 file_position="APPEND", &
871 unit_number=new_output_unit)
872 ELSE
873 ! this unit should be negative, otherwise all processors that get a default unit
874 ! start writing output (to the same file, adding to confusion).
875 ! error handling should be careful, asking for a local output unit if required
876 new_output_unit = -1
877 END IF
878
879 CALL cp2k_run(input_declaration, trim(farming_env%Job(i)%input), new_output_unit, new_group, initial_variables)
880
881 IF (new_rank == 0) CALL close_file(unit_number=new_output_unit)
882
883 ! change to the original working directory
884 CALL m_chdir(trim(farming_env%cwd), ierr)
885 cpassert(ierr == 0)
886
887 END SUBROUTINE execute_job
888 END SUBROUTINE farming_run
889
890! **************************************************************************************************
891!> \brief ...
892! **************************************************************************************************
893 SUBROUTINE write_xml_file()
894
895 INTEGER :: i, unit_number
896 TYPE(section_type), POINTER :: root_section
897
898 NULLIFY (root_section)
899 CALL create_cp2k_root_section(root_section)
900 CALL keyword_release(root_section%keywords(0)%keyword)
901 CALL open_file(unit_number=unit_number, &
902 file_name="cp2k_input.xml", &
903 file_action="WRITE", &
904 file_status="REPLACE")
905
906 WRITE (unit=unit_number, fmt="(A)") '<?xml version="1.0" encoding="utf-8"?>'
907
908 !MK CP2K input structure
909 WRITE (unit=unit_number, fmt="(A)") &
910 "<CP2K_INPUT>", &
911 " <CP2K_VERSION>"//trim(cp2k_version)//"</CP2K_VERSION>", &
912 " <CP2K_YEAR>"//trim(cp2k_year)//"</CP2K_YEAR>", &
913 " <COMPILE_DATE>"//trim(compile_date)//"</COMPILE_DATE>", &
914 " <COMPILE_REVISION>"//trim(compile_revision)//"</COMPILE_REVISION>"
915 DO i = 1, root_section%n_subsections
916 CALL write_section_xml(root_section%subsections(i)%section, 1, unit_number)
917 END DO
918
919 WRITE (unit=unit_number, fmt="(A)") "</CP2K_INPUT>"
920 CALL close_file(unit_number=unit_number)
921 CALL section_release(root_section)
922
923 ! References
924 CALL open_file(unit_number=unit_number, file_name="references.html", &
925 file_action="WRITE", file_status="REPLACE")
926 WRITE (unit_number, fmt='(A)') "<HTML><BODY><HEAD><TITLE>The cp2k literature list</TITLE>"
927 WRITE (unit_number, fmt='(A)') "<H1>CP2K references</H1>"
928 CALL print_all_references(sorted=.true., cited_only=.false., &
929 format=print_format_html, unit=unit_number)
930 WRITE (unit_number, fmt='(A)') "</BODY></HTML>"
931 CALL close_file(unit_number=unit_number)
932
933 ! Units
934 CALL open_file(unit_number=unit_number, file_name="units.html", &
935 file_action="WRITE", file_status="REPLACE")
936 WRITE (unit_number, fmt='(A)') "<HTML><BODY><HEAD><TITLE>The cp2k units list</TITLE>"
937 WRITE (unit_number, fmt='(A)') "<H1>CP2K Available Units of Measurement</H1>"
938 CALL print_all_units(unit_nr=unit_number)
939 WRITE (unit_number, fmt='(A)') "</BODY></HTML>"
940 CALL close_file(unit_number=unit_number)
941
942 END SUBROUTINE write_xml_file
943
944! **************************************************************************************************
945!> \brief runs the given input
946!> \param input_declaration ...
947!> \param input_file_path the path of the input file
948!> \param output_file_path path of the output file (to which it is appended)
949!> if it is "__STD_OUT__" the default_output_unit is used
950!> \param initial_variables key-value list of initial preprocessor variables
951!> \param mpi_comm the mpi communicator to be used for this environment
952!> it will not be freed
953!> \author fawzi
954!> \note
955!> moved here because of circular dependencies
956! **************************************************************************************************
957 SUBROUTINE run_input(input_declaration, input_file_path, output_file_path, initial_variables, mpi_comm)
958 TYPE(section_type), POINTER :: input_declaration
959 CHARACTER(len=*), INTENT(in) :: input_file_path, output_file_path
960 CHARACTER(len=default_path_length), &
961 DIMENSION(:, :), INTENT(IN) :: initial_variables
962 TYPE(mp_comm_type), INTENT(in), OPTIONAL :: mpi_comm
963
964 INTEGER :: unit_nr
965 TYPE(mp_para_env_type), POINTER :: para_env
966
967 IF (PRESENT(mpi_comm)) THEN
968 ALLOCATE (para_env)
969 para_env = mpi_comm
970 ELSE
971 para_env => f77_default_para_env
972 CALL para_env%retain()
973 END IF
974 IF (para_env%is_source()) THEN
975 IF (output_file_path == "__STD_OUT__") THEN
976 unit_nr = default_output_unit
977 ELSE
978 INQUIRE (file=output_file_path, number=unit_nr)
979 END IF
980 ELSE
981 unit_nr = -1
982 END IF
983 CALL cp2k_run(input_declaration, input_file_path, unit_nr, para_env, initial_variables)
984 CALL mp_para_env_release(para_env)
985 END SUBROUTINE run_input
986
987END MODULE cp2k_runs
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
void apply_cutoff(void *ptr)
void grid_library_print_stats(void(*mpi_sum_func)(long *, int), const int mpi_comm, void(*print_func)(char *, int), const int output_unit)
Prints statistics gathered by the grid library.
void grid_library_set_config(const enum grid_backend backend, const bool validate, const bool apply_cutoff)
Configures the grid library.
Definition atom.F:9
subroutine, public atom_code(root_section)
Driver routine to perform atomic calculations.
Definition atom.F:46
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public hutter2014
Module to perform a counterpoise correction (BSSE)
Definition bsse.F:14
subroutine, public do_bsse_calculation(force_env, globenv)
Perform an COUNTERPOISE CORRECTION (BSSE) For a 2-body system the correction scheme can be represente...
Definition bsse.F:80
performs CELL optimization
Definition cell_opt.F:13
subroutine, public cp_cell_opt(force_env, globenv)
Main driver to perform geometry optimization.
Definition cell_opt.F:56
Debug energy and derivatives w.r.t. finite differences.
Definition cp2k_debug.F:26
subroutine, public cp2k_debug_energy_and_forces(force_env)
...
Definition cp2k_debug.F:76
some minimal info about CP2K, including its version and license
Definition cp2k_info.F:16
character(len= *), parameter, public compile_revision
Definition cp2k_info.F:37
character(len= *), parameter, public compile_date
Definition cp2k_info.F:55
character(len= *), parameter, public cp2k_year
Definition cp2k_info.F:42
character(len= *), parameter, public cp2k_version
Definition cp2k_info.F:41
subroutine, public run_input(input_declaration, input_file_path, output_file_path, initial_variables, mpi_comm)
runs the given input
Definition cp2k_runs.F:958
subroutine, public write_xml_file()
...
Definition cp2k_runs.F:894
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public cp_dlaf_finalize()
Finalize DLA-Future and pika runtime.
subroutine, public cp_dlaf_initialize()
Initialize DLA-Future and pika runtime.
Utility routines to open and close files. Tracking of preconnections.
Definition cp_files.F:16
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
Definition cp_files.F:308
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Definition cp_files.F:119
various routines to log and control the output. The idea is that decisions about where to log should ...
logical function, public cp_logger_would_log(logger, level)
this function can be called to check if the logger would log a message with the given level from the ...
integer, parameter, public cp_note_level
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
subroutine, public cp_rm_iter_level(iteration_info, level_name, n_rlevel_att)
Removes an iteration level.
subroutine, public cp_add_iter_level(iteration_info, level_name, n_rlevel_new)
Adds an iteration level.
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_search_string(parser, string, ignore_case, found, line, begin_line, search_from_begin_of_file)
Search a string pattern in a file defined by its logical unit number "unit". A case sensitive search ...
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 print_all_units(unit_nr)
Prints info on all available units in CP2K.
Definition cp_units.F:1316
subroutine, public cp_unit_set_release(unit_set)
releases the given unit set
Definition cp_units.F:1299
subroutine, public cp_unit_set_create(unit_set, name)
initializes the given unit set
Definition cp_units.F:1228
subroutine validate(matrix)
Dummy for when DBM_VALIDATE_AGAINST_DBCSR is not defined.
Definition dbm_api.F:251
subroutine, public dbm_library_print_stats(mpi_comm, output_unit)
Print DBM library statistics.
Definition dbm_api.F:1513
Sets up and terminates the global environment variables.
Definition environment.F:17
subroutine, public cp2k_finalize(root_section, para_env, globenv, wdir, q_finalize)
Writes final timings and banner for CP2K.
subroutine, public cp2k_read(root_section, para_env, globenv)
read part of cp2k_init
subroutine, public cp2k_init(para_env, output_unit, globenv, input_file_name, wdir)
Initializes a CP2K run (setting of the global environment variables)
subroutine, public cp2k_setup(root_section, para_env, globenv)
globenv initializations that need the input and error
interface to use cp2k as library
recursive subroutine, public destroy_force_env(env_id, ierr, q_finalize)
deallocates the force_env with the given id
subroutine, public f_env_add_defaults(f_env_id, f_env, handle)
adds the default environments of the f_env to the stack of the defaults, and returns a new error and ...
type(mp_para_env_type), pointer, save, public default_para_env
recursive subroutine, public create_force_env(new_env_id, input_declaration, input_path, output_path, mpi_comm, output_unit, owns_out_unit, input, ierr, work_dir, initial_variables)
creates a new force environment using the given input, and writing the output to the given output uni...
subroutine, public f_env_rm_defaults(f_env, ierr, handle)
removes the default environments of the f_env to the stack of the defaults, and sets ierr accordingly...
recursive subroutine, public calc_force(env_id, pos, n_el_pos, e_pot, force, n_el_force, ierr)
returns the energy of the configuration given by the positions passed as argument
subroutine, public farming_parse_input(farming_env, root_section, para_env)
...
integer, parameter, public do_nothing
integer, parameter, public do_wait
subroutine, public get_next_job(farming_env, start, end, current, todo)
...
integer, parameter, public do_deadlock
subroutine, public deallocate_farming_env(farming_env)
deallocates all associated fields of the farming_env type and the type itself
integer, parameter, public job_finished
integer, parameter, public job_running
subroutine, public init_farming_env(farming_env)
help poor compilers do their job i.e. provide a default initialization
Interface for the force calculations.
recursive subroutine, public force_env_calc_energy_force(force_env, calc_force, consistent_energies, skip_external_control, eval_energy_forces, require_consistent_energy_force, linres, calc_stress_tensor)
Interface routine for force and energy calculations.
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env)
returns various attributes about the force environment
performs geometry optimization
Definition geo_opt.F:13
subroutine, public cp_geo_opt(force_env, globenv, eval_opt_geo, rm_restart_info)
Main driver to perform geometry optimization.
Definition geo_opt.F:58
Define type storing the global information of a run. Keep the amount of stored data small....
subroutine, public globenv_create(globenv)
Creates the global environment globenv.
subroutine, public globenv_release(globenv)
Releases the global environment globenv.
Fortran API for the grid package, which is written in C.
Definition grid_api.F:12
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public driver_run
integer, parameter, public energy_run
integer, parameter, public do_farming
integer, parameter, public electronic_spectra_run
integer, parameter, public do_nnp
integer, parameter, public do_cp2k
integer, parameter, public linear_response_run
integer, parameter, public do_tamc
integer, parameter, public ehrenfest
integer, parameter, public do_opt_basis
integer, parameter, public debug_run
integer, parameter, public do_test
integer, parameter, public do_fist
integer, parameter, public do_qmmm
integer, parameter, public do_embed
integer, parameter, public do_sirius
integer, parameter, public do_band
integer, parameter, public do_tree_mc
integer, parameter, public bsse_run
integer, parameter, public energy_force_run
integer, parameter, public do_optimize_input
integer, parameter, public do_atom
integer, parameter, public mon_car_run
integer, parameter, public do_tree_mc_ana
integer, parameter, public mol_dyn_run
integer, parameter, public cell_opt_run
integer, parameter, public pint_run
integer, parameter, public vib_anal
integer, parameter, public none_run
integer, parameter, public negf_run
integer, parameter, public do_qs
integer, parameter, public do_mixed
integer, parameter, public tree_mc_run
integer, parameter, public real_time_propagation
integer, parameter, public geo_opt_run
integer, parameter, public do_swarm
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
builds the global input section for cp2k
subroutine, public create_global_section(section)
section to hold global settings for the whole program
parse cp2k input files
type(section_vals_type) function, pointer, public read_input(input_declaration, file_path, initial_variables, para_env)
reads the cp2k input from the given filepath and returns a section_vals containing the input
builds the input structure for cp2k
Definition input_cp2k.F:14
subroutine, public create_cp2k_root_section(root_section)
creates the input structure of the file used by cp2k
Definition input_cp2k.F:75
represents keywords in an input
subroutine, public keyword_release(keyword)
releases the given keyword (see doc/ReferenceCounting.html)
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
recursive subroutine, public write_section_xml(section, level, unit_number)
writes the values in the given section in xml
recursive subroutine, public section_vals_create(section_vals, section)
creates a object where to store the values of a section
subroutine, public section_vals_retain(section_vals)
retains the given section values (see doc/ReferenceCounting.html)
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
recursive subroutine, public section_release(section)
releases the given keyword list (see doc/ReferenceCounting.html)
recursive subroutine, public section_vals_write(section_vals, unit_nr, hide_root, hide_defaults)
writes the values in the given section in a way that is suitable to the automatic parsing
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
Driver mode - To communicate with i-PI Python wrapper.
Definition ipi_driver.F:14
subroutine, public run_driver(force_env, globenv)
...
Definition ipi_driver.F:76
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public int_8
Definition kinds.F:54
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
Performance tests for basic tasks like matrix multiplies, copy, fft.
subroutine, public lib_test(root_section, para_env, globenv)
Master routine for tests.
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
integer, parameter, public default_output_unit
Definition machine.F:45
subroutine, public m_memory(mem)
Returns the total amount of memory [bytes] in use, if known, zero otherwise.
Definition machine.F:332
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition machine.F:106
subroutine, public m_getcwd(curdir)
...
Definition machine.F:507
subroutine, public m_chdir(dir, ierror)
...
Definition machine.F:536
integer(kind=int_8), save, public m_memory_max
Definition machine.F:93
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition machine.F:123
preps the system for a Monte Carlo run (sets up some environments, calls the routines to read in the ...
Definition mc_run.F:40
subroutine, public do_mon_car(force_env_1, globenv, input_declaration, input_file_name)
starts the Monte Carlo simulation and determines which ensemble we're running
Definition mc_run.F:103
Perform a molecular dynamics (MD) run using QUICKSTEP.
Definition md_run.F:14
subroutine, public qs_mol_dyn(force_env, globenv, averages, rm_restart_info, hmc_e_initial, hmc_e_final, mdctrl)
Main driver module for Molecular Dynamics.
Definition md_run.F:121
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
integer, parameter, public mp_any_source
Subroutines to perform calculations on molecules from a bigger system. Useful to generate a high-qual...
subroutine, public loop_over_molecules(globenv, force_env)
Prepare data for calculations on isolated molecules.
logical function, public do_mol_loop(force_env)
Is the loop over molecules requested?
Module performing a Nudged Elastic Band Calculation.
Definition neb_methods.F:23
subroutine, public neb(input, input_declaration, para_env, globenv)
Real subroutine for NEB calculations.
Definition neb_methods.F:93
NEGF based quantum transport calculations.
subroutine, public do_negf(force_env)
Perform NEGF calculation.
Fortran API for the offload package, which is written in C.
Definition offload_api.F:12
integer function, public offload_get_device_count()
Returns the number of available devices.
integer function, public offload_get_chosen_device()
Returns the chosen device.
subroutine, public run_optimize_basis(input_declaration, root_section, para_env)
main entry point for methods aimed at optimizing basis sets
subroutine, public run_optimize_input(input_declaration, root_section, para_env)
main entry point for methods aimed at optimizing parameters in a CP2K input file
Methods to performs a path integral run.
subroutine, public do_pint_run(para_env, input, input_declaration, globenv)
Perform a path integral simulation.
subroutine, public pw_fpga_finalize()
Releases resources on the fpga device.
Definition pw_fpga.F:135
subroutine, public pw_fpga_init()
Allocates resources on the fpga device.
Definition pw_fpga.F:112
subroutine, public pw_gpu_init()
Allocates resources on the gpu device for gpu fft acceleration.
Definition pw_gpu.F:63
subroutine, public pw_gpu_finalize()
Releases resources on the gpu device for gpu fft acceleration.
Definition pw_gpu.F:82
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
Contains the setup for the calculation of properties by linear response by the application of second ...
subroutine, public linres_calculation(force_env)
Driver for the linear response calculatios.
Performs density functional perturbation theory (tddfpt) calculations. Uses the self consistent appro...
subroutine, public tddfpt_calculation(qs_env)
Performs the perturbation calculation.
provides a uniform framework to add references to CP2K cite and output these
subroutine, public print_all_references(cited_only, sorted, format, unit, list)
printout of all references in a specific format optionally printing only those that are actually cite...
subroutine, public cite_reference(key)
marks a given reference as cited.
integer, parameter, public print_format_html
Routines for the real time propagation.
subroutine, public rt_prop_setup(force_env)
creates rtp_type, gets the initial state, either by reading MO's from file or calling SCF run
Interface to the SIRIUS Library.
subroutine, public cp_sirius_init()
Empty implementation in case SIRIUS is not compiled in.
subroutine, public cp_sirius_finalize()
Empty implementation in case SIRIUS is not compiled in.
Swarm-framwork, provides a convenient master/worker architecture.
Definition swarm.F:12
subroutine, public run_swarm(input_declaration, root_section, para_env, globenv, input_path)
Central driver routine of the swarm framework, called by cp2k_runs.F.
Definition swarm.F:62
Perform a temperature accelarated hybrid monte carlo (TAHMC) run using QUICKSTEP.
Definition tamc_run.F:14
subroutine, public qs_tamc(force_env, globenv, averages)
Driver routine for TAHMC.
Definition tamc_run.F:147
Tree Monte Carlo entry point, set up, CPU redistribution and input reading.
Definition tmc_setup.F:16
subroutine, public do_analyze_files(input_declaration, root_section, para_env)
analyze TMC trajectory files
Definition tmc_setup.F:348
subroutine, public do_tmc(input_declaration, root_section, para_env, globenv)
tmc_entry point
Definition tmc_setup.F:98
Module performing a vibrational analysis.
subroutine, public vb_anal(input, input_declaration, para_env, globenv)
Module performing a vibrational analysis.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores the default units to be used
Definition cp_units.F:150
wrapper to abstract the force evaluation of the various methods
contains the initially parsed file and the initial parallel environment
represent a section of the input file
stores all the informations relevant to an mpi environment