LCOV - code coverage report
Current view: top level - src/subsys - atprop_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:20fe009) Lines: 58 59 98.3 %
Date: 2022-07-05 19:56:53 Functions: 6 7 85.7 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2022 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief Holds information on atomic properties
      10             : !> \par History
      11             : !>      07.2011 created
      12             : !> \author JHU
      13             : ! **************************************************************************************************
      14             : MODULE atprop_types
      15             : 
      16             :    USE kinds,                           ONLY: dp
      17             : #include "../base/base_uses.f90"
      18             : 
      19             :    IMPLICIT NONE
      20             :    PRIVATE
      21             : 
      22             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'atprop_types'
      23             : 
      24             :    PUBLIC :: atprop_type, atprop_create, atprop_release, atprop_init
      25             :    PUBLIC :: atprop_array_init, atprop_array_add
      26             : 
      27             : ! **************************************************************************************************
      28             : !> \brief type for the atomic properties
      29             : !> \author fawzi
      30             : ! **************************************************************************************************
      31             :    TYPE atprop_type
      32             :       LOGICAL                                   :: energy
      33             :       LOGICAL                                   :: stress
      34             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atener
      35             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ateb
      36             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atexc
      37             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ateself
      38             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atevdw
      39             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ategcp
      40             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atecc
      41             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ate1c
      42             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atecoul
      43             :       REAL(KIND=dp), DIMENSION(:, :, :), POINTER  :: atstress
      44             :    END TYPE atprop_type
      45             : 
      46             : CONTAINS
      47             : 
      48             : ! **************************************************************************************************
      49             : !> \brief ...
      50             : !> \param atprop_env ...
      51             : ! **************************************************************************************************
      52        8583 :    SUBROUTINE atprop_create(atprop_env)
      53             :       TYPE(atprop_type), POINTER                         :: atprop_env
      54             : 
      55        8583 :       CALL atprop_release(atprop_env)
      56        8583 :       ALLOCATE (atprop_env)
      57        8583 :       NULLIFY (atprop_env%atener, atprop_env%atstress)
      58        8583 :       NULLIFY (atprop_env%ateb, atprop_env%atevdw, atprop_env%ategcp, atprop_env%atecc, atprop_env%atecoul)
      59        8583 :       NULLIFY (atprop_env%ateself, atprop_env%atexc, atprop_env%ate1c)
      60        8583 :       atprop_env%energy = .FALSE.
      61        8583 :       atprop_env%stress = .FALSE.
      62             : 
      63        8583 :    END SUBROUTINE atprop_create
      64             : 
      65             : ! **************************************************************************************************
      66             : !> \brief ...
      67             : !> \param atprop_env ...
      68             : !> \param natom ...
      69             : ! **************************************************************************************************
      70       96827 :    SUBROUTINE atprop_init(atprop_env, natom)
      71             :       TYPE(atprop_type), POINTER                         :: atprop_env
      72             :       INTEGER, INTENT(IN)                                :: natom
      73             : 
      74       96827 :       CPASSERT(ASSOCIATED(atprop_env))
      75             : 
      76       96827 :       IF (atprop_env%energy) THEN
      77         944 :          CALL atprop_array_init(atprop_env%atener, natom)
      78         944 :          CALL atprop_array_release(atprop_env%ateb)
      79         944 :          CALL atprop_array_release(atprop_env%atevdw)
      80         944 :          CALL atprop_array_release(atprop_env%ategcp)
      81         944 :          CALL atprop_array_release(atprop_env%atecc)
      82         944 :          CALL atprop_array_release(atprop_env%atecoul)
      83         944 :          CALL atprop_array_release(atprop_env%ateself)
      84         944 :          CALL atprop_array_release(atprop_env%atexc)
      85         944 :          CALL atprop_array_release(atprop_env%ate1c)
      86             :       END IF
      87             : 
      88       96827 :       IF (atprop_env%stress) THEN
      89         868 :          IF (ASSOCIATED(atprop_env%atstress)) THEN
      90         846 :             CPASSERT(SIZE(atprop_env%atstress, 3) == natom)
      91             :          ELSE
      92          66 :             ALLOCATE (atprop_env%atstress(3, 3, natom))
      93             :          END IF
      94      373630 :          atprop_env%atstress = 0._dp
      95             :       END IF
      96             : 
      97       96827 :    END SUBROUTINE atprop_init
      98             : 
      99             : ! **************************************************************************************************
     100             : !> \brief ...
     101             : !> \param atarray ...
     102             : !> \param natom ...
     103             : ! **************************************************************************************************
     104        7839 :    SUBROUTINE atprop_array_init(atarray, natom)
     105             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: atarray
     106             :       INTEGER, INTENT(IN)                                :: natom
     107             : 
     108        7839 :       IF (ASSOCIATED(atarray)) THEN
     109        5854 :          CPASSERT(SIZE(atarray) == natom)
     110             :       ELSE
     111        5955 :          ALLOCATE (atarray(natom))
     112             :       END IF
     113      126226 :       atarray = 0._dp
     114             : 
     115        7839 :    END SUBROUTINE atprop_array_init
     116             : 
     117             : ! **************************************************************************************************
     118             : !> \brief ...
     119             : !> \param atarray ...
     120             : ! **************************************************************************************************
     121       84799 :    SUBROUTINE atprop_array_release(atarray)
     122             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: atarray
     123             : 
     124       84799 :       IF (ASSOCIATED(atarray)) THEN
     125        1985 :          DEALLOCATE (atarray)
     126             :       END IF
     127             : 
     128       84799 :    END SUBROUTINE atprop_array_release
     129             : 
     130             : ! **************************************************************************************************
     131             : !> \brief ...
     132             : !> \param array_a ...
     133             : !> \param array_b ...
     134             : ! **************************************************************************************************
     135         848 :    SUBROUTINE atprop_array_add(array_a, array_b)
     136             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: array_a, array_b
     137             : 
     138         848 :       IF (ASSOCIATED(array_b)) THEN
     139         276 :          CPASSERT(ASSOCIATED(array_a))
     140       37068 :          array_a = array_a + array_b
     141             :       END IF
     142             : 
     143         848 :    END SUBROUTINE atprop_array_add
     144             : 
     145             : ! **************************************************************************************************
     146             : !> \brief releases the atprop
     147             : !> \param atprop_env the object to release
     148             : !> \author fawzi
     149             : ! **************************************************************************************************
     150       17166 :    SUBROUTINE atprop_release(atprop_env)
     151             :       TYPE(atprop_type), POINTER                         :: atprop_env
     152             : 
     153       17166 :       IF (ASSOCIATED(atprop_env)) THEN
     154             :          ! energy
     155        8583 :          CALL atprop_array_release(atprop_env%atener)
     156        8583 :          CALL atprop_array_release(atprop_env%ateb)
     157        8583 :          CALL atprop_array_release(atprop_env%ateself)
     158        8583 :          CALL atprop_array_release(atprop_env%atexc)
     159        8583 :          CALL atprop_array_release(atprop_env%atevdw)
     160        8583 :          CALL atprop_array_release(atprop_env%ategcp)
     161        8583 :          CALL atprop_array_release(atprop_env%atecc)
     162        8583 :          CALL atprop_array_release(atprop_env%ate1c)
     163        8583 :          CALL atprop_array_release(atprop_env%atecoul)
     164             :          ! stress
     165        8583 :          IF (ASSOCIATED(atprop_env%atstress)) THEN
     166          22 :             DEALLOCATE (atprop_env%atstress)
     167             :          END IF
     168             :          ! atprop type
     169        8583 :          DEALLOCATE (atprop_env)
     170             :       END IF
     171       17166 :       NULLIFY (atprop_env)
     172       17166 :    END SUBROUTINE atprop_release
     173             : 
     174           0 : END MODULE atprop_types

Generated by: LCOV version 1.15