CP2K 2.4 (Revision 12889)

shell_potential_types.f90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------------!
00002 !   CP2K: A general program to perform molecular dynamics simulations         !
00003 !   Copyright (C) 2000 - 2013  CP2K developers group                          !
00004 !-----------------------------------------------------------------------------!
00005 
00006 ! *****************************************************************************
00009 MODULE shell_potential_types
00010 
00011   USE f77_blas
00012   USE kinds,                           ONLY: default_string_length,&
00013                                              dp
00014 #include "cp_common_uses.h"
00015 
00016   IMPLICIT NONE
00017 
00018   PRIVATE
00019 
00020 ! Global parameters (only in this module)
00021 
00022   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'shell_potential_types'
00023 
00024 ! *****************************************************************************
00027   TYPE shell_kind_type
00028     INTEGER                                :: ref_count
00029     REAL(dp)                               :: charge_core, 
00030                                               charge_shell
00031     REAL(dp)                               :: mass_core, 
00032                                               massfrac, 
00033                                               mass_shell
00034     REAL(dp)                               :: k2_spring,k4_spring
00035     REAL(dp)                               :: max_dist
00036     REAL(dp)                               :: shell_cutoff
00037   END TYPE shell_kind_type
00038 
00039 ! *****************************************************************************
00040   TYPE shell_p_type
00041     CHARACTER (LEN=default_string_length)   :: atm_name
00042     TYPE(shell_kind_type), POINTER          :: shell
00043   END TYPE shell_p_type
00044 
00045 ! Public subroutines
00046 
00047   PUBLIC :: get_shell, shell_create, shell_p_create, &
00048             shell_p_release, shell_release, shell_retain
00049 
00050 ! Public data types
00051 
00052   PUBLIC :: shell_p_type, shell_kind_type
00053 
00054 CONTAINS
00055 
00056 ! *****************************************************************************
00057   SUBROUTINE get_shell(shell,charge,charge_core,charge_shell,mass_core,&
00058                        mass_shell,k2_spring,k4_spring,max_dist,shell_cutoff,&
00059                        error)
00060 
00061     TYPE(shell_kind_type), POINTER           :: shell
00062     REAL(KIND=dp), INTENT(OUT), OPTIONAL :: charge, charge_core, 
00063       charge_shell, mass_core, mass_shell, k2_spring, k4_spring, max_dist, 
00064       shell_cutoff
00065     TYPE(cp_error_type), INTENT(inout)       :: error
00066 
00067     CHARACTER(LEN=*), PARAMETER :: routineN = 'get_shell', 
00068       routineP = moduleN//':'//routineN
00069 
00070     IF (ASSOCIATED(shell)) THEN
00071       IF (PRESENT(charge)) charge = shell%charge_core + shell%charge_shell
00072       IF (PRESENT(charge_core)) charge_core = shell%charge_core
00073       IF (PRESENT(charge_shell)) charge_shell = shell%charge_shell
00074       IF (PRESENT(mass_core)) mass_core = shell%mass_core
00075       IF (PRESENT(mass_shell)) mass_shell = shell%mass_shell
00076       IF (PRESENT(k2_spring)) k2_spring = shell%k2_spring
00077       IF (PRESENT(k4_spring)) k4_spring = shell%k4_spring
00078       IF (PRESENT(max_dist)) max_dist = shell%max_dist
00079       IF (PRESENT(shell_cutoff)) shell_cutoff = shell%shell_cutoff
00080     END IF
00081 
00082   END SUBROUTINE
00083 ! *****************************************************************************
00084   SUBROUTINE shell_create(shell,error)
00085 
00086     TYPE(shell_kind_type), POINTER           :: shell
00087     TYPE(cp_error_type), INTENT(inout)       :: error
00088 
00089     CHARACTER(len=*), PARAMETER :: routineN = 'shell_create', 
00090       routineP = moduleN//':'//routineN
00091 
00092     INTEGER                                  :: istat
00093     LOGICAL                                  :: failure
00094 
00095     failure = .FALSE.
00096     CPPostcondition(.NOT.ASSOCIATED(shell),cp_failure_level,routineP,error,failure)
00097     ALLOCATE(shell,STAT=istat)
00098     CPPostcondition(istat==0,cp_failure_level,routineP,error,failure)
00099     shell%ref_count = 1
00100 
00101   END SUBROUTINE shell_create
00102 
00103 ! *****************************************************************************
00104   SUBROUTINE shell_p_create(shell_list,ndim,error)
00105 
00106     TYPE(shell_p_type), DIMENSION(:), 
00107       POINTER                                :: shell_list
00108     INTEGER, INTENT(IN)                      :: ndim
00109     TYPE(cp_error_type), INTENT(inout)       :: error
00110 
00111     CHARACTER(len=*), PARAMETER :: routineN = 'shell_p_create', 
00112       routineP = moduleN//':'//routineN
00113 
00114     INTEGER                                  :: i, istat
00115     LOGICAL                                  :: failure
00116 
00117     failure = .FALSE.
00118 
00119     CPPostcondition(.NOT.ASSOCIATED(shell_list),cp_failure_level,routineP,error,failure)
00120     ALLOCATE(shell_list(ndim), STAT=istat)
00121     CPPostcondition(istat==0,cp_failure_level,routineP,error,failure)
00122 
00123     DO i = 1,ndim
00124       NULLIFY (shell_list(i)%shell)
00125       CALL shell_create(shell_list(i)%shell,error)
00126       shell_list(i)%atm_name=''
00127     END DO
00128 
00129   END SUBROUTINE shell_p_create
00130 
00131 ! *****************************************************************************
00132   SUBROUTINE shell_retain(shell,error)
00133 
00134     TYPE(shell_kind_type), POINTER           :: shell
00135     TYPE(cp_error_type), INTENT(inout)       :: error
00136 
00137     CHARACTER(len=*), PARAMETER :: routineN = 'shell_retain', 
00138       routineP = moduleN//':'//routineN
00139 
00140     LOGICAL                                  :: failure
00141 
00142     failure = .FALSE.
00143 
00144     CPPrecondition(ASSOCIATED(shell),cp_failure_level,routineP,error,failure)
00145     IF(.NOT. failure) THEN
00146       CPPrecondition(shell%ref_count>0,cp_failure_level,routineP,error,failure)
00147       shell%ref_count=shell%ref_count+1
00148     END IF
00149 
00150   END SUBROUTINE shell_retain
00151 
00152 ! *****************************************************************************
00153   SUBROUTINE shell_release(shell,error)
00154 
00155     TYPE(shell_kind_type), POINTER           :: shell
00156     TYPE(cp_error_type), INTENT(inout)       :: error
00157 
00158     CHARACTER(len=*), PARAMETER :: routineN = 'shell_release', 
00159       routineP = moduleN//':'//routineN
00160 
00161     INTEGER                                  :: istat
00162     LOGICAL                                  :: failure
00163 
00164     failure = .FALSE.
00165     IF(ASSOCIATED(shell)) THEN
00166       CPPrecondition(shell%ref_count>0,cp_failure_level,routineP,error,failure)
00167       shell%ref_count=shell%ref_count-1
00168       IF(shell%ref_count==0) THEN
00169         DEALLOCATE(shell,STAT=istat)
00170         CPPostconditionNoFail(istat==0,cp_warning_level,routineP,error)
00171       END IF
00172     END IF
00173     NULLIFY(shell)
00174 
00175   END SUBROUTINE shell_release
00176 
00177 ! *****************************************************************************
00178   SUBROUTINE shell_p_release(shell_list, error)
00179     TYPE(shell_p_type), DIMENSION(:), 
00180       POINTER                                :: shell_list
00181     TYPE(cp_error_type), INTENT(inout)       :: error
00182 
00183     CHARACTER(len=*), PARAMETER :: routineN = 'shell_p_release', 
00184       routineP = moduleN//':'//routineN
00185 
00186     INTEGER                                  :: i, istat
00187 
00188     IF (ASSOCIATED(shell_list)) THEN
00189       DO i = 1,SIZE(shell_list)
00190          CALL shell_release(shell_list(i)%shell,error=error)
00191       END DO
00192       DEALLOCATE(shell_list,stat=istat)
00193       CPPostconditionNoFail(istat==0,cp_warning_level,routineP,error)
00194     END IF
00195 
00196     NULLIFY (shell_list)
00197 
00198   END SUBROUTINE shell_p_release
00199 
00200 END MODULE shell_potential_types