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