LCOV - code coverage report
Current view: top level - src - pair_potential_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:5064cfc) Lines: 92.2 % 1084 999
Test Date: 2026-03-04 06:45:10 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       525710 :    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       525710 :       CPASSERT(.NOT. ASSOCIATED(potparm))
     593      5782810 :       ALLOCATE (potparm)
     594       525710 :       lnset = 1
     595       525710 :       IF (PRESENT(nset)) lnset = nset
     596              :       ! Standard allocation to size 1
     597      1577130 :       ALLOCATE (potparm%type(lnset))
     598      2102848 :       ALLOCATE (potparm%set(lnset))
     599              :       NULLIFY (potparm%spl_f, &
     600       525710 :                potparm%pair_spline_data)
     601      1051428 :       DO i = 1, lnset
     602       525718 :          potparm%set(i)%rmin = not_initialized
     603       525718 :          potparm%set(i)%rmax = not_initialized
     604              :          NULLIFY (potparm%set(i)%ipbv, &
     605       525718 :                   potparm%set(i)%lj, &
     606       525718 :                   potparm%set(i)%gp, &
     607       525718 :                   potparm%set(i)%ft, &
     608       525718 :                   potparm%set(i)%willis, &
     609       525718 :                   potparm%set(i)%goodwin, &
     610       525718 :                   potparm%set(i)%eam, &
     611       525718 :                   potparm%set(i)%nequip, &
     612       525718 :                   potparm%set(i)%ace, &
     613       525718 :                   potparm%set(i)%deepmd, &
     614       525718 :                   potparm%set(i)%buck4r, &
     615       525718 :                   potparm%set(i)%buckmo, &
     616       525718 :                   potparm%set(i)%tersoff, &
     617       525718 :                   potparm%set(i)%siepmann, &
     618       525718 :                   potparm%set(i)%gal, &
     619       525718 :                   potparm%set(i)%gal21, &
     620       525718 :                   potparm%set(i)%ftd, &
     621      1051428 :                   potparm%set(i)%tab)
     622              :       END DO
     623       525710 :       CALL pair_potential_single_clean(potparm)
     624       525710 :    END SUBROUTINE pair_potential_single_create
     625              : 
     626              : ! **************************************************************************************************
     627              : !> \brief Cleans the potential parameter type
     628              : !> \param potparm ...
     629              : !> \author unknown
     630              : ! **************************************************************************************************
     631       569985 :    SUBROUTINE pair_potential_single_clean(potparm)
     632              :       TYPE(pair_potential_single_type), POINTER          :: potparm
     633              : 
     634              :       INTEGER                                            :: i
     635              : 
     636      1139978 :       potparm%type = nn_type
     637       569985 :       potparm%shell_type = nosh_nosh
     638       569985 :       potparm%undef = .TRUE.
     639       569985 :       potparm%no_pp = .FALSE.
     640       569985 :       potparm%no_mb = .FALSE.
     641       569985 :       potparm%at1 = 'NULL'
     642       569985 :       potparm%at2 = 'NULL'
     643       569985 :       potparm%rcutsq = 0.0_dp
     644       569985 :       IF (ASSOCIATED(potparm%pair_spline_data)) &
     645            0 :          CALL spline_data_p_release(potparm%pair_spline_data)
     646       569985 :       IF (ASSOCIATED(potparm%spl_f)) &
     647            0 :          CALL spline_factor_release(potparm%spl_f)
     648              : 
     649      1139978 :       DO i = 1, SIZE(potparm%type)
     650       569993 :          potparm%set(i)%rmin = not_initialized
     651       569993 :          potparm%set(i)%rmax = not_initialized
     652       569993 :          CALL pair_potential_lj_clean(potparm%set(i)%lj)
     653       569993 :          CALL pair_potential_williams_clean(potparm%set(i)%willis)
     654       569993 :          CALL pair_potential_goodwin_clean(potparm%set(i)%goodwin)
     655       569993 :          CALL pair_potential_eam_clean(potparm%set(i)%eam)
     656       569993 :          CALL pair_potential_nequip_clean(potparm%set(i)%nequip)
     657       569993 :          CALL pair_potential_ace_clean(potparm%set(i)%ace)
     658       569993 :          CALL pair_potential_deepmd_clean(potparm%set(i)%deepmd)
     659       569993 :          CALL pair_potential_buck4r_clean(potparm%set(i)%buck4r)
     660       569993 :          CALL pair_potential_buckmo_clean(potparm%set(i)%buckmo)
     661       569993 :          CALL pair_potential_bmhft_clean(potparm%set(i)%ft)
     662       569993 :          CALL pair_potential_bmhftd_clean(potparm%set(i)%ftd)
     663       569993 :          CALL pair_potential_ipbv_clean(potparm%set(i)%ipbv)
     664       569993 :          CALL pair_potential_gp_clean(potparm%set(i)%gp)
     665       569993 :          CALL pair_potential_tersoff_clean(potparm%set(i)%tersoff)
     666       569993 :          CALL pair_potential_siepmann_clean(potparm%set(i)%siepmann)
     667       569993 :          CALL pair_potential_gal_clean(potparm%set(i)%gal)
     668       569993 :          CALL pair_potential_gal21_clean(potparm%set(i)%gal21)
     669      1139978 :          CALL pair_potential_tab_clean(potparm%set(i)%tab)
     670              :       END DO
     671       569985 :    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        12484 :    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        12484 :       CPASSERT(ASSOCIATED(potparm_source))
     685        12484 :       IF (.NOT. ASSOCIATED(potparm_dest)) THEN
     686            8 :          CALL pair_potential_single_create(potparm_dest, SIZE(potparm_source%type))
     687              :       ELSE
     688        12476 :          CALL pair_potential_single_clean(potparm_dest)
     689              :       END IF
     690        49936 :       potparm_dest%type = potparm_source%type
     691        12484 :       potparm_dest%shell_type = potparm_source%shell_type
     692        12484 :       potparm_dest%undef = potparm_source%undef
     693        12484 :       potparm_dest%no_mb = potparm_source%no_mb
     694        12484 :       potparm_dest%no_pp = potparm_source%no_pp
     695        12484 :       potparm_dest%at1 = potparm_source%at1
     696        12484 :       potparm_dest%at2 = potparm_source%at2
     697        12484 :       potparm_dest%rcutsq = potparm_source%rcutsq
     698        12484 :       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        12484 :       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        24968 :       DO i = 1, SIZE(potparm_source%type)
     707        12484 :          potparm_dest%set(i)%rmin = potparm_source%set(i)%rmin
     708        12484 :          potparm_dest%set(i)%rmax = potparm_source%set(i)%rmax
     709        12484 :          CALL pair_potential_lj_copy(potparm_source%set(i)%lj, potparm_dest%set(i)%lj)
     710        12484 :          CALL pair_potential_williams_copy(potparm_source%set(i)%willis, potparm_dest%set(i)%willis)
     711        12484 :          CALL pair_potential_goodwin_copy(potparm_source%set(i)%goodwin, potparm_dest%set(i)%goodwin)
     712        12484 :          CALL pair_potential_eam_copy(potparm_source%set(i)%eam, potparm_dest%set(i)%eam)
     713        12484 :          CALL pair_potential_nequip_copy(potparm_source%set(i)%nequip, potparm_dest%set(i)%nequip)
     714        12484 :          CALL pair_potential_ace_copy(potparm_source%set(i)%ace, potparm_dest%set(i)%ace)
     715        12484 :          CALL pair_potential_deepmd_copy(potparm_source%set(i)%deepmd, potparm_dest%set(i)%deepmd)
     716        12484 :          CALL pair_potential_bmhft_copy(potparm_source%set(i)%ft, potparm_dest%set(i)%ft)
     717        12484 :          CALL pair_potential_bmhftd_copy(potparm_source%set(i)%ftd, potparm_dest%set(i)%ftd)
     718        12484 :          CALL pair_potential_ipbv_copy(potparm_source%set(i)%ipbv, potparm_dest%set(i)%ipbv)
     719        12484 :          CALL pair_potential_buck4r_copy(potparm_source%set(i)%buck4r, potparm_dest%set(i)%buck4r)
     720        12484 :          CALL pair_potential_buckmo_copy(potparm_source%set(i)%buckmo, potparm_dest%set(i)%buckmo)
     721        12484 :          CALL pair_potential_gp_copy(potparm_source%set(i)%gp, potparm_dest%set(i)%gp)
     722        12484 :          CALL pair_potential_tersoff_copy(potparm_source%set(i)%tersoff, potparm_dest%set(i)%tersoff)
     723        12484 :          CALL pair_potential_siepmann_copy(potparm_source%set(i)%siepmann, potparm_dest%set(i)%siepmann)
     724        12484 :          CALL pair_potential_gal_copy(potparm_source%set(i)%gal, potparm_dest%set(i)%gal)
     725        12484 :          CALL pair_potential_gal21_copy(potparm_source%set(i)%gal21, potparm_dest%set(i)%gal21)
     726        24968 :          CALL pair_potential_tab_copy(potparm_source%set(i)%tab, potparm_dest%set(i)%tab)
     727              :       END DO
     728        12484 :    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       525710 :    SUBROUTINE pair_potential_single_release(potparm)
     874              :       TYPE(pair_potential_single_type), POINTER          :: potparm
     875              : 
     876              :       INTEGER                                            :: i
     877              : 
     878       525710 :       CPASSERT(ASSOCIATED(potparm))
     879       525710 :       CALL spline_data_p_release(potparm%pair_spline_data)
     880       525710 :       CALL spline_factor_release(potparm%spl_f)
     881      1051428 :       DO i = 1, SIZE(potparm%type)
     882       525718 :          CALL pair_potential_ipbv_release(potparm%set(i)%ipbv)
     883       525718 :          CALL pair_potential_lj_release(potparm%set(i)%lj)
     884       525718 :          CALL pair_potential_bmhft_release(potparm%set(i)%ft)
     885       525718 :          CALL pair_potential_bmhftd_release(potparm%set(i)%ftd)
     886       525718 :          CALL pair_potential_williams_release(potparm%set(i)%willis)
     887       525718 :          CALL pair_potential_goodwin_release(potparm%set(i)%goodwin)
     888       525718 :          CALL pair_potential_eam_release(potparm%set(i)%eam)
     889       525718 :          CALL pair_potential_nequip_release(potparm%set(i)%nequip)
     890       525718 :          CALL pair_potential_ace_release(potparm%set(i)%ace)
     891       525718 :          CALL pair_potential_deepmd_release(potparm%set(i)%deepmd)
     892       525718 :          CALL pair_potential_buck4r_release(potparm%set(i)%buck4r)
     893       525718 :          CALL pair_potential_buckmo_release(potparm%set(i)%buckmo)
     894       525718 :          CALL pair_potential_gp_release(potparm%set(i)%gp)
     895       525718 :          CALL pair_potential_tersoff_release(potparm%set(i)%tersoff)
     896       525718 :          CALL pair_potential_siepmann_release(potparm%set(i)%siepmann)
     897       525718 :          CALL pair_potential_gal_release(potparm%set(i)%gal)
     898       525718 :          CALL pair_potential_gal21_release(potparm%set(i)%gal21)
     899      1051428 :          CALL pair_potential_tab_release(potparm%set(i)%tab)
     900              :       END DO
     901       525710 :       DEALLOCATE (potparm%type)
     902       525710 :       DEALLOCATE (potparm%set)
     903       525710 :       DEALLOCATE (potparm)
     904       525710 :    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         5284 :    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         5284 :       CPASSERT(.NOT. ASSOCIATED(potparm))
     919         5284 :       ALLOCATE (potparm)
     920      1052664 :       ALLOCATE (potparm%pot(nkinds, nkinds))
     921        27826 :       DO i = 1, nkinds
     922      1036812 :          DO j = 1, nkinds
     923      1031528 :             NULLIFY (potparm%pot(i, j)%pot)
     924              :          END DO
     925              :       END DO
     926              :       ! Use no-redundancy in the potential definition
     927        27826 :       DO i = 1, nkinds
     928       543590 :          DO j = i, nkinds
     929       515764 :             CALL pair_potential_single_create(potparm%pot(i, j)%pot)
     930       538306 :             potparm%pot(j, i)%pot => potparm%pot(i, j)%pot
     931              :          END DO
     932              :       END DO
     933         5284 :    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         5380 :    SUBROUTINE pair_potential_pp_release(potparm)
     944              :       TYPE(pair_potential_pp_type), POINTER              :: potparm
     945              : 
     946              :       INTEGER                                            :: i, j
     947              : 
     948         5380 :       IF (ASSOCIATED(potparm)) THEN
     949         5284 :          IF (ASSOCIATED(potparm%pot)) THEN
     950        27826 :             DO i = 1, SIZE(potparm%pot, 1)
     951       543590 :                DO j = i, SIZE(potparm%pot, 2)
     952       515764 :                   CALL pair_potential_single_release(potparm%pot(i, j)%pot)
     953       538306 :                   NULLIFY (potparm%pot(j, i)%pot)
     954              :                END DO
     955              :             END DO
     956         5284 :             DEALLOCATE (potparm%pot)
     957              :          END IF
     958         5284 :          DEALLOCATE (potparm)
     959              :       END IF
     960         5380 :       NULLIFY (potparm)
     961         5380 :    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         2649 :    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         2649 :       CPASSERT(.NOT. ASSOCIATED(potparm))
     978         2649 :       ALLOCATE (potparm)
     979         2649 :       IF (PRESENT(ndim)) THEN
     980            0 :          loc_lb = 1
     981            0 :          loc_ub = ndim
     982            0 :          ALLOCATE (potparm%pot(loc_lb:loc_ub))
     983            0 :          IF (PRESENT(lb) .OR. PRESENT(ub)) THEN
     984            0 :             CPABORT("")
     985              :          END IF
     986         2649 :       ELSE IF (PRESENT(lb) .AND. PRESENT(ub)) THEN
     987         2649 :          loc_lb = lb
     988         2649 :          loc_ub = ub
     989        17847 :          ALLOCATE (potparm%pot(loc_lb:loc_ub))
     990              :          IF (PRESENT(ndim)) THEN
     991              :             CPABORT("")
     992              :          END IF
     993              :       ELSE
     994            0 :          CPABORT("")
     995              :       END IF
     996        12549 :       DO i = loc_lb, loc_ub
     997         9900 :          NULLIFY (potparm%pot(i)%pot)
     998        12549 :          CALL pair_potential_single_create(potparm%pot(i)%pot)
     999              :       END DO
    1000         2649 :    END SUBROUTINE pair_potential_p_create
    1001              : 
    1002              : ! **************************************************************************************************
    1003              : !> \brief Release Data-structure that constains potential parameters
    1004              : !> \param potparm ...
    1005              : !> \par History
    1006              : !>      Teodoro Laino [Teo] 11.2005 : Reorganizing the structures to optimize
    1007              : !>                                    memory management
    1008              : !> \author unknown
    1009              : ! **************************************************************************************************
    1010         2649 :    SUBROUTINE pair_potential_p_release(potparm)
    1011              :       TYPE(pair_potential_p_type), POINTER               :: potparm
    1012              : 
    1013              :       INTEGER                                            :: i
    1014              : 
    1015         2649 :       IF (ASSOCIATED(potparm)) THEN
    1016         2649 :          IF (ASSOCIATED(potparm%pot)) THEN
    1017        12549 :             DO i = 1, SIZE(potparm%pot)
    1018        12549 :                CALL pair_potential_single_release(potparm%pot(i)%pot)
    1019              :             END DO
    1020         2649 :             DEALLOCATE (potparm%pot)
    1021              :          END IF
    1022         2649 :          DEALLOCATE (potparm)
    1023              :       END IF
    1024         2649 :       NULLIFY (potparm)
    1025         2649 :    END SUBROUTINE pair_potential_p_release
    1026              : 
    1027              : ! **************************************************************************************************
    1028              : !> \brief Copy structures between two pair_potential_p_type
    1029              : !> \param source ...
    1030              : !> \param dest ...
    1031              : !> \param istart ...
    1032              : !> \param iend ...
    1033              : !> \author Teodoro Laino [Teo] 11.2005
    1034              : ! **************************************************************************************************
    1035          614 :    SUBROUTINE pair_potential_p_copy(source, dest, istart, iend)
    1036              :       TYPE(pair_potential_p_type), POINTER               :: source, dest
    1037              :       INTEGER, INTENT(IN), OPTIONAL                      :: istart, iend
    1038              : 
    1039              :       INTEGER                                            :: i, l_end, l_start
    1040              : 
    1041          614 :       CPASSERT(ASSOCIATED(source))
    1042          614 :       CPASSERT(ASSOCIATED(dest))
    1043          614 :       l_start = LBOUND(source%pot, 1)
    1044          614 :       l_end = UBOUND(source%pot, 1)
    1045          614 :       IF (PRESENT(istart)) l_start = istart
    1046          614 :       IF (PRESENT(iend)) l_end = iend
    1047         1960 :       DO i = l_start, l_end
    1048         1346 :          IF (.NOT. ASSOCIATED(source%pot(i)%pot)) &
    1049            0 :             CALL pair_potential_single_create(source%pot(i)%pot)
    1050         1960 :          CALL pair_potential_single_copy(source%pot(i)%pot, dest%pot(i)%pot)
    1051              :       END DO
    1052          614 :    END SUBROUTINE pair_potential_p_copy
    1053              : 
    1054              : ! **************************************************************************************************
    1055              : !> \brief Cleans the potential parameter type
    1056              : !> \param p ...
    1057              : !> \param lb1_new ...
    1058              : !> \param ub1_new ...
    1059              : !> \param lj ...
    1060              : !> \param lj_charmm ...
    1061              : !> \param williams ...
    1062              : !> \param goodwin ...
    1063              : !> \param eam ...
    1064              : !> \param nequip ...
    1065              : !> \param bmhft ...
    1066              : !> \param bmhftd ...
    1067              : !> \param ipbv ...
    1068              : !> \param buck4r ...
    1069              : !> \param buckmo ...
    1070              : !> \param gp ...
    1071              : !> \param tersoff ...
    1072              : !> \param siepmann ...
    1073              : !> \param gal ...
    1074              : !> \param gal21 ...
    1075              : !> \param tab ...
    1076              : !> \param deepmd ...
    1077              : !> \param ace ...
    1078              : !> \author Teodoro Laino [Teo] 11.2005
    1079              : ! **************************************************************************************************
    1080         2342 :    SUBROUTINE pair_potential_reallocate(p, lb1_new, ub1_new, lj, lj_charmm, williams, goodwin, eam, &
    1081              :                                         nequip, bmhft, bmhftd, ipbv, buck4r, buckmo, &
    1082              :                                         gp, tersoff, siepmann, gal, gal21, tab, deepmd, ace)
    1083              :       TYPE(pair_potential_p_type), POINTER               :: p
    1084              :       INTEGER, INTENT(IN)                                :: lb1_new, ub1_new
    1085              :       LOGICAL, INTENT(IN), OPTIONAL :: lj, lj_charmm, williams, goodwin, eam, nequip, bmhft, &
    1086              :          bmhftd, ipbv, buck4r, buckmo, gp, tersoff, siepmann, gal, gal21, tab, deepmd, ace
    1087              : 
    1088              :       INTEGER                                            :: i, ipot, lb1_old, std_dim, ub1_old
    1089              :       LOGICAL :: check, lace, lbmhft, lbmhftd, lbuck4r, lbuckmo, ldeepmd, leam, lgal, lgal21, &
    1090              :          lgoodwin, lgp, lipbv, llj, llj_charmm, lnequip, lsiepmann, ltab, ltersoff, lwilliams
    1091              :       TYPE(pair_potential_p_type), POINTER               :: work
    1092              : 
    1093         2342 :       NULLIFY (work)
    1094         2342 :       ipot = 0
    1095         2342 :       llj = .FALSE.; IF (PRESENT(lj)) llj = lj
    1096         2342 :       llj_charmm = .FALSE.; IF (PRESENT(lj_charmm)) llj_charmm = lj_charmm
    1097         2342 :       lwilliams = .FALSE.; IF (PRESENT(williams)) lwilliams = williams
    1098         2342 :       lgoodwin = .FALSE.; IF (PRESENT(goodwin)) lgoodwin = goodwin
    1099         2342 :       leam = .FALSE.; IF (PRESENT(eam)) leam = eam
    1100         2342 :       lnequip = .FALSE.; IF (PRESENT(nequip)) lnequip = nequip
    1101         2342 :       lace = .FALSE.; IF (PRESENT(ace)) lace = ace
    1102         2342 :       ldeepmd = .FALSE.; IF (PRESENT(deepmd)) ldeepmd = deepmd
    1103         2342 :       lbmhft = .FALSE.; IF (PRESENT(bmhft)) lbmhft = bmhft
    1104         2342 :       lbmhftd = .FALSE.; IF (PRESENT(bmhftd)) lbmhftd = bmhftd
    1105         2342 :       lipbv = .FALSE.; IF (PRESENT(ipbv)) lipbv = ipbv
    1106         2342 :       lbuck4r = .FALSE.; IF (PRESENT(buck4r)) lbuck4r = buck4r
    1107         2342 :       lbuckmo = .FALSE.; IF (PRESENT(buckmo)) lbuckmo = buckmo
    1108         2342 :       lgp = .FALSE.; IF (PRESENT(gp)) lgp = gp
    1109         2342 :       ltersoff = .FALSE.; IF (PRESENT(tersoff)) ltersoff = tersoff
    1110         2342 :       lsiepmann = .FALSE.; IF (PRESENT(siepmann)) lsiepmann = siepmann
    1111         2342 :       lgal = .FALSE.; IF (PRESENT(gal)) lgal = gal
    1112         2342 :       lgal21 = .FALSE.; IF (PRESENT(gal21)) lgal21 = gal21
    1113         2342 :       ltab = .FALSE.; IF (PRESENT(tab)) ltab = tab
    1114              : 
    1115         2342 :       IF (llj) THEN
    1116            0 :          ipot = lj_type
    1117              :          check = .NOT. (llj_charmm .OR. lwilliams .OR. lgoodwin .OR. leam .OR. lnequip &
    1118              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1119            0 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1120            0 :          CPASSERT(check)
    1121              :       END IF
    1122         2342 :       IF (llj_charmm) THEN
    1123         1004 :          ipot = lj_charmm_type
    1124              :          check = .NOT. (llj .OR. lwilliams .OR. lgoodwin .OR. leam .OR. lnequip &
    1125              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1126         1004 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1127            0 :          CPASSERT(check)
    1128              :       END IF
    1129         2342 :       IF (lwilliams) THEN
    1130          375 :          ipot = wl_type
    1131              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. leam .OR. lnequip &
    1132              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1133          375 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1134            0 :          CPASSERT(check)
    1135              :       END IF
    1136         2342 :       IF (lgoodwin) THEN
    1137            0 :          ipot = gw_type
    1138              :          check = .NOT. (llj .OR. llj_charmm .OR. lwilliams .OR. leam .OR. lnequip &
    1139              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1140            0 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1141            0 :          CPASSERT(check)
    1142              :       END IF
    1143         2342 :       IF (leam) THEN
    1144           12 :          ipot = ea_type
    1145              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. lnequip &
    1146              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1147           12 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1148            0 :          CPASSERT(check)
    1149              :       END IF
    1150         2342 :       IF (lnequip) THEN
    1151            4 :          ipot = nequip_type
    1152              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam &
    1153              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1154            4 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1155            0 :          CPASSERT(check)
    1156              :       END IF
    1157         2342 :       IF (lace) THEN
    1158            6 :          ipot = ace_type
    1159              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1160              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp &
    1161            6 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd)
    1162            0 :          CPASSERT(check)
    1163              :       END IF
    1164         2342 :       IF (ldeepmd) THEN
    1165            2 :          ipot = deepmd_type
    1166              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1167              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp &
    1168            2 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. lace)
    1169            0 :          CPASSERT(check)
    1170              :       END IF
    1171         2342 :       IF (lbmhft) THEN
    1172            4 :          ipot = ft_type
    1173              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1174              :                         .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1175            4 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1176            0 :          CPASSERT(check)
    1177              :       END IF
    1178         2342 :       IF (lbmhftd) THEN
    1179           18 :          ipot = ftd_type
    1180              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1181              :                         .OR. lbmhft .OR. lipbv .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1182           18 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1183            0 :          CPASSERT(check)
    1184              :       END IF
    1185         2342 :       IF (lipbv) THEN
    1186           16 :          ipot = ip_type
    1187              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1188              :                         .OR. lbmhft .OR. lbmhftd .OR. lbuck4r .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1189           16 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1190            0 :          CPASSERT(check)
    1191              :       END IF
    1192         2342 :       IF (lbuck4r) THEN
    1193          262 :          ipot = b4_type
    1194              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1195              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuckmo .OR. lgp .OR. ltersoff &
    1196          262 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1197            0 :          CPASSERT(check)
    1198              :       END IF
    1199         2342 :       IF (lbuckmo) THEN
    1200            6 :          ipot = bm_type
    1201              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1202              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. ltersoff &
    1203            6 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1204            0 :          CPASSERT(check)
    1205              :       END IF
    1206         2342 :       IF (ltersoff) THEN
    1207           40 :          ipot = tersoff_type
    1208              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1209              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1210           40 :                         .OR. lsiepmann .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1211            0 :          CPASSERT(check)
    1212              :       END IF
    1213         2342 :       IF (lsiepmann) THEN
    1214            5 :          ipot = siepmann_type
    1215              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1216              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1217            5 :                         .OR. ltersoff .OR. lgal .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1218            0 :          CPASSERT(check)
    1219              :       END IF
    1220         2342 :       IF (lgal) THEN
    1221            1 :          ipot = gal_type
    1222              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1223              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1224            1 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal21 .OR. ltab .OR. ldeepmd .OR. lace)
    1225            0 :          CPASSERT(check)
    1226              :       END IF
    1227         2342 :       IF (lgal21) THEN
    1228            1 :          ipot = gal21_type
    1229              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1230              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lbuckmo &
    1231            1 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. ltab .OR. ldeepmd .OR. lace)
    1232            0 :          CPASSERT(check)
    1233              :       END IF
    1234         2342 :       IF (lgp) THEN
    1235          578 :          ipot = gp_type
    1236              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1237              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgal21 .OR. lbuckmo &
    1238          578 :                         .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. ltab .OR. ldeepmd .OR. lace)
    1239            0 :          CPASSERT(check)
    1240              :       END IF
    1241         2342 :       IF (ltab) THEN
    1242            8 :          ipot = tab_type
    1243              :          check = .NOT. (llj .OR. llj_charmm .OR. lgoodwin .OR. lwilliams .OR. leam .OR. lnequip &
    1244              :                         .OR. lbmhft .OR. lbmhftd .OR. lipbv .OR. lbuck4r .OR. lgp .OR. lgal21 &
    1245            8 :                         .OR. lbuckmo .OR. ltersoff .OR. lsiepmann .OR. lgal .OR. lace)
    1246            0 :          CPASSERT(check)
    1247              :       END IF
    1248              : 
    1249         2342 :       lb1_old = 0
    1250         2342 :       ub1_old = 0
    1251         2342 :       IF (ASSOCIATED(p)) THEN
    1252          307 :          lb1_old = LBOUND(p%pot, 1)
    1253          307 :          ub1_old = UBOUND(p%pot, 1)
    1254          307 :          CALL pair_potential_p_create(work, lb=lb1_old, ub=ub1_old)
    1255          307 :          CALL pair_potential_p_copy(p, work)
    1256          307 :          CALL pair_potential_p_release(p)
    1257              :       END IF
    1258              : 
    1259         2342 :       CALL pair_potential_p_create(p, lb=lb1_new, ub=ub1_new)
    1260         2342 :       IF (ASSOCIATED(work)) THEN
    1261          307 :          CALL pair_potential_p_copy(work, p, istart=lb1_old, iend=ub1_old)
    1262              :       END IF
    1263         2342 :       std_dim = 1
    1264        10896 :       DO i = ub1_old + 1, ub1_new
    1265         8554 :          check = (SIZE(p%pot(i)%pot%type) == std_dim) .AND. (SIZE(p%pot(i)%pot%type) == std_dim)
    1266         8554 :          CPASSERT(check)
    1267        17108 :          p%pot(i)%pot%type = nn_type
    1268         8554 :          p%pot(i)%pot%shell_type = nosh_nosh
    1269         8554 :          p%pot(i)%pot%undef = .TRUE.
    1270         8554 :          p%pot(i)%pot%no_mb = .FALSE.
    1271         8554 :          p%pot(i)%pot%no_pp = .FALSE.
    1272         8554 :          p%pot(i)%pot%at1 = 'NULL'
    1273         8554 :          p%pot(i)%pot%at2 = 'NULL'
    1274         8554 :          p%pot(i)%pot%set(std_dim)%rmin = not_initialized
    1275         8554 :          p%pot(i)%pot%set(std_dim)%rmax = not_initialized
    1276         3786 :          SELECT CASE (ipot)
    1277              :          CASE (lj_type, lj_charmm_type)
    1278         3786 :             CALL pair_potential_lj_create(p%pot(i)%pot%set(std_dim)%lj)
    1279              :          CASE (wl_type)
    1280         1011 :             CALL pair_potential_williams_create(p%pot(i)%pot%set(std_dim)%willis)
    1281              :          CASE (gw_type)
    1282            0 :             CALL pair_potential_goodwin_create(p%pot(i)%pot%set(std_dim)%goodwin)
    1283              :          CASE (ea_type)
    1284           20 :             CALL pair_potential_eam_create(p%pot(i)%pot%set(std_dim)%eam)
    1285              :          CASE (nequip_type, allegro_type)
    1286           12 :             CALL pair_potential_nequip_create(p%pot(i)%pot%set(std_dim)%nequip)
    1287              :          CASE (ace_type)
    1288           18 :             CALL pair_potential_ace_create(p%pot(i)%pot%set(std_dim)%ace)
    1289              :          CASE (deepmd_type)
    1290            6 :             CALL pair_potential_deepmd_create(p%pot(i)%pot%set(std_dim)%deepmd)
    1291              :          CASE (ft_type)
    1292           12 :             CALL pair_potential_bmhft_create(p%pot(i)%pot%set(std_dim)%ft)
    1293              :          CASE (ftd_type)
    1294           66 :             CALL pair_potential_bmhftd_create(p%pot(i)%pot%set(std_dim)%ftd)
    1295              :          CASE (ip_type)
    1296           48 :             CALL pair_potential_ipbv_create(p%pot(i)%pot%set(std_dim)%ipbv)
    1297              :          CASE (b4_type)
    1298          262 :             CALL pair_potential_buck4r_create(p%pot(i)%pot%set(std_dim)%buck4r)
    1299              :          CASE (bm_type)
    1300           14 :             CALL pair_potential_buckmo_create(p%pot(i)%pot%set(std_dim)%buckmo)
    1301              :          CASE (gp_type)
    1302         3224 :             CALL pair_potential_gp_create(p%pot(i)%pot%set(std_dim)%gp)
    1303              :          CASE (tersoff_type)
    1304           44 :             CALL pair_potential_tersoff_create(p%pot(i)%pot%set(std_dim)%tersoff)
    1305              :          CASE (siepmann_type)
    1306            5 :             CALL pair_potential_siepmann_create(p%pot(i)%pot%set(std_dim)%siepmann)
    1307              :          CASE (gal_type)
    1308            1 :             CALL pair_potential_gal_create(p%pot(i)%pot%set(std_dim)%gal)
    1309              :          CASE (gal21_type)
    1310            1 :             CALL pair_potential_gal21_create(p%pot(i)%pot%set(std_dim)%gal21)
    1311              :          CASE (tab_type)
    1312         8554 :             CALL pair_potential_tab_create(p%pot(i)%pot%set(std_dim)%tab)
    1313              :          END SELECT
    1314         8554 :          NULLIFY (p%pot(i)%pot%spl_f)
    1315        10896 :          NULLIFY (p%pot(i)%pot%pair_spline_data)
    1316              :       END DO
    1317              : 
    1318         2342 :       IF (ASSOCIATED(work)) CALL pair_potential_p_release(work)
    1319         2342 :    END SUBROUTINE pair_potential_reallocate
    1320              : 
    1321              : ! **************************************************************************************************
    1322              : !> \brief Creates the generic potential type
    1323              : !> \param gp ...
    1324              : !> \author Teodoro Laino [teo] 11.2005
    1325              : ! **************************************************************************************************
    1326         6480 :    SUBROUTINE pair_potential_gp_create(gp)
    1327              :       TYPE(gp_pot_type), POINTER                         :: gp
    1328              : 
    1329         6480 :       CPASSERT(.NOT. ASSOCIATED(gp))
    1330         6480 :       ALLOCATE (gp)
    1331              :       NULLIFY (gp%parameters)
    1332              :       NULLIFY (gp%values)
    1333         6480 :       CALL pair_potential_gp_clean(gp)
    1334         6480 :    END SUBROUTINE pair_potential_gp_create
    1335              : 
    1336              : ! **************************************************************************************************
    1337              : !> \brief Copy two generic potential type
    1338              : !> \param gp_source ...
    1339              : !> \param gp_dest ...
    1340              : !> \author Teodoro Laino [teo] 11.2005
    1341              : ! **************************************************************************************************
    1342        12530 :    SUBROUTINE pair_potential_gp_copy(gp_source, gp_dest)
    1343              :       TYPE(gp_pot_type), POINTER                         :: gp_source, gp_dest
    1344              : 
    1345              :       INTEGER                                            :: idim
    1346              : 
    1347        12530 :       IF (.NOT. ASSOCIATED(gp_source)) RETURN
    1348         3256 :       IF (ASSOCIATED(gp_dest)) CALL pair_potential_gp_release(gp_dest)
    1349         3256 :       CALL pair_potential_gp_create(gp_dest)
    1350         3256 :       gp_dest%myid = gp_source%myid
    1351         3256 :       gp_dest%potential = gp_source%potential
    1352         3256 :       gp_dest%variables = gp_source%variables
    1353         3256 :       IF (ASSOCIATED(gp_source%parameters)) THEN
    1354         3256 :          idim = SIZE(gp_source%parameters)
    1355         9768 :          ALLOCATE (gp_dest%parameters(idim))
    1356        22904 :          gp_dest%parameters = gp_source%parameters
    1357              :       END IF
    1358         3256 :       IF (ASSOCIATED(gp_source%values)) THEN
    1359         3256 :          idim = SIZE(gp_source%values)
    1360         9768 :          ALLOCATE (gp_dest%values(idim))
    1361        22904 :          gp_dest%values = gp_source%values
    1362              :       END IF
    1363              :    END SUBROUTINE pair_potential_gp_copy
    1364              : 
    1365              : ! **************************************************************************************************
    1366              : !> \brief Cleans the generic potential type
    1367              : !> \param gp ...
    1368              : !> \author Teodoro Laino [teo] 11.2005
    1369              : ! **************************************************************************************************
    1370       576473 :    SUBROUTINE pair_potential_gp_clean(gp)
    1371              :       TYPE(gp_pot_type), POINTER                         :: gp
    1372              : 
    1373       576473 :       IF (.NOT. ASSOCIATED(gp)) RETURN
    1374         6480 :       gp%myid = 0
    1375         6480 :       gp%potential = ""
    1376         6480 :       gp%variables = ""
    1377         6480 :       IF (ASSOCIATED(gp%values)) THEN
    1378            0 :          DEALLOCATE (gp%values)
    1379              :       END IF
    1380         6480 :       IF (ASSOCIATED(gp%parameters)) THEN
    1381            0 :          DEALLOCATE (gp%parameters)
    1382              :       END IF
    1383              :    END SUBROUTINE pair_potential_gp_clean
    1384              : 
    1385              : ! **************************************************************************************************
    1386              : !> \brief Destroys the generic potential type
    1387              : !> \param gp ...
    1388              : !> \author Teodoro Laino [teo] 11.2005
    1389              : ! **************************************************************************************************
    1390       525718 :    SUBROUTINE pair_potential_gp_release(gp)
    1391              :       TYPE(gp_pot_type), POINTER                         :: gp
    1392              : 
    1393       525718 :       IF (ASSOCIATED(gp)) THEN
    1394         6480 :          IF (ASSOCIATED(gp%parameters)) THEN
    1395         6480 :             DEALLOCATE (gp%parameters)
    1396              :          END IF
    1397         6480 :          IF (ASSOCIATED(gp%values)) THEN
    1398         6480 :             DEALLOCATE (gp%values)
    1399              :          END IF
    1400         6480 :          DEALLOCATE (gp)
    1401              :       END IF
    1402       525718 :       NULLIFY (gp)
    1403       525718 :    END SUBROUTINE pair_potential_gp_release
    1404              : 
    1405              : ! **************************************************************************************************
    1406              : !> \brief Cleans the LJ potential type
    1407              : !> \param lj ...
    1408              : !> \author Teodoro Laino [teo] 11.2005
    1409              : ! **************************************************************************************************
    1410       505146 :    SUBROUTINE pair_potential_lj_create(lj)
    1411              :       TYPE(lj_pot_type), POINTER                         :: lj
    1412              : 
    1413       505146 :       CPASSERT(.NOT. ASSOCIATED(lj))
    1414       505146 :       ALLOCATE (lj)
    1415       505146 :       CALL pair_potential_lj_clean(lj)
    1416       505146 :    END SUBROUTINE pair_potential_lj_create
    1417              : 
    1418              : ! **************************************************************************************************
    1419              : !> \brief Copy two LJ potential type
    1420              : !> \param lj_source ...
    1421              : !> \param lj_dest ...
    1422              : !> \author Teodoro Laino [teo] 11.2005
    1423              : ! **************************************************************************************************
    1424        12530 :    SUBROUTINE pair_potential_lj_copy(lj_source, lj_dest)
    1425              :       TYPE(lj_pot_type), POINTER                         :: lj_source, lj_dest
    1426              : 
    1427        12530 :       IF (.NOT. ASSOCIATED(lj_source)) RETURN
    1428         5110 :       IF (ASSOCIATED(lj_dest)) CALL pair_potential_lj_release(lj_dest)
    1429         5110 :       CALL pair_potential_lj_create(lj_dest)
    1430         5110 :       lj_dest%epsilon = lj_source%epsilon
    1431         5110 :       lj_dest%sigma6 = lj_source%sigma6
    1432         5110 :       lj_dest%sigma12 = lj_source%sigma12
    1433              :    END SUBROUTINE pair_potential_lj_copy
    1434              : 
    1435              : ! **************************************************************************************************
    1436              : !> \brief Creates the LJ potential type
    1437              : !> \param lj ...
    1438              : !> \author Teodoro Laino [teo] 11.2005
    1439              : ! **************************************************************************************************
    1440      1075139 :    SUBROUTINE pair_potential_lj_clean(lj)
    1441              :       TYPE(lj_pot_type), POINTER                         :: lj
    1442              : 
    1443      1075139 :       IF (.NOT. ASSOCIATED(lj)) RETURN
    1444       525240 :       lj%epsilon = 0.0_dp
    1445       525240 :       lj%sigma6 = 0.0_dp
    1446       525240 :       lj%sigma12 = 0.0_dp
    1447              :    END SUBROUTINE pair_potential_lj_clean
    1448              : 
    1449              : ! **************************************************************************************************
    1450              : !> \brief Destroys the LJ potential type
    1451              : !> \param lj ...
    1452              : !> \author Teodoro Laino [teo] 11.2005
    1453              : ! **************************************************************************************************
    1454       525720 :    SUBROUTINE pair_potential_lj_release(lj)
    1455              :       TYPE(lj_pot_type), POINTER                         :: lj
    1456              : 
    1457       525720 :       IF (ASSOCIATED(lj)) THEN
    1458       505146 :          DEALLOCATE (lj)
    1459              :       END IF
    1460       525720 :       NULLIFY (lj)
    1461       525720 :    END SUBROUTINE pair_potential_lj_release
    1462              : 
    1463              : ! **************************************************************************************************
    1464              : !> \brief Creates the WILLIAMS potential type
    1465              : !> \param willis ...
    1466              : !> \author Teodoro Laino [teo] 11.2005
    1467              : ! **************************************************************************************************
    1468         3160 :    SUBROUTINE pair_potential_williams_create(willis)
    1469              :       TYPE(williams_pot_type), POINTER                   :: willis
    1470              : 
    1471         3160 :       CPASSERT(.NOT. ASSOCIATED(willis))
    1472         3160 :       ALLOCATE (willis)
    1473         3160 :       CALL pair_potential_williams_clean(willis)
    1474         3160 :    END SUBROUTINE pair_potential_williams_create
    1475              : 
    1476              : ! **************************************************************************************************
    1477              : !> \brief Copy two WILLIAMS potential type
    1478              : !> \param willis_source ...
    1479              : !> \param willis_dest ...
    1480              : !> \author Teodoro Laino [teo] 11.2005
    1481              : ! **************************************************************************************************
    1482        12530 :    SUBROUTINE pair_potential_williams_copy(willis_source, willis_dest)
    1483              :       TYPE(williams_pot_type), POINTER                   :: willis_source, willis_dest
    1484              : 
    1485        12530 :       IF (.NOT. ASSOCIATED(willis_source)) RETURN
    1486         2149 :       IF (ASSOCIATED(willis_dest)) CALL pair_potential_williams_release(willis_dest)
    1487         2149 :       CALL pair_potential_williams_create(willis_dest)
    1488         2149 :       willis_dest%a = willis_source%a
    1489         2149 :       willis_dest%b = willis_source%b
    1490         2149 :       willis_dest%c = willis_source%c
    1491              :    END SUBROUTINE pair_potential_williams_copy
    1492              : 
    1493              : ! **************************************************************************************************
    1494              : !> \brief Creates the WILLIAMS potential type
    1495              : !> \param willis ...
    1496              : !> \author Teodoro Laino [teo] 11.2005
    1497              : ! **************************************************************************************************
    1498       573153 :    SUBROUTINE pair_potential_williams_clean(willis)
    1499              :       TYPE(williams_pot_type), POINTER                   :: willis
    1500              : 
    1501       573153 :       IF (.NOT. ASSOCIATED(willis)) RETURN
    1502         3210 :       willis%a = 0.0_dp
    1503         3210 :       willis%b = 0.0_dp
    1504         3210 :       willis%c = 0.0_dp
    1505              :    END SUBROUTINE pair_potential_williams_clean
    1506              : 
    1507              : ! **************************************************************************************************
    1508              : !> \brief Destroys the WILLIAMS potential type
    1509              : !> \param willis ...
    1510              : !> \author Teodoro Laino [teo] 11.2005
    1511              : ! **************************************************************************************************
    1512       525720 :    SUBROUTINE pair_potential_williams_release(willis)
    1513              :       TYPE(williams_pot_type), POINTER                   :: willis
    1514              : 
    1515       525720 :       IF (ASSOCIATED(willis)) THEN
    1516         3160 :          DEALLOCATE (willis)
    1517              :       END IF
    1518       525720 :       NULLIFY (willis)
    1519       525720 :    END SUBROUTINE pair_potential_williams_release
    1520              : 
    1521              : ! **************************************************************************************************
    1522              : !> \brief Creates the GOODWIN potential type
    1523              : !> \param goodwin ...
    1524              : !> \author Teodoro Laino [teo] 11.2005
    1525              : ! **************************************************************************************************
    1526            0 :    SUBROUTINE pair_potential_goodwin_create(goodwin)
    1527              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin
    1528              : 
    1529            0 :       CPASSERT(.NOT. ASSOCIATED(goodwin))
    1530            0 :       ALLOCATE (goodwin)
    1531            0 :       CALL pair_potential_goodwin_clean(goodwin)
    1532            0 :    END SUBROUTINE pair_potential_goodwin_create
    1533              : 
    1534              : ! **************************************************************************************************
    1535              : !> \brief Copy two GOODWIN potential type
    1536              : !> \param goodwin_source ...
    1537              : !> \param goodwin_dest ...
    1538              : !> \author Teodoro Laino [teo] 11.2005
    1539              : ! **************************************************************************************************
    1540        12530 :    SUBROUTINE pair_potential_goodwin_copy(goodwin_source, goodwin_dest)
    1541              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin_source, goodwin_dest
    1542              : 
    1543        12530 :       IF (.NOT. ASSOCIATED(goodwin_source)) RETURN
    1544            0 :       IF (ASSOCIATED(goodwin_dest)) CALL pair_potential_goodwin_release(goodwin_dest)
    1545            0 :       CALL pair_potential_goodwin_create(goodwin_dest)
    1546            0 :       goodwin_dest%vr0 = goodwin_source%vr0
    1547            0 :       goodwin_dest%d = goodwin_source%d
    1548            0 :       goodwin_dest%dc = goodwin_source%dc
    1549            0 :       goodwin_dest%m = goodwin_source%m
    1550            0 :       goodwin_dest%mc = goodwin_source%mc
    1551              :    END SUBROUTINE pair_potential_goodwin_copy
    1552              : 
    1553              : ! **************************************************************************************************
    1554              : !> \brief Creates the GOODWIN potential type
    1555              : !> \param goodwin ...
    1556              : !> \author Teodoro Laino [teo] 11.2005
    1557              : ! **************************************************************************************************
    1558       569993 :    SUBROUTINE pair_potential_goodwin_clean(goodwin)
    1559              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin
    1560              : 
    1561       569993 :       IF (.NOT. ASSOCIATED(goodwin)) RETURN
    1562            0 :       goodwin%vr0 = 0.0_dp
    1563            0 :       goodwin%d = 0.0_dp
    1564            0 :       goodwin%dc = 0.0_dp
    1565            0 :       goodwin%m = 0.0_dp
    1566            0 :       goodwin%mc = 0.0_dp
    1567              :    END SUBROUTINE pair_potential_goodwin_clean
    1568              : 
    1569              : ! **************************************************************************************************
    1570              : !> \brief Destroys the GOODWIN potential type
    1571              : !> \param goodwin ...
    1572              : !> \author Teodoro Laino [teo] 11.2005
    1573              : ! **************************************************************************************************
    1574       525718 :    SUBROUTINE pair_potential_goodwin_release(goodwin)
    1575              :       TYPE(goodwin_pot_type), POINTER                    :: goodwin
    1576              : 
    1577       525718 :       IF (ASSOCIATED(goodwin)) THEN
    1578            0 :          DEALLOCATE (goodwin)
    1579              :       END IF
    1580       525718 :       NULLIFY (goodwin)
    1581       525718 :    END SUBROUTINE pair_potential_goodwin_release
    1582              : 
    1583              : ! **************************************************************************************************
    1584              : !> \brief Creates the EAM potential type
    1585              : !> \param eam ...
    1586              : !> \author Teodoro Laino [teo] 11.2005
    1587              : ! **************************************************************************************************
    1588           44 :    SUBROUTINE pair_potential_eam_create(eam)
    1589              :       TYPE(eam_pot_type), POINTER                        :: eam
    1590              : 
    1591           44 :       CPASSERT(.NOT. ASSOCIATED(eam))
    1592           44 :       ALLOCATE (eam)
    1593              :       NULLIFY (eam%rho, eam%phi, eam%frho, eam%rhoval, eam%rval, &
    1594              :                eam%rhop, eam%phip, eam%frhop)
    1595           44 :       CALL pair_potential_eam_clean(eam)
    1596           44 :    END SUBROUTINE pair_potential_eam_create
    1597              : 
    1598              : ! **************************************************************************************************
    1599              : !> \brief Copy two EAM potential type
    1600              : !> \param eam_source ...
    1601              : !> \param eam_dest ...
    1602              : !> \author Teodoro Laino [teo] 11.2005
    1603              : ! **************************************************************************************************
    1604        12530 :    SUBROUTINE pair_potential_eam_copy(eam_source, eam_dest)
    1605              :       TYPE(eam_pot_type), POINTER                        :: eam_source, eam_dest
    1606              : 
    1607        12530 :       IF (.NOT. ASSOCIATED(eam_source)) RETURN
    1608           24 :       IF (ASSOCIATED(eam_dest)) CALL pair_potential_eam_release(eam_dest)
    1609           24 :       CALL pair_potential_eam_create(eam_dest)
    1610           24 :       eam_dest%eam_file_name = eam_source%eam_file_name
    1611           24 :       eam_dest%drar = eam_source%drar
    1612           24 :       eam_dest%drhoar = eam_source%drhoar
    1613           24 :       eam_dest%acutal = eam_source%acutal
    1614           24 :       eam_dest%npoints = eam_source%npoints
    1615              :       ! Allocate arrays with the proper size
    1616           24 :       CALL reallocate(eam_dest%rho, 1, eam_dest%npoints)
    1617           24 :       CALL reallocate(eam_dest%rhop, 1, eam_dest%npoints)
    1618           24 :       CALL reallocate(eam_dest%phi, 1, eam_dest%npoints)
    1619           24 :       CALL reallocate(eam_dest%phip, 1, eam_dest%npoints)
    1620           24 :       CALL reallocate(eam_dest%frho, 1, eam_dest%npoints)
    1621           24 :       CALL reallocate(eam_dest%frhop, 1, eam_dest%npoints)
    1622           24 :       CALL reallocate(eam_dest%rval, 1, eam_dest%npoints)
    1623           24 :       CALL reallocate(eam_dest%rhoval, 1, eam_dest%npoints)
    1624       132024 :       eam_dest%rho = eam_source%rho
    1625       132024 :       eam_dest%phi = eam_source%phi
    1626       132024 :       eam_dest%frho = eam_source%frho
    1627       132024 :       eam_dest%rhoval = eam_source%rhoval
    1628       132024 :       eam_dest%rval = eam_source%rval
    1629       132024 :       eam_dest%rhop = eam_source%rhop
    1630       132024 :       eam_dest%phip = eam_source%phip
    1631       132024 :       eam_dest%frhop = eam_source%frhop
    1632              :    END SUBROUTINE pair_potential_eam_copy
    1633              : 
    1634              : ! **************************************************************************************************
    1635              : !> \brief Creates the EAM potential type
    1636              : !> \param eam ...
    1637              : !> \author Teodoro Laino [teo] 11.2005
    1638              : ! **************************************************************************************************
    1639       570037 :    SUBROUTINE pair_potential_eam_clean(eam)
    1640              :       TYPE(eam_pot_type), POINTER                        :: eam
    1641              : 
    1642       570037 :       IF (.NOT. ASSOCIATED(eam)) RETURN
    1643           44 :       eam%eam_file_name = 'NULL'
    1644           44 :       eam%drar = 0.0_dp
    1645           44 :       eam%drhoar = 0.0_dp
    1646           44 :       eam%acutal = 0.0_dp
    1647           44 :       eam%npoints = 0
    1648           44 :       CALL reallocate(eam%rho, 1, eam%npoints)
    1649           44 :       CALL reallocate(eam%rhop, 1, eam%npoints)
    1650           44 :       CALL reallocate(eam%phi, 1, eam%npoints)
    1651           44 :       CALL reallocate(eam%phip, 1, eam%npoints)
    1652           44 :       CALL reallocate(eam%frho, 1, eam%npoints)
    1653           44 :       CALL reallocate(eam%frhop, 1, eam%npoints)
    1654           44 :       CALL reallocate(eam%rval, 1, eam%npoints)
    1655           44 :       CALL reallocate(eam%rhoval, 1, eam%npoints)
    1656              :    END SUBROUTINE pair_potential_eam_clean
    1657              : 
    1658              : ! **************************************************************************************************
    1659              : !> \brief Destroys the EAM potential type
    1660              : !> \param eam ...
    1661              : !> \author Teodoro Laino [teo] 11.2005
    1662              : ! **************************************************************************************************
    1663       525718 :    SUBROUTINE pair_potential_eam_release(eam)
    1664              :       TYPE(eam_pot_type), POINTER                        :: eam
    1665              : 
    1666       525718 :       IF (ASSOCIATED(eam)) THEN
    1667           44 :          IF (ASSOCIATED(eam%rho)) THEN
    1668           44 :             DEALLOCATE (eam%rho)
    1669              :          END IF
    1670           44 :          IF (ASSOCIATED(eam%rhop)) THEN
    1671           44 :             DEALLOCATE (eam%rhop)
    1672              :          END IF
    1673           44 :          IF (ASSOCIATED(eam%phi)) THEN
    1674           44 :             DEALLOCATE (eam%phi)
    1675              :          END IF
    1676           44 :          IF (ASSOCIATED(eam%phip)) THEN
    1677           44 :             DEALLOCATE (eam%phip)
    1678              :          END IF
    1679           44 :          IF (ASSOCIATED(eam%frho)) THEN
    1680           44 :             DEALLOCATE (eam%frho)
    1681              :          END IF
    1682           44 :          IF (ASSOCIATED(eam%frhop)) THEN
    1683           44 :             DEALLOCATE (eam%frhop)
    1684              :          END IF
    1685           44 :          IF (ASSOCIATED(eam%rval)) THEN
    1686           44 :             DEALLOCATE (eam%rval)
    1687              :          END IF
    1688           44 :          IF (ASSOCIATED(eam%rhoval)) THEN
    1689           44 :             DEALLOCATE (eam%rhoval)
    1690              :          END IF
    1691           44 :          DEALLOCATE (eam)
    1692              :       END IF
    1693       525718 :    END SUBROUTINE pair_potential_eam_release
    1694              : 
    1695              : ! **************************************************************************************************
    1696              : !> \brief Creates the ACE potential type
    1697              : !> \param ace ...
    1698              : !> \author
    1699              : ! **************************************************************************************************
    1700           36 :    SUBROUTINE pair_potential_ace_create(ace)
    1701              :       TYPE(ace_pot_type), POINTER                        :: ace
    1702              : 
    1703           36 :       CPASSERT(.NOT. ASSOCIATED(ace))
    1704           36 :       ALLOCATE (ace)
    1705           36 :    END SUBROUTINE pair_potential_ace_create
    1706              : 
    1707              : ! **************************************************************************************************
    1708              : !> \brief Copy two ACE potential type
    1709              : !> \param ace_source ...
    1710              : !> \param ace_dest ...
    1711              : !> \author
    1712              : ! **************************************************************************************************
    1713        12530 :    SUBROUTINE pair_potential_ace_copy(ace_source, ace_dest)
    1714              :       TYPE(ace_pot_type), POINTER                        :: ace_source, ace_dest
    1715              : 
    1716        12530 :       IF (.NOT. ASSOCIATED(ace_source)) RETURN
    1717           18 :       NULLIFY (ace_dest)
    1718              :       IF (ASSOCIATED(ace_dest)) CALL pair_potential_ace_release(ace_dest)
    1719           18 :       CALL pair_potential_ace_create(ace_dest)
    1720           18 :       ace_dest = ace_source
    1721              :    END SUBROUTINE pair_potential_ace_copy
    1722              : 
    1723              : ! **************************************************************************************************
    1724              : !> \brief CLEAN the ACE potential type
    1725              : !> \param ace ...
    1726              : !> \author
    1727              : ! **************************************************************************************************
    1728       569993 :    SUBROUTINE pair_potential_ace_clean(ace)
    1729              :       TYPE(ace_pot_type), POINTER                        :: ace
    1730              : 
    1731       569993 :       IF (.NOT. ASSOCIATED(ace)) RETURN
    1732            0 :       ace = ace_pot_type()
    1733              :    END SUBROUTINE pair_potential_ace_clean
    1734              : 
    1735              : ! **************************************************************************************************
    1736              : !> \brief Destroys the ACE potential type
    1737              : !> \param ace ...
    1738              : !> \author
    1739              : ! **************************************************************************************************
    1740       525718 :    SUBROUTINE pair_potential_ace_release(ace)
    1741              :       TYPE(ace_pot_type), POINTER                        :: ace
    1742              : 
    1743       525718 :       IF (ASSOCIATED(ace)) THEN
    1744           36 :          DEALLOCATE (ace)
    1745              :       END IF
    1746       525718 :    END SUBROUTINE pair_potential_ace_release
    1747              : 
    1748              : ! **************************************************************************************************
    1749              : !> \brief Creates the DEEPMD potential type
    1750              : !> \param deepmd ...
    1751              : !> \author Yongbin Zhuang 07.2019
    1752              : ! **************************************************************************************************
    1753           12 :    SUBROUTINE pair_potential_deepmd_create(deepmd)
    1754              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd
    1755              : 
    1756           12 :       CPASSERT(.NOT. ASSOCIATED(deepmd))
    1757           12 :       ALLOCATE (deepmd)
    1758           12 :    END SUBROUTINE pair_potential_deepmd_create
    1759              : 
    1760              : ! **************************************************************************************************
    1761              : !> \brief Copy two DEEPMD potential type
    1762              : !> \param deepmd_source ...
    1763              : !> \param deepmd_dest ...
    1764              : !> \author Yongbin Zhuang 07.2019
    1765              : ! **************************************************************************************************
    1766        12530 :    SUBROUTINE pair_potential_deepmd_copy(deepmd_source, deepmd_dest)
    1767              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd_source, deepmd_dest
    1768              : 
    1769        12530 :       IF (.NOT. ASSOCIATED(deepmd_source)) RETURN
    1770            6 :       NULLIFY (deepmd_dest)
    1771              :       IF (ASSOCIATED(deepmd_dest)) CALL pair_potential_deepmd_release(deepmd_dest)
    1772            6 :       CALL pair_potential_deepmd_create(deepmd_dest)
    1773            6 :       deepmd_dest = deepmd_source
    1774              :    END SUBROUTINE pair_potential_deepmd_copy
    1775              : 
    1776              : ! **************************************************************************************************
    1777              : !> \brief CLEAN the DEEPMD potential type
    1778              : !> \param deepmd ...
    1779              : !> \author Yongbin Zhuang 07.2019
    1780              : ! **************************************************************************************************
    1781       569993 :    SUBROUTINE pair_potential_deepmd_clean(deepmd)
    1782              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd
    1783              : 
    1784       569993 :       IF (.NOT. ASSOCIATED(deepmd)) RETURN
    1785            0 :       deepmd = deepmd_pot_type()
    1786              :    END SUBROUTINE pair_potential_deepmd_clean
    1787              : 
    1788              : ! **************************************************************************************************
    1789              : !> \brief Destroys the DEEPMD potential type
    1790              : !> \param deepmd ...
    1791              : !> \author Yongbin Zhuang 07.2019
    1792              : ! **************************************************************************************************
    1793       525718 :    SUBROUTINE pair_potential_deepmd_release(deepmd)
    1794              :       TYPE(deepmd_pot_type), POINTER                     :: deepmd
    1795              : 
    1796       525718 :       IF (ASSOCIATED(deepmd)) THEN
    1797           12 :          DEALLOCATE (deepmd)
    1798              :       END IF
    1799       525718 :    END SUBROUTINE pair_potential_deepmd_release
    1800              : 
    1801              : ! **************************************************************************************************
    1802              : !> \brief Creates the NEQUIP potential type
    1803              : !> \param nequip ...
    1804              : !> \author Gabriele Tocci 2023
    1805              : ! **************************************************************************************************
    1806           24 :    SUBROUTINE pair_potential_nequip_create(nequip)
    1807              :       TYPE(nequip_pot_type), POINTER                     :: nequip
    1808              : 
    1809           24 :       CPASSERT(.NOT. ASSOCIATED(nequip))
    1810           24 :       ALLOCATE (nequip)
    1811           24 :    END SUBROUTINE pair_potential_nequip_create
    1812              : 
    1813              : ! **************************************************************************************************
    1814              : !> \brief Copy two NEQUIP potential type
    1815              : !> \param nequip_source ...
    1816              : !> \param nequip_dest ...
    1817              : !> \author Gabriele Tocci 2023
    1818              : ! **************************************************************************************************
    1819        12530 :    SUBROUTINE pair_potential_nequip_copy(nequip_source, nequip_dest)
    1820              :       TYPE(nequip_pot_type), POINTER                     :: nequip_source, nequip_dest
    1821              : 
    1822        12530 :       IF (.NOT. ASSOCIATED(nequip_source)) RETURN
    1823           12 :       IF (ASSOCIATED(nequip_dest)) CALL pair_potential_nequip_release(nequip_dest)
    1824           12 :       CALL pair_potential_nequip_create(nequip_dest)
    1825           12 :       nequip_dest = nequip_source
    1826              : 
    1827              :    END SUBROUTINE pair_potential_nequip_copy
    1828              : 
    1829              : ! **************************************************************************************************
    1830              : !> \brief Creates the NEQUIP potential type
    1831              : !> \param nequip ...
    1832              : !> \author Gabriele Tocci 2023
    1833              : ! **************************************************************************************************
    1834       569993 :    SUBROUTINE pair_potential_nequip_clean(nequip)
    1835              :       TYPE(nequip_pot_type), POINTER                     :: nequip
    1836              : 
    1837       569993 :       IF (.NOT. ASSOCIATED(nequip)) RETURN
    1838            0 :       nequip = nequip_pot_type()
    1839              : 
    1840              :    END SUBROUTINE pair_potential_nequip_clean
    1841              : 
    1842              : ! **************************************************************************************************
    1843              : !> \brief Destroys the NEQUIP potential type
    1844              : !> \param nequip ...
    1845              : !> \author Gabriele Tocci 2023
    1846              : ! **************************************************************************************************
    1847       525718 :    SUBROUTINE pair_potential_nequip_release(nequip)
    1848              :       TYPE(nequip_pot_type), POINTER                     :: nequip
    1849              : 
    1850       525718 :       IF (ASSOCIATED(nequip)) THEN
    1851           24 :          DEALLOCATE (nequip)
    1852              :       END IF
    1853       525718 :    END SUBROUTINE pair_potential_nequip_release
    1854              : 
    1855              : ! **************************************************************************************************
    1856              : !> \brief Creates the BMHFT (TOSI-FUMI) potential type
    1857              : !> \param ft ...
    1858              : !> \author Teodoro Laino [teo] 11.2005
    1859              : ! **************************************************************************************************
    1860           24 :    SUBROUTINE pair_potential_bmhft_create(ft)
    1861              :       TYPE(ft_pot_type), POINTER                         :: ft
    1862              : 
    1863           24 :       CPASSERT(.NOT. ASSOCIATED(ft))
    1864           24 :       ALLOCATE (ft)
    1865           24 :       CALL pair_potential_bmhft_clean(ft)
    1866           24 :    END SUBROUTINE pair_potential_bmhft_create
    1867              : 
    1868              : ! **************************************************************************************************
    1869              : !> \brief Copy two BMHFT (TOSI-FUMI) potential type
    1870              : !> \param ft_source ...
    1871              : !> \param ft_dest ...
    1872              : !> \author Teodoro Laino [teo] 11.2005
    1873              : ! **************************************************************************************************
    1874        12530 :    SUBROUTINE pair_potential_bmhft_copy(ft_source, ft_dest)
    1875              :       TYPE(ft_pot_type), POINTER                         :: ft_source, ft_dest
    1876              : 
    1877        12530 :       IF (.NOT. ASSOCIATED(ft_source)) RETURN
    1878           12 :       IF (ASSOCIATED(ft_dest)) CALL pair_potential_bmhft_release(ft_dest)
    1879           12 :       CALL pair_potential_bmhft_create(ft_dest)
    1880           12 :       ft_dest%A = ft_source%A
    1881           12 :       ft_dest%B = ft_source%B
    1882           12 :       ft_dest%C = ft_source%C
    1883           12 :       ft_dest%D = ft_source%D
    1884              :    END SUBROUTINE pair_potential_bmhft_copy
    1885              : 
    1886              : ! **************************************************************************************************
    1887              : !> \brief Creates the BMHFT (TOSI-FUMI) potential type
    1888              : !> \param ft ...
    1889              : !> \author Teodoro Laino [teo] 11.2005
    1890              : ! **************************************************************************************************
    1891       570017 :    SUBROUTINE pair_potential_bmhft_clean(ft)
    1892              :       TYPE(ft_pot_type), POINTER                         :: ft
    1893              : 
    1894       570017 :       IF (.NOT. ASSOCIATED(ft)) RETURN
    1895           24 :       ft%A = 0.0_dp
    1896           24 :       ft%B = 0.0_dp
    1897           24 :       ft%C = 0.0_dp
    1898           24 :       ft%D = 0.0_dp
    1899              :    END SUBROUTINE pair_potential_bmhft_clean
    1900              : 
    1901              : ! **************************************************************************************************
    1902              : !> \brief Destroys the BMHFT potential type
    1903              : !> \param ft ...
    1904              : !> \author Teodoro Laino [teo] 11.2005
    1905              : ! **************************************************************************************************
    1906       525718 :    SUBROUTINE pair_potential_bmhft_release(ft)
    1907              :       TYPE(ft_pot_type), POINTER                         :: ft
    1908              : 
    1909       525718 :       IF (ASSOCIATED(ft)) THEN
    1910           24 :          DEALLOCATE (ft)
    1911              :       END IF
    1912       525718 :       NULLIFY (ft)
    1913       525718 :    END SUBROUTINE pair_potential_bmhft_release
    1914              : 
    1915              : ! **************************************************************************************************
    1916              : !> \brief Creates the BMHFTD (damped TOSI-FUMI) potential type
    1917              : !> \param ftd ...
    1918              : !> \author Mathieu Salanne 05.2010
    1919              : ! **************************************************************************************************
    1920          132 :    SUBROUTINE pair_potential_bmhftd_create(ftd)
    1921              :       TYPE(ftd_pot_type), POINTER                        :: ftd
    1922              : 
    1923          132 :       CPASSERT(.NOT. ASSOCIATED(ftd))
    1924          528 :       ALLOCATE (ftd)
    1925          132 :       CALL pair_potential_bmhftd_clean(ftd)
    1926          132 :    END SUBROUTINE pair_potential_bmhftd_create
    1927              : 
    1928              : ! **************************************************************************************************
    1929              : !> \brief Copy two BMHFTD (Damped TOSI-FUMI) potential type
    1930              : !> \param ftd_source ...
    1931              : !> \param ftd_dest ...
    1932              : !> \author Mathieu Salanne 05.2010
    1933              : ! **************************************************************************************************
    1934        12530 :    SUBROUTINE pair_potential_bmhftd_copy(ftd_source, ftd_dest)
    1935              :       TYPE(ftd_pot_type), POINTER                        :: ftd_source, ftd_dest
    1936              : 
    1937        12530 :       IF (.NOT. ASSOCIATED(ftd_source)) RETURN
    1938           66 :       IF (ASSOCIATED(ftd_dest)) CALL pair_potential_bmhftd_release(ftd_dest)
    1939           66 :       CALL pair_potential_bmhftd_create(ftd_dest)
    1940           66 :       ftd_dest%A = ftd_source%A
    1941           66 :       ftd_dest%B = ftd_source%B
    1942           66 :       ftd_dest%C = ftd_source%C
    1943           66 :       ftd_dest%D = ftd_source%D
    1944          330 :       ftd_dest%BD = ftd_source%BD
    1945              :    END SUBROUTINE pair_potential_bmhftd_copy
    1946              : 
    1947              : ! **************************************************************************************************
    1948              : !> \brief Cleans the BMHFTD (damped TOSI-FUMI) potential type
    1949              : !> \param ftd ...
    1950              : !> \author Mathieu Salanne
    1951              : ! **************************************************************************************************
    1952       570125 :    SUBROUTINE pair_potential_bmhftd_clean(ftd)
    1953              :       TYPE(ftd_pot_type), POINTER                        :: ftd
    1954              : 
    1955       570125 :       IF (.NOT. ASSOCIATED(ftd)) RETURN
    1956          132 :       ftd%A = 0.0_dp
    1957          132 :       ftd%B = 0.0_dp
    1958          132 :       ftd%C = 0.0_dp
    1959          132 :       ftd%D = 0.0_dp
    1960          396 :       ftd%BD = 0.0_dp
    1961              :    END SUBROUTINE pair_potential_bmhftd_clean
    1962              : 
    1963              : ! **************************************************************************************************
    1964              : !> \brief Destroys the BMHFTD potential type
    1965              : !> \param ftd ...
    1966              : !> \author Mathieu Salanne 05.2010
    1967              : ! **************************************************************************************************
    1968       525718 :    SUBROUTINE pair_potential_bmhftd_release(ftd)
    1969              :       TYPE(ftd_pot_type), POINTER                        :: ftd
    1970              : 
    1971       525718 :       IF (ASSOCIATED(ftd)) THEN
    1972          132 :          DEALLOCATE (ftd)
    1973              :       END IF
    1974       525718 :       NULLIFY (ftd)
    1975       525718 :    END SUBROUTINE pair_potential_bmhftd_release
    1976              : 
    1977              : ! **************************************************************************************************
    1978              : !> \brief Creates the IPBV potential type
    1979              : !> \param ipbv ...
    1980              : !> \author Teodoro Laino [teo] 11.2005
    1981              : ! **************************************************************************************************
    1982           96 :    SUBROUTINE pair_potential_ipbv_create(ipbv)
    1983              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv
    1984              : 
    1985           96 :       CPASSERT(.NOT. ASSOCIATED(ipbv))
    1986         1536 :       ALLOCATE (ipbv)
    1987           96 :       CALL pair_potential_ipbv_clean(ipbv)
    1988           96 :    END SUBROUTINE pair_potential_ipbv_create
    1989              : 
    1990              : ! **************************************************************************************************
    1991              : !> \brief Copy two IPBV potential type
    1992              : !> \param ipbv_source ...
    1993              : !> \param ipbv_dest ...
    1994              : !> \author Teodoro Laino [teo] 11.2005
    1995              : ! **************************************************************************************************
    1996        12530 :    SUBROUTINE pair_potential_ipbv_copy(ipbv_source, ipbv_dest)
    1997              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv_source, ipbv_dest
    1998              : 
    1999        12530 :       IF (.NOT. ASSOCIATED(ipbv_source)) RETURN
    2000           48 :       IF (ASSOCIATED(ipbv_dest)) CALL pair_potential_ipbv_release(ipbv_dest)
    2001           48 :       CALL pair_potential_ipbv_create(ipbv_dest)
    2002         1392 :       ipbv_dest%a = ipbv_source%a
    2003           48 :       ipbv_dest%rcore = ipbv_source%rcore
    2004           48 :       ipbv_dest%b = ipbv_source%b
    2005           48 :       ipbv_dest%m = ipbv_source%m
    2006              :    END SUBROUTINE pair_potential_ipbv_copy
    2007              : 
    2008              : ! **************************************************************************************************
    2009              : !> \brief Creates the IPBV potential type
    2010              : !> \param ipbv ...
    2011              : !> \author Teodoro Laino [teo] 11.2005
    2012              : ! **************************************************************************************************
    2013       570089 :    SUBROUTINE pair_potential_ipbv_clean(ipbv)
    2014              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv
    2015              : 
    2016       570089 :       IF (.NOT. ASSOCIATED(ipbv)) RETURN
    2017         1440 :       ipbv%a = 0.0_dp
    2018           96 :       ipbv%rcore = 0.0_dp
    2019           96 :       ipbv%b = 0.0_dp
    2020           96 :       ipbv%m = 0.0_dp
    2021              :    END SUBROUTINE pair_potential_ipbv_clean
    2022              : 
    2023              : ! **************************************************************************************************
    2024              : !> \brief Destroys the IPBV potential type
    2025              : !> \param ipbv ...
    2026              : !> \author Teodoro Laino [teo] 11.2005
    2027              : ! **************************************************************************************************
    2028       525718 :    SUBROUTINE pair_potential_ipbv_release(ipbv)
    2029              :       TYPE(ipbv_pot_type), POINTER                       :: ipbv
    2030              : 
    2031       525718 :       IF (ASSOCIATED(ipbv)) THEN
    2032           96 :          DEALLOCATE (ipbv)
    2033              :       END IF
    2034       525718 :       NULLIFY (ipbv)
    2035       525718 :    END SUBROUTINE pair_potential_ipbv_release
    2036              : 
    2037              : ! **************************************************************************************************
    2038              : !> \brief Creates the Buckingham 4 ranges  potential type
    2039              : !> \param buck4r ...
    2040              : !> \author MI 10.2006
    2041              : ! **************************************************************************************************
    2042          526 :    SUBROUTINE pair_potential_buck4r_create(buck4r)
    2043              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r
    2044              : 
    2045          526 :       CPASSERT(.NOT. ASSOCIATED(buck4r))
    2046        13150 :       ALLOCATE (buck4r)
    2047          526 :       CALL pair_potential_buck4r_clean(buck4r)
    2048          526 :    END SUBROUTINE pair_potential_buck4r_create
    2049              : 
    2050              : ! **************************************************************************************************
    2051              : !> \brief Copy two Buckingham 4 ranges  potential type
    2052              : !> \param buck4r_source ...
    2053              : !> \param buck4r_dest ...
    2054              : !> \author MI 10.2006
    2055              : ! **************************************************************************************************
    2056        12530 :    SUBROUTINE pair_potential_buck4r_copy(buck4r_source, buck4r_dest)
    2057              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r_source, buck4r_dest
    2058              : 
    2059        12530 :       IF (.NOT. ASSOCIATED(buck4r_source)) RETURN
    2060          264 :       IF (ASSOCIATED(buck4r_dest)) CALL pair_potential_buck4r_release(buck4r_dest)
    2061          264 :       CALL pair_potential_buck4r_create(buck4r_dest)
    2062          264 :       buck4r_dest%a = buck4r_source%a
    2063          264 :       buck4r_dest%b = buck4r_source%b
    2064          264 :       buck4r_dest%c = buck4r_source%c
    2065          264 :       buck4r_dest%r1 = buck4r_source%r1
    2066          264 :       buck4r_dest%r2 = buck4r_source%r2
    2067          264 :       buck4r_dest%r3 = buck4r_source%r3
    2068         6072 :       buck4r_dest%poly1 = buck4r_source%poly1
    2069         6072 :       buck4r_dest%poly2 = buck4r_source%poly2
    2070          264 :       buck4r_dest%npoly1 = buck4r_source%npoly1
    2071          264 :       buck4r_dest%npoly2 = buck4r_source%npoly2
    2072              :    END SUBROUTINE pair_potential_buck4r_copy
    2073              : 
    2074              : ! **************************************************************************************************
    2075              : !> \brief Creates the Buckingham 4 ranges  potential type
    2076              : !> \param buck4r ...
    2077              : !> \author MI 10.2006
    2078              : ! **************************************************************************************************
    2079       570519 :    SUBROUTINE pair_potential_buck4r_clean(buck4r)
    2080              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r
    2081              : 
    2082       570519 :       IF (.NOT. ASSOCIATED(buck4r)) RETURN
    2083          526 :       buck4r%a = 0.0_dp
    2084          526 :       buck4r%b = 0.0_dp
    2085          526 :       buck4r%c = 0.0_dp
    2086          526 :       buck4r%r1 = 0.0_dp
    2087          526 :       buck4r%r2 = 0.0_dp
    2088          526 :       buck4r%r3 = 0.0_dp
    2089         6312 :       buck4r%poly1 = 0.0_dp
    2090          526 :       buck4r%npoly1 = 0
    2091         6312 :       buck4r%poly2 = 0.0_dp
    2092          526 :       buck4r%npoly2 = 0
    2093              :    END SUBROUTINE pair_potential_buck4r_clean
    2094              : 
    2095              : ! **************************************************************************************************
    2096              : !> \brief Destroys the Buckingham 4 ranges potential type
    2097              : !> \param buck4r ...
    2098              : !> \author MI  10.2006
    2099              : ! **************************************************************************************************
    2100       525718 :    SUBROUTINE pair_potential_buck4r_release(buck4r)
    2101              :       TYPE(buck4ran_pot_type), POINTER                   :: buck4r
    2102              : 
    2103       525718 :       IF (ASSOCIATED(buck4r)) THEN
    2104          526 :          DEALLOCATE (buck4r)
    2105              :       END IF
    2106       525718 :       NULLIFY (buck4r)
    2107       525718 :    END SUBROUTINE pair_potential_buck4r_release
    2108              : 
    2109              : ! **************************************************************************************************
    2110              : !> \brief Creates the Buckingham plus Morse potential type
    2111              : !> \param buckmo ...
    2112              : !> \author MI 10.2006
    2113              : ! **************************************************************************************************
    2114           24 :    SUBROUTINE pair_potential_buckmo_create(buckmo)
    2115              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo
    2116              : 
    2117           24 :       CPASSERT(.NOT. ASSOCIATED(buckmo))
    2118           24 :       ALLOCATE (buckmo)
    2119           24 :       CALL pair_potential_buckmo_clean(buckmo)
    2120           24 :    END SUBROUTINE pair_potential_buckmo_create
    2121              : 
    2122              : ! **************************************************************************************************
    2123              : !> \brief Copy two Buckingham plus Morse  potential type
    2124              : !> \param buckmo_source ...
    2125              : !> \param buckmo_dest ...
    2126              : !> \author MI 10.2006
    2127              : ! **************************************************************************************************
    2128        12530 :    SUBROUTINE pair_potential_buckmo_copy(buckmo_source, buckmo_dest)
    2129              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo_source, buckmo_dest
    2130              : 
    2131        12530 :       IF (.NOT. ASSOCIATED(buckmo_source)) RETURN
    2132           10 :       IF (ASSOCIATED(buckmo_dest)) CALL pair_potential_buckmo_release(buckmo_dest)
    2133           10 :       CALL pair_potential_buckmo_create(buckmo_dest)
    2134           10 :       buckmo_dest%f0 = buckmo_source%f0
    2135           10 :       buckmo_dest%a1 = buckmo_source%a1
    2136           10 :       buckmo_dest%a2 = buckmo_source%a2
    2137           10 :       buckmo_dest%b1 = buckmo_source%b1
    2138           10 :       buckmo_dest%b2 = buckmo_source%b2
    2139           10 :       buckmo_dest%c = buckmo_source%c
    2140           10 :       buckmo_dest%d = buckmo_source%d
    2141           10 :       buckmo_dest%r0 = buckmo_source%r0
    2142           10 :       buckmo_dest%beta = buckmo_source%beta
    2143              :    END SUBROUTINE pair_potential_buckmo_copy
    2144              : 
    2145              : ! **************************************************************************************************
    2146              : !> \brief Creates the Buckingham plus Morse  potential type
    2147              : !> \param buckmo ...
    2148              : !> \author MI 10.2006
    2149              : ! **************************************************************************************************
    2150       570017 :    SUBROUTINE pair_potential_buckmo_clean(buckmo)
    2151              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo
    2152              : 
    2153       570017 :       IF (.NOT. ASSOCIATED(buckmo)) RETURN
    2154           24 :       buckmo%f0 = 0.0_dp
    2155           24 :       buckmo%a1 = 0.0_dp
    2156           24 :       buckmo%a2 = 0.0_dp
    2157           24 :       buckmo%b1 = 0.0_dp
    2158           24 :       buckmo%b2 = 0.0_dp
    2159           24 :       buckmo%c = 0.0_dp
    2160           24 :       buckmo%d = 0.0_dp
    2161           24 :       buckmo%r0 = 0.0_dp
    2162           24 :       buckmo%beta = 0.0_dp
    2163              :    END SUBROUTINE pair_potential_buckmo_clean
    2164              : 
    2165              : ! **************************************************************************************************
    2166              : !> \brief Destroys the Buckingham plus Morse potential type
    2167              : !> \param buckmo ...
    2168              : !> \author MI  10.2006
    2169              : ! **************************************************************************************************
    2170       525718 :    SUBROUTINE pair_potential_buckmo_release(buckmo)
    2171              :       TYPE(buckmorse_pot_type), POINTER                  :: buckmo
    2172              : 
    2173       525718 :       IF (ASSOCIATED(buckmo)) THEN
    2174           24 :          DEALLOCATE (buckmo)
    2175              :       END IF
    2176       525718 :       NULLIFY (buckmo)
    2177       525718 :    END SUBROUTINE pair_potential_buckmo_release
    2178              : 
    2179              : ! **************************************************************************************************
    2180              : !> \brief Creates the Tersoff potential type
    2181              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2182              : !> \param tersoff ...
    2183              : ! **************************************************************************************************
    2184         1568 :    SUBROUTINE pair_potential_tersoff_create(tersoff)
    2185              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff
    2186              : 
    2187         1568 :       CPASSERT(.NOT. ASSOCIATED(tersoff))
    2188         1568 :       ALLOCATE (tersoff)
    2189         1568 :       CALL pair_potential_tersoff_clean(tersoff)
    2190         1568 :    END SUBROUTINE pair_potential_tersoff_create
    2191              : 
    2192              : ! **************************************************************************************************
    2193              : !> \brief Copy two Tersoff potential type
    2194              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2195              : !> \param tersoff_source ...
    2196              : !> \param tersoff_dest ...
    2197              : ! **************************************************************************************************
    2198        12530 :    SUBROUTINE pair_potential_tersoff_copy(tersoff_source, tersoff_dest)
    2199              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff_source, tersoff_dest
    2200              : 
    2201        12530 :       IF (.NOT. ASSOCIATED(tersoff_source)) RETURN
    2202         1524 :       IF (ASSOCIATED(tersoff_dest)) CALL pair_potential_tersoff_release(tersoff_dest)
    2203         1524 :       CALL pair_potential_tersoff_create(tersoff_dest)
    2204         1524 :       tersoff_dest%A = tersoff_source%A
    2205         1524 :       tersoff_dest%B = tersoff_source%B
    2206         1524 :       tersoff_dest%lambda1 = tersoff_source%lambda1
    2207         1524 :       tersoff_dest%lambda2 = tersoff_source%lambda2
    2208         1524 :       tersoff_dest%alpha = tersoff_source%alpha
    2209         1524 :       tersoff_dest%beta = tersoff_source%beta
    2210         1524 :       tersoff_dest%n = tersoff_source%n
    2211         1524 :       tersoff_dest%c = tersoff_source%c
    2212         1524 :       tersoff_dest%d = tersoff_source%d
    2213         1524 :       tersoff_dest%h = tersoff_source%h
    2214         1524 :       tersoff_dest%lambda3 = tersoff_source%lambda3
    2215         1524 :       tersoff_dest%bigR = tersoff_source%bigR
    2216         1524 :       tersoff_dest%bigD = tersoff_source%bigD
    2217         1524 :       tersoff_dest%rcutsq = tersoff_source%rcutsq
    2218              :    END SUBROUTINE pair_potential_tersoff_copy
    2219              : 
    2220              : ! **************************************************************************************************
    2221              : !> \brief Creates the Tersoff potential type
    2222              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2223              : !> \param tersoff ...
    2224              : ! **************************************************************************************************
    2225       571561 :    SUBROUTINE pair_potential_tersoff_clean(tersoff)
    2226              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff
    2227              : 
    2228       571561 :       IF (.NOT. ASSOCIATED(tersoff)) RETURN
    2229         2974 :       tersoff%A = 0.0_dp
    2230         2974 :       tersoff%B = 0.0_dp
    2231         2974 :       tersoff%lambda1 = 0.0_dp
    2232         2974 :       tersoff%lambda2 = 0.0_dp
    2233         2974 :       tersoff%alpha = 0.0_dp
    2234         2974 :       tersoff%beta = 0.0_dp
    2235         2974 :       tersoff%n = 0.0_dp
    2236         2974 :       tersoff%c = 0.0_dp
    2237         2974 :       tersoff%d = 0.0_dp
    2238         2974 :       tersoff%h = 0.0_dp
    2239         2974 :       tersoff%lambda3 = 0.0_dp
    2240         2974 :       tersoff%bigR = 0.0_dp
    2241         2974 :       tersoff%bigD = 0.0_dp
    2242         2974 :       tersoff%rcutsq = 0.0_dp
    2243              :    END SUBROUTINE pair_potential_tersoff_clean
    2244              : 
    2245              : ! **************************************************************************************************
    2246              : !> \brief Destroys the Tersoff
    2247              : !>      (Tersoff, J. PRB 39(8), 5566, 1989)
    2248              : !> \param tersoff ...
    2249              : ! **************************************************************************************************
    2250       525718 :    SUBROUTINE pair_potential_tersoff_release(tersoff)
    2251              :       TYPE(tersoff_pot_type), POINTER                    :: tersoff
    2252              : 
    2253       525718 :       IF (ASSOCIATED(tersoff)) THEN
    2254         1568 :          DEALLOCATE (tersoff)
    2255              :       END IF
    2256       525718 :       NULLIFY (tersoff)
    2257       525718 :    END SUBROUTINE pair_potential_tersoff_release
    2258              : 
    2259              : ! **************************************************************************************************
    2260              : !> \brief Creates the Siepmann-Sprik potential type
    2261              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2262              : !> \param siepmann ...
    2263              : ! **************************************************************************************************
    2264           10 :    SUBROUTINE pair_potential_siepmann_create(siepmann)
    2265              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann
    2266              : 
    2267           10 :       CPASSERT(.NOT. ASSOCIATED(siepmann))
    2268           10 :       ALLOCATE (siepmann)
    2269           10 :       CALL pair_potential_siepmann_clean(siepmann)
    2270           10 :    END SUBROUTINE pair_potential_siepmann_create
    2271              : ! **************************************************************************************************
    2272              : !> \brief Copy two Siepmann potential type
    2273              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2274              : !> \param siepmann_source ...
    2275              : !> \param siepmann_dest ...
    2276              : ! **************************************************************************************************
    2277        12530 :    SUBROUTINE pair_potential_siepmann_copy(siepmann_source, siepmann_dest)
    2278              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann_source, siepmann_dest
    2279              : 
    2280        12530 :       IF (.NOT. ASSOCIATED(siepmann_source)) RETURN
    2281            5 :       IF (ASSOCIATED(siepmann_dest)) CALL pair_potential_siepmann_release(siepmann_dest)
    2282            5 :       CALL pair_potential_siepmann_create(siepmann_dest)
    2283            5 :       siepmann_dest%B = siepmann_source%B
    2284            5 :       siepmann_dest%D = siepmann_source%D
    2285            5 :       siepmann_dest%E = siepmann_source%E
    2286            5 :       siepmann_dest%F = siepmann_source%F
    2287            5 :       siepmann_dest%beta = siepmann_source%beta
    2288            5 :       siepmann_dest%rcutsq = siepmann_source%rcutsq
    2289            5 :       siepmann_dest%allow_oh_formation = siepmann_source%allow_oh_formation
    2290            5 :       siepmann_dest%allow_h3o_formation = siepmann_source%allow_h3o_formation
    2291            5 :       siepmann_dest%allow_o_formation = siepmann_source%allow_o_formation
    2292              : 
    2293              :    END SUBROUTINE pair_potential_siepmann_copy
    2294              : 
    2295              : ! **************************************************************************************************
    2296              : !> \brief Creates the Siepmann-Sprik potential type
    2297              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2298              : !> \param siepmann ...
    2299              : ! **************************************************************************************************
    2300       570003 :    SUBROUTINE pair_potential_siepmann_clean(siepmann)
    2301              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann
    2302              : 
    2303       570003 :       IF (.NOT. ASSOCIATED(siepmann)) RETURN
    2304           10 :       siepmann%B = 0.0_dp
    2305           10 :       siepmann%D = 0.0_dp
    2306           10 :       siepmann%E = 0.0_dp
    2307           10 :       siepmann%F = 0.0_dp
    2308           10 :       siepmann%beta = 0.0_dp
    2309           10 :       siepmann%rcutsq = 0.0_dp
    2310           10 :       siepmann%allow_oh_formation = .FALSE.
    2311           10 :       siepmann%allow_h3o_formation = .FALSE.
    2312           10 :       siepmann%allow_o_formation = .FALSE.
    2313              : 
    2314              :    END SUBROUTINE pair_potential_siepmann_clean
    2315              : 
    2316              : ! **************************************************************************************************
    2317              : !> \brief Destroys the Siepmann-Sprik potential
    2318              : !>      (Siepmann and Sprik, J. Chem. Phys. 102(1) 511, 1995)
    2319              : !> \param siepmann ...
    2320              : ! **************************************************************************************************
    2321       525718 :    SUBROUTINE pair_potential_siepmann_release(siepmann)
    2322              :       TYPE(siepmann_pot_type), POINTER                   :: siepmann
    2323              : 
    2324       525718 :       IF (ASSOCIATED(siepmann)) THEN
    2325           10 :          DEALLOCATE (siepmann)
    2326              :       END IF
    2327       525718 :       NULLIFY (siepmann)
    2328       525718 :    END SUBROUTINE pair_potential_siepmann_release
    2329              : 
    2330              : ! **************************************************************************************************
    2331              : !> \brief Creates the GAL19 potential type
    2332              : !>      (??)
    2333              : !> \param gal ...
    2334              : ! **************************************************************************************************
    2335            2 :    SUBROUTINE pair_potential_gal_create(gal)
    2336              :       TYPE(gal_pot_type), POINTER                        :: gal
    2337              : 
    2338            2 :       CPASSERT(.NOT. ASSOCIATED(gal))
    2339            2 :       ALLOCATE (gal)
    2340            2 :       CALL pair_potential_gal_clean(gal)
    2341            2 :    END SUBROUTINE pair_potential_gal_create
    2342              : 
    2343              : ! **************************************************************************************************
    2344              : !> \brief Copy two GAL potential type
    2345              : !>      (??)
    2346              : !> \param gal_source ...
    2347              : !> \param gal_dest ...
    2348              : ! **************************************************************************************************
    2349        12530 :    SUBROUTINE pair_potential_gal_copy(gal_source, gal_dest)
    2350              :       TYPE(gal_pot_type), POINTER                        :: gal_source, gal_dest
    2351              : 
    2352        12530 :       IF (.NOT. ASSOCIATED(gal_source)) RETURN
    2353            1 :       IF (ASSOCIATED(gal_dest)) CALL pair_potential_gal_release(gal_dest)
    2354            1 :       CALL pair_potential_gal_create(gal_dest)
    2355            1 :       gal_dest%met1 = gal_source%met1
    2356            1 :       gal_dest%met2 = gal_source%met2
    2357            1 :       gal_dest%epsilon = gal_source%epsilon
    2358            1 :       gal_dest%bxy = gal_source%bxy
    2359            1 :       gal_dest%bz = gal_source%bz
    2360            1 :       gal_dest%r1 = gal_source%r1
    2361            1 :       gal_dest%r2 = gal_source%r2
    2362            1 :       gal_dest%a1 = gal_source%a1
    2363            1 :       gal_dest%a2 = gal_source%a2
    2364            1 :       gal_dest%a3 = gal_source%a3
    2365            1 :       gal_dest%a4 = gal_source%a4
    2366            1 :       gal_dest%a = gal_source%a
    2367            1 :       gal_dest%b = gal_source%b
    2368            1 :       gal_dest%c = gal_source%c
    2369            3 :       ALLOCATE (gal_dest%gcn(SIZE(gal_source%gcn)))
    2370         1741 :       gal_dest%gcn = gal_source%gcn
    2371            1 :       gal_dest%express = gal_source%express
    2372            1 :       gal_dest%rcutsq = gal_source%rcutsq
    2373              : 
    2374              :    END SUBROUTINE pair_potential_gal_copy
    2375              : 
    2376              : ! **************************************************************************************************
    2377              : !> \brief Creates the GAL19 potential type
    2378              : !>      (??)
    2379              : !> \param gal ...
    2380              : ! **************************************************************************************************
    2381       569995 :    SUBROUTINE pair_potential_gal_clean(gal)
    2382              :       TYPE(gal_pot_type), POINTER                        :: gal
    2383              : 
    2384       569995 :       IF (.NOT. ASSOCIATED(gal)) RETURN
    2385            2 :       gal%epsilon = 0.0_dp
    2386            2 :       gal%bxy = 0.0_dp
    2387            2 :       gal%bz = 0.0_dp
    2388            2 :       gal%r1 = 0.0_dp
    2389            2 :       gal%r2 = 0.0_dp
    2390            2 :       gal%a1 = 0.0_dp
    2391            2 :       gal%a2 = 0.0_dp
    2392            2 :       gal%a3 = 0.0_dp
    2393            2 :       gal%a4 = 0.0_dp
    2394            2 :       gal%a = 0.0_dp
    2395            2 :       gal%b = 0.0_dp
    2396            2 :       gal%c = 0.0_dp
    2397            2 :       gal%rcutsq = 0.0_dp
    2398            2 :       gal%express = .FALSE.
    2399              : 
    2400              :    END SUBROUTINE pair_potential_gal_clean
    2401              : 
    2402              : ! **************************************************************************************************
    2403              : !> \brief Destroys the GAL19 potential
    2404              : !>      (??)
    2405              : !> \param gal ...
    2406              : ! **************************************************************************************************
    2407       525718 :    SUBROUTINE pair_potential_gal_release(gal)
    2408              :       TYPE(gal_pot_type), POINTER                        :: gal
    2409              : 
    2410       525718 :       IF (ASSOCIATED(gal)) THEN
    2411            2 :          DEALLOCATE (gal%gcn)
    2412            2 :          DEALLOCATE (gal)
    2413              :       END IF
    2414       525718 :       NULLIFY (gal)
    2415       525718 :    END SUBROUTINE pair_potential_gal_release
    2416              : 
    2417              : ! **************************************************************************************************
    2418              : !> \brief Creates the GAL21 potential type
    2419              : !>      (??)
    2420              : !> \param gal21 ...
    2421              : ! **************************************************************************************************
    2422            2 :    SUBROUTINE pair_potential_gal21_create(gal21)
    2423              :       TYPE(gal21_pot_type), POINTER                      :: gal21
    2424              : 
    2425            2 :       CPASSERT(.NOT. ASSOCIATED(gal21))
    2426            2 :       ALLOCATE (gal21)
    2427            2 :       CALL pair_potential_gal21_clean(gal21)
    2428            2 :    END SUBROUTINE pair_potential_gal21_create
    2429              : 
    2430              : ! **************************************************************************************************
    2431              : !> \brief Copy two GAL21 potential type
    2432              : !>      (??)
    2433              : !> \param gal21_source ...
    2434              : !> \param gal21_dest ...
    2435              : ! **************************************************************************************************
    2436        12530 :    SUBROUTINE pair_potential_gal21_copy(gal21_source, gal21_dest)
    2437              :       TYPE(gal21_pot_type), POINTER                      :: gal21_source, gal21_dest
    2438              : 
    2439        12530 :       IF (.NOT. ASSOCIATED(gal21_source)) RETURN
    2440            1 :       IF (ASSOCIATED(gal21_dest)) CALL pair_potential_gal21_release(gal21_dest)
    2441            1 :       CALL pair_potential_gal21_create(gal21_dest)
    2442            1 :       gal21_dest%met1 = gal21_source%met1
    2443            1 :       gal21_dest%met2 = gal21_source%met2
    2444            1 :       gal21_dest%epsilon1 = gal21_source%epsilon1
    2445            1 :       gal21_dest%epsilon2 = gal21_source%epsilon2
    2446            1 :       gal21_dest%epsilon3 = gal21_source%epsilon3
    2447            1 :       gal21_dest%bxy1 = gal21_source%bxy1
    2448            1 :       gal21_dest%bxy2 = gal21_source%bxy2
    2449            1 :       gal21_dest%bz1 = gal21_source%bz1
    2450            1 :       gal21_dest%bz2 = gal21_source%bz2
    2451            1 :       gal21_dest%r1 = gal21_source%r1
    2452            1 :       gal21_dest%r2 = gal21_source%r2
    2453            1 :       gal21_dest%a11 = gal21_source%a11
    2454            1 :       gal21_dest%a12 = gal21_source%a12
    2455            1 :       gal21_dest%a13 = gal21_source%a13
    2456            1 :       gal21_dest%a21 = gal21_source%a21
    2457            1 :       gal21_dest%a22 = gal21_source%a22
    2458            1 :       gal21_dest%a23 = gal21_source%a23
    2459            1 :       gal21_dest%a31 = gal21_source%a31
    2460            1 :       gal21_dest%a32 = gal21_source%a32
    2461            1 :       gal21_dest%a33 = gal21_source%a33
    2462            1 :       gal21_dest%a41 = gal21_source%a41
    2463            1 :       gal21_dest%a42 = gal21_source%a42
    2464            1 :       gal21_dest%a43 = gal21_source%a43
    2465            1 :       gal21_dest%AO1 = gal21_source%AO1
    2466            1 :       gal21_dest%AO2 = gal21_source%AO2
    2467            1 :       gal21_dest%BO1 = gal21_source%BO1
    2468            1 :       gal21_dest%BO2 = gal21_source%BO2
    2469            1 :       gal21_dest%c = gal21_source%c
    2470            1 :       gal21_dest%AH1 = gal21_source%AH1
    2471            1 :       gal21_dest%AH2 = gal21_source%AH2
    2472            1 :       gal21_dest%BH1 = gal21_source%BH1
    2473            1 :       gal21_dest%BH2 = gal21_source%BH2
    2474            3 :       ALLOCATE (gal21_dest%gcn(SIZE(gal21_source%gcn)))
    2475         1741 :       gal21_dest%gcn = gal21_source%gcn
    2476            1 :       gal21_dest%express = gal21_source%express
    2477            1 :       gal21_dest%rcutsq = gal21_source%rcutsq
    2478              : 
    2479              :    END SUBROUTINE pair_potential_gal21_copy
    2480              : 
    2481              : ! **************************************************************************************************
    2482              : !> \brief Creates the GAL21 potential type
    2483              : !>      (??)
    2484              : !> \param gal21 ...
    2485              : ! **************************************************************************************************
    2486       569995 :    SUBROUTINE pair_potential_gal21_clean(gal21)
    2487              :       TYPE(gal21_pot_type), POINTER                      :: gal21
    2488              : 
    2489       569995 :       IF (.NOT. ASSOCIATED(gal21)) RETURN
    2490            2 :       gal21%epsilon1 = 0.0_dp
    2491            2 :       gal21%epsilon2 = 0.0_dp
    2492            2 :       gal21%epsilon3 = 0.0_dp
    2493            2 :       gal21%bxy1 = 0.0_dp
    2494            2 :       gal21%bxy2 = 0.0_dp
    2495            2 :       gal21%bz1 = 0.0_dp
    2496            2 :       gal21%bz2 = 0.0_dp
    2497            2 :       gal21%r1 = 0.0_dp
    2498            2 :       gal21%r2 = 0.0_dp
    2499            2 :       gal21%a11 = 0.0_dp
    2500            2 :       gal21%a12 = 0.0_dp
    2501            2 :       gal21%a13 = 0.0_dp
    2502            2 :       gal21%a21 = 0.0_dp
    2503            2 :       gal21%a22 = 0.0_dp
    2504            2 :       gal21%a23 = 0.0_dp
    2505            2 :       gal21%a31 = 0.0_dp
    2506            2 :       gal21%a32 = 0.0_dp
    2507            2 :       gal21%a33 = 0.0_dp
    2508            2 :       gal21%a41 = 0.0_dp
    2509            2 :       gal21%a42 = 0.0_dp
    2510            2 :       gal21%a43 = 0.0_dp
    2511            2 :       gal21%AO1 = 0.0_dp
    2512            2 :       gal21%AO2 = 0.0_dp
    2513            2 :       gal21%BO1 = 0.0_dp
    2514            2 :       gal21%BO2 = 0.0_dp
    2515            2 :       gal21%c = 0.0_dp
    2516            2 :       gal21%AH1 = 0.0_dp
    2517            2 :       gal21%AH2 = 0.0_dp
    2518            2 :       gal21%BH1 = 0.0_dp
    2519            2 :       gal21%BH2 = 0.0_dp
    2520            2 :       gal21%rcutsq = 0.0_dp
    2521            2 :       gal21%express = .FALSE.
    2522              : 
    2523              :    END SUBROUTINE pair_potential_gal21_clean
    2524              : 
    2525              : ! **************************************************************************************************
    2526              : !> \brief Destroys the GAL21 potential
    2527              : !>      (??)
    2528              : !> \param gal21 ...
    2529              : ! **************************************************************************************************
    2530       525718 :    SUBROUTINE pair_potential_gal21_release(gal21)
    2531              :       TYPE(gal21_pot_type), POINTER                      :: gal21
    2532              : 
    2533       525718 :       IF (ASSOCIATED(gal21)) THEN
    2534            2 :          DEALLOCATE (gal21%gcn)
    2535            2 :          DEALLOCATE (gal21)
    2536              :       END IF
    2537       525718 :       NULLIFY (gal21)
    2538       525718 :    END SUBROUTINE pair_potential_gal21_release
    2539              : 
    2540              : ! **************************************************************************************************
    2541              : !> \brief Creates the TABPOT potential type
    2542              : !> \param tab ...
    2543              : !> \author Alex Mironenko, Da Teng 2019-2022
    2544              : ! **************************************************************************************************
    2545           48 :    SUBROUTINE pair_potential_tab_create(tab)
    2546              :       TYPE(tab_pot_type), POINTER                        :: tab
    2547              : 
    2548           48 :       CPASSERT(.NOT. ASSOCIATED(tab))
    2549           48 :       ALLOCATE (tab)
    2550              :       NULLIFY (tab%r, tab%e, tab%f)
    2551           48 :       CALL pair_potential_tab_clean(tab)
    2552           48 :    END SUBROUTINE pair_potential_tab_create
    2553              : 
    2554              : ! **************************************************************************************************
    2555              : !> \brief Copy two TABPOT potential type
    2556              : !> \param tab_source ...
    2557              : !> \param tab_dest ...
    2558              : ! **************************************************************************************************
    2559        12530 :    SUBROUTINE pair_potential_tab_copy(tab_source, tab_dest)
    2560              :       TYPE(tab_pot_type), POINTER                        :: tab_source, tab_dest
    2561              : 
    2562        12530 :       IF (.NOT. ASSOCIATED(tab_source)) RETURN
    2563           24 :       IF (ASSOCIATED(tab_dest)) CALL pair_potential_tab_release(tab_dest)
    2564           24 :       CALL pair_potential_tab_create(tab_dest)
    2565           24 :       tab_dest%tabpot_file_name = tab_source%tabpot_file_name
    2566           24 :       tab_dest%dr = tab_source%dr
    2567           24 :       tab_dest%rcut = tab_source%rcut
    2568           24 :       tab_dest%npoints = tab_source%npoints
    2569           24 :       tab_dest%index = tab_source%index
    2570              :       ! Allocate arrays with the proper size
    2571           24 :       CALL reallocate(tab_dest%r, 1, tab_dest%npoints)
    2572           24 :       CALL reallocate(tab_dest%e, 1, tab_dest%npoints)
    2573           24 :       CALL reallocate(tab_dest%f, 1, tab_dest%npoints)
    2574        43800 :       tab_dest%r = tab_source%r
    2575        43800 :       tab_dest%e = tab_source%e
    2576        43800 :       tab_dest%f = tab_source%f
    2577              :    END SUBROUTINE pair_potential_tab_copy
    2578              : 
    2579              : ! **************************************************************************************************
    2580              : !> \brief Creates the TABPOT potential type
    2581              : !> \param tab ...
    2582              : ! **************************************************************************************************
    2583       570041 :    SUBROUTINE pair_potential_tab_clean(tab)
    2584              :       TYPE(tab_pot_type), POINTER                        :: tab
    2585              : 
    2586       570041 :       IF (.NOT. ASSOCIATED(tab)) RETURN
    2587           48 :       tab%tabpot_file_name = 'NULL'
    2588           48 :       tab%dr = 0.0_dp
    2589           48 :       tab%rcut = 0.0_dp
    2590           48 :       tab%npoints = 0
    2591           48 :       tab%index = 0
    2592           48 :       CALL reallocate(tab%r, 1, tab%npoints)
    2593           48 :       CALL reallocate(tab%e, 1, tab%npoints)
    2594           48 :       CALL reallocate(tab%f, 1, tab%npoints)
    2595              : 
    2596              :    END SUBROUTINE pair_potential_tab_clean
    2597              : 
    2598              : ! **************************************************************************************************
    2599              : !> \brief Destroys the TABPOT potential type
    2600              : !> \param tab ...
    2601              : ! **************************************************************************************************
    2602       525718 :    SUBROUTINE pair_potential_tab_release(tab)
    2603              :       TYPE(tab_pot_type), POINTER                        :: tab
    2604              : 
    2605       525718 :       IF (ASSOCIATED(tab)) THEN
    2606           48 :          IF (ASSOCIATED(tab%r)) THEN
    2607           48 :             DEALLOCATE (tab%r)
    2608              :          END IF
    2609           48 :          IF (ASSOCIATED(tab%e)) THEN
    2610           48 :             DEALLOCATE (tab%e)
    2611              :          END IF
    2612           48 :          IF (ASSOCIATED(tab%f)) THEN
    2613           48 :             DEALLOCATE (tab%f)
    2614              :          END IF
    2615           48 :          DEALLOCATE (tab)
    2616              :       END IF
    2617       525718 :    END SUBROUTINE pair_potential_tab_release
    2618              : 
    2619            0 : END MODULE pair_potential_types
    2620              : 
        

Generated by: LCOV version 2.0-1