LCOV - code coverage report
Current view: top level - src - cp2k_info.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 53 74 71.6 %
Date: 2024-11-21 06:45:46 Functions: 3 4 75.0 %

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

Generated by: LCOV version 1.15