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