LCOV - code coverage report
Current view: top level - src - cp_control_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:c740a4b) Lines: 196 202 97.0 %
Date: 2025-05-29 08:02:39 Functions: 25 55 45.5 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2025 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief Defines control structures, which contain the parameters and the
      10             : !>      settings for the DFT-based calculations.
      11             : ! **************************************************************************************************
      12             : MODULE cp_control_types
      13             :    USE cp_fm_types,                     ONLY: cp_fm_release,&
      14             :                                               cp_fm_type
      15             :    USE eeq_input,                       ONLY: eeq_solver_type
      16             :    USE input_constants,                 ONLY: do_full_density,&
      17             :                                               rtp_bse_ham_G0W0,&
      18             :                                               rtp_method_tddft
      19             :    USE kinds,                           ONLY: default_path_length,&
      20             :                                               default_string_length,&
      21             :                                               dp
      22             :    USE pair_potential_types,            ONLY: pair_potential_p_release,&
      23             :                                               pair_potential_p_type
      24             :    USE qs_cdft_types,                   ONLY: cdft_control_create,&
      25             :                                               cdft_control_release,&
      26             :                                               cdft_control_type
      27             :    USE smeagol_control_types,           ONLY: smeagol_control_create,&
      28             :                                               smeagol_control_release,&
      29             :                                               smeagol_control_type
      30             :    USE xas_control,                     ONLY: xas_control_release,&
      31             :                                               xas_control_type
      32             : #include "./base/base_uses.f90"
      33             : 
      34             :    IMPLICIT NONE
      35             : 
      36             :    PRIVATE
      37             : 
      38             : !***************************************************************************************************
      39             : !\brief Control parameters for hairy-probes DFT
      40             : !***************************************************************************************************
      41             :    TYPE hairy_probes_type
      42             :       REAL(KIND=dp)                        :: alpha = 0.0_dp     ! solution probes parameter
      43             :       REAL(KIND=dp)                        :: mu = 0.0_dp        ! chemical potenatial of electrons in reservoir
      44             :       REAL(KIND=dp)                        :: T = 0.0_dp         ! temperature of electrons in reservoir
      45             :       REAL(KIND=dp)                        :: eps_hp = 0.0_dp    ! tolerance for accuracy checks on occupation numbers
      46             :       INTEGER                              :: natoms = 0, &
      47             :                                               last_ao = 0, &
      48             :                                               first_ao = 0
      49             :       INTEGER, DIMENSION(:), POINTER       :: atom_ids => NULL() ! atom ids to which the probes are attached
      50             :    END TYPE hairy_probes_type
      51             : 
      52             : ! **************************************************************************************************
      53             : ! \brief Control parameters for pw grids
      54             : ! **************************************************************************************************
      55             :    TYPE pw_grid_option
      56             :       LOGICAL                              :: spherical = .FALSE.
      57             :       LOGICAL                              :: fullspace = .FALSE.
      58             :       INTEGER, DIMENSION(2)                :: distribution_layout = 0
      59             :       INTEGER                              :: blocked = 0
      60             :    END TYPE pw_grid_option
      61             : 
      62             : ! **************************************************************************************************
      63             : ! \brief parameters for EMD/RTP calculations involving MO projections
      64             : ! **************************************************************************************************
      65             :    TYPE proj_mo_type
      66             :       INTEGER, DIMENSION(:), ALLOCATABLE         :: ref_mo_index
      67             :       INTEGER                                    :: ref_mo_spin = 1
      68             :       INTEGER                                    :: ref_nlumo = 0
      69             :       LOGICAL                                    :: sum_on_all_ref = .FALSE.
      70             :       INTEGER, DIMENSION(:), ALLOCATABLE         :: td_mo_index
      71             :       REAL(dp), DIMENSION(:), ALLOCATABLE        :: td_mo_occ
      72             :       INTEGER                                    :: td_mo_spin = 1
      73             :       LOGICAL                                    :: sum_on_all_td = .FALSE.
      74             :       CHARACTER(LEN=default_path_length)         :: ref_mo_file_name = ""
      75             :       LOGICAL                                    :: propagate_ref = .FALSE.
      76             :       TYPE(cp_fm_type), DIMENSION(:), &
      77             :          ALLOCATABLE                       :: mo_ref
      78             :    END TYPE proj_mo_type
      79             : 
      80             :    TYPE proj_mo_p_type
      81             :       TYPE(proj_mo_type), POINTER                :: proj_mo => NULL()
      82             :    END TYPE proj_mo_p_type
      83             : 
      84             : ! **************************************************************************************************
      85             : ! \brief Control parameters for REAL_TIME_PROPAGATION calculations
      86             : ! **************************************************************************************************
      87             :    TYPE rtp_control_type
      88             :       LOGICAL                              :: converged = .FALSE.
      89             :       REAL(KIND=dp)                        :: eps_ener = 0.0_dp
      90             :       INTEGER                              :: max_iter = 0
      91             :       INTEGER                              :: mat_exp = 0
      92             :       INTEGER                              :: propagator = 0
      93             :       LOGICAL                              :: fixed_ions = .FALSE.
      94             :       INTEGER                              :: rtp_method = rtp_method_tddft
      95             :       INTEGER                              :: rtbse_ham = rtp_bse_ham_G0W0
      96             :       INTEGER                              :: initial_wfn = 0
      97             :       REAL(dp)                             :: eps_exp = 0.0_dp
      98             :       LOGICAL                              :: initial_step = .FALSE.
      99             :       LOGICAL                              :: hfx_redistribute = .FALSE.
     100             :       INTEGER                              :: aspc_order = 0
     101             :       INTEGER                              :: sc_check_start = 0
     102             :       LOGICAL                              :: apply_wfn_mix_init_restart = .FALSE.
     103             :       LOGICAL                              :: apply_delta_pulse = .FALSE.
     104             :       LOGICAL                              :: apply_delta_pulse_mag = .FALSE.
     105             :       LOGICAL                              :: periodic = .FALSE.
     106             :       LOGICAL                              :: linear_scaling = .FALSE.
     107             :       LOGICAL                              :: write_restart = .FALSE.
     108             :       INTEGER                              :: mcweeny_max_iter = 0
     109             :       INTEGER                              :: acc_ref = 0
     110             :       REAL(dp)                             :: mcweeny_eps = 0.0_dp
     111             :       INTEGER, DIMENSION(3)                :: delta_pulse_direction = 0
     112             :       REAL(KIND=dp)                        :: delta_pulse_scale = 0.0_dp
     113             :       LOGICAL                              :: velocity_gauge = .FALSE.
     114             :       REAL(KIND=dp), DIMENSION(3)          :: field = 0.0_dp
     115             :       REAL(KIND=dp), DIMENSION(3)          :: vec_pot = 0.0_dp
     116             :       LOGICAL                              :: nl_gauge_transform = .FALSE.
     117             :       LOGICAL                              :: is_proj_mo = .FALSE.
     118             :       TYPE(proj_mo_p_type), DIMENSION(:), &
     119             :          POINTER                :: proj_mo_list => NULL()
     120             :    END TYPE rtp_control_type
     121             : 
     122             : ! **************************************************************************************************
     123             : ! \brief Control parameters for DFTB calculations
     124             : ! **************************************************************************************************
     125             :    TYPE dftb_control_type
     126             :       LOGICAL                              :: self_consistent = .FALSE.
     127             :       LOGICAL                              :: orthogonal_basis = .FALSE.
     128             :       LOGICAL                              :: dispersion = .FALSE.
     129             :       INTEGER                              :: dispersion_type = 0
     130             :       LOGICAL                              :: dftb3_diagonal = .FALSE.
     131             :       LOGICAL                              :: hb_sr_damp = .FALSE.
     132             :       REAL(KIND=dp)                        :: hb_sr_para = 0.0_dp
     133             :       REAL(KIND=dp)                        :: eps_disp = 0.0_dp
     134             :       REAL(KIND=dp)                        :: epscn = 0.0_dp
     135             :       REAL(KIND=dp)                        :: exp_pre = 0.0_dp
     136             :       REAL(KIND=dp)                        :: scaling = 0.0_dp
     137             :       REAL(KIND=dp)                        :: rcdisp = 0.0_dp
     138             :       REAL(KIND=dp), DIMENSION(3)          :: sd3 = 0.0_dp
     139             :       REAL(KIND=dp), DIMENSION(4)          :: sd3bj = 0.0_dp
     140             :       LOGICAL                              :: do_ewald = .FALSE.
     141             :       CHARACTER(LEN=default_path_length)   :: sk_file_path = ""
     142             :       CHARACTER(LEN=default_path_length)   :: sk_file_list = ""
     143             :       CHARACTER(LEN=default_string_length), &
     144             :          DIMENSION(:, :), POINTER          :: sk_pair_list => NULL()
     145             :       CHARACTER(LEN=default_path_length)   :: uff_force_field = ""
     146             :       CHARACTER(LEN=default_path_length)   :: dispersion_parameter_file = ""
     147             :    END TYPE dftb_control_type
     148             : 
     149             : ! **************************************************************************************************
     150             : ! \brief Control parameters for xTB calculations
     151             : ! **************************************************************************************************
     152             :    TYPE xtb_control_type
     153             :       !
     154             :       INTEGER                              :: gfn_type = 1
     155             :       !
     156             :       LOGICAL                              :: do_ewald = .FALSE.
     157             :       LOGICAL                              :: do_tblite = .FALSE.
     158             :       !
     159             :       INTEGER                              :: sto_ng = 0
     160             :       INTEGER                              :: h_sto_ng = 0
     161             :       INTEGER                              :: tblite_method = 0
     162             :       !
     163             :       INTEGER                              :: vdw_type = -1
     164             :       CHARACTER(LEN=default_path_length)   :: parameter_file_path = ""
     165             :       CHARACTER(LEN=default_path_length)   :: parameter_file_name = ""
     166             :       !
     167             :       CHARACTER(LEN=default_path_length)   :: dispersion_parameter_file = ""
     168             :       REAL(KIND=dp)                        :: epscn = 0.0_dp
     169             :       REAL(KIND=dp)                        :: rcdisp = 0.0_dp
     170             :       REAL(KIND=dp)                        :: s6 = 0.0_dp, s8 = 0.0_dp
     171             :       REAL(KIND=dp)                        :: a1 = 0.0_dp, a2 = 0.0_dp
     172             :       !
     173             :       REAL(KIND=dp)                        :: ks = 0.0_dp, kp = 0.0_dp, kd = 0.0_dp, ksp = 0.0_dp, k2sh = 0.0_dp
     174             :       REAL(KIND=dp)                        :: kg = 0.0_dp, kf = 0.0_dp
     175             :       REAL(KIND=dp)                        :: kcns = 0.0_dp, kcnp = 0.0_dp, kcnd = 0.0_dp
     176             :       REAL(KIND=dp)                        :: ken = 0.0_dp
     177             :       REAL(KIND=dp)                        :: ksen = 0.0_dp, kpen = 0.0_dp, kden = 0.0_dp
     178             :       REAL(KIND=dp)                        :: ben = 0.0_dp
     179             :       REAL(KIND=dp)                        :: kxr = 0.0_dp, kx2 = 0.0_dp
     180             :       REAL(KIND=dp)                        :: enscale = 0.0_dp
     181             :       !
     182             :       LOGICAL                              :: xb_interaction = .FALSE.
     183             :       LOGICAL                              :: do_nonbonded = .FALSE.
     184             :       LOGICAL                              :: coulomb_interaction = .FALSE.
     185             :       LOGICAL                              :: coulomb_lr = .FALSE.
     186             :       LOGICAL                              :: tb3_interaction = .FALSE.
     187             :       LOGICAL                              :: check_atomic_charges = .FALSE.
     188             :       LOGICAL                              :: var_dipole = .FALSE.
     189             :       !
     190             :       REAL(KIND=dp)                        :: xb_radius = 0.0_dp
     191             :       REAL(KIND=dp)                        :: coulomb_sr_cut = 0.0_dp
     192             :       REAL(KIND=dp)                        :: coulomb_sr_eps = 0.0_dp
     193             :       !
     194             :       CHARACTER(LEN=default_string_length), &
     195             :          DIMENSION(:, :), POINTER          :: kab_param => NULL()
     196             :       INTEGER, DIMENSION(:, :), POINTER    :: kab_types => NULL()
     197             :       INTEGER                              :: kab_nval = 0
     198             :       REAL, DIMENSION(:), POINTER          :: kab_vals => NULL()
     199             :       !
     200             :       TYPE(pair_potential_p_type), POINTER :: nonbonded => NULL()
     201             :       REAL(KIND=dp)                        :: eps_pair = 0.0_dp
     202             :       REAL(KIND=dp), DIMENSION(:, :), &
     203             :          POINTER                           :: rcpair => NULL()
     204             :       !
     205             :       ! SRB terms
     206             :       REAL(KIND=dp)                        :: ksrb = 0.0_dp, esrb = 0.0_dp, gscal = 0.0_dp
     207             :       REAL(KIND=dp)                        :: c1srb = 0.0_dp, c2srb = 0.0_dp, shift = 0.0_dp
     208             :       !
     209             :       ! EN shift in EEQ (molecular=1 or crystaline=2)
     210             :       INTEGER                              :: enshift_type = 1
     211             :       TYPE(eeq_solver_type)                :: eeq_sparam ! parameters for EEQ solver
     212             :    END TYPE xtb_control_type
     213             : 
     214             : ! **************************************************************************************************
     215             : ! \brief Control parameters for semi empirical calculations
     216             : ! **************************************************************************************************
     217             :    TYPE semi_empirical_control_type
     218             :       LOGICAL                              :: orthogonal_basis = .FALSE.
     219             :       LOGICAL                              :: analytical_gradients = .FALSE.
     220             :       LOGICAL                              :: force_kdsod_EX = .FALSE.
     221             :       LOGICAL                              :: do_ewald = .FALSE., do_ewald_r3 = .FALSE., do_ewald_gks = .FALSE.
     222             :       INTEGER                              :: integral_screening = 0, periodic_type = 0
     223             :       INTEGER                              :: max_multipole = 0
     224             :       INTEGER                              :: ga_ncells = 0
     225             :       REAL(KIND=dp)                        :: delta = 0.0_dp
     226             :       ! Dispersion pair potential
     227             :       LOGICAL                              :: dispersion = .FALSE.
     228             :       REAL(KIND=dp)                        :: rcdisp = 0.0_dp
     229             :       REAL(KIND=dp)                        :: epscn = 0.0_dp
     230             :       REAL(KIND=dp), DIMENSION(3)          :: sd3 = 0.0_dp
     231             :       CHARACTER(LEN=default_path_length)   :: dispersion_parameter_file = ""
     232             :       ! Parameters controlling the evaluation of the integrals
     233             :       REAL(KIND=dp)                        :: cutoff_lrc = 0.0_dp, taper_lrc = 0.0_dp, range_lrc = 0.0_dp
     234             :       REAL(KIND=dp)                        :: cutoff_cou = 0.0_dp, taper_cou = 0.0_dp, range_cou = 0.0_dp
     235             :       REAL(KIND=dp)                        :: cutoff_exc = 0.0_dp, taper_exc = 0.0_dp, range_exc = 0.0_dp
     236             :       REAL(KIND=dp)                        :: taper_scr = 0.0_dp, range_scr = 0.0_dp
     237             :    END TYPE semi_empirical_control_type
     238             : 
     239             : ! **************************************************************************************************
     240             : ! \brief Control parameters for GAPW method within QUICKSTEP ***
     241             : ! **************************************************************************************************
     242             :    TYPE gapw_control_type
     243             :       INTEGER                              :: basis_1c = 0
     244             :       REAL(KIND=dp)                        :: eps_fit = 0.0_dp, &
     245             :                                               eps_iso = 0.0_dp, &
     246             :                                               eps_Vrho0 = 0.0_dp, &
     247             :                                               eps_svd = 0.0_dp, &
     248             :                                               eps_cpc = 0.0_dp
     249             :       INTEGER                              :: ladd_rho0 = 0, &
     250             :                                               lmax_rho0 = 0, &
     251             :                                               lmax_sphere = 0, &
     252             :                                               quadrature = 0
     253             :       LOGICAL                              :: lrho1_eq_lrho0 = .FALSE.
     254             :       LOGICAL                              :: alpha0_hard_from_input = .FALSE., &
     255             :                                               force_paw = .FALSE., &
     256             :                                               non_paw_atoms = .FALSE., &
     257             :                                               nopaw_as_gpw = .FALSE.
     258             :       REAL(KIND=dp)                        :: alpha0_hard = 0.0_dp
     259             :       REAL(KIND=dp)                        :: max_rad_local = 0.0_dp
     260             :    END TYPE gapw_control_type
     261             : 
     262             : ! **************************************************************************************************
     263             : ! \brief parameters for calculations involving a time dependent electric field
     264             : ! **************************************************************************************************
     265             :    TYPE efield_type
     266             :       REAL(KIND=dp)                        :: actual_time = 0.0_dp
     267             :       REAL(KIND=dp), DIMENSION(:), POINTER :: polarisation => NULL()
     268             :       INTEGER                              :: envelop_id = 0
     269             :       REAL(KIND=dp), DIMENSION(:), POINTER :: envelop_r_vars => NULL()
     270             :       INTEGER, DIMENSION(:), POINTER       :: envelop_i_vars => NULL()
     271             :       REAL(KIND=dp)                        :: strength = 0.0_dp
     272             :       REAL(KIND=dp)                        :: phase_offset = 0.0_dp
     273             :       REAL(KIND=dp)                        :: wavelength = 0.0_dp
     274             :       REAL(KIND=dp), DIMENSION(3)          :: vec_pot_initial = 0.0_dp
     275             :    END TYPE efield_type
     276             : 
     277             :    TYPE efield_p_type
     278             :       TYPE(efield_type), POINTER           :: efield => NULL()
     279             :    END TYPE efield_p_type
     280             : 
     281             : ! **************************************************************************************************
     282             : ! \brief parameters for calculations involving a time dependent electric field
     283             : ! **************************************************************************************************
     284             :    TYPE period_efield_type
     285             :       LOGICAL                              :: displacement_field = .FALSE.
     286             :       REAL(KIND=dp), DIMENSION(3)          :: polarisation = 0.0_dp
     287             :       REAL(KIND=dp), DIMENSION(3)          :: d_filter = 0.0_dp
     288             :       REAL(KIND=dp)                        :: strength = 0.0_dp
     289             :       REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: strength_list
     290             :       INTEGER                              :: start_frame = 0
     291             :       INTEGER                              :: end_frame = -1
     292             :    END TYPE period_efield_type
     293             : 
     294             : ! **************************************************************************************************
     295             : ! \brief some parameters useful for mulliken_restraints
     296             : ! **************************************************************************************************
     297             :    TYPE mulliken_restraint_type
     298             :       REAL(KIND=dp)                        :: strength = 0.0_dp
     299             :       REAL(KIND=dp)                        :: TARGET = 0.0_dp
     300             :       INTEGER                              :: natoms = 0
     301             :       INTEGER, POINTER, DIMENSION(:)       :: atoms => NULL()
     302             :    END TYPE mulliken_restraint_type
     303             : 
     304             : ! **************************************************************************************************
     305             : ! \brief some parameters useful for ddapc_restraints
     306             : ! **************************************************************************************************
     307             :    TYPE ddapc_restraint_type
     308             :       INTEGER                              :: ref_count = 0
     309             :       REAL(KIND=dp)                        :: strength = 0.0_dp
     310             :       REAL(KIND=dp)                        :: TARGET = 0.0_dp
     311             :       REAL(KIND=dp)                        :: ddapc_order_p = 0.0_dp
     312             :       INTEGER                              :: functional_form = 0
     313             :       INTEGER                              :: natoms = 0
     314             :       INTEGER, POINTER, DIMENSION(:)       :: atoms => NULL()
     315             :       REAL(KIND=dp), POINTER, DIMENSION(:) :: coeff => NULL()
     316             :       INTEGER                              :: density_type = 0
     317             :    END TYPE ddapc_restraint_type
     318             : 
     319             : ! **************************************************************************************************
     320             : ! \brief some parameters useful for s2_restraints
     321             : ! **************************************************************************************************
     322             :    TYPE s2_restraint_type
     323             :       REAL(KIND=dp)                        :: strength = 0.0_dp
     324             :       REAL(KIND=dp)                        :: TARGET = 0.0_dp
     325             :       REAL(KIND=dp)                        :: s2_order_p = 0.0_dp
     326             :       INTEGER                              :: functional_form = 0
     327             :    END TYPE s2_restraint_type
     328             : 
     329             : ! **************************************************************************************************
     330             : ! \brief some parameters useful for auxiliary density matrix method
     331             : ! **************************************************************************************************
     332             :    TYPE admm_block_type
     333             :       INTEGER, DIMENSION(:), ALLOCATABLE   :: list
     334             :    END TYPE admm_block_type
     335             : 
     336             :    TYPE admm_control_type
     337             :       REAL(KIND=dp)                        :: eps_filter = 0.0_dp
     338             :       INTEGER                              :: admm_type = 0
     339             :       INTEGER                              :: purification_method = 0
     340             :       INTEGER                              :: method = 0
     341             :       LOGICAL                              :: charge_constrain = .FALSE.
     342             :       INTEGER                              :: scaling_model = 0
     343             :       INTEGER                              :: aux_exch_func = 0
     344             :       LOGICAL                              :: aux_exch_func_param = .FALSE.
     345             :       REAL(KIND=dp), DIMENSION(3)          :: aux_x_param = 0.0_dp
     346             :       TYPE(admm_block_type), DIMENSION(:), &
     347             :          ALLOCATABLE                       :: blocks
     348             :    END TYPE admm_control_type
     349             : 
     350             : ! **************************************************************************************************
     351             : ! \brief Parameters for external potential
     352             : ! **************************************************************************************************
     353             :    TYPE expot_control_type
     354             :       LOGICAL                              :: read_from_cube = .FALSE.
     355             :       LOGICAL                              :: maxwell_solver = .FALSE.
     356             :       LOGICAL                              :: static = .FALSE.
     357             :       REAL(KIND=dp)                        :: scaling_factor = 0.0_dp
     358             :    END TYPE expot_control_type
     359             : 
     360             : ! **************************************************************************************************
     361             : ! \brief Parameters useful for Maxwell equation evaluation of external potential
     362             : ! **************************************************************************************************
     363             :    TYPE maxwell_control_type
     364             :       LOGICAL                              :: log_test = .FALSE.
     365             :       INTEGER                              :: int_test = 0
     366             :       REAL(KIND=dp)                        :: real_test = 0.0_dp
     367             :    END TYPE maxwell_control_type
     368             : 
     369             : ! **************************************************************************************************
     370             : ! \brief Control parameters for a QUICKSTEP and KIM-GORDON calculation ***
     371             : !        eps_pgf_orb: Cutoff value for the interaction of the primitive
     372             : !                     Gaussian-type functions (primitive basis functions).
     373             : ! **************************************************************************************************
     374             :    TYPE qs_control_type
     375             :       INTEGER                              :: method_id = 0
     376             :       REAL(KIND=dp)                        :: eps_core_charge = 0.0_dp, &
     377             :                                               eps_kg_orb = 0.0_dp, &
     378             :                                               eps_pgf_orb = 0.0_dp, &
     379             :                                               eps_ppl = 0.0_dp, &
     380             :                                               eps_ppnl = 0.0_dp, &
     381             :                                               eps_rho_gspace = 0.0_dp, &
     382             :                                               eps_rho_rspace = 0.0_dp, &
     383             :                                               eps_filter_matrix = 0.0_dp, &
     384             :                                               eps_gvg_rspace = 0.0_dp, &
     385             :                                               progression_factor = 0.0_dp, &
     386             :                                               relative_cutoff = 0.0_dp
     387             :       LOGICAL                              :: do_almo_scf = .FALSE.
     388             :       LOGICAL                              :: do_ls_scf = .FALSE.
     389             :       LOGICAL                              :: do_kg = .FALSE.
     390             :       LOGICAL                              :: commensurate_mgrids = .FALSE.
     391             :       LOGICAL                              :: realspace_mgrids = .FALSE.
     392             :       LOGICAL                              :: gapw = .FALSE., gapw_xc = .FALSE., gpw = .FALSE., pao = .FALSE.
     393             :       LOGICAL                              :: lrigpw = .FALSE., rigpw = .FALSE.
     394             :       LOGICAL                              :: lri_optbas = .FALSE.
     395             :       LOGICAL                              :: ofgpw = .FALSE.
     396             :       LOGICAL                              :: dftb = .FALSE.
     397             :       LOGICAL                              :: xtb = .FALSE.
     398             :       LOGICAL                              :: semi_empirical = .FALSE.
     399             :       LOGICAL                              :: mulliken_restraint = .FALSE.
     400             :       LOGICAL                              :: ddapc_restraint = .FALSE.
     401             :       LOGICAL                              :: ddapc_restraint_is_spin = .FALSE.
     402             :       LOGICAL                              :: ddapc_explicit_potential = .FALSE.
     403             :       LOGICAL                              :: cdft = .FALSE.
     404             :       LOGICAL                              :: et_coupling_calc = .FALSE.
     405             :       LOGICAL                              :: s2_restraint = .FALSE.
     406             :       INTEGER                              :: do_ppl_method = 0
     407             :       INTEGER                              :: wf_interpolation_method_nr = 0
     408             :       INTEGER                              :: wf_extrapolation_order = 0
     409             :       INTEGER                              :: periodicity = 0
     410             :       REAL(KIND=dp)                        :: pairlist_radius = 0.0_dp
     411             :       REAL(KIND=dp)                        :: cutoff = 0.0_dp
     412             :       REAL(KIND=dp), DIMENSION(:), POINTER :: e_cutoff => NULL()
     413             :       TYPE(mulliken_restraint_type), &
     414             :          POINTER                           :: mulliken_restraint_control => NULL()
     415             :       TYPE(ddapc_restraint_type), &
     416             :          DIMENSION(:), POINTER             :: ddapc_restraint_control => NULL()
     417             :       TYPE(cdft_control_type), POINTER     :: cdft_control => NULL()
     418             :       TYPE(s2_restraint_type), POINTER     :: s2_restraint_control => NULL()
     419             :       TYPE(dftb_control_type), POINTER     :: dftb_control => NULL()
     420             :       TYPE(xtb_control_type), POINTER      :: xtb_control => NULL()
     421             :       TYPE(semi_empirical_control_type), &
     422             :          POINTER                           :: se_control => NULL()
     423             :       TYPE(gapw_control_type), POINTER     :: gapw_control => NULL()
     424             :       TYPE(pw_grid_option)                 :: pw_grid_opt = pw_grid_option()
     425             :       LOGICAL                              :: skip_load_balance_distributed = .FALSE.
     426             :       ! Types of subsystems for embedding
     427             :       LOGICAL                              :: ref_embed_subsys = .FALSE.
     428             :       LOGICAL                              :: cluster_embed_subsys = .FALSE.
     429             :       LOGICAL                              :: high_level_embed_subsys = .FALSE.
     430             :       LOGICAL                              :: dfet_embedded = .FALSE.
     431             :       LOGICAL                              :: dmfet_embedded = .FALSE.
     432             :    END TYPE qs_control_type
     433             : 
     434             : ! **************************************************************************************************
     435             : ! \brief Control parameters for the SCCS models
     436             : ! **************************************************************************************************
     437             :    TYPE sccs_control_type
     438             :       LOGICAL                              :: sccs_activated = .FALSE.
     439             :       INTEGER                              :: derivative_method = 0, &
     440             :                                               max_iter = 0, &
     441             :                                               method_id = 0
     442             :       REAL(KIND=dp)                        :: alpha_solvent = 0.0_dp, &
     443             :                                               beta = 0.0_dp, &
     444             :                                               beta_solvent = 0.0_dp, &
     445             :                                               delta_rho = 0.0_dp, &
     446             :                                               eps_sccs = 0.0_dp, &
     447             :                                               eps_scf = 0.0_dp, &
     448             :                                               epsilon_solvent = 0.0_dp, &
     449             :                                               gamma_solvent = 0.0_dp, &
     450             :                                               mixing = 0.0_dp, &
     451             :                                               rho_zero = 0.0_dp, &
     452             :                                               rho_max = 0.0_dp, &
     453             :                                               rho_min = 0.0_dp
     454             :    END TYPE sccs_control_type
     455             : 
     456             : ! **************************************************************************************************
     457             : ! \brief Control parameters for simplified Tamm Dancoff approximation (sTDA)
     458             : ! \par  ATTRIBUTES
     459             : ! \par  NOTES
     460             : ! **************************************************************************************************
     461             :    TYPE stda_control_type
     462             :       LOGICAL                                :: do_ewald = .FALSE.
     463             :       LOGICAL                                :: do_exchange = .FALSE.
     464             :       REAL(KIND=dp)                          :: hfx_fraction = 0.0_dp
     465             :       REAL(KIND=dp)                          :: eps_td_filter = 0.0_dp
     466             :       REAL(KIND=dp)                          :: mn_alpha = 0.0_dp
     467             :       REAL(KIND=dp)                          :: mn_beta = 0.0_dp
     468             :       REAL(KIND=dp)                          :: coulomb_sr_cut = 0.0_dp
     469             :       REAL(KIND=dp)                          :: coulomb_sr_eps = 0.0_dp
     470             :    END TYPE stda_control_type
     471             : 
     472             : ! **************************************************************************************************
     473             : ! \brief Control parameters for smeared occupation
     474             : ! \par  ATTRIBUTES
     475             : ! \par  NOTES
     476             : ! **************************************************************************************************
     477             :    TYPE smeared_type
     478             :       REAL(KIND=dp), DIMENSION(:), POINTER :: fermia => NULL()
     479             :       REAL(KIND=dp), DIMENSION(:, :), POINTER :: fermib => NULL()
     480             :    END TYPE smeared_type
     481             : 
     482             : ! **************************************************************************************************
     483             : ! \brief Control parameters for a Time-Dependent DFT calculation.
     484             : ! **************************************************************************************************
     485             :    TYPE tddfpt2_control_type
     486             :       !> compute TDDFPT excitation energies and oscillator strengths
     487             :       LOGICAL                              :: enabled = .FALSE.
     488             :       !> number of excited states to converge
     489             :       INTEGER                              :: nstates = 0
     490             :       !> maximal number of iterations to be performed
     491             :       INTEGER                              :: niters = 0
     492             :       !> maximal number of Krylov space vectors
     493             :       INTEGER                              :: nkvs = 0
     494             :       !> number of unoccupied (virtual) molecular orbitals to consider
     495             :       INTEGER                              :: nlumo = 0
     496             :       !> minimal number of MPI processes to be used per excited state
     497             :       INTEGER                              :: nprocs = 0
     498             :       !> type of kernel function/approximation to use
     499             :       INTEGER                              :: kernel = 0
     500             :       !> for full kernel, do we have HFX/ADMM
     501             :       LOGICAL                              :: do_hfx = .FALSE.
     502             :       LOGICAL                              :: do_admm = .FALSE.
     503             :       !> for full kernel, do we have short-range/long-range HFX and/or Kxc potential
     504             :       LOGICAL                              :: do_hfxsr = .FALSE.
     505             :       LOGICAL                              :: hfxsr_re_int = .TRUE.
     506             :       INTEGER                              :: hfxsr_primbas = 0
     507             :       LOGICAL                              :: do_hfxlr = .FALSE.
     508             :       REAL(KIND=dp)                        :: hfxlr_rcut = 0.0_dp, hfxlr_scale = 0.0_dp
     509             :       LOGICAL                              :: do_exck = .FALSE.
     510             :       !> options used in sTDA calculation (Kernel)
     511             :       TYPE(stda_control_type)              :: stda_control = stda_control_type()
     512             :       !> algorithm to correct orbital energies
     513             :       INTEGER                              :: oe_corr = 0
     514             :       !> eigenvalue shifts
     515             :       REAL(KIND=dp)                        :: ev_shift = 0.0_dp, eos_shift = 0.0_dp
     516             :       !> target accuracy
     517             :       REAL(kind=dp)                        :: conv = 0.0_dp
     518             :       !> the smallest excitation amplitude to print
     519             :       REAL(kind=dp)                        :: min_excitation_amplitude = 0.0_dp
     520             :       !> threshold which controls when two wave functions considered to be orthogonal:
     521             :       !> maxabs(Ci^T * S * Cj) <= orthogonal_eps
     522             :       REAL(kind=dp)                        :: orthogonal_eps = 0.0_dp
     523             :       !> read guess wave functions from restart file if exists
     524             :       LOGICAL                              :: is_restart = .FALSE.
     525             :       !> compute triplet excited states using spin-unpolarised molecular orbitals
     526             :       LOGICAL                              :: rks_triplets = .FALSE.
     527             :       !> local resolution of identity for Coulomb contribution
     528             :       LOGICAL                              :: do_lrigpw = .FALSE.
     529             :       !> smeared occupation
     530             :       LOGICAL                              :: do_smearing = .FALSE.
     531             :       ! automatic generation of auxiliary basis for LRI-TDDFT
     532             :       INTEGER                              :: auto_basis_p_lri_aux = 1
     533             :       !> use symmetric definition of ADMM Kernel correction
     534             :       LOGICAL                              :: admm_symm = .FALSE.
     535             :       !> Use/Ignore possible ADMM Kernel XC correction
     536             :       LOGICAL                              :: admm_xc_correction = .FALSE.
     537             :       ! Compute exciton descriptors
     538             :       LOGICAL                              :: do_exciton_descriptors = .FALSE.
     539             :       LOGICAL                              :: do_directional_exciton_descriptors = .FALSE.
     540             :       !
     541             :       ! DIPOLE_MOMENTS subsection
     542             :       !
     543             :       ! form of the dipole operator used to compute oscillator strengths
     544             :       INTEGER                              :: dipole_form = 0
     545             :       !> type of the reference point used for calculation of electrostatic dipole moments
     546             :       INTEGER                              :: dipole_reference = 0
     547             :       !> user-defined reference point
     548             :       REAL(kind=dp), DIMENSION(:), POINTER :: dipole_ref_point => NULL()
     549             :       !
     550             :       ! SOC subsection
     551             :       LOGICAL                              :: do_soc = .FALSE.
     552             :       !
     553             :       ! MGRID subsection
     554             :       !
     555             :       !> number of plain-wave grids
     556             :       INTEGER                              :: mgrid_ngrids = 0
     557             :       !> create commensurate grids (progression factor and cutoff values of sub-grids will be ignored)
     558             :       LOGICAL                              :: mgrid_commensurate_mgrids = .FALSE.
     559             :       !> signals that MGRID section has been explicitly given. Other mgrid_* variables
     560             :       !> are not initialised when it is equal to .FALSE. as in this case the default
     561             :       !> set of plain-wave grids will be used
     562             :       LOGICAL                              :: mgrid_is_explicit = .FALSE.
     563             :       !> same as qs_control%realspace_mgrids
     564             :       LOGICAL                              :: mgrid_realspace_mgrids = .FALSE.
     565             :       !> do not perform load balancing
     566             :       LOGICAL                              :: mgrid_skip_load_balance = .FALSE.
     567             :       !> cutoff value at the finest grid level
     568             :       REAL(kind=dp)                        :: mgrid_cutoff = 0.0_dp
     569             :       !> cutoff at the next grid level will be smaller then the cutoff
     570             :       !> at the current grid by this number of times
     571             :       REAL(kind=dp)                        :: mgrid_progression_factor = 0.0_dp
     572             :       !> cutoff that determines to which grid a particular Gaussian function will be mapped
     573             :       REAL(kind=dp)                        :: mgrid_relative_cutoff = 0.0_dp
     574             :       !> manually provided the list of cutoff values for each grid level
     575             :       !> (when it is null(), the cutoff values will be assigned automatically)
     576             :       REAL(kind=dp), DIMENSION(:), POINTER :: mgrid_e_cutoff => NULL()
     577             :       !> Parameter for smeared occupation TDA
     578             :       TYPE(smeared_type), DIMENSION(:), POINTER :: smeared_occup => NULL()
     579             :    END TYPE tddfpt2_control_type
     580             : 
     581             : ! **************************************************************************************************
     582             : ! \brief Control parameters for a DFT calculation
     583             : ! \par History
     584             : !      10.2019 added variables related to surface dipole correction [Soumya Ghosh]
     585             : ! **************************************************************************************************
     586             :    TYPE dft_control_type
     587             :       TYPE(admm_control_type), POINTER     :: admm_control => NULL()
     588             :       TYPE(period_efield_type), POINTER    :: period_efield => NULL()
     589             :       TYPE(qs_control_type), POINTER       :: qs_control => NULL()
     590             :       TYPE(rtp_control_type), POINTER      :: rtp_control => NULL()
     591             :       TYPE(sccs_control_type), POINTER     :: sccs_control => NULL()
     592             :       TYPE(tddfpt2_control_type), POINTER  :: tddfpt2_control => NULL()
     593             :       TYPE(xas_control_type), POINTER      :: xas_control => NULL()
     594             :       TYPE(expot_control_type), POINTER    :: expot_control => NULL()
     595             :       TYPE(maxwell_control_type), POINTER  :: maxwell_control => NULL()
     596             :       TYPE(smeagol_control_type), POINTER  :: smeagol_control => NULL()
     597             :       TYPE(efield_p_type), POINTER, &
     598             :          DIMENSION(:)                      :: efield_fields => NULL()
     599             :       TYPE(hairy_probes_type), POINTER, &
     600             :          DIMENSION(:)                      :: probe => NULL()
     601             :       INTEGER                              :: nspins = 0, &
     602             :                                               charge = 0, &
     603             :                                               multiplicity = 0, &
     604             :                                               sic_method_id = 0, &
     605             :                                               plus_u_method_id = 0, &
     606             :                                               dir_surf_dip = 0, &
     607             :                                               nimages = 1
     608             :       INTEGER                              :: sic_list_id = 0
     609             :       INTEGER                              :: auto_basis_ri_aux = 1, &
     610             :                                               auto_basis_aux_fit = 1, &
     611             :                                               auto_basis_lri_aux = 1, &
     612             :                                               auto_basis_p_lri_aux = 1, &
     613             :                                               auto_basis_ri_hxc = 1, &
     614             :                                               auto_basis_ri_xas = 1, &
     615             :                                               auto_basis_ri_hfx = 1
     616             :       REAL(KIND=dp)                        :: relax_multiplicity = 0.0_dp, &
     617             :                                               sic_scaling_a = 0.0_dp, &
     618             :                                               sic_scaling_b = 0.0_dp, &
     619             :                                               pos_dir_surf_dip = 0.0_dp
     620             :       LOGICAL                              :: do_xas_calculation = .FALSE., &
     621             :                                               do_xas_tdp_calculation = .FALSE., &
     622             :                                               drho_by_collocation = .FALSE., &
     623             :                                               use_kinetic_energy_density = .FALSE., &
     624             :                                               restricted = .FALSE., &
     625             :                                               roks = .FALSE., &
     626             :                                               uks = .FALSE., &
     627             :                                               lsd = .FALSE., &
     628             :                                               dft_plus_u = .FALSE., &
     629             :                                               apply_efield = .FALSE., &
     630             :                                               apply_efield_field = .FALSE., &
     631             :                                               apply_vector_potential = .FALSE., &
     632             :                                               apply_period_efield = .FALSE., &
     633             :                                               apply_external_potential = .FALSE., &
     634             :                                               eval_external_potential = .FALSE., &
     635             :                                               do_admm = .FALSE., &
     636             :                                               do_admm_dm = .FALSE., &
     637             :                                               do_admm_mo = .FALSE., &
     638             :                                               smear = .FALSE., &
     639             :                                               low_spin_roks = .FALSE., &
     640             :                                               apply_external_density = .FALSE., &
     641             :                                               read_external_density = .FALSE., &
     642             :                                               apply_external_vxc = .FALSE., &
     643             :                                               read_external_vxc = .FALSE., &
     644             :                                               correct_surf_dip = .FALSE., &
     645             :                                               surf_dip_correct_switch = .FALSE., &
     646             :                                               switch_surf_dip = .FALSE., &
     647             :                                               correct_el_density_dip = .FALSE., &
     648             :                                               do_sccs = .FALSE., &
     649             :                                               apply_embed_pot = .FALSE., &
     650             :                                               apply_dmfet_pot = .FALSE., &
     651             :                                               hairy_probes = .FALSE.
     652             :    END TYPE dft_control_type
     653             : 
     654             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_control_types'
     655             : 
     656             :    ! Public data types
     657             : 
     658             :    PUBLIC :: dft_control_type, &
     659             :              qs_control_type, &
     660             :              gapw_control_type, &
     661             :              tddfpt2_control_type, &
     662             :              proj_mo_type, &
     663             :              efield_type, &
     664             :              mulliken_restraint_type, &
     665             :              ddapc_restraint_type, &
     666             :              dftb_control_type, &
     667             :              xtb_control_type, &
     668             :              semi_empirical_control_type, &
     669             :              s2_restraint_type, &
     670             :              admm_control_type, &
     671             :              maxwell_control_type, &
     672             :              expot_control_type, &
     673             :              rtp_control_type, &
     674             :              sccs_control_type, &
     675             :              stda_control_type, &
     676             :              smeared_type, &
     677             :              hairy_probes_type
     678             : 
     679             :    ! Public subroutines
     680             : 
     681             :    PUBLIC :: dft_control_release, &
     682             :              dft_control_create, &
     683             :              admm_control_create, &
     684             :              admm_control_release, &
     685             :              maxwell_control_create, &
     686             :              expot_control_create, &
     687             :              ddapc_control_create
     688             : 
     689             : CONTAINS
     690             : 
     691             : ! **************************************************************************************************
     692             : !> \brief create  the mulliken_restraint_type
     693             : !> \param mulliken_restraint_control ...
     694             : !> \par History
     695             : !>      02.2005 created [Joost VandeVondele]
     696             : ! **************************************************************************************************
     697        7354 :    SUBROUTINE mulliken_control_create(mulliken_restraint_control)
     698             :       TYPE(mulliken_restraint_type), INTENT(OUT)         :: mulliken_restraint_control
     699             : 
     700        7354 :       mulliken_restraint_control%strength = 0.1_dp
     701        7354 :       mulliken_restraint_control%target = 1.0_dp
     702             :       mulliken_restraint_control%natoms = 0
     703             :       NULLIFY (mulliken_restraint_control%atoms)
     704        7354 :    END SUBROUTINE mulliken_control_create
     705             : 
     706             : ! **************************************************************************************************
     707             : !> \brief release the mulliken_restraint_type
     708             : !> \param mulliken_restraint_control ...
     709             : !> \par History
     710             : !>      02.2005 created [Joost VandeVondele]
     711             : ! **************************************************************************************************
     712        7354 :    SUBROUTINE mulliken_control_release(mulliken_restraint_control)
     713             :       TYPE(mulliken_restraint_type), INTENT(INOUT)       :: mulliken_restraint_control
     714             : 
     715        7354 :       IF (ASSOCIATED(mulliken_restraint_control%atoms)) &
     716           2 :          DEALLOCATE (mulliken_restraint_control%atoms)
     717        7354 :       mulliken_restraint_control%strength = 0.0_dp
     718        7354 :       mulliken_restraint_control%target = 0.0_dp
     719        7354 :       mulliken_restraint_control%natoms = 0
     720        7354 :    END SUBROUTINE mulliken_control_release
     721             : 
     722             : ! **************************************************************************************************
     723             : !> \brief create the ddapc_restraint_type
     724             : !> \param ddapc_restraint_control ...
     725             : !> \par History
     726             : !>      02.2006 created [Joost VandeVondele]
     727             : ! **************************************************************************************************
     728          18 :    SUBROUTINE ddapc_control_create(ddapc_restraint_control)
     729             :       TYPE(ddapc_restraint_type), INTENT(OUT)            :: ddapc_restraint_control
     730             : 
     731             :       ddapc_restraint_control%density_type = do_full_density
     732          18 :       ddapc_restraint_control%strength = 0.1_dp
     733             :       ddapc_restraint_control%ddapc_order_p = 0.0_dp
     734          18 :       ddapc_restraint_control%functional_form = -1
     735          18 :       ddapc_restraint_control%target = 1.0_dp
     736             :       ddapc_restraint_control%natoms = 0
     737             :       NULLIFY (ddapc_restraint_control%atoms)
     738             :       NULLIFY (ddapc_restraint_control%coeff)
     739             : 
     740          18 :    END SUBROUTINE ddapc_control_create
     741             : 
     742             : ! **************************************************************************************************
     743             : !> \brief release the ddapc_restraint_type
     744             : !> \param ddapc_restraint_control ...
     745             : !> \par History
     746             : !>      02.2006 created [Joost VandeVondele]
     747             : ! **************************************************************************************************
     748          18 :    SUBROUTINE ddapc_control_release(ddapc_restraint_control)
     749             :       TYPE(ddapc_restraint_type), INTENT(INOUT)          :: ddapc_restraint_control
     750             : 
     751          18 :       IF (ASSOCIATED(ddapc_restraint_control%atoms)) &
     752          18 :          DEALLOCATE (ddapc_restraint_control%atoms)
     753          18 :       IF (ASSOCIATED(ddapc_restraint_control%coeff)) &
     754          18 :          DEALLOCATE (ddapc_restraint_control%coeff)
     755          18 :       ddapc_restraint_control%strength = 0.0_dp
     756          18 :       ddapc_restraint_control%target = 0.0_dp
     757          18 :       ddapc_restraint_control%natoms = 0
     758          18 :    END SUBROUTINE ddapc_control_release
     759             : 
     760             : ! **************************************************************************************************
     761             : !> \brief create the s2_restraint_type
     762             : !> \param s2_restraint_control ...
     763             : !> \par History
     764             : !>      03.2006 created [Joost VandeVondele]
     765             : ! **************************************************************************************************
     766        7354 :    SUBROUTINE s2_control_create(s2_restraint_control)
     767             :       TYPE(s2_restraint_type), INTENT(OUT)               :: s2_restraint_control
     768             : 
     769        7354 :       s2_restraint_control%strength = 0.1_dp
     770             :       s2_restraint_control%s2_order_p = 0.0_dp
     771        7354 :       s2_restraint_control%functional_form = -1
     772        7354 :       s2_restraint_control%target = 1.0_dp
     773        7354 :    END SUBROUTINE s2_control_create
     774             : 
     775             : ! **************************************************************************************************
     776             : !> \brief release the s2_restraint_type
     777             : !> \param s2_restraint_control ...
     778             : !> \par History
     779             : !>      03.2006 created [Joost VandeVondele]
     780             : ! **************************************************************************************************
     781        7354 :    SUBROUTINE s2_control_release(s2_restraint_control)
     782             :       TYPE(s2_restraint_type), INTENT(INOUT)             :: s2_restraint_control
     783             : 
     784        7354 :       s2_restraint_control%strength = 0.0_dp
     785        7354 :       s2_restraint_control%target = 0.0_dp
     786        7354 :    END SUBROUTINE s2_control_release
     787             : 
     788             : ! **************************************************************************************************
     789             : !> \brief allocates and perform a very basic initialization
     790             : !> \param dft_control the object to create
     791             : !> \par History
     792             : !>      02.2003 created [fawzi]
     793             : !> \author fawzi
     794             : ! **************************************************************************************************
     795        7354 :    SUBROUTINE dft_control_create(dft_control)
     796             :       TYPE(dft_control_type), INTENT(OUT)                :: dft_control
     797             : 
     798             :       NULLIFY (dft_control%xas_control)
     799             :       NULLIFY (dft_control%qs_control)
     800             :       NULLIFY (dft_control%tddfpt2_control)
     801             :       NULLIFY (dft_control%efield_fields)
     802             :       NULLIFY (dft_control%period_efield)
     803             :       NULLIFY (dft_control%admm_control)
     804             :       NULLIFY (dft_control%expot_control)
     805             :       NULLIFY (dft_control%maxwell_control)
     806             :       NULLIFY (dft_control%smeagol_control)
     807             :       NULLIFY (dft_control%rtp_control)
     808             :       NULLIFY (dft_control%sccs_control)
     809             :       NULLIFY (dft_control%probe)
     810             :       dft_control%do_sccs = .FALSE.
     811             :       dft_control%apply_embed_pot = .FALSE.
     812             :       dft_control%apply_dmfet_pot = .FALSE.
     813             :       dft_control%hairy_probes = .FALSE.
     814        7354 :       CALL qs_control_create(dft_control%qs_control)
     815        7354 :       CALL tddfpt2_control_create(dft_control%tddfpt2_control)
     816        7354 :       CALL smeagol_control_create(dft_control%smeagol_control)
     817        7354 :    END SUBROUTINE dft_control_create
     818             : 
     819             : ! **************************************************************************************************
     820             : !> \brief ...
     821             : !> \param dft_control ...
     822             : !> \par History
     823             : !>      02.2003 created [fawzi]
     824             : !> \author fawzi
     825             : ! **************************************************************************************************
     826        7354 :    SUBROUTINE dft_control_release(dft_control)
     827             :       TYPE(dft_control_type), INTENT(INOUT)              :: dft_control
     828             : 
     829             :       INTEGER                                            :: i
     830             : 
     831        7354 :       CALL qs_control_release(dft_control%qs_control)
     832        7354 :       CALL tddfpt2_control_release(dft_control%tddfpt2_control)
     833        7354 :       IF (ASSOCIATED(dft_control%xas_control)) THEN
     834          42 :          CALL xas_control_release(dft_control%xas_control)
     835          42 :          DEALLOCATE (dft_control%xas_control)
     836             :       END IF
     837        7354 :       CALL admm_control_release(dft_control%admm_control)
     838        7354 :       CALL expot_control_release(dft_control%expot_control)
     839        7354 :       CALL maxwell_control_release(dft_control%maxwell_control)
     840        7354 :       CALL smeagol_control_release(dft_control%smeagol_control)
     841        7354 :       CALL efield_fields_release(dft_control%efield_fields)
     842        7354 :       IF (ASSOCIATED(dft_control%probe)) THEN
     843          12 :          DO i = 1, SIZE(dft_control%probe)
     844          12 :             DEALLOCATE (dft_control%probe(i)%atom_ids)
     845             :          END DO
     846           4 :          DEALLOCATE (dft_control%probe)
     847             :       END IF
     848        7354 :       IF (ASSOCIATED(dft_control%sccs_control)) DEALLOCATE (dft_control%sccs_control)
     849        7354 :       IF (ASSOCIATED(dft_control%period_efield)) THEN
     850          76 :          DEALLOCATE (dft_control%period_efield)
     851             :       END IF
     852        7354 :       IF (ASSOCIATED(dft_control%rtp_control)) THEN
     853         248 :          CALL proj_mo_list_release(dft_control%rtp_control%proj_mo_list)
     854         248 :          DEALLOCATE (dft_control%rtp_control)
     855             :       END IF
     856             : 
     857        7354 :    END SUBROUTINE dft_control_release
     858             : 
     859             : ! **************************************************************************************************
     860             : !> \brief ...
     861             : !> \param qs_control ...
     862             : ! **************************************************************************************************
     863        7354 :    SUBROUTINE qs_control_create(qs_control)
     864             :       TYPE(qs_control_type), POINTER                     :: qs_control
     865             : 
     866        7354 :       CPASSERT(.NOT. ASSOCIATED(qs_control))
     867       29416 :       ALLOCATE (qs_control)
     868             : 
     869             :       NULLIFY (qs_control%e_cutoff)
     870             :       NULLIFY (qs_control%gapw_control)
     871             :       NULLIFY (qs_control%mulliken_restraint_control)
     872             :       NULLIFY (qs_control%ddapc_restraint_control)
     873             :       NULLIFY (qs_control%s2_restraint_control)
     874             :       NULLIFY (qs_control%se_control)
     875             :       NULLIFY (qs_control%dftb_control)
     876             :       NULLIFY (qs_control%xtb_control)
     877             :       NULLIFY (qs_control%cdft_control)
     878             :       NULLIFY (qs_control%ddapc_restraint_control)
     879             : 
     880        7354 :       ALLOCATE (qs_control%mulliken_restraint_control)
     881        7354 :       CALL mulliken_control_create(qs_control%mulliken_restraint_control)
     882        7354 :       ALLOCATE (qs_control%s2_restraint_control)
     883        7354 :       CALL s2_control_create(qs_control%s2_restraint_control)
     884        7354 :       ALLOCATE (qs_control%gapw_control)
     885        7354 :       CALL se_control_create(qs_control%se_control)
     886        7354 :       CALL dftb_control_create(qs_control%dftb_control)
     887        7354 :       CALL xtb_control_create(qs_control%xtb_control)
     888       22062 :       ALLOCATE (qs_control%cdft_control)
     889        7354 :       CALL cdft_control_create(qs_control%cdft_control)
     890        7354 :    END SUBROUTINE qs_control_create
     891             : 
     892             : ! **************************************************************************************************
     893             : !> \brief ...
     894             : !> \param qs_control ...
     895             : ! **************************************************************************************************
     896        7354 :    SUBROUTINE qs_control_release(qs_control)
     897             :       TYPE(qs_control_type), POINTER                     :: qs_control
     898             : 
     899             :       INTEGER                                            :: i
     900             : 
     901        7354 :       IF (ASSOCIATED(qs_control)) THEN
     902        7354 :          CALL mulliken_control_release(qs_control%mulliken_restraint_control)
     903        7354 :          DEALLOCATE (qs_control%mulliken_restraint_control)
     904        7354 :          CALL s2_control_release(qs_control%s2_restraint_control)
     905        7354 :          DEALLOCATE (qs_control%s2_restraint_control)
     906        7354 :          CALL se_control_release(qs_control%se_control)
     907        7354 :          CALL dftb_control_release(qs_control%dftb_control)
     908        7354 :          CALL xtb_control_release(qs_control%xtb_control)
     909        7354 :          IF (ASSOCIATED(qs_control%cdft_control)) THEN
     910        7354 :             CALL cdft_control_release(qs_control%cdft_control)
     911        7354 :             DEALLOCATE (qs_control%cdft_control)
     912             :          END IF
     913             : 
     914        7354 :          IF (ASSOCIATED(qs_control%e_cutoff)) THEN
     915        7354 :             DEALLOCATE (qs_control%e_cutoff)
     916             :          END IF
     917        7354 :          IF (ASSOCIATED(qs_control%gapw_control)) THEN
     918        7354 :             DEALLOCATE (qs_control%gapw_control)
     919             :          END IF
     920        7354 :          IF (ASSOCIATED(qs_control%ddapc_restraint_control)) THEN
     921          32 :             DO i = 1, SIZE(qs_control%ddapc_restraint_control)
     922          32 :                CALL ddapc_control_release(qs_control%ddapc_restraint_control(i))
     923             :             END DO
     924          14 :             DEALLOCATE (qs_control%ddapc_restraint_control)
     925             :          END IF
     926        7354 :          DEALLOCATE (qs_control)
     927             :       END IF
     928        7354 :    END SUBROUTINE qs_control_release
     929             : 
     930             : ! **************************************************************************************************
     931             : !> \brief allocate control options for Time-Dependent Density Functional Theory calculation
     932             : !> \param tddfpt_control an object to create
     933             : !> \par History
     934             : !>    * 05.2016 created [Sergey Chulkov]
     935             : ! **************************************************************************************************
     936       14708 :    SUBROUTINE tddfpt2_control_create(tddfpt_control)
     937             :       TYPE(tddfpt2_control_type), POINTER                :: tddfpt_control
     938             : 
     939             :       CHARACTER(len=*), PARAMETER :: routineN = 'tddfpt2_control_create'
     940             : 
     941             :       INTEGER                                            :: handle
     942             : 
     943        7354 :       CPASSERT(.NOT. ASSOCIATED(tddfpt_control))
     944        7354 :       CALL timeset(routineN, handle)
     945             : 
     946        7354 :       ALLOCATE (tddfpt_control)
     947             :       tddfpt_control%do_soc = .FALSE.
     948             : 
     949        7354 :       CALL timestop(handle)
     950        7354 :    END SUBROUTINE tddfpt2_control_create
     951             : 
     952             : ! **************************************************************************************************
     953             : !> \brief release memory allocated for TDDFT control options
     954             : !> \param tddfpt_control an object to release
     955             : !> \par History
     956             : !>    * 05.2016 created [Sergey Chulkov]
     957             : ! **************************************************************************************************
     958        7354 :    SUBROUTINE tddfpt2_control_release(tddfpt_control)
     959             :       TYPE(tddfpt2_control_type), POINTER                :: tddfpt_control
     960             : 
     961             :       CHARACTER(len=*), PARAMETER :: routineN = 'tddfpt2_control_release'
     962             : 
     963             :       INTEGER                                            :: handle
     964             : 
     965        7354 :       CALL timeset(routineN, handle)
     966             : 
     967        7354 :       IF (ASSOCIATED(tddfpt_control)) THEN
     968        7354 :          DEALLOCATE (tddfpt_control)
     969             :       END IF
     970             : 
     971        7354 :       CALL timestop(handle)
     972        7354 :    END SUBROUTINE tddfpt2_control_release
     973             : 
     974             : ! **************************************************************************************************
     975             : !> \brief ...
     976             : !> \param proj_mo_list ...
     977             : ! **************************************************************************************************
     978         248 :    SUBROUTINE proj_mo_list_release(proj_mo_list)
     979             :       TYPE(proj_mo_p_type), DIMENSION(:), POINTER        :: proj_mo_list
     980             : 
     981             :       INTEGER                                            :: i, mo_ref_nbr
     982             : 
     983         248 :       IF (ASSOCIATED(proj_mo_list)) THEN
     984          56 :          DO i = 1, SIZE(proj_mo_list)
     985          56 :             IF (ASSOCIATED(proj_mo_list(i)%proj_mo)) THEN
     986          52 :                IF (ALLOCATED(proj_mo_list(i)%proj_mo%ref_mo_index)) &
     987          52 :                   DEALLOCATE (proj_mo_list(i)%proj_mo%ref_mo_index)
     988          52 :                IF (ALLOCATED(proj_mo_list(i)%proj_mo%mo_ref)) THEN
     989         204 :                   DO mo_ref_nbr = 1, SIZE(proj_mo_list(i)%proj_mo%mo_ref)
     990         204 :                      CALL cp_fm_release(proj_mo_list(i)%proj_mo%mo_ref(mo_ref_nbr))
     991             :                   END DO
     992          52 :                   DEALLOCATE (proj_mo_list(i)%proj_mo%mo_ref)
     993             :                END IF
     994          52 :                IF (ALLOCATED(proj_mo_list(i)%proj_mo%td_mo_index)) &
     995          52 :                   DEALLOCATE (proj_mo_list(i)%proj_mo%td_mo_index)
     996          52 :                IF (ALLOCATED(proj_mo_list(i)%proj_mo%td_mo_occ)) &
     997          52 :                   DEALLOCATE (proj_mo_list(i)%proj_mo%td_mo_occ)
     998          52 :                DEALLOCATE (proj_mo_list(i)%proj_mo)
     999             :             END IF
    1000             :          END DO
    1001           4 :          DEALLOCATE (proj_mo_list)
    1002             :       END IF
    1003         248 :    END SUBROUTINE proj_mo_list_release
    1004             : 
    1005             : ! **************************************************************************************************
    1006             : !> \brief ...
    1007             : !> \param efield_fields ...
    1008             : ! **************************************************************************************************
    1009        7354 :    SUBROUTINE efield_fields_release(efield_fields)
    1010             :       TYPE(efield_p_type), DIMENSION(:), POINTER         :: efield_fields
    1011             : 
    1012             :       INTEGER                                            :: i
    1013             : 
    1014        7354 :       IF (ASSOCIATED(efield_fields)) THEN
    1015         524 :          DO i = 1, SIZE(efield_fields)
    1016         524 :             IF (ASSOCIATED(efield_fields(i)%efield)) THEN
    1017         262 :                IF (ASSOCIATED(efield_fields(i)%efield%envelop_r_vars)) THEN
    1018           8 :                   DEALLOCATE (efield_fields(i)%efield%envelop_r_vars)
    1019             :                END IF
    1020         262 :                IF (ASSOCIATED(efield_fields(i)%efield%envelop_i_vars)) THEN
    1021         254 :                   DEALLOCATE (efield_fields(i)%efield%envelop_i_vars)
    1022             :                END IF
    1023         262 :                IF (ASSOCIATED(efield_fields(i)%efield%polarisation)) &
    1024         262 :                   DEALLOCATE (efield_fields(i)%efield%polarisation)
    1025         262 :                DEALLOCATE (efield_fields(i)%efield)
    1026             :             END IF
    1027             :          END DO
    1028         262 :          DEALLOCATE (efield_fields)
    1029             :       END IF
    1030        7354 :    END SUBROUTINE efield_fields_release
    1031             : 
    1032             : ! **************************************************************************************************
    1033             : !> \brief ...
    1034             : !> \param dftb_control ...
    1035             : ! **************************************************************************************************
    1036        7354 :    SUBROUTINE dftb_control_create(dftb_control)
    1037             :       TYPE(dftb_control_type), POINTER                   :: dftb_control
    1038             : 
    1039        7354 :       CPASSERT(.NOT. ASSOCIATED(dftb_control))
    1040       73540 :       ALLOCATE (dftb_control)
    1041             : 
    1042             :       NULLIFY (dftb_control%sk_pair_list)
    1043        7354 :    END SUBROUTINE dftb_control_create
    1044             : 
    1045             : ! **************************************************************************************************
    1046             : !> \brief ...
    1047             : !> \param dftb_control ...
    1048             : ! **************************************************************************************************
    1049        7354 :    SUBROUTINE dftb_control_release(dftb_control)
    1050             :       TYPE(dftb_control_type), POINTER                   :: dftb_control
    1051             : 
    1052        7354 :       IF (ASSOCIATED(dftb_control)) THEN
    1053        7354 :          IF (ASSOCIATED(dftb_control%sk_pair_list)) THEN
    1054         222 :             DEALLOCATE (dftb_control%sk_pair_list)
    1055             :          END IF
    1056        7354 :          DEALLOCATE (dftb_control)
    1057             :       END IF
    1058        7354 :    END SUBROUTINE dftb_control_release
    1059             : 
    1060             : ! **************************************************************************************************
    1061             : !> \brief ...
    1062             : !> \param xtb_control ...
    1063             : ! **************************************************************************************************
    1064        7354 :    SUBROUTINE xtb_control_create(xtb_control)
    1065             :       TYPE(xtb_control_type), POINTER                    :: xtb_control
    1066             : 
    1067        7354 :       CPASSERT(.NOT. ASSOCIATED(xtb_control))
    1068        7354 :       ALLOCATE (xtb_control)
    1069             : 
    1070             :       NULLIFY (xtb_control%kab_param)
    1071             :       NULLIFY (xtb_control%kab_vals)
    1072             :       NULLIFY (xtb_control%kab_types)
    1073             :       NULLIFY (xtb_control%nonbonded)
    1074             :       NULLIFY (xtb_control%rcpair)
    1075             : 
    1076        7354 :    END SUBROUTINE xtb_control_create
    1077             : 
    1078             : ! **************************************************************************************************
    1079             : !> \brief ...
    1080             : !> \param xtb_control ...
    1081             : ! **************************************************************************************************
    1082        7354 :    SUBROUTINE xtb_control_release(xtb_control)
    1083             :       TYPE(xtb_control_type), POINTER                    :: xtb_control
    1084             : 
    1085        7354 :       IF (ASSOCIATED(xtb_control)) THEN
    1086        7354 :          IF (ASSOCIATED(xtb_control%kab_param)) THEN
    1087           2 :             DEALLOCATE (xtb_control%kab_param)
    1088             :          END IF
    1089        7354 :          IF (ASSOCIATED(xtb_control%kab_vals)) THEN
    1090           2 :             DEALLOCATE (xtb_control%kab_vals)
    1091             :          END IF
    1092        7354 :          IF (ASSOCIATED(xtb_control%kab_types)) THEN
    1093           2 :             DEALLOCATE (xtb_control%kab_types)
    1094             :          END IF
    1095        7354 :          IF (ASSOCIATED(xtb_control%rcpair)) THEN
    1096         940 :             DEALLOCATE (xtb_control%rcpair)
    1097             :          END IF
    1098        7354 :          IF (ASSOCIATED(xtb_control%nonbonded)) THEN
    1099           6 :             CALL pair_potential_p_release(xtb_control%nonbonded)
    1100             :          END IF
    1101        7354 :          DEALLOCATE (xtb_control)
    1102             :       END IF
    1103        7354 :    END SUBROUTINE xtb_control_release
    1104             : 
    1105             : ! **************************************************************************************************
    1106             : !> \brief ...
    1107             : !> \param se_control ...
    1108             : ! **************************************************************************************************
    1109        7354 :    SUBROUTINE se_control_create(se_control)
    1110             :       TYPE(semi_empirical_control_type), POINTER         :: se_control
    1111             : 
    1112        7354 :       CPASSERT(.NOT. ASSOCIATED(se_control))
    1113       36770 :       ALLOCATE (se_control)
    1114        7354 :    END SUBROUTINE se_control_create
    1115             : 
    1116             : ! **************************************************************************************************
    1117             : !> \brief ...
    1118             : !> \param se_control ...
    1119             : ! **************************************************************************************************
    1120        7354 :    SUBROUTINE se_control_release(se_control)
    1121             :       TYPE(semi_empirical_control_type), POINTER         :: se_control
    1122             : 
    1123        7354 :       IF (ASSOCIATED(se_control)) THEN
    1124        7354 :          DEALLOCATE (se_control)
    1125             :       END IF
    1126        7354 :    END SUBROUTINE se_control_release
    1127             : 
    1128             : ! **************************************************************************************************
    1129             : !> \brief ...
    1130             : !> \param admm_control ...
    1131             : ! **************************************************************************************************
    1132         446 :    SUBROUTINE admm_control_create(admm_control)
    1133             :       TYPE(admm_control_type), POINTER                   :: admm_control
    1134             : 
    1135         446 :       CPASSERT(.NOT. ASSOCIATED(admm_control))
    1136        2230 :       ALLOCATE (admm_control)
    1137             : 
    1138         446 :    END SUBROUTINE admm_control_create
    1139             : 
    1140             : ! **************************************************************************************************
    1141             : !> \brief ...
    1142             : !> \param admm_control ...
    1143             : ! **************************************************************************************************
    1144        7358 :    SUBROUTINE admm_control_release(admm_control)
    1145             :       TYPE(admm_control_type), POINTER                   :: admm_control
    1146             : 
    1147        7358 :       IF (ASSOCIATED(admm_control)) THEN
    1148         486 :          DEALLOCATE (admm_control)
    1149             :       END IF
    1150        7358 :    END SUBROUTINE admm_control_release
    1151             : 
    1152             : ! **************************************************************************************************
    1153             : !> \brief ...
    1154             : !> \param expot_control ...
    1155             : ! **************************************************************************************************
    1156          16 :    SUBROUTINE expot_control_create(expot_control)
    1157             :       TYPE(expot_control_type), POINTER                  :: expot_control
    1158             : 
    1159          16 :       CPASSERT(.NOT. ASSOCIATED(expot_control))
    1160          16 :       ALLOCATE (expot_control)
    1161             :       expot_control%read_from_cube = .FALSE.
    1162             :       expot_control%maxwell_solver = .FALSE.
    1163          16 :       expot_control%static = .TRUE.
    1164          16 :       expot_control%scaling_factor = 1.0_dp
    1165             : 
    1166          16 :    END SUBROUTINE expot_control_create
    1167             : 
    1168             : ! **************************************************************************************************
    1169             : !> \brief ...
    1170             : !> \param expot_control ...
    1171             : ! **************************************************************************************************
    1172        7354 :    SUBROUTINE expot_control_release(expot_control)
    1173             :       TYPE(expot_control_type), POINTER                  :: expot_control
    1174             : 
    1175        7354 :       IF (ASSOCIATED(expot_control)) THEN
    1176          16 :          DEALLOCATE (expot_control)
    1177             :       END IF
    1178             : 
    1179        7354 :    END SUBROUTINE expot_control_release
    1180             : 
    1181             : ! **************************************************************************************************
    1182             : !> \brief ...
    1183             : !> \param maxwell_control ...
    1184             : ! **************************************************************************************************
    1185           0 :    SUBROUTINE maxwell_control_create(maxwell_control)
    1186             :       TYPE(maxwell_control_type), POINTER                :: maxwell_control
    1187             : 
    1188           0 :       CPASSERT(.NOT. ASSOCIATED(maxwell_control))
    1189           0 :       ALLOCATE (maxwell_control)
    1190             : 
    1191           0 :    END SUBROUTINE maxwell_control_create
    1192             : 
    1193             : ! **************************************************************************************************
    1194             : !> \brief ...
    1195             : !> \param maxwell_control ...
    1196             : ! **************************************************************************************************
    1197        7354 :    SUBROUTINE maxwell_control_release(maxwell_control)
    1198             :       TYPE(maxwell_control_type), POINTER                :: maxwell_control
    1199             : 
    1200        7354 :       IF (ASSOCIATED(maxwell_control)) THEN
    1201           0 :          DEALLOCATE (maxwell_control)
    1202             :       END IF
    1203             : 
    1204        7354 :    END SUBROUTINE maxwell_control_release
    1205             : 
    1206           0 : END MODULE cp_control_types

Generated by: LCOV version 1.15