LCOV - code coverage report
Current view: top level - src/subsys - shell_potential_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:20fe009) Lines: 44 45 97.8 %
Date: 2022-07-05 19:56:53 Functions: 6 8 75.0 %

          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             : !> \author MI (12.01.2007)
      10             : ! **************************************************************************************************
      11             : MODULE shell_potential_types
      12             : 
      13             :    USE kinds,                           ONLY: default_string_length,&
      14             :                                               dp
      15             : #include "../base/base_uses.f90"
      16             : 
      17             :    IMPLICIT NONE
      18             : 
      19             :    PRIVATE
      20             : 
      21             : ! Global parameters (only in this module)
      22             : 
      23             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'shell_potential_types'
      24             : 
      25             : ! **************************************************************************************************
      26             : !> \brief Define the shell type
      27             : ! **************************************************************************************************
      28             :    TYPE shell_kind_type
      29             :       INTEGER                                :: ref_count
      30             :       REAL(dp)                               :: charge_core, &
      31             :                                                 charge_shell
      32             :       REAL(dp)                               :: mass_core, &
      33             :                                                 massfrac, &
      34             :                                                 mass_shell
      35             :       REAL(dp)                               :: k2_spring, k4_spring
      36             :       REAL(dp)                               :: max_dist
      37             :       REAL(dp)                               :: shell_cutoff
      38             :    END TYPE shell_kind_type
      39             : 
      40             : ! **************************************************************************************************
      41             :    TYPE shell_p_type
      42             :       CHARACTER(LEN=default_string_length)   :: atm_name
      43             :       TYPE(shell_kind_type), POINTER          :: shell
      44             :    END TYPE shell_p_type
      45             : 
      46             : ! Public subroutines
      47             : 
      48             :    PUBLIC :: get_shell, shell_create, shell_p_create, &
      49             :              shell_p_release, shell_release, shell_retain
      50             : 
      51             : ! Public data types
      52             : 
      53             :    PUBLIC :: shell_p_type, shell_kind_type
      54             : 
      55             : CONTAINS
      56             : 
      57             : ! **************************************************************************************************
      58             : !> \brief ...
      59             : !> \param shell ...
      60             : !> \param charge ...
      61             : !> \param charge_core ...
      62             : !> \param charge_shell ...
      63             : !> \param mass_core ...
      64             : !> \param mass_shell ...
      65             : !> \param k2_spring ...
      66             : !> \param k4_spring ...
      67             : !> \param max_dist ...
      68             : !> \param shell_cutoff ...
      69             : ! **************************************************************************************************
      70       49406 :    SUBROUTINE get_shell(shell, charge, charge_core, charge_shell, mass_core, &
      71             :                         mass_shell, k2_spring, k4_spring, max_dist, shell_cutoff)
      72             : 
      73             :       TYPE(shell_kind_type), INTENT(IN)                  :: shell
      74             :       REAL(KIND=dp), INTENT(OUT), OPTIONAL               :: charge, charge_core, charge_shell, &
      75             :                                                             mass_core, mass_shell, k2_spring, &
      76             :                                                             k4_spring, max_dist, shell_cutoff
      77             : 
      78       49406 :       IF (PRESENT(charge)) charge = shell%charge_core + shell%charge_shell
      79       49406 :       IF (PRESENT(charge_core)) charge_core = shell%charge_core
      80       49406 :       IF (PRESENT(charge_shell)) charge_shell = shell%charge_shell
      81       49406 :       IF (PRESENT(mass_core)) mass_core = shell%mass_core
      82       49406 :       IF (PRESENT(mass_shell)) mass_shell = shell%mass_shell
      83       49406 :       IF (PRESENT(k2_spring)) k2_spring = shell%k2_spring
      84       49406 :       IF (PRESENT(k4_spring)) k4_spring = shell%k4_spring
      85       49406 :       IF (PRESENT(max_dist)) max_dist = shell%max_dist
      86       49406 :       IF (PRESENT(shell_cutoff)) shell_cutoff = shell%shell_cutoff
      87             : 
      88       49406 :    END SUBROUTINE
      89             : ! **************************************************************************************************
      90             : !> \brief ...
      91             : !> \param shell ...
      92             : ! **************************************************************************************************
      93         886 :    SUBROUTINE shell_create(shell)
      94             : 
      95             :       TYPE(shell_kind_type), POINTER                     :: shell
      96             : 
      97         886 :       CPASSERT(.NOT. ASSOCIATED(shell))
      98         886 :       ALLOCATE (shell)
      99         886 :       shell%ref_count = 1
     100             : 
     101         886 :    END SUBROUTINE shell_create
     102             : 
     103             : ! **************************************************************************************************
     104             : !> \brief ...
     105             : !> \param shell_list ...
     106             : !> \param ndim ...
     107             : ! **************************************************************************************************
     108         254 :    SUBROUTINE shell_p_create(shell_list, ndim)
     109             : 
     110             :       TYPE(shell_p_type), DIMENSION(:), POINTER          :: shell_list
     111             :       INTEGER, INTENT(IN)                                :: ndim
     112             : 
     113             :       INTEGER                                            :: i
     114             : 
     115         254 :       CPASSERT(.NOT. ASSOCIATED(shell_list))
     116         762 :       ALLOCATE (shell_list(ndim))
     117             : 
     118         698 :       DO i = 1, ndim
     119         444 :          NULLIFY (shell_list(i)%shell)
     120         444 :          CALL shell_create(shell_list(i)%shell)
     121         698 :          shell_list(i)%atm_name = ''
     122             :       END DO
     123             : 
     124         254 :    END SUBROUTINE shell_p_create
     125             : 
     126             : ! **************************************************************************************************
     127             : !> \brief ...
     128             : !> \param shell ...
     129             : ! **************************************************************************************************
     130         442 :    SUBROUTINE shell_retain(shell)
     131             : 
     132             :       TYPE(shell_kind_type), POINTER                     :: shell
     133             : 
     134         442 :       CPASSERT(ASSOCIATED(shell))
     135         442 :       CPASSERT(shell%ref_count > 0)
     136         442 :       shell%ref_count = shell%ref_count + 1
     137             : 
     138         442 :    END SUBROUTINE shell_retain
     139             : 
     140             : ! **************************************************************************************************
     141             : !> \brief ...
     142             : !> \param shell ...
     143             : ! **************************************************************************************************
     144       30465 :    SUBROUTINE shell_release(shell)
     145             : 
     146             :       TYPE(shell_kind_type), POINTER                     :: shell
     147             : 
     148       30465 :       IF (ASSOCIATED(shell)) THEN
     149        1328 :          CPASSERT(shell%ref_count > 0)
     150        1328 :          shell%ref_count = shell%ref_count - 1
     151        1328 :          IF (shell%ref_count == 0) THEN
     152         886 :             DEALLOCATE (shell)
     153             :          END IF
     154             :       END IF
     155       30465 :       NULLIFY (shell)
     156             : 
     157       30465 :    END SUBROUTINE shell_release
     158             : 
     159             : ! **************************************************************************************************
     160             : !> \brief ...
     161             : !> \param shell_list ...
     162             : ! **************************************************************************************************
     163         254 :    SUBROUTINE shell_p_release(shell_list)
     164             :       TYPE(shell_p_type), DIMENSION(:), POINTER          :: shell_list
     165             : 
     166             :       INTEGER                                            :: i
     167             : 
     168         254 :       IF (ASSOCIATED(shell_list)) THEN
     169         698 :          DO i = 1, SIZE(shell_list)
     170         698 :             CALL shell_release(shell_list(i)%shell)
     171             :          END DO
     172         254 :          DEALLOCATE (shell_list)
     173             :       END IF
     174             : 
     175         254 :       NULLIFY (shell_list)
     176             : 
     177         254 :    END SUBROUTINE shell_p_release
     178             : 
     179           0 : END MODULE shell_potential_types

Generated by: LCOV version 1.15