(git:d88cc65)
Loading...
Searching...
No Matches
cp2k_info.F
Go to the documentation of this file.
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! **************************************************************************************************
17
18 USE iso_fortran_env, ONLY: compiler_options
19 USE kinds, ONLY: default_path_length,&
21 USE machine, ONLY: m_getcwd,&
22 m_getlog,&
23 m_getpid,&
24 m_hostnm,&
28
29 IMPLICIT NONE
30 PRIVATE
31
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'
73CONTAINS
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 FUNCTION cp2k_flags() RESULT(flags)
81 CHARACTER(len=10*default_string_length) :: flags
82
83 CHARACTER(len=default_string_length) :: tmp_str
84
85 flags = "cp2kflags:"
86
87 ! Ensure that tmp_str is used to silence compiler warnings
88 tmp_str = ""
89 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!$ 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 flags = trim(flags)//" libint"
103#endif
104#if defined(__FFTW3)
105 flags = trim(flags)//" fftw3"
106#endif
107#if defined(__LIBXC)
108 flags = trim(flags)//" libxc"
109#endif
110#if defined(__PEXSI)
111 flags = trim(flags)//" pexsi"
112#endif
113#if defined(__ELPA)
114 flags = trim(flags)//" elpa"
115#endif
116#if defined(__parallel)
117#if defined(__SCALAPACK_NO_WA)
118 flags = trim(flags)//" parallel scalapack"
119#else
120 flags = trim(flags)//" parallel scalapack"
121#endif
122#endif
123#if defined(__MPI_F08)
124 flags = trim(flags)//" mpi_f08"
125#endif
126#if defined(__COSMA)
127 flags = trim(flags)//" cosma"
128#endif
129#if defined(__ACE)
130 flags = trim(flags)//" ace"
131#endif
132#if defined(__DEEPMD)
133 flags = trim(flags)//" deepmd"
134#endif
135#if defined(__PW_FPGA)
136 flags = trim(flags)//" pw_fpga"
137#endif
138#if defined(__PW_FPGA_SP)
139 flags = trim(flags)//" pw_fpga_sp"
140#endif
141#if defined(__LIBXSMM)
142 flags = trim(flags)//" xsmm"
143#endif
144#if defined(__CRAY_PM_ACCEL_ENERGY)
145 flags = trim(flags)//" cray_pm_accel_energy"
146#endif
147#if defined(__CRAY_PM_ENERGY)
148 flags = trim(flags)//" cray_pm_energy"
149#endif
150#if defined(__CRAY_PM_FAKE_ENERGY)
151 flags = trim(flags)//" cray_pm_fake_energy"
152#endif
153#if defined(__DBCSR_ACC)
154 flags = trim(flags)//" dbcsr_acc"
155#endif
156#if defined(__MAX_CONTR)
157 CALL integer_to_string(__max_contr, tmp_str)
158 flags = trim(flags)//" max_contr="//trim(tmp_str)
159#endif
160#if defined(__NO_SOCKETS)
161 flags = trim(flags)//" no_sockets"
162#endif
163#if defined(__NO_STATM_ACCESS)
164 flags = trim(flags)//" no_statm_access"
165#endif
166#if defined(__PW_CUDA_NO_HOSTALLOC)
167 flags = trim(flags)//" pw_cuda_no_hostalloc"
168#endif
169#if defined(__STATM_RESIDENT)
170 flags = trim(flags)//" statm_resident"
171#endif
172#if defined(__STATM_TOTAL)
173 flags = trim(flags)//" statm_total"
174#endif
175#if defined(__PLUMED2)
176 flags = trim(flags)//" plumed2"
177#endif
178#if defined(__HAS_IEEE_EXCEPTIONS)
179 flags = trim(flags)//" has_ieee_exceptions"
180#endif
181#if defined(__NO_ABORT)
182 flags = trim(flags)//" no_abort"
183#endif
184#if defined(__SPGLIB)
185 flags = trim(flags)//" spglib"
186#endif
187#if defined(__ACCELERATE)
188 flags = trim(flags)//" accelerate"
189#endif
190#if defined(__MKL)
191 flags = trim(flags)//" mkl"
192#endif
193#if defined(__DFTD4)
194 flags = trim(flags)//" libdftd4"
195#endif
196#if defined(__TBLITE)
197 flags = trim(flags)//" mctc-lib"
198 flags = trim(flags)//" tblite"
199#endif
200#if defined(__SIRIUS)
201 flags = trim(flags)//" sirius"
202#endif
203#if defined(__SIRIUS_NLCG)
204 flags = trim(flags)//" sirius_nlcg"
205#endif
206#if defined(__SIRIUS_DFTD4)
207 flags = trim(flags)//" sirius_dftd4"
208#endif
209#if defined(__SIRIUS_VCSQNM)
210 flags = trim(flags)//" sirius_vcsqnm"
211#endif
212#if defined(__CHECK_DIAG)
213 flags = trim(flags)//" check_diag"
214#endif
215#if defined(__LIBVORI)
216 flags = trim(flags)//" libvori"
217 flags = trim(flags)//" libbqb"
218#endif
219#if defined(__LIBMAXWELL)
220 flags = trim(flags)//" libmaxwell"
221#endif
222#if defined(__LIBTORCH)
223 flags = trim(flags)//" libtorch"
224#endif
225#if defined(__OFFLOAD_CUDA)
226 flags = trim(flags)//" offload_cuda"
227#endif
228#if defined(__OFFLOAD_HIP)
229 flags = trim(flags)//" offload_hip"
230#endif
231#if defined(__OFFLOAD_OPENCL)
232 flags = trim(flags)//" offload_opencl"
233#endif
234#if defined(__NO_OFFLOAD_GRID)
235 flags = trim(flags)//" no_offload_grid"
236#endif
237#if defined(__NO_OFFLOAD_DBM)
238 flags = trim(flags)//" no_offload_dbm"
239#endif
240#if defined(__NO_OFFLOAD_PW)
241 flags = trim(flags)//" no_offload_pw"
242#endif
243#if defined(__OFFLOAD_PROFILING)
244 flags = trim(flags)//" offload_profiling"
245#endif
246#if defined(__SPLA) && defined(__OFFLOAD_GEMM)
247 flags = trim(flags)//" spla_gemm_offloading"
248#endif
249#if defined(__CUSOLVERMP)
250 flags = trim(flags)//" cusolvermp"
251#endif
252#if defined(__DLAF)
253 flags = trim(flags)//" dlaf"
254#endif
255#if defined(__LIBVDWXC)
256 flags = trim(flags)//" libvdwxc"
257#endif
258#if defined(__HDF5)
259 flags = trim(flags)//" hdf5"
260#endif
261#if defined(__TREXIO)
262 flags = trim(flags)//" trexio"
263#endif
264#if defined(__OFFLOAD_UNIFIED_MEMORY)
265 flags = trim(flags)//" offload_unified_memory"
266#endif
267#if defined(__SMEAGOL)
268 flags = trim(flags)//" libsmeagol"
269#endif
270#if defined(__GREENX)
271 flags = trim(flags)//" greenx"
272#endif
273
274 END FUNCTION cp2k_flags
275
276! **************************************************************************************************
277!> \brief ...
278!> \param iunit ...
279! **************************************************************************************************
280 SUBROUTINE print_cp2k_license(iunit)
281
282 INTEGER :: iunit
283
284 WRITE (unit=iunit, fmt="(T2,A)") &
285 "******************************************************************************", &
286 "* *", &
287 "* CP2K: A general program to perform molecular dynamics simulations *", &
288 "* Copyright (C) 2000-2025 CP2K developer group <https://www.cp2k.org/> *", &
289 "* *", &
290 "* This program is free software: you can redistribute it and/or modify *", &
291 "* it under the terms of the GNU General Public License as published by *", &
292 "* the Free Software Foundation, either version 2 of the License, or *", &
293 "* (at your option) any later version. *", &
294 "* *", &
295 "* This program is distributed in the hope that it will be useful, *", &
296 "* but WITHOUT ANY WARRANTY; without even the implied warranty of *", &
297 "* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *", &
298 "* GNU General Public License for more details. *", &
299 "* *", &
300 "* You should have received a copy of the GNU General Public License *", &
301 "* along with this program. If not, see <https://www.gnu.org/licenses/>. *", &
302 "* *", &
303 "******************************************************************************"
304
305 END SUBROUTINE print_cp2k_license
306
307! **************************************************************************************************
308!> \brief ...
309! **************************************************************************************************
310 SUBROUTINE get_runtime_info()
311
312 r_cwd = ""
313 r_host_name = ""
314 r_timestamp = ""
315 r_user_name = ""
316 r_pid = -1
317
318 CALL m_getpid(r_pid)
322 CALL m_getcwd(r_cwd)
323
324 END SUBROUTINE get_runtime_info
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 SUBROUTINE write_restart_header(iunit)
334 INTEGER, INTENT(IN) :: iunit
335
336 CHARACTER(LEN=256) :: cwd
337 CHARACTER(LEN=timestamp_length) :: timestamp
338
339 CALL m_timestamp(timestamp)
340 CALL m_getcwd(cwd)
341
342 WRITE (unit=iunit, fmt="(T2,A)") "# Version information for this restart file "
343 WRITE (unit=iunit, fmt="(T2,A)") "# current date "//timestamp
344 WRITE (unit=iunit, fmt="(T2,A)") "# current working dir "//trim(cwd)
345
346 WRITE (unit=iunit, fmt="(T2,A,T31,A50)") &
347 "# Program compiled at", &
348 adjustr(compile_date(1:min(50, len(compile_date))))
349 WRITE (unit=iunit, fmt="(T2,A,T31,A50)") &
350 "# Program compiled on", &
351 adjustr(compile_host(1:min(50, len(compile_host))))
352 WRITE (unit=iunit, fmt="(T2,A,T31,A50)") &
353 "# Program compiled for", &
354 adjustr(compile_arch(1:min(50, len(compile_arch))))
355 WRITE (unit=iunit, fmt="(T2,A,T31,A50)") &
356 "# Source code revision number", &
357 adjustr(compile_revision)
358
359 END SUBROUTINE write_restart_header
360
361END MODULE cp2k_info
some minimal info about CP2K, including its version and license
Definition cp2k_info.F:16
character(len=default_string_length), public r_host_name
Definition cp2k_info.F:68
character(len= *), parameter, public cp2k_home
Definition cp2k_info.F:45
character(len= *), parameter, public compile_host
Definition cp2k_info.F:63
character(len= *), parameter, public compile_arch
Definition cp2k_info.F:51
integer, public r_pid
Definition cp2k_info.F:70
subroutine, public print_cp2k_license(iunit)
...
Definition cp2k_info.F:281
subroutine, public write_restart_header(iunit)
Writes the header for the restart file.
Definition cp2k_info.F:334
character(len= *), parameter, public compile_revision
Definition cp2k_info.F:39
character(len= *), parameter, public compile_date
Definition cp2k_info.F:57
character(len=timestamp_length), public r_timestamp
Definition cp2k_info.F:69
character(len= *), parameter, public cp2k_year
Definition cp2k_info.F:44
character(len=10 *default_string_length) function, public cp2k_flags()
list all compile time options that influence the capabilities of cp2k. All new flags should be added ...
Definition cp2k_info.F:81
character(len= *), parameter, public cp2k_version
Definition cp2k_info.F:43
character(len=default_path_length), public r_cwd
Definition cp2k_info.F:67
subroutine, public get_runtime_info()
...
Definition cp2k_info.F:311
character(len=default_string_length), public r_user_name
Definition cp2k_info.F:68
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
subroutine, public m_getpid(pid)
...
Definition machine.F:667
integer, parameter, public timestamp_length
Definition machine.F:58
subroutine, public m_timestamp(timestamp)
Returns a human readable timestamp.
Definition machine.F:393
subroutine, public m_getcwd(curdir)
...
Definition machine.F:619
subroutine, public m_getlog(user)
...
Definition machine.F:744
subroutine, public m_hostnm(hname)
...
Definition machine.F:592
Utilities for string manipulations.
subroutine, public integer_to_string(inumber, string)
Converts an integer number to a string. The WRITE statement will return an error message,...