(git:27c966b)
Loading...
Searching...
No Matches
cp_iter_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Collection of routines to handle the iteration info
10! **************************************************************************************************
12 USE kinds, ONLY: default_path_length,&
14#include "../base/base_uses.f90"
15
16 IMPLICIT NONE
17 PRIVATE
18
19 ! iteration_info
20 PUBLIC :: cp_iteration_info_type, &
25
26 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_iter_types'
27 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .false.
28
29 ! Verbosity of iteration level information
30 INTEGER, PARAMETER, PUBLIC :: iter_silent = 0, &
31 iter_notice = 1, &
32 iter_stack = 2
33
34 ! When adding a new iteration level PLEASE update the following list with the proper name!
35 CHARACTER(LEN=default_path_length), PARAMETER, PUBLIC, DIMENSION(19) :: each_possible_labels = [ &
36 "__ROOT__ ", &
37 "JUST_ENERGY ", &
38 "POWELL_OPT ", &
39 "QS_SCF ", &
40 "XAS_SCF ", &
41 "MD ", &
42 "PINT ", &
43 "METADYNAMICS ", &
44 "GEO_OPT ", &
45 "ROT_OPT ", &
46 "CELL_OPT ", &
47 "BAND ", &
48 "EP_LIN_SOLVER ", &
49 "SPLINE_FIND_COEFFS", &
50 "REPLICA_EVAL ", &
51 "BSSE ", &
52 "SHELL_OPT ", &
53 "TDDFT_SCF ", &
54 "NEGF_SCF "]
55
56 CHARACTER(LEN=default_path_length), PARAMETER, PUBLIC, DIMENSION(19) :: each_desc_labels = [ &
57 "Iteration level for __ROOT__ (fictitious iteration level) ", &
58 "Iteration level for an ENERGY/ENERGY_FORCE calculation. ", &
59 "Iteration level for POWELL based optimization steps. ", &
60 "Iteration level for the SCF steps. ", &
61 "Iteration level for the X-Ray Absorption Spectroscopy (XAS) SCF steps. ", &
62 "Iteration level for the MD steps. ", &
63 "Iteration level for the Path integral md steps. ", &
64 "Iteration level for the METADYNAMICS steps (number of hills added). ", &
65 "Iteration level for the Geometry optimization steps. ", &
66 "Iteration level for the Rotational optimization steps in the Dimer calculation.", &
67 "Iteration level for the Cell optimization steps. ", &
68 "Iteration level for the BAND calculation steps ", &
69 "Iteration level for the Energy Perturbation (EP) linear solver ", &
70 "Iteration level for the solution of the coefficients of the splines ", &
71 "Iteration level for the evaluation of the Replica Environment ", &
72 "Iteration level for the Basis Set Superposition Error (BSSE) calculation ", &
73 "Iteration level for the Shell-Core distances optimization steps ", &
74 "Iteration level for the Time-Dependent Density Functional Theory SCF steps. ", &
75 "Iteration level for the NEGF SCF steps. "]
76
77! **************************************************************************************************
78!> \brief contains the information about the current state of the program
79!> to be able to decide if output is necessary
80!> \author fawzi
81! **************************************************************************************************
83 INTEGER :: ref_count = -1
84 INTEGER :: print_level = -1, n_rlevel = -1
85 INTEGER :: iter_print = iter_silent - 1
86 INTEGER, DIMENSION(:), POINTER :: iteration => null()
87 LOGICAL, DIMENSION(:), POINTER :: last_iter => null()
88 CHARACTER(len=default_string_length) :: project_name = ""
89 CHARACTER(LEN=default_string_length), &
90 DIMENSION(:), POINTER :: level_name => null()
92
93CONTAINS
94
95! **************************************************************************************************
96!> \brief creates an output info object
97!> \param iteration_info the object to create
98!> \param project_name name of the project, used to create the filenames
99!> \author fawzi
100! **************************************************************************************************
101 PURE SUBROUTINE cp_iteration_info_create(iteration_info, project_name)
102 TYPE(cp_iteration_info_type), POINTER :: iteration_info
103 CHARACTER(len=*), INTENT(in) :: project_name
104
105 ALLOCATE (iteration_info)
106
107 iteration_info%ref_count = 1
108 iteration_info%print_level = 2
109 iteration_info%n_rlevel = 1
110 iteration_info%iter_print = iter_silent - 1
111 iteration_info%project_name = project_name
112 ALLOCATE (iteration_info%iteration(iteration_info%n_rlevel))
113 ALLOCATE (iteration_info%level_name(iteration_info%n_rlevel))
114 ALLOCATE (iteration_info%last_iter(iteration_info%n_rlevel))
115 iteration_info%iteration(iteration_info%n_rlevel) = 1
116 iteration_info%level_name(iteration_info%n_rlevel) = "__ROOT__"
117 iteration_info%last_iter(iteration_info%n_rlevel) = .false.
118
119 END SUBROUTINE cp_iteration_info_create
120
121! **************************************************************************************************
122!> \brief retains the iteration_info (see doc/ReferenceCounting.html)
123!> \param iteration_info the iteration_info to retain
124!> \author fawzi
125! **************************************************************************************************
126 SUBROUTINE cp_iteration_info_retain(iteration_info)
127 TYPE(cp_iteration_info_type), INTENT(INOUT) :: iteration_info
128
129 CHARACTER(len=*), PARAMETER :: routinen = 'cp_iteration_info_retain', &
130 routinep = modulen//':'//routinen
131
132 IF (iteration_info%ref_count <= 0) THEN
133 cpabort(routinep//" iteration_info%ref_counf<=0")
134 END IF
135 iteration_info%ref_count = iteration_info%ref_count + 1
136 END SUBROUTINE cp_iteration_info_retain
137
138! **************************************************************************************************
139!> \brief releases the iteration_info (see doc/ReferenceCounting.html)
140!> \param iteration_info the iteration_info to release
141!> \author fawzi
142! **************************************************************************************************
143 SUBROUTINE cp_iteration_info_release(iteration_info)
144 TYPE(cp_iteration_info_type), POINTER :: iteration_info
145
146 CHARACTER(len=*), PARAMETER :: routinen = 'cp_iteration_info_release', &
147 routinep = modulen//':'//routinen
148
149 IF (ASSOCIATED(iteration_info)) THEN
150 IF (iteration_info%ref_count <= 0) THEN
151 cpabort(routinep//" iteration_info%ref_counf<=0")
152 END IF
153 iteration_info%ref_count = iteration_info%ref_count - 1
154 IF (iteration_info%ref_count == 0) THEN
155 IF (ASSOCIATED(iteration_info%iteration)) THEN
156 DEALLOCATE (iteration_info%iteration)
157 END IF
158 IF (ASSOCIATED(iteration_info%last_iter)) THEN
159 DEALLOCATE (iteration_info%last_iter)
160 END IF
161 IF (ASSOCIATED(iteration_info%level_name)) THEN
162 DEALLOCATE (iteration_info%level_name)
163 END IF
164 DEALLOCATE (iteration_info)
165 END IF
166 END IF
167 END SUBROUTINE cp_iteration_info_release
168
169! **************************************************************************************************
170!> \brief Copies iterations info of an iteration info into another iteration info
171!> \param iteration_info_in the iteration_info to be copied
172!> \param iteration_info_out the iteration_info results of the copy
173!> \author Teodoro Laino [tlaino]
174! **************************************************************************************************
175 SUBROUTINE cp_iteration_info_copy_iter(iteration_info_in, iteration_info_out)
176 TYPE(cp_iteration_info_type), INTENT(INOUT) :: iteration_info_in, iteration_info_out
177
178 CHARACTER(len=*), PARAMETER :: routinen = 'cp_iteration_info_copy_iter', &
179 routinep = modulen//':'//routinen
180
181 INTEGER :: i
182
183 IF (iteration_info_in%ref_count <= 0) THEN
184 cpabort(routinep//" iteration_info_in%ref_counf<=0")
185 END IF
186
187 iteration_info_out%n_rlevel = iteration_info_in%n_rlevel
188
189 DEALLOCATE (iteration_info_out%iteration)
190 i = SIZE(iteration_info_in%iteration)
191 ALLOCATE (iteration_info_out%iteration(i))
192 iteration_info_out%iteration = iteration_info_in%iteration
193
194 DEALLOCATE (iteration_info_out%last_iter)
195 i = SIZE(iteration_info_in%last_iter)
196 ALLOCATE (iteration_info_out%last_iter(i))
197 iteration_info_out%last_iter = iteration_info_in%last_iter
198
199 DEALLOCATE (iteration_info_out%level_name)
200 i = SIZE(iteration_info_in%level_name)
201 ALLOCATE (iteration_info_out%level_name(i))
202 iteration_info_out%level_name = iteration_info_in%level_name
203
204 END SUBROUTINE cp_iteration_info_copy_iter
205
206END MODULE cp_iter_types
207
Collection of routines to handle the iteration info.
integer, parameter, public iter_silent
subroutine, public cp_iteration_info_copy_iter(iteration_info_in, iteration_info_out)
Copies iterations info of an iteration info into another iteration info.
pure subroutine, public cp_iteration_info_create(iteration_info, project_name)
creates an output info object
character(len=default_path_length), dimension(19), parameter, public each_possible_labels
subroutine, public cp_iteration_info_retain(iteration_info)
retains the iteration_info (see doc/ReferenceCounting.html)
integer, parameter, public iter_stack
subroutine, public cp_iteration_info_release(iteration_info)
releases the iteration_info (see doc/ReferenceCounting.html)
character(len=default_path_length), dimension(19), parameter, public each_desc_labels
integer, parameter, public iter_notice
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
contains the information about the current state of the program to be able to decide if output is nec...