LCOV - code coverage report
Current view: top level - src - pair_potential_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:c24029e) Lines: 92.2 % 1083 999
Test Date: 2026-07-04 06:36:57 Functions: 74.8 % 111 83

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \par History
      10              : !>      Teodoro Laino [Teo] 11.2005 : Reorganizing the structures to optimize
      11              : !>                                    memory management
      12              : !> \author CJM
      13              : ! **************************************************************************************************
      14              : MODULE pair_potential_types
      15              : 
      16              :    USE ace_wrapper,                     ONLY: ace_model_type
      17              :    USE kinds,                           ONLY: default_path_length,&
      18              :                                               default_string_length,&
      19              :                                               dp
      20              :    USE memory_utilities,                ONLY: reallocate
      21              :    USE splines_types,                   ONLY: spline_data_p_copy,&
      22              :                                               spline_data_p_release,&
      23              :                                               spline_data_p_type,&
      24              :                                               spline_factor_copy,&
      25              :                                               spline_factor_release,&
      26              :                                               spline_factor_type
      27              : #include "./base/base_uses.f90"
      28              : 
      29              :    IMPLICIT NONE
      30              : 
      31              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'pair_potential_types'
      32              : 
      33              :    PRIVATE
      34              :    ! when adding a new nonbonded potential please update also the list_pot
      35              :    ! used for the linear scaling screening of potential calculation
      36              :    INTEGER, PUBLIC, PARAMETER :: multi_type = -1, &
      37              :                                  nn_type = 0, &
      38              :                                  lj_type = 1, &
      39              :                                  lj_charmm_type = 2, &
      40              :                                  ft_type = 3, &
      41              :                                  wl_type = 4, &
      42              :                                  gw_type = 5, &
      43              :                                  ip_type = 6, &
      44              :                                  ea_type = 7, &
      45              :                                  b4_type = 8, &
      46              :                                  bm_type = 9, &
      47              :                                  gp_type = 10, &
      48              :                                  tersoff_type = 11, &
      49              :                                  ftd_type = 12, &
      50              :                                  siepmann_type = 13, &
      51              :                                  gal_type = 14, &
      52              :                                  nequip_type = 16, &
      53              :                                  allegro_type = 17, &
      54              :                                  gal21_type = 18, &
      55              :                                  tab_type = 19, &
      56              :                                  deepmd_type = 20, &
      57              :                                  ace_type = 21
      58              : 
      59              :    INTEGER, PUBLIC, PARAMETER, DIMENSION(21) :: list_pot = [nn_type, &
      60              :                                                             lj_type, &
      61              :                                                             lj_charmm_type, &
      62              :                                                             ft_type, &
      63              :                                                             wl_type, &
      64              :                                                             gw_type, &
      65              :                                                             ip_type, &
      66              :                                                             ea_type, &
      67              :                                                             b4_type, &
      68              :                                                             bm_type, &
      69              :                                                             gp_type, &
      70              :                                                             tersoff_type, &
      71              :                                                             ftd_type, &
      72              :                                                             siepmann_type, &
      73              :                                                             gal_type, &
      74              :                                                             nequip_type, &
      75              :                                                             allegro_type, &
      76              :                                                             gal21_type, &
      77              :                                                             tab_type, &
      78              :                                                             deepmd_type, &
      79              :                                                             ace_type]
      80              : 
      81              :    ! Shell model
      82              :    INTEGER, PUBLIC, PARAMETER :: nosh_nosh = 0, &
      83              :                                  nosh_sh = 1, &
      84              :                                  sh_sh = 2
      85              : 
      86              :    INTEGER, PUBLIC, PARAMETER, DIMENSION(3) :: list_sh_type = [nosh_nosh, nosh_sh, sh_sh]
      87              : 
      88              :    ! Single Spline generation info
      89              :    REAL(KIND=dp), PARAMETER, PUBLIC         :: not_initialized = -HUGE(0.0_dp)
      90              :    INTEGER, PARAMETER, DIMENSION(2), PUBLIC :: do_potential_single_allocation = [lj_type, lj_charmm_type]
      91              :    INTEGER, PARAMETER, DIMENSION(2), PUBLIC :: no_potential_single_allocation = [-HUGE(0), -HUGE(0)]
      92              :    INTEGER, DIMENSION(2), PUBLIC            :: potential_single_allocation
      93              : 
      94              :    PUBLIC :: pair_potential_reallocate
      95              : 
      96              :    PUBLIC :: pair_potential_single_copy, &
      97              :              pair_potential_single_add, &
      98              :              pair_potential_single_clean, &
      99              :              pair_potential_single_type
     100              : 
     101              :    PUBLIC :: pair_potential_pp_create, &
     102              :              pair_potential_pp_release, &
     103              :              pair_potential_pp_type
     104              : 
     105              :    PUBLIC :: pair_potential_p_type, &
     106              :              pair_potential_p_release
     107              : 
     108              :    PUBLIC :: ft_pot_type, &
     109              :              ipbv_pot_type, &
     110              :              eam_pot_type, &
     111              :              nequip_pot_type, &
     112              :              deepmd_pot_type, &
     113              :              ace_pot_type, &
     114              :              tersoff_pot_type, &
     115              :              siepmann_pot_type, &
     116              :              gal_pot_type, &
     117              :              gal21_pot_type, &
     118              :              tab_pot_type
     119              : 
     120              :    PUBLIC :: pair_potential_lj_create
     121              :    PUBLIC :: compare_pot
     122              : 
     123              : ! **************************************************************************************************
     124              :    TYPE ipbv_pot_type
     125              :       REAL(KIND=dp), DIMENSION(2:15) :: a = 0.0_dp
     126              :       REAL(KIND=dp) :: rcore = 0.0_dp
     127              :       REAL(KIND=dp) :: m = 0.0_dp
     128              :       REAL(KIND=dp) :: b = 0.0_dp
     129              :    END TYPE ipbv_pot_type
     130              : 
     131              : ! **************************************************************************************************
     132              :    TYPE lj_pot_type
     133              :       REAL(KIND=dp) :: epsilon = 0.0_dp
     134              :       REAL(KIND=dp) :: sigma6 = 0.0_dp
     135              :       REAL(KIND=dp) :: sigma12 = 0.0_dp
     136              :    END TYPE Lj_pot_type
     137              : 
     138              : ! **************************************************************************************************
     139              :    TYPE ft_pot_type
     140              :       REAL(KIND=dp) :: A = 0.0_dp
     141              :       REAL(KIND=dp) :: B = 0.0_dp
     142              :       REAL(KIND=dp) :: C = 0.0_dp
     143              :       REAL(KIND=dp) :: D = 0.0_dp
     144              :    END TYPE ft_pot_type
     145              : 
     146              : ! **************************************************************************************************
     147              :    TYPE ftd_pot_type
     148              :       REAL(KIND=dp) :: A = 0.0_dp
     149              :       REAL(KIND=dp) :: B = 0.0_dp
     150              :       REAL(KIND=dp) :: C = 0.0_dp
     151              :       REAL(KIND=dp) :: D = 0.0_dp
     152              :       REAL(KIND=dp), DIMENSION(2) :: BD = 0.0_dp
     153              :    END TYPE ftd_pot_type
     154              : 
     155              : ! **************************************************************************************************
     156              :    TYPE williams_pot_type
     157              :       REAL(KIND=dp) :: a = 0.0_dp
     158              :       REAL(KIND=dp) :: b = 0.0_dp
     159              :       REAL(KIND=dp) :: c = 0.0_dp
     160              :    END TYPE williams_pot_type
     161              : 
     162              : ! **************************************************************************************************
     163              :    TYPE goodwin_pot_type
     164              :       REAL(KIND=dp) :: vr0 = 0.0_dp
     165              :       REAL(KIND=dp) :: m = 0.0_dp, mc = 0.0_dp
     166              :       REAL(KIND=dp) :: d = 0.0_dp, dc = 0.0_dp
     167              :    END TYPE goodwin_pot_type
     168              : 
     169              : ! **************************************************************************************************
     170              :    TYPE eam_pot_type
     171              :       CHARACTER(LEN=default_path_length)     :: eam_file_name = ""
     172              :       INTEGER                                 :: npoints = 0
     173              :       REAL(KIND=dp)                          :: drar = 0.0_dp, drhoar = 0.0_dp, acutal = 0.0_dp
     174              :       REAL(KIND=dp), POINTER, DIMENSION(:)    :: rho => NULL(), phi => NULL(), frho => NULL(), rhoval => NULL(), rval => NULL()
     175              :       REAL(KIND=dp), POINTER, DIMENSION(:)    :: rhop => NULL(), phip => NULL(), frhop => NULL()
     176              :    END TYPE eam_pot_type
     177              : 
     178              : ! **************************************************************************************************
     179              :    TYPE ace_pot_type
     180              :       CHARACTER(LEN=default_path_length)     :: ace_file_name = 'NULL'
     181              :       INTEGER                                :: atom_ace_type = 0
     182              :       TYPE(ace_model_type)                   :: model = ace_model_type()
     183              :    END TYPE ace_pot_type
     184              : 
     185              : !     **************************************************************************************************
     186              :    TYPE deepmd_pot_type
     187              :       CHARACTER(LEN=default_path_length)     :: deepmd_file_name = 'NULL'
     188              :       INTEGER                                :: atom_deepmd_type = 0
     189              :    END TYPE deepmd_pot_type
     190              : 
     191              : ! **************************************************************************************************
     192              :    TYPE nequip_pot_type
     193              :       CHARACTER(LEN=default_path_length)     :: pot_file_name = 'NULL', &
     194              :                                                 unit_length = 'NULL', unit_forces = 'NULL', &
     195              :                                                 unit_energy = 'NULL'
     196              :       CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE      :: type_names_torch
     197              :       REAL(KIND=dp), DIMENSION(:, :), ALLOCATABLE :: cutoff_matrix
     198              :       INTEGER                                :: num_types = 0
     199              :       REAL(KIND=dp)                          :: rcutsq = 0.0_dp, unit_length_val = 1.0_dp, &
     200              :                                                 unit_forces_val = 1.0_dp, unit_energy_val = 1.0_dp
     201              :       LOGICAL                                :: mixed_precision = .FALSE.
     202              :    END TYPE nequip_pot_type
     203              : 
     204              : ! **************************************************************************************************
     205              :    TYPE buck4ran_pot_type
     206              :       REAL(KIND=dp) :: a = 0.0_dp
     207              :       REAL(KIND=dp) :: b = 0.0_dp
     208              :       REAL(KIND=dp) :: c = 0.0_dp
     209              :       REAL(KIND=dp) :: r1 = 0.0_dp
     210              :       REAL(KIND=dp) :: r2 = 0.0_dp
     211              :       REAL(KIND=dp) :: r3 = 0.0_dp
     212              :       INTEGER :: npoly1 = 0, npoly2 = 0
     213              :       REAL(KIND=dp), DIMENSION(0:10) :: poly1 = 0.0_dp
     214              :       REAL(KIND=dp), DIMENSION(0:10) :: poly2 = 0.0_dp
     215              :    END TYPE buck4ran_pot_type
     216              : 
     217              : ! **************************************************************************************************
     218              :    TYPE buckmorse_pot_type
     219              :       REAL(KIND=dp) :: f0 = 0.0_dp
     220              :       REAL(KIND=dp) :: a1 = 0.0_dp
     221              :       REAL(KIND=dp) :: a2 = 0.0_dp
     222              :       REAL(KIND=dp) :: b1 = 0.0_dp
     223              :       REAL(KIND=dp) :: b2 = 0.0_dp
     224              :       REAL(KIND=dp) :: c = 0.0_dp
     225              :       REAL(KIND=dp) :: d = 0.0_dp
     226              :       REAL(KIND=dp) :: r0 = 0.0_dp
     227              :       REAL(KIND=dp) :: beta = 0.0_dp
     228              :    END TYPE buckmorse_pot_type
     229              : 
     230              : ! **************************************************************************************************
     231              :    TYPE gp_pot_type
     232              :       INTEGER                                   :: myid = 0
     233              :       CHARACTER(LEN=default_path_length)       :: potential = ""
     234              :       CHARACTER(LEN=default_string_length), &
     235              :          POINTER, DIMENSION(:)                   :: parameters => NULL(), units => NULL()
     236              :       CHARACTER(LEN=default_string_length)     :: variables = ""
     237              :       REAL(KIND=dp), DIMENSION(:), POINTER      :: values => NULL()
     238              :    END TYPE gp_pot_type
     239              : 
     240              : ! **************************************************************************************************
     241              :    TYPE tersoff_pot_type
     242              :       ! Get this stuff from the PRB V38, N14 9902 (1988) by Tersoff
     243              :       REAL(KIND=dp) :: A = 0.0_dp
     244              :       REAL(KIND=dp) :: B = 0.0_dp
     245              :       REAL(KIND=dp) :: lambda1 = 0.0_dp
     246              :       REAL(KIND=dp) :: lambda2 = 0.0_dp
     247              :       REAL(KIND=dp) :: alpha = 0.0_dp
     248              :       REAL(KIND=dp) :: beta = 0.0_dp
     249              :       REAL(KIND=dp) :: n = 0.0_dp
     250              :       REAL(KIND=dp) :: c = 0.0_dp
     251              :       REAL(KIND=dp) :: d = 0.0_dp
     252              :       REAL(KIND=dp) :: h = 0.0_dp
     253              :       REAL(KIND=dp) :: lambda3 = 0.0_dp
     254              :       REAL(KIND=dp) :: bigR = 0.0_dp ! Used to be R = Rij + D
     255              :       REAL(KIND=dp) :: bigD = 0.0_dp ! Used to be D = Rij - D
     256              :       REAL(KIND=dp) :: rcutsq = 0.0_dp ! Always set to (bigR+bigD)^2
     257              :    END TYPE tersoff_pot_type
     258              : 
     259              : ! **************************************************************************************************
     260              :    TYPE siepmann_pot_type
     261              :       REAL(KIND=dp) :: B = 0.0_dp
     262              :       REAL(KIND=dp) :: D = 0.0_dp
     263              :       REAL(KIND=dp) :: E = 0.0_dp
     264              :       REAL(KIND=dp) :: F = 0.0_dp
     265              :       REAL(KIND=dp) :: beta = 0.0_dp
     266              :       REAL(KIND=dp) :: rcutsq = 0.0_dp
     267              :       LOGICAL        :: allow_oh_formation = .FALSE.
     268              :       LOGICAL        :: allow_h3o_formation = .FALSE.
     269              :       LOGICAL        :: allow_o_formation = .FALSE.
     270              :    END TYPE siepmann_pot_type
     271              : 
     272              : ! **************************************************************************************************
     273              :    TYPE gal_pot_type
     274              :       CHARACTER(LEN=2) :: met1 = ""
     275              :       CHARACTER(LEN=2) :: met2 = ""
     276              :       REAL(KIND=dp) :: epsilon = 0.0_dp
     277              :       REAL(KIND=dp) :: bxy = 0.0_dp
     278              :       REAL(KIND=dp) :: bz = 0.0_dp
     279              :       REAL(KIND=dp) :: r1 = 0.0_dp
     280              :       REAL(KIND=dp) :: r2 = 0.0_dp
     281              :       REAL(KIND=dp) :: a1 = 0.0_dp
     282              :       REAL(KIND=dp) :: a2 = 0.0_dp
     283              :       REAL(KIND=dp) :: a3 = 0.0_dp
     284              :       REAL(KIND=dp) :: a4 = 0.0_dp
     285              :       REAL(KIND=dp) :: a = 0.0_dp
     286              :       REAL(KIND=dp) :: b = 0.0_dp
     287              :       REAL(KIND=dp) :: c = 0.0_dp
     288              :       REAL(KIND=dp), POINTER, DIMENSION(:) :: gcn => NULL()
     289              :       REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :)    :: n_vectors
     290              :       REAL(KIND=dp)  :: rcutsq = 0.0_dp
     291              :       LOGICAL        :: express = .FALSE.
     292              :    END TYPE gal_pot_type
     293              : 
     294              : ! **************************************************************************************************
     295              : 
     296              :    TYPE gal21_pot_type
     297              :       CHARACTER(LEN=2) :: met1 = ""
     298              :       CHARACTER(LEN=2) :: met2 = ""
     299              :       REAL(KIND=dp) :: epsilon1 = 0.0_dp
     300              :       REAL(KIND=dp) :: epsilon2 = 0.0_dp
     301              :       REAL(KIND=dp) :: epsilon3 = 0.0_dp
     302              :       REAL(KIND=dp) :: bxy1 = 0.0_dp
     303              :       REAL(KIND=dp) :: bxy2 = 0.0_dp
     304              :       REAL(KIND=dp) :: bz1 = 0.0_dp
     305              :       REAL(KIND=dp) :: bz2 = 0.0_dp
     306              :       REAL(KIND=dp) :: r1 = 0.0_dp
     307              :       REAL(KIND=dp) :: r2 = 0.0_dp
     308              :       REAL(KIND=dp) :: a11 = 0.0_dp
     309              :       REAL(KIND=dp) :: a12 = 0.0_dp
     310              :       REAL(KIND=dp) :: a13 = 0.0_dp
     311              :       REAL(KIND=dp) :: a21 = 0.0_dp
     312              :       REAL(KIND=dp) :: a22 = 0.0_dp
     313              :       REAL(KIND=dp) :: a23 = 0.0_dp
     314              :       REAL(KIND=dp) :: a31 = 0.0_dp
     315              :       REAL(KIND=dp) :: a32 = 0.0_dp
     316              :       REAL(KIND=dp) :: a33 = 0.0_dp
     317              :       REAL(KIND=dp) :: a41 = 0.0_dp
     318              :       REAL(KIND=dp) :: a42 = 0.0_dp
     319              :       REAL(KIND=dp) :: a43 = 0.0_dp
     320              :       REAL(KIND=dp) :: AO1 = 0.0_dp
     321              :       REAL(KIND=dp) :: AO2 = 0.0_dp
     322              :       REAL(KIND=dp) :: BO1 = 0.0_dp
     323              :       REAL(KIND=dp) :: BO2 = 0.0_dp
     324              :       REAL(KIND=dp) :: c = 0.0_dp
     325              :       REAL(KIND=dp) :: AH1 = 0.0_dp
     326              :       REAL(KIND=dp) :: AH2 = 0.0_dp
     327              :       REAL(KIND=dp) :: BH1 = 0.0_dp
     328              :       REAL(KIND=dp) :: BH2 = 0.0_dp
     329              :       REAL(KIND=dp), POINTER, DIMENSION(:) :: gcn => NULL()
     330              :       REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :)    :: n_vectors
     331              :       REAL(KIND=dp)  :: rcutsq = 0.0_dp
     332              :       LOGICAL        :: express = .FALSE.
     333              :    END TYPE gal21_pot_type
     334              : 
     335              : ! **************************************************************************************************
     336              : 
     337              :    TYPE tab_pot_type
     338              :       CHARACTER(LEN=default_path_length)      :: tabpot_file_name = ""
     339              :       INTEGER                                 :: npoints = 0, index = 0
     340              :       REAL(KIND=dp)                           :: dr = 0.0_dp, rcut = 0.0_dp
     341              :       REAL(KIND=dp), POINTER, DIMENSION(:)    :: r => NULL(), e => NULL(), f => NULL()
     342              :    END TYPE tab_pot_type
     343              : 
     344              : ! **************************************************************************************************
     345              : 
     346              :    TYPE pot_set_type
     347              :       REAL(KIND=dp)                      :: rmin = 0.0_dp, rmax = 0.0_dp
     348              :       TYPE(ipbv_pot_type), POINTER :: ipbv => NULL()
     349              :       TYPE(gp_pot_type), POINTER :: gp => NULL()
     350              :       TYPE(lj_pot_type), POINTER :: lj => NULL()
     351              :       TYPE(ft_pot_type), POINTER :: ft => NULL()
     352              :       TYPE(williams_pot_type), POINTER :: willis => NULL()
     353              :       TYPE(goodwin_pot_type), POINTER :: goodwin => NULL()
     354              :       TYPE(eam_pot_type), POINTER :: eam => NULL()
     355              :       TYPE(nequip_pot_type), POINTER :: nequip => NULL()
     356              :       TYPE(ace_pot_type), POINTER :: ace => NULL()
     357              :       TYPE(deepmd_pot_type), POINTER :: deepmd => NULL()
     358              :       TYPE(buck4ran_pot_type), POINTER :: buck4r => NULL()
     359              :       TYPE(buckmorse_pot_type), POINTER :: buckmo => NULL()
     360              :       TYPE(tersoff_pot_type), POINTER :: tersoff => NULL()
     361              :       TYPE(siepmann_pot_type), POINTER :: siepmann => NULL()
     362              :       TYPE(gal_pot_type), POINTER :: gal => NULL()
     363              :       TYPE(gal21_pot_type), POINTER :: gal21 => NULL()
     364              :       TYPE(ftd_pot_type), POINTER :: ftd => NULL()
     365              :       TYPE(tab_pot_type), POINTER :: tab => NULL()
     366              :    END TYPE pot_set_type
     367              : 
     368              : ! **************************************************************************************************
     369              :    TYPE pair_potential_single_type
     370              :       REAL(KIND=dp) :: rcutsq = 0.0_dp
     371              :       REAL(KIND=dp) :: e_fac = 0.0_dp
     372              :       REAL(KIND=dp) :: e_fcc = 0.0_dp
     373              :       REAL(KIND=dp) :: e_fcs = 0.0_dp
     374              :       REAL(KIND=dp) :: e_fsc = 0.0_dp
     375              :       REAL(KIND=dp) :: z1 = 0.0_dp
     376              :       REAL(KIND=dp) :: z2 = 0.0_dp
     377              :       REAL(KIND=dp), DIMENSION(0:5) :: zbl_poly = 0.0_dp
     378              :       REAL(KIND=dp), DIMENSION(2) :: zbl_rcut = 0.0_dp
     379              :       LOGICAL        :: undef = .FALSE., & ! non-bonding interaction not defined
     380              :                         no_mb = .FALSE., & ! no many-body potential
     381              :                         no_pp = .FALSE. ! no pair (=two-body) potential
     382              :       INTEGER        :: shell_type = 0
     383              :       CHARACTER(LEN=default_string_length)   :: at1 = ""
     384              :       CHARACTER(LEN=default_string_length)   :: at2 = ""
     385              :       INTEGER, POINTER, DIMENSION(:)              :: TYPE => NULL()
     386              :       TYPE(pot_set_type), POINTER, DIMENSION(:) :: set => NULL()
     387              :       TYPE(spline_data_p_type), POINTER, DIMENSION(:) :: pair_spline_data => NULL()
     388              :       TYPE(spline_factor_type), POINTER :: spl_f => NULL()
     389              :    END TYPE pair_potential_single_type
     390              : 
     391              : ! **************************************************************************************************
     392              :    TYPE pair_potential_type
     393              :       TYPE(pair_potential_single_type), POINTER :: pot => NULL()
     394              :    END TYPE pair_potential_type
     395              : 
     396              : ! **************************************************************************************************
     397              :    TYPE pair_potential_p_type
     398              :       TYPE(pair_potential_type), DIMENSION(:), POINTER :: pot => NULL()
     399              :    END TYPE pair_potential_p_type
     400              : 
     401              : ! **************************************************************************************************
     402              :    TYPE pair_potential_pp_type
     403              :       TYPE(pair_potential_type), DIMENSION(:, :), POINTER :: pot => NULL()
     404              :    END TYPE pair_potential_pp_type
     405              : 
     406              : CONTAINS
     407              : 
     408              : ! **************************************************************************************************
     409              : !> \brief compare two different potentials
     410              : !> \param pot1 ...
     411              : !> \param pot2 ...
     412              : !> \param compare ...
     413              : !> \author Teodoro Laino [teo] 05.2006
     414              : ! **************************************************************************************************
     415           68 :    SUBROUTINE compare_pot(pot1, pot2, compare)
     416              :       TYPE(pair_potential_single_type), POINTER          :: pot1, pot2
     417              :       LOGICAL, INTENT(OUT)                               :: compare
     418              : 
     419              :       INTEGER                                            :: i
     420              :       LOGICAL                                            :: mycompare
     421              : 
     422           68 :       compare = .FALSE.
     423              :       ! Preliminary checks
     424              : 
     425           68 :       CPASSERT(ASSOCIATED(pot1%type))
     426           68 :       CPASSERT(ASSOCIATED(pot2%type))
     427           68 :       IF (SIZE(pot1%type) /= SIZE(pot2%type)) RETURN
     428          136 :       IF (ANY(pot1%type /= pot2%type)) RETURN
     429              : 
     430              :       ! Checking the real values of parameters
     431           68 :       CPASSERT(ASSOCIATED(pot1%set))
     432           68 :       CPASSERT(ASSOCIATED(pot2%set))
     433          136 :       DO i = 1, SIZE(pot1%type)
     434           68 :          mycompare = .FALSE.
     435           68 :          SELECT CASE (pot1%type(i))
     436              :          CASE (lj_type, lj_charmm_type)
     437              :             IF ((pot1%set(i)%lj%epsilon == pot2%set(i)%lj%epsilon) .AND. &
     438            0 :                 (pot1%set(i)%lj%sigma6 == pot2%set(i)%lj%sigma6) .AND. &
     439            0 :                 (pot1%set(i)%lj%sigma12 == pot2%set(i)%lj%sigma12)) mycompare = .TRUE.
     440              :          CASE (wl_type)
     441              :             IF ((pot1%set(i)%willis%a == pot2%set(i)%willis%a) .AND. &
     442            0 :                 (pot1%set(i)%willis%b == pot2%set(i)%willis%b) .AND. &
     443            0 :                 (pot1%set(i)%willis%c == pot2%set(i)%willis%c)) mycompare = .TRUE.
     444              :          CASE (gw_type)
     445              :             IF ((pot1%set(i)%goodwin%vr0 == pot2%set(i)%goodwin%vr0) .AND. &
     446              :                 (pot1%set(i)%goodwin%m == pot2%set(i)%goodwin%m) .AND. &
     447              :                 (pot1%set(i)%goodwin%mc == pot2%set(i)%goodwin%mc) .AND. &
     448            0 :                 (pot1%set(i)%goodwin%d == pot2%set(i)%goodwin%d) .AND. &
     449            0 :                 (pot1%set(i)%goodwin%dc == pot2%set(i)%goodwin%dc)) mycompare = .TRUE.
     450              :          CASE (ea_type)
     451              :             ! Compare only if EAM have the same number of points
     452           20 :             IF (pot1%set(i)%eam%npoints == pot2%set(i)%eam%npoints) THEN
     453              :                IF ((pot1%set(i)%eam%drar == pot2%set(i)%eam%drar) .AND. &
     454              :                    (pot1%set(i)%eam%drhoar == pot2%set(i)%eam%drhoar) .AND. &
     455              :                    (pot1%set(i)%eam%acutal == pot2%set(i)%eam%acutal) .AND. &
     456              :                    (SUM(ABS(pot1%set(i)%eam%rho - pot2%set(i)%eam%rho)) == 0.0_dp) .AND. &
     457              :                    (SUM(ABS(pot1%set(i)%eam%phi - pot2%set(i)%eam%phi)) == 0.0_dp) .AND. &
     458              :                    (SUM(ABS(pot1%set(i)%eam%frho - pot2%set(i)%eam%frho)) == 0.0_dp) .AND. &
     459              :                    (SUM(ABS(pot1%set(i)%eam%rhoval - pot2%set(i)%eam%rhoval)) == 0.0_dp) .AND. &
     460              :                    (SUM(ABS(pot1%set(i)%eam%rval - pot2%set(i)%eam%rval)) == 0.0_dp) .AND. &
     461              :                    (SUM(ABS(pot1%set(i)%eam%rhop - pot2%set(i)%eam%rhop)) == 0.0_dp) .AND. &
     462       512020 :                    (SUM(ABS(pot1%set(i)%eam%phip - pot2%set(i)%eam%phip)) == 0.0_dp) .AND. &
     463           16 :                    (SUM(ABS(pot1%set(i)%eam%frhop - pot2%set(i)%eam%frhop)) == 0.0_dp)) mycompare = .TRUE.
     464              :             END IF
     465              :          CASE (ace_type)
     466            0 :             IF ((pot1%set(i)%ace%ace_file_name == pot2%set(i)%ace%ace_file_name) .AND. &
     467            0 :                 (pot1%set(i)%ace%atom_ace_type == pot2%set(i)%ace%atom_ace_type)) mycompare = .TRUE.
     468              :          CASE (deepmd_type)
     469            0 :             IF ((pot1%set(i)%deepmd%deepmd_file_name == pot2%set(i)%deepmd%deepmd_file_name) .AND. &
     470            0 :                 (pot1%set(i)%deepmd%atom_deepmd_type == pot2%set(i)%deepmd%atom_deepmd_type)) mycompare = .TRUE.
     471              :          CASE (nequip_type, allegro_type)
     472              :             IF ((pot1%set(i)%nequip%pot_file_name == pot2%set(i)%nequip%pot_file_name) .AND. &
     473              :                 (pot1%set(i)%nequip%unit_length == pot2%set(i)%nequip%unit_length) .AND. &
     474            0 :                 (pot1%set(i)%nequip%unit_forces == pot2%set(i)%nequip%unit_forces) .AND. &
     475            0 :                 (pot1%set(i)%nequip%unit_energy == pot2%set(i)%nequip%unit_energy)) mycompare = .TRUE.
     476              :          CASE (ft_type)
     477              :             IF ((pot1%set(i)%ft%A == pot2%set(i)%ft%A) .AND. &
     478              :                 (pot1%set(i)%ft%B == pot2%set(i)%ft%B) .AND. &
     479            0 :                 (pot1%set(i)%ft%C == pot2%set(i)%ft%C) .AND. &
     480            0 :                 (pot1%set(i)%ft%D == pot2%set(i)%ft%D)) mycompare = .TRUE.
     481              :          CASE (ftd_type)
     482              :             IF ((pot1%set(i)%ftd%A == pot2%set(i)%ftd%A) .AND. &
     483              :                 (pot1%set(i)%ftd%B == pot2%set(i)%ftd%B) .AND. &
     484              :                 (pot1%set(i)%ftd%C == pot2%set(i)%ftd%C) .AND. &
     485            0 :                 (pot1%set(i)%ftd%D == pot2%set(i)%ftd%D) .AND. &
     486            0 :                 (ALL(pot1%set(i)%ftd%BD(:) == pot2%set(i)%ftd%BD(:)))) mycompare = .TRUE.
     487              :          CASE (ip_type)
     488              :             IF ((SUM(ABS(pot1%set(i)%ipbv%a - pot2%set(i)%ipbv%a)) == 0.0_dp) .AND. &
     489              :                 (pot1%set(i)%ipbv%rcore == pot2%set(i)%ipbv%rcore) .AND. &
     490          720 :                 (pot1%set(i)%ipbv%m == pot2%set(i)%ipbv%m) .AND. &
     491           16 :                 (pot1%set(i)%ipbv%b == pot2%set(i)%ipbv%b)) mycompare = .TRUE.
     492              :          CASE (tersoff_type)
     493              :             IF ((pot1%set(i)%tersoff%A == pot2%set(i)%tersoff%A) .AND. &
     494              :                 (pot1%set(i)%tersoff%B == pot2%set(i)%tersoff%B) .AND. &
     495              :                 (pot1%set(i)%tersoff%lambda1 == pot2%set(i)%tersoff%lambda1) .AND. &
     496              :                 (pot1%set(i)%tersoff%lambda2 == pot2%set(i)%tersoff%lambda2) .AND. &
     497              :                 (pot1%set(i)%tersoff%alpha == pot2%set(i)%tersoff%alpha) .AND. &
     498              :                 (pot1%set(i)%tersoff%beta == pot2%set(i)%tersoff%beta) .AND. &
     499              :                 (pot1%set(i)%tersoff%n == pot2%set(i)%tersoff%n) .AND. &
     500              :                 (pot1%set(i)%tersoff%c == pot2%set(i)%tersoff%c) .AND. &
     501              :                 (pot1%set(i)%tersoff%d == pot2%set(i)%tersoff%d) .AND. &
     502              :                 (pot1%set(i)%tersoff%h == pot2%set(i)%tersoff%h) .AND. &
     503              :                 (pot1%set(i)%tersoff%lambda3 == pot2%set(i)%tersoff%lambda3) .AND. &
     504              :                 (pot1%set(i)%tersoff%rcutsq == pot2%set(i)%tersoff%rcutsq) .AND. &
     505            0 :                 (pot1%set(i)%tersoff%bigR == pot2%set(i)%tersoff%bigR) .AND. &
     506            0 :                 (pot1%set(i)%tersoff%bigD == pot2%set(i)%tersoff%bigD)) mycompare = .TRUE.
     507              :          CASE (siepmann_type)
     508              :             IF ((pot1%set(i)%siepmann%B == pot2%set(i)%siepmann%B) .AND. &
     509              :                 (pot1%set(i)%siepmann%D == pot2%set(i)%siepmann%D) .AND. &
     510              :                 (pot1%set(i)%siepmann%E == pot2%set(i)%siepmann%E) .AND. &
     511              :                 (pot1%set(i)%siepmann%F == pot2%set(i)%siepmann%F) .AND. &
     512              :                 (pot1%set(i)%siepmann%beta == pot2%set(i)%siepmann%beta) .AND. &
     513              :                 (pot1%set(i)%siepmann%rcutsq == pot2%set(i)%siepmann%rcutsq) .AND. &
     514              :                 (pot1%set(i)%siepmann%allow_oh_formation .EQV. &
     515              :                  pot2%set(i)%siepmann%allow_oh_formation) .AND. &
     516              :                 (pot1%set(i)%siepmann%allow_o_formation .EQV. &
     517            0 :                  pot2%set(i)%siepmann%allow_o_formation) .AND. &
     518              :                 (pot1%set(i)%siepmann%allow_h3o_formation .EQV. &
     519            0 :                  pot2%set(i)%siepmann%allow_h3o_formation)) mycompare = .TRUE.
     520              :          CASE (gal_type)
     521              :             IF ((pot1%set(i)%gal%epsilon == pot2%set(i)%gal%epsilon) .AND. &
     522              :                 (pot1%set(i)%gal%bxy == pot2%set(i)%gal%bxy) .AND. &
     523              :                 (pot1%set(i)%gal%bz == pot2%set(i)%gal%bz) .AND. &
     524              :                 (pot1%set(i)%gal%r1 == pot2%set(i)%gal%r1) .AND. &
     525              :                 (pot1%set(i)%gal%r2 == pot2%set(i)%gal%r2) .AND. &
     526              :                 (pot1%set(i)%gal%a1 == pot2%set(i)%gal%a1) .AND. &
     527              :                 (pot1%set(i)%gal%a2 == pot2%set(i)%gal%a2) .AND. &
     528              :                 (pot1%set(i)%gal%a3 == pot2%set(i)%gal%a3) .AND. &
     529              :                 (pot1%set(i)%gal%a4 == pot2%set(i)%gal%a4) .AND. &
     530              :                 (pot1%set(i)%gal%a == pot2%set(i)%gal%a) .AND. &
     531              :                 (pot1%set(i)%gal%b == pot2%set(i)%gal%b) .AND. &
     532              :                 (pot1%set(i)%gal%c == pot2%set(i)%gal%c) .AND. &
     533              :                 (pot1%set(i)%gal%express .EQV. &
     534            0 :                  pot2%set(i)%gal%express) .AND. &
     535            0 :                 (pot1%set(i)%gal%rcutsq == pot2%set(i)%gal%rcutsq)) mycompare = .TRUE.
     536              :          CASE (gal21_type)
     537              :             IF ((pot1%set(i)%gal21%epsilon1 == pot2%set(i)%gal21%epsilon1) .AND. &
     538              :                 (pot1%set(i)%gal21%epsilon2 == pot2%set(i)%gal21%epsilon2) .AND. &
     539              :                 (pot1%set(i)%gal21%epsilon3 == pot2%set(i)%gal21%epsilon3) .AND. &
     540              :                 (pot1%set(i)%gal21%bxy1 == pot2%set(i)%gal21%bxy1) .AND. &
     541              :                 (pot1%set(i)%gal21%bxy2 == pot2%set(i)%gal21%bxy1) .AND. &
     542              :                 (pot1%set(i)%gal21%bz1 == pot2%set(i)%gal21%bz1) .AND. &
     543              :                 (pot1%set(i)%gal21%bz2 == pot2%set(i)%gal21%bz2) .AND. &
     544              :                 (pot1%set(i)%gal21%r1 == pot2%set(i)%gal21%r1) .AND. &
     545              :                 (pot1%set(i)%gal21%r2 == pot2%set(i)%gal21%r2) .AND. &
     546              :                 (pot1%set(i)%gal21%a11 == pot2%set(i)%gal21%a11) .AND. &
     547              :                 (pot1%set(i)%gal21%a12 == pot2%set(i)%gal21%a12) .AND. &
     548              :                 (pot1%set(i)%gal21%a13 == pot2%set(i)%gal21%a13) .AND. &
     549              :                 (pot1%set(i)%gal21%a21 == pot2%set(i)%gal21%a21) .AND. &
     550              :                 (pot1%set(i)%gal21%a22 == pot2%set(i)%gal21%a22) .AND. &
     551              :                 (pot1%set(i)%gal21%a23 == pot2%set(i)%gal21%a23) .AND. &
     552              :                 (pot1%set(i)%gal21%a31 == pot2%set(i)%gal21%a31) .AND. &
     553              :                 (pot1%set(i)%gal21%a32 == pot2%set(i)%gal21%a32) .AND. &
     554              :                 (pot1%set(i)%gal21%a33 == pot2%set(i)%gal21%a33) .AND. &
     555              :                 (pot1%set(i)%gal21%a41 == pot2%set(i)%gal21%a41) .AND. &
     556              :                 (pot1%set(i)%gal21%a42 == pot2%set(i)%gal21%a42) .AND. &
     557              :                 (pot1%set(i)%gal21%a43 == pot2%set(i)%gal21%a43) .AND. &
     558              :                 (pot1%set(i)%gal21%AO1 == pot2%set(i)%gal21%AO1) .AND. &
     559              :                 (pot1%set(i)%gal21%AO2 == pot2%set(i)%gal21%AO2) .AND. &
     560              :                 (pot1%set(i)%gal21%BO1 == pot2%set(i)%gal21%BO1) .AND. &
     561              :                 (pot1%set(i)%gal21%BO2 == pot2%set(i)%gal21%BO2) .AND. &
     562              :                 (pot1%set(i)%gal21%c == pot2%set(i)%gal21%c) .AND. &
     563              :                 (pot1%set(i)%gal21%AH1 == pot2%set(i)%gal21%AH1) .AND. &
     564              :                 (pot1%set(i)%gal21%AH2 == pot2%set(i)%gal21%AH2) .AND. &
     565              :                 (pot1%set(i)%gal21%BH1 == pot2%set(i)%gal21%BH1) .AND. &
     566              :                 (pot1%set(i)%gal21%BH2 == pot2%set(i)%gal21%BH2) .AND. &
     567              :                 (pot1%set(i)%gal21%express .EQV. &
     568            0 :                  pot2%set(i)%gal21%express) .AND. &
     569           68 :                 (pot1%set(i)%gal21%rcutsq == pot2%set(i)%gal21%rcutsq)) mycompare = .TRUE.
     570              : 
     571              :          END SELECT
     572              :          mycompare = mycompare .AND. &
     573           68 :                      (pot1%set(i)%rmin == pot2%set(i)%rmin) .AND. (pot1%set(i)%rmax == pot2%set(i)%rmax)
     574           68 :          IF ((mycompare) .AND. (i == 1)) compare = .TRUE.
     575          172 :          compare = compare .AND. mycompare
     576              :       END DO
     577              : 
     578              :    END SUBROUTINE compare_pot
     579              : 
     580              : ! **************************************************************************************************
     581              : !> \brief Creates the potential parameter type
     582              : !> \param potparm ...
     583              : !> \param nset ...
     584              : !> \author Teodoro Laino [teo] 11.2005
     585              : ! **************************************************************************************************
     586       525582 :    SUBROUTINE pair_potential_single_create(potparm, nset)
     587              :       TYPE(pair_potential_single_type), POINTER          :: potparm
     588              :       INTEGER, INTENT(IN), OPTIONAL                      :: nset
     589              : 
     590              :       INTEGER                                            :: i, lnset
     591              : 
     592       525582 :       CPASSERT(.NOT. ASSOCIATED(potparm))
     593      5781402 :       ALLOCATE (potparm)
     594       525582 :       lnset = 1
     595       525582 :       IF (PRESENT(nset)) lnset = nset
     596              :       ! Standard allocation to size 1
     597      1576746 :       ALLOCATE (potparm%type(lnset))
     598      2102336 :       ALLOCATE (potparm%set(lnset))
     599              :       NULLIFY (potparm%spl_f, &
     600       525582 :                potparm%pair_spline_data)
     601      1051172 :       DO i = 1, lnset
     602       525590 :          potparm%set(i)%rmin = not_initialized
     603       525590 :          potparm%set(i)%rmax = not_initialized
     604              :          NULLIFY (potparm%set(i)%ipbv, &
     605       525590 :                   potparm%set(i)%lj, &
     606       525590 :                   potparm%set(i)%gp, &
     607       525590 :                   potparm%set(i)%ft, &
     608       525590 :                   potparm%set(i)%willis, &
     609       525590 :                   potparm%set(i)%goodwin, &
     610       525590 :                   potparm%set(i)%eam, &
     611       525590 :                   potparm%set(i)%nequip, &
     612       525590 :                   potparm%set(i)%ace, &
     613       525590 :                   potparm%set(i)%deepmd, &
     614       525590 :                   potparm%set(i)%buck4r, &
     615       525590 :                   potparm%set(i)%buckmo, &
     616       525590 :                   potparm%set(i)%tersoff, &
     617       525590 :                   potparm%set(i)%siepmann, &
     618       525590 :                   potparm%set(i)%gal, &
     619       525590 :                   potparm%set(i)%gal21, &
     620       525590 :                   potparm%set(i)%ftd, &
     621      1051172 :                   potparm%set(i)%tab)
     622              :       END DO
     623       525582 :       CALL pair_potential_single_clean(potparm)
     624       525582 :    END SUBROUTINE pair_potential_single_create
     625              : 
     626              : ! **************************************************************************************************
     627              : !> \brief Cleans the potential parameter type
     628              : !> \param potparm ...
     629              : !> \author unknown
     630              : ! **************************************************************************************************
     631       569741 :    SUBROUTINE pair_potential_single_clean(potparm)
     632              :       TYPE(pair_potential_single_type), POINTER          :: potparm
     633              : 
     634              :       INTEGER                                            :: i
     635              : 
     636      1139490 :       potparm%type = nn_type
     637       569741 :       potparm%shell_type = nosh_nosh
     638       569741 :       potparm%undef = .TRUE.
     639       569741 :       potparm%no_pp = .FALSE.
     640       569741 :       potparm%no_mb = .FALSE.
     641       569741 :       potparm%at1 = 'NULL'
     642       569741 :       potparm%at2 = 'NULL'
     643       569741 :       potparm%rcutsq = 0.0_dp
     644       569741 :       IF (ASSOCIATED(potparm%pair_spline_data)) &
     645            0 :          CALL spline_data_p_release(potparm%pair_spline_data)
     646       569741 :       IF (ASSOCIATED(potparm%spl_f)) &
     647            0 :          CALL spline_factor_release(potparm%spl_f)
     648              : 
     649      1139490 :       DO i = 1, SIZE(potparm%type)
     650       569749 :          potparm%set(i)%rmin = not_initialized
     651       569749 :          potparm%set(i)%rmax = not_initialized
     652       569749 :          CALL pair_potential_lj_clean(potparm%set(i)%lj)
     653       569749 :          CALL pair_potential_williams_clean(potparm%set(i)%willis)
     654       569749 :          CALL pair_potential_goodwin_clean(potparm%set(i)%goodwin)
     655       569749 :          CALL pair_potential_eam_clean(potparm%set(i)%eam)
     656       569749 :          CALL pair_potential_nequip_clean(potparm%set(i)%nequip)
     657       569749 :          CALL pair_potential_ace_clean(potparm%set(i)%ace)
     658       569749 :          CALL pair_potential_deepmd_clean(potparm%set(i)%deepmd)
     659       569749 :          CALL pair_potential_buck4r_clean(potparm%set(i)%buck4r)
     660       569749 :          CALL pair_potential_buckmo_clean(potparm%set(i)%buckmo)
     661       569749 :          CALL pair_potential_bmhft_clean(potparm%set(i)%ft)
     662       569749 :          CALL pair_potential_bmhftd_clean(potparm%set(i)%ftd)
     663       569749 :          CALL pair_potential_ipbv_clean(potparm%set(i)%ipbv)
     664       569749 :          CALL pair_potential_gp_clean(potparm%set(i)%gp)
     665       569749 :          CALL pair_potential_tersoff_clean(potparm%set(i)%tersoff)
     666       569749 :          CALL pair_potential_siepmann_clean(potparm%set(i)%siepmann)
     667       569749 :          CALL pair_potential_gal_clean(potparm%set(i)%gal)
     668       569749 :          CALL pair_potential_gal21_clean(potparm%set(i)%gal21)
     669      1139490 :          CALL pair_potential_tab_clean(potparm%set(i)%tab)
     670              :       END DO
     671       569741 :    END SUBROUTINE pair_potential_single_clean
     672              : 
     673              : ! **************************************************************************************************
     674              : !> \brief Copy two potential parameter type
     675              : !> \param potparm_source ...
     676              : !> \param potparm_dest ...
     677              : !> \author Teodoro Laino [teo] 11.2005
     678              : ! **************************************************************************************************
     679        12408 :    SUBROUTINE pair_potential_single_copy(potparm_source, potparm_dest)
     680              :       TYPE(pair_potential_single_type), POINTER          :: potparm_source, potparm_dest
     681              : 
     682              :       INTEGER                                            :: i
     683              : 
     684        12408 :       CPASSERT(ASSOCIATED(potparm_source))
     685        12408 :       IF (.NOT. ASSOCIATED(potparm_dest)) THEN
     686            8 :          CALL pair_potential_single_create(potparm_dest, SIZE(potparm_source%type))
     687              :       ELSE
     688        12400 :          CALL pair_potential_single_clean(potparm_dest)
     689              :       END IF
     690        49632 :       potparm_dest%type = potparm_source%type
     691        12408 :       potparm_dest%shell_type = potparm_source%shell_type
     692        12408 :       potparm_dest%undef = potparm_source%undef
     693        12408 :       potparm_dest%no_mb = potparm_source%no_mb
     694        12408 :       potparm_dest%no_pp = potparm_source%no_pp
     695        12408 :       potparm_dest%at1 = potparm_source%at1
     696        12408 :       potparm_dest%at2 = potparm_source%at2
     697        12408 :       potparm_dest%rcutsq = potparm_source%rcutsq
     698        12408 :       IF (ASSOCIATED(potparm_source%pair_spline_data)) THEN
     699            0 :          CALL spline_data_p_copy(potparm_source%pair_spline_data, potparm_dest%pair_spline_data)
     700              :       END IF
     701              : 
     702        12408 :       IF (ASSOCIATED(potparm_source%spl_f)) THEN
     703            0 :          CALL spline_factor_copy(potparm_source%spl_f, potparm_dest%spl_f)
     704              :       END IF
     705              : 
     706        24816 :       DO i = 1, SIZE(potparm_source%type)
     707        12408 :          potparm_dest%set(i)%rmin = potparm_source%set(i)%rmin
     708        12408 :          potparm_dest%set(i)%rmax = potparm_source%set(i)%rmax
     709        12408 :          CALL pair_potential_lj_copy(potparm_source%set(i)%lj, potparm_dest%set(i)%lj)
     710        12408 :          CALL pair_potential_williams_copy(potparm_source%set(i)%willis, potparm_dest%set(i)%willis)
     711        12408 :          CALL pair_potential_goodwin_copy(potparm_source%set(i)%goodwin, potparm_dest%set(i)%goodwin)
     712        12408 :          CALL pair_potential_eam_copy(potparm_source%set(i)%eam, potparm_dest%set(i)%eam)
     713        12408 :          CALL pair_potential_nequip_copy(potparm_source%set(i)%nequip, potparm_dest%set(i)%nequip)
     714        12408 :          CALL pair_potential_ace_copy(potparm_source%set(i)%ace, potparm_dest%set(i)%ace)
     715        12408 :          CALL pair_potential_deepmd_copy(potparm_source%set(i)%deepmd, potparm_dest%set(i)%deepmd)
     716        12408 :          CALL pair_potential_bmhft_copy(potparm_source%set(i)%ft, potparm_dest%set(i)%ft)
     717        12408 :          CALL pair_potential_bmhftd_copy(potparm_source%set(i)%ftd, potparm_dest%set(i)%ftd)
     718        12408 :          CALL pair_potential_ipbv_copy(potparm_source%set(i)%ipbv, potparm_dest%set(i)%ipbv)
     719        12408 :          CALL pair_potential_buck4r_copy(potparm_source%set(i)%buck4r, potparm_dest%set(i)%buck4r)
     720        12408 :          CALL pair_potential_buckmo_copy(potparm_source%set(i)%buckmo, potparm_dest%set(i)%buckmo)
     721        12408 :          CALL pair_potential_gp_copy(potparm_source%set(i)%gp, potparm_dest%set(i)%gp)
     722        12408 :          CALL pair_potential_tersoff_copy(potparm_source%set(i)%tersoff, potparm_dest%set(i)%tersoff)
     723        12408 :          CALL pair_potential_siepmann_copy(potparm_source%set(i)%siepmann, potparm_dest%set(i)%siepmann)
     724        12408 :          CALL pair_potential_gal_copy(potparm_source%set(i)%gal, potparm_dest%set(i)%gal)
     725        12408 :          CALL pair_potential_gal21_copy(potparm_source%set(i)%gal21, potparm_dest%set(i)%gal21)
     726        24816 :          CALL pair_potential_tab_copy(potparm_source%set(i)%tab, potparm_dest%set(i)%tab)
     727              :       END DO
     728        12408 :    END SUBROUTINE pair_potential_single_copy
     729              : 
     730              : ! **************************************************************************************************
     731              : !> \brief Add potential parameter type to an existing potential parameter type
     732              : !>      Used in case of multiple_potential definition
     733              : !> \param potparm_source ...
     734              : !> \param potparm_dest ...
     735              : !> \author Teodoro Laino [teo] 11.2005
     736              : ! **************************************************************************************************
     737           38 :    SUBROUTINE pair_potential_single_add(potparm_source, potparm_dest)
     738              :       TYPE(pair_potential_single_type), POINTER          :: potparm_source, potparm_dest
     739              : 
     740              :       INTEGER                                            :: i, j, size_dest, size_source
     741              :       LOGICAL                                            :: allocate_new, check
     742              :       TYPE(pair_potential_single_type), POINTER          :: potparm_tmp
     743              : 
     744           38 :       CPASSERT(ASSOCIATED(potparm_source))
     745              :       ! At this level we expect all splines types
     746              :       ! be not allocated.. No sense add splines at this level.. in case fail!
     747              :       check = (.NOT. ASSOCIATED(potparm_source%pair_spline_data)) .AND. &
     748           38 :               (.NOT. ASSOCIATED(potparm_source%spl_f))
     749            0 :       CPASSERT(check)
     750              :       check = (.NOT. ASSOCIATED(potparm_dest%pair_spline_data)) .AND. &
     751           38 :               (.NOT. ASSOCIATED(potparm_dest%spl_f))
     752            0 :       CPASSERT(check)
     753              :       ! Increase the size of the destination potparm (in case) and copy the new data
     754           38 :       size_source = SIZE(potparm_source%type)
     755           38 :       allocate_new = .NOT. ASSOCIATED(potparm_dest)
     756           38 :       IF (.NOT. allocate_new) THEN
     757           38 :          size_dest = SIZE(potparm_dest%type)
     758           38 :          IF (size_dest == 1) THEN
     759              :             check = (ASSOCIATED(potparm_dest%set(1)%lj)) .OR. &
     760              :                     (ASSOCIATED(potparm_dest%set(1)%willis)) .OR. &
     761              :                     (ASSOCIATED(potparm_dest%set(1)%goodwin)) .OR. &
     762              :                     (ASSOCIATED(potparm_dest%set(1)%eam)) .OR. &
     763              :                     (ASSOCIATED(potparm_dest%set(1)%nequip)) .OR. &
     764              :                     (ASSOCIATED(potparm_dest%set(1)%ace)) .OR. &
     765              :                     (ASSOCIATED(potparm_dest%set(1)%deepmd)) .OR. &
     766              :                     (ASSOCIATED(potparm_dest%set(1)%ft)) .OR. &
     767              :                     (ASSOCIATED(potparm_dest%set(1)%ftd)) .OR. &
     768              :                     (ASSOCIATED(potparm_dest%set(1)%ipbv)) .OR. &
     769              :                     (ASSOCIATED(potparm_dest%set(1)%buck4r)) .OR. &
     770              :                     (ASSOCIATED(potparm_dest%set(1)%buckmo)) .OR. &
     771              :                     (ASSOCIATED(potparm_dest%set(1)%gp)) .OR. &
     772              :                     (ASSOCIATED(potparm_dest%set(1)%tersoff)) .OR. &
     773              :                     (ASSOCIATED(potparm_dest%set(1)%siepmann)) .OR. &
     774              :                     (ASSOCIATED(potparm_dest%set(1)%gal)) .OR. &
     775              :                     (ASSOCIATED(potparm_dest%set(1)%gal)) .OR. &
     776           38 :                     (ASSOCIATED(potparm_dest%set(1)%tab))
     777              :             IF (.NOT. check) THEN
     778           30 :                allocate_new = .TRUE.
     779           30 :                CALL pair_potential_single_release(potparm_dest)
     780              :             END IF
     781              :          END IF
     782              :       END IF
     783            8 :       IF (allocate_new) THEN
     784           30 :          size_dest = 0
     785           30 :          CALL pair_potential_single_create(potparm_dest, size_source)
     786           30 :          potparm_dest%shell_type = potparm_source%shell_type
     787           30 :          potparm_dest%undef = potparm_source%undef
     788           30 :          potparm_dest%no_mb = potparm_source%no_mb
     789           30 :          potparm_dest%no_pp = potparm_source%no_pp
     790           30 :          potparm_dest%at1 = potparm_source%at1
     791           30 :          potparm_dest%at2 = potparm_source%at2
     792           30 :          potparm_dest%rcutsq = potparm_source%rcutsq
     793              :       ELSE
     794            8 :          size_dest = SIZE(potparm_dest%type)
     795            8 :          NULLIFY (potparm_tmp)
     796            8 :          CALL pair_potential_single_copy(potparm_dest, potparm_tmp)
     797            8 :          CALL pair_potential_single_release(potparm_dest)
     798            8 :          CALL pair_potential_single_create(potparm_dest, size_dest + size_source)
     799              :          ! Copy back original informations..
     800            8 :          potparm_dest%shell_type = potparm_tmp%shell_type
     801            8 :          potparm_dest%undef = potparm_tmp%undef
     802            8 :          potparm_dest%no_mb = potparm_tmp%no_mb
     803            8 :          potparm_dest%no_pp = potparm_tmp%no_pp
     804            8 :          potparm_dest%at1 = potparm_tmp%at1
     805            8 :          potparm_dest%at2 = potparm_tmp%at2
     806            8 :          potparm_dest%rcutsq = potparm_tmp%rcutsq
     807           16 :          DO i = 1, size_dest
     808            8 :             potparm_dest%type(i) = potparm_tmp%type(i)
     809            8 :             potparm_dest%set(i)%rmin = potparm_tmp%set(i)%rmin
     810            8 :             potparm_dest%set(i)%rmax = potparm_tmp%set(i)%rmax
     811            8 :             CALL pair_potential_lj_copy(potparm_tmp%set(i)%lj, potparm_dest%set(i)%lj)
     812            8 :             CALL pair_potential_williams_copy(potparm_tmp%set(i)%willis, potparm_dest%set(i)%willis)
     813            8 :             CALL pair_potential_goodwin_copy(potparm_tmp%set(i)%goodwin, potparm_dest%set(i)%goodwin)
     814            8 :             CALL pair_potential_eam_copy(potparm_tmp%set(i)%eam, potparm_dest%set(i)%eam)
     815            8 :             CALL pair_potential_nequip_copy(potparm_tmp%set(i)%nequip, potparm_dest%set(i)%nequip)
     816            8 :             CALL pair_potential_ace_copy(potparm_tmp%set(i)%ace, potparm_dest%set(i)%ace)
     817            8 :             CALL pair_potential_deepmd_copy(potparm_tmp%set(i)%deepmd, potparm_dest%set(i)%deepmd)
     818            8 :             CALL pair_potential_bmhft_copy(potparm_tmp%set(i)%ft, potparm_dest%set(i)%ft)
     819            8 :             CALL pair_potential_bmhftd_copy(potparm_tmp%set(i)%ftd, potparm_dest%set(i)%ftd)
     820            8 :             CALL pair_potential_ipbv_copy(potparm_tmp%set(i)%ipbv, potparm_dest%set(i)%ipbv)
     821            8 :             CALL pair_potential_buck4r_copy(potparm_tmp%set(i)%buck4r, potparm_dest%set(i)%buck4r)
     822            8 :             CALL pair_potential_buckmo_copy(potparm_tmp%set(i)%buckmo, potparm_dest%set(i)%buckmo)
     823            8 :             CALL pair_potential_gp_copy(potparm_tmp%set(i)%gp, potparm_dest%set(i)%gp)
     824            8 :             CALL pair_potential_tersoff_copy(potparm_tmp%set(i)%tersoff, potparm_dest%set(i)%tersoff)
     825            8 :             CALL pair_potential_siepmann_copy(potparm_tmp%set(i)%siepmann, potparm_dest%set(i)%siepmann)
     826            8 :             CALL pair_potential_gal_copy(potparm_tmp%set(i)%gal, potparm_dest%set(i)%gal)
     827            8 :             CALL pair_potential_gal21_copy(potparm_tmp%set(i)%gal21, potparm_dest%set(i)%gal21)
     828           16 :             CALL pair_potential_tab_copy(potparm_tmp%set(i)%tab, potparm_dest%set(i)%tab)
     829              :          END DO
     830            8 :          CALL pair_potential_single_release(potparm_tmp)
     831              :       END IF
     832              :       ! Further check with main option with source and dest (already filled with few informations)
     833              :       check = (potparm_dest%shell_type == potparm_source%shell_type) .AND. &
     834              :               (potparm_dest%undef .EQV. potparm_source%undef) .AND. &
     835              :               (potparm_dest%no_mb .EQV. potparm_source%no_mb) .AND. &
     836              :               (potparm_dest%no_pp .EQV. potparm_source%no_pp) .AND. &
     837              :               (potparm_dest%at1 == potparm_source%at1) .AND. &
     838              :               (potparm_dest%at2 == potparm_source%at2) .AND. &
     839           38 :               (potparm_dest%rcutsq == potparm_source%rcutsq)
     840            0 :       CPASSERT(check)
     841              :       ! Now copy the new pair_potential type
     842           76 :       DO i = size_dest + 1, size_dest + size_source
     843           38 :          j = i - size_dest
     844           38 :          potparm_dest%type(i) = potparm_source%type(j)
     845           38 :          potparm_dest%set(i)%rmin = potparm_source%set(j)%rmin
     846           38 :          potparm_dest%set(i)%rmax = potparm_source%set(j)%rmax
     847           38 :          CALL pair_potential_lj_copy(potparm_source%set(j)%lj, potparm_dest%set(i)%lj)
     848           38 :          CALL pair_potential_williams_copy(potparm_source%set(j)%willis, potparm_dest%set(i)%willis)
     849           38 :          CALL pair_potential_goodwin_copy(potparm_source%set(j)%goodwin, potparm_dest%set(i)%goodwin)
     850           38 :          CALL pair_potential_eam_copy(potparm_source%set(j)%eam, potparm_dest%set(i)%eam)
     851           38 :          CALL pair_potential_nequip_copy(potparm_source%set(j)%nequip, potparm_dest%set(i)%nequip)
     852           38 :          CALL pair_potential_ace_copy(potparm_source%set(j)%ace, potparm_dest%set(i)%ace)
     853           38 :          CALL pair_potential_deepmd_copy(potparm_source%set(j)%deepmd, potparm_dest%set(i)%deepmd)
     854           38 :          CALL pair_potential_bmhft_copy(potparm_source%set(j)%ft, potparm_dest%set(i)%ft)
     855           38 :          CALL pair_potential_bmhftd_copy(potparm_source%set(j)%ftd, potparm_dest%set(i)%ftd)
     856           38 :          CALL pair_potential_ipbv_copy(potparm_source%set(j)%ipbv, potparm_dest%set(i)%ipbv)
     857           38 :          CALL pair_potential_buck4r_copy(potparm_source%set(j)%buck4r, potparm_dest%set(i)%buck4r)
     858           38 :          CALL pair_potential_buckmo_copy(potparm_source%set(j)%buckmo, potparm_dest%set(i)%buckmo)
     859           38 :          CALL pair_potential_gp_copy(potparm_source%set(j)%gp, potparm_dest%set(i)%gp)
     860           38 :          CALL pair_potential_tersoff_copy(potparm_source%set(j)%tersoff, potparm_dest%set(i)%tersoff)
     861           38 :          CALL pair_potential_siepmann_copy(potparm_source%set(j)%siepmann, potparm_dest%set(i)%siepmann)
     862           38 :          CALL pair_potential_gal_copy(potparm_source%set(j)%gal, potparm_dest%set(i)%gal)
     863           38 :          CALL pair_potential_gal21_copy(potparm_source%set(j)%gal21, potparm_dest%set(i)%gal21)
     864           76 :          CALL pair_potential_tab_copy(potparm_source%set(j)%tab, potparm_dest%set(i)%tab)
     865              :       END DO
     866           38 :    END SUBROUTINE pair_potential_single_add
     867              : 
     868              : ! **************************************************************************************************
     869              : !> \brief Release Data-structure that constains potential parameters of a single pair
     870              : !> \param potparm ...
     871              : !> \author Teodoro Laino [Teo] 11.2005
     872              : ! **************************************************************************************************
     873       525582 :    SUBROUTINE pair_potential_single_release(potparm)
     874              :       TYPE(pair_potential_single_type), POINTER          :: potparm
     875              : 
     876              :       INTEGER                                            :: i
     877              : 
     878       525582 :       CPASSERT(ASSOCIATED(potparm))
     879       525582 :       CALL spline_data_p_release(potparm%pair_spline_data)
     880       525582 :       CALL spline_factor_release(potparm%spl_f)
     881      1051172 :       DO i = 1, SIZE(potparm%type)
     882       525590 :          CALL pair_potential_ipbv_release(potparm%set(i)%ipbv)
     883       525590 :          CALL pair_potential_lj_release(potparm%set(i)%lj)
     884       525590 :          CALL pair_potential_bmhft_release(potparm%set(i)%ft)
     885       525590 :          CALL pair_potential_bmhftd_release(potparm%set(i)%ftd)
     886       525590 :          CALL pair_potential_williams_release(potparm%set(i)%willis)
     887       525590 :          CALL pair_potential_goodwin_release(potparm%set(i)%goodwin)
     888       525590 :          CALL pair_potential_eam_release(potparm%set(i)%eam)
     889       525590 :          CALL pair_potential_nequip_release(potparm%set(i)%nequip)
     890       525590 :          CALL pair_potential_ace_release(potparm%set(i)%ace)
     891       525590 :          CALL pair_potential_deepmd_release(potparm%set(i)%deepmd)
     892       525590 :          CALL pair_potential_buck4r_release(potparm%set(i)%buck4r)
     893       525590 :          CALL pair_potential_buckmo_release(potparm%set(i)%buckmo)
     894       525590 :          CALL pair_potential_gp_release(potparm%set(i)%gp)
     895       525590 :          CALL pair_potential_tersoff_release(potparm%set(i)%tersoff)
     896       525590 :          CALL pair_potential_siepmann_release(potparm%set(i)%siepmann)
     897       525590 :          CALL pair_potential_gal_release(potparm%set(i)%gal)
     898       525590 :          CALL pair_potential_gal21_release(potparm%set(i)%gal21)
     899      1051172 :          CALL pair_potential_tab_release(potparm%set(i)%tab)
     900              :       END DO
     901       525582 :       DEALLOCATE (potparm%type)
     902       525582 :       DEALLOCATE (potparm%set)
     903       525582 :       DEALLOCATE (potparm)
     904       525582 :    END SUBROUTINE pair_potential_single_release
     905              : 
     906              : ! **************************************************************************************************
     907              : !> \brief Data-structure that constains potential parameters
     908              : !> \param potparm ...
     909              : !> \param nkinds ...
     910              : !> \author unknown
     911              : ! **************************************************************************************************
     912         5272 :    SUBROUTINE pair_potential_pp_create(potparm, nkinds)
     913              :       TYPE(pair_potential_pp_type), POINTER              :: potparm
     914              :       INTEGER, INTENT(IN)                                :: nkinds
     915              : 
     916              :       INTEGER                                            :: i, j
     917              : 
     918         5272 :       CPASSERT(.NOT. ASSOCIATED(potparm))
     919         5272 :       ALLOCATE (potparm)
     920      1052512 :       ALLOCATE (potparm%pot(nkinds, nkinds))
     921        27782 :       DO i = 1, nkinds
     922      1036696 :          DO j = 1, nkinds
     923      1031424 :             NULLIFY (potparm%pot(i, j)%pot)
     924              :          END DO
     925              :       END DO
     926              :       ! Use no-redundancy in the potential definition
     927        27782 :       DO i = 1, nkinds
     928       543494 :          DO j = i, nkinds
     929       515712 :             CALL pair_potential_single_create(potparm%pot(i, j)%pot)
     930       538222 :             potparm%pot(j, i)%pot => potparm%pot(i, j)%pot
     931              :          END DO
     932              :       END DO
     933         5272 :    END SUBROUTINE pair_potential_pp_create
     934              : 
     935              : ! **************************************************************************************************
     936              : !> \brief Release Data-structure that constains potential parameters
     937              : !> \param potparm ...
     938              : !> \par History
     939              : !>      Teodoro Laino [Teo] 11.2005 : Reorganizing the structures to optimize
     940              : !>                                    memory management
     941              : !> \author unknown
     942              : ! **************************************************************************************************
     943         5368 :    SUBROUTINE pair_potential_pp_release(potparm)
     944              :       TYPE(pair_potential_pp_type), POINTER              :: potparm
     945              : 
     946              :       INTEGER                                            :: i, j
     947              : 
     948         5368 :       IF (ASSOCIATED(potparm)) THEN
     949         5272 :          IF (ASSOCIATED(potparm%pot)) THEN
     950        27782 :             DO i = 1, SIZE(potparm%pot, 1)
     951       543494 :                DO j = i, SIZE(potparm%pot, 2)
     952       515712 :                   CALL pair_potential_single_release(potparm%pot(i, j)%pot)
     953       538222 :                   NULLIFY (potparm%pot(j, i)%pot)
     954              :                END DO
     955              :             END DO
     956         5272 :             DEALLOCATE (potparm%pot)
     957              :          END IF
     958         5272 :          DEALLOCATE (potparm)
     959              :       END IF
     960         5368 :       NULLIFY (potparm)
     961         5368 :    END SUBROUTINE pair_potential_pp_release
     962              : 
     963              : ! **************************************************************************************************
     964              : !> \brief Data-structure that constains potential parameters
     965              : !> \param potparm ...
     966              : !> \param ndim ...
     967              : !> \param ub ...
     968              : !> \param lb ...
     969              : !> \author unknown
     970              : ! **************************************************************************************************
     971         2621 :    SUBROUTINE pair_potential_p_create(potparm, ndim, ub, lb)
     972              :       TYPE(pair_potential_p_type), POINTER               :: potparm
     973              :       INTEGER, INTENT(IN), OPTIONAL                      :: ndim, ub, lb
     974              : 
     975              :       INTEGER                                            :: i, loc_lb, loc_ub
     976              : 
     977         2621 :       CPASSERT(.NOT. ASSOCIATED(potparm))
     978         2621 :       ALLOCATE (potparm)
     979              : 
     980         2621 :       IF (PRESENT(ndim) .AND. (PRESENT(ub) .OR. PRESENT(lb))) THEN
     981              :          CALL cp_abort(__LOCATION__, &
     982              :                        "pair_potential_p_create expects either 1 input parameter <ndim> "// &
     983              :                        "or 2 input parameters <ub> and <lb> at each call; found <ndim> "// &
     984            0 :                        "together with <ub> or <lb>")
     985              :       END IF
     986              : 
     987              :       IF (PRESENT(ndim)) THEN
     988            0 :          loc_lb = 1
     989            0 :          loc_ub = ndim
     990            0 :          ALLOCATE (potparm%pot(loc_lb:loc_ub))
     991         2621 :       ELSE IF (PRESENT(lb) .AND. PRESENT(ub)) THEN
     992         2621 :          loc_lb = lb
     993         2621 :          loc_ub = ub
     994        17687 :          ALLOCATE (potparm%pot(loc_lb:loc_ub))
     995              :       ELSE
     996              :          CALL cp_abort(__LOCATION__, &
     997              :                        "pair_potential_p_create expects either 1 input parameter <ndim> "// &
     998            0 :                        "or 2 input parameters <ub> and <lb> at each call; found none")
     999              :       END IF
    1000        12445 :       DO i = loc_lb, loc_ub
    1001         9824 :          NULLIFY (potparm%pot(i)%pot)
    1002        12445 :          CALL pair_potential_single_create(potparm%pot(i)%pot)
    1003              :       END DO
    1004         2621 :    END SUBROUTINE pair_potential_p_create
    1005              : 
    1006              : ! **************************************************************************************************
    1007              : !> \brief Release Data-structure that constains potential parameters
    1008              : !> \param potparm ...
    1009              : !> \par History
    1010              : !>      Teodoro Laino [Teo] 11.2005 : Reorganizing the structures to optimize
    1011              : !>                                    memory management
    1012              : !> \author unknown
    1013              : ! **************************************************************************************************
    1014         2621 :    SUBROUTINE pair_potential_p_release(potparm)
    1015              :       TYPE(pair_potential_p_type), POINTER               :: potparm
    1016              : 
    1017              :       INTEGER                                            :: i
    1018              : 
    1019         2621 :       IF (ASSOCIATED(potparm)) THEN
    1020         2621 :          IF (ASSOCIATED(potparm%pot)) THEN
    1021        12445 :             DO i = 1, SIZE(potparm%pot)
    1022        12445 :                CALL pair_potential_single_release(potparm%pot(i)%pot)
    1023              :             END DO
    1024         2621 :             DEALLOCATE (potparm%pot)
    1025              :          END IF
    1026         2621 :          DEALLOCATE (potparm)
    1027              :       END IF
    1028         2621 :       NULLIFY (potparm)
    1029         2621 :    END SUBROUTINE pair_potential_p_release
    1030              : 
    1031              : ! **************************************************************************************************
    1032              : !> \brief Copy structures between two pair_potential_p_type
    1033              : !> \param source ...
    1034              : !> \param dest ...
    1035              : !> \param istart ...
    1036              : !> \param iend ...
    1037              : !> \author Teodoro Laino [Teo] 11.2005
    1038              : ! **************************************************************************************************
    1039          594 :    SUBROUTINE pair_potential_p_copy(source, dest, istart, iend)
    1040              :       TYPE(pair_potential_p_type), POINTER               :: source, dest
    1041              :       INTEGER, INTENT(IN), OPTIONAL                      :: istart, iend
    1042              : 
    1043              :       INTEGER                                            :: i, l_end, l_start
    1044              : 
    1045          594 :       CPASSERT(ASSOCIATED(source))
    1046          594 :       CPASSERT(ASSOCIATED(dest))
    1047          594 :       l_start = LBOUND(source%pot, 1)
    1048          594 :       l_end = UBOUND(source%pot, 1)
    1049          594 :       IF (PRESENT(istart)) l_start = istart
    1050          594 :       IF (PRESENT(iend)) l_end = iend
    1051         1900 :       DO i = l_start, l_end
    1052         1306 :          IF (.NOT. ASSOCIATED(source%pot(i)%pot)) &
    1053            0 :             CALL pair_potential_single_create(source%pot(i)%pot)
    1054         1900 :          CALL pair_potential_single_copy(source%pot(i)%pot, dest%pot(i)%pot)
    1055              :       END DO
    1056          594 :    END SUBROUTINE pair_potential_p_copy
    1057              : 
    1058              : ! **************************************************************************************************
    1059              : !> \brief Cleans the potential parameter type
    1060              : !> \param p ...
    1061              : !> \param lb1_new ...
    1062              : !> \param ub1_new ...
    1063              : !> \param lj ...
    1064              : !> \param lj_charmm ...
    1065              : !> \param williams ...
    1066              : !> \param goodwin ...
    1067              : !> \param eam ...
    1068              : !> \param nequip ...
    1069              : !> \param bmhft ...
    1070              : !> \param bmhftd ...
    1071              : !> \param ipbv ...
    1072              : !> \param buck4r ...
    1073              : !> \param buckmo ...
    1074              : !> \param gp ...
    1075              : !> \param tersoff ...
    1076              : !> \param siepmann ...
    1077              : !> \param gal ...
    1078              : !> \param gal21 ...
    1079              : !> \param tab ...
    1080              : !> \param deepmd ...
    1081              : !> \param ace ...
    1082              : !> \author Teodoro Laino [Teo] 11.2005
    1083              : ! **************************************************************************************************
    1084         2324 :    SUBROUTINE pair_potential_reallocate(p, lb1_new, ub1_new, lj, lj_charmm, williams, goodwin, eam, &
    1085              :                                         nequip, bmhft, bmhftd, ipbv, buck4r, buckmo, &
    1086              :                                         gp, tersoff, siepmann, gal, gal21, tab, deepmd, ace)
    1087              :       TYPE(pair_potential_p_type), POINTER               :: p
    1088              :       INTEGER, INTENT(IN)                                :: lb1_new, ub1_new
    1089              :       LOGICAL, INTENT(IN), OPTIONAL :: lj, lj_charmm, williams, goodwin, eam, nequip, bmhft, &
    1090              :          bmhftd, ipbv, buck4r, buckmo, gp, tersoff, siepmann, gal, gal21, tab, deepmd, ace
    1091              : 
    1092              :       INTEGER                                            :: i, ipot, lb1_old, std_dim, ub1_old
    1093              :       LOGICAL :: check, lace, lbmhft, lbmhftd, lbuck4r, lbuckmo, ldeepmd, leam, lgal, lgal21, &
    1094              :          lgoodwin, lgp, lipbv, llj, llj_charmm, lnequip, lsiepmann, ltab, ltersoff, lwilliams
    1095              :       TYPE(pair_potential_p_type), POINTER               :: work
    1096              : 
    1097         2324 :       NULLIFY (work)
    1098         2324 :       ipot = 0
    1099         2324 :       llj = .FALSE.; IF (PRESENT(lj)) llj = lj
    1100         2324 :       llj_charmm = .FALSE.; IF (PRESENT(lj_charmm)) llj_charmm = lj_charmm
    1101         2324 :       lwilliams = .FALSE.; IF (PRESENT(williams)) lwilliams = williams
    1102         2324 :       lgoodwin = .FALSE.; IF (PRESENT(goodwin)) lgoodwin = goodwin
    1103         2324 :       leam = .FALSE.; IF (PRESENT(eam)) leam = eam
    1104         2324 :       lnequip = .FALSE.; IF (PRESENT(nequip)) lnequip = nequip
    1105         2324 :       lace = .FALSE.; IF (PRESENT(ace)) lace = ace
    1106         2324 :       ldeepmd = .FALSE.; IF (PRESENT(deepmd)) ldeepmd = deepmd
    1107         2324 :       lbmhft = .FALSE.; IF (PRESENT(bmhft)) lbmhft = bmhft
    1108         2324 :       lbmhftd = .FALSE.; IF (PRESENT(bmhftd)) lbmhftd = bmhftd
    1109         2324 :       lipbv = .FALSE.; IF (PRESENT(ipbv)) lipbv = ipbv
    1110         2324 :       lbuck4r = .FALSE.; IF (PRESENT(buck4r)) lbuck4r = buck4r
    1111         2324 :       lbuckmo = .FALSE.; IF (PRESENT(buckmo)) lbuckmo = buckmo
    1112         2324 :       lgp = .FALSE.; IF (PRESENT(gp)) lgp = gp
    1113         2324 :       ltersoff = .FALSE.; IF (PRESENT(tersoff)) ltersoff = tersoff
    1114         2324 :       lsiepmann = .FALSE.; IF (PRESENT(siepmann)) lsiepmann = siepmann
    1115         2324 :       lgal = .FALSE.; IF (PRESENT(gal)) lgal = gal
    1116         2324 :       lgal21 = .FALSE.; IF (PRESENT(gal21)) lgal21 = gal21
    1117         2324 :       ltab = .FALSE.; IF (PRESENT(tab)) ltab = tab
    1118              : 
    1119         2324 :       IF (llj) THEN
    1120            0 :          ipot = lj_type
    1121              :          check = .NOT. (llj_charmm .OR. lwilliams .OR. lgoodwin .OR. leam .OR. lnequip &
    1122              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1123            0 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1124            0 :          CPASSERT(check)
    1125              :       END IF
    1126         2324 :       IF (llj_charmm) THEN
    1127         1008 :          ipot = lj_charmm_type
    1128              :          check = .NOT. (llj .OR. lwilliams .OR. lgoodwin .OR. leam .OR. lnequip &
    1129              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1130         1008 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1131            0 :          CPASSERT(check)
    1132              :       END IF
    1133         2324 :       IF (lwilliams) THEN
    1134          361 :          ipot = wl_type
    1135              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. leam .OR. lnequip &
    1136              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1137          361 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1138            0 :          CPASSERT(check)
    1139              :       END IF
    1140         2324 :       IF (lgoodwin) THEN
    1141            0 :          ipot = gw_type
    1142              :          check = .NOT. (llj .OR. llj_charmm .OR. lwilliams .OR. leam .OR. lnequip &
    1143              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1144            0 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1145            0 :          CPASSERT(check)
    1146              :       END IF
    1147         2324 :       IF (leam) THEN
    1148           12 :          ipot = ea_type
    1149              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. lnequip &
    1150              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1151           12 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1152            0 :          CPASSERT(check)
    1153              :       END IF
    1154         2324 :       IF (lnequip) THEN
    1155            4 :          ipot = nequip_type
    1156              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam &
    1157              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1158            4 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1159            0 :          CPASSERT(check)
    1160              :       END IF
    1161         2324 :       IF (lace) THEN
    1162            6 :          ipot = ace_type
    1163              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1164              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp &
    1165            6 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd)
    1166            0 :          CPASSERT(check)
    1167              :       END IF
    1168         2324 :       IF (ldeepmd) THEN
    1169            2 :          ipot = deepmd_type
    1170              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1171              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp &
    1172            2 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. lace)
    1173            0 :          CPASSERT(check)
    1174              :       END IF
    1175         2324 :       IF (lbmhft) THEN
    1176            4 :          ipot = ft_type
    1177              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1178              :                         .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1179            4 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1180            0 :          CPASSERT(check)
    1181              :       END IF
    1182         2324 :       IF (lbmhftd) THEN
    1183           18 :          ipot = ftd_type
    1184              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1185              :                         .OR. lbmhft .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1186           18 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1187            0 :          CPASSERT(check)
    1188              :       END IF
    1189         2324 :       IF (lipbv) THEN
    1190           16 :          ipot = ip_type
    1191              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1192              :                         .OR. lbmhft .OR. lbmhftd .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1193           16 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1194            0 :          CPASSERT(check)
    1195              :       END IF
    1196         2324 :       IF (lbuck4r) THEN
    1197          252 :          ipot = b4_type
    1198              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1199              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1200          252 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1201            0 :          CPASSERT(check)
    1202              :       END IF
    1203         2324 :       IF (lbuckmo) THEN
    1204            6 :          ipot = bm_type
    1205              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1206              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. ltersoff &
    1207            6 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1208            0 :          CPASSERT(check)
    1209              :       END IF
    1210         2324 :       IF (ltersoff) THEN
    1211           38 :          ipot = tersoff_type
    1212              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1213              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1214           38 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1215            0 :          CPASSERT(check)
    1216              :       END IF
    1217         2324 :       IF (lsiepmann) THEN
    1218            5 :          ipot = siepmann_type
    1219              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1220              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1221            5 :                         .OR. ltersoff .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1222            0 :          CPASSERT(check)
    1223              :       END IF
    1224         2324 :       IF (lgal) THEN
    1225            1 :          ipot = gal_type
    1226              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1227              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1228            1 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1229            0 :          CPASSERT(check)
    1230              :       END IF
    1231         2324 :       IF (lgal21) THEN
    1232            1 :          ipot = gal21_type
    1233              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1234              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1235            1 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. ltab .OR. ldeepmd .OR. lace)
    1236            0 :          CPASSERT(check)
    1237              :       END IF
    1238         2324 :       IF (lgp) THEN
    1239          582 :          ipot = gp_type
    1240              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1241              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgal21 .OR. lbuckmo &
    1242          582 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. ltab .OR. ldeepmd .OR. lace)
    1243            0 :          CPASSERT(check)
    1244              :       END IF
    1245         2324 :       IF (ltab) THEN
    1246            8 :          ipot = tab_type
    1247              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1248              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lgal21 &
    1249            8 :                         .OR. lbuckmo .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. lace)
    1250            0 :          CPASSERT(check)
    1251              :       END IF
    1252              : 
    1253         2324 :       lb1_old = 0
    1254         2324 :       ub1_old = 0
    1255         2324 :       IF (ASSOCIATED(p)) THEN
    1256          297 :          lb1_old = LBOUND(p%pot, 1)
    1257          297 :          ub1_old = UBOUND(p%pot, 1)
    1258          297 :          CALL pair_potential_p_create(work, lb=lb1_old, ub=ub1_old)
    1259          297 :          CALL pair_potential_p_copy(p, work)
    1260          297 :          CALL pair_potential_p_release(p)
    1261              :       END IF
    1262              : 
    1263         2324 :       CALL pair_potential_p_create(p, lb=lb1_new, ub=ub1_new)
    1264         2324 :       IF (ASSOCIATED(work)) THEN
    1265          297 :          CALL pair_potential_p_copy(work, p, istart=lb1_old, iend=ub1_old)
    1266              :       END IF
    1267         2324 :       std_dim = 1
    1268        10842 :       DO i = ub1_old + 1, ub1_new
    1269         8518 :          check = (SIZE(p%pot(i)%pot%type) == std_dim) .AND. (SIZE(p%pot(i)%pot%type) == std_dim)
    1270         8518 :          CPASSERT(check)
    1271        17036 :          p%pot(i)%pot%type = nn_type
    1272         8518 :          p%pot(i)%pot%shell_type = nosh_nosh
    1273         8518 :          p%pot(i)%pot%undef = .TRUE.
    1274         8518 :          p%pot(i)%pot%no_mb = .FALSE.
    1275         8518 :          p%pot(i)%pot%no_pp = .FALSE.
    1276         8518 :          p%pot(i)%pot%at1 = 'NULL'
    1277         8518 :          p%pot(i)%pot%at2 = 'NULL'
    1278         8518 :          p%pot(i)%pot%set(std_dim)%rmin = not_initialized
    1279         8518 :          p%pot(i)%pot%set(std_dim)%rmax = not_initialized
    1280         3790 :          SELECT CASE (ipot)
    1281              :          CASE (lj_type, lj_charmm_type)
    1282         3790 :             CALL pair_potential_lj_create(p%pot(i)%pot%set(std_dim)%lj)
    1283              :          CASE (wl_type)
    1284          979 :             CALL pair_potential_williams_create(p%pot(i)%pot%set(std_dim)%willis)
    1285              :          CASE (gw_type)
    1286            0 :             CALL pair_potential_goodwin_create(p%pot(i)%pot%set(std_dim)%goodwin)
    1287              :          CASE (ea_type)
    1288           20 :             CALL pair_potential_eam_create(p%pot(i)%pot%set(std_dim)%eam)
    1289              :          CASE (nequip_type, allegro_type)
    1290           12 :             CALL pair_potential_nequip_create(p%pot(i)%pot%set(std_dim)%nequip)
    1291              :          CASE (ace_type)
    1292           18 :             CALL pair_potential_ace_create(p%pot(i)%pot%set(std_dim)%ace)
    1293              :          CASE (deepmd_type)
    1294            6 :             CALL pair_potential_deepmd_create(p%pot(i)%pot%set(std_dim)%deepmd)
    1295              :          CASE (ft_type)
    1296           12 :             CALL pair_potential_bmhft_create(p%pot(i)%pot%set(std_dim)%ft)
    1297              :          CASE (ftd_type)
    1298           66 :             CALL pair_potential_bmhftd_create(p%pot(i)%pot%set(std_dim)%ftd)
    1299              :          CASE (ip_type)
    1300           48 :             CALL pair_potential_ipbv_create(p%pot(i)%pot%set(std_dim)%ipbv)
    1301              :          CASE (b4_type)
    1302          252 :             CALL pair_potential_buck4r_create(p%pot(i)%pot%set(std_dim)%buck4r)
    1303              :          CASE (bm_type)
    1304           14 :             CALL pair_potential_buckmo_create(p%pot(i)%pot%set(std_dim)%buckmo)
    1305              :          CASE (gp_type)
    1306         3228 :             CALL pair_potential_gp_create(p%pot(i)%pot%set(std_dim)%gp)
    1307              :          CASE (tersoff_type)
    1308           42 :             CALL pair_potential_tersoff_create(p%pot(i)%pot%set(std_dim)%tersoff)
    1309              :          CASE (siepmann_type)
    1310            5 :             CALL pair_potential_siepmann_create(p%pot(i)%pot%set(std_dim)%siepmann)
    1311              :          CASE (gal_type)
    1312            1 :             CALL pair_potential_gal_create(p%pot(i)%pot%set(std_dim)%gal)
    1313              :          CASE (gal21_type)
    1314            1 :             CALL pair_potential_gal21_create(p%pot(i)%pot%set(std_dim)%gal21)
    1315              :          CASE (tab_type)
    1316         8518 :             CALL pair_potential_tab_create(p%pot(i)%pot%set(std_dim)%tab)
    1317              :          END SELECT
    1318         8518 :          NULLIFY (p%pot(i)%pot%spl_f)
    1319        10842 :          NULLIFY (p%pot(i)%pot%pair_spline_data)
    1320              :       END DO
    1321              : 
    1322         2324 :       IF (ASSOCIATED(work)) CALL pair_potential_p_release(work)
    1323         2324 :    END SUBROUTINE pair_potential_reallocate
    1324              : 
    1325              : ! **************************************************************************************************
    1326              : !> \brief Creates the generic potential type
    1327              : !> \param gp ...
    1328              : !> \author Teodoro Laino [teo] 11.2005
    1329              : ! **************************************************************************************************
    1330         6488 :    SUBROUTINE pair_potential_gp_create(gp)
    1331              :       TYPE(gp_pot_type), POINTER                         :: gp
    1332              : 
    1333         6488 :       CPASSERT(.NOT. ASSOCIATED(gp))
    1334         6488 :       ALLOCATE (gp)
    1335              :       NULLIFY (gp%parameters)
    1336              :       NULLIFY (gp%values)
    1337         6488 :       CALL pair_potential_gp_clean(gp)
    1338         6488 :    END SUBROUTINE pair_potential_gp_create
    1339              : 
    1340              : ! **************************************************************************************************
    1341              : !> \brief Copy two generic potential type
    1342              : !> \param gp_source ...
    1343              : !> \param gp_dest ...
    1344              : !> \author Teodoro Laino [teo] 11.2005
    1345              : ! **************************************************************************************************
    1346        12454 :    SUBROUTINE pair_potential_gp_copy(gp_source, gp_dest)
    1347              :       TYPE(gp_pot_type), POINTER                         :: gp_source, gp_dest
    1348              : 
    1349              :       INTEGER                                            :: idim
    1350              : 
    1351        12454 :       IF (.NOT. ASSOCIATED(gp_source)) RETURN
    1352         3260 :       IF (ASSOCIATED(gp_dest)) CALL pair_potential_gp_release(gp_dest)
    1353         3260 :       CALL pair_potential_gp_create(gp_dest)
    1354         3260 :       gp_dest%myid = gp_source%myid
    1355         3260 :       gp_dest%potential = gp_source%potential
    1356         3260 :       gp_dest%variables = gp_source%variables
    1357         3260 :       IF (ASSOCIATED(gp_source%parameters)) THEN
    1358         3260 :          idim = SIZE(gp_source%parameters)
    1359         9780 :          ALLOCATE (gp_dest%parameters(idim))
    1360        22916 :          gp_dest%parameters = gp_source%parameters
    1361              :       END IF
    1362         3260 :       IF (ASSOCIATED(gp_source%values)) THEN
    1363         3260 :          idim = SIZE(gp_source%values)
    1364         9780 :          ALLOCATE (gp_dest%values(idim))
    1365        22916 :          gp_dest%values = gp_source%values
    1366              :       END IF
    1367              :    END SUBROUTINE pair_potential_gp_copy
    1368              : 
    1369              : ! **************************************************************************************************
    1370              : !> \brief Cleans the generic potential type
    1371              : !> \param gp ...
    1372              : !> \author Teodoro Laino [teo] 11.2005
    1373              : ! **************************************************************************************************
    1374       576237 :    SUBROUTINE pair_potential_gp_clean(gp)
    1375              :       TYPE(gp_pot_type), POINTER                         :: gp
    1376              : 
    1377       576237 :       IF (.NOT. ASSOCIATED(gp)) RETURN
    1378         6488 :       gp%myid = 0
    1379         6488 :       gp%potential = ""
    1380         6488 :       gp%variables = ""
    1381         6488 :       IF (ASSOCIATED(gp%values)) THEN
    1382            0 :          DEALLOCATE (gp%values)
    1383              :       END IF
    1384         6488 :       IF (ASSOCIATED(gp%parameters)) THEN
    1385            0 :          DEALLOCATE (gp%parameters)
    1386              :       END IF
    1387              :    END SUBROUTINE pair_potential_gp_clean
    1388              : 
    1389              : ! **************************************************************************************************
    1390              : !> \brief Destroys the generic potential type
    1391              : !> \param gp ...
    1392              : !> \author Teodoro Laino [teo] 11.2005
    1393              : ! **************************************************************************************************
    1394       525590 :    SUBROUTINE pair_potential_gp_release(gp)
    1395              :       TYPE(gp_pot_type), POINTER                         :: gp
    1396              : 
    1397       525590 :       IF (ASSOCIATED(gp)) THEN
    1398         6488 :          IF (ASSOCIATED(gp%parameters)) THEN
    1399         6488 :             DEALLOCATE (gp%parameters)
    1400              :          END IF
    1401         6488 :          IF (ASSOCIATED(gp%values)) THEN
    1402         6488 :             DEALLOCATE (gp%values)
    1403              :          END IF
    1404         6488 :          DEALLOCATE (gp)
    1405              :       END IF
    1406       525590 :       NULLIFY (gp)
    1407       525590 :    END SUBROUTINE pair_potential_gp_release
    1408              : 
    1409              : ! **************************************************************************************************
    1410              : !> \brief Cleans the LJ potential type
    1411              : !> \param lj ...
    1412              : !> \author Teodoro Laino [teo] 11.2005
    1413              : ! **************************************************************************************************
    1414       505178 :    SUBROUTINE pair_potential_lj_create(lj)
    1415              :       TYPE(lj_pot_type), POINTER                         :: lj
    1416              : 
    1417       505178 :       CPASSERT(.NOT. ASSOCIATED(lj))
    1418       505178 :       ALLOCATE (lj)
    1419       505178 :       CALL pair_potential_lj_clean(lj)
    1420       505178 :    END SUBROUTINE pair_potential_lj_create
    1421              : 
    1422              : ! **************************************************************************************************
    1423              : !> \brief Copy two LJ potential type
    1424              : !> \param lj_source ...
    1425              : !> \param lj_dest ...
    1426              : !> \author Teodoro Laino [teo] 11.2005
    1427              : ! **************************************************************************************************
    1428        12454 :    SUBROUTINE pair_potential_lj_copy(lj_source, lj_dest)
    1429              :       TYPE(lj_pot_type), POINTER                         :: lj_source, lj_dest
    1430              : 
    1431        12454 :       IF (.NOT. ASSOCIATED(lj_source)) RETURN
    1432         5114 :       IF (ASSOCIATED(lj_dest)) CALL pair_potential_lj_release(lj_dest)
    1433         5114 :       CALL pair_potential_lj_create(lj_dest)
    1434         5114 :       lj_dest%epsilon = lj_source%epsilon
    1435         5114 :       lj_dest%sigma6 = lj_source%sigma6
    1436         5114 :       lj_dest%sigma12 = lj_source%sigma12
    1437              :    END SUBROUTINE pair_potential_lj_copy
    1438              : 
    1439              : ! **************************************************************************************************
    1440              : !> \brief Creates the LJ potential type
    1441              : !> \param lj ...
    1442              : !> \author Teodoro Laino [teo] 11.2005
    1443              : ! **************************************************************************************************
    1444      1074927 :    SUBROUTINE pair_potential_lj_clean(lj)
    1445              :       TYPE(lj_pot_type), POINTER                         :: lj
    1446              : 
    1447      1074927 :       IF (.NOT. ASSOCIATED(lj)) RETURN
    1448       525272 :       lj%epsilon = 0.0_dp
    1449       525272 :       lj%sigma6 = 0.0_dp
    1450       525272 :       lj%sigma12 = 0.0_dp
    1451              :    END SUBROUTINE pair_potential_lj_clean
    1452              : 
    1453              : ! **************************************************************************************************
    1454              : !> \brief Destroys the LJ potential type
    1455              : !> \param lj ...
    1456              : !> \author Teodoro Laino [teo] 11.2005
    1457              : ! **************************************************************************************************
    1458       525592 :    SUBROUTINE pair_potential_lj_release(lj)
    1459              :       TYPE(lj_pot_type), POINTER                         :: lj
    1460              : 
    1461       525592 :       IF (ASSOCIATED(lj)) THEN
    1462       505178 :          DEALLOCATE (lj)
    1463              :       END IF
    1464       525592 :       NULLIFY (lj)
    1465       525592 :    END SUBROUTINE pair_potential_lj_release
    1466              : 
    1467              : ! **************************************************************************************************
    1468              : !> \brief Creates the WILLIAMS potential type
    1469              : !> \param willis ...
    1470              : !> \author Teodoro Laino [teo] 11.2005
    1471              : ! **************************************************************************************************
    1472         3056 :    SUBROUTINE pair_potential_williams_create(willis)
    1473              :       TYPE(williams_pot_type), POINTER                   :: willis
    1474              : 
    1475         3056 :       CPASSERT(.NOT. ASSOCIATED(willis))
    1476         3056 :       ALLOCATE (willis)
    1477         3056 :       CALL pair_potential_williams_clean(willis)
    1478         3056 :    END SUBROUTINE pair_potential_williams_create
    1479              : 
    1480              : ! **************************************************************************************************
    1481              : !> \brief Copy two WILLIAMS potential type
    1482              : !> \param willis_source ...
    1483              : !> \param willis_dest ...
    1484              : !> \author Teodoro Laino [teo] 11.2005
    1485              : ! **************************************************************************************************
    1486        12454 :    SUBROUTINE pair_potential_williams_copy(willis_source, willis_dest)
    1487              :       TYPE(williams_pot_type), POINTER                   :: willis_source, willis_dest
    1488              : 
    1489        12454 :       IF (.NOT. ASSOCIATED(willis_source)) RETURN
    1490         2077 :       IF (ASSOCIATED(willis_dest)) CALL pair_potential_williams_release(willis_dest)
    1491         2077 :       CALL pair_potential_williams_create(willis_dest)
    1492         2077 :       willis_dest%a = willis_source%a
    1493         2077 :       willis_dest%b = willis_source%b
    1494         2077 :       willis_dest%c = willis_source%c
    1495              :    END SUBROUTINE pair_potential_williams_copy
    1496              : 
    1497              : ! **************************************************************************************************
    1498              : !> \brief Creates the WILLIAMS potential type
    1499              : !> \param willis ...
    1500              : !> \author Teodoro Laino [teo] 11.2005
    1501              : ! **************************************************************************************************
    1502       572805 :    SUBROUTINE pair_potential_williams_clean(willis)
    1503              :       TYPE(williams_pot_type), POINTER                   :: willis
    1504              : 
    1505       572805 :       IF (.NOT. ASSOCIATED(willis)) RETURN
    1506         3106 :       willis%a = 0.0_dp
    1507         3106 :       willis%b = 0.0_dp
    1508         3106 :       willis%c = 0.0_dp
    1509              :    END SUBROUTINE pair_potential_williams_clean
    1510              : 
    1511              : ! **************************************************************************************************
    1512              : !> \brief Destroys the WILLIAMS potential type
    1513              : !> \param willis ...
    1514              : !> \author Teodoro Laino [teo] 11.2005
    1515              : ! **************************************************************************************************
    1516       525592 :    SUBROUTINE pair_potential_williams_release(willis)
    1517              :       TYPE(williams_pot_type), POINTER                   :: willis
    1518              : 
    1519       525592 :       IF (ASSOCIATED(willis)) THEN
    1520         3056 :          DEALLOCATE (willis)
    1521              :       END IF
    1522       525592 :       NULLIFY (willis)
    1523       525592 :    END SUBROUTINE pair_potential_williams_release
    1524              : 
    1525              : ! **************************************************************************************************
    1526              : !> \brief Creates the GOODWIN potential type
    1527              : !> \param goodwin ...
    1528              : !> \author Teodoro Laino [teo] 11.2005
    1529              : ! **************************************************************************************************
    1530            0 :    SUBROUTINE pair_potential_goodwin_create(goodwin)
    1531              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin
    1532              : 
    1533            0 :       CPASSERT(.NOT. ASSOCIATED(goodwin))
    1534            0 :       ALLOCATE (goodwin)
    1535            0 :       CALL pair_potential_goodwin_clean(goodwin)
    1536            0 :    END SUBROUTINE pair_potential_goodwin_create
    1537              : 
    1538              : ! **************************************************************************************************
    1539              : !> \brief Copy two GOODWIN potential type
    1540              : !> \param goodwin_source ...
    1541              : !> \param goodwin_dest ...
    1542              : !> \author Teodoro Laino [teo] 11.2005
    1543              : ! **************************************************************************************************
    1544        12454 :    SUBROUTINE pair_potential_goodwin_copy(goodwin_source, goodwin_dest)
    1545              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin_source, goodwin_dest
    1546              : 
    1547        12454 :       IF (.NOT. ASSOCIATED(goodwin_source)) RETURN
    1548            0 :       IF (ASSOCIATED(goodwin_dest)) CALL pair_potential_goodwin_release(goodwin_dest)
    1549            0 :       CALL pair_potential_goodwin_create(goodwin_dest)
    1550            0 :       goodwin_dest%vr0 = goodwin_source%vr0
    1551            0 :       goodwin_dest%d = goodwin_source%d
    1552            0 :       goodwin_dest%dc = goodwin_source%dc
    1553            0 :       goodwin_dest%m = goodwin_source%m
    1554            0 :       goodwin_dest%mc = goodwin_source%mc
    1555              :    END SUBROUTINE pair_potential_goodwin_copy
    1556              : 
    1557              : ! **************************************************************************************************
    1558              : !> \brief Creates the GOODWIN potential type
    1559              : !> \param goodwin ...
    1560              : !> \author Teodoro Laino [teo] 11.2005
    1561              : ! **************************************************************************************************
    1562       569749 :    SUBROUTINE pair_potential_goodwin_clean(goodwin)
    1563              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin
    1564              : 
    1565       569749 :       IF (.NOT. ASSOCIATED(goodwin)) RETURN
    1566            0 :       goodwin%vr0 = 0.0_dp
    1567            0 :       goodwin%d = 0.0_dp
    1568            0 :       goodwin%dc = 0.0_dp
    1569            0 :       goodwin%m = 0.0_dp
    1570            0 :       goodwin%mc = 0.0_dp
    1571              :    END SUBROUTINE pair_potential_goodwin_clean
    1572              : 
    1573              : ! **************************************************************************************************
    1574              : !> \brief Destroys the GOODWIN potential type
    1575              : !> \param goodwin ...
    1576              : !> \author Teodoro Laino [teo] 11.2005
    1577              : ! **************************************************************************************************
    1578       525590 :    SUBROUTINE pair_potential_goodwin_release(goodwin)
    1579              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin
    1580              : 
    1581       525590 :       IF (ASSOCIATED(goodwin)) THEN
    1582            0 :          DEALLOCATE (goodwin)
    1583              :       END IF
    1584       525590 :       NULLIFY (goodwin)
    1585       525590 :    END SUBROUTINE pair_potential_goodwin_release
    1586              : 
    1587              : ! **************************************************************************************************
    1588              : !> \brief Creates the EAM potential type
    1589              : !> \param eam ...
    1590              : !> \author Teodoro Laino [teo] 11.2005
    1591              : ! **************************************************************************************************
    1592           44 :    SUBROUTINE pair_potential_eam_create(eam)
    1593              :       TYPE(eam_pot_type), POINTER                        :: eam
    1594              : 
    1595           44 :       CPASSERT(.NOT. ASSOCIATED(eam))
    1596           44 :       ALLOCATE (eam)
    1597              :       NULLIFY (eam%rho, eam%phi, eam%frho, eam%rhoval, eam%rval, &
    1598              :                eam%rhop, eam%phip, eam%frhop)
    1599           44 :       CALL pair_potential_eam_clean(eam)
    1600           44 :    END SUBROUTINE pair_potential_eam_create
    1601              : 
    1602              : ! **************************************************************************************************
    1603              : !> \brief Copy two EAM potential type
    1604              : !> \param eam_source ...
    1605              : !> \param eam_dest ...
    1606              : !> \author Teodoro Laino [teo] 11.2005
    1607              : ! **************************************************************************************************
    1608        12454 :    SUBROUTINE pair_potential_eam_copy(eam_source, eam_dest)
    1609              :       TYPE(eam_pot_type), POINTER                        :: eam_source, eam_dest
    1610              : 
    1611        12454 :       IF (.NOT. ASSOCIATED(eam_source)) RETURN
    1612           24 :       IF (ASSOCIATED(eam_dest)) CALL pair_potential_eam_release(eam_dest)
    1613           24 :       CALL pair_potential_eam_create(eam_dest)
    1614           24 :       eam_dest%eam_file_name = eam_source%eam_file_name
    1615           24 :       eam_dest%drar = eam_source%drar
    1616           24 :       eam_dest%drhoar = eam_source%drhoar
    1617           24 :       eam_dest%acutal = eam_source%acutal
    1618           24 :       eam_dest%npoints = eam_source%npoints
    1619              :       ! Allocate arrays with the proper size
    1620           24 :       CALL reallocate(eam_dest%rho, 1, eam_dest%npoints)
    1621           24 :       CALL reallocate(eam_dest%rhop, 1, eam_dest%npoints)
    1622           24 :       CALL reallocate(eam_dest%phi, 1, eam_dest%npoints)
    1623           24 :       CALL reallocate(eam_dest%phip, 1, eam_dest%npoints)
    1624           24 :       CALL reallocate(eam_dest%frho, 1, eam_dest%npoints)
    1625           24 :       CALL reallocate(eam_dest%frhop, 1, eam_dest%npoints)
    1626           24 :       CALL reallocate(eam_dest%rval, 1, eam_dest%npoints)
    1627           24 :       CALL reallocate(eam_dest%rhoval, 1, eam_dest%npoints)
    1628       132024 :       eam_dest%rho = eam_source%rho
    1629       132024 :       eam_dest%phi = eam_source%phi
    1630       132024 :       eam_dest%frho = eam_source%frho
    1631       132024 :       eam_dest%rhoval = eam_source%rhoval
    1632       132024 :       eam_dest%rval = eam_source%rval
    1633       132024 :       eam_dest%rhop = eam_source%rhop
    1634       132024 :       eam_dest%phip = eam_source%phip
    1635       132024 :       eam_dest%frhop = eam_source%frhop
    1636              :    END SUBROUTINE pair_potential_eam_copy
    1637              : 
    1638              : ! **************************************************************************************************
    1639              : !> \brief Creates the EAM potential type
    1640              : !> \param eam ...
    1641              : !> \author Teodoro Laino [teo] 11.2005
    1642              : ! **************************************************************************************************
    1643       569793 :    SUBROUTINE pair_potential_eam_clean(eam)
    1644              :       TYPE(eam_pot_type), POINTER                        :: eam
    1645              : 
    1646       569793 :       IF (.NOT. ASSOCIATED(eam)) RETURN
    1647           44 :       eam%eam_file_name = 'NULL'
    1648           44 :       eam%drar = 0.0_dp
    1649           44 :       eam%drhoar = 0.0_dp
    1650           44 :       eam%acutal = 0.0_dp
    1651           44 :       eam%npoints = 0
    1652           44 :       CALL reallocate(eam%rho, 1, eam%npoints)
    1653           44 :       CALL reallocate(eam%rhop, 1, eam%npoints)
    1654           44 :       CALL reallocate(eam%phi, 1, eam%npoints)
    1655           44 :       CALL reallocate(eam%phip, 1, eam%npoints)
    1656           44 :       CALL reallocate(eam%frho, 1, eam%npoints)
    1657           44 :       CALL reallocate(eam%frhop, 1, eam%npoints)
    1658           44 :       CALL reallocate(eam%rval, 1, eam%npoints)
    1659           44 :       CALL reallocate(eam%rhoval, 1, eam%npoints)
    1660              :    END SUBROUTINE pair_potential_eam_clean
    1661              : 
    1662              : ! **************************************************************************************************
    1663              : !> \brief Destroys the EAM potential type
    1664              : !> \param eam ...
    1665              : !> \author Teodoro Laino [teo] 11.2005
    1666              : ! **************************************************************************************************
    1667       525590 :    SUBROUTINE pair_potential_eam_release(eam)
    1668              :       TYPE(eam_pot_type), POINTER                        :: eam
    1669              : 
    1670       525590 :       IF (ASSOCIATED(eam)) THEN
    1671           44 :          IF (ASSOCIATED(eam%rho)) THEN
    1672           44 :             DEALLOCATE (eam%rho)
    1673              :          END IF
    1674           44 :          IF (ASSOCIATED(eam%rhop)) THEN
    1675           44 :             DEALLOCATE (eam%rhop)
    1676              :          END IF
    1677           44 :          IF (ASSOCIATED(eam%phi)) THEN
    1678           44 :             DEALLOCATE (eam%phi)
    1679              :          END IF
    1680           44 :          IF (ASSOCIATED(eam%phip)) THEN
    1681           44 :             DEALLOCATE (eam%phip)
    1682              :          END IF
    1683           44 :          IF (ASSOCIATED(eam%frho)) THEN
    1684           44 :             DEALLOCATE (eam%frho)
    1685              :          END IF
    1686           44 :          IF (ASSOCIATED(eam%frhop)) THEN
    1687           44 :             DEALLOCATE (eam%frhop)
    1688              :          END IF
    1689           44 :          IF (ASSOCIATED(eam%rval)) THEN
    1690           44 :             DEALLOCATE (eam%rval)
    1691              :          END IF
    1692           44 :          IF (ASSOCIATED(eam%rhoval)) THEN
    1693           44 :             DEALLOCATE (eam%rhoval)
    1694              :          END IF
    1695           44 :          DEALLOCATE (eam)
    1696              :       END IF
    1697       525590 :    END SUBROUTINE pair_potential_eam_release
    1698              : 
    1699              : ! **************************************************************************************************
    1700              : !> \brief Creates the ACE potential type
    1701              : !> \param ace ...
    1702              : !> \author
    1703              : ! **************************************************************************************************
    1704           36 :    SUBROUTINE pair_potential_ace_create(ace)
    1705              :       TYPE(ace_pot_type), POINTER                        :: ace
    1706              : 
    1707           36 :       CPASSERT(.NOT. ASSOCIATED(ace))
    1708           36 :       ALLOCATE (ace)
    1709           36 :    END SUBROUTINE pair_potential_ace_create
    1710              : 
    1711              : ! **************************************************************************************************
    1712              : !> \brief Copy two ACE potential type
    1713              : !> \param ace_source ...
    1714              : !> \param ace_dest ...
    1715              : !> \author
    1716              : ! **************************************************************************************************
    1717        12454 :    SUBROUTINE pair_potential_ace_copy(ace_source, ace_dest)
    1718              :       TYPE(ace_pot_type), POINTER                        :: ace_source, ace_dest
    1719              : 
    1720        12454 :       IF (.NOT. ASSOCIATED(ace_source)) RETURN
    1721           18 :       NULLIFY (ace_dest)
    1722              :       IF (ASSOCIATED(ace_dest)) CALL pair_potential_ace_release(ace_dest)
    1723           18 :       CALL pair_potential_ace_create(ace_dest)
    1724           18 :       ace_dest = ace_source
    1725              :    END SUBROUTINE pair_potential_ace_copy
    1726              : 
    1727              : ! **************************************************************************************************
    1728              : !> \brief CLEAN the ACE potential type
    1729              : !> \param ace ...
    1730              : !> \author
    1731              : ! **************************************************************************************************
    1732       569749 :    SUBROUTINE pair_potential_ace_clean(ace)
    1733              :       TYPE(ace_pot_type), POINTER                        :: ace
    1734              : 
    1735       569749 :       IF (.NOT. ASSOCIATED(ace)) RETURN
    1736            0 :       ace = ace_pot_type()
    1737              :    END SUBROUTINE pair_potential_ace_clean
    1738              : 
    1739              : ! **************************************************************************************************
    1740              : !> \brief Destroys the ACE potential type
    1741              : !> \param ace ...
    1742              : !> \author
    1743              : ! **************************************************************************************************
    1744       525590 :    SUBROUTINE pair_potential_ace_release(ace)
    1745              :       TYPE(ace_pot_type), POINTER                        :: ace
    1746              : 
    1747       525590 :       IF (ASSOCIATED(ace)) THEN
    1748           36 :          DEALLOCATE (ace)
    1749              :       END IF
    1750       525590 :    END SUBROUTINE pair_potential_ace_release
    1751              : 
    1752              : ! **************************************************************************************************
    1753              : !> \brief Creates the DEEPMD potential type
    1754              : !> \param deepmd ...
    1755              : !> \author Yongbin Zhuang 07.2019
    1756              : ! **************************************************************************************************
    1757           12 :    SUBROUTINE pair_potential_deepmd_create(deepmd)
    1758              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd
    1759              : 
    1760           12 :       CPASSERT(.NOT. ASSOCIATED(deepmd))
    1761           12 :       ALLOCATE (deepmd)
    1762           12 :    END SUBROUTINE pair_potential_deepmd_create
    1763              : 
    1764              : ! **************************************************************************************************
    1765              : !> \brief Copy two DEEPMD potential type
    1766              : !> \param deepmd_source ...
    1767              : !> \param deepmd_dest ...
    1768              : !> \author Yongbin Zhuang 07.2019
    1769              : ! **************************************************************************************************
    1770        12454 :    SUBROUTINE pair_potential_deepmd_copy(deepmd_source, deepmd_dest)
    1771              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd_source, deepmd_dest
    1772              : 
    1773        12454 :       IF (.NOT. ASSOCIATED(deepmd_source)) RETURN
    1774            6 :       NULLIFY (deepmd_dest)
    1775              :       IF (ASSOCIATED(deepmd_dest)) CALL pair_potential_deepmd_release(deepmd_dest)
    1776            6 :       CALL pair_potential_deepmd_create(deepmd_dest)
    1777            6 :       deepmd_dest = deepmd_source
    1778              :    END SUBROUTINE pair_potential_deepmd_copy
    1779              : 
    1780              : ! **************************************************************************************************
    1781              : !> \brief CLEAN the DEEPMD potential type
    1782              : !> \param deepmd ...
    1783              : !> \author Yongbin Zhuang 07.2019
    1784              : ! **************************************************************************************************
    1785       569749 :    SUBROUTINE pair_potential_deepmd_clean(deepmd)
    1786              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd
    1787              : 
    1788       569749 :       IF (.NOT. ASSOCIATED(deepmd)) RETURN
    1789            0 :       deepmd = deepmd_pot_type()
    1790              :    END SUBROUTINE pair_potential_deepmd_clean
    1791              : 
    1792              : ! **************************************************************************************************
    1793              : !> \brief Destroys the DEEPMD potential type
    1794              : !> \param deepmd ...
    1795              : !> \author Yongbin Zhuang 07.2019
    1796              : ! **************************************************************************************************
    1797       525590 :    SUBROUTINE pair_potential_deepmd_release(deepmd)
    1798              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd
    1799              : 
    1800       525590 :       IF (ASSOCIATED(deepmd)) THEN
    1801           12 :          DEALLOCATE (deepmd)
    1802              :       END IF
    1803       525590 :    END SUBROUTINE pair_potential_deepmd_release
    1804              : 
    1805              : ! **************************************************************************************************
    1806              : !> \brief Creates the NEQUIP potential type
    1807              : !> \param nequip ...
    1808              : !> \author Gabriele Tocci 2023
    1809              : ! **************************************************************************************************
    1810           24 :    SUBROUTINE pair_potential_nequip_create(nequip)
    1811              :       TYPE(nequip_pot_type), POINTER                     :: nequip
    1812              : 
    1813           24 :       CPASSERT(.NOT. ASSOCIATED(nequip))
    1814           24 :       ALLOCATE (nequip)
    1815           24 :    END SUBROUTINE pair_potential_nequip_create
    1816              : 
    1817              : ! **************************************************************************************************
    1818              : !> \brief Copy two NEQUIP potential type
    1819              : !> \param nequip_source ...
    1820              : !> \param nequip_dest ...
    1821              : !> \author Gabriele Tocci 2023
    1822              : ! **************************************************************************************************
    1823        12454 :    SUBROUTINE pair_potential_nequip_copy(nequip_source, nequip_dest)
    1824              :       TYPE(nequip_pot_type), POINTER                     :: nequip_source, nequip_dest
    1825              : 
    1826        12454 :       IF (.NOT. ASSOCIATED(nequip_source)) RETURN
    1827           12 :       IF (ASSOCIATED(nequip_dest)) CALL pair_potential_nequip_release(nequip_dest)
    1828           12 :       CALL pair_potential_nequip_create(nequip_dest)
    1829           12 :       nequip_dest = nequip_source
    1830              : 
    1831              :    END SUBROUTINE pair_potential_nequip_copy
    1832              : 
    1833              : ! **************************************************************************************************
    1834              : !> \brief Creates the NEQUIP potential type
    1835              : !> \param nequip ...
    1836              : !> \author Gabriele Tocci 2023
    1837              : ! **************************************************************************************************
    1838       569749 :    SUBROUTINE pair_potential_nequip_clean(nequip)
    1839              :       TYPE(nequip_pot_type), POINTER                     :: nequip
    1840              : 
    1841       569749 :       IF (.NOT. ASSOCIATED(nequip)) RETURN
    1842            0 :       nequip = nequip_pot_type()
    1843              : 
    1844              :    END SUBROUTINE pair_potential_nequip_clean
    1845              : 
    1846              : ! **************************************************************************************************
    1847              : !> \brief Destroys the NEQUIP potential type
    1848              : !> \param nequip ...
    1849              : !> \author Gabriele Tocci 2023
    1850              : ! **************************************************************************************************
    1851       525590 :    SUBROUTINE pair_potential_nequip_release(nequip)
    1852              :       TYPE(nequip_pot_type), POINTER                     :: nequip
    1853              : 
    1854       525590 :       IF (ASSOCIATED(nequip)) THEN
    1855           24 :          DEALLOCATE (nequip)
    1856              :       END IF
    1857       525590 :    END SUBROUTINE pair_potential_nequip_release
    1858              : 
    1859              : ! **************************************************************************************************
    1860              : !> \brief Creates the BMHFT (TOSI-FUMI) potential type
    1861              : !> \param ft ...
    1862              : !> \author Teodoro Laino [teo] 11.2005
    1863              : ! **************************************************************************************************
    1864           24 :    SUBROUTINE pair_potential_bmhft_create(ft)
    1865              :       TYPE(ft_pot_type), POINTER                         :: ft
    1866              : 
    1867           24 :       CPASSERT(.NOT. ASSOCIATED(ft))
    1868           24 :       ALLOCATE (ft)
    1869           24 :       CALL pair_potential_bmhft_clean(ft)
    1870           24 :    END SUBROUTINE pair_potential_bmhft_create
    1871              : 
    1872              : ! **************************************************************************************************
    1873              : !> \brief Copy two BMHFT (TOSI-FUMI) potential type
    1874              : !> \param ft_source ...
    1875              : !> \param ft_dest ...
    1876              : !> \author Teodoro Laino [teo] 11.2005
    1877              : ! **************************************************************************************************
    1878        12454 :    SUBROUTINE pair_potential_bmhft_copy(ft_source, ft_dest)
    1879              :       TYPE(ft_pot_type), POINTER                         :: ft_source, ft_dest
    1880              : 
    1881        12454 :       IF (.NOT. ASSOCIATED(ft_source)) RETURN
    1882           12 :       IF (ASSOCIATED(ft_dest)) CALL pair_potential_bmhft_release(ft_dest)
    1883           12 :       CALL pair_potential_bmhft_create(ft_dest)
    1884           12 :       ft_dest%A = ft_source%A
    1885           12 :       ft_dest%B = ft_source%B
    1886           12 :       ft_dest%C = ft_source%C
    1887           12 :       ft_dest%D = ft_source%D
    1888              :    END SUBROUTINE pair_potential_bmhft_copy
    1889              : 
    1890              : ! **************************************************************************************************
    1891              : !> \brief Creates the BMHFT (TOSI-FUMI) potential type
    1892              : !> \param ft ...
    1893              : !> \author Teodoro Laino [teo] 11.2005
    1894              : ! **************************************************************************************************
    1895       569773 :    SUBROUTINE pair_potential_bmhft_clean(ft)
    1896              :       TYPE(ft_pot_type), POINTER                         :: ft
    1897              : 
    1898       569773 :       IF (.NOT. ASSOCIATED(ft)) RETURN
    1899           24 :       ft%A = 0.0_dp
    1900           24 :       ft%B = 0.0_dp
    1901           24 :       ft%C = 0.0_dp
    1902           24 :       ft%D = 0.0_dp
    1903              :    END SUBROUTINE pair_potential_bmhft_clean
    1904              : 
    1905              : ! **************************************************************************************************
    1906              : !> \brief Destroys the BMHFT potential type
    1907              : !> \param ft ...
    1908              : !> \author Teodoro Laino [teo] 11.2005
    1909              : ! **************************************************************************************************
    1910       525590 :    SUBROUTINE pair_potential_bmhft_release(ft)
    1911              :       TYPE(ft_pot_type), POINTER                         :: ft
    1912              : 
    1913       525590 :       IF (ASSOCIATED(ft)) THEN
    1914           24 :          DEALLOCATE (ft)
    1915              :       END IF
    1916       525590 :       NULLIFY (ft)
    1917       525590 :    END SUBROUTINE pair_potential_bmhft_release
    1918              : 
    1919              : ! **************************************************************************************************
    1920              : !> \brief Creates the BMHFTD (damped TOSI-FUMI) potential type
    1921              : !> \param ftd ...
    1922              : !> \author Mathieu Salanne 05.2010
    1923              : ! **************************************************************************************************
    1924          132 :    SUBROUTINE pair_potential_bmhftd_create(ftd)
    1925              :       TYPE(ftd_pot_type), POINTER                        :: ftd
    1926              : 
    1927          132 :       CPASSERT(.NOT. ASSOCIATED(ftd))
    1928          528 :       ALLOCATE (ftd)
    1929          132 :       CALL pair_potential_bmhftd_clean(ftd)
    1930          132 :    END SUBROUTINE pair_potential_bmhftd_create
    1931              : 
    1932              : ! **************************************************************************************************
    1933              : !> \brief Copy two BMHFTD (Damped TOSI-FUMI) potential type
    1934              : !> \param ftd_source ...
    1935              : !> \param ftd_dest ...
    1936              : !> \author Mathieu Salanne 05.2010
    1937              : ! **************************************************************************************************
    1938        12454 :    SUBROUTINE pair_potential_bmhftd_copy(ftd_source, ftd_dest)
    1939              :       TYPE(ftd_pot_type), POINTER                        :: ftd_source, ftd_dest
    1940              : 
    1941        12454 :       IF (.NOT. ASSOCIATED(ftd_source)) RETURN
    1942           66 :       IF (ASSOCIATED(ftd_dest)) CALL pair_potential_bmhftd_release(ftd_dest)
    1943           66 :       CALL pair_potential_bmhftd_create(ftd_dest)
    1944           66 :       ftd_dest%A = ftd_source%A
    1945           66 :       ftd_dest%B = ftd_source%B
    1946           66 :       ftd_dest%C = ftd_source%C
    1947           66 :       ftd_dest%D = ftd_source%D
    1948          330 :       ftd_dest%BD = ftd_source%BD
    1949              :    END SUBROUTINE pair_potential_bmhftd_copy
    1950              : 
    1951              : ! **************************************************************************************************
    1952              : !> \brief Cleans the BMHFTD (damped TOSI-FUMI) potential type
    1953              : !> \param ftd ...
    1954              : !> \author Mathieu Salanne
    1955              : ! **************************************************************************************************
    1956       569881 :    SUBROUTINE pair_potential_bmhftd_clean(ftd)
    1957              :       TYPE(ftd_pot_type), POINTER                        :: ftd
    1958              : 
    1959       569881 :       IF (.NOT. ASSOCIATED(ftd)) RETURN
    1960          132 :       ftd%A = 0.0_dp
    1961          132 :       ftd%B = 0.0_dp
    1962          132 :       ftd%C = 0.0_dp
    1963          132 :       ftd%D = 0.0_dp
    1964          396 :       ftd%BD = 0.0_dp
    1965              :    END SUBROUTINE pair_potential_bmhftd_clean
    1966              : 
    1967              : ! **************************************************************************************************
    1968              : !> \brief Destroys the BMHFTD potential type
    1969              : !> \param ftd ...
    1970              : !> \author Mathieu Salanne 05.2010
    1971              : ! **************************************************************************************************
    1972       525590 :    SUBROUTINE pair_potential_bmhftd_release(ftd)
    1973              :       TYPE(ftd_pot_type), POINTER                        :: ftd
    1974              : 
    1975       525590 :       IF (ASSOCIATED(ftd)) THEN
    1976          132 :          DEALLOCATE (ftd)
    1977              :       END IF
    1978       525590 :       NULLIFY (ftd)
    1979       525590 :    END SUBROUTINE pair_potential_bmhftd_release
    1980              : 
    1981              : ! **************************************************************************************************
    1982              : !> \brief Creates the IPBV potential type
    1983              : !> \param ipbv ...
    1984              : !> \author Teodoro Laino [teo] 11.2005
    1985              : ! **************************************************************************************************
    1986           96 :    SUBROUTINE pair_potential_ipbv_create(ipbv)
    1987              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv
    1988              : 
    1989           96 :       CPASSERT(.NOT. ASSOCIATED(ipbv))
    1990         1536 :       ALLOCATE (ipbv)
    1991           96 :       CALL pair_potential_ipbv_clean(ipbv)
    1992           96 :    END SUBROUTINE pair_potential_ipbv_create
    1993              : 
    1994              : ! **************************************************************************************************
    1995              : !> \brief Copy two IPBV potential type
    1996              : !> \param ipbv_source ...
    1997              : !> \param ipbv_dest ...
    1998              : !> \author Teodoro Laino [teo] 11.2005
    1999              : ! **************************************************************************************************
    2000        12454 :    SUBROUTINE pair_potential_ipbv_copy(ipbv_source, ipbv_dest)
    2001              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv_source, ipbv_dest
    2002              : 
    2003        12454 :       IF (.NOT. ASSOCIATED(ipbv_source)) RETURN
    2004           48 :       IF (ASSOCIATED(ipbv_dest)) CALL pair_potential_ipbv_release(ipbv_dest)
    2005           48 :       CALL pair_potential_ipbv_create(ipbv_dest)
    2006         1392 :       ipbv_dest%a = ipbv_source%a
    2007           48 :       ipbv_dest%rcore = ipbv_source%rcore
    2008           48 :       ipbv_dest%b = ipbv_source%b
    2009           48 :       ipbv_dest%m = ipbv_source%m
    2010              :    END SUBROUTINE pair_potential_ipbv_copy
    2011              : 
    2012              : ! **************************************************************************************************
    2013              : !> \brief Creates the IPBV potential type
    2014              : !> \param ipbv ...
    2015              : !> \author Teodoro Laino [teo] 11.2005
    2016              : ! **************************************************************************************************
    2017       569845 :    SUBROUTINE pair_potential_ipbv_clean(ipbv)
    2018              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv
    2019              : 
    2020       569845 :       IF (.NOT. ASSOCIATED(ipbv)) RETURN
    2021         1440 :       ipbv%a = 0.0_dp
    2022           96 :       ipbv%rcore = 0.0_dp
    2023           96 :       ipbv%b = 0.0_dp
    2024           96 :       ipbv%m = 0.0_dp
    2025              :    END SUBROUTINE pair_potential_ipbv_clean
    2026              : 
    2027              : ! **************************************************************************************************
    2028              : !> \brief Destroys the IPBV potential type
    2029              : !> \param ipbv ...
    2030              : !> \author Teodoro Laino [teo] 11.2005
    2031              : ! **************************************************************************************************
    2032       525590 :    SUBROUTINE pair_potential_ipbv_release(ipbv)
    2033              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv
    2034              : 
    2035       525590 :       IF (ASSOCIATED(ipbv)) THEN
    2036           96 :          DEALLOCATE (ipbv)
    2037              :       END IF
    2038       525590 :       NULLIFY (ipbv)
    2039       525590 :    END SUBROUTINE pair_potential_ipbv_release
    2040              : 
    2041              : ! **************************************************************************************************
    2042              : !> \brief Creates the Buckingham 4 ranges  potential type
    2043              : !> \param buck4r ...
    2044              : !> \author MI 10.2006
    2045              : ! **************************************************************************************************
    2046          506 :    SUBROUTINE pair_potential_buck4r_create(buck4r)
    2047              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r
    2048              : 
    2049          506 :       CPASSERT(.NOT. ASSOCIATED(buck4r))
    2050        12650 :       ALLOCATE (buck4r)
    2051          506 :       CALL pair_potential_buck4r_clean(buck4r)
    2052          506 :    END SUBROUTINE pair_potential_buck4r_create
    2053              : 
    2054              : ! **************************************************************************************************
    2055              : !> \brief Copy two Buckingham 4 ranges  potential type
    2056              : !> \param buck4r_source ...
    2057              : !> \param buck4r_dest ...
    2058              : !> \author MI 10.2006
    2059              : ! **************************************************************************************************
    2060        12454 :    SUBROUTINE pair_potential_buck4r_copy(buck4r_source, buck4r_dest)
    2061              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r_source, buck4r_dest
    2062              : 
    2063        12454 :       IF (.NOT. ASSOCIATED(buck4r_source)) RETURN
    2064          254 :       IF (ASSOCIATED(buck4r_dest)) CALL pair_potential_buck4r_release(buck4r_dest)
    2065          254 :       CALL pair_potential_buck4r_create(buck4r_dest)
    2066          254 :       buck4r_dest%a = buck4r_source%a
    2067          254 :       buck4r_dest%b = buck4r_source%b
    2068          254 :       buck4r_dest%c = buck4r_source%c
    2069          254 :       buck4r_dest%r1 = buck4r_source%r1
    2070          254 :       buck4r_dest%r2 = buck4r_source%r2
    2071          254 :       buck4r_dest%r3 = buck4r_source%r3
    2072         5842 :       buck4r_dest%poly1 = buck4r_source%poly1
    2073         5842 :       buck4r_dest%poly2 = buck4r_source%poly2
    2074          254 :       buck4r_dest%npoly1 = buck4r_source%npoly1
    2075          254 :       buck4r_dest%npoly2 = buck4r_source%npoly2
    2076              :    END SUBROUTINE pair_potential_buck4r_copy
    2077              : 
    2078              : ! **************************************************************************************************
    2079              : !> \brief Creates the Buckingham 4 ranges  potential type
    2080              : !> \param buck4r ...
    2081              : !> \author MI 10.2006
    2082              : ! **************************************************************************************************
    2083       570255 :    SUBROUTINE pair_potential_buck4r_clean(buck4r)
    2084              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r
    2085              : 
    2086       570255 :       IF (.NOT. ASSOCIATED(buck4r)) RETURN
    2087          506 :       buck4r%a = 0.0_dp
    2088          506 :       buck4r%b = 0.0_dp
    2089          506 :       buck4r%c = 0.0_dp
    2090          506 :       buck4r%r1 = 0.0_dp
    2091          506 :       buck4r%r2 = 0.0_dp
    2092          506 :       buck4r%r3 = 0.0_dp
    2093         6072 :       buck4r%poly1 = 0.0_dp
    2094          506 :       buck4r%npoly1 = 0
    2095         6072 :       buck4r%poly2 = 0.0_dp
    2096          506 :       buck4r%npoly2 = 0
    2097              :    END SUBROUTINE pair_potential_buck4r_clean
    2098              : 
    2099              : ! **************************************************************************************************
    2100              : !> \brief Destroys the Buckingham 4 ranges potential type
    2101              : !> \param buck4r ...
    2102              : !> \author MI  10.2006
    2103              : ! **************************************************************************************************
    2104       525590 :    SUBROUTINE pair_potential_buck4r_release(buck4r)
    2105              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r
    2106              : 
    2107       525590 :       IF (ASSOCIATED(buck4r)) THEN
    2108          506 :          DEALLOCATE (buck4r)
    2109              :       END IF
    2110       525590 :       NULLIFY (buck4r)
    2111       525590 :    END SUBROUTINE pair_potential_buck4r_release
    2112              : 
    2113              : ! **************************************************************************************************
    2114              : !> \brief Creates the Buckingham plus Morse potential type
    2115              : !> \param buckmo ...
    2116              : !> \author MI 10.2006
    2117              : ! **************************************************************************************************
    2118           24 :    SUBROUTINE pair_potential_buckmo_create(buckmo)
    2119              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo
    2120              : 
    2121           24 :       CPASSERT(.NOT. ASSOCIATED(buckmo))
    2122           24 :       ALLOCATE (buckmo)
    2123           24 :       CALL pair_potential_buckmo_clean(buckmo)
    2124           24 :    END SUBROUTINE pair_potential_buckmo_create
    2125              : 
    2126              : ! **************************************************************************************************
    2127              : !> \brief Copy two Buckingham plus Morse  potential type
    2128              : !> \param buckmo_source ...
    2129              : !> \param buckmo_dest ...
    2130              : !> \author MI 10.2006
    2131              : ! **************************************************************************************************
    2132        12454 :    SUBROUTINE pair_potential_buckmo_copy(buckmo_source, buckmo_dest)
    2133              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo_source, buckmo_dest
    2134              : 
    2135        12454 :       IF (.NOT. ASSOCIATED(buckmo_source)) RETURN
    2136           10 :       IF (ASSOCIATED(buckmo_dest)) CALL pair_potential_buckmo_release(buckmo_dest)
    2137           10 :       CALL pair_potential_buckmo_create(buckmo_dest)
    2138           10 :       buckmo_dest%f0 = buckmo_source%f0
    2139           10 :       buckmo_dest%a1 = buckmo_source%a1
    2140           10 :       buckmo_dest%a2 = buckmo_source%a2
    2141           10 :       buckmo_dest%b1 = buckmo_source%b1
    2142           10 :       buckmo_dest%b2 = buckmo_source%b2
    2143           10 :       buckmo_dest%c = buckmo_source%c
    2144           10 :       buckmo_dest%d = buckmo_source%d
    2145           10 :       buckmo_dest%r0 = buckmo_source%r0
    2146           10 :       buckmo_dest%beta = buckmo_source%beta
    2147              :    END SUBROUTINE pair_potential_buckmo_copy
    2148              : 
    2149              : ! **************************************************************************************************
    2150              : !> \brief Creates the Buckingham plus Morse  potential type
    2151              : !> \param buckmo ...
    2152              : !> \author MI 10.2006
    2153              : ! **************************************************************************************************
    2154       569773 :    SUBROUTINE pair_potential_buckmo_clean(buckmo)
    2155              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo
    2156              : 
    2157       569773 :       IF (.NOT. ASSOCIATED(buckmo)) RETURN
    2158           24 :       buckmo%f0 = 0.0_dp
    2159           24 :       buckmo%a1 = 0.0_dp
    2160           24 :       buckmo%a2 = 0.0_dp
    2161           24 :       buckmo%b1 = 0.0_dp
    2162           24 :       buckmo%b2 = 0.0_dp
    2163           24 :       buckmo%c = 0.0_dp
    2164           24 :       buckmo%d = 0.0_dp
    2165           24 :       buckmo%r0 = 0.0_dp
    2166           24 :       buckmo%beta = 0.0_dp
    2167              :    END SUBROUTINE pair_potential_buckmo_clean
    2168              : 
    2169              : ! **************************************************************************************************
    2170              : !> \brief Destroys the Buckingham plus Morse potential type
    2171              : !> \param buckmo ...
    2172              : !> \author MI  10.2006
    2173              : ! **************************************************************************************************
    2174       525590 :    SUBROUTINE pair_potential_buckmo_release(buckmo)
    2175              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo
    2176              : 
    2177       525590 :       IF (ASSOCIATED(buckmo)) THEN
    2178           24 :          DEALLOCATE (buckmo)
    2179              :       END IF
    2180       525590 :       NULLIFY (buckmo)
    2181       525590 :    END SUBROUTINE pair_potential_buckmo_release
    2182              : 
    2183              : ! **************************************************************************************************
    2184              : !> \brief Creates the Tersoff potential type
    2185              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2186              : !> \param tersoff ...
    2187              : ! **************************************************************************************************
    2188         1564 :    SUBROUTINE pair_potential_tersoff_create(tersoff)
    2189              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff
    2190              : 
    2191         1564 :       CPASSERT(.NOT. ASSOCIATED(tersoff))
    2192         1564 :       ALLOCATE (tersoff)
    2193         1564 :       CALL pair_potential_tersoff_clean(tersoff)
    2194         1564 :    END SUBROUTINE pair_potential_tersoff_create
    2195              : 
    2196              : ! **************************************************************************************************
    2197              : !> \brief Copy two Tersoff potential type
    2198              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2199              : !> \param tersoff_source ...
    2200              : !> \param tersoff_dest ...
    2201              : ! **************************************************************************************************
    2202        12454 :    SUBROUTINE pair_potential_tersoff_copy(tersoff_source, tersoff_dest)
    2203              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff_source, tersoff_dest
    2204              : 
    2205        12454 :       IF (.NOT. ASSOCIATED(tersoff_source)) RETURN
    2206         1522 :       IF (ASSOCIATED(tersoff_dest)) CALL pair_potential_tersoff_release(tersoff_dest)
    2207         1522 :       CALL pair_potential_tersoff_create(tersoff_dest)
    2208         1522 :       tersoff_dest%A = tersoff_source%A
    2209         1522 :       tersoff_dest%B = tersoff_source%B
    2210         1522 :       tersoff_dest%lambda1 = tersoff_source%lambda1
    2211         1522 :       tersoff_dest%lambda2 = tersoff_source%lambda2
    2212         1522 :       tersoff_dest%alpha = tersoff_source%alpha
    2213         1522 :       tersoff_dest%beta = tersoff_source%beta
    2214         1522 :       tersoff_dest%n = tersoff_source%n
    2215         1522 :       tersoff_dest%c = tersoff_source%c
    2216         1522 :       tersoff_dest%d = tersoff_source%d
    2217         1522 :       tersoff_dest%h = tersoff_source%h
    2218         1522 :       tersoff_dest%lambda3 = tersoff_source%lambda3
    2219         1522 :       tersoff_dest%bigR = tersoff_source%bigR
    2220         1522 :       tersoff_dest%bigD = tersoff_source%bigD
    2221         1522 :       tersoff_dest%rcutsq = tersoff_source%rcutsq
    2222              :    END SUBROUTINE pair_potential_tersoff_copy
    2223              : 
    2224              : ! **************************************************************************************************
    2225              : !> \brief Creates the Tersoff potential type
    2226              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2227              : !> \param tersoff ...
    2228              : ! **************************************************************************************************
    2229       571313 :    SUBROUTINE pair_potential_tersoff_clean(tersoff)
    2230              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff
    2231              : 
    2232       571313 :       IF (.NOT. ASSOCIATED(tersoff)) RETURN
    2233         2970 :       tersoff%A = 0.0_dp
    2234         2970 :       tersoff%B = 0.0_dp
    2235         2970 :       tersoff%lambda1 = 0.0_dp
    2236         2970 :       tersoff%lambda2 = 0.0_dp
    2237         2970 :       tersoff%alpha = 0.0_dp
    2238         2970 :       tersoff%beta = 0.0_dp
    2239         2970 :       tersoff%n = 0.0_dp
    2240         2970 :       tersoff%c = 0.0_dp
    2241         2970 :       tersoff%d = 0.0_dp
    2242         2970 :       tersoff%h = 0.0_dp
    2243         2970 :       tersoff%lambda3 = 0.0_dp
    2244         2970 :       tersoff%bigR = 0.0_dp
    2245         2970 :       tersoff%bigD = 0.0_dp
    2246         2970 :       tersoff%rcutsq = 0.0_dp
    2247              :    END SUBROUTINE pair_potential_tersoff_clean
    2248              : 
    2249              : ! **************************************************************************************************
    2250              : !> \brief Destroys the Tersoff
    2251              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2252              : !> \param tersoff ...
    2253              : ! **************************************************************************************************
    2254       525590 :    SUBROUTINE pair_potential_tersoff_release(tersoff)
    2255              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff
    2256              : 
    2257       525590 :       IF (ASSOCIATED(tersoff)) THEN
    2258         1564 :          DEALLOCATE (tersoff)
    2259              :       END IF
    2260       525590 :       NULLIFY (tersoff)
    2261       525590 :    END SUBROUTINE pair_potential_tersoff_release
    2262              : 
    2263              : ! **************************************************************************************************
    2264              : !> \brief Creates the Siepmann-Sprik potential type
    2265              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2266              : !> \param siepmann ...
    2267              : ! **************************************************************************************************
    2268           10 :    SUBROUTINE pair_potential_siepmann_create(siepmann)
    2269              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann
    2270              : 
    2271           10 :       CPASSERT(.NOT. ASSOCIATED(siepmann))
    2272           10 :       ALLOCATE (siepmann)
    2273           10 :       CALL pair_potential_siepmann_clean(siepmann)
    2274           10 :    END SUBROUTINE pair_potential_siepmann_create
    2275              : ! **************************************************************************************************
    2276              : !> \brief Copy two Siepmann potential type
    2277              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2278              : !> \param siepmann_source ...
    2279              : !> \param siepmann_dest ...
    2280              : ! **************************************************************************************************
    2281        12454 :    SUBROUTINE pair_potential_siepmann_copy(siepmann_source, siepmann_dest)
    2282              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann_source, siepmann_dest
    2283              : 
    2284        12454 :       IF (.NOT. ASSOCIATED(siepmann_source)) RETURN
    2285            5 :       IF (ASSOCIATED(siepmann_dest)) CALL pair_potential_siepmann_release(siepmann_dest)
    2286            5 :       CALL pair_potential_siepmann_create(siepmann_dest)
    2287            5 :       siepmann_dest%B = siepmann_source%B
    2288            5 :       siepmann_dest%D = siepmann_source%D
    2289            5 :       siepmann_dest%E = siepmann_source%E
    2290            5 :       siepmann_dest%F = siepmann_source%F
    2291            5 :       siepmann_dest%beta = siepmann_source%beta
    2292            5 :       siepmann_dest%rcutsq = siepmann_source%rcutsq
    2293            5 :       siepmann_dest%allow_oh_formation = siepmann_source%allow_oh_formation
    2294            5 :       siepmann_dest%allow_h3o_formation = siepmann_source%allow_h3o_formation
    2295            5 :       siepmann_dest%allow_o_formation = siepmann_source%allow_o_formation
    2296              : 
    2297              :    END SUBROUTINE pair_potential_siepmann_copy
    2298              : 
    2299              : ! **************************************************************************************************
    2300              : !> \brief Creates the Siepmann-Sprik potential type
    2301              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2302              : !> \param siepmann ...
    2303              : ! **************************************************************************************************
    2304       569759 :    SUBROUTINE pair_potential_siepmann_clean(siepmann)
    2305              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann
    2306              : 
    2307       569759 :       IF (.NOT. ASSOCIATED(siepmann)) RETURN
    2308           10 :       siepmann%B = 0.0_dp
    2309           10 :       siepmann%D = 0.0_dp
    2310           10 :       siepmann%E = 0.0_dp
    2311           10 :       siepmann%F = 0.0_dp
    2312           10 :       siepmann%beta = 0.0_dp
    2313           10 :       siepmann%rcutsq = 0.0_dp
    2314           10 :       siepmann%allow_oh_formation = .FALSE.
    2315           10 :       siepmann%allow_h3o_formation = .FALSE.
    2316           10 :       siepmann%allow_o_formation = .FALSE.
    2317              : 
    2318              :    END SUBROUTINE pair_potential_siepmann_clean
    2319              : 
    2320              : ! **************************************************************************************************
    2321              : !> \brief Destroys the Siepmann-Sprik potential
    2322              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2323              : !> \param siepmann ...
    2324              : ! **************************************************************************************************
    2325       525590 :    SUBROUTINE pair_potential_siepmann_release(siepmann)
    2326              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann
    2327              : 
    2328       525590 :       IF (ASSOCIATED(siepmann)) THEN
    2329           10 :          DEALLOCATE (siepmann)
    2330              :       END IF
    2331       525590 :       NULLIFY (siepmann)
    2332       525590 :    END SUBROUTINE pair_potential_siepmann_release
    2333              : 
    2334              : ! **************************************************************************************************
    2335              : !> \brief Creates the GAL19 potential type
    2336              : !>      (??)
    2337              : !> \param gal ...
    2338              : ! **************************************************************************************************
    2339            2 :    SUBROUTINE pair_potential_gal_create(gal)
    2340              :       TYPE(gal_pot_type), POINTER                        :: gal
    2341              : 
    2342            2 :       CPASSERT(.NOT. ASSOCIATED(gal))
    2343            2 :       ALLOCATE (gal)
    2344            2 :       CALL pair_potential_gal_clean(gal)
    2345            2 :    END SUBROUTINE pair_potential_gal_create
    2346              : 
    2347              : ! **************************************************************************************************
    2348              : !> \brief Copy two GAL potential type
    2349              : !>      (??)
    2350              : !> \param gal_source ...
    2351              : !> \param gal_dest ...
    2352              : ! **************************************************************************************************
    2353        12454 :    SUBROUTINE pair_potential_gal_copy(gal_source, gal_dest)
    2354              :       TYPE(gal_pot_type), POINTER                        :: gal_source, gal_dest
    2355              : 
    2356        12454 :       IF (.NOT. ASSOCIATED(gal_source)) RETURN
    2357            1 :       IF (ASSOCIATED(gal_dest)) CALL pair_potential_gal_release(gal_dest)
    2358            1 :       CALL pair_potential_gal_create(gal_dest)
    2359            1 :       gal_dest%met1 = gal_source%met1
    2360            1 :       gal_dest%met2 = gal_source%met2
    2361            1 :       gal_dest%epsilon = gal_source%epsilon
    2362            1 :       gal_dest%bxy = gal_source%bxy
    2363            1 :       gal_dest%bz = gal_source%bz
    2364            1 :       gal_dest%r1 = gal_source%r1
    2365            1 :       gal_dest%r2 = gal_source%r2
    2366            1 :       gal_dest%a1 = gal_source%a1
    2367            1 :       gal_dest%a2 = gal_source%a2
    2368            1 :       gal_dest%a3 = gal_source%a3
    2369            1 :       gal_dest%a4 = gal_source%a4
    2370            1 :       gal_dest%a = gal_source%a
    2371            1 :       gal_dest%b = gal_source%b
    2372            1 :       gal_dest%c = gal_source%c
    2373            3 :       ALLOCATE (gal_dest%gcn(SIZE(gal_source%gcn)))
    2374         1741 :       gal_dest%gcn = gal_source%gcn
    2375            1 :       gal_dest%express = gal_source%express
    2376            1 :       gal_dest%rcutsq = gal_source%rcutsq
    2377              : 
    2378              :    END SUBROUTINE pair_potential_gal_copy
    2379              : 
    2380              : ! **************************************************************************************************
    2381              : !> \brief Creates the GAL19 potential type
    2382              : !>      (??)
    2383              : !> \param gal ...
    2384              : ! **************************************************************************************************
    2385       569751 :    SUBROUTINE pair_potential_gal_clean(gal)
    2386              :       TYPE(gal_pot_type), POINTER                        :: gal
    2387              : 
    2388       569751 :       IF (.NOT. ASSOCIATED(gal)) RETURN
    2389            2 :       gal%epsilon = 0.0_dp
    2390            2 :       gal%bxy = 0.0_dp
    2391            2 :       gal%bz = 0.0_dp
    2392            2 :       gal%r1 = 0.0_dp
    2393            2 :       gal%r2 = 0.0_dp
    2394            2 :       gal%a1 = 0.0_dp
    2395            2 :       gal%a2 = 0.0_dp
    2396            2 :       gal%a3 = 0.0_dp
    2397            2 :       gal%a4 = 0.0_dp
    2398            2 :       gal%a = 0.0_dp
    2399            2 :       gal%b = 0.0_dp
    2400            2 :       gal%c = 0.0_dp
    2401            2 :       gal%rcutsq = 0.0_dp
    2402            2 :       gal%express = .FALSE.
    2403              : 
    2404              :    END SUBROUTINE pair_potential_gal_clean
    2405              : 
    2406              : ! **************************************************************************************************
    2407              : !> \brief Destroys the GAL19 potential
    2408              : !>      (??)
    2409              : !> \param gal ...
    2410              : ! **************************************************************************************************
    2411       525590 :    SUBROUTINE pair_potential_gal_release(gal)
    2412              :       TYPE(gal_pot_type), POINTER                        :: gal
    2413              : 
    2414       525590 :       IF (ASSOCIATED(gal)) THEN
    2415            2 :          DEALLOCATE (gal%gcn)
    2416            2 :          DEALLOCATE (gal)
    2417              :       END IF
    2418       525590 :       NULLIFY (gal)
    2419       525590 :    END SUBROUTINE pair_potential_gal_release
    2420              : 
    2421              : ! **************************************************************************************************
    2422              : !> \brief Creates the GAL21 potential type
    2423              : !>      (??)
    2424              : !> \param gal21 ...
    2425              : ! **************************************************************************************************
    2426            2 :    SUBROUTINE pair_potential_gal21_create(gal21)
    2427              :       TYPE(gal21_pot_type), POINTER                      :: gal21
    2428              : 
    2429            2 :       CPASSERT(.NOT. ASSOCIATED(gal21))
    2430            2 :       ALLOCATE (gal21)
    2431            2 :       CALL pair_potential_gal21_clean(gal21)
    2432            2 :    END SUBROUTINE pair_potential_gal21_create
    2433              : 
    2434              : ! **************************************************************************************************
    2435              : !> \brief Copy two GAL21 potential type
    2436              : !>      (??)
    2437              : !> \param gal21_source ...
    2438              : !> \param gal21_dest ...
    2439              : ! **************************************************************************************************
    2440        12454 :    SUBROUTINE pair_potential_gal21_copy(gal21_source, gal21_dest)
    2441              :       TYPE(gal21_pot_type), POINTER                      :: gal21_source, gal21_dest
    2442              : 
    2443        12454 :       IF (.NOT. ASSOCIATED(gal21_source)) RETURN
    2444            1 :       IF (ASSOCIATED(gal21_dest)) CALL pair_potential_gal21_release(gal21_dest)
    2445            1 :       CALL pair_potential_gal21_create(gal21_dest)
    2446            1 :       gal21_dest%met1 = gal21_source%met1
    2447            1 :       gal21_dest%met2 = gal21_source%met2
    2448            1 :       gal21_dest%epsilon1 = gal21_source%epsilon1
    2449            1 :       gal21_dest%epsilon2 = gal21_source%epsilon2
    2450            1 :       gal21_dest%epsilon3 = gal21_source%epsilon3
    2451            1 :       gal21_dest%bxy1 = gal21_source%bxy1
    2452            1 :       gal21_dest%bxy2 = gal21_source%bxy2
    2453            1 :       gal21_dest%bz1 = gal21_source%bz1
    2454            1 :       gal21_dest%bz2 = gal21_source%bz2
    2455            1 :       gal21_dest%r1 = gal21_source%r1
    2456            1 :       gal21_dest%r2 = gal21_source%r2
    2457            1 :       gal21_dest%a11 = gal21_source%a11
    2458            1 :       gal21_dest%a12 = gal21_source%a12
    2459            1 :       gal21_dest%a13 = gal21_source%a13
    2460            1 :       gal21_dest%a21 = gal21_source%a21
    2461            1 :       gal21_dest%a22 = gal21_source%a22
    2462            1 :       gal21_dest%a23 = gal21_source%a23
    2463            1 :       gal21_dest%a31 = gal21_source%a31
    2464            1 :       gal21_dest%a32 = gal21_source%a32
    2465            1 :       gal21_dest%a33 = gal21_source%a33
    2466            1 :       gal21_dest%a41 = gal21_source%a41
    2467            1 :       gal21_dest%a42 = gal21_source%a42
    2468            1 :       gal21_dest%a43 = gal21_source%a43
    2469            1 :       gal21_dest%AO1 = gal21_source%AO1
    2470            1 :       gal21_dest%AO2 = gal21_source%AO2
    2471            1 :       gal21_dest%BO1 = gal21_source%BO1
    2472            1 :       gal21_dest%BO2 = gal21_source%BO2
    2473            1 :       gal21_dest%c = gal21_source%c
    2474            1 :       gal21_dest%AH1 = gal21_source%AH1
    2475            1 :       gal21_dest%AH2 = gal21_source%AH2
    2476            1 :       gal21_dest%BH1 = gal21_source%BH1
    2477            1 :       gal21_dest%BH2 = gal21_source%BH2
    2478            3 :       ALLOCATE (gal21_dest%gcn(SIZE(gal21_source%gcn)))
    2479         1741 :       gal21_dest%gcn = gal21_source%gcn
    2480            1 :       gal21_dest%express = gal21_source%express
    2481            1 :       gal21_dest%rcutsq = gal21_source%rcutsq
    2482              : 
    2483              :    END SUBROUTINE pair_potential_gal21_copy
    2484              : 
    2485              : ! **************************************************************************************************
    2486              : !> \brief Creates the GAL21 potential type
    2487              : !>      (??)
    2488              : !> \param gal21 ...
    2489              : ! **************************************************************************************************
    2490       569751 :    SUBROUTINE pair_potential_gal21_clean(gal21)
    2491              :       TYPE(gal21_pot_type), POINTER                      :: gal21
    2492              : 
    2493       569751 :       IF (.NOT. ASSOCIATED(gal21)) RETURN
    2494            2 :       gal21%epsilon1 = 0.0_dp
    2495            2 :       gal21%epsilon2 = 0.0_dp
    2496            2 :       gal21%epsilon3 = 0.0_dp
    2497            2 :       gal21%bxy1 = 0.0_dp
    2498            2 :       gal21%bxy2 = 0.0_dp
    2499            2 :       gal21%bz1 = 0.0_dp
    2500            2 :       gal21%bz2 = 0.0_dp
    2501            2 :       gal21%r1 = 0.0_dp
    2502            2 :       gal21%r2 = 0.0_dp
    2503            2 :       gal21%a11 = 0.0_dp
    2504            2 :       gal21%a12 = 0.0_dp
    2505            2 :       gal21%a13 = 0.0_dp
    2506            2 :       gal21%a21 = 0.0_dp
    2507            2 :       gal21%a22 = 0.0_dp
    2508            2 :       gal21%a23 = 0.0_dp
    2509            2 :       gal21%a31 = 0.0_dp
    2510            2 :       gal21%a32 = 0.0_dp
    2511            2 :       gal21%a33 = 0.0_dp
    2512            2 :       gal21%a41 = 0.0_dp
    2513            2 :       gal21%a42 = 0.0_dp
    2514            2 :       gal21%a43 = 0.0_dp
    2515            2 :       gal21%AO1 = 0.0_dp
    2516            2 :       gal21%AO2 = 0.0_dp
    2517            2 :       gal21%BO1 = 0.0_dp
    2518            2 :       gal21%BO2 = 0.0_dp
    2519            2 :       gal21%c = 0.0_dp
    2520            2 :       gal21%AH1 = 0.0_dp
    2521            2 :       gal21%AH2 = 0.0_dp
    2522            2 :       gal21%BH1 = 0.0_dp
    2523            2 :       gal21%BH2 = 0.0_dp
    2524            2 :       gal21%rcutsq = 0.0_dp
    2525            2 :       gal21%express = .FALSE.
    2526              : 
    2527              :    END SUBROUTINE pair_potential_gal21_clean
    2528              : 
    2529              : ! **************************************************************************************************
    2530              : !> \brief Destroys the GAL21 potential
    2531              : !>      (??)
    2532              : !> \param gal21 ...
    2533              : ! **************************************************************************************************
    2534       525590 :    SUBROUTINE pair_potential_gal21_release(gal21)
    2535              :       TYPE(gal21_pot_type), POINTER                      :: gal21
    2536              : 
    2537       525590 :       IF (ASSOCIATED(gal21)) THEN
    2538            2 :          DEALLOCATE (gal21%gcn)
    2539            2 :          DEALLOCATE (gal21)
    2540              :       END IF
    2541       525590 :       NULLIFY (gal21)
    2542       525590 :    END SUBROUTINE pair_potential_gal21_release
    2543              : 
    2544              : ! **************************************************************************************************
    2545              : !> \brief Creates the TABPOT potential type
    2546              : !> \param tab ...
    2547              : !> \author Alex Mironenko, Da Teng 2019-2022
    2548              : ! **************************************************************************************************
    2549           48 :    SUBROUTINE pair_potential_tab_create(tab)
    2550              :       TYPE(tab_pot_type), POINTER                        :: tab
    2551              : 
    2552           48 :       CPASSERT(.NOT. ASSOCIATED(tab))
    2553           48 :       ALLOCATE (tab)
    2554              :       NULLIFY (tab%r, tab%e, tab%f)
    2555           48 :       CALL pair_potential_tab_clean(tab)
    2556           48 :    END SUBROUTINE pair_potential_tab_create
    2557              : 
    2558              : ! **************************************************************************************************
    2559              : !> \brief Copy two TABPOT potential type
    2560              : !> \param tab_source ...
    2561              : !> \param tab_dest ...
    2562              : ! **************************************************************************************************
    2563        12454 :    SUBROUTINE pair_potential_tab_copy(tab_source, tab_dest)
    2564              :       TYPE(tab_pot_type), POINTER                        :: tab_source, tab_dest
    2565              : 
    2566        12454 :       IF (.NOT. ASSOCIATED(tab_source)) RETURN
    2567           24 :       IF (ASSOCIATED(tab_dest)) CALL pair_potential_tab_release(tab_dest)
    2568           24 :       CALL pair_potential_tab_create(tab_dest)
    2569           24 :       tab_dest%tabpot_file_name = tab_source%tabpot_file_name
    2570           24 :       tab_dest%dr = tab_source%dr
    2571           24 :       tab_dest%rcut = tab_source%rcut
    2572           24 :       tab_dest%npoints = tab_source%npoints
    2573           24 :       tab_dest%index = tab_source%index
    2574              :       ! Allocate arrays with the proper size
    2575           24 :       CALL reallocate(tab_dest%r, 1, tab_dest%npoints)
    2576           24 :       CALL reallocate(tab_dest%e, 1, tab_dest%npoints)
    2577           24 :       CALL reallocate(tab_dest%f, 1, tab_dest%npoints)
    2578        43800 :       tab_dest%r = tab_source%r
    2579        43800 :       tab_dest%e = tab_source%e
    2580        43800 :       tab_dest%f = tab_source%f
    2581              :    END SUBROUTINE pair_potential_tab_copy
    2582              : 
    2583              : ! **************************************************************************************************
    2584              : !> \brief Creates the TABPOT potential type
    2585              : !> \param tab ...
    2586              : ! **************************************************************************************************
    2587       569797 :    SUBROUTINE pair_potential_tab_clean(tab)
    2588              :       TYPE(tab_pot_type), POINTER                        :: tab
    2589              : 
    2590       569797 :       IF (.NOT. ASSOCIATED(tab)) RETURN
    2591           48 :       tab%tabpot_file_name = 'NULL'
    2592           48 :       tab%dr = 0.0_dp
    2593           48 :       tab%rcut = 0.0_dp
    2594           48 :       tab%npoints = 0
    2595           48 :       tab%index = 0
    2596           48 :       CALL reallocate(tab%r, 1, tab%npoints)
    2597           48 :       CALL reallocate(tab%e, 1, tab%npoints)
    2598           48 :       CALL reallocate(tab%f, 1, tab%npoints)
    2599              : 
    2600              :    END SUBROUTINE pair_potential_tab_clean
    2601              : 
    2602              : ! **************************************************************************************************
    2603              : !> \brief Destroys the TABPOT potential type
    2604              : !> \param tab ...
    2605              : ! **************************************************************************************************
    2606       525590 :    SUBROUTINE pair_potential_tab_release(tab)
    2607              :       TYPE(tab_pot_type), POINTER                        :: tab
    2608              : 
    2609       525590 :       IF (ASSOCIATED(tab)) THEN
    2610           48 :          IF (ASSOCIATED(tab%r)) THEN
    2611           48 :             DEALLOCATE (tab%r)
    2612              :          END IF
    2613           48 :          IF (ASSOCIATED(tab%e)) THEN
    2614           48 :             DEALLOCATE (tab%e)
    2615              :          END IF
    2616           48 :          IF (ASSOCIATED(tab%f)) THEN
    2617           48 :             DEALLOCATE (tab%f)
    2618              :          END IF
    2619           48 :          DEALLOCATE (tab)
    2620              :       END IF
    2621       525590 :    END SUBROUTINE pair_potential_tab_release
    2622              : 
    2623            0 : END MODULE pair_potential_types
    2624              : 
        

Generated by: LCOV version 2.0-1