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

Generated by: LCOV version 2.0-1