LCOV - code coverage report
Current view: top level - src - cp2k_info.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:06f838d) Lines: 75.3 % 85 64
Test Date: 2026-06-05 07:04:50 Functions: 75.0 % 4 3

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

Generated by: LCOV version 2.0-1