LCOV - code coverage report
Current view: top level - src/base - kinds.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 23 23 100.0 %
Date: 2024-11-21 06:45:46 Functions: 1 1 100.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 Defines the basic variable types
      10             : !> \note
      11             : !>      Data type definitions; tested on:
      12             : !>          - IBM AIX xlf90
      13             : !>          - SGI IRIX  f90
      14             : !>          - CRAY T3E  f90
      15             : !>          - DEC ALPHA f90
      16             : !>          - NAG_F90
      17             : !>          - SUN
      18             : !>          - HITACHI
      19             : !> \par History
      20             : !>      Adapted for CP2K by JGH
      21             : !> \author Matthias Krack
      22             : ! **************************************************************************************************
      23             : MODULE kinds
      24             : 
      25             :    IMPLICIT NONE
      26             : 
      27             :    PRIVATE
      28             :    PUBLIC :: sp, dp, print_kind_info, dp_size, sp_size, int_size
      29             :    PUBLIC :: int_1, int_4, int_8, int_1_size, int_2_size, int_4_size, int_8_size
      30             :    PUBLIC :: real_4, real_8, real_4_size, real_8_size
      31             :    PUBLIC :: default_string_length, default_path_length, max_line_length
      32             : 
      33             :    INTEGER, PARAMETER :: sp = SELECTED_REAL_KIND(6, 30)
      34             :    INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(14, 200)
      35             :    ! we rely on this (libraries) but do not check this
      36             :    INTEGER, PARAMETER :: dp_size = 8, &
      37             :                          int_size = BIT_SIZE(0)/8, &
      38             :                          sp_size = 4
      39             : 
      40             :    INTEGER, PARAMETER :: real_4 = SELECTED_REAL_KIND(6, 30)
      41             :    INTEGER, PARAMETER :: real_8 = SELECTED_REAL_KIND(14, 200)
      42             :    INTEGER, PARAMETER :: real_4_size = 4
      43             :    INTEGER, PARAMETER :: real_8_size = 8
      44             : 
      45             :    INTEGER, PARAMETER :: int_1 = SELECTED_INT_KIND(2)
      46             :    INTEGER, PARAMETER :: int_1_size = BIT_SIZE(INT(0, int_1))/8
      47             : 
      48             :    INTEGER, PARAMETER :: int_2 = SELECTED_INT_KIND(4)
      49             :    INTEGER, PARAMETER :: int_2_size = BIT_SIZE(INT(0, int_2))/8
      50             : 
      51             :    INTEGER, PARAMETER :: int_4 = SELECTED_INT_KIND(5)
      52             :    INTEGER, PARAMETER :: int_4_size = BIT_SIZE(INT(0, int_4))/8
      53             : 
      54             :    INTEGER, PARAMETER :: int_8 = SELECTED_INT_KIND(10)
      55             :    INTEGER, PARAMETER :: int_8_size = BIT_SIZE(INT(0, int_8))/8
      56             : 
      57             :    INTEGER, PARAMETER :: default_string_length = 80
      58             :    INTEGER, PARAMETER :: default_path_length = 1024
      59             :    INTEGER, PARAMETER :: max_line_length = 2*default_path_length
      60             :    CHARACTER(LEN=1), PARAMETER, PUBLIC :: default_blank_character(2) = (/" ", CHAR(9)/)
      61             : 
      62             : CONTAINS
      63             : 
      64             : ! **************************************************************************************************
      65             : !> \brief Print informations about the used data types.
      66             : !> \param iw ...
      67             : !> \par History
      68             : !>      Adapted by JGH for Cp2k
      69             : !> \author Matthias Krack
      70             : ! **************************************************************************************************
      71           1 :    SUBROUTINE print_kind_info(iw)
      72             : 
      73             :       INTEGER, INTENT(IN)                                :: iw
      74             : 
      75           1 :       WRITE (iw, '( /, T2, A )') 'DATA TYPE INFORMATION:'
      76             : 
      77             :       WRITE (iw, '( /,T2,A,T79,A,2(/,T2,A,T75,I6),3(/,T2,A,T67,E14.8) )') &
      78           1 :          'REAL: Data type name:', 'dp', '      Kind value:', KIND(0.0_dp), &
      79           1 :          '      Precision:', PRECISION(0.0_dp), &
      80           1 :          '      Smallest non-negligible quantity relative to 1:', &
      81           1 :          EPSILON(0.0_dp), &
      82           1 :          '      Smallest positive number:', TINY(0.0_dp), &
      83           2 :          '      Largest representable number:', HUGE(0.0_dp)
      84             :       WRITE (iw, '( /,T2,A,T79,A,2(/,T2,A,T75,I6),3(/,T2,A,T67,E14.8) )') &
      85           1 :          '      Data type name:', 'sp', '      Kind value:', KIND(0.0_sp), &
      86           1 :          '      Precision:', PRECISION(0.0_sp), &
      87           1 :          '      Smallest non-negligible quantity relative to 1:', &
      88           1 :          EPSILON(0.0_sp), &
      89           1 :          '      Smallest positive number:', TINY(0.0_sp), &
      90           2 :          '      Largest representable number:', HUGE(0.0_sp)
      91             :       WRITE (iw, '( /,T2,A,T72,A,4(/,T2,A,T61,I20) )') &
      92           1 :          'INTEGER: Data type name:', '(default)', '         Kind value:', &
      93           1 :          KIND(0), &
      94           1 :          '         Bit size:', BIT_SIZE(0), &
      95           2 :          '         Largest representable number:', HUGE(0)
      96             :       WRITE (iw, '( /,T2,A,T72,A,/,T2,A,T75,I6,/ )') &
      97           1 :          'LOGICAL: Data type name:', '(default)', &
      98           2 :          '         Kind value:', KIND(.TRUE.)
      99             :       WRITE (iw, '( /,T2,A,T72,A,/,T2,A,T75,I6,/ )') &
     100           1 :          'CHARACTER: Data type name:', '(default)', &
     101           2 :          '           Kind value:', KIND('C')
     102             : 
     103           1 :    END SUBROUTINE print_kind_info
     104             : 
     105             : END MODULE kinds

Generated by: LCOV version 1.15