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 : #ifdef __GAUXC
9 : #include "gauxc/gauxc_config.f"
10 : #endif
11 :
12 : ! **************************************************************************************************
13 : !> \brief some minimal info about CP2K, including its version and license
14 : !> \par History
15 : !> - created (2007-09, Joost VandeVondele)
16 : !> - moved into this module information related to runtime:pid, user_name,
17 : !> host_name, cwd, timestamp (2009-06, Teodoro Laino, 2025-08 MK)
18 : !> \author Joost VandeVondele
19 : ! **************************************************************************************************
20 : MODULE cp2k_info
21 :
22 : USE iso_fortran_env, ONLY: compiler_options
23 : USE kinds, ONLY: default_path_length,&
24 : default_string_length
25 : USE machine, ONLY: m_getcwd,&
26 : m_getlog,&
27 : m_getpid,&
28 : m_hostnm,&
29 : m_timestamp,&
30 : timestamp_length
31 : USE string_utilities, ONLY: integer_to_string
32 :
33 : IMPLICIT NONE
34 : PRIVATE
35 :
36 : PUBLIC :: cp2k_version, cp2k_year, cp2k_home, cp2k_flags
37 : PUBLIC :: compile_arch, compile_date, compile_host, compile_revision
38 : PUBLIC :: print_cp2k_license, get_runtime_info, write_restart_header
39 :
40 : #if defined(__COMPILE_REVISION)
41 : CHARACTER(LEN=*), PARAMETER :: compile_revision = __COMPILE_REVISION
42 : #else
43 : CHARACTER(LEN=*), PARAMETER :: compile_revision = "unknown"
44 : #endif
45 :
46 : !!! Keep version in sync with CMakeLists.txt !!!
47 : CHARACTER(LEN=*), PARAMETER :: cp2k_version = "CP2K version 2026.1 (Development Version)"
48 : CHARACTER(LEN=*), PARAMETER :: cp2k_year = "2026"
49 : CHARACTER(LEN=*), PARAMETER :: cp2k_home = "https://docker.axuan.wang/cp2k/"
50 :
51 : ! compile time information
52 : #if defined(__COMPILE_ARCH)
53 : CHARACTER(LEN=*), PARAMETER :: compile_arch = __COMPILE_ARCH
54 : #else
55 : CHARACTER(LEN=*), PARAMETER :: compile_arch = "unknown: -D__COMPILE_ARCH=?"
56 : #endif
57 :
58 : #if defined(__COMPILE_DATE)
59 : CHARACTER(LEN=*), PARAMETER :: compile_date = __COMPILE_DATE
60 : #else
61 : CHARACTER(LEN=*), PARAMETER :: compile_date = "unknown: -D__COMPILE_DATE=?"
62 : #endif
63 :
64 : #if defined(__COMPILE_HOST)
65 : CHARACTER(LEN=*), PARAMETER :: compile_host = __COMPILE_HOST
66 : #else
67 : CHARACTER(LEN=*), PARAMETER :: compile_host = "unknown: -D__COMPILE_HOST=?"
68 : #endif
69 :
70 : ! Local runtime informations
71 : CHARACTER(LEN=default_path_length), PUBLIC :: r_cwd
72 : CHARACTER(LEN=default_string_length), PUBLIC :: r_host_name, r_user_name
73 : CHARACTER(LEN=timestamp_length), PUBLIC :: r_timestamp
74 : INTEGER, PUBLIC :: r_pid
75 :
76 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp2k_info'
77 : CONTAINS
78 :
79 : ! **************************************************************************************************
80 : !> \brief list all compile time options that influence the capabilities of cp2k.
81 : !> All new flags should be added here (and be unique grep-able)
82 : !> \return ...
83 : ! **************************************************************************************************
84 5577 : FUNCTION cp2k_flags() RESULT(flags)
85 : CHARACTER(len=10*default_string_length) :: flags
86 :
87 : CHARACTER(len=default_string_length) :: tmp_str
88 :
89 5577 : flags = "cp2kflags:"
90 :
91 : ! Ensure that tmp_str is used to silence compiler warnings
92 5577 : tmp_str = ""
93 5577 : flags = TRIM(flags)//TRIM(tmp_str)
94 :
95 : IF (INDEX(COMPILER_OPTIONS(), "-fsanitize=leak") > 0) THEN
96 : flags = TRIM(flags)//" lsan"
97 : END IF
98 :
99 5577 : !$ flags = TRIM(flags)//" omp"
100 :
101 : ! TODO: remove __INTEL_LLVM_COMPILER conditions (regtests)
102 : #if defined(__INTEL_LLVM_COMPILER)
103 : flags = TRIM(flags)//" ifx"
104 : #endif
105 : #if defined(__LIBINT)
106 5577 : flags = TRIM(flags)//" libint"
107 : #endif
108 : #if defined(__FFTW3)
109 5577 : flags = TRIM(flags)//" fftw3"
110 : #endif
111 : #if defined(__LIBXC)
112 5577 : flags = TRIM(flags)//" libxc"
113 : #endif
114 : #if defined(__GAUXC)
115 5577 : flags = TRIM(flags)//" gauxc"
116 : #endif
117 : #if defined(GAUXC_HAS_MPI)
118 5577 : flags = TRIM(flags)//" gauxc_mpi"
119 : #endif
120 : #if defined(GAUXC_HAS_ONEDFT)
121 5577 : flags = TRIM(flags)//" gauxc_onedft"
122 : #endif
123 : #if defined(GAUXC_HAS_HOST)
124 5577 : flags = TRIM(flags)//" gauxc_host"
125 : #endif
126 : #if defined(GAUXC_HAS_DEVICE)
127 : flags = TRIM(flags)//" gauxc_device"
128 : #endif
129 : #if defined(GAUXC_HAS_CUDA)
130 : flags = TRIM(flags)//" gauxc_cuda"
131 : #endif
132 : #if defined(GAUXC_HAS_HDF5)
133 : flags = TRIM(flags)//" gauxc_hdf5"
134 : #endif
135 : #if defined(__PEXSI)
136 : flags = TRIM(flags)//" pexsi"
137 : #endif
138 : #if defined(__ELPA)
139 5577 : flags = TRIM(flags)//" elpa"
140 : #endif
141 : #if defined(__parallel)
142 : #if defined(__SCALAPACK_NO_WA)
143 : flags = TRIM(flags)//" parallel scalapack"
144 : #else
145 5577 : flags = TRIM(flags)//" parallel scalapack"
146 : #endif
147 : #endif
148 : #if defined(__MPI_F08)
149 5577 : flags = TRIM(flags)//" mpi_f08"
150 : #endif
151 : #if defined(__COSMA)
152 5577 : flags = TRIM(flags)//" cosma"
153 : #endif
154 : #if defined(__ACE)
155 5577 : flags = TRIM(flags)//" ace"
156 : #endif
157 : #if defined(__DEEPMD)
158 5577 : flags = TRIM(flags)//" deepmd"
159 : #endif
160 : #if defined(__PW_FPGA)
161 : flags = TRIM(flags)//" pw_fpga"
162 : #endif
163 : #if defined(__PW_FPGA_SP)
164 : flags = TRIM(flags)//" pw_fpga_sp"
165 : #endif
166 : #if defined(__LIBXS)
167 5577 : flags = TRIM(flags)//" libxs"
168 : #endif
169 : #if defined(__LIBXSMM)
170 5577 : flags = TRIM(flags)//" libxsmm"
171 : #endif
172 : #if defined(__LIBXSTREAM)
173 : flags = TRIM(flags)//" libxstream"
174 : #endif
175 : #if defined(__CRAY_PM_ACCEL_ENERGY)
176 : flags = TRIM(flags)//" cray_pm_accel_energy"
177 : #endif
178 : #if defined(__CRAY_PM_ENERGY)
179 : flags = TRIM(flags)//" cray_pm_energy"
180 : #endif
181 : #if defined(__CRAY_PM_FAKE_ENERGY)
182 : flags = TRIM(flags)//" cray_pm_fake_energy"
183 : #endif
184 : #if defined(__DBCSR_ACC)
185 : flags = TRIM(flags)//" dbcsr_acc"
186 : #endif
187 : #if defined(__MAX_CONTR)
188 : CALL integer_to_string(__MAX_CONTR, tmp_str)
189 : flags = TRIM(flags)//" max_contr="//TRIM(tmp_str)
190 : #endif
191 : #if defined(__NO_SOCKETS)
192 : flags = TRIM(flags)//" no_sockets"
193 : #endif
194 : #if defined(__NO_STATM_ACCESS)
195 : flags = TRIM(flags)//" no_statm_access"
196 : #endif
197 : #if defined(__PW_CUDA_NO_HOSTALLOC)
198 : flags = TRIM(flags)//" pw_cuda_no_hostalloc"
199 : #endif
200 : #if defined(__STATM_RESIDENT)
201 : flags = TRIM(flags)//" statm_resident"
202 : #endif
203 : #if defined(__STATM_TOTAL)
204 : flags = TRIM(flags)//" statm_total"
205 : #endif
206 : #if defined(__PLUMED2)
207 5577 : flags = TRIM(flags)//" plumed2"
208 : #endif
209 : #if defined(__HAS_IEEE_EXCEPTIONS)
210 : flags = TRIM(flags)//" has_ieee_exceptions"
211 : #endif
212 : #if defined(__NO_ABORT)
213 5577 : flags = TRIM(flags)//" no_abort"
214 : #endif
215 : #if defined(__SPGLIB)
216 5577 : flags = TRIM(flags)//" spglib"
217 : #endif
218 : #if defined(__ACCELERATE)
219 : flags = TRIM(flags)//" accelerate"
220 : #endif
221 : #if defined(__MKL)
222 : flags = TRIM(flags)//" mkl"
223 : #endif
224 : #if defined(__DFTD4)
225 5577 : flags = TRIM(flags)//" libdftd4"
226 : #endif
227 : #if defined(__DFTD4_V3)
228 : flags = TRIM(flags)//" dftd4_v3"
229 : #endif
230 : #if defined(__DFTD4_V4_2)
231 5577 : flags = TRIM(flags)//" dftd4_v4_2"
232 : #endif
233 : #if defined(__S_DFTD3)
234 5577 : flags = TRIM(flags)//" s_dftd3"
235 : #endif
236 : #if defined(__TBLITE)
237 5577 : flags = TRIM(flags)//" mctc-lib"
238 5577 : flags = TRIM(flags)//" tblite"
239 : #endif
240 : #if defined(__TBLITE_DEBUG_DIAGNOSTICS)
241 : flags = TRIM(flags)//" tblite_debug_diagnostics"
242 : #endif
243 : #if defined(__SIRIUS)
244 5577 : flags = TRIM(flags)//" sirius"
245 : #endif
246 : #if defined(__SIRIUS_NLCG)
247 : flags = TRIM(flags)//" sirius_nlcg"
248 : #endif
249 : #if defined(__SIRIUS_DFTD3)
250 : flags = TRIM(flags)//" sirius_dftd3"
251 : #endif
252 : #if defined(__SIRIUS_DFTD4)
253 : flags = TRIM(flags)//" sirius_dftd4"
254 : #endif
255 : #if defined(__SIRIUS_VCSQNM)
256 : flags = TRIM(flags)//" sirius_vcsqnm"
257 : #endif
258 : #if defined(__CHECK_DIAG)
259 : flags = TRIM(flags)//" check_diag"
260 : #endif
261 : #if defined(__LIBVORI)
262 5577 : flags = TRIM(flags)//" libvori"
263 5577 : flags = TRIM(flags)//" libbqb"
264 : #endif
265 : #if defined(__LIBMAXWELL)
266 : flags = TRIM(flags)//" libmaxwell"
267 : #endif
268 : #if defined(__LIBTORCH)
269 5577 : flags = TRIM(flags)//" libtorch"
270 : #endif
271 : #if defined(__MIMIC)
272 5577 : flags = TRIM(flags)//" mimic"
273 : #endif
274 : #if defined(__OFFLOAD_CUDA)
275 : flags = TRIM(flags)//" offload_cuda"
276 : #endif
277 : #if defined(__OFFLOAD_HIP)
278 : flags = TRIM(flags)//" offload_hip"
279 : #endif
280 : #if defined(__OFFLOAD_OPENCL)
281 : flags = TRIM(flags)//" offload_opencl"
282 : #endif
283 : #if defined(__NO_OFFLOAD_ELPA)
284 : flags = TRIM(flags)//" no_offload_elpa"
285 : #endif
286 : #if defined(__NO_OFFLOAD_GRID)
287 : flags = TRIM(flags)//" no_offload_grid"
288 : #endif
289 : #if defined(__NO_OFFLOAD_DBM)
290 : flags = TRIM(flags)//" no_offload_dbm"
291 : #endif
292 : #if defined(__NO_OFFLOAD_PW)
293 : flags = TRIM(flags)//" no_offload_pw"
294 : #endif
295 : #if defined(__OFFLOAD_PROFILING)
296 : flags = TRIM(flags)//" offload_profiling"
297 : #endif
298 : #if defined(__SPLA) && defined(__OFFLOAD_GEMM)
299 : flags = TRIM(flags)//" spla_gemm_offloading"
300 : #endif
301 : #if defined(__CUSOLVERMP)
302 : flags = TRIM(flags)//" cusolvermp"
303 : #endif
304 : #if defined(__CUSOLVERMP_NCCL)
305 : flags = TRIM(flags)//" cusolvermp_nccl"
306 : #endif
307 : #if defined(__DLAF)
308 : flags = TRIM(flags)//" dlaf"
309 : #endif
310 : #if defined(__LIBVDWXC)
311 5577 : flags = TRIM(flags)//" libvdwxc"
312 : #endif
313 : #if defined(__HDF5)
314 5577 : flags = TRIM(flags)//" hdf5"
315 : #endif
316 : #if defined(__TREXIO)
317 5577 : flags = TRIM(flags)//" trexio"
318 : #endif
319 : #if defined(__LIBFCI)
320 5577 : flags = TRIM(flags)//" libfci"
321 : #endif
322 : #if defined(__OFFLOAD_UNIFIED_MEMORY)
323 : flags = TRIM(flags)//" offload_unified_memory"
324 : #endif
325 : #if defined(__SMEAGOL)
326 5577 : flags = TRIM(flags)//" libsmeagol"
327 : #endif
328 : #if defined(__GREENX)
329 5577 : flags = TRIM(flags)//" greenx"
330 : #endif
331 :
332 : #if defined(__OPENPMD)
333 : flags = TRIM(flags)//" openpmd"
334 : #endif
335 :
336 5577 : END FUNCTION cp2k_flags
337 :
338 : ! **************************************************************************************************
339 : !> \brief ...
340 : !> \param iunit ...
341 : ! **************************************************************************************************
342 0 : SUBROUTINE print_cp2k_license(iunit)
343 :
344 : INTEGER :: iunit
345 :
346 : WRITE (UNIT=iunit, FMT="(T2,A)") &
347 0 : "******************************************************************************", &
348 0 : "* *", &
349 0 : "* CP2K: A general program to perform molecular dynamics simulations *", &
350 0 : "* Copyright (C) 2000-2026 CP2K developer group <https://docker.axuan.wang/cp2k/> *", &
351 0 : "* *", &
352 0 : "* This program is free software: you can redistribute it and/or modify *", &
353 0 : "* it under the terms of the GNU General Public License as published by *", &
354 0 : "* the Free Software Foundation, either version 2 of the License, or *", &
355 0 : "* (at your option) any later version. *", &
356 0 : "* *", &
357 0 : "* This program is distributed in the hope that it will be useful, *", &
358 0 : "* but WITHOUT ANY WARRANTY; without even the implied warranty of *", &
359 0 : "* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *", &
360 0 : "* GNU General Public License for more details. *", &
361 0 : "* *", &
362 0 : "* You should have received a copy of the GNU General Public License *", &
363 0 : "* along with this program. If not, see <https://www.gnu.org/licenses/>. *", &
364 0 : "* *", &
365 0 : "******************************************************************************"
366 :
367 0 : END SUBROUTINE print_cp2k_license
368 :
369 : ! **************************************************************************************************
370 : !> \brief ...
371 : ! **************************************************************************************************
372 15950 : SUBROUTINE get_runtime_info()
373 :
374 15950 : r_cwd = ""
375 15950 : r_host_name = ""
376 15950 : r_timestamp = ""
377 15950 : r_user_name = ""
378 : r_pid = -1
379 :
380 15950 : CALL m_getpid(r_pid)
381 15950 : CALL m_getlog(r_user_name)
382 15950 : CALL m_hostnm(r_host_name)
383 15950 : CALL m_timestamp(r_timestamp)
384 15950 : CALL m_getcwd(r_cwd)
385 :
386 15950 : END SUBROUTINE get_runtime_info
387 :
388 : ! **************************************************************************************************
389 : !> \brief Writes the header for the restart file
390 : !> \param iunit ...
391 : !> \par History
392 : !> 01.2008 [created] - Split from write_restart
393 : !> \author Teodoro Laino - University of Zurich - 01.2008
394 : ! **************************************************************************************************
395 8135 : SUBROUTINE write_restart_header(iunit)
396 : INTEGER, INTENT(IN) :: iunit
397 :
398 : CHARACTER(LEN=256) :: cwd
399 : CHARACTER(LEN=timestamp_length) :: timestamp
400 :
401 8135 : CALL m_timestamp(timestamp)
402 8135 : CALL m_getcwd(cwd)
403 :
404 8135 : WRITE (UNIT=iunit, FMT="(T2,A)") "# Version information for this restart file "
405 8135 : WRITE (UNIT=iunit, FMT="(T2,A)") "# current date "//timestamp
406 8135 : WRITE (UNIT=iunit, FMT="(T2,A)") "# current working dir "//TRIM(cwd)
407 :
408 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
409 8135 : "# Program compiled at", &
410 16270 : ADJUSTR(compile_date(1:MIN(50, LEN(compile_date))))
411 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
412 8135 : "# Program compiled on", &
413 16270 : ADJUSTR(compile_host(1:MIN(50, LEN(compile_host))))
414 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
415 8135 : "# Program compiled for", &
416 16270 : ADJUSTR(compile_arch(1:MIN(50, LEN(compile_arch))))
417 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
418 8135 : "# Source code revision number", &
419 16270 : ADJUSTR(compile_revision)
420 :
421 8135 : END SUBROUTINE write_restart_header
422 :
423 : END MODULE cp2k_info
|