Line data Source code
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 : ! **************************************************************************************************
9 : !> \brief Sets up and terminates the global environment variables
10 : !> \par History
11 : !> - Merged with Quickstep MODULE start_program_run (17.01.2002,MK)
12 : !> - Compile information added (16.01.2002,MK)
13 : !> - Merged with MODULE cp2k_input, some rearrangements (30.10.2002,MK)
14 : !> - Update seed input (24.10.2016,MK)
15 : !> \author JGH,MK
16 : ! **************************************************************************************************
17 : MODULE environment
18 : USE bibliography, ONLY: Frigo2005,&
19 : Marek2014,&
20 : Solca2024,&
21 : cite_reference
22 : USE cp2k_info, ONLY: &
23 : compile_arch, compile_date, compile_host, compile_revision, cp2k_flags, cp2k_home, &
24 : cp2k_version, cp2k_year, get_runtime_info, r_host_name, r_pid, r_user_name
25 : USE cp_error_handling, ONLY: warning_counter
26 : USE cp_files, ONLY: close_file,&
27 : get_data_dir,&
28 : open_file
29 : USE cp_fm_diag, ONLY: FM_DIAG_TYPE_CUSOLVER,&
30 : FM_DIAG_TYPE_DLAF,&
31 : FM_DIAG_TYPE_ELPA,&
32 : FM_DIAG_TYPE_SCALAPACK,&
33 : diag_finalize,&
34 : diag_init,&
35 : eps_check_diag_default
36 : USE cp_fm_diag_utils, ONLY: cp_fm_redistribute_init
37 : USE cp_fm_struct, ONLY: cp_fm_struct_config
38 : USE cp_fm_types, ONLY: cp_fm_get_mm_type,&
39 : cp_fm_setup
40 : USE cp_log_handling, ONLY: &
41 : cp_add_default_logger, cp_get_default_logger, cp_logger_create, &
42 : cp_logger_get_default_unit_nr, cp_logger_release, cp_logger_set, cp_logger_type, &
43 : cp_rm_default_logger, cp_to_string
44 : USE cp_output_handling, ONLY: cp_mpi_io_set,&
45 : cp_print_key_finished_output,&
46 : cp_print_key_unit_nr,&
47 : debug_print_level,&
48 : high_print_level,&
49 : low_print_level,&
50 : medium_print_level,&
51 : silent_print_level
52 : USE fft_tools, ONLY: FWFFT,&
53 : fft3d,&
54 : finalize_fft,&
55 : init_fft
56 : USE force_env_types, ONLY: multiple_fe_list
57 : USE gamma, ONLY: deallocate_md_ftable
58 : USE global_types, ONLY: global_environment_type
59 : USE grid_api, ONLY: GRID_BACKEND_AUTO,&
60 : GRID_BACKEND_CPU,&
61 : GRID_BACKEND_DGEMM,&
62 : GRID_BACKEND_GPU,&
63 : GRID_BACKEND_HIP,&
64 : GRID_BACKEND_REF
65 : USE header, ONLY: cp2k_footer,&
66 : cp2k_header
67 : USE input_constants, ONLY: &
68 : callgraph_all, callgraph_none, do_cosma, do_cp2k, do_dgemm_blas, do_dgemm_spla, do_eip, &
69 : do_farming, do_fft_fftw3, do_fft_sg, do_fist, do_qs, do_scalapack, do_sirius, do_test, &
70 : energy_run, mol_dyn_run, none_run
71 : USE input_cp2k_global, ONLY: create_global_section
72 : USE input_enumeration_types, ONLY: enum_i2c,&
73 : enumeration_type
74 : USE input_keyword_types, ONLY: keyword_get,&
75 : keyword_type
76 : USE input_section_types, ONLY: &
77 : section_get_ival, section_get_keyword, section_get_lval, section_get_rval, &
78 : section_release, section_type, section_vals_get, section_vals_get_subs_vals, &
79 : section_vals_get_subs_vals3, section_vals_type, section_vals_val_get, section_vals_val_set
80 : USE kinds, ONLY: default_path_length,&
81 : default_string_length,&
82 : dp,&
83 : int_8,&
84 : print_kind_info
85 : USE local_gemm_api, ONLY: local_gemm_set_library
86 : USE machine, ONLY: &
87 : flush_should_flush, m_cpuid, m_cpuid_name, m_cpuid_static, m_cpuid_vlen, m_cpuinfo, &
88 : m_energy, m_memory_details, m_omp_get_stacksize, m_omp_trace_issues, m_procrun
89 : USE message_passing, ONLY: mp_collect_timings,&
90 : mp_para_env_type
91 : USE mp_perf_env, ONLY: add_mp_perf_env,&
92 : describe_mp_perf_env,&
93 : rm_mp_perf_env
94 : USE orbital_pointers, ONLY: deallocate_orbital_pointers,&
95 : init_orbital_pointers
96 : USE orbital_transformation_matrices, ONLY: deallocate_spherical_harmonics,&
97 : init_spherical_harmonics
98 : USE parallel_rng_types, ONLY: GAUSSIAN,&
99 : check_rng,&
100 : rng_stream_type,&
101 : write_rng_matrices
102 : USE physcon, ONLY: write_physcon
103 : USE reference_manager, ONLY: collect_citations_from_ranks,&
104 : print_cited_references
105 : USE string_utilities, ONLY: ascii_to_string,&
106 : integer_to_string,&
107 : string_to_ascii
108 : USE timings, ONLY: add_timer_env,&
109 : global_timings_level,&
110 : rm_timer_env,&
111 : root_cp2k_name,&
112 : timings_setup_tracing
113 : USE timings_report, ONLY: cost_type_energy,&
114 : cost_type_time,&
115 : timings_report_callgraph,&
116 : timings_report_print
117 : USE voronoi_interface, ONLY: finalize_libvori
118 :
119 : !$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_get_thread_num, omp_get_num_threads
120 : #include "./base/base_uses.f90"
121 :
122 : IMPLICIT NONE
123 :
124 : PRIVATE
125 :
126 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'environment'
127 :
128 : ! Public subroutines
129 :
130 : PUBLIC :: cp2k_finalize, cp2k_init, cp2k_read, cp2k_setup, cp2k_get_walltime
131 :
132 : CONTAINS
133 :
134 : ! **************************************************************************************************
135 : !> \brief Initializes a CP2K run (setting of the global environment variables)
136 : !> \param para_env ...
137 : !> \param output_unit ...
138 : !> \param globenv ...
139 : !> \param input_file_name ...
140 : !> \param wdir ...
141 : !> \par History
142 : !> JGH (28.11.2001) : default for pp_library_path
143 : !> - print keys added (17.01.2002, MK)
144 : !> - merged with cp2k_input (30.10.2002,MK)
145 : !> \author JGH,MK
146 : ! **************************************************************************************************
147 9771 : SUBROUTINE cp2k_init(para_env, output_unit, globenv, input_file_name, wdir)
148 :
149 : TYPE(mp_para_env_type), POINTER :: para_env
150 : INTEGER :: output_unit
151 : TYPE(global_environment_type), POINTER :: globenv
152 : CHARACTER(LEN=*) :: input_file_name
153 : CHARACTER(LEN=*), OPTIONAL :: wdir
154 :
155 : CHARACTER(LEN=10*default_string_length) :: cp_flags
156 : INTEGER :: i, ilen, my_output_unit
157 : TYPE(cp_logger_type), POINTER :: logger
158 :
159 : ! create a timer_env
160 :
161 9771 : CALL add_timer_env()
162 :
163 : ! Message passing performance
164 9771 : CALL add_mp_perf_env()
165 :
166 : ! Init the default logger
167 9771 : IF (para_env%is_source()) THEN
168 4989 : my_output_unit = output_unit
169 : ELSE
170 4782 : my_output_unit = -1
171 : END IF
172 9771 : NULLIFY (logger)
173 : CALL cp_logger_create(logger, para_env=para_env, &
174 : default_global_unit_nr=output_unit, &
175 9771 : close_global_unit_on_dealloc=.FALSE.)
176 9771 : CALL cp_add_default_logger(logger)
177 9771 : CALL cp_logger_release(logger)
178 :
179 : ! Initialize timing
180 9771 : CALL timeset(root_cp2k_name, globenv%handle)
181 :
182 : ! Print header
183 10291 : CALL cp2k_header(my_output_unit, wdir)
184 :
185 9771 : IF (my_output_unit > 0) THEN
186 : WRITE (UNIT=my_output_unit, FMT="(/,T2,A,T31,A50)") &
187 4989 : "CP2K| version string: ", ADJUSTR(TRIM(cp2k_version))
188 : WRITE (UNIT=my_output_unit, FMT="(T2,A,T41,A40)") &
189 4989 : "CP2K| source code revision number:", &
190 9978 : ADJUSTR(compile_revision)
191 4989 : cp_flags = cp2k_flags()
192 4989 : ilen = LEN_TRIM(cp_flags)
193 : WRITE (UNIT=my_output_unit, FMT="(T2,A)") &
194 4989 : "CP2K| "//cp_flags(1:73)
195 4989 : IF (ilen > 73) THEN
196 14967 : DO i = 0, (ilen - 75)/61
197 : WRITE (UNIT=my_output_unit, FMT="(T2,A)") &
198 14967 : "CP2K| "//TRIM(cp_flags(74 + i*61:MIN(74 + (i + 1)*61, ilen)))
199 : END DO
200 : END IF
201 : WRITE (UNIT=my_output_unit, FMT="(T2,A,T41,A40)") &
202 4989 : "CP2K| is freely available from ", &
203 9978 : ADJUSTR(TRIM(cp2k_home))
204 : WRITE (UNIT=my_output_unit, FMT="(T2,A,T31,A50)") &
205 4989 : "CP2K| Program compiled at", &
206 9978 : ADJUSTR(compile_date(1:MIN(50, LEN(compile_date))))
207 : WRITE (UNIT=my_output_unit, FMT="(T2,A,T31,A50)") &
208 4989 : "CP2K| Program compiled on", &
209 9978 : ADJUSTR(compile_host(1:MIN(50, LEN(compile_host))))
210 : WRITE (UNIT=my_output_unit, FMT="(T2,A,T31,A50)") &
211 4989 : "CP2K| Program compiled for", &
212 9978 : ADJUSTR(compile_arch(1:MIN(50, LEN(compile_arch))))
213 : WRITE (UNIT=my_output_unit, FMT="(T2,A,T31,A50)") &
214 4989 : "CP2K| Data directory path", &
215 9978 : ADJUSTR(TRIM(get_data_dir()))
216 : WRITE (UNIT=my_output_unit, FMT="(T2,A,T31,A50)") &
217 4989 : "CP2K| Input file name", &
218 9978 : ADJUSTR(TRIM(input_file_name))
219 4989 : FLUSH (my_output_unit) ! ignore &GLOBAL / FLUSH_SHOULD_FLUSH
220 : END IF
221 :
222 : #if defined(__FAST_MATH__)
223 : CALL cp_warn(__LOCATION__, &
224 : "During compilation one of the following flags was active:"// &
225 : " `-ffast-math` (GCC)"// &
226 : " `-hfpN` (Cray, N > 0, default N=2)"// &
227 : " This can lead to wrong results and numerical instabilities"// &
228 : " and is therefore no longer supported.")
229 :
230 : #if !defined(__FORCE_USE_FAST_MATH)
231 : #error "-ffast-math (GCC) or -hfpN (N>0, Cray) can lead to wrong results and numerical instabilities and are therefore no longer supported"
232 : #endif
233 : #endif
234 :
235 : #if defined(NDEBUG)
236 : #error "Please do not build CP2K with NDEBUG. There is no performance advantage and asserts will save your neck."
237 : #endif
238 :
239 9771 : END SUBROUTINE cp2k_init
240 :
241 : ! **************************************************************************************************
242 : !> \brief echoes the list of host names and pids
243 : !> \param para_env ...
244 : !> \param output_unit ...
245 : ! **************************************************************************************************
246 2 : SUBROUTINE echo_all_hosts(para_env, output_unit)
247 : TYPE(mp_para_env_type), POINTER :: para_env
248 : INTEGER :: output_unit
249 :
250 : CHARACTER(LEN=default_string_length) :: string
251 : INTEGER :: ipe
252 2 : INTEGER, ALLOCATABLE, DIMENSION(:) :: all_pid
253 : INTEGER, ALLOCATABLE, DIMENSION(:, :) :: all_host
254 :
255 : ! Print a list of all started processes
256 :
257 6 : ALLOCATE (all_pid(para_env%num_pe))
258 6 : all_pid(:) = 0
259 2 : all_pid(para_env%mepos + 1) = r_pid
260 :
261 2 : CALL para_env%sum(all_pid)
262 6 : ALLOCATE (all_host(30, para_env%num_pe))
263 126 : all_host(:, :) = 0
264 2 : CALL string_to_ascii(r_host_name, all_host(:, para_env%mepos + 1))
265 2 : CALL para_env%sum(all_host)
266 2 : IF (output_unit > 0) THEN
267 :
268 1 : WRITE (UNIT=output_unit, FMT="(T2,A)") ""
269 3 : DO ipe = 1, para_env%num_pe
270 2 : CALL ascii_to_string(all_host(:, ipe), string)
271 : WRITE (UNIT=output_unit, FMT="(T2,A,T63,I8,T71,I10)") &
272 : TRIM(r_user_name)//"@"//TRIM(string)// &
273 3 : " has created rank and process ", ipe - 1, all_pid(ipe)
274 : END DO
275 1 : WRITE (UNIT=output_unit, FMT="(T2,A)") ""
276 : END IF
277 2 : DEALLOCATE (all_pid)
278 2 : DEALLOCATE (all_host)
279 :
280 2 : END SUBROUTINE echo_all_hosts
281 :
282 : ! **************************************************************************************************
283 : !> \brief echoes the list the number of process per host
284 : !> \param para_env ...
285 : !> \param output_unit ...
286 : ! **************************************************************************************************
287 2 : SUBROUTINE echo_all_process_host(para_env, output_unit)
288 : TYPE(mp_para_env_type), POINTER :: para_env
289 : INTEGER :: output_unit
290 :
291 : CHARACTER(LEN=default_string_length) :: string, string_sec
292 : INTEGER :: ipe, jpe, nr_occu
293 2 : INTEGER, ALLOCATABLE, DIMENSION(:) :: all_pid
294 : INTEGER, ALLOCATABLE, DIMENSION(:, :) :: all_host
295 :
296 6 : ALLOCATE (all_host(30, para_env%num_pe))
297 126 : all_host(:, :) = 0
298 :
299 2 : IF (m_procrun(r_pid) .EQ. 1) THEN
300 2 : CALL string_to_ascii(r_host_name, all_host(:, para_env%mepos + 1))
301 2 : CALL para_env%sum(all_host)
302 : END IF
303 :
304 2 : IF (output_unit > 0) THEN
305 3 : ALLOCATE (all_pid(para_env%num_pe))
306 3 : all_pid(:) = 0
307 :
308 1 : WRITE (UNIT=output_unit, FMT="(T2,A)") ""
309 3 : DO ipe = 1, para_env%num_pe
310 2 : nr_occu = 0
311 3 : IF (all_pid(ipe) .NE. -1) THEN
312 1 : CALL ascii_to_string(all_host(:, ipe), string)
313 3 : DO jpe = 1, para_env%num_pe
314 2 : CALL ascii_to_string(all_host(:, jpe), string_sec)
315 3 : IF (string .EQ. string_sec) THEN
316 2 : nr_occu = nr_occu + 1
317 2 : all_pid(jpe) = -1
318 : END IF
319 : END DO
320 : WRITE (UNIT=output_unit, FMT="(T2,A,T63,I8,A)") &
321 : TRIM(r_user_name)//"@"//TRIM(string)// &
322 1 : " is running ", nr_occu, " processes"
323 1 : WRITE (UNIT=output_unit, FMT="(T2,A)") ""
324 : END IF
325 : END DO
326 1 : DEALLOCATE (all_pid)
327 :
328 : END IF
329 :
330 2 : DEALLOCATE (all_host)
331 :
332 2 : END SUBROUTINE echo_all_process_host
333 :
334 : ! **************************************************************************************************
335 : !> \brief read part of cp2k_init
336 : !> \param root_section ...
337 : !> \param para_env ...
338 : !> \param globenv the globenv
339 : !> \author fawzi
340 : !> \note
341 : !> The following routines need to be synchronized wrt. adding/removing
342 : !> of the default environments (logging, performance,error):
343 : !> environment:cp2k_init, environment:cp2k_finalize,
344 : !> f77_interface:f_env_add_defaults, f77_interface:f_env_rm_defaults,
345 : !> f77_interface:create_force_env, f77_interface:destroy_force_env
346 : ! **************************************************************************************************
347 9771 : SUBROUTINE cp2k_read(root_section, para_env, globenv)
348 :
349 : TYPE(section_vals_type), POINTER :: root_section
350 : TYPE(mp_para_env_type), POINTER :: para_env
351 : TYPE(global_environment_type), POINTER :: globenv
352 :
353 : CHARACTER(LEN=3*default_string_length) :: message
354 : CHARACTER(len=default_string_length) :: c_val
355 : INTEGER :: i, iw
356 : TYPE(cp_logger_type), POINTER :: logger
357 :
358 : ! Read the input/output section
359 :
360 9771 : logger => cp_get_default_logger()
361 :
362 : ! try to use better names for the local log if it is not too late
363 : CALL section_vals_val_get(root_section, "GLOBAL%OUTPUT_FILE_NAME", &
364 9771 : c_val=c_val)
365 9771 : IF (c_val /= "") THEN
366 : CALL cp_logger_set(logger, &
367 144 : local_filename=TRIM(c_val)//"_localLog")
368 : END IF
369 :
370 : ! Process project name
371 9771 : CALL section_vals_val_get(root_section, "GLOBAL%PROJECT", c_val=c_val)
372 9771 : IF (INDEX(c_val(:LEN_TRIM(c_val)), " ") > 0) THEN
373 : message = "Project name <"//TRIM(c_val)// &
374 2 : "> contains spaces which will be replaced with underscores"
375 2 : CPWARN(TRIM(message))
376 24 : DO i = 1, LEN_TRIM(c_val)
377 : ! Replace space with underscore
378 24 : IF (c_val(i:i) == " ") c_val(i:i) = "_"
379 : END DO
380 2 : CALL section_vals_val_set(root_section, "GLOBAL%PROJECT", c_val=TRIM(c_val))
381 : END IF
382 9771 : IF (c_val /= "") THEN
383 9771 : CALL cp_logger_set(logger, local_filename=TRIM(c_val)//"_localLog")
384 : END IF
385 9771 : logger%iter_info%project_name = c_val
386 :
387 9771 : CALL section_vals_val_get(root_section, "GLOBAL%PRINT_LEVEL", i_val=logger%iter_info%print_level)
388 :
389 : ! Read the CP2K section
390 9771 : CALL read_cp2k_section(root_section, para_env, globenv)
391 :
392 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PRINT/BASIC_DATA_TYPES", &
393 9771 : extension=".Log")
394 9771 : IF (iw > 0) CALL print_kind_info(iw)
395 : CALL cp_print_key_finished_output(iw, logger, root_section, &
396 9771 : "GLOBAL%PRINT/BASIC_DATA_TYPES")
397 :
398 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PRINT/PHYSCON", &
399 9771 : extension=".Log")
400 9771 : IF (iw > 0) CALL write_physcon(iw)
401 : CALL cp_print_key_finished_output(iw, logger, root_section, &
402 9771 : "GLOBAL%PRINT/PHYSCON")
403 :
404 9771 : END SUBROUTINE cp2k_read
405 :
406 : ! **************************************************************************************************
407 : !> \brief globenv initializations that need the input and error
408 : !> \param root_section ...
409 : !> \param para_env ...
410 : !> \param globenv the global environment to initialize
411 : !> \author fawzi
412 : !> \note
413 : !> if possible do the initializations here as the environment
414 : !> (error,...) is setup, instead of cp2k_init
415 : ! **************************************************************************************************
416 19542 : SUBROUTINE cp2k_setup(root_section, para_env, globenv)
417 :
418 : TYPE(section_vals_type), POINTER :: root_section
419 : TYPE(mp_para_env_type), POINTER :: para_env
420 : TYPE(global_environment_type), POINTER :: globenv
421 :
422 : INTEGER :: iw, maxl
423 9771 : INTEGER, DIMENSION(:), POINTER :: seed_vals
424 : REAL(KIND=dp), DIMENSION(3, 2) :: initial_seed
425 : TYPE(cp_logger_type), POINTER :: logger
426 :
427 9771 : NULLIFY (logger)
428 19542 : logger => cp_get_default_logger()
429 :
430 : ! Initialize the parallel random number generator
431 :
432 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PRINT/RNG_MATRICES", &
433 9771 : extension=".Log")
434 9771 : IF (iw > 0) THEN
435 1 : CALL write_rng_matrices(iw)
436 : END IF
437 :
438 : CALL cp_print_key_finished_output(iw, logger, root_section, &
439 9771 : "GLOBAL%PRINT/RNG_MATRICES")
440 :
441 : ! Initialize a global normally Gaussian distributed (pseudo)random number stream
442 :
443 9771 : CALL section_vals_val_get(root_section, "GLOBAL%SEED", i_vals=seed_vals)
444 9771 : IF (SIZE(seed_vals) == 1) THEN
445 87939 : initial_seed(:, :) = REAL(seed_vals(1), KIND=dp)
446 0 : ELSE IF (SIZE(seed_vals) == 6) THEN
447 0 : initial_seed(1:3, 1:2) = RESHAPE(REAL(seed_vals(:), KIND=dp), (/3, 2/))
448 : ELSE
449 0 : CPABORT("Supply exactly 1 or 6 arguments for SEED in &GLOBAL only!")
450 : END IF
451 :
452 : globenv%gaussian_rng_stream = rng_stream_type( &
453 : name="Global Gaussian random numbers", &
454 : distribution_type=GAUSSIAN, &
455 : seed=initial_seed, &
456 9771 : extended_precision=.TRUE.)
457 :
458 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PRINT/RNG_CHECK", &
459 9771 : extension=".Log")
460 9771 : IF (iw > 0) THEN
461 1 : CALL check_rng(iw, para_env%is_source())
462 : END IF
463 :
464 : CALL cp_print_key_finished_output(iw, logger, root_section, &
465 9771 : "GLOBAL%PRINT/RNG_CHECK")
466 :
467 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PRINT/GLOBAL_GAUSSIAN_RNG", &
468 9771 : extension=".Log")
469 9771 : IF (iw > 0) &
470 1 : CALL globenv%gaussian_rng_stream%write(iw, write_all=.TRUE.)
471 :
472 : CALL cp_print_key_finished_output(iw, logger, root_section, &
473 9771 : "GLOBAL%PRINT/GLOBAL_GAUSSIAN_RNG")
474 :
475 9771 : CALL section_vals_val_get(root_section, "GLOBAL%PRINT%SPHERICAL_HARMONICS", i_val=maxl)
476 9771 : IF (maxl >= 0) THEN
477 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PRINT", &
478 2 : extension=".Log")
479 2 : CALL init_orbital_pointers(maxl)
480 2 : CALL init_spherical_harmonics(maxl, iw)
481 2 : CALL deallocate_spherical_harmonics()
482 2 : CALL deallocate_orbital_pointers()
483 : CALL cp_print_key_finished_output(iw, logger, root_section, &
484 2 : "GLOBAL%PRINT")
485 : END IF
486 :
487 9771 : END SUBROUTINE cp2k_setup
488 :
489 : ! **************************************************************************************************
490 : !> \brief read the global section of new input
491 : !> \param root_section ...
492 : !> \param para_env ...
493 : !> \param globenv ...
494 : !> \par History
495 : !> 06-2005 [created]
496 : !> \author MI
497 : !> \note
498 : !> Should not be required anymore once everything is converted
499 : !> to get information directly from the input structure
500 : ! **************************************************************************************************
501 136794 : SUBROUTINE read_global_section(root_section, para_env, globenv)
502 :
503 : TYPE(section_vals_type), POINTER :: root_section
504 : TYPE(mp_para_env_type), POINTER :: para_env
505 : TYPE(global_environment_type), POINTER :: globenv
506 :
507 : CHARACTER(LEN=6), PARAMETER :: start_section_label = "GLOBAL"
508 :
509 : CHARACTER(len=13) :: omp_stacksize, tracing_string
510 : CHARACTER(len=6) :: print_level_string
511 : CHARACTER(len=default_path_length) :: basis_set_file_name, coord_file_name, &
512 : mm_potential_file_name, &
513 : potential_file_name
514 : CHARACTER(LEN=default_string_length) :: env_num, model_name, project_name
515 : CHARACTER(LEN=default_string_length), &
516 9771 : DIMENSION(:), POINTER :: trace_routines
517 : INTEGER :: cpuid, cpuid_static, i_dgemm, i_diag, i_fft, i_grid_backend, iforce_eval, &
518 : method_name_id, n_rep_val, nforce_eval, num_threads, output_unit, print_level, trace_max, &
519 : unit_nr
520 : INTEGER(kind=int_8) :: Buffers, Buffers_avr, Buffers_max, Buffers_min, Cached, Cached_avr, &
521 : Cached_max, Cached_min, MemFree, MemFree_avr, MemFree_max, MemFree_min, MemLikelyFree, &
522 : MemLikelyFree_avr, MemLikelyFree_max, MemLikelyFree_min, MemTotal, MemTotal_avr, &
523 : MemTotal_max, MemTotal_min, Slab, Slab_avr, Slab_max, Slab_min, SReclaimable, &
524 : SReclaimable_avr, SReclaimable_max, SReclaimable_min
525 9771 : INTEGER, DIMENSION(:), POINTER :: i_force_eval
526 : LOGICAL :: ata, do_echo_all_hosts, efl, explicit, &
527 : flag, report_maxloc, trace, &
528 : trace_master
529 : TYPE(cp_logger_type), POINTER :: logger
530 : TYPE(enumeration_type), POINTER :: enum1, enum2
531 : TYPE(keyword_type), POINTER :: keyword
532 : TYPE(section_type), POINTER :: section
533 : TYPE(section_vals_type), POINTER :: dft_section, force_env_sections, &
534 : global_section, qmmm_section, &
535 : subsys_section
536 :
537 9771 : NULLIFY (dft_section, global_section, i_force_eval)
538 :
539 19542 : logger => cp_get_default_logger()
540 9771 : global_section => section_vals_get_subs_vals(root_section, "GLOBAL")
541 9771 : CALL section_vals_val_get(global_section, "BLACS_GRID", i_val=globenv%blacs_grid_layout)
542 9771 : CALL section_vals_val_get(global_section, "BLACS_REPEATABLE", l_val=globenv%blacs_repeatable)
543 9771 : CALL section_vals_val_get(global_section, "PREFERRED_DIAG_LIBRARY", i_val=i_diag)
544 9771 : CALL section_vals_val_get(global_section, "PREFERRED_DGEMM_LIBRARY", i_val=i_dgemm)
545 9771 : CALL section_vals_val_get(global_section, "EPS_CHECK_DIAG", r_val=globenv%eps_check_diag)
546 9771 : CALL section_vals_val_get(global_section, "ENABLE_MPI_IO", l_val=flag)
547 9771 : CALL cp_mpi_io_set(flag)
548 9771 : CALL section_vals_val_get(global_section, "ELPA_KERNEL", i_val=globenv%k_elpa)
549 9771 : CALL section_vals_val_get(global_section, "ELPA_NEIGVEC_MIN", i_val=globenv%elpa_neigvec_min)
550 9771 : CALL section_vals_val_get(global_section, "ELPA_QR", l_val=globenv%elpa_qr)
551 9771 : CALL section_vals_val_get(global_section, "ELPA_QR_UNSAFE", l_val=globenv%elpa_qr_unsafe)
552 9771 : unit_nr = cp_print_key_unit_nr(logger, global_section, "PRINT_ELPA", extension=".Log")
553 9771 : IF (unit_nr > 0) globenv%elpa_print = .TRUE.
554 9771 : CALL cp_print_key_finished_output(unit_nr, logger, global_section, "PRINT_ELPA")
555 9771 : CALL section_vals_val_get(global_section, "DLAF_NEIGVEC_MIN", i_val=globenv%dlaf_neigvec_min)
556 9771 : CALL section_vals_val_get(global_section, "PREFERRED_FFT_LIBRARY", i_val=i_fft)
557 9771 : CALL section_vals_val_get(global_section, "PRINT_LEVEL", i_val=print_level)
558 9771 : CALL section_vals_val_get(global_section, "PROGRAM_NAME", i_val=globenv%prog_name_id)
559 9771 : CALL section_vals_val_get(global_section, "FFT_POOL_SCRATCH_LIMIT", i_val=globenv%fft_pool_scratch_limit)
560 9771 : CALL section_vals_val_get(global_section, "FFTW_PLAN_TYPE", i_val=globenv%fftw_plan_type)
561 9771 : CALL section_vals_val_get(global_section, "PROJECT_NAME", c_val=project_name)
562 9771 : CALL section_vals_val_get(global_section, "FFTW_WISDOM_FILE_NAME", c_val=globenv%fftw_wisdom_file_name)
563 9771 : CALL section_vals_val_get(global_section, "RUN_TYPE", i_val=globenv%run_type_id)
564 : CALL cp2k_get_walltime(section=global_section, keyword_name="WALLTIME", &
565 9771 : walltime=globenv%cp2k_target_time)
566 9771 : CALL section_vals_val_get(global_section, "TRACE", l_val=trace)
567 9771 : CALL section_vals_val_get(global_section, "TRACE_MASTER", l_val=trace_MASTER)
568 9771 : CALL section_vals_val_get(global_section, "TRACE_MAX", i_val=trace_max)
569 9771 : CALL section_vals_val_get(global_section, "TRACE_ROUTINES", explicit=explicit)
570 9771 : IF (explicit) THEN
571 0 : CALL section_vals_val_get(global_section, "TRACE_ROUTINES", c_vals=trace_routines)
572 : ELSE
573 9771 : NULLIFY (trace_routines)
574 : END IF
575 9771 : CALL section_vals_val_get(global_section, "FLUSH_SHOULD_FLUSH", l_val=flush_should_flush)
576 9771 : CALL section_vals_val_get(global_section, "ECHO_ALL_HOSTS", l_val=do_echo_all_hosts)
577 9771 : report_maxloc = section_get_lval(global_section, "TIMINGS%REPORT_MAXLOC")
578 9771 : global_timings_level = section_get_ival(global_section, "TIMINGS%TIMINGS_LEVEL")
579 9771 : do_echo_all_hosts = do_echo_all_hosts .OR. report_maxloc
580 9771 : force_env_sections => section_vals_get_subs_vals(root_section, "FORCE_EVAL")
581 9771 : CALL section_vals_get(force_env_sections, n_repetition=nforce_eval)
582 : output_unit = cp_print_key_unit_nr(logger, global_section, "PROGRAM_RUN_INFO", &
583 9771 : extension=".log")
584 :
585 9771 : CALL fm_setup(global_section)
586 9771 : CALL fm_diag_rules_setup(global_section)
587 9771 : CALL dgemm_setup(global_section)
588 :
589 9771 : IF (trace .AND. (.NOT. trace_master .OR. para_env%mepos == 0)) THEN
590 0 : unit_nr = -1
591 0 : IF (logger%para_env%is_source() .OR. .NOT. trace_master) &
592 0 : unit_nr = cp_logger_get_default_unit_nr(logger, local=.TRUE.)
593 0 : WRITE (tracing_string, "(I6.6,A1,I6.6)") para_env%mepos, ":", para_env%num_pe
594 0 : IF (ASSOCIATED(trace_routines)) THEN
595 0 : CALL timings_setup_tracing(trace_max, unit_nr, tracing_string, trace_routines)
596 : ELSE
597 0 : CALL timings_setup_tracing(trace_max, unit_nr, tracing_string)
598 : END IF
599 : END IF
600 :
601 9771 : CALL section_vals_val_get(global_section, "TIMINGS%TIME_MPI", l_val=mp_collect_timings)
602 :
603 188 : SELECT CASE (i_diag)
604 : CASE (FM_DIAG_TYPE_SCALAPACK)
605 188 : globenv%diag_library = "ScaLAPACK"
606 : CASE (FM_DIAG_TYPE_ELPA)
607 9583 : globenv%diag_library = "ELPA"
608 9583 : CALL cite_reference(Marek2014)
609 : CASE (FM_DIAG_TYPE_CUSOLVER)
610 0 : globenv%diag_library = "cuSOLVER"
611 : CASE (FM_DIAG_TYPE_DLAF)
612 0 : globenv%diag_library = "DLAF"
613 0 : CALL cite_reference(Solca2024)
614 : CASE DEFAULT
615 9771 : CPABORT("Unknown diagonalization library specified")
616 : END SELECT
617 :
618 10 : SELECT CASE (i_fft)
619 : CASE (do_fft_sg)
620 10 : globenv%default_fft_library = "FFTSG"
621 : CASE (do_fft_fftw3)
622 9761 : globenv%default_fft_library = "FFTW3"
623 9761 : CALL cite_reference(Frigo2005)
624 : CASE DEFAULT
625 9771 : CPABORT("Unknown FFT library specified")
626 : END SELECT
627 :
628 0 : SELECT CASE (i_dgemm)
629 : CASE (do_dgemm_spla)
630 0 : globenv%default_dgemm_library = "SPLA"
631 : CASE (do_dgemm_blas)
632 9771 : globenv%default_dgemm_library = "BLAS"
633 : CASE DEFAULT
634 9771 : CPABORT("Unknown DGEMM library specified")
635 : END SELECT
636 :
637 9771 : IF (globenv%run_type_id == 0) THEN
638 0 : SELECT CASE (globenv%prog_name_id)
639 : CASE (do_farming, do_test)
640 0 : globenv%run_type_id = none_run
641 : CASE (do_cp2k)
642 0 : IF (nforce_eval /= 1) THEN
643 : ! multiple force_eval corresponds at the moment to RESPA calculations only
644 : ! default MD
645 0 : globenv%run_type_id = mol_dyn_run
646 : ELSE
647 0 : CALL section_vals_val_get(force_env_sections, "METHOD", i_val=method_name_id)
648 0 : SELECT CASE (method_name_id)
649 : CASE (do_fist)
650 0 : globenv%run_type_id = mol_dyn_run
651 : CASE (do_eip)
652 0 : globenv%run_type_id = mol_dyn_run
653 : CASE (do_qs)
654 0 : globenv%run_type_id = energy_run
655 : CASE (do_sirius)
656 0 : globenv%run_type_id = energy_run
657 : END SELECT
658 : END IF
659 : END SELECT
660 : END IF
661 :
662 9771 : IF (globenv%prog_name_id == do_farming .AND. globenv%run_type_id /= none_run) THEN
663 0 : CPABORT("FARMING program supports only NONE as run type")
664 : END IF
665 :
666 9771 : IF (globenv%prog_name_id == do_test .AND. globenv%run_type_id /= none_run) &
667 0 : CPABORT("TEST program supports only NONE as run type")
668 :
669 9771 : CALL m_memory_details(MemTotal, MemFree, Buffers, Cached, Slab, SReclaimable, MemLikelyFree)
670 9771 : MemTotal_avr = MemTotal
671 9771 : MemFree_avr = MemFree
672 9771 : Buffers_avr = Buffers
673 9771 : Cached_avr = Cached
674 9771 : Slab_avr = Slab
675 9771 : SReclaimable_avr = SReclaimable
676 9771 : MemLikelyFree_avr = MemLikelyFree
677 9771 : CALL para_env%sum(MemTotal_avr); MemTotal_avr = MemTotal_avr/para_env%num_pe/1024
678 9771 : CALL para_env%sum(MemFree_avr); MemFree_avr = MemFree_avr/para_env%num_pe/1024
679 9771 : CALL para_env%sum(Buffers_avr); Buffers_avr = Buffers_avr/para_env%num_pe/1024
680 9771 : CALL para_env%sum(Cached_avr); Cached_avr = Cached_avr/para_env%num_pe/1024
681 9771 : CALL para_env%sum(Slab_avr); Slab_avr = Slab_avr/para_env%num_pe/1024
682 9771 : CALL para_env%sum(SReclaimable_avr); SReclaimable_avr = SReclaimable_avr/para_env%num_pe/1024
683 9771 : CALL para_env%sum(MemLikelyFree_avr); MemLikelyFree_avr = MemLikelyFree_avr/para_env%num_pe/1024
684 :
685 9771 : MemTotal_min = -MemTotal
686 9771 : MemFree_min = -MemFree
687 9771 : Buffers_min = -Buffers
688 9771 : Cached_min = -Cached
689 9771 : Slab_min = -Slab
690 9771 : SReclaimable_min = -SReclaimable
691 9771 : MemLikelyFree_min = -MemLikelyFree
692 9771 : CALL para_env%max(MemTotal_min); MemTotal_min = -MemTotal_min/1024
693 9771 : CALL para_env%max(MemFree_min); MemFree_min = -MemFree_min/1024
694 9771 : CALL para_env%max(Buffers_min); Buffers_min = -Buffers_min/1024
695 9771 : CALL para_env%max(Cached_min); Cached_min = -Cached_min/1024
696 9771 : CALL para_env%max(Slab_min); Slab_min = -Slab_min/1024
697 9771 : CALL para_env%max(SReclaimable_min); SReclaimable_min = -SReclaimable_min/1024
698 9771 : CALL para_env%max(MemLikelyFree_min); MemLikelyFree_min = -MemLikelyFree_min/1024
699 :
700 9771 : MemTotal_max = MemTotal
701 9771 : MemFree_max = MemFree
702 9771 : Buffers_max = Buffers
703 9771 : Cached_max = Cached
704 9771 : Slab_max = Slab
705 9771 : SReclaimable_max = SReclaimable
706 9771 : MemLikelyFree_max = MemLikelyFree
707 9771 : CALL para_env%max(MemTotal_max); MemTotal_max = MemTotal_max/1024
708 9771 : CALL para_env%max(MemFree_max); MemFree_max = MemFree_max/1024
709 9771 : CALL para_env%max(Buffers_max); Buffers_max = Buffers_max/1024
710 9771 : CALL para_env%max(Cached_max); Cached_max = Cached_max/1024
711 9771 : CALL para_env%max(Slab_max); Slab_max = Slab_max/1024
712 9771 : CALL para_env%max(SReclaimable_max); SReclaimable_max = SReclaimable_max/1024
713 9771 : CALL para_env%max(MemLikelyFree_max); MemLikelyFree_max = MemLikelyFree_max/1024
714 :
715 9771 : MemTotal = MemTotal/1024
716 9771 : MemFree = MemFree/1024
717 9771 : Buffers = Buffers/1024
718 9771 : Cached = Cached/1024
719 9771 : Slab = Slab/1024
720 9771 : SReclaimable = SReclaimable/1024
721 9771 : MemLikelyFree = MemLikelyFree/1024
722 :
723 : ! Print a list of all started processes
724 9771 : IF (do_echo_all_hosts) THEN
725 2 : CALL echo_all_hosts(para_env, output_unit)
726 :
727 : ! Print the number of processes per host
728 2 : CALL echo_all_process_host(para_env, output_unit)
729 : END IF
730 :
731 9771 : num_threads = 1
732 9771 : !$ num_threads = omp_get_max_threads()
733 9771 : IF (output_unit > 0) THEN
734 4989 : WRITE (UNIT=output_unit, FMT=*)
735 4989 : CALL multiple_fe_list(force_env_sections, root_section, i_force_eval, nforce_eval)
736 9920 : DO iforce_eval = 1, nforce_eval
737 : dft_section => section_vals_get_subs_vals3(force_env_sections, "DFT", &
738 4931 : i_rep_section=i_force_eval(iforce_eval))
739 : qmmm_section => section_vals_get_subs_vals3(force_env_sections, "QMMM", &
740 4931 : i_rep_section=i_force_eval(iforce_eval))
741 : CALL section_vals_val_get(dft_section, "BASIS_SET_FILE_NAME", &
742 4931 : c_val=basis_set_file_name)
743 : CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", &
744 4931 : c_val=potential_file_name)
745 :
746 : CALL section_vals_val_get(qmmm_section, "MM_POTENTIAL_FILE_NAME", &
747 4931 : c_val=mm_potential_file_name)
748 : ! SUBSYS - If any
749 : subsys_section => section_vals_get_subs_vals3(force_env_sections, "SUBSYS", &
750 4931 : i_rep_section=i_force_eval(iforce_eval))
751 4931 : CALL section_vals_get(subsys_section, explicit=explicit)
752 4931 : coord_file_name = "__STD_INPUT__"
753 4931 : IF (explicit) THEN
754 : CALL section_vals_val_get(subsys_section, "TOPOLOGY%COORD_FILE_NAME", &
755 4824 : n_rep_val=n_rep_val)
756 4824 : IF (n_rep_val == 1) THEN
757 : CALL section_vals_val_get(subsys_section, "TOPOLOGY%COORD_FILE_NAME", &
758 918 : c_val=coord_file_name)
759 : END IF
760 : END IF
761 4931 : CALL integer_to_string(i_force_eval(iforce_eval), env_num)
762 :
763 : WRITE (UNIT=output_unit, FMT="(T2,A,T41,A)") &
764 4931 : start_section_label//"| Force Environment number", &
765 4931 : ADJUSTR(env_num(:40)), &
766 4931 : start_section_label//"| Basis set file name", &
767 4931 : ADJUSTR(basis_set_file_name(:40)), &
768 4931 : start_section_label//"| Potential file name", &
769 4931 : ADJUSTR(potential_file_name(:40)), &
770 4931 : start_section_label//"| MM Potential file name", &
771 4931 : ADJUSTR(mm_potential_file_name(:40)), &
772 4931 : start_section_label//"| Coordinate file name", &
773 19782 : ADJUSTR(coord_file_name(:40))
774 : END DO
775 4989 : DEALLOCATE (i_force_eval)
776 :
777 4989 : NULLIFY (enum1, enum2, keyword, section)
778 4989 : CALL create_global_section(section)
779 4989 : keyword => section_get_keyword(section, "PROGRAM_NAME")
780 4989 : CALL keyword_get(keyword, enum=enum1)
781 4989 : keyword => section_get_keyword(section, "RUN_TYPE")
782 4989 : CALL keyword_get(keyword, enum=enum2)
783 :
784 : WRITE (UNIT=output_unit, FMT="(T2,A,T41,A40)") &
785 4989 : start_section_label//"| Method name", &
786 4989 : ADJUSTR(TRIM(enum_i2c(enum1, globenv%prog_name_id))), &
787 4989 : start_section_label//"| Project name", &
788 4989 : ADJUSTR(project_name(:40)), &
789 4989 : start_section_label//"| Run type", &
790 4989 : ADJUSTR(TRIM(enum_i2c(enum2, globenv%run_type_id))), &
791 4989 : start_section_label//"| FFT library", &
792 4989 : ADJUSTR(globenv%default_fft_library(:40)), &
793 4989 : start_section_label//"| Diagonalization library", &
794 4989 : ADJUSTR(globenv%diag_library(:40)), &
795 4989 : start_section_label//"| DGEMM library", &
796 9978 : ADJUSTR(globenv%default_dgemm_library(:40))
797 :
798 4989 : IF (globenv%diag_library == "ELPA") THEN
799 : WRITE (UNIT=output_unit, FMT="(T2,A,T71,I10)") &
800 4894 : start_section_label//"| Minimum number of eigenvectors for ELPA usage", &
801 9788 : globenv%elpa_neigvec_min
802 : END IF
803 :
804 4989 : IF (globenv%diag_library == "DLAF") THEN
805 : WRITE (UNIT=output_unit, FMT="(T2,A,T71,I10)") &
806 0 : start_section_label//"| Minimum number of eigenvectors for DLAF usage", &
807 0 : globenv%dlaf_neigvec_min
808 : END IF
809 :
810 : #if defined(__CHECK_DIAG)
811 : ! Perform default check if no threshold value has been specified explicitly
812 : IF (globenv%eps_check_diag < 0.0_dp) THEN
813 : WRITE (UNIT=output_unit, FMT="(T2,A,T71,ES10.3)") &
814 : start_section_label//"| Orthonormality check for eigenvectors enabled", &
815 : eps_check_diag_default
816 : ELSE
817 : WRITE (UNIT=output_unit, FMT="(T2,A,T71,ES10.3)") &
818 : start_section_label//"| Orthonormality check for eigenvectors enabled", &
819 : globenv%eps_check_diag
820 : END IF
821 : #else
822 4989 : IF (globenv%eps_check_diag < 0.0_dp) THEN
823 : WRITE (UNIT=output_unit, FMT="(T2,A,T73,A)") &
824 4985 : start_section_label//"| Orthonormality check for eigenvectors", &
825 9970 : "DISABLED"
826 : ELSE
827 : WRITE (UNIT=output_unit, FMT="(T2,A,T71,ES10.3)") &
828 4 : start_section_label//"| Orthonormality check for eigenvectors enabled", &
829 8 : globenv%eps_check_diag
830 : END IF
831 : #endif
832 4989 : CALL section_release(section)
833 :
834 0 : SELECT CASE (cp_fm_get_mm_type())
835 : CASE (do_scalapack)
836 : WRITE (UNIT=output_unit, FMT="(T2,A,T72,A)") &
837 0 : start_section_label//"| Matrix multiplication library", "ScaLAPACK"
838 : CASE (do_cosma)
839 : WRITE (UNIT=output_unit, FMT="(T2,A,T76,A)") &
840 4989 : start_section_label//"| Matrix multiplication library", "COSMA"
841 : END SELECT
842 :
843 4989 : CALL section_vals_val_get(global_section, "ALLTOALL_SGL", l_val=ata)
844 : WRITE (UNIT=output_unit, FMT="(T2,A,T80,L1)") &
845 4989 : start_section_label//"| All-to-all communication in single precision", ata
846 4989 : CALL section_vals_val_get(global_section, "EXTENDED_FFT_LENGTHS", l_val=efl)
847 : WRITE (UNIT=output_unit, FMT="(T2,A,T80,L1)") &
848 4989 : start_section_label//"| FFTs using library dependent lengths", efl
849 :
850 136 : SELECT CASE (print_level)
851 : CASE (silent_print_level)
852 136 : print_level_string = "SILENT"
853 : CASE (low_print_level)
854 2340 : print_level_string = " LOW"
855 : CASE (medium_print_level)
856 2462 : print_level_string = "MEDIUM"
857 : CASE (high_print_level)
858 26 : print_level_string = " HIGH"
859 : CASE (debug_print_level)
860 25 : print_level_string = " DEBUG"
861 : CASE DEFAULT
862 4989 : CPABORT("Unknown print_level")
863 : END SELECT
864 :
865 4989 : CALL section_vals_val_get(global_section, "GRID%BACKEND", i_val=i_grid_backend)
866 4979 : SELECT CASE (i_grid_backend)
867 : CASE (GRID_BACKEND_AUTO)
868 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,A6)") &
869 4979 : start_section_label//"| Grid backend", "AUTO"
870 : CASE (GRID_BACKEND_CPU)
871 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,A6)") &
872 4 : start_section_label//"| Grid backend", "CPU"
873 : CASE (GRID_BACKEND_DGEMM)
874 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,A6)") &
875 4 : start_section_label//"| Grid backend", "DGEMM"
876 : CASE (GRID_BACKEND_GPU)
877 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,A6)") &
878 0 : start_section_label//"| Grid backend", "GPU"
879 : CASE (GRID_BACKEND_HIP)
880 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,A6)") &
881 0 : start_section_label//"| Grid backend", "HIP"
882 : CASE (GRID_BACKEND_REF)
883 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,A6)") &
884 4989 : start_section_label//"| Grid backend", "REF"
885 : END SELECT
886 :
887 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,A6)") &
888 4989 : start_section_label//"| Global print level", print_level_string
889 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,L6)") &
890 4989 : start_section_label//"| MPI I/O enabled", flag
891 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,I6)") &
892 4989 : start_section_label//"| Total number of message passing processes", &
893 4989 : para_env%num_pe, &
894 4989 : start_section_label//"| Number of threads for this process", &
895 4989 : num_threads, &
896 9978 : start_section_label//"| This output is from process", para_env%mepos
897 :
898 4989 : CALL m_omp_get_stacksize(omp_stacksize)
899 : WRITE (UNIT=output_unit, FMT="(T2,A,T68,A13)") &
900 4989 : start_section_label//"| OpenMP stack size per thread (OMP_STACKSIZE)", &
901 9978 : ADJUSTR(omp_stacksize)
902 :
903 4989 : IF (0 <= m_omp_trace_issues()) THEN ! only show in header if enabled
904 : WRITE (UNIT=output_unit, FMT="(T2,A,T68,A13)") &
905 0 : start_section_label//"| OpenMP issue trace (CP2K_OMP_TRACE)", &
906 0 : "enabled"
907 : END IF
908 :
909 4989 : CALL m_cpuinfo(model_name)
910 : WRITE (UNIT=output_unit, FMT="(T2,A,T30,A51)") &
911 4989 : start_section_label//"| CPU model name", ADJUSTR(TRIM(model_name))
912 :
913 4989 : cpuid = m_cpuid()
914 4989 : cpuid_static = m_cpuid_static()
915 :
916 4989 : IF ((cpuid > 0) .OR. (cpuid_static > 0)) THEN
917 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,I6)") &
918 4989 : start_section_label//"| CPUID", cpuid
919 4989 : IF (cpuid /= cpuid_static) THEN
920 : WRITE (UNIT=output_unit, FMT="(T2,A,T75,I6)") &
921 0 : start_section_label//"| Compiled for CPUID", cpuid_static
922 : END IF
923 : END IF
924 :
925 : ! filter cpuids by vlen to show more relevant information
926 4989 : IF (m_cpuid_vlen(cpuid_static) < m_cpuid_vlen(cpuid)) THEN
927 : ! base/machine_cpuid.c relies on the (same) target flags as the Fortran code
928 : CALL cp_hint(__LOCATION__, "The compiler target flags ("// &
929 : TRIM(m_cpuid_name(cpuid_static))//") used to build this binary cannot exploit "// &
930 : "all extensions of this CPU model ("//TRIM(m_cpuid_name(cpuid))//"). "// &
931 0 : "Consider compiler target flags as part of FCFLAGS and CFLAGS (ARCH file).")
932 : END IF
933 :
934 4989 : WRITE (UNIT=output_unit, FMT="()")
935 4989 : WRITE (UNIT=output_unit, FMT="(T2,A)") "MEMORY| system memory details [Kb]"
936 4989 : WRITE (UNIT=output_unit, FMT="(T2,A23,4A14)") "MEMORY| ", "rank 0", "min", "max", "average"
937 4989 : WRITE (UNIT=output_unit, FMT="(T2,A23,4I14)") "MEMORY| MemTotal ", memtotal, memtotal_min, memtotal_max, memtotal_avr
938 4989 : WRITE (UNIT=output_unit, FMT="(T2,A23,4I14)") "MEMORY| MemFree ", memFree, memfree_min, memfree_max, memfree_avr
939 4989 : WRITE (UNIT=output_unit, FMT="(T2,A23,4I14)") "MEMORY| Buffers ", Buffers, Buffers_min, Buffers_max, Buffers_avr
940 4989 : WRITE (UNIT=output_unit, FMT="(T2,A23,4I14)") "MEMORY| Cached ", Cached, Cached_min, Cached_max, Cached_avr
941 4989 : WRITE (UNIT=output_unit, FMT="(T2,A23,4I14)") "MEMORY| Slab ", Slab, Slab_min, Slab_max, Slab_avr
942 : WRITE (UNIT=output_unit, FMT="(T2,A23,4I14)") &
943 4989 : "MEMORY| SReclaimable ", SReclaimable, SReclaimable_min, SReclaimable_max, &
944 9978 : SReclaimable_avr
945 : WRITE (UNIT=output_unit, FMT="(T2,A23,4I14)") &
946 4989 : "MEMORY| MemLikelyFree ", MemLikelyFree, MemLikelyFree_min, MemLikelyFree_max, &
947 9978 : MemLikelyFree_avr
948 4989 : WRITE (UNIT=output_unit, FMT='()')
949 :
950 : END IF
951 :
952 : CALL cp_print_key_finished_output(output_unit, logger, global_section, &
953 9771 : "PROGRAM_RUN_INFO")
954 :
955 9771 : END SUBROUTINE read_global_section
956 :
957 : ! **************************************************************************************************
958 : !> \brief ...
959 : !> \param root_section ...
960 : !> \param para_env ...
961 : !> \param globenv ...
962 : !> \par History
963 : !> 2-Dec-2000 (JGH) added default fft library
964 : !> \author JGH,MK
965 : ! **************************************************************************************************
966 9771 : SUBROUTINE read_cp2k_section(root_section, para_env, globenv)
967 :
968 : TYPE(section_vals_type), POINTER :: root_section
969 : TYPE(mp_para_env_type), POINTER :: para_env
970 : TYPE(global_environment_type), POINTER :: globenv
971 :
972 : INTEGER :: output_unit
973 : TYPE(cp_logger_type), POINTER :: logger
974 : TYPE(section_vals_type), POINTER :: global_section
975 :
976 9771 : global_section => section_vals_get_subs_vals(root_section, "GLOBAL")
977 9771 : CALL read_global_section(root_section, para_env, globenv)
978 9771 : logger => cp_get_default_logger()
979 : output_unit = cp_print_key_unit_nr(logger, global_section, "PROGRAM_RUN_INFO", &
980 9771 : extension=".log")
981 :
982 9771 : CALL fft_setup_library(globenv, global_section)
983 9771 : CALL diag_setup_library(globenv)
984 :
985 : CALL cp_print_key_finished_output(output_unit, logger, global_section, &
986 9771 : "PROGRAM_RUN_INFO")
987 :
988 9771 : END SUBROUTINE read_cp2k_section
989 :
990 : ! **************************************************************************************************
991 : !> \brief check FFT preferred library availability, if not switch
992 : !> \param globenv ...
993 : !> \param global_section ...
994 : !> \par History
995 : !> 2-Dec-2000 (JGH) added default fft library
996 : !> Nov-2013 (MI) refactoring
997 : !> \author JGH,MK
998 : ! **************************************************************************************************
999 9771 : SUBROUTINE fft_setup_library(globenv, global_section)
1000 :
1001 : TYPE(global_environment_type), POINTER :: globenv
1002 : TYPE(section_vals_type), POINTER :: global_section
1003 :
1004 : CHARACTER(LEN=3*default_string_length) :: message
1005 : COMPLEX(KIND=dp), DIMENSION(4, 4, 4) :: zz
1006 : INTEGER :: stat
1007 : INTEGER, DIMENSION(3) :: n
1008 : LOGICAL :: try_fftw
1009 :
1010 39084 : n(:) = 4
1011 9771 : zz(:, :, :) = 0.0_dp
1012 :
1013 : ! Setup the FFT library
1014 : ! If the user has specified PREFERRED_FFT_LIBRARY try that first (default FFTW3)
1015 : ! If that one is not available, try FFTW3 (unless it has been tried already)
1016 : ! If FFTW3 is not available use FFTSG
1017 :
1018 9771 : IF (globenv%default_fft_library == "FFTW3") THEN
1019 : try_fftw = .FALSE.
1020 : ELSE
1021 10 : try_fftw = .TRUE.
1022 : END IF
1023 :
1024 : ! Initialize FFT library with the user's preferred FFT library
1025 : CALL init_fft(fftlib=TRIM(globenv%default_fft_library), &
1026 : alltoall=section_get_lval(global_section, "ALLTOALL_SGL"), &
1027 : fftsg_sizes=.NOT. section_get_lval(global_section, "EXTENDED_FFT_LENGTHS"), &
1028 : pool_limit=globenv%fft_pool_scratch_limit, &
1029 : wisdom_file=globenv%fftw_wisdom_file_name, &
1030 9771 : plan_style=globenv%fftw_plan_type)
1031 :
1032 : ! Check for FFT library
1033 9771 : CALL fft3d(FWFFT, n, zz, status=stat)
1034 9771 : IF (stat /= 0) THEN
1035 0 : IF (try_fftw) THEN
1036 : message = "FFT library "//TRIM(globenv%default_fft_library)// &
1037 0 : " is not available. Trying FFT library FFTW3."
1038 0 : CPWARN(TRIM(message))
1039 0 : globenv%default_fft_library = "FFTW3"
1040 : CALL init_fft(fftlib=TRIM(globenv%default_fft_library), &
1041 : alltoall=section_get_lval(global_section, "ALLTOALL_SGL"), &
1042 : fftsg_sizes=.NOT. section_get_lval(global_section, "EXTENDED_FFT_LENGTHS"), &
1043 : pool_limit=globenv%fft_pool_scratch_limit, &
1044 : wisdom_file=globenv%fftw_wisdom_file_name, &
1045 0 : plan_style=globenv%fftw_plan_type)
1046 :
1047 0 : CALL fft3d(FWFFT, n, zz, status=stat)
1048 : END IF
1049 0 : IF (stat /= 0) THEN
1050 : message = "FFT library "//TRIM(globenv%default_fft_library)// &
1051 0 : " is not available. Trying FFT library FFTSG."
1052 0 : CPWARN(TRIM(message))
1053 0 : globenv%default_fft_library = "FFTSG"
1054 : CALL init_fft(fftlib=TRIM(globenv%default_fft_library), &
1055 : alltoall=section_get_lval(global_section, "ALLTOALL_SGL"), &
1056 : fftsg_sizes=.NOT. section_get_lval(global_section, "EXTENDED_FFT_LENGTHS"), &
1057 : pool_limit=globenv%fft_pool_scratch_limit, &
1058 : wisdom_file=globenv%fftw_wisdom_file_name, &
1059 0 : plan_style=globenv%fftw_plan_type)
1060 :
1061 0 : CALL fft3d(FWFFT, n, zz, status=stat)
1062 0 : IF (stat /= 0) THEN
1063 0 : CPABORT("FFT library FFTSG does not work. No FFT library available.")
1064 : END IF
1065 : END IF
1066 : END IF
1067 :
1068 9771 : END SUBROUTINE fft_setup_library
1069 :
1070 : ! **************************************************************************************************
1071 : !> \brief availability diagonalizatioon library
1072 : !>
1073 : !> \param globenv ...
1074 : !> \author MI
1075 : ! **************************************************************************************************
1076 9771 : SUBROUTINE diag_setup_library(globenv)
1077 : TYPE(global_environment_type), POINTER :: globenv
1078 :
1079 : CHARACTER(LEN=3*default_string_length) :: message
1080 : LOGICAL :: fallback_applied
1081 :
1082 : CALL diag_init(diag_lib=TRIM(globenv%diag_library), &
1083 : fallback_applied=fallback_applied, &
1084 : elpa_kernel=globenv%k_elpa, &
1085 : elpa_neigvec_min_input=globenv%elpa_neigvec_min, &
1086 : elpa_qr=globenv%elpa_qr, &
1087 : elpa_print=globenv%elpa_print, &
1088 : elpa_qr_unsafe=globenv%elpa_qr_unsafe, &
1089 : dlaf_neigvec_min_input=globenv%dlaf_neigvec_min, &
1090 9771 : eps_check_diag_input=globenv%eps_check_diag)
1091 :
1092 9771 : IF (fallback_applied) THEN
1093 : message = "Diagonalization library "//TRIM(globenv%diag_library)// &
1094 0 : " is not available. The ScaLAPACK library is used as fallback."
1095 0 : CPWARN(TRIM(message))
1096 : END IF
1097 :
1098 9771 : END SUBROUTINE diag_setup_library
1099 :
1100 : ! **************************************************************************************************
1101 : !> \brief ...
1102 : !> \param glob_section ...
1103 : ! **************************************************************************************************
1104 48855 : SUBROUTINE fm_setup(glob_section)
1105 : TYPE(section_vals_type), POINTER :: glob_section
1106 :
1107 : INTEGER :: multiplication_type, ncb, nrb
1108 : LOGICAL :: force_me
1109 : TYPE(section_vals_type), POINTER :: fm_section
1110 :
1111 9771 : fm_section => section_vals_get_subs_vals(glob_section, "FM")
1112 :
1113 9771 : CALL section_vals_val_get(fm_section, "NROW_BLOCKS", i_val=nrb)
1114 9771 : CALL section_vals_val_get(fm_section, "NCOL_BLOCKS", i_val=ncb)
1115 9771 : CALL section_vals_val_get(fm_section, "FORCE_BLOCK_SIZE", l_val=force_me)
1116 :
1117 9771 : CALL cp_fm_struct_config(nrow_block=nrb, ncol_block=ncb, force_block=force_me)
1118 :
1119 : CALL section_vals_val_get(fm_section, "TYPE_OF_MATRIX_MULTIPLICATION", &
1120 9771 : i_val=multiplication_type)
1121 :
1122 9771 : CALL cp_fm_setup(multiplication_type)
1123 :
1124 9771 : END SUBROUTINE fm_setup
1125 :
1126 : ! **************************************************************************************************
1127 : !> \brief ...
1128 : !> \param glob_section ...
1129 : ! **************************************************************************************************
1130 9771 : SUBROUTINE dgemm_setup(glob_section)
1131 : TYPE(section_vals_type), POINTER :: glob_section
1132 :
1133 : INTEGER :: dgemm_type
1134 :
1135 9771 : CALL section_vals_val_get(glob_section, "PREFERRED_DGEMM_LIBRARY", i_val=dgemm_type)
1136 :
1137 9771 : CALL local_gemm_set_library(dgemm_type)
1138 :
1139 9771 : END SUBROUTINE dgemm_setup
1140 :
1141 : ! **************************************************************************************************
1142 : !> \brief Parses the input section used to define the heuristic rules which determine if
1143 : !> a FM matrix should be redistributed before diagonalizing it.
1144 : !> \param glob_section the global input section
1145 : !> \author Nico Holmberg [01.2018]
1146 : ! **************************************************************************************************
1147 48855 : SUBROUTINE fm_diag_rules_setup(glob_section)
1148 : TYPE(section_vals_type), POINTER :: glob_section
1149 :
1150 : INTEGER :: a, x
1151 : LOGICAL :: elpa_force_redistribute, should_print
1152 : TYPE(section_vals_type), POINTER :: section
1153 :
1154 9771 : section => section_vals_get_subs_vals(glob_section, "FM_DIAG_SETTINGS")
1155 :
1156 9771 : CALL section_vals_val_get(section, "PARAMETER_A", i_val=a)
1157 9771 : CALL section_vals_val_get(section, "PARAMETER_X", i_val=x)
1158 9771 : CALL section_vals_val_get(section, "PRINT_FM_REDISTRIBUTE", l_val=should_print)
1159 9771 : CALL section_vals_val_get(section, "ELPA_FORCE_REDISTRIBUTE", l_val=elpa_force_redistribute)
1160 :
1161 9771 : CALL cp_fm_redistribute_init(a, x, should_print, elpa_force_redistribute)
1162 :
1163 9771 : END SUBROUTINE fm_diag_rules_setup
1164 : ! **************************************************************************************************
1165 : !> \brief reads the Walltime also in format HH:MM:SS
1166 : !> \param section ...
1167 : !> \param keyword_name ...
1168 : !> \param walltime ...
1169 : !> \par History
1170 : !> none
1171 : !> \author Mandes
1172 : ! **************************************************************************************************
1173 9791 : SUBROUTINE cp2k_get_walltime(section, keyword_name, walltime)
1174 : TYPE(section_vals_type), POINTER :: section
1175 : CHARACTER(len=*), INTENT(in) :: keyword_name
1176 : REAL(KIND=dp), INTENT(out) :: walltime
1177 :
1178 : CHARACTER(LEN=1) :: c1, c2
1179 : CHARACTER(LEN=100) :: txt
1180 : INTEGER :: hours, ierr, minutes, n, seconds
1181 :
1182 9791 : CALL section_vals_val_get(section, keyword_name, c_val=txt)
1183 9791 : n = LEN_TRIM(txt)
1184 :
1185 9791 : IF (n == 0) THEN
1186 9550 : walltime = -1.0_dp
1187 241 : ELSE IF (INDEX(txt, ":") == 0) THEN
1188 189 : READ (txt(1:n), FMT=*, IOSTAT=ierr) walltime
1189 189 : IF (ierr /= 0) CPABORT('Could not parse WALLTIME: "'//txt(1:n)//'"')
1190 : ELSE
1191 52 : READ (txt(1:n), FMT="(I2,A1,I2,A1,I2)", IOSTAT=ierr) hours, c1, minutes, c2, seconds
1192 52 : IF (n /= 8 .OR. ierr /= 0 .OR. c1 .NE. ":" .OR. c2 .NE. ":") &
1193 0 : CPABORT('Could not parse WALLTIME: "'//txt(1:n)//'"')
1194 52 : walltime = 3600.0_dp*REAL(hours, dp) + 60.0_dp*REAL(minutes, dp) + REAL(seconds, dp)
1195 : END IF
1196 9791 : END SUBROUTINE cp2k_get_walltime
1197 :
1198 : ! **************************************************************************************************
1199 : !> \brief Writes final timings and banner for CP2K
1200 : !> \param root_section ...
1201 : !> \param para_env ...
1202 : !> \param globenv ...
1203 : !> \param wdir ...
1204 : !> \param q_finalize ...
1205 : !> \par History
1206 : !> none
1207 : !> \author JGH,MK
1208 : !> \note
1209 : !> The following routines need to be synchronized wrt. adding/removing
1210 : !> of the default environments (logging, performance,error):
1211 : !> environment:cp2k_init, environment:cp2k_finalize,
1212 : !> f77_interface:f_env_add_defaults, f77_interface:f_env_rm_defaults,
1213 : !> f77_interface:create_force_env, f77_interface:destroy_force_env
1214 : ! **************************************************************************************************
1215 19542 : SUBROUTINE cp2k_finalize(root_section, para_env, globenv, wdir, q_finalize)
1216 :
1217 : TYPE(section_vals_type), POINTER :: root_section
1218 : TYPE(mp_para_env_type), POINTER :: para_env
1219 : TYPE(global_environment_type), POINTER :: globenv
1220 : CHARACTER(LEN=*), OPTIONAL :: wdir
1221 : LOGICAL, INTENT(IN), OPTIONAL :: q_finalize
1222 :
1223 : CHARACTER(LEN=default_path_length) :: cg_filename
1224 : INTEGER :: cg_mode, iw, unit_exit
1225 : LOGICAL :: delete_it, do_finalize, report_maxloc, &
1226 : sort_by_self_time
1227 : REAL(KIND=dp) :: r_timings
1228 : TYPE(cp_logger_type), POINTER :: logger
1229 :
1230 : ! Look if we inherited a failure, more care is needed if so
1231 : ! i.e. the input is most likely not available
1232 : ! Set flag if this is a development version
1233 :
1234 9771 : do_finalize = .TRUE.
1235 9771 : IF (PRESENT(q_finalize)) do_finalize = q_finalize
1236 : ! Clean up
1237 9771 : NULLIFY (logger)
1238 9771 : logger => cp_get_default_logger()
1239 9771 : IF (do_finalize) THEN
1240 9561 : CALL deallocate_spherical_harmonics()
1241 9561 : CALL deallocate_orbital_pointers()
1242 9561 : CALL deallocate_md_ftable()
1243 9561 : CALL diag_finalize()
1244 : ! finalize the fft (i.e. writes the wisdom if FFTW3 )
1245 9561 : CALL finalize_fft(para_env, globenv%fftw_wisdom_file_name)
1246 9561 : CALL finalize_libvori()
1247 : END IF
1248 :
1249 : ! Write message passing performance info
1250 :
1251 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PROGRAM_RUN_INFO", &
1252 9771 : extension=".log")
1253 9771 : CALL describe_mp_perf_env(iw)
1254 : CALL cp_print_key_finished_output(iw, logger, root_section, &
1255 9771 : "GLOBAL%PROGRAM_RUN_INFO")
1256 :
1257 9771 : CALL collect_citations_from_ranks(para_env)
1258 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%REFERENCES", &
1259 9771 : extension=".Log")
1260 9771 : IF (iw > 0) THEN
1261 4981 : WRITE (UNIT=iw, FMT="(/,T2,A)") REPEAT("-", 79)
1262 4981 : WRITE (UNIT=iw, FMT="(T2,A,T80,A)") "-", "-"
1263 4981 : WRITE (UNIT=iw, FMT="(T2,A,T30,A,T80,A)") "-", "R E F E R E N C E S", "-"
1264 4981 : WRITE (UNIT=iw, FMT="(T2,A,T80,A)") "-", "-"
1265 4981 : WRITE (UNIT=iw, FMT="(T2,A)") REPEAT("-", 79)
1266 4981 : WRITE (UNIT=iw, FMT="(T2,A)") ""
1267 4981 : WRITE (UNIT=iw, FMT="(T2,A)") TRIM(cp2k_version)//", the CP2K developers group ("//TRIM(cp2k_year)//")."
1268 4981 : WRITE (UNIT=iw, FMT="(T2,A)") "CP2K is freely available from "//TRIM(cp2k_home)//" ."
1269 4981 : WRITE (UNIT=iw, FMT="(T2,A)") ""
1270 4981 : CALL print_cited_references(unit=iw)
1271 : END IF
1272 : CALL cp_print_key_finished_output(iw, logger, root_section, &
1273 9771 : "GLOBAL%REFERENCES")
1274 :
1275 9771 : CALL timestop(globenv%handle) ! corresponding the "CP2K" in cp2k_init
1276 :
1277 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%TIMINGS", &
1278 9771 : extension=".Log")
1279 9771 : r_timings = section_get_rval(root_section, "GLOBAL%TIMINGS%THRESHOLD")
1280 9771 : sort_by_self_time = section_get_lval(root_section, "GLOBAL%TIMINGS%SORT_BY_SELF_TIME")
1281 9771 : report_maxloc = section_get_lval(root_section, "GLOBAL%TIMINGS%REPORT_MAXLOC")
1282 9771 : IF (m_energy() .NE. 0.0_dp) THEN
1283 0 : CALL timings_report_print(iw, r_timings, sort_by_self_time, cost_type_energy, report_maxloc, para_env)
1284 : END IF
1285 9771 : CALL timings_report_print(iw, r_timings, sort_by_self_time, cost_type_time, report_maxloc, para_env)
1286 :
1287 : ! Write the callgraph, if desired by user
1288 9771 : CALL section_vals_val_get(root_section, "GLOBAL%CALLGRAPH", i_val=cg_mode)
1289 9771 : IF (cg_mode /= CALLGRAPH_NONE) THEN
1290 2 : CALL section_vals_val_get(root_section, "GLOBAL%CALLGRAPH_FILE_NAME", c_val=cg_filename)
1291 2 : IF (LEN_TRIM(cg_filename) == 0) cg_filename = TRIM(logger%iter_info%project_name)
1292 2 : IF (cg_mode == CALLGRAPH_ALL) & !incorporate mpi-rank into filename
1293 0 : cg_filename = TRIM(cg_filename)//"_"//TRIM(ADJUSTL(cp_to_string(para_env%mepos)))
1294 2 : IF (iw > 0) THEN
1295 1 : WRITE (UNIT=iw, FMT="(T2,3X,A)") "Writing callgraph to: "//TRIM(cg_filename)//".callgraph"
1296 1 : WRITE (UNIT=iw, FMT="()")
1297 1 : WRITE (UNIT=iw, FMT="(T2,A)") "-------------------------------------------------------------------------------"
1298 : END IF
1299 2 : IF (cg_mode == CALLGRAPH_ALL .OR. para_env%is_source()) &
1300 1 : CALL timings_report_callgraph(TRIM(cg_filename)//".callgraph")
1301 : END IF
1302 :
1303 : CALL cp_print_key_finished_output(iw, logger, root_section, &
1304 9771 : "GLOBAL%TIMINGS")
1305 :
1306 9771 : CALL rm_mp_perf_env()
1307 9771 : CALL rm_timer_env()
1308 :
1309 9771 : IF (para_env%is_source()) THEN
1310 : iw = cp_print_key_unit_nr(logger, root_section, "GLOBAL%PROGRAM_RUN_INFO", &
1311 4989 : extension=".log")
1312 :
1313 : ! Deleting (if existing) the external EXIT files
1314 4989 : delete_it = .FALSE.
1315 4989 : INQUIRE (FILE="EXIT", EXIST=delete_it)
1316 4989 : IF (delete_it) THEN
1317 0 : CALL open_file(file_name="EXIT", unit_number=unit_exit)
1318 0 : CALL close_file(unit_number=unit_exit, file_status="DELETE")
1319 : END IF
1320 :
1321 4989 : delete_it = .FALSE.
1322 4989 : INQUIRE (FILE=TRIM(logger%iter_info%project_name)//".EXIT", EXIST=delete_it)
1323 4989 : IF (delete_it) THEN
1324 0 : CALL open_file(file_name=TRIM(logger%iter_info%project_name)//".EXIT", unit_number=unit_exit)
1325 0 : CALL close_file(unit_number=unit_exit, file_status="DELETE")
1326 : END IF
1327 :
1328 : ! Print OpenMP issue counter and number of warnings for this workload
1329 4989 : IF (iw > 0) THEN
1330 4989 : IF (0 <= m_omp_trace_issues()) THEN
1331 0 : WRITE (iw, "(T2,A,I0)") "The number of traced issues for OpenMP : ", m_omp_trace_issues()
1332 : END IF
1333 4989 : WRITE (iw, "(T2,A,I0)") "The number of warnings for this run is : ", warning_counter
1334 4989 : WRITE (iw, *) ""
1335 4989 : WRITE (UNIT=iw, FMT="(T2,A)") REPEAT("-", 79)
1336 : END IF
1337 :
1338 : ! Update the runtime environment variables
1339 4989 : CALL get_runtime_info()
1340 :
1341 : ! Just a choice, do not print the CP2K footer if there is a failure
1342 5249 : CALL cp2k_footer(iw, wdir)
1343 4989 : IF (iw > 0) FLUSH (iw) ! ignore &GLOBAL / FLUSH_SHOULD_FLUSH
1344 :
1345 : CALL cp_print_key_finished_output(iw, logger, root_section, &
1346 4989 : "GLOBAL%PROGRAM_RUN_INFO")
1347 : END IF
1348 :
1349 : ! Release message passing environment
1350 9771 : CALL cp_rm_default_logger()
1351 :
1352 9771 : END SUBROUTINE cp2k_finalize
1353 :
1354 : END MODULE environment
|