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