LCOV - code coverage report
Current view: top level - src/subsys - atprop_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 44 45 97.8 %
Date: 2024-12-21 06:28:57 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       10153 :    SUBROUTINE atprop_create(atprop_env)
      51             :       TYPE(atprop_type), POINTER                         :: atprop_env
      52             : 
      53       10153 :       CALL atprop_release(atprop_env)
      54       10153 :       ALLOCATE (atprop_env)
      55             : 
      56       10153 :    END SUBROUTINE atprop_create
      57             : 
      58             : ! **************************************************************************************************
      59             : !> \brief ...
      60             : !> \param atprop_env ...
      61             : !> \param natom ...
      62             : ! **************************************************************************************************
      63       99752 :    SUBROUTINE atprop_init(atprop_env, natom)
      64             :       TYPE(atprop_type), INTENT(INOUT)                   :: atprop_env
      65             :       INTEGER, INTENT(IN)                                :: natom
      66             : 
      67       99752 :       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       99752 :    END SUBROUTINE atprop_init
      80             : 
      81             : ! **************************************************************************************************
      82             : !> \brief ...
      83             : !> \param atarray ...
      84             : !> \param natom ...
      85             : ! **************************************************************************************************
      86        9053 :    SUBROUTINE atprop_array_init(atarray, natom)
      87             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: atarray
      88             :       INTEGER, INTENT(IN)                                :: natom
      89             : 
      90        9053 :       IF (ASSOCIATED(atarray)) THEN
      91        6562 :          CPASSERT(SIZE(atarray) == natom)
      92             :       ELSE
      93        7473 :          ALLOCATE (atarray(natom))
      94             :       END IF
      95      131656 :       atarray = 0._dp
      96             : 
      97        9053 :    END SUBROUTINE atprop_array_init
      98             : 
      99             : ! **************************************************************************************************
     100             : !> \brief ...
     101             : !> \param atarray ...
     102             : ! **************************************************************************************************
     103       99201 :    SUBROUTINE atprop_array_release(atarray)
     104             :       REAL(KIND=dp), DIMENSION(:), POINTER               :: atarray
     105             : 
     106       99201 :       IF (ASSOCIATED(atarray)) THEN
     107        2491 :          DEALLOCATE (atarray)
     108             :       END IF
     109             : 
     110       99201 :    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       20306 :    SUBROUTINE atprop_release(atprop_env)
     133             :       TYPE(atprop_type), POINTER                         :: atprop_env
     134             : 
     135       20306 :       IF (ASSOCIATED(atprop_env)) THEN
     136             :          ! energy
     137       10153 :          CALL atprop_array_release(atprop_env%atener)
     138       10153 :          CALL atprop_array_release(atprop_env%ateb)
     139       10153 :          CALL atprop_array_release(atprop_env%ateself)
     140       10153 :          CALL atprop_array_release(atprop_env%atexc)
     141       10153 :          CALL atprop_array_release(atprop_env%atevdw)
     142       10153 :          CALL atprop_array_release(atprop_env%ategcp)
     143       10153 :          CALL atprop_array_release(atprop_env%atecc)
     144       10153 :          CALL atprop_array_release(atprop_env%ate1c)
     145       10153 :          CALL atprop_array_release(atprop_env%atecoul)
     146             :          ! atprop type
     147       10153 :          DEALLOCATE (atprop_env)
     148             :       END IF
     149       20306 :       NULLIFY (atprop_env)
     150       20306 :    END SUBROUTINE atprop_release
     151             : 
     152           0 : END MODULE atprop_types

Generated by: LCOV version 1.15