(git:298f7c4)
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-2025 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,&
21 USE cp_dbcsr_api, ONLY: dbcsr_finalize_lib,&
22 dbcsr_init_lib,&
23 dbcsr_print_config,&
24 dbcsr_print_statistics
26 USE cp_files, ONLY: close_file,&
41 USE cp_units, ONLY: cp_unit_set_create,&
46 USE environment, ONLY: cp2k_finalize,&
47 cp2k_init,&
48 cp2k_read,&
52 f77_default_para_env => default_para_env,&
56 USE farming_methods, ONLY: do_deadlock,&
58 do_wait,&
69 USE geo_opt, ONLY: cp_geo_opt
75 USE input_constants, ONLY: &
87 USE input_section_types, ONLY: &
91 USE ipi_driver, ONLY: run_driver
92 USE kinds, ONLY: default_path_length,&
94 dp,&
95 int_8
96 USE library_tests, ONLY: lib_test
97 USE machine, ONLY: default_output_unit,&
98 m_chdir,&
99 m_flush,&
100 m_getcwd,&
101 m_memory,&
104 USE mc_run, ONLY: do_mon_car
105 USE md_run, ONLY: qs_mol_dyn
106 USE message_passing, ONLY: mp_any_source,&
110 USE mscfg_methods, ONLY: do_mol_loop,&
112 USE neb_methods, ONLY: neb
113 USE negf_methods, ONLY: do_negf
119 USE pint_methods, ONLY: do_pint_run
123 USE rt_bse, ONLY: run_propagation_bse
125 USE swarm, ONLY: run_swarm
126 USE tamc_run, ONLY: qs_tamc
127 USE tmc_setup, ONLY: do_analyze_files,&
128 do_tmc
130#include "../base/base_uses.f90"
131
132 IMPLICIT NONE
133
134 PRIVATE
135
136 PUBLIC :: write_xml_file, run_input
137
138 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp2k_runs'
139
140CONTAINS
141
142! **************************************************************************************************
143!> \brief performs an instance of a cp2k run
144!> \param input_declaration ...
145!> \param input_file_name name of the file to be opened for input
146!> \param output_unit unit to which output should be written
147!> \param mpi_comm ...
148!> \param initial_variables key-value list of initial preprocessor variables
149!> \author Joost VandeVondele
150!> \note
151!> para_env should be a valid communicator
152!> output_unit should be writeable by at least the lowest rank of the mpi group
153!>
154!> recursive because a given run_type might need to be able to perform
155!> another cp2k_run as part of its job (e.g. farming, classical equilibration, ...)
156!>
157!> the idea is that a cp2k instance should be able to run with just three
158!> arguments, i.e. a given input file, output unit, mpi communicator.
159!> giving these three to cp2k_run should produce a valid run.
160!> the only task of the PROGRAM cp2k is to create valid instances of the
161!> above arguments. Ideally, anything that is called afterwards should be
162!> able to run simultaneously / multithreaded / sequential / parallel / ...
163!> and able to fail safe
164! **************************************************************************************************
165 RECURSIVE SUBROUTINE cp2k_run(input_declaration, input_file_name, output_unit, mpi_comm, initial_variables)
166 TYPE(section_type), POINTER :: input_declaration
167 CHARACTER(LEN=*), INTENT(IN) :: input_file_name
168 INTEGER, INTENT(IN) :: output_unit
169
170 CLASS(mp_comm_type) :: mpi_comm
171 CHARACTER(len=default_path_length), &
172 DIMENSION(:, :), INTENT(IN) :: initial_variables
173
174 INTEGER :: f_env_handle, grid_backend, ierr, &
175 iter_level, method_name_id, &
176 new_env_id, prog_name_id, run_type_id
177#if defined(__DBCSR_ACC)
178 INTEGER, TARGET :: offload_chosen_device
179#endif
180 INTEGER, POINTER :: active_device_id
181 INTEGER(KIND=int_8) :: m_memory_max_mpi
182 LOGICAL :: echo_input, grid_apply_cutoff, &
183 grid_validate, I_was_ionode
184 TYPE(cp_logger_type), POINTER :: logger, sublogger
185 TYPE(mp_para_env_type), POINTER :: para_env
186 TYPE(dft_control_type), POINTER :: dft_control
187 TYPE(f_env_type), POINTER :: f_env
188 TYPE(force_env_type), POINTER :: force_env
189 TYPE(global_environment_type), POINTER :: globenv
190 TYPE(section_vals_type), POINTER :: glob_section, input_file, root_section
191
192 NULLIFY (para_env, f_env, dft_control, active_device_id)
193 ALLOCATE (para_env)
194 para_env = mpi_comm
195
196#if defined(__DBCSR_ACC)
197 IF (offload_get_device_count() > 0) THEN
198 offload_chosen_device = offload_get_chosen_device()
199 active_device_id => offload_chosen_device
200 END IF
201#endif
202 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit, &
203 accdrv_active_device_id=active_device_id)
204
205 NULLIFY (globenv, force_env)
206
208
209 ! parse the input
210 input_file => read_input(input_declaration, input_file_name, initial_variables=initial_variables, &
211 para_env=para_env)
212
213 CALL para_env%sync()
214
215 glob_section => section_vals_get_subs_vals(input_file, "GLOBAL")
216 CALL section_vals_val_get(glob_section, "ECHO_INPUT", l_val=echo_input)
217 logger => cp_get_default_logger()
218 IF (echo_input) THEN
219 CALL section_vals_write(input_file, &
220 unit_nr=cp_logger_get_default_io_unit(logger), &
221 hide_root=.true., hide_defaults=.false.)
222 END IF
223
224 CALL check_cp2k_input(input_declaration, input_file, para_env=para_env, output_unit=output_unit)
225 root_section => input_file
226 CALL section_vals_val_get(input_file, "GLOBAL%PROGRAM_NAME", &
227 i_val=prog_name_id)
228 CALL section_vals_val_get(input_file, "GLOBAL%RUN_TYPE", &
229 i_val=run_type_id)
230 CALL section_vals_val_get(root_section, "FORCE_EVAL%METHOD", i_val=method_name_id)
231
232 IF (prog_name_id /= do_cp2k) THEN
233 ! initial setup (cp2k does in in the creation of the force_env)
234 CALL globenv_create(globenv)
235 CALL section_vals_retain(input_file)
236 CALL cp2k_init(para_env, output_unit, globenv, input_file_name=input_file_name)
237 CALL cp2k_read(root_section, para_env, globenv)
238 CALL cp2k_setup(root_section, para_env, globenv)
239 END IF
240
241 CALL cp_dbcsr_config(root_section)
242 IF (output_unit > 0 .AND. &
244 CALL dbcsr_print_config(unit_nr=output_unit)
245 WRITE (unit=output_unit, fmt='()')
246 END IF
247
248 ! Configure the grid library.
249 CALL section_vals_val_get(root_section, "GLOBAL%GRID%BACKEND", i_val=grid_backend)
250 CALL section_vals_val_get(root_section, "GLOBAL%GRID%VALIDATE", l_val=grid_validate)
251 CALL section_vals_val_get(root_section, "GLOBAL%GRID%APPLY_CUTOFF", l_val=grid_apply_cutoff)
252
253 CALL grid_library_set_config(backend=grid_backend, &
254 validate=grid_validate, &
255 apply_cutoff=grid_apply_cutoff)
256
257 SELECT CASE (prog_name_id)
258 CASE (do_atom)
259 globenv%run_type_id = none_run
260 CALL atom_code(root_section)
261 CASE (do_optimize_input)
262 CALL run_optimize_input(input_declaration, root_section, para_env)
263 CASE (do_swarm)
264 CALL run_swarm(input_declaration, root_section, para_env, globenv, input_file_name)
265 CASE (do_farming) ! TODO: refactor cp2k's startup code
266 CALL dbcsr_finalize_lib()
267 CALL farming_run(input_declaration, root_section, para_env, initial_variables)
268 CALL dbcsr_init_lib(mpi_comm%get_handle(), io_unit=output_unit, &
269 accdrv_active_device_id=active_device_id)
270 CASE (do_opt_basis)
271 CALL run_optimize_basis(input_declaration, root_section, para_env)
272 globenv%run_type_id = none_run
273 CASE (do_cp2k)
274 CALL create_force_env(new_env_id, &
275 input_declaration=input_declaration, &
276 input_path=input_file_name, &
277 output_path="__STD_OUT__", mpi_comm=para_env, &
278 output_unit=output_unit, &
279 owns_out_unit=.false., &
280 input=input_file, ierr=ierr)
281 cpassert(ierr == 0)
282 CALL f_env_add_defaults(new_env_id, f_env, handle=f_env_handle)
283 force_env => f_env%force_env
284 CALL force_env_get(force_env, globenv=globenv)
285 CASE (do_test)
286 CALL lib_test(root_section, para_env, globenv)
287 CASE (do_tree_mc) ! TMC entry point
288 CALL do_tmc(input_declaration, root_section, para_env, globenv)
289 CASE (do_tree_mc_ana)
290 CALL do_analyze_files(input_declaration, root_section, para_env)
291 CASE default
292 cpabort("")
293 END SELECT
294 CALL section_vals_release(input_file)
295
296 SELECT CASE (globenv%run_type_id)
297 CASE (pint_run)
298 CALL do_pint_run(para_env, root_section, input_declaration, globenv)
299 CASE (none_run, tree_mc_run)
300 ! do nothing
301 CASE (driver_run)
302 CALL run_driver(force_env, globenv)
304 IF (method_name_id /= do_qs .AND. &
305 method_name_id /= do_sirius .AND. &
306 method_name_id /= do_qmmm .AND. &
307 method_name_id /= do_mixed .AND. &
308 method_name_id /= do_nnp .AND. &
309 method_name_id /= do_embed .AND. &
310 method_name_id /= do_fist .AND. &
311 method_name_id /= do_ipi) &
312 cpabort("Energy/Force run not available for all methods ")
313
314 sublogger => cp_get_default_logger()
315 CALL cp_add_iter_level(sublogger%iter_info, "JUST_ENERGY", &
316 n_rlevel_new=iter_level)
317
318 ! loop over molecules to generate a molecular guess
319 ! this procedure is initiated here to avoid passing globenv deep down
320 ! the subroutine stack
321 IF (do_mol_loop(force_env=force_env)) &
322 CALL loop_over_molecules(globenv, force_env)
323
324 SELECT CASE (globenv%run_type_id)
325 CASE (energy_run)
326 CALL force_env_calc_energy_force(force_env, calc_force=.false.)
327 CASE (energy_force_run)
328 CALL force_env_calc_energy_force(force_env, calc_force=.true.)
329 CASE default
330 cpabort("")
331 END SELECT
332 CALL cp_rm_iter_level(sublogger%iter_info, level_name="JUST_ENERGY", n_rlevel_att=iter_level)
333 CASE (mol_dyn_run)
334 CALL qs_mol_dyn(force_env, globenv)
335 CASE (geo_opt_run)
336 CALL cp_geo_opt(force_env, globenv)
337 CASE (cell_opt_run)
338 CALL cp_cell_opt(force_env, globenv)
339 CASE (mon_car_run)
340 CALL do_mon_car(force_env, globenv, input_declaration, input_file_name)
341 CASE (do_tamc)
342 CALL qs_tamc(force_env, globenv)
344 IF (method_name_id /= do_qs) &
345 cpabort("Real time propagation needs METHOD QS. ")
346 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
347 dft_control%rtp_control%fixed_ions = .true.
348 SELECT CASE (dft_control%rtp_control%rtp_method)
349 CASE (rtp_method_bse)
350 ! Run the TD-BSE method
351 CALL run_propagation_bse(force_env%qs_env, force_env)
352 CASE default
353 ! Run the TDDFT method
354 CALL rt_prop_setup(force_env)
355 END SELECT
356 CASE (ehrenfest)
357 IF (method_name_id /= do_qs) &
358 cpabort("Ehrenfest dynamics needs METHOD QS ")
359 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
360 dft_control%rtp_control%fixed_ions = .false.
361 CALL qs_mol_dyn(force_env, globenv)
362 CASE (bsse_run)
363 CALL do_bsse_calculation(force_env, globenv)
365 IF (method_name_id /= do_qs .AND. &
366 method_name_id /= do_qmmm) &
367 cpabort("Property calculations by Linear Response only within the QS or QMMM program ")
368 ! The Ground State is needed, it can be read from Restart
369 CALL force_env_calc_energy_force(force_env, calc_force=.false., linres=.true.)
370 CALL linres_calculation(force_env)
371 CASE (debug_run)
372 SELECT CASE (method_name_id)
373 CASE (do_qs, do_qmmm, do_fist)
374 CALL cp2k_debug_energy_and_forces(force_env)
375 CASE DEFAULT
376 cpabort("Debug run available only with QS, FIST, and QMMM program ")
377 END SELECT
378 CASE (vib_anal)
379 CALL vb_anal(root_section, input_declaration, para_env, globenv)
380 CASE (do_band)
381 CALL neb(root_section, input_declaration, para_env, globenv)
382 CASE (negf_run)
383 CALL do_negf(force_env)
384 CASE default
385 cpabort("")
386 END SELECT
387
388 ! Sample peak memory
389 CALL m_memory()
390
391 CALL dbcsr_print_statistics()
392 CALL dbm_library_print_stats(mpi_comm=mpi_comm, output_unit=output_unit)
393 CALL grid_library_print_stats(mpi_comm=mpi_comm, output_unit=output_unit)
394 CALL offload_mempool_stats_print(mpi_comm=mpi_comm, output_unit=output_unit)
395
396 m_memory_max_mpi = m_memory_max
397 CALL mpi_comm%max(m_memory_max_mpi)
398 IF (output_unit > 0) THEN
399 WRITE (output_unit, *)
400 WRITE (output_unit, '(T2,"MEMORY| Estimated peak process memory [MiB]",T73,I8)') &
401 (m_memory_max_mpi + (1024*1024) - 1)/(1024*1024)
402 END IF
403
404 IF (prog_name_id == do_cp2k) THEN
405 f_env%force_env => force_env ! for mc
406 IF (ASSOCIATED(force_env%globenv)) THEN
407 IF (.NOT. ASSOCIATED(force_env%globenv, globenv)) THEN
408 CALL globenv_release(force_env%globenv) !mc
409 END IF
410 END IF
411 force_env%globenv => globenv !mc
412 CALL f_env_rm_defaults(f_env, ierr=ierr, &
413 handle=f_env_handle)
414 cpassert(ierr == 0)
415 CALL destroy_force_env(new_env_id, ierr=ierr)
416 cpassert(ierr == 0)
417 ELSE
418 i_was_ionode = para_env%is_source()
419 CALL cp2k_finalize(root_section, para_env, globenv)
420 cpassert(globenv%ref_count == 1)
421 CALL section_vals_release(root_section)
422 CALL globenv_release(globenv)
423 END IF
424
425 CALL dbcsr_finalize_lib()
426
427 CALL mp_para_env_release(para_env)
428
429 END SUBROUTINE cp2k_run
430
431! **************************************************************************************************
432!> \brief performs a farming run that performs several independent cp2k_runs
433!> \param input_declaration ...
434!> \param root_section ...
435!> \param para_env ...
436!> \param initial_variables ...
437!> \author Joost VandeVondele
438!> \note
439!> needs to be part of this module as the cp2k_run -> farming_run -> cp2k_run
440!> calling style creates a hard circular dependency
441! **************************************************************************************************
442 RECURSIVE SUBROUTINE farming_run(input_declaration, root_section, para_env, initial_variables)
443 TYPE(section_type), POINTER :: input_declaration
444 TYPE(section_vals_type), POINTER :: root_section
445 TYPE(mp_para_env_type), POINTER :: para_env
446 CHARACTER(len=default_path_length), DIMENSION(:, :), INTENT(IN) :: initial_variables
447
448 CHARACTER(len=*), PARAMETER :: routineN = 'farming_run'
449 INTEGER, PARAMETER :: minion_status_done = -3, &
450 minion_status_wait = -4
451
452 CHARACTER(len=7) :: label
453 CHARACTER(LEN=default_path_length) :: output_file
454 CHARACTER(LEN=default_string_length) :: str
455 INTEGER :: dest, handle, i, i_job_to_restart, ierr, ijob, ijob_current, &
456 ijob_end, ijob_start, iunit, n_jobs_to_run, new_output_unit, &
457 new_rank, ngroups, num_minions, output_unit, primus_minion, &
458 minion_rank, source, tag, todo
459 INTEGER, DIMENSION(:), POINTER :: group_distribution, &
460 captain_minion_partition, &
461 minion_distribution, &
462 minion_status
463 LOGICAL :: found, captain, minion
464 REAL(KIND=dp) :: t1, t2
465 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: waittime
466 TYPE(cp_logger_type), POINTER :: logger
467 TYPE(cp_parser_type), POINTER :: my_parser
468 TYPE(cp_unit_set_type) :: default_units
469 TYPE(farming_env_type), POINTER :: farming_env
470 TYPE(section_type), POINTER :: g_section
471 TYPE(section_vals_type), POINTER :: g_data
472 TYPE(mp_comm_type) :: minion_group, new_group
473
474 ! the primus of all minions, talks to the captain on topics concerning all minions
475 CALL timeset(routinen, handle)
476 NULLIFY (my_parser, g_section, g_data)
477
478 logger => cp_get_default_logger()
479 output_unit = cp_print_key_unit_nr(logger, root_section, "FARMING%PROGRAM_RUN_INFO", &
480 extension=".log")
481
482 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A)") "FARMING| Hi, welcome on this farm!"
483
484 ALLOCATE (farming_env)
485 CALL init_farming_env(farming_env)
486 ! remember where we started
487 CALL m_getcwd(farming_env%cwd)
488 CALL farming_parse_input(farming_env, root_section, para_env)
489
490 ! the full mpi group is first split in a minion group and a captain group, the latter being at most 1 process
491 minion = .true.
492 captain = .false.
493 IF (farming_env%captain_minion) THEN
494 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A)") "FARMING| Using a Captain-Minion setup"
495
496 ALLOCATE (captain_minion_partition(0:1))
497 captain_minion_partition = (/1, para_env%num_pe - 1/)
498 ALLOCATE (group_distribution(0:para_env%num_pe - 1))
499
500 CALL minion_group%from_split(para_env, ngroups, group_distribution, &
501 n_subgroups=2, group_partition=captain_minion_partition)
502 DEALLOCATE (captain_minion_partition)
503 DEALLOCATE (group_distribution)
504 num_minions = minion_group%num_pe
505 minion_rank = minion_group%mepos
506
507 IF (para_env%mepos == 0) THEN
508 minion = .false.
509 captain = .true.
510 ! on the captain node, num_minions corresponds to the size of the captain group
511 cpassert(num_minions == 1)
512 num_minions = para_env%num_pe - 1
513 minion_rank = -1
514 END IF
515 cpassert(num_minions == para_env%num_pe - 1)
516 ELSE
517 ! all processes are minions
518 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A)") "FARMING| Using a Minion-only setup"
519 CALL minion_group%from_dup(para_env)
520 num_minions = minion_group%num_pe
521 minion_rank = minion_group%mepos
522 END IF
523 IF (output_unit > 0) WRITE (output_unit, fmt="(T2,A,I0)") "FARMING| Number of Minions ", num_minions
524
525 ! keep track of which para_env rank is which minion/captain
526 ALLOCATE (minion_distribution(0:para_env%num_pe - 1))
527 minion_distribution = 0
528 minion_distribution(para_env%mepos) = minion_rank
529 CALL para_env%sum(minion_distribution)
530 ! we do have a primus inter pares
531 primus_minion = 0
532 DO i = 1, para_env%num_pe - 1
533 IF (minion_distribution(i) == 0) primus_minion = i
534 END DO
535
536 ! split the current communicator for the minions
537 ! in a new_group, new_size and new_rank according to the number of groups required according to the input
538 ALLOCATE (group_distribution(0:num_minions - 1))
539 group_distribution = -1
540 IF (minion) THEN
541 IF (farming_env%group_size_wish_set) THEN
542 farming_env%group_size_wish = min(farming_env%group_size_wish, para_env%num_pe)
543 CALL new_group%from_split(minion_group, ngroups, group_distribution, &
544 subgroup_min_size=farming_env%group_size_wish, stride=farming_env%stride)
545 ELSE IF (farming_env%ngroup_wish_set) THEN
546 IF (ASSOCIATED(farming_env%group_partition)) THEN
547 CALL new_group%from_split(minion_group, ngroups, group_distribution, &
548 n_subgroups=farming_env%ngroup_wish, &
549 group_partition=farming_env%group_partition, stride=farming_env%stride)
550 ELSE
551 CALL new_group%from_split(minion_group, ngroups, group_distribution, &
552 n_subgroups=farming_env%ngroup_wish, stride=farming_env%stride)
553 END IF
554 ELSE
555 cpabort("must set either group_size_wish or ngroup_wish")
556 END IF
557 new_rank = new_group%mepos
558 END IF
559
560 ! transfer the info about the minion group distribution to the captain
561 IF (farming_env%captain_minion) THEN
562 IF (para_env%mepos == primus_minion) THEN
563 tag = 1
564 CALL para_env%send(group_distribution, 0, tag)
565 tag = 2
566 CALL para_env%send(ngroups, 0, tag)
567 END IF
568 IF (para_env%mepos == 0) THEN
569 tag = 1
570 CALL para_env%recv(group_distribution, primus_minion, tag)
571 tag = 2
572 CALL para_env%recv(ngroups, primus_minion, tag)
573 END IF
574 END IF
575
576 ! write info on group distribution
577 IF (output_unit > 0) THEN
578 WRITE (output_unit, fmt="(T2,A,T71,I10)") "FARMING| Number of created MPI (Minion) groups:", ngroups
579 WRITE (output_unit, fmt="(T2,A)", advance="NO") "FARMING| MPI (Minion) process to group correspondence:"
580 DO i = 0, num_minions - 1
581 IF (modulo(i, 4) == 0) WRITE (output_unit, *)
582 WRITE (output_unit, fmt='(A3,I6,A3,I6,A1)', advance="NO") &
583 " (", i, " : ", group_distribution(i), ")"
584 END DO
585 WRITE (output_unit, *)
586 CALL m_flush(output_unit)
587 END IF
588
589 ! protect about too many jobs being run in single go. Not more jobs are allowed than the number in the input file
590 ! and determine the future restart point
591 IF (farming_env%cycle) THEN
592 n_jobs_to_run = farming_env%max_steps*ngroups
593 i_job_to_restart = modulo(farming_env%restart_n + n_jobs_to_run - 1, farming_env%njobs) + 1
594 ELSE
595 n_jobs_to_run = min(farming_env%njobs, farming_env%max_steps*ngroups)
596 n_jobs_to_run = min(n_jobs_to_run, farming_env%njobs - farming_env%restart_n + 1)
597 i_job_to_restart = n_jobs_to_run + farming_env%restart_n
598 END IF
599
600 ! and write the restart now, that's the point where the next job starts, even if this one is running
601 iunit = cp_print_key_unit_nr(logger, root_section, "FARMING%RESTART", &
602 extension=".restart")
603 IF (iunit > 0) THEN
604 WRITE (iunit, *) i_job_to_restart
605 END IF
606 CALL cp_print_key_finished_output(iunit, logger, root_section, "FARMING%RESTART")
607
608 ! this is the job range to be executed.
609 ijob_start = farming_env%restart_n
610 ijob_end = ijob_start + n_jobs_to_run - 1
611 IF (output_unit > 0 .AND. ijob_end - ijob_start < 0) THEN
612 WRITE (output_unit, fmt="(T2,A)") "FARMING| --- WARNING --- NO JOBS NEED EXECUTION ? "
613 WRITE (output_unit, fmt="(T2,A)") "FARMING| is the cycle keyword required ?"
614 WRITE (output_unit, fmt="(T2,A)") "FARMING| or is a stray RESTART file present ?"
615 WRITE (output_unit, fmt="(T2,A)") "FARMING| or is the group_size requested smaller than the number of CPUs?"
616 END IF
617
618 ! actual executions of the jobs in two different modes
619 IF (farming_env%captain_minion) THEN
620 IF (minion) THEN
621 ! keep on doing work until captain has decided otherwise
622 todo = do_wait
623 DO
624 IF (new_rank == 0) THEN
625 ! the head minion tells the captain he's done or ready to start
626 ! the message tells what has been done lately
627 tag = 1
628 dest = 0
629 CALL para_env%send(todo, dest, tag)
630
631 ! gets the new todo item
632 tag = 2
633 source = 0
634 CALL para_env%recv(todo, source, tag)
635
636 ! and informs his peer minions
637 CALL new_group%bcast(todo, 0)
638 ELSE
639 CALL new_group%bcast(todo, 0)
640 END IF
641
642 ! if the todo is do_nothing we are flagged to quit. Otherwise it is the job number
643 SELECT CASE (todo)
644 CASE (do_wait, do_deadlock)
645 ! go for a next round, but we first wait a bit
646 t1 = m_walltime()
647 DO
648 t2 = m_walltime()
649 IF (t2 - t1 > farming_env%wait_time) EXIT
650 END DO
651 CASE (do_nothing)
652 EXIT
653 CASE (1:)
654 CALL execute_job(todo)
655 END SELECT
656 END DO
657 ELSE ! captain
658 ALLOCATE (minion_status(0:ngroups - 1))
659 minion_status = minion_status_wait
660 ijob_current = ijob_start - 1
661
662 DO
663 IF (all(minion_status == minion_status_done)) EXIT
664
665 ! who's the next minion waiting for work
666 tag = 1
667 source = mp_any_source
668 CALL para_env%recv(todo, source, tag) ! updates source
669 IF (todo > 0) THEN
670 farming_env%Job(todo)%status = job_finished
671 IF (output_unit > 0) THEN
672 WRITE (output_unit, fmt=*) "Job finished: ", todo
673 CALL m_flush(output_unit)
674 END IF
675 END IF
676
677 ! get the next job in line, this could be do_nothing, if we're finished
678 CALL get_next_job(farming_env, ijob_start, ijob_end, ijob_current, todo)
679 dest = source
680 tag = 2
681 CALL para_env%send(todo, dest, tag)
682
683 IF (todo > 0) THEN
684 farming_env%Job(todo)%status = job_running
685 IF (output_unit > 0) THEN
686 WRITE (output_unit, fmt=*) "Job: ", todo, " Dir: ", trim(farming_env%Job(todo)%cwd), &
687 " assigned to group ", group_distribution(minion_distribution(dest))
688 CALL m_flush(output_unit)
689 END IF
690 ELSE
691 IF (todo == do_nothing) THEN
692 minion_status(group_distribution(minion_distribution(dest))) = minion_status_done
693 IF (output_unit > 0) THEN
694 WRITE (output_unit, fmt=*) "group done: ", group_distribution(minion_distribution(dest))
695 CALL m_flush(output_unit)
696 END IF
697 END IF
698 IF (todo == do_deadlock) THEN
699 IF (output_unit > 0) THEN
700 WRITE (output_unit, fmt=*) ""
701 WRITE (output_unit, fmt=*) "FARMING JOB DEADLOCKED ... CIRCULAR DEPENDENCIES"
702 WRITE (output_unit, fmt=*) ""
703 CALL m_flush(output_unit)
704 END IF
705 cpassert(todo .NE. do_deadlock)
706 END IF
707 END IF
708
709 END DO
710
711 DEALLOCATE (minion_status)
712
713 END IF
714 ELSE
715 ! this is the non-captain-minion mode way of executing the jobs
716 ! the i-th job in the input is always executed by the MODULO(i-1,ngroups)-th group
717 ! (needed for cyclic runs, we don't want two groups working on the same job)
718 IF (output_unit > 0) THEN
719 IF (ijob_end - ijob_start >= 0) THEN
720 WRITE (output_unit, fmt="(T2,A)") "FARMING| List of jobs : "
721 DO ijob = ijob_start, ijob_end
722 i = modulo(ijob - 1, farming_env%njobs) + 1
723 WRITE (output_unit, fmt=*) "Job: ", i, " Dir: ", trim(farming_env%Job(i)%cwd), " Input: ", &
724 trim(farming_env%Job(i)%input), " MPI group:", modulo(i - 1, ngroups)
725 END DO
726 END IF
727 CALL m_flush(output_unit)
728 END IF
729
730 DO ijob = ijob_start, ijob_end
731 i = modulo(ijob - 1, farming_env%njobs) + 1
732 ! this farms out the jobs
733 IF (modulo(i - 1, ngroups) == group_distribution(minion_rank)) THEN
734 IF (output_unit > 0) THEN
735 WRITE (output_unit, fmt="(T2,A,I5.5,A)", advance="NO") " Running Job ", i, &
736 " in "//trim(farming_env%Job(i)%cwd)//"."
737 CALL m_flush(output_unit)
738 END IF
739 CALL execute_job(i)
740 IF (output_unit > 0) THEN
741 WRITE (output_unit, fmt="(A)") " Done, output in "//trim(output_file)
742 CALL m_flush(output_unit)
743 END IF
744 END IF
745 END DO
746 END IF
747
748 ! keep information about how long each process has to wait
749 ! i.e. the load imbalance
750 t1 = m_walltime()
751 CALL para_env%sync()
752 t2 = m_walltime()
753 ALLOCATE (waittime(0:para_env%num_pe - 1))
754 waittime = 0.0_dp
755 waittime(para_env%mepos) = t2 - t1
756 CALL para_env%sum(waittime)
757 IF (output_unit > 0) THEN
758 WRITE (output_unit, '(T2,A)') "Process idle times [s] at the end of the run"
759 DO i = 0, para_env%num_pe - 1
760 WRITE (output_unit, fmt='(A2,I6,A3,F8.3,A1)', advance="NO") &
761 " (", i, " : ", waittime(i), ")"
762 IF (mod(i + 1, 4) == 0) WRITE (output_unit, '(A)') ""
763 END DO
764 CALL m_flush(output_unit)
765 END IF
766 DEALLOCATE (waittime)
767
768 ! give back the communicators of the split groups
769 IF (minion) CALL new_group%free()
770 CALL minion_group%free()
771
772 ! and message passing deallocate structures
773 DEALLOCATE (group_distribution)
774 DEALLOCATE (minion_distribution)
775
776 ! clean the farming env
777 CALL deallocate_farming_env(farming_env)
778
779 CALL cp_print_key_finished_output(output_unit, logger, root_section, &
780 "FARMING%PROGRAM_RUN_INFO")
781
782 CALL timestop(handle)
783
784 CONTAINS
785! **************************************************************************************************
786!> \brief ...
787!> \param i ...
788! **************************************************************************************************
789 RECURSIVE SUBROUTINE execute_job(i)
790 INTEGER :: i
791
792 ! change to the new working directory
793
794 CALL m_chdir(trim(farming_env%Job(i)%cwd), ierr)
795 IF (ierr .NE. 0) &
796 cpabort("Failed to change dir to: "//trim(farming_env%Job(i)%cwd))
797
798 ! generate a fresh call to cp2k_run
799 IF (new_rank == 0) THEN
800
801 IF (farming_env%Job(i)%output == "") THEN
802 ! generate the output file
803 WRITE (output_file, '(A12,I5.5)') "FARMING_OUT_", i
804 ALLOCATE (my_parser)
805 CALL parser_create(my_parser, file_name=trim(farming_env%Job(i)%input))
806 label = "&GLOBAL"
807 CALL parser_search_string(my_parser, label, ignore_case=.true., found=found)
808 IF (found) THEN
809 CALL create_global_section(g_section)
810 CALL section_vals_create(g_data, g_section)
811 CALL cp_unit_set_create(default_units, "OUTPUT")
812 CALL section_vals_parse(g_data, my_parser, default_units)
813 CALL cp_unit_set_release(default_units)
814 CALL section_vals_val_get(g_data, "PROJECT", &
815 c_val=str)
816 IF (str .NE. "") output_file = trim(str)//".out"
817 CALL section_vals_val_get(g_data, "OUTPUT_FILE_NAME", &
818 c_val=str)
819 IF (str .NE. "") output_file = str
820 CALL section_vals_release(g_data)
821 CALL section_release(g_section)
822 END IF
823 CALL parser_release(my_parser)
824 DEALLOCATE (my_parser)
825 ELSE
826 output_file = farming_env%Job(i)%output
827 END IF
828
829 CALL open_file(file_name=trim(output_file), &
830 file_action="WRITE", &
831 file_status="UNKNOWN", &
832 file_position="APPEND", &
833 unit_number=new_output_unit)
834 ELSE
835 ! this unit should be negative, otherwise all processors that get a default unit
836 ! start writing output (to the same file, adding to confusion).
837 ! error handling should be careful, asking for a local output unit if required
838 new_output_unit = -1
839 END IF
840
841 CALL cp2k_run(input_declaration, trim(farming_env%Job(i)%input), new_output_unit, new_group, initial_variables)
842
843 IF (new_rank == 0) CALL close_file(unit_number=new_output_unit)
844
845 ! change to the original working directory
846 CALL m_chdir(trim(farming_env%cwd), ierr)
847 cpassert(ierr == 0)
848
849 END SUBROUTINE execute_job
850 END SUBROUTINE farming_run
851
852! **************************************************************************************************
853!> \brief ...
854! **************************************************************************************************
855 SUBROUTINE write_xml_file()
856
857 INTEGER :: i, unit_number
858 TYPE(section_type), POINTER :: root_section
859
860 NULLIFY (root_section)
861 CALL create_cp2k_root_section(root_section)
862 CALL keyword_release(root_section%keywords(0)%keyword)
863 CALL open_file(unit_number=unit_number, &
864 file_name="cp2k_input.xml", &
865 file_action="WRITE", &
866 file_status="REPLACE")
867
868 WRITE (unit=unit_number, fmt="(A)") '<?xml version="1.0" encoding="utf-8"?>'
869
870 !MK CP2K input structure
871 WRITE (unit=unit_number, fmt="(A)") &
872 "<CP2K_INPUT>", &
873 " <CP2K_VERSION>"//trim(cp2k_version)//"</CP2K_VERSION>", &
874 " <CP2K_YEAR>"//trim(cp2k_year)//"</CP2K_YEAR>", &
875 " <COMPILE_DATE>"//trim(compile_date)//"</COMPILE_DATE>", &
876 " <COMPILE_REVISION>"//trim(compile_revision)//"</COMPILE_REVISION>"
877
878 CALL export_references_as_xml(unit_number)
879 CALL export_units_as_xml(unit_number)
880
881 DO i = 1, root_section%n_subsections
882 CALL write_section_xml(root_section%subsections(i)%section, 1, unit_number)
883 END DO
884
885 WRITE (unit=unit_number, fmt="(A)") "</CP2K_INPUT>"
886 CALL close_file(unit_number=unit_number)
887 CALL section_release(root_section)
888
889 END SUBROUTINE write_xml_file
890
891! **************************************************************************************************
892!> \brief runs the given input
893!> \param input_declaration ...
894!> \param input_file_path the path of the input file
895!> \param output_file_path path of the output file (to which it is appended)
896!> if it is "__STD_OUT__" the default_output_unit is used
897!> \param initial_variables key-value list of initial preprocessor variables
898!> \param mpi_comm the mpi communicator to be used for this environment
899!> it will not be freed
900!> \author fawzi
901!> \note
902!> moved here because of circular dependencies
903! **************************************************************************************************
904 SUBROUTINE run_input(input_declaration, input_file_path, output_file_path, initial_variables, mpi_comm)
905 TYPE(section_type), POINTER :: input_declaration
906 CHARACTER(len=*), INTENT(in) :: input_file_path, output_file_path
907 CHARACTER(len=default_path_length), &
908 DIMENSION(:, :), INTENT(IN) :: initial_variables
909 TYPE(mp_comm_type), INTENT(in), OPTIONAL :: mpi_comm
910
911 INTEGER :: unit_nr
912 TYPE(mp_para_env_type), POINTER :: para_env
913
914 IF (PRESENT(mpi_comm)) THEN
915 ALLOCATE (para_env)
916 para_env = mpi_comm
917 ELSE
918 para_env => f77_default_para_env
919 CALL para_env%retain()
920 END IF
921 IF (para_env%is_source()) THEN
922 IF (output_file_path == "__STD_OUT__") THEN
923 unit_nr = default_output_unit
924 ELSE
925 INQUIRE (file=output_file_path, number=unit_nr)
926 END IF
927 ELSE
928 unit_nr = -1
929 END IF
930 CALL cp2k_run(input_declaration, input_file_path, unit_nr, para_env, initial_variables)
931 CALL mp_para_env_release(para_env)
932 END SUBROUTINE run_input
933
934END 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_set_config(const enum grid_backend backend, const bool validate, const bool apply_cutoff)
Configures the grid library.
void grid_library_print_stats(const int fortran_comm, void(*print_func)(const char *, int, int), const int output_unit)
Prints statistics gathered by 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:39
character(len= *), parameter, public compile_date
Definition cp2k_info.F:57
character(len= *), parameter, public cp2k_year
Definition cp2k_info.F:44
character(len= *), parameter, public cp2k_version
Definition cp2k_info.F:43
subroutine, public run_input(input_declaration, input_file_path, output_file_path, initial_variables, mpi_comm)
runs the given input
Definition cp2k_runs.F:905
subroutine, public write_xml_file()
...
Definition cp2k_runs.F:856
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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:311
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:122
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 cp_unit_set_release(unit_set)
releases the given unit set
Definition cp_units.F:1298
subroutine, public cp_unit_set_create(unit_set, name)
initializes the given unit set
Definition cp_units.F:1227
subroutine, public export_units_as_xml(iw)
Exports all available units as XML.
Definition cp_units.F:1315
subroutine validate(matrix)
Dummy for when DBM_VALIDATE_AGAINST_DBCSR is not defined.
Definition dbm_api.F:250
subroutine, public dbm_library_print_stats(mpi_comm, output_unit)
Print DBM library statistics.
Definition dbm_api.F:1512
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, ipi_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 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 rtp_method_bse
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 do_ipi
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:53
subroutine, public m_memory(mem)
Returns the total amount of memory [bytes] in use, if known, zero otherwise.
Definition machine.F:443
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition machine.F:131
subroutine, public m_getcwd(curdir)
...
Definition machine.F:616
subroutine, public m_chdir(dir, ierror)
...
Definition machine.F:645
integer(kind=int_8), save, public m_memory_max
Definition machine.F:118
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition machine.F:148
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.
subroutine, public offload_mempool_stats_print(mpi_comm, output_unit)
Print allocation statistics.
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 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_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, 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, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_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, harris_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, eeq, rhs, do_rixs, tb_tblite)
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.
provides a uniform framework to add references to CP2K cite and output these
subroutine, public cite_reference(key)
marks a given reference as cited.
subroutine, public export_references_as_xml(unit)
Exports all references as XML.
Routines for the propagation via RT-BSE method.
Definition rt_bse.F:14
subroutine, public run_propagation_bse(qs_env, force_env)
Runs the electron-only real time BSE propagation.
Definition rt_bse.F:196
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
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:149
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