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

Generated by: LCOV version 2.0-1