LCOV - code coverage report
Current view: top level - src/subsys - atprop_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 44 45 97.8 %
Date: 2024-11-21 06:45:46 Functions: 6 7 85.7 %

          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 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 = .FALSE.
      33             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atener => NULL()
      34             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ateb => NULL()
      35             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atexc => NULL()
      36             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ateself => NULL()
      37             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atevdw => NULL()
      38             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ategcp => NULL()
      39             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atecc => NULL()
      40             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: ate1c => NULL()
      41             :       REAL(KIND=dp), DIMENSION(:), POINTER      :: atecoul => NULL()
      42             :    END TYPE atprop_type
      43             : 
      44             : CONTAINS
      45             : 
      46             : ! **************************************************************************************************
      47             : !> \brief ...
      48             : !> \param atprop_env ...
      49             : ! **************************************************************************************************
      50        9509 :    SUBROUTINE atprop_create(atprop_env)
      51             :       TYPE(atprop_type), POINTER                         :: atprop_env
      52             : 
      53        9509 :       CALL atprop_release(atprop_env)
      54        9509 :       ALLOCATE (atprop_env)
      55             : 
      56        9509 :    END SUBROUTINE atprop_create
      57             : 
      58             : ! **************************************************************************************************
      59             : !> \brief ...
      60             : !> \param atprop_env ...
      61             : !> \param natom ...
      62             : ! **************************************************************************************************
      63       98906 :    SUBROUTINE atprop_init(atprop_env, natom)
      64             :       TYPE(atprop_type), INTENT(INOUT)                   :: atprop_env
      65             :       INTEGER, INTENT(IN)                                :: natom
      66             : 
      67       98906 :       IF (atprop_env%energy) THEN
      68         978 :          CALL atprop_array_init(atprop_env%atener, natom)
      69         978 :          CALL atprop_array_release(atprop_env%ateb)
      70         978 :          CALL atprop_array_release(atprop_env%atevdw)
      71         978 :          CALL atprop_array_release(atprop_env%ategcp)
      72         978 :          CALL atprop_array_release(atprop_env%atecc)
      73         978 :          CALL atprop_array_release(atprop_env%atecoul)
      74         978 :          CALL atprop_array_release(atprop_env%ateself)
      75         978 :          CALL atprop_array_release(atprop_env%atexc)
      76         978 :          CALL atprop_array_release(atprop_env%ate1c)
      77             :       END IF
      78             : 
      79       98906 :    END SUBROUTINE atprop_init
      80             : 
      81             : ! **************************************************************************************************
      82             : !> \brief ...
      83             : !> \param atarray ...
      84             : !> \param natom ...
      85             : ! **************************************************************************************************
      86        9059 :    SUBROUTINE atprop_array_init(atarray, natom)
      87             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: atarray
      88             :       INTEGER, INTENT(IN)                                :: natom
      89             : 
      90        9059 :       IF (ASSOCIATED(atarray)) THEN
      91        6570 :          CPASSERT(SIZE(atarray) == natom)
      92             :       ELSE
      93        7467 :          ALLOCATE (atarray(natom))
      94             :       END IF
      95      131662 :       atarray = 0._dp
      96             : 
      97        9059 :    END SUBROUTINE atprop_array_init
      98             : 
      99             : ! **************************************************************************************************
     100             : !> \brief ...
     101             : !> \param atarray ...
     102             : ! **************************************************************************************************
     103       93405 :    SUBROUTINE atprop_array_release(atarray)
     104             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: atarray
     105             : 
     106       93405 :       IF (ASSOCIATED(atarray)) THEN
     107        2489 :          DEALLOCATE (atarray)
     108             :       END IF
     109             : 
     110       93405 :    END SUBROUTINE atprop_array_release
     111             : 
     112             : ! **************************************************************************************************
     113             : !> \brief ...
     114             : !> \param array_a ...
     115             : !> \param array_b ...
     116             : ! **************************************************************************************************
     117        1120 :    SUBROUTINE atprop_array_add(array_a, array_b)
     118             :       REAL(KIND=dp), DIMENSION(:), INTENT(INOUT)         :: array_a
     119             :       REAL(KIND=dp), DIMENSION(:), INTENT(IN), POINTER   :: array_b
     120             : 
     121        1120 :       IF (ASSOCIATED(array_b)) THEN
     122       19206 :          array_a = array_a + array_b
     123             :       END IF
     124             : 
     125        1120 :    END SUBROUTINE atprop_array_add
     126             : 
     127             : ! **************************************************************************************************
     128             : !> \brief releases the atprop
     129             : !> \param atprop_env the object to release
     130             : !> \author fawzi
     131             : ! **************************************************************************************************
     132       19018 :    SUBROUTINE atprop_release(atprop_env)
     133             :       TYPE(atprop_type), POINTER                         :: atprop_env
     134             : 
     135       19018 :       IF (ASSOCIATED(atprop_env)) THEN
     136             :          ! energy
     137        9509 :          CALL atprop_array_release(atprop_env%atener)
     138        9509 :          CALL atprop_array_release(atprop_env%ateb)
     139        9509 :          CALL atprop_array_release(atprop_env%ateself)
     140        9509 :          CALL atprop_array_release(atprop_env%atexc)
     141        9509 :          CALL atprop_array_release(atprop_env%atevdw)
     142        9509 :          CALL atprop_array_release(atprop_env%ategcp)
     143        9509 :          CALL atprop_array_release(atprop_env%atecc)
     144        9509 :          CALL atprop_array_release(atprop_env%ate1c)
     145        9509 :          CALL atprop_array_release(atprop_env%atecoul)
     146             :          ! atprop type
     147        9509 :          DEALLOCATE (atprop_env)
     148             :       END IF
     149       19018 :       NULLIFY (atprop_env)
     150       19018 :    END SUBROUTINE atprop_release
     151             : 
     152           0 : END MODULE atprop_types

Generated by: LCOV version 1.15