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 some minimal info about CP2K, including its version and license
10 : !> \par History
11 : !> - created (2007-09, Joost VandeVondele)
12 : !> - moved into this module information related to runtime:pid, user_name,
13 : !> host_name, cwd, datx (2009-06, Teodoro Laino)
14 : !> \author Joost VandeVondele
15 : ! **************************************************************************************************
16 : MODULE cp2k_info
17 :
18 : USE kinds, ONLY: default_path_length,&
19 : default_string_length
20 : USE machine, ONLY: m_datum,&
21 : m_getcwd,&
22 : m_getlog,&
23 : m_getpid,&
24 : m_hostnm
25 : USE string_utilities, ONLY: integer_to_string
26 :
27 : IMPLICIT NONE
28 : PRIVATE
29 :
30 : PUBLIC :: cp2k_version, cp2k_year, cp2k_home, cp2k_flags
31 : PUBLIC :: compile_arch, compile_date, compile_host, compile_revision
32 : PUBLIC :: print_cp2k_license, get_runtime_info, write_restart_header
33 :
34 : #if defined(__COMPILE_REVISION)
35 : CHARACTER(LEN=*), PARAMETER :: compile_revision = __COMPILE_REVISION
36 : #else
37 : CHARACTER(LEN=*), PARAMETER :: compile_revision = "unknown"
38 : #endif
39 :
40 : !!! Keep version in sync with CMakeLists.txt !!!
41 : CHARACTER(LEN=*), PARAMETER :: cp2k_version = "CP2K version 2024.2 (Development Version)"
42 : CHARACTER(LEN=*), PARAMETER :: cp2k_year = "2024"
43 : CHARACTER(LEN=*), PARAMETER :: cp2k_home = "https://www.cp2k.org/"
44 :
45 : ! compile time information
46 : #if defined(__COMPILE_ARCH)
47 : CHARACTER(LEN=*), PARAMETER :: compile_arch = __COMPILE_ARCH
48 : #else
49 : CHARACTER(LEN=*), PARAMETER :: compile_arch = "unknown: -D__COMPILE_ARCH=?"
50 : #endif
51 :
52 : #if defined(__COMPILE_DATE)
53 : CHARACTER(LEN=*), PARAMETER :: compile_date = __COMPILE_DATE
54 : #else
55 : CHARACTER(LEN=*), PARAMETER :: compile_date = "unknown: -D__COMPILE_DATE=?"
56 : #endif
57 :
58 : #if defined(__COMPILE_HOST)
59 : CHARACTER(LEN=*), PARAMETER :: compile_host = __COMPILE_HOST
60 : #else
61 : CHARACTER(LEN=*), PARAMETER :: compile_host = "unknown: -D__COMPILE_HOST=?"
62 : #endif
63 :
64 : ! Local runtime informations
65 : CHARACTER(LEN=26), PUBLIC :: r_datx
66 : CHARACTER(LEN=default_path_length), PUBLIC :: r_cwd
67 : CHARACTER(LEN=default_string_length), PUBLIC :: r_host_name, r_user_name
68 : INTEGER, PUBLIC :: r_pid
69 :
70 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp2k_info'
71 : CONTAINS
72 :
73 : ! **************************************************************************************************
74 : !> \brief list all compile time options that influence the capabilities of cp2k.
75 : !> All new flags should be added here (and be unique grep-able)
76 : !> \return ...
77 : ! **************************************************************************************************
78 4617 : FUNCTION cp2k_flags() RESULT(flags)
79 : CHARACTER(len=10*default_string_length) :: flags
80 :
81 : CHARACTER(len=default_string_length) :: tmp_str
82 :
83 4617 : flags = "cp2kflags:"
84 :
85 : ! Ensure that tmp_str is used to silence compiler warnings
86 4617 : tmp_str = ""
87 4617 : flags = TRIM(flags)//TRIM(tmp_str)
88 :
89 4617 : !$ flags = TRIM(flags)//" omp"
90 : #if defined(__LIBINT)
91 4617 : flags = TRIM(flags)//" libint"
92 : #endif
93 : #if defined(__FFTW3)
94 4617 : flags = TRIM(flags)//" fftw3"
95 : #endif
96 : #if defined(__FFTW3_MKL)
97 : flags = TRIM(flags)//" fftw3_mkl"
98 : #endif
99 : #if defined(__LIBXC)
100 4617 : flags = TRIM(flags)//" libxc"
101 : #endif
102 : #if defined(__LIBGRPP)
103 4617 : flags = TRIM(flags)//" libgrpp"
104 : #endif
105 : #if defined(__LIBPEXSI)
106 4617 : flags = TRIM(flags)//" pexsi"
107 : #endif
108 : #if defined(__ELPA)
109 4617 : flags = TRIM(flags)//" elpa"
110 : #endif
111 : #if defined(__ELPA_NVIDIA_GPU)
112 : flags = TRIM(flags)//" elpa_nvidia_gpu"
113 : #endif
114 : #if defined(__ELPA_AMD_GPU)
115 : flags = TRIM(flags)//" elpa_amd_gpu"
116 : #endif
117 : #if defined(__ELPA_INTEL_GPU)
118 : flags = TRIM(flags)//" elpa_intel_gpu"
119 : #endif
120 : #if defined(__parallel)
121 4617 : flags = TRIM(flags)//" parallel scalapack"
122 : #endif
123 : #if defined(__MPI_F08)
124 : flags = TRIM(flags)//" mpi_f08"
125 : #endif
126 : #if defined(__COSMA)
127 4617 : flags = TRIM(flags)//" cosma"
128 : #endif
129 :
130 : #if defined(__QUIP)
131 4617 : flags = TRIM(flags)//" quip"
132 : #endif
133 :
134 : #if defined(__HAS_PATCHED_CUFFT_70)
135 : flags = TRIM(flags)//" patched_cufft_70"
136 : #endif
137 :
138 : #if defined(__DEEPMD)
139 4617 : flags = TRIM(flags)//" deepmd"
140 : #endif
141 :
142 : #if defined(__PW_FPGA)
143 : flags = TRIM(flags)//" pw_fpga"
144 : #endif
145 :
146 : #if defined(__PW_FPGA_SP)
147 : flags = TRIM(flags)//" pw_fpga_sp"
148 : #endif
149 :
150 : #if defined(__LIBXSMM)
151 4617 : flags = TRIM(flags)//" xsmm"
152 : #endif
153 :
154 : #if defined(__CRAY_PM_ACCEL_ENERGY)
155 : flags = TRIM(flags)//" cray_pm_accel_energy"
156 : #endif
157 : #if defined(__CRAY_PM_ENERGY)
158 : flags = TRIM(flags)//" cray_pm_energy"
159 : #endif
160 : #if defined(__CRAY_PM_FAKE_ENERGY)
161 : flags = TRIM(flags)//" cray_pm_fake_energy"
162 : #endif
163 : #if defined(__DBCSR_ACC)
164 : flags = TRIM(flags)//" dbcsr_acc"
165 : #endif
166 : #if defined(__MAX_CONTR)
167 : CALL integer_to_string(__MAX_CONTR, tmp_str)
168 : flags = TRIM(flags)//" max_contr="//TRIM(tmp_str)
169 : #endif
170 : #if defined(__NO_SOCKETS)
171 : flags = TRIM(flags)//" no_sockets"
172 : #endif
173 : #if defined(__NO_MPI_THREAD_SUPPORT_CHECK)
174 : flags = TRIM(flags)//" no_mpi_thread_support_check"
175 : #endif
176 : #if defined(__NO_STATM_ACCESS)
177 : flags = TRIM(flags)//" no_statm_access"
178 : #endif
179 : #if defined(__MINGW)
180 : flags = TRIM(flags)//" mingw"
181 : #endif
182 : #if defined(__PW_CUDA_NO_HOSTALLOC)
183 : flags = TRIM(flags)//" pw_cuda_no_hostalloc"
184 : #endif
185 : #if defined(__STATM_RESIDENT)
186 : flags = TRIM(flags)//" statm_resident"
187 : #endif
188 : #if defined(__STATM_TOTAL)
189 : flags = TRIM(flags)//" statm_total"
190 : #endif
191 : #if defined(__PLUMED2)
192 4617 : flags = TRIM(flags)//" plumed2"
193 : #endif
194 : #if defined(__HAS_IEEE_EXCEPTIONS)
195 : flags = TRIM(flags)//" has_ieee_exceptions"
196 : #endif
197 : #if defined(__NO_ABORT)
198 4617 : flags = TRIM(flags)//" no_abort"
199 : #endif
200 : #if defined(__SPGLIB)
201 4617 : flags = TRIM(flags)//" spglib"
202 : #endif
203 : #if defined(__ACCELERATE)
204 : flags = TRIM(flags)//" accelerate"
205 : #endif
206 : #if defined(__MKL)
207 : flags = TRIM(flags)//" mkl"
208 : #endif
209 : #if defined(__DFTD4)
210 4617 : flags = TRIM(flags)//" libdftd4"
211 : #endif
212 : #if defined(__SIRIUS)
213 4617 : flags = TRIM(flags)//" sirius"
214 : #endif
215 : #if defined(__CHECK_DIAG)
216 : flags = TRIM(flags)//" check_diag"
217 : #endif
218 : #if defined(__LIBVORI)
219 4617 : flags = TRIM(flags)//" libvori"
220 4617 : flags = TRIM(flags)//" libbqb"
221 : #endif
222 : #if defined(__LIBMAXWELL)
223 : flags = TRIM(flags)//" libmaxwell"
224 : #endif
225 : #if defined(__LIBTORCH)
226 4617 : flags = TRIM(flags)//" libtorch"
227 : #endif
228 : #if defined(__OFFLOAD_CUDA)
229 : flags = TRIM(flags)//" offload_cuda"
230 : #endif
231 : #if defined(__OFFLOAD_HIP)
232 : flags = TRIM(flags)//" offload_hip"
233 : #endif
234 : #if defined(__OFFLOAD_OPENCL)
235 : flags = TRIM(flags)//" offload_opencl"
236 : #endif
237 : #if defined(__NO_OFFLOAD_GRID)
238 : flags = TRIM(flags)//" no_offload_grid"
239 : #endif
240 : #if defined(__NO_OFFLOAD_DBM)
241 : flags = TRIM(flags)//" no_offload_dbm"
242 : #endif
243 : #if defined(__NO_OFFLOAD_PW)
244 : flags = TRIM(flags)//" no_offload_pw"
245 : #endif
246 : #if defined(__OFFLOAD_PROFILING)
247 : flags = TRIM(flags)//" offload_profiling"
248 : #endif
249 :
250 : #if defined(__SPLA) && defined(__OFFLOAD_GEMM)
251 : flags = TRIM(flags)//" spla_gemm_offloading"
252 : #endif
253 :
254 : #if defined(__CUSOLVERMP)
255 : flags = TRIM(flags)//" cusolvermp"
256 : #endif
257 :
258 : #if defined(__DLAF)
259 : flags = TRIM(flags)//" dlaf"
260 : #endif
261 :
262 : #if defined(__LIBVDWXC)
263 4617 : flags = TRIM(flags)//" libvdwxc"
264 : #endif
265 :
266 : #if defined(__HDF5)
267 4617 : flags = TRIM(flags)//" hdf5"
268 : #endif
269 :
270 : #if defined(__OFFLOAD_UNIFIED_MEMORY)
271 : flags = TRIM(flags)//" offload_unified_memory"
272 : #endif
273 :
274 4617 : END FUNCTION cp2k_flags
275 :
276 : ! **************************************************************************************************
277 : !> \brief ...
278 : !> \param iunit ...
279 : ! **************************************************************************************************
280 0 : SUBROUTINE print_cp2k_license(iunit)
281 :
282 : INTEGER :: iunit
283 :
284 : WRITE (UNIT=iunit, FMT="(T2,A)") &
285 0 : "******************************************************************************", &
286 0 : "* *", &
287 0 : "* CP2K: A general program to perform molecular dynamics simulations *", &
288 0 : "* Copyright (C) 2000-2024 CP2K developer group <https://www.cp2k.org/> *", &
289 0 : "* *", &
290 0 : "* This program is free software: you can redistribute it and/or modify *", &
291 0 : "* it under the terms of the GNU General Public License as published by *", &
292 0 : "* the Free Software Foundation, either version 2 of the License, or *", &
293 0 : "* (at your option) any later version. *", &
294 0 : "* *", &
295 0 : "* This program is distributed in the hope that it will be useful, *", &
296 0 : "* but WITHOUT ANY WARRANTY; without even the implied warranty of *", &
297 0 : "* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *", &
298 0 : "* GNU General Public License for more details. *", &
299 0 : "* *", &
300 0 : "* You should have received a copy of the GNU General Public License *", &
301 0 : "* along with this program. If not, see <https://www.gnu.org/licenses/>. *", &
302 0 : "* *", &
303 0 : "******************************************************************************"
304 :
305 0 : END SUBROUTINE print_cp2k_license
306 :
307 : ! **************************************************************************************************
308 : !> \brief ...
309 : ! **************************************************************************************************
310 13078 : SUBROUTINE get_runtime_info()
311 :
312 13078 : r_datx = ""
313 13078 : r_cwd = ""
314 13078 : r_host_name = ""
315 13078 : r_user_name = ""
316 : r_pid = -1
317 :
318 13078 : CALL m_getpid(r_pid)
319 13078 : CALL m_getlog(r_user_name)
320 13078 : CALL m_hostnm(r_host_name)
321 13078 : CALL m_datum(r_datx)
322 13078 : CALL m_getcwd(r_cwd)
323 :
324 13078 : END SUBROUTINE
325 :
326 : ! **************************************************************************************************
327 : !> \brief Writes the header for the restart file
328 : !> \param iunit ...
329 : !> \par History
330 : !> 01.2008 [created] - Split from write_restart
331 : !> \author Teodoro Laino - University of Zurich - 01.2008
332 : ! **************************************************************************************************
333 8337 : SUBROUTINE write_restart_header(iunit)
334 : INTEGER, INTENT(IN) :: iunit
335 :
336 : CHARACTER(LEN=256) :: cwd, datx
337 :
338 8337 : CALL m_datum(datx)
339 8337 : CALL m_getcwd(cwd)
340 :
341 8337 : WRITE (UNIT=iunit, FMT="(T2,A)") "# Version information for this restart file "
342 8337 : WRITE (UNIT=iunit, FMT="(T2,A)") "# current date "//TRIM(datx)
343 8337 : WRITE (UNIT=iunit, FMT="(T2,A)") "# current working dir "//TRIM(cwd)
344 :
345 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
346 8337 : "# Program compiled at", &
347 16674 : ADJUSTR(compile_date(1:MIN(50, LEN(compile_date))))
348 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
349 8337 : "# Program compiled on", &
350 16674 : ADJUSTR(compile_host(1:MIN(50, LEN(compile_host))))
351 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
352 8337 : "# Program compiled for", &
353 16674 : ADJUSTR(compile_arch(1:MIN(50, LEN(compile_arch))))
354 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
355 8337 : "# Source code revision number", &
356 16674 : ADJUSTR(compile_revision)
357 :
358 8337 : END SUBROUTINE write_restart_header
359 :
360 : END MODULE cp2k_info
|