User Tools

Site Tools


dev:printkey

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
dev:printkey [2020/08/21 10:15] – external edit 127.0.0.1dev:printkey [2026/10/14 08:45] (current) – fstein
Line 1: Line 1:
 ====== Printkeys ====== ====== Printkeys ======
  
-When writing output in cp2k, to the screen or a file, one should use a //printkey//.  +This page has been moved to [[https://manual.cp2k.org/trunk/development/print-keys.html]]
- +
-A printkey allows the user to control the output. He can e.g. turn if off, redirect it to a different file, or output after a certain number of iteration (see [[dev:iter_levels]]). +
- +
-To each printkey belongs an input-section, which is always structured in a similar way. For example, the printkey used to write trajectories is controlled by [[http://manual.cp2k.org/trunk/CP2K_INPUT/MOTION/PRINT/TRAJECTORY.html|this input-section]]. +
- +
-====== Creating a Printkey Input-section ====== +
- +
-<code Fortran> +
- USE cp_output_handling,              ONLY: cp_print_key_section_create +
- !... +
- CALL section_create(subsection,name="print",& +
-      description="Controls the printing properties during an MD run",& +
-      n_keywords=0, n_subsections=1, repeats=.TRUE., required=.FALSE.,error=error) +
- CALL cp_print_key_section_create(print_key,"TRAJECTORY",& +
-      description="Controls the output of the trajectory",& +
-      print_level=low_print_level, common_iter_levels=1,& +
-      filename="",unit_str="angstrom",error=error) +
- CALL section_add_subsection(subsection,print_key,error=error) +
- CALL section_release(print_key,error=error) +
- !... +
-</code> +
- +
-====== Using a Printkey for output ====== +
- +
-<code Fortran> +
- USE cp_output_handling,              ONLY: cp_print_key_finished_output,& +
-                                            cp_print_key_unit_nr +
- !... +
- TYPE(cp_logger_type), POINTER :: logger +
- INTEGER                       :: traj_unit +
- !... +
- logger => cp_error_get_logger(error) +
- traj_unit = cp_print_key_unit_nr(logger,root_section,"MOTION%PRINT%TRAJECTORY",error=error) +
- IF (traj_unit > 0) THEN +
-   WRITE(traj_unit, *) "here goes the output" +
- ENDIF +
- CALL cp_print_key_finished_output(traj_unit,logger,root_section,"MOTION%PRINT%TRAJECTORY",error=error) +
-</code>+
dev/printkey.txt · Last modified: by fstein