(git:b3d087c)
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 ! When adding a new iteration level PLEASE update the following list with the proper name!
30 CHARACTER(LEN=default_path_length), PARAMETER, PUBLIC, DIMENSION(19) :: each_possible_labels = [ &
31 "__ROOT__ ", &
32 "JUST_ENERGY ", &
33 "POWELL_OPT ", &
34 "QS_SCF ", &
35 "XAS_SCF ", &
36 "MD ", &
37 "PINT ", &
38 "METADYNAMICS ", &
39 "GEO_OPT ", &
40 "ROT_OPT ", &
41 "CELL_OPT ", &
42 "BAND ", &
43 "EP_LIN_SOLVER ", &
44 "SPLINE_FIND_COEFFS", &
45 "REPLICA_EVAL ", &
46 "BSSE ", &
47 "SHELL_OPT ", &
48 "TDDFT_SCF ", &
49 "NEGF_SCF "]
50
51 CHARACTER(LEN=default_path_length), PARAMETER, PUBLIC, DIMENSION(19) :: each_desc_labels = [ &
52 "Iteration level for __ROOT__ (fictitious iteration level) ", &
53 "Iteration level for an ENERGY/ENERGY_FORCE calculation. ", &
54 "Iteration level for POWELL based optimization steps. ", &
55 "Iteration level for the SCF steps. ", &
56 "Iteration level for the X-Ray Absorption Spectroscopy (XAS) SCF steps. ", &
57 "Iteration level for the MD steps. ", &
58 "Iteration level for the Path integral md steps. ", &
59 "Iteration level for the METADYNAMICS steps (number of hills added). ", &
60 "Iteration level for the Geometry optimization steps. ", &
61 "Iteration level for the Rotational optimization steps in the Dimer calculation.", &
62 "Iteration level for the Cell optimization steps. ", &
63 "Iteration level for the BAND calculation steps ", &
64 "Iteration level for the Energy Perturbation (EP) linear solver ", &
65 "Iteration level for the solution of the coefficients of the splines ", &
66 "Iteration level for the evaluation of the Replica Environment ", &
67 "Iteration level for the Basis Set Superposition Error (BSSE) calculation ", &
68 "Iteration level for the Shell-Core distances optimization steps ", &
69 "Iteration level for the Time-Dependent Density Functional Theory SCF steps. ", &
70 "Iteration level for the NEGF SCF steps. "]
71
72! **************************************************************************************************
73!> \brief contains the information about the current state of the program
74!> to be able to decide if output is necessary
75!> \author fawzi
76! **************************************************************************************************
78 INTEGER :: ref_count = -1
79 INTEGER :: print_level = -1, n_rlevel = -1
80 INTEGER, DIMENSION(:), POINTER :: iteration => null()
81 LOGICAL, DIMENSION(:), POINTER :: last_iter => null()
82 CHARACTER(len=default_string_length) :: project_name = ""
83 CHARACTER(LEN=default_string_length), &
84 DIMENSION(:), POINTER :: level_name => null()
86
87CONTAINS
88
89! **************************************************************************************************
90!> \brief creates an output info object
91!> \param iteration_info the object to create
92!> \param project_name name of the project, used to create the filenames
93!> \author fawzi
94! **************************************************************************************************
95 PURE SUBROUTINE cp_iteration_info_create(iteration_info, project_name)
96 TYPE(cp_iteration_info_type), POINTER :: iteration_info
97 CHARACTER(len=*), INTENT(in) :: project_name
98
99 ALLOCATE (iteration_info)
100
101 iteration_info%ref_count = 1
102 iteration_info%print_level = 2
103 iteration_info%n_rlevel = 1
104 iteration_info%project_name = project_name
105 ALLOCATE (iteration_info%iteration(iteration_info%n_rlevel))
106 ALLOCATE (iteration_info%level_name(iteration_info%n_rlevel))
107 ALLOCATE (iteration_info%last_iter(iteration_info%n_rlevel))
108 iteration_info%iteration(iteration_info%n_rlevel) = 1
109 iteration_info%level_name(iteration_info%n_rlevel) = "__ROOT__"
110 iteration_info%last_iter(iteration_info%n_rlevel) = .false.
111
112 END SUBROUTINE cp_iteration_info_create
113
114! **************************************************************************************************
115!> \brief retains the iteration_info (see doc/ReferenceCounting.html)
116!> \param iteration_info the iteration_info to retain
117!> \author fawzi
118! **************************************************************************************************
119 SUBROUTINE cp_iteration_info_retain(iteration_info)
120 TYPE(cp_iteration_info_type), INTENT(INOUT) :: iteration_info
121
122 CHARACTER(len=*), PARAMETER :: routinen = 'cp_iteration_info_retain', &
123 routinep = modulen//':'//routinen
124
125 IF (iteration_info%ref_count <= 0) THEN
126 cpabort(routinep//" iteration_info%ref_counf<=0")
127 END IF
128 iteration_info%ref_count = iteration_info%ref_count + 1
129 END SUBROUTINE cp_iteration_info_retain
130
131! **************************************************************************************************
132!> \brief releases the iteration_info (see doc/ReferenceCounting.html)
133!> \param iteration_info the iteration_info to release
134!> \author fawzi
135! **************************************************************************************************
136 SUBROUTINE cp_iteration_info_release(iteration_info)
137 TYPE(cp_iteration_info_type), POINTER :: iteration_info
138
139 CHARACTER(len=*), PARAMETER :: routinen = 'cp_iteration_info_release', &
140 routinep = modulen//':'//routinen
141
142 IF (ASSOCIATED(iteration_info)) THEN
143 IF (iteration_info%ref_count <= 0) THEN
144 cpabort(routinep//" iteration_info%ref_counf<=0")
145 END IF
146 iteration_info%ref_count = iteration_info%ref_count - 1
147 IF (iteration_info%ref_count == 0) THEN
148 IF (ASSOCIATED(iteration_info%iteration)) THEN
149 DEALLOCATE (iteration_info%iteration)
150 END IF
151 IF (ASSOCIATED(iteration_info%last_iter)) THEN
152 DEALLOCATE (iteration_info%last_iter)
153 END IF
154 IF (ASSOCIATED(iteration_info%level_name)) THEN
155 DEALLOCATE (iteration_info%level_name)
156 END IF
157 DEALLOCATE (iteration_info)
158 END IF
159 END IF
160 END SUBROUTINE cp_iteration_info_release
161
162! **************************************************************************************************
163!> \brief Copies iterations info of an iteration info into another iteration info
164!> \param iteration_info_in the iteration_info to be copied
165!> \param iteration_info_out the iteration_info results of the copy
166!> \author Teodoro Laino [tlaino]
167! **************************************************************************************************
168 SUBROUTINE cp_iteration_info_copy_iter(iteration_info_in, iteration_info_out)
169 TYPE(cp_iteration_info_type), INTENT(INOUT) :: iteration_info_in, iteration_info_out
170
171 CHARACTER(len=*), PARAMETER :: routinen = 'cp_iteration_info_copy_iter', &
172 routinep = modulen//':'//routinen
173
174 INTEGER :: i
175
176 IF (iteration_info_in%ref_count <= 0) THEN
177 cpabort(routinep//" iteration_info_in%ref_counf<=0")
178 END IF
179
180 iteration_info_out%n_rlevel = iteration_info_in%n_rlevel
181
182 DEALLOCATE (iteration_info_out%iteration)
183 i = SIZE(iteration_info_in%iteration)
184 ALLOCATE (iteration_info_out%iteration(i))
185 iteration_info_out%iteration = iteration_info_in%iteration
186
187 DEALLOCATE (iteration_info_out%last_iter)
188 i = SIZE(iteration_info_in%last_iter)
189 ALLOCATE (iteration_info_out%last_iter(i))
190 iteration_info_out%last_iter = iteration_info_in%last_iter
191
192 DEALLOCATE (iteration_info_out%level_name)
193 i = SIZE(iteration_info_in%level_name)
194 ALLOCATE (iteration_info_out%level_name(i))
195 iteration_info_out%level_name = iteration_info_in%level_name
196
197 END SUBROUTINE cp_iteration_info_copy_iter
198
199END MODULE cp_iter_types
200
Collection of routines to handle the iteration info.
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)
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
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...