Line data Source code
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 Define type storing the global information of a run. Keep the amount of stored data small.
10 : !> Use it sparingly and try not to send it too deep in your structures.
11 : !> \par History
12 : !> - print keys, basis_set_file name and potential_file_name added to the
13 : !> global type (27.02.2001, MK)
14 : !> - added pp_library_path to type (28.11.2001, JGH)
15 : !> - Merged with MODULE print_keys (17.01.2002, MK)
16 : !> - reference counting, create (08.2004, fawzi)
17 : !> - new (parallel) random number generator (11.03.2006, MK)
18 : !> - add eps_check_diag, remove id_nr from globenv, and revise initialization (04.05.2021, MK)
19 : !> \author JGH, MK, fawzi
20 : ! **************************************************************************************************
21 : MODULE global_types
22 :
23 : USE cp_blacs_env, ONLY: BLACS_GRID_SQUARE
24 : USE fft_api, ONLY: FFT_LIBRARY_BACKEND_DEFAULT
25 : USE kinds, ONLY: default_path_length,&
26 : default_string_length,&
27 : dp
28 : USE machine, ONLY: m_walltime
29 : USE parallel_rng_types, ONLY: rng_stream_type
30 : #include "./base/base_uses.f90"
31 :
32 : IMPLICIT NONE
33 :
34 : PRIVATE
35 :
36 : ! Global parameters
37 :
38 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'global_types'
39 :
40 : INTEGER, PARAMETER :: SILENT = 0, &
41 : LOW = 1, &
42 : MEDIUM = 2, &
43 : HIGH = 3, &
44 : DEBUG = 4
45 :
46 : ! Public data types
47 :
48 : PUBLIC :: global_environment_type
49 :
50 : ! Public subroutines
51 :
52 : PUBLIC :: globenv_create, &
53 : globenv_retain, &
54 : globenv_release
55 :
56 : ! **************************************************************************************************
57 : !> \brief contains the initially parsed file and the initial parallel environment
58 : !> \param ref_count reference count (see doc/ReferenceCounting.html)
59 : !> \param handle handle with the total time of the computation
60 : !>
61 : !> Personally I think that all the other attributes should go away
62 : !> (and maybe add a logger)[fawzi]
63 : !> \note
64 : !> This is not but really should be passed as pointer and use reference
65 : !> counting. Use it accordingly wherever possible.
66 : ! **************************************************************************************************
67 : TYPE global_environment_type
68 : INTEGER :: ref_count = 0
69 : TYPE(rng_stream_type), ALLOCATABLE :: gaussian_rng_stream
70 : CHARACTER(LEN=default_string_length) :: diag_library = "ScaLAPACK"
71 : CHARACTER(LEN=default_string_length) :: cholesky_library = "ScaLAPACK"
72 : INTEGER :: default_fft_library = FFT_LIBRARY_BACKEND_DEFAULT
73 : CHARACTER(LEN=default_path_length) :: fftw_wisdom_file_name = "/etc/fftw/wisdom"
74 : CHARACTER(LEN=default_string_length) :: default_dgemm_library = "BLAS"
75 : INTEGER :: fft_pool_scratch_limit = 0 ! limit number of used FFT scratches
76 : INTEGER :: fftw_plan_type = 0 ! which kind of planning to use with FFTW
77 : INTEGER :: idum = 0 ! random number seed
78 : INTEGER :: prog_name_id = 0 ! index to define the type of program
79 : INTEGER :: run_type_id = 0 ! index to define the run_tupe
80 : INTEGER :: blacs_grid_layout = BLACS_GRID_SQUARE ! will store the user preference for the BLACS grid
81 : INTEGER :: k_elpa = 1 ! optimized kernel for the ELPA diagonalization library
82 : INTEGER :: k_elpa_c = -1 ! optimized kernel for the ELPA diagonalization library (complex matrices)
83 : INTEGER :: elpa_neigvec_min = 0 ! Minimum number of eigenvectors for ELPA usage
84 : LOGICAL :: fftw_wisdom_file_explicit = .FALSE. ! FFTW wisdom file name was specified in the input
85 : LOGICAL :: fftw_use_guru_interface = .TRUE. ! use the FFTW guru interface when available
86 : LOGICAL :: elpa_qr = .TRUE. ! allow ELPA to use QR during diagonalization
87 : LOGICAL :: elpa_print = .FALSE. ! if additional information about ELPA diagonalization should be printed
88 : LOGICAL :: elpa_one_stage = .FALSE. ! enable one-stage ELPA solver
89 : INTEGER :: dlaf_neigvec_min = 0 ! Minimum number of eigenvectors for DLAF eigensolver usage
90 : INTEGER :: dlaf_cholesky_n_min = 0 ! Minimum matrix size for DLAF Cholesky decomposition usage
91 : LOGICAL :: direct_generalized_diagonalization = .FALSE. ! use a direct generalized eigensolver
92 : LOGICAL :: blacs_repeatable = .FALSE. ! will store the user preference for the repeatability of BLACS collectives
93 : REAL(KIND=dp) :: cp2k_start_time = 0.0_dp
94 : REAL(KIND=dp) :: cp2k_target_time = HUGE(0.0_dp) ! Maximum run time in seconds
95 : ! Threshold value for the orthonormality of the eigenvectors after diagonalization
96 : ! A negative threshold value disables the check which is the default
97 : REAL(KIND=dp) :: eps_check_diag = -1.0_dp
98 : INTEGER :: handle = 0
99 : END TYPE global_environment_type
100 :
101 : CONTAINS
102 :
103 : ! **************************************************************************************************
104 : !> \brief Creates the global environment globenv
105 : !> \param globenv the globenv to create
106 : !> \author fawzi
107 : ! **************************************************************************************************
108 11915 : SUBROUTINE globenv_create(globenv)
109 : TYPE(global_environment_type), POINTER :: globenv
110 :
111 11915 : CPASSERT(.NOT. ASSOCIATED(globenv))
112 11915 : ALLOCATE (globenv)
113 321705 : ALLOCATE (globenv%gaussian_rng_stream)
114 11915 : globenv%ref_count = 1
115 11915 : globenv%cp2k_start_time = m_walltime()
116 :
117 11915 : END SUBROUTINE globenv_create
118 :
119 : ! **************************************************************************************************
120 : !> \brief Retains the global environment globenv
121 : !> \param globenv the global environment to retain
122 : !> \author fawzi
123 : ! **************************************************************************************************
124 11721 : SUBROUTINE globenv_retain(globenv)
125 : TYPE(global_environment_type), POINTER :: globenv
126 :
127 11721 : CPASSERT(ASSOCIATED(globenv))
128 11721 : CPASSERT(globenv%ref_count > 0)
129 11721 : globenv%ref_count = globenv%ref_count + 1
130 :
131 11721 : END SUBROUTINE globenv_retain
132 :
133 : ! **************************************************************************************************
134 : !> \brief Releases the global environment globenv
135 : !> \param globenv the global environment to release
136 : !> \author fawzi
137 : ! **************************************************************************************************
138 35023 : SUBROUTINE globenv_release(globenv)
139 : TYPE(global_environment_type), POINTER :: globenv
140 :
141 35023 : IF (ASSOCIATED(globenv)) THEN
142 23636 : CPASSERT(globenv%ref_count > 0)
143 23636 : globenv%ref_count = globenv%ref_count - 1
144 23636 : IF (globenv%ref_count == 0) THEN
145 11915 : IF (ALLOCATED(globenv%gaussian_rng_stream)) THEN
146 11915 : DEALLOCATE (globenv%gaussian_rng_stream)
147 : END IF
148 11915 : DEALLOCATE (globenv)
149 : END IF
150 : END IF
151 :
152 35023 : NULLIFY (globenv)
153 :
154 35023 : END SUBROUTINE globenv_release
155 :
156 0 : END MODULE global_types
|