LCOV - code coverage report
Current view: top level - src - cp2k_info.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:42dac4a) Lines: 73.4 % 79 58
Test Date: 2025-07-25 12:55:17 Functions: 75.0 % 4 3

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

Generated by: LCOV version 2.0-1