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.3 (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 4990 : FUNCTION cp2k_flags() RESULT(flags)
79 : CHARACTER(len=10*default_string_length) :: flags
80 :
81 : CHARACTER(len=default_string_length) :: tmp_str
82 :
83 4990 : flags = "cp2kflags:"
84 :
85 : ! Ensure that tmp_str is used to silence compiler warnings
86 4990 : tmp_str = ""
87 4990 : flags = TRIM(flags)//TRIM(tmp_str)
88 :
89 4990 : !$ flags = TRIM(flags)//" omp"
90 : #if defined(__LIBINT)
91 4990 : flags = TRIM(flags)//" libint"
92 : #endif
93 : #if defined(__FFTW3)
94 4990 : flags = TRIM(flags)//" fftw3"
95 : #endif
96 : #if defined(__FFTW3_MKL)
97 : flags = TRIM(flags)//" fftw3_mkl"
98 : #endif
99 : #if defined(__LIBXC)
100 4990 : flags = TRIM(flags)//" libxc"
101 : #endif
102 : #if defined(__LIBGRPP)
103 4990 : flags = TRIM(flags)//" libgrpp"
104 : #endif
105 : #if defined(__LIBPEXSI)
106 4990 : flags = TRIM(flags)//" pexsi"
107 : #endif
108 : #if defined(__ELPA)
109 4990 : 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 4990 : 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 4990 : flags = TRIM(flags)//" cosma"
128 : #endif
129 :
130 : #if defined(__QUIP)
131 4990 : 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 4990 : 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 4990 : 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 4990 : 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 4990 : flags = TRIM(flags)//" no_abort"
199 : #endif
200 : #if defined(__SPGLIB)
201 4990 : 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 4990 : flags = TRIM(flags)//" libdftd4"
211 : #endif
212 : #if defined(__SIRIUS)
213 4990 : flags = TRIM(flags)//" sirius"
214 : #endif
215 : #if defined(__CHECK_DIAG)
216 : flags = TRIM(flags)//" check_diag"
217 : #endif
218 : #if defined(__LIBVORI)
219 4990 : flags = TRIM(flags)//" libvori"
220 4990 : flags = TRIM(flags)//" libbqb"
221 : #endif
222 : #if defined(__LIBMAXWELL)
223 : flags = TRIM(flags)//" libmaxwell"
224 : #endif
225 : #if defined(__LIBTORCH)
226 4990 : 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 4990 : flags = TRIM(flags)//" libvdwxc"
264 : #endif
265 :
266 : #if defined(__HDF5)
267 4990 : flags = TRIM(flags)//" hdf5"
268 : #endif
269 :
270 : #if defined(__TREXIO)
271 4990 : flags = TRIM(flags)//" trexio"
272 : #endif
273 :
274 : #if defined(__OFFLOAD_UNIFIED_MEMORY)
275 : flags = TRIM(flags)//" offload_unified_memory"
276 : #endif
277 :
278 : #if defined(__SMEAGOL)
279 : flags = TRIM(flags)//" libsmeagol"
280 : #endif
281 :
282 4990 : END FUNCTION cp2k_flags
283 :
284 : ! **************************************************************************************************
285 : !> \brief ...
286 : !> \param iunit ...
287 : ! **************************************************************************************************
288 0 : SUBROUTINE print_cp2k_license(iunit)
289 :
290 : INTEGER :: iunit
291 :
292 : WRITE (UNIT=iunit, FMT="(T2,A)") &
293 0 : "******************************************************************************", &
294 0 : "* *", &
295 0 : "* CP2K: A general program to perform molecular dynamics simulations *", &
296 0 : "* Copyright (C) 2000-2024 CP2K developer group <https://www.cp2k.org/> *", &
297 0 : "* *", &
298 0 : "* This program is free software: you can redistribute it and/or modify *", &
299 0 : "* it under the terms of the GNU General Public License as published by *", &
300 0 : "* the Free Software Foundation, either version 2 of the License, or *", &
301 0 : "* (at your option) any later version. *", &
302 0 : "* *", &
303 0 : "* This program is distributed in the hope that it will be useful, *", &
304 0 : "* but WITHOUT ANY WARRANTY; without even the implied warranty of *", &
305 0 : "* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *", &
306 0 : "* GNU General Public License for more details. *", &
307 0 : "* *", &
308 0 : "* You should have received a copy of the GNU General Public License *", &
309 0 : "* along with this program. If not, see <https://www.gnu.org/licenses/>. *", &
310 0 : "* *", &
311 0 : "******************************************************************************"
312 :
313 0 : END SUBROUTINE print_cp2k_license
314 :
315 : ! **************************************************************************************************
316 : !> \brief ...
317 : ! **************************************************************************************************
318 14197 : SUBROUTINE get_runtime_info()
319 :
320 14197 : r_datx = ""
321 14197 : r_cwd = ""
322 14197 : r_host_name = ""
323 14197 : r_user_name = ""
324 : r_pid = -1
325 :
326 14197 : CALL m_getpid(r_pid)
327 14197 : CALL m_getlog(r_user_name)
328 14197 : CALL m_hostnm(r_host_name)
329 14197 : CALL m_datum(r_datx)
330 14197 : CALL m_getcwd(r_cwd)
331 :
332 14197 : END SUBROUTINE
333 :
334 : ! **************************************************************************************************
335 : !> \brief Writes the header for the restart file
336 : !> \param iunit ...
337 : !> \par History
338 : !> 01.2008 [created] - Split from write_restart
339 : !> \author Teodoro Laino - University of Zurich - 01.2008
340 : ! **************************************************************************************************
341 8337 : SUBROUTINE write_restart_header(iunit)
342 : INTEGER, INTENT(IN) :: iunit
343 :
344 : CHARACTER(LEN=256) :: cwd, datx
345 :
346 8337 : CALL m_datum(datx)
347 8337 : CALL m_getcwd(cwd)
348 :
349 8337 : WRITE (UNIT=iunit, FMT="(T2,A)") "# Version information for this restart file "
350 8337 : WRITE (UNIT=iunit, FMT="(T2,A)") "# current date "//TRIM(datx)
351 8337 : WRITE (UNIT=iunit, FMT="(T2,A)") "# current working dir "//TRIM(cwd)
352 :
353 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
354 8337 : "# Program compiled at", &
355 16674 : ADJUSTR(compile_date(1:MIN(50, LEN(compile_date))))
356 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
357 8337 : "# Program compiled on", &
358 16674 : ADJUSTR(compile_host(1:MIN(50, LEN(compile_host))))
359 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
360 8337 : "# Program compiled for", &
361 16674 : ADJUSTR(compile_arch(1:MIN(50, LEN(compile_arch))))
362 : WRITE (UNIT=iunit, FMT="(T2,A,T31,A50)") &
363 8337 : "# Source code revision number", &
364 16674 : ADJUSTR(compile_revision)
365 :
366 8337 : END SUBROUTINE write_restart_header
367 :
368 : END MODULE cp2k_info
|