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 : !> \par History
10 : !> - mo_set_p_type added to qs_env (23.04.02,MK)
11 : !> - qs_force_type added to qs_env (05.06.02,MK)
12 : !> \author MK (23.01.2002)
13 : ! **************************************************************************************************
14 : MODULE qs_environment_types
15 : USE admm_types, ONLY: admm_env_release,&
16 : admm_type
17 : USE almo_scf_types, ONLY: almo_scf_env_release,&
18 : almo_scf_env_type
19 : USE atomic_kind_types, ONLY: atomic_kind_type
20 : USE atprop_types, ONLY: atprop_type
21 : USE cell_types, ONLY: cell_release,&
22 : cell_retain,&
23 : cell_type
24 : USE cp_blacs_env, ONLY: cp_blacs_env_type
25 : USE cp_control_types, ONLY: dft_control_type
26 : USE cp_dbcsr_api, ONLY: dbcsr_distribution_type,&
27 : dbcsr_p_type,&
28 : dbcsr_release_p
29 : USE cp_ddapc_types, ONLY: cp_ddapc_ewald_release,&
30 : cp_ddapc_ewald_type,&
31 : cp_ddapc_release,&
32 : cp_ddapc_type
33 : USE cp_fm_types, ONLY: cp_fm_release,&
34 : cp_fm_type
35 : USE cp_result_types, ONLY: cp_result_type
36 : USE cp_subsys_types, ONLY: cp_subsys_type
37 : USE distribution_1d_types, ONLY: distribution_1d_type
38 : USE distribution_2d_types, ONLY: distribution_2d_type
39 : USE dm_ls_scf_types, ONLY: ls_scf_env_type,&
40 : ls_scf_release
41 : USE ec_env_types, ONLY: ec_env_release,&
42 : energy_correction_type
43 : USE et_coupling_types, ONLY: et_coupling_release,&
44 : et_coupling_type
45 : USE ewald_environment_types, ONLY: ewald_env_release,&
46 : ewald_environment_type
47 : USE ewald_pw_types, ONLY: ewald_pw_release,&
48 : ewald_pw_type
49 : USE exstates_types, ONLY: excited_energy_type,&
50 : exstate_release
51 : USE fist_nonbond_env_types, ONLY: fist_nonbond_env_release,&
52 : fist_nonbond_env_type
53 : USE global_types, ONLY: global_environment_type
54 : USE hartree_local_types, ONLY: ecoul_1center_type,&
55 : get_hartree_local,&
56 : hartree_local_create,&
57 : hartree_local_release,&
58 : hartree_local_type,&
59 : set_hartree_local
60 : USE hfx_types, ONLY: hfx_release,&
61 : hfx_type
62 : USE input_constants, ONLY: energy_force_run,&
63 : energy_run
64 : USE input_section_types, ONLY: section_vals_release,&
65 : section_vals_retain,&
66 : section_vals_type
67 : USE kg_environment_types, ONLY: kg_env_release,&
68 : kg_environment_type
69 : USE kinds, ONLY: dp
70 : USE kpoint_types, ONLY: kpoint_type
71 : USE lri_environment_types, ONLY: lri_density_release,&
72 : lri_density_type,&
73 : lri_env_release,&
74 : lri_environment_type
75 : USE message_passing, ONLY: mp_para_env_type
76 : USE molecule_kind_types, ONLY: molecule_kind_type
77 : USE molecule_types, ONLY: molecule_type
78 : USE mp2_types, ONLY: mp2_env_release,&
79 : mp2_type
80 : USE mscfg_types, ONLY: molecular_scf_guess_env_destroy,&
81 : molecular_scf_guess_env_type
82 : USE particle_types, ONLY: particle_type
83 : USE post_scf_bandstructure_types, ONLY: bs_env_release,&
84 : post_scf_bandstructure_type
85 : USE pw_env_types, ONLY: pw_env_type
86 : USE pw_types, ONLY: pw_c1d_gs_type,&
87 : pw_r3d_rs_type
88 : USE qmmm_types_low, ONLY: qmmm_env_qm_type
89 : USE qs_active_space_types, ONLY: active_space_type,&
90 : release_active_space_type
91 : USE qs_charges_types, ONLY: qs_charges_release,&
92 : qs_charges_type
93 : USE qs_dftb_types, ONLY: qs_dftb_pairpot_release,&
94 : qs_dftb_pairpot_type
95 : USE qs_dispersion_types, ONLY: qs_dispersion_release,&
96 : qs_dispersion_type
97 : USE qs_energy_types, ONLY: qs_energy_type
98 : USE qs_force_types, ONLY: qs_force_type
99 : USE qs_gcp_types, ONLY: qs_gcp_release,&
100 : qs_gcp_type
101 : USE qs_harris_types, ONLY: harris_env_release,&
102 : harris_type
103 : USE qs_kind_types, ONLY: qs_kind_type
104 : USE qs_ks_qmmm_types, ONLY: qs_ks_qmmm_env_type,&
105 : qs_ks_qmmm_release
106 : USE qs_ks_types, ONLY: get_ks_env,&
107 : qs_ks_env_type,&
108 : qs_ks_part_release,&
109 : qs_ks_release,&
110 : set_ks_env
111 : USE qs_linres_types, ONLY: linres_control_release,&
112 : linres_control_type,&
113 : polar_env_release,&
114 : polar_env_type
115 : USE qs_local_rho_types, ONLY: get_local_rho,&
116 : local_rho_set_create,&
117 : local_rho_set_release,&
118 : local_rho_type,&
119 : rhoz_type,&
120 : set_local_rho
121 : USE qs_matrix_pools, ONLY: mpools_release,&
122 : mpools_retain,&
123 : qs_matrix_pools_type
124 : USE qs_mo_types, ONLY: deallocate_mo_set,&
125 : mo_set_type
126 : USE qs_neighbor_list_types, ONLY: neighbor_list_set_p_type
127 : USE qs_oce_types, ONLY: deallocate_oce_set,&
128 : oce_matrix_type
129 : USE qs_period_efield_types, ONLY: efield_berry_release,&
130 : efield_berry_type
131 : USE qs_rho0_types, ONLY: rho0_atom_type,&
132 : rho0_mpole_type
133 : USE qs_rho_atom_types, ONLY: rho_atom_type
134 : USE qs_rho_types, ONLY: qs_rho_p_type,&
135 : qs_rho_release,&
136 : qs_rho_type
137 : USE qs_scf_types, ONLY: qs_scf_env_type,&
138 : scf_env_release
139 : USE qs_subsys_types, ONLY: qs_subsys_set,&
140 : qs_subsys_type
141 : USE qs_wf_history_types, ONLY: qs_wf_history_type,&
142 : wfi_release,&
143 : wfi_retain
144 : USE rel_control_types, ONLY: rel_c_release,&
145 : rel_control_type
146 : USE rt_propagation_types, ONLY: rt_prop_release,&
147 : rt_prop_type
148 : USE scf_control_types, ONLY: scf_c_release,&
149 : scf_control_type
150 : USE semi_empirical_mpole_types, ONLY: nddo_mpole_release,&
151 : nddo_mpole_type
152 : USE semi_empirical_store_int_types, ONLY: semi_empirical_si_release,&
153 : semi_empirical_si_type
154 : USE semi_empirical_types, ONLY: se_taper_release,&
155 : se_taper_type
156 : USE task_list_types, ONLY: task_list_type
157 : USE transport_env_types, ONLY: transport_env_release,&
158 : transport_env_type
159 : USE virial_types, ONLY: virial_type
160 : USE wannier_states_types, ONLY: wannier_centres_type
161 : USE xas_env_types, ONLY: xas_env_release,&
162 : xas_environment_type
163 : #include "./base/base_uses.f90"
164 :
165 : IMPLICIT NONE
166 :
167 : PRIVATE
168 :
169 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_environment_types'
170 :
171 : ! *** Public data types ***
172 :
173 : PUBLIC :: qs_environment_type
174 :
175 : ! *** Public subroutines ***
176 :
177 : PUBLIC :: get_qs_env, &
178 : qs_env_create, &
179 : qs_env_release, &
180 : qs_env_part_release, &
181 : set_qs_env
182 :
183 : ! **************************************************************************************************
184 : !> \param local_rho_set contains the atomic, compensations and core densities
185 : !> and the local parts of the xc terms
186 : !> \param hartree_local contains the 1, 2 and 3 centers coulomb terms
187 : !> \param requires_mo_derivs logical, true if dE/dC is required (e.g. OT)
188 : !> \param has_unit_metric logical, true if the S matrix is considered unity for the SCF
189 : !> \param mo_derivs the actual derivatives of the total energy wrt to MO coeffs (divided by 2*f_i)
190 : !> \param xas_env temporary information for xas calculation
191 : !> \param dftb_potential pair potentials for use with DFTB
192 : !> \param dispersion_env environment for use with QS dispersion
193 : !>
194 : !> compatibility get (things that you should get from the subsys):
195 : !> \param atomic_kind_set array with infos about the species (atomic_kinds)
196 : !> present in the system
197 : !> \param particle_set info on the atoms you simulate, pos,...
198 : !> \param local_particles which particles ar local to this processor
199 : !> new:
200 : !> \param local_molecules which molecules are local to this processor
201 : !> \param molecule_kind_set description of the molecule kinds
202 : !> \param molecule_set all the molecule description
203 : !> \param rtp all data needed for real time propagation
204 : !> \param x contains data used in Hartree-Fock-Exchange calculations
205 : !> \param task_list the list of tasks used in collocate and integrate
206 : !> \param task_list_soft the list of tasks used in collocate and integrate in case of soft basis functions
207 : !> \param mo_loc_history if a history of localized wfn is kept, they are stored here.
208 : !> \param molecular_scf_guess_env contains inforamation about and results of claculations
209 : !> on separate molecules
210 : !> \par History
211 : !> 11.2002 added doc and attribute description [fawzi]
212 : !> 08.2004 renamed some of the very short names (s,c,k,h) for easier grepping
213 : !> 06.2018 polar_env added (MK)
214 : !> \author Matthias Krack & fawzi
215 : ! **************************************************************************************************
216 :
217 : TYPE qs_environment_type
218 : LOGICAL :: qmmm = .FALSE., qmmm_periodic = .FALSE.
219 : LOGICAL :: requires_mo_derivs = .FALSE.
220 : LOGICAL :: requires_matrix_vxc = .FALSE.
221 : LOGICAL :: has_unit_metric = .FALSE.
222 : LOGICAL :: run_rtp = .FALSE.
223 : LOGICAL :: linres_run = .FALSE.
224 : LOGICAL :: calc_image_preconditioner = .FALSE.
225 : LOGICAL :: do_transport = .FALSE.
226 : LOGICAL :: single_point_run = .FALSE.
227 : LOGICAL :: given_embed_pot = .FALSE.
228 : LOGICAL :: energy_correction = .FALSE.
229 : LOGICAL :: harris_method = .FALSE.
230 : REAL(KIND=dp) :: sim_time = -1.0_dp
231 : REAL(KIND=dp) :: start_time = -1.0_dp, target_time = -1.0_dp
232 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: image_matrix => NULL()
233 : REAL(KIND=dp), DIMENSION(:), POINTER :: image_coeff => NULL()
234 : INTEGER, DIMENSION(:), POINTER :: ipiv => NULL()
235 : INTEGER :: sim_step = -1
236 : TYPE(ls_scf_env_type), POINTER :: ls_scf_env => NULL()
237 : TYPE(almo_scf_env_type), POINTER :: almo_scf_env => NULL()
238 : TYPE(transport_env_type), POINTER :: transport_env => NULL()
239 : TYPE(cell_type), POINTER :: super_cell => NULL()
240 : TYPE(mo_set_type), DIMENSION(:), POINTER :: mos => NULL()
241 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: mo_loc_history => NULL()
242 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mo_derivs => NULL()
243 : TYPE(scf_control_type), POINTER :: scf_control => NULL()
244 : TYPE(rel_control_type), POINTER :: rel_control => NULL()
245 : ! ZMP adding variables
246 : TYPE(qs_rho_type), POINTER :: rho_external => NULL()
247 : TYPE(pw_r3d_rs_type), POINTER :: external_vxc => NULL()
248 : TYPE(pw_r3d_rs_type), POINTER :: mask => NULL()
249 : TYPE(qs_charges_type), POINTER :: qs_charges => NULL()
250 : TYPE(qs_ks_env_type), POINTER :: ks_env => NULL()
251 : TYPE(qs_ks_qmmm_env_type), POINTER :: ks_qmmm_env => NULL()
252 : TYPE(qmmm_env_qm_type), POINTER :: qmmm_env_qm => NULL()
253 : TYPE(qs_wf_history_type), POINTER :: wf_history => NULL()
254 : TYPE(qs_scf_env_type), POINTER :: scf_env => NULL()
255 : TYPE(qs_matrix_pools_type), POINTER :: mpools => NULL()
256 : TYPE(oce_matrix_type), POINTER :: oce => NULL()
257 : TYPE(local_rho_type), POINTER :: local_rho_set => NULL()
258 : TYPE(hartree_local_type), POINTER :: hartree_local => NULL()
259 : TYPE(section_vals_type), POINTER :: input => NULL()
260 : TYPE(linres_control_type), POINTER :: linres_control => NULL()
261 : TYPE(xas_environment_type), POINTER :: xas_env => NULL()
262 : TYPE(cp_ddapc_type), POINTER :: cp_ddapc_env => NULL()
263 : TYPE(cp_ddapc_ewald_type), POINTER :: cp_ddapc_ewald => NULL()
264 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: outer_scf_history => NULL()
265 : INTEGER :: outer_scf_ihistory = -1
266 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: gradient_history => NULL(), &
267 : variable_history => NULL()
268 : TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data => NULL()
269 : TYPE(et_coupling_type), POINTER :: et_coupling => NULL()
270 : TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), POINTER :: dftb_potential => NULL()
271 : TYPE(admm_type), POINTER :: admm_env => NULL()
272 : TYPE(active_space_type), POINTER :: active_space => NULL()
273 : ! LRI
274 : TYPE(lri_environment_type), POINTER :: lri_env => NULL()
275 : TYPE(lri_density_type), POINTER :: lri_density => NULL()
276 : ! Harris model
277 : TYPE(harris_type), POINTER :: harris_env => NULL()
278 : ! Energy correction
279 : TYPE(energy_correction_type), POINTER :: ec_env => NULL()
280 : ! Excited States
281 : LOGICAL :: excited_state = .FALSE.
282 : TYPE(excited_energy_type), POINTER :: exstate_env => NULL()
283 : ! Empirical dispersion
284 : TYPE(qs_dispersion_type), POINTER :: dispersion_env => NULL()
285 : ! Empirical geometrical BSSE correction
286 : TYPE(qs_gcp_type), POINTER :: gcp_env => NULL()
287 : ! Semi-empirical and DFTB types
288 : TYPE(ewald_environment_type), POINTER :: ewald_env => NULL()
289 : TYPE(ewald_pw_type), POINTER :: ewald_pw => NULL()
290 : ! Semi-empirical types
291 : TYPE(se_taper_type), POINTER :: se_taper => NULL()
292 : TYPE(semi_empirical_si_type), POINTER :: se_store_int_env => NULL()
293 : TYPE(nddo_mpole_type), POINTER :: se_nddo_mpole => NULL()
294 : TYPE(fist_nonbond_env_type), POINTER :: se_nonbond_env => NULL()
295 : TYPE(rt_prop_type), POINTER :: rtp => NULL()
296 : TYPE(efield_berry_type), POINTER :: efield => NULL()
297 : ! a history for the broyden ot
298 : REAL(KIND=dp) :: broyden_adaptive_sigma = -1.0_dp
299 : TYPE(mp2_type), POINTER :: mp2_env => NULL()
300 : TYPE(post_scf_bandstructure_type), POINTER :: bs_env => NULL()
301 : TYPE(kg_environment_type), POINTER :: kg_env => NULL()
302 : TYPE(wannier_centres_type), POINTER, DIMENSION(:) :: WannierCentres => NULL()
303 : TYPE(molecular_scf_guess_env_type), POINTER :: molecular_scf_guess_env => NULL()
304 : ! Subsystem densities
305 : TYPE(qs_rho_p_type), DIMENSION(:), POINTER :: subsys_dens => NULL()
306 : ! Embedding potential
307 : TYPE(pw_r3d_rs_type), POINTER :: embed_pot => NULL()
308 : TYPE(pw_r3d_rs_type), POINTER :: spin_embed_pot => NULL()
309 : ! Polarizability tensor
310 : TYPE(polar_env_type), POINTER :: polar_env => NULL()
311 : ! EEQ charges
312 : REAL(KIND=dp), DIMENSION(:), POINTER :: eeq => NULL()
313 : ! Resp charges
314 : REAL(KIND=dp), DIMENSION(:), POINTER :: rhs => NULL()
315 : REAL(KIND=dp) :: total_zeff_corr = -1.0_dp, surface_dipole_moment = -1.0_dp
316 : LOGICAL :: surface_dipole_switch_off = .FALSE.
317 : TYPE(mo_set_type), DIMENSION(:), POINTER :: mos_last_converged => NULL()
318 : END TYPE qs_environment_type
319 :
320 : CONTAINS
321 :
322 : ! **************************************************************************************************
323 : !> \brief Get the QUICKSTEP environment.
324 : !> \param qs_env ...
325 : !> \param atomic_kind_set ...
326 : !> \param qs_kind_set ...
327 : !> \param cell ...
328 : !> \param super_cell ...
329 : !> \param cell_ref ...
330 : !> \param use_ref_cell ...
331 : !> \param kpoints ...
332 : !> \param dft_control ...
333 : !> \param mos ...
334 : !> \param sab_orb ...
335 : !> \param sab_all ...
336 : !> \param qmmm ...
337 : !> \param qmmm_periodic ...
338 : !> \param sac_ae ...
339 : !> \param sac_ppl ...
340 : !> \param sac_lri ...
341 : !> \param sap_ppnl ...
342 : !> \param sab_vdw ...
343 : !> \param sab_scp ...
344 : !> \param sap_oce ...
345 : !> \param sab_lrc ...
346 : !> \param sab_se ...
347 : !> \param sab_xtbe ...
348 : !> \param sab_tbe ...
349 : !> \param sab_core ...
350 : !> \param sab_xb ...
351 : !> \param sab_xtb_pp ...
352 : !> \param sab_xtb_nonbond ...
353 : !> \param sab_almo ...
354 : !> \param sab_kp ...
355 : !> \param sab_kp_nosym ...
356 : !> \param particle_set ...
357 : !> \param energy ...
358 : !> \param force ...
359 : !> \param matrix_h ...
360 : !> \param matrix_h_im ...
361 : !> \param matrix_ks ...
362 : !> \param matrix_ks_im ...
363 : !> \param matrix_vxc ...
364 : !> \param run_rtp ...
365 : !> \param rtp ...
366 : !> \param matrix_h_kp ...
367 : !> \param matrix_h_im_kp ...
368 : !> \param matrix_ks_kp ...
369 : !> \param matrix_ks_im_kp ...
370 : !> \param matrix_vxc_kp ...
371 : !> \param kinetic_kp ...
372 : !> \param matrix_s_kp ...
373 : !> \param matrix_w_kp ...
374 : !> \param matrix_s_RI_aux_kp ...
375 : !> \param matrix_s ...
376 : !> \param matrix_s_RI_aux ...
377 : !> \param matrix_w ...
378 : !> \param matrix_p_mp2 ...
379 : !> \param matrix_p_mp2_admm ...
380 : !> \param rho ...
381 : !> \param rho_xc ...
382 : !> \param pw_env ...
383 : !> \param ewald_env ...
384 : !> \param ewald_pw ...
385 : !> \param active_space ...
386 : !> \param mpools ...
387 : !> \param input ...
388 : !> \param para_env ...
389 : !> \param blacs_env ...
390 : !> \param scf_control ...
391 : !> \param rel_control ...
392 : !> \param kinetic ...
393 : !> \param qs_charges ...
394 : !> \param vppl ...
395 : !> \param rho_core ...
396 : !> \param rho_nlcc ...
397 : !> \param rho_nlcc_g ...
398 : !> \param ks_env ...
399 : !> \param ks_qmmm_env ...
400 : !> \param wf_history ...
401 : !> \param scf_env ...
402 : !> \param local_particles ...
403 : !> \param local_molecules ...
404 : !> \param distribution_2d ...
405 : !> \param dbcsr_dist ...
406 : !> \param molecule_kind_set ...
407 : !> \param molecule_set ...
408 : !> \param subsys ...
409 : !> \param cp_subsys ...
410 : !> \param oce ...
411 : !> \param local_rho_set ...
412 : !> \param rho_atom_set ...
413 : !> \param task_list ...
414 : !> \param task_list_soft ...
415 : !> \param rho0_atom_set ...
416 : !> \param rho0_mpole ...
417 : !> \param rhoz_set ...
418 : !> \param ecoul_1c ...
419 : !> \param rho0_s_rs ...
420 : !> \param rho0_s_gs ...
421 : !> \param do_kpoints ...
422 : !> \param has_unit_metric ...
423 : !> \param requires_mo_derivs ...
424 : !> \param mo_derivs ...
425 : !> \param mo_loc_history ...
426 : !> \param nkind ...
427 : !> \param natom ...
428 : !> \param nelectron_total ...
429 : !> \param nelectron_spin ...
430 : !> \param efield ...
431 : !> \param neighbor_list_id ...
432 : !> \param linres_control ...
433 : !> \param xas_env ...
434 : !> \param virial ...
435 : !> \param cp_ddapc_env ...
436 : !> \param cp_ddapc_ewald ...
437 : !> \param outer_scf_history ...
438 : !> \param outer_scf_ihistory ...
439 : !> \param x_data ...
440 : !> \param et_coupling ...
441 : !> \param dftb_potential ...
442 : !> \param results ...
443 : !> \param se_taper ...
444 : !> \param se_store_int_env ...
445 : !> \param se_nddo_mpole ...
446 : !> \param se_nonbond_env ...
447 : !> \param admm_env ...
448 : !> \param lri_env ...
449 : !> \param lri_density ...
450 : !> \param exstate_env ...
451 : !> \param ec_env ...
452 : !> \param harris_env ...
453 : !> \param dispersion_env ...
454 : !> \param gcp_env ...
455 : !> \param vee ...
456 : !> \param rho_external ...
457 : !> \param external_vxc ...
458 : !> \param mask ...
459 : !> \param mp2_env ...
460 : !> \param bs_env ...
461 : !> \param kg_env ...
462 : !> \param WannierCentres ...
463 : !> \param atprop ...
464 : !> \param ls_scf_env ...
465 : !> \param do_transport ...
466 : !> \param transport_env ...
467 : !> \param v_hartree_rspace ...
468 : !> \param s_mstruct_changed ...
469 : !> \param rho_changed ...
470 : !> \param potential_changed ...
471 : !> \param forces_up_to_date ...
472 : !> \param mscfg_env ...
473 : !> \param almo_scf_env ...
474 : !> \param gradient_history ...
475 : !> \param variable_history ...
476 : !> \param embed_pot ...
477 : !> \param spin_embed_pot ...
478 : !> \param polar_env ...
479 : !> \param mos_last_converged ... [SGh]
480 : !> \param eeq ...
481 : !> \param rhs ...
482 : !> \date 23.01.2002
483 : !> \author MK
484 : !> \version 1.0
485 : ! **************************************************************************************************
486 8566828 : SUBROUTINE get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, &
487 : dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, &
488 : sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, &
489 : sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, &
490 : sab_kp, sab_kp_nosym, particle_set, energy, force, &
491 : matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, &
492 : matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, &
493 : matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, &
494 : matrix_p_mp2, matrix_p_mp2_admm, rho, &
495 : rho_xc, pw_env, ewald_env, ewald_pw, active_space, &
496 : mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, &
497 : vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, &
498 : local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, &
499 : molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, &
500 : task_list, &
501 : task_list_soft, &
502 : rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, &
503 : rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, &
504 : mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, &
505 : neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, &
506 : outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, &
507 : se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, &
508 : lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, &
509 : rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, &
510 : WannierCentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, &
511 : s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, &
512 : gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, &
513 : eeq, rhs)
514 : TYPE(qs_environment_type), INTENT(IN) :: qs_env
515 : TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
516 : POINTER :: atomic_kind_set
517 : TYPE(qs_kind_type), DIMENSION(:), OPTIONAL, &
518 : POINTER :: qs_kind_set
519 : TYPE(cell_type), OPTIONAL, POINTER :: cell, super_cell, cell_ref
520 : LOGICAL, OPTIONAL :: use_ref_cell
521 : TYPE(kpoint_type), OPTIONAL, POINTER :: kpoints
522 : TYPE(dft_control_type), OPTIONAL, POINTER :: dft_control
523 : TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos
524 : TYPE(neighbor_list_set_p_type), DIMENSION(:), &
525 : OPTIONAL, POINTER :: sab_orb, sab_all
526 : LOGICAL, OPTIONAL :: qmmm, qmmm_periodic
527 : TYPE(neighbor_list_set_p_type), DIMENSION(:), OPTIONAL, POINTER :: sac_ae, sac_ppl, sac_lri, &
528 : sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, &
529 : sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym
530 : TYPE(particle_type), DIMENSION(:), OPTIONAL, &
531 : POINTER :: particle_set
532 : TYPE(qs_energy_type), OPTIONAL, POINTER :: energy
533 : TYPE(qs_force_type), DIMENSION(:), OPTIONAL, &
534 : POINTER :: force
535 : TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
536 : POINTER :: matrix_h, matrix_h_im, matrix_ks, &
537 : matrix_ks_im, matrix_vxc
538 : LOGICAL, OPTIONAL :: run_rtp
539 : TYPE(rt_prop_type), OPTIONAL, POINTER :: rtp
540 : TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, POINTER :: matrix_h_kp, matrix_h_im_kp, &
541 : matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, &
542 : matrix_s_RI_aux_kp
543 : TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
544 : POINTER :: matrix_s, matrix_s_RI_aux, matrix_w, &
545 : matrix_p_mp2, matrix_p_mp2_admm
546 : TYPE(qs_rho_type), OPTIONAL, POINTER :: rho, rho_xc
547 : TYPE(pw_env_type), OPTIONAL, POINTER :: pw_env
548 : TYPE(ewald_environment_type), OPTIONAL, POINTER :: ewald_env
549 : TYPE(ewald_pw_type), OPTIONAL, POINTER :: ewald_pw
550 : TYPE(active_space_type), OPTIONAL, POINTER :: active_space
551 : TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
552 : TYPE(section_vals_type), OPTIONAL, POINTER :: input
553 : TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
554 : TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env
555 : TYPE(scf_control_type), OPTIONAL, POINTER :: scf_control
556 : TYPE(rel_control_type), OPTIONAL, POINTER :: rel_control
557 : TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
558 : POINTER :: kinetic
559 : TYPE(qs_charges_type), OPTIONAL, POINTER :: qs_charges
560 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: vppl
561 : TYPE(pw_c1d_gs_type), OPTIONAL, POINTER :: rho_core
562 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: rho_nlcc
563 : TYPE(pw_c1d_gs_type), OPTIONAL, POINTER :: rho_nlcc_g
564 : TYPE(qs_ks_env_type), OPTIONAL, POINTER :: ks_env
565 : TYPE(qs_ks_qmmm_env_type), OPTIONAL, POINTER :: ks_qmmm_env
566 : TYPE(qs_wf_history_type), OPTIONAL, POINTER :: wf_history
567 : TYPE(qs_scf_env_type), OPTIONAL, POINTER :: scf_env
568 : TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles, local_molecules
569 : TYPE(distribution_2d_type), OPTIONAL, POINTER :: distribution_2d
570 : TYPE(dbcsr_distribution_type), OPTIONAL, POINTER :: dbcsr_dist
571 : TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
572 : POINTER :: molecule_kind_set
573 : TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
574 : POINTER :: molecule_set
575 : TYPE(qs_subsys_type), OPTIONAL, POINTER :: subsys
576 : TYPE(cp_subsys_type), OPTIONAL, POINTER :: cp_subsys
577 : TYPE(oce_matrix_type), OPTIONAL, POINTER :: oce
578 : TYPE(local_rho_type), OPTIONAL, POINTER :: local_rho_set
579 : TYPE(rho_atom_type), DIMENSION(:), OPTIONAL, &
580 : POINTER :: rho_atom_set
581 : TYPE(task_list_type), OPTIONAL, POINTER :: task_list, task_list_soft
582 : TYPE(rho0_atom_type), DIMENSION(:), OPTIONAL, &
583 : POINTER :: rho0_atom_set
584 : TYPE(rho0_mpole_type), OPTIONAL, POINTER :: rho0_mpole
585 : TYPE(rhoz_type), DIMENSION(:), OPTIONAL, POINTER :: rhoz_set
586 : TYPE(ecoul_1center_type), DIMENSION(:), OPTIONAL, &
587 : POINTER :: ecoul_1c
588 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: rho0_s_rs
589 : TYPE(pw_c1d_gs_type), OPTIONAL, POINTER :: rho0_s_gs
590 : LOGICAL, OPTIONAL :: do_kpoints, has_unit_metric, &
591 : requires_mo_derivs
592 : TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
593 : POINTER :: mo_derivs
594 : TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: mo_loc_history
595 : INTEGER, OPTIONAL :: nkind, natom, nelectron_total
596 : INTEGER, DIMENSION(2), OPTIONAL :: nelectron_spin
597 : TYPE(efield_berry_type), OPTIONAL, POINTER :: efield
598 : INTEGER, OPTIONAL :: neighbor_list_id
599 : TYPE(linres_control_type), OPTIONAL, POINTER :: linres_control
600 : TYPE(xas_environment_type), OPTIONAL, POINTER :: xas_env
601 : TYPE(virial_type), OPTIONAL, POINTER :: virial
602 : TYPE(cp_ddapc_type), OPTIONAL, POINTER :: cp_ddapc_env
603 : TYPE(cp_ddapc_ewald_type), OPTIONAL, POINTER :: cp_ddapc_ewald
604 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: outer_scf_history
605 : INTEGER, INTENT(out), OPTIONAL :: outer_scf_ihistory
606 : TYPE(hfx_type), DIMENSION(:, :), OPTIONAL, POINTER :: x_data
607 : TYPE(et_coupling_type), OPTIONAL, POINTER :: et_coupling
608 : TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), &
609 : OPTIONAL, POINTER :: dftb_potential
610 : TYPE(cp_result_type), OPTIONAL, POINTER :: results
611 : TYPE(se_taper_type), OPTIONAL, POINTER :: se_taper
612 : TYPE(semi_empirical_si_type), OPTIONAL, POINTER :: se_store_int_env
613 : TYPE(nddo_mpole_type), OPTIONAL, POINTER :: se_nddo_mpole
614 : TYPE(fist_nonbond_env_type), OPTIONAL, POINTER :: se_nonbond_env
615 : TYPE(admm_type), OPTIONAL, POINTER :: admm_env
616 : TYPE(lri_environment_type), OPTIONAL, POINTER :: lri_env
617 : TYPE(lri_density_type), OPTIONAL, POINTER :: lri_density
618 : TYPE(excited_energy_type), OPTIONAL, POINTER :: exstate_env
619 : TYPE(energy_correction_type), OPTIONAL, POINTER :: ec_env
620 : TYPE(harris_type), OPTIONAL, POINTER :: harris_env
621 : TYPE(qs_dispersion_type), OPTIONAL, POINTER :: dispersion_env
622 : TYPE(qs_gcp_type), OPTIONAL, POINTER :: gcp_env
623 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: vee
624 : TYPE(qs_rho_type), OPTIONAL, POINTER :: rho_external
625 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: external_vxc, mask
626 : TYPE(mp2_type), OPTIONAL, POINTER :: mp2_env
627 : TYPE(post_scf_bandstructure_type), OPTIONAL, &
628 : POINTER :: bs_env
629 : TYPE(kg_environment_type), OPTIONAL, POINTER :: kg_env
630 : TYPE(wannier_centres_type), DIMENSION(:), &
631 : OPTIONAL, POINTER :: WannierCentres
632 : TYPE(atprop_type), OPTIONAL, POINTER :: atprop
633 : TYPE(ls_scf_env_type), OPTIONAL, POINTER :: ls_scf_env
634 : LOGICAL, OPTIONAL :: do_transport
635 : TYPE(transport_env_type), OPTIONAL, POINTER :: transport_env
636 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: v_hartree_rspace
637 : LOGICAL, OPTIONAL :: s_mstruct_changed, rho_changed, &
638 : potential_changed, forces_up_to_date
639 : TYPE(molecular_scf_guess_env_type), OPTIONAL, &
640 : POINTER :: mscfg_env
641 : TYPE(almo_scf_env_type), OPTIONAL, POINTER :: almo_scf_env
642 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: gradient_history, variable_history
643 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: embed_pot, spin_embed_pot
644 : TYPE(polar_env_type), OPTIONAL, POINTER :: polar_env
645 : TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_last_converged
646 : REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: eeq, rhs
647 :
648 : TYPE(rho0_mpole_type), POINTER :: rho0_m
649 :
650 8566828 : NULLIFY (rho0_m)
651 8566828 : CPASSERT(ASSOCIATED(qs_env%ks_env))
652 :
653 8566828 : IF (PRESENT(outer_scf_history)) outer_scf_history => qs_env%outer_scf_history
654 8566828 : IF (PRESENT(outer_scf_ihistory)) outer_scf_ihistory = qs_env%outer_scf_ihistory
655 8566828 : IF (PRESENT(gradient_history)) gradient_history => qs_env%gradient_history
656 8566828 : IF (PRESENT(variable_history)) variable_history => qs_env%variable_history
657 8566828 : IF (PRESENT(mp2_env)) mp2_env => qs_env%mp2_env
658 8566828 : IF (PRESENT(bs_env)) bs_env => qs_env%bs_env
659 8566828 : IF (PRESENT(kg_env)) kg_env => qs_env%kg_env
660 8566828 : IF (PRESENT(super_cell)) super_cell => qs_env%super_cell
661 8566828 : IF (PRESENT(qmmm)) qmmm = qs_env%qmmm
662 8566828 : IF (PRESENT(qmmm_periodic)) qmmm_periodic = qs_env%qmmm_periodic
663 8566828 : IF (PRESENT(mos)) mos => qs_env%mos
664 8566828 : IF (PRESENT(mos_last_converged)) mos_last_converged => qs_env%mos_last_converged
665 8566828 : IF (PRESENT(ewald_env)) ewald_env => qs_env%ewald_env
666 8566828 : IF (PRESENT(ewald_pw)) ewald_pw => qs_env%ewald_pw
667 8566828 : IF (PRESENT(mpools)) mpools => qs_env%mpools
668 8566828 : IF (PRESENT(scf_control)) scf_control => qs_env%scf_control
669 8566828 : IF (PRESENT(rel_control)) rel_control => qs_env%rel_control
670 : ! ZMP pointing vectors
671 8566828 : IF (PRESENT(rho_external)) rho_external => qs_env%rho_external
672 8566828 : IF (PRESENT(external_vxc)) external_vxc => qs_env%external_vxc
673 8566828 : IF (PRESENT(mask)) mask => qs_env%mask
674 8566828 : IF (PRESENT(qs_charges)) qs_charges => qs_env%qs_charges
675 8566828 : IF (PRESENT(ks_env)) ks_env => qs_env%ks_env
676 8566828 : IF (PRESENT(ks_qmmm_env)) ks_qmmm_env => qs_env%ks_qmmm_env
677 8566828 : IF (PRESENT(wf_history)) wf_history => qs_env%wf_history
678 8566828 : IF (PRESENT(scf_env)) scf_env => qs_env%scf_env
679 8566828 : IF (PRESENT(oce)) oce => qs_env%oce
680 8566828 : IF (PRESENT(requires_mo_derivs)) requires_mo_derivs = qs_env%requires_mo_derivs
681 8566828 : IF (PRESENT(has_unit_metric)) has_unit_metric = qs_env%has_unit_metric
682 8566828 : IF (PRESENT(mo_derivs)) mo_derivs => qs_env%mo_derivs
683 8566828 : IF (PRESENT(mo_loc_history)) mo_loc_history => qs_env%mo_loc_history
684 8566828 : IF (PRESENT(linres_control)) linres_control => qs_env%linres_control
685 8566828 : IF (PRESENT(se_taper)) se_taper => qs_env%se_taper
686 8566828 : IF (PRESENT(se_store_int_env)) se_store_int_env => qs_env%se_store_int_env
687 8566828 : IF (PRESENT(se_nddo_mpole)) se_nddo_mpole => qs_env%se_nddo_mpole
688 8566828 : IF (PRESENT(se_nonbond_env)) se_nonbond_env => qs_env%se_nonbond_env
689 8566828 : IF (PRESENT(lri_env)) lri_env => qs_env%lri_env
690 8566828 : IF (PRESENT(lri_density)) lri_density => qs_env%lri_density
691 8566828 : IF (PRESENT(harris_env)) harris_env => qs_env%harris_env
692 8566828 : IF (PRESENT(ec_env)) ec_env => qs_env%ec_env
693 8566828 : IF (PRESENT(exstate_env)) exstate_env => qs_env%exstate_env
694 8566828 : IF (PRESENT(dispersion_env)) dispersion_env => qs_env%dispersion_env
695 8566828 : IF (PRESENT(gcp_env)) gcp_env => qs_env%gcp_env
696 8566828 : IF (PRESENT(run_rtp)) run_rtp = qs_env%run_rtp
697 8566828 : IF (PRESENT(rtp)) rtp => qs_env%rtp
698 8566828 : IF (PRESENT(ls_scf_env)) ls_scf_env => qs_env%ls_scf_env
699 8566828 : IF (PRESENT(almo_scf_env)) almo_scf_env => qs_env%almo_scf_env
700 8566828 : IF (PRESENT(do_transport)) do_transport = qs_env%do_transport
701 8566828 : IF (PRESENT(transport_env)) transport_env => qs_env%transport_env
702 8566828 : IF (PRESENT(mscfg_env)) mscfg_env => qs_env%molecular_scf_guess_env
703 8566828 : IF (PRESENT(active_space)) active_space => qs_env%active_space
704 8566828 : IF (PRESENT(admm_env)) admm_env => qs_env%admm_env
705 :
706 : ! Embedding potential
707 8566828 : IF (PRESENT(embed_pot)) embed_pot => qs_env%embed_pot
708 8566828 : IF (PRESENT(spin_embed_pot)) spin_embed_pot => qs_env%spin_embed_pot
709 :
710 : ! Polarisability tensor
711 8566828 : IF (PRESENT(polar_env)) polar_env => qs_env%polar_env
712 :
713 : ! EEQ charges
714 8566828 : IF (PRESENT(eeq)) eeq => qs_env%eeq
715 :
716 : ! Resp charges
717 8566828 : IF (PRESENT(rhs)) rhs => qs_env%rhs
718 :
719 8566828 : IF (PRESENT(local_rho_set)) &
720 13930 : local_rho_set => qs_env%local_rho_set
721 8566828 : IF (PRESENT(rho_atom_set)) &
722 98862 : CALL get_local_rho(qs_env%local_rho_set, rho_atom_set=rho_atom_set)
723 8566828 : IF (PRESENT(rho0_atom_set)) &
724 22794 : CALL get_local_rho(qs_env%local_rho_set, rho0_atom_set=rho0_atom_set)
725 8566828 : IF (PRESENT(rho0_mpole)) &
726 40972 : CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_mpole)
727 8566828 : IF (PRESENT(rhoz_set)) &
728 14 : CALL get_local_rho(qs_env%local_rho_set, rhoz_set=rhoz_set)
729 8566828 : IF (PRESENT(ecoul_1c)) &
730 13122 : CALL get_hartree_local(qs_env%hartree_local, ecoul_1c=ecoul_1c)
731 8566828 : IF (PRESENT(rho0_s_rs)) THEN
732 1488 : CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_m)
733 1488 : IF (ASSOCIATED(rho0_m)) THEN
734 1488 : rho0_s_rs => rho0_m%rho0_s_rs
735 : END IF
736 : END IF
737 8566828 : IF (PRESENT(rho0_s_gs)) THEN
738 18490 : CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_m)
739 18490 : IF (ASSOCIATED(rho0_m)) THEN
740 13336 : rho0_s_gs => rho0_m%rho0_s_gs
741 : END IF
742 : END IF
743 :
744 8566828 : IF (PRESENT(xas_env)) xas_env => qs_env%xas_env
745 8566828 : IF (PRESENT(input)) input => qs_env%input
746 8566828 : IF (PRESENT(cp_ddapc_env)) cp_ddapc_env => qs_env%cp_ddapc_env
747 8566828 : IF (PRESENT(cp_ddapc_ewald)) cp_ddapc_ewald => qs_env%cp_ddapc_ewald
748 8566828 : IF (PRESENT(x_data)) x_data => qs_env%x_data
749 8566828 : IF (PRESENT(et_coupling)) et_coupling => qs_env%et_coupling
750 8566828 : IF (PRESENT(dftb_potential)) dftb_potential => qs_env%dftb_potential
751 8566828 : IF (PRESENT(efield)) efield => qs_env%efield
752 8566828 : IF (PRESENT(WannierCentres)) WannierCentres => qs_env%WannierCentres
753 :
754 : CALL get_ks_env(qs_env%ks_env, &
755 : v_hartree_rspace=v_hartree_rspace, &
756 : s_mstruct_changed=s_mstruct_changed, &
757 : rho_changed=rho_changed, &
758 : potential_changed=potential_changed, &
759 : forces_up_to_date=forces_up_to_date, &
760 : matrix_h=matrix_h, &
761 : matrix_h_im=matrix_h_im, &
762 : matrix_ks=matrix_ks, &
763 : matrix_ks_im=matrix_ks_im, &
764 : matrix_vxc=matrix_vxc, &
765 : kinetic=kinetic, &
766 : matrix_s=matrix_s, &
767 : matrix_s_RI_aux=matrix_s_RI_aux, &
768 : matrix_ks_im_kp=matrix_ks_im_kp, &
769 : matrix_w=matrix_w, &
770 : matrix_p_mp2=matrix_p_mp2, &
771 : matrix_p_mp2_admm=matrix_p_mp2_admm, &
772 : matrix_h_kp=matrix_h_kp, &
773 : matrix_h_im_kp=matrix_h_im_kp, &
774 : matrix_ks_kp=matrix_ks_kp, &
775 : matrix_vxc_kp=matrix_vxc_kp, &
776 : kinetic_kp=kinetic_kp, &
777 : matrix_s_kp=matrix_s_kp, &
778 : matrix_w_kp=matrix_w_kp, &
779 : matrix_s_RI_aux_kp=matrix_s_RI_aux_kp, &
780 : rho=rho, &
781 : rho_xc=rho_xc, &
782 : rho_core=rho_core, &
783 : rho_nlcc=rho_nlcc, &
784 : rho_nlcc_g=rho_nlcc_g, &
785 : vppl=vppl, &
786 : vee=vee, &
787 : neighbor_list_id=neighbor_list_id, &
788 : sab_orb=sab_orb, &
789 : sab_all=sab_all, &
790 : sab_scp=sab_scp, &
791 : sab_vdw=sab_vdw, &
792 : sac_ae=sac_ae, &
793 : sac_ppl=sac_ppl, &
794 : sac_lri=sac_lri, &
795 : sap_ppnl=sap_ppnl, &
796 : sap_oce=sap_oce, &
797 : sab_se=sab_se, &
798 : sab_lrc=sab_lrc, &
799 : sab_tbe=sab_tbe, &
800 : sab_xtbe=sab_xtbe, &
801 : sab_core=sab_core, &
802 : sab_xb=sab_xb, &
803 : sab_xtb_pp=sab_xtb_pp, &
804 : sab_xtb_nonbond=sab_xtb_nonbond, &
805 : sab_almo=sab_almo, &
806 : sab_kp=sab_kp, &
807 : sab_kp_nosym=sab_kp_nosym, &
808 : task_list=task_list, &
809 : task_list_soft=task_list_soft, &
810 : kpoints=kpoints, &
811 : do_kpoints=do_kpoints, &
812 : local_molecules=local_molecules, &
813 : local_particles=local_particles, &
814 : atprop=atprop, &
815 : virial=virial, &
816 : results=results, &
817 : cell=cell, &
818 : cell_ref=cell_ref, &
819 : use_ref_cell=use_ref_cell, &
820 : energy=energy, &
821 : force=force, &
822 : qs_kind_set=qs_kind_set, &
823 : subsys=subsys, &
824 : cp_subsys=cp_subsys, &
825 : atomic_kind_set=atomic_kind_set, &
826 : particle_set=particle_set, &
827 : molecule_kind_set=molecule_kind_set, &
828 : molecule_set=molecule_set, &
829 : natom=natom, &
830 : nkind=nkind, &
831 : dft_control=dft_control, &
832 : dbcsr_dist=dbcsr_dist, &
833 : distribution_2d=distribution_2d, &
834 : pw_env=pw_env, &
835 : para_env=para_env, &
836 : blacs_env=blacs_env, &
837 : nelectron_total=nelectron_total, &
838 8566828 : nelectron_spin=nelectron_spin)
839 :
840 8566828 : END SUBROUTINE get_qs_env
841 :
842 : ! **************************************************************************************************
843 : !> \brief Initialise the QUICKSTEP environment.
844 : !> \param qs_env ...
845 : !> \param globenv ...
846 : !> \date 25.01.2002
847 : !> \author MK
848 : !> \version 1.0
849 : ! **************************************************************************************************
850 7366 : SUBROUTINE init_qs_env(qs_env, globenv)
851 :
852 : TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
853 : TYPE(global_environment_type), OPTIONAL, POINTER :: globenv
854 :
855 7366 : NULLIFY (qs_env%ls_scf_env)
856 7366 : NULLIFY (qs_env%almo_scf_env)
857 7366 : NULLIFY (qs_env%transport_env)
858 7366 : NULLIFY (qs_env%image_matrix)
859 7366 : NULLIFY (qs_env%ipiv)
860 7366 : NULLIFY (qs_env%image_coeff)
861 7366 : NULLIFY (qs_env%super_cell)
862 7366 : NULLIFY (qs_env%mos)
863 7366 : NULLIFY (qs_env%mos_last_converged)
864 7366 : NULLIFY (qs_env%mpools)
865 7366 : NULLIFY (qs_env%ewald_env)
866 7366 : NULLIFY (qs_env%ewald_pw)
867 7366 : NULLIFY (qs_env%scf_control)
868 7366 : NULLIFY (qs_env%rel_control)
869 7366 : NULLIFY (qs_env%qs_charges)
870 : ! ZMP initializing arrays
871 7366 : NULLIFY (qs_env%rho_external)
872 7366 : NULLIFY (qs_env%external_vxc)
873 7366 : NULLIFY (qs_env%mask)
874 : ! Embedding potential
875 7366 : NULLIFY (qs_env%embed_pot)
876 7366 : NULLIFY (qs_env%spin_embed_pot)
877 :
878 : ! Polarisability tensor
879 7366 : NULLIFY (qs_env%polar_env)
880 :
881 7366 : NULLIFY (qs_env%ks_env)
882 7366 : NULLIFY (qs_env%ks_qmmm_env)
883 7366 : NULLIFY (qs_env%wf_history)
884 7366 : NULLIFY (qs_env%scf_env)
885 7366 : NULLIFY (qs_env%oce)
886 7366 : NULLIFY (qs_env%local_rho_set)
887 7366 : NULLIFY (qs_env%hartree_local)
888 7366 : NULLIFY (qs_env%input)
889 7366 : NULLIFY (qs_env%linres_control)
890 7366 : NULLIFY (qs_env%xas_env)
891 7366 : NULLIFY (qs_env%cp_ddapc_env)
892 7366 : NULLIFY (qs_env%cp_ddapc_ewald)
893 7366 : NULLIFY (qs_env%outer_scf_history)
894 7366 : NULLIFY (qs_env%gradient_history)
895 7366 : NULLIFY (qs_env%variable_history)
896 7366 : NULLIFY (qs_env%x_data)
897 7366 : NULLIFY (qs_env%et_coupling)
898 7366 : NULLIFY (qs_env%dftb_potential)
899 7366 : NULLIFY (qs_env%active_space)
900 :
901 7366 : NULLIFY (qs_env%se_taper)
902 7366 : NULLIFY (qs_env%se_store_int_env)
903 7366 : NULLIFY (qs_env%se_nddo_mpole)
904 7366 : NULLIFY (qs_env%se_nonbond_env)
905 7366 : NULLIFY (qs_env%admm_env)
906 7366 : NULLIFY (qs_env%efield)
907 7366 : NULLIFY (qs_env%lri_env)
908 7366 : NULLIFY (qs_env%harris_env)
909 7366 : NULLIFY (qs_env%ec_env)
910 7366 : NULLIFY (qs_env%exstate_env)
911 7366 : NULLIFY (qs_env%lri_density)
912 7366 : NULLIFY (qs_env%gcp_env)
913 7366 : NULLIFY (qs_env%rtp)
914 7366 : NULLIFY (qs_env%mp2_env)
915 7366 : NULLIFY (qs_env%bs_env)
916 7366 : NULLIFY (qs_env%kg_env)
917 7366 : NULLIFY (qs_env%WannierCentres)
918 :
919 7366 : qs_env%outer_scf_ihistory = 0
920 7366 : qs_env%broyden_adaptive_sigma = -1.0_dp
921 :
922 7366 : CALL local_rho_set_create(qs_env%local_rho_set)
923 7366 : CALL hartree_local_create(qs_env%hartree_local)
924 7366 : qs_env%run_rtp = .FALSE.
925 7366 : qs_env%linres_run = .FALSE.
926 7366 : qs_env%single_point_run = .FALSE.
927 7366 : qs_env%qmmm = .FALSE.
928 7366 : qs_env%qmmm_periodic = .FALSE.
929 7366 : qs_env%requires_mo_derivs = .FALSE.
930 7366 : qs_env%requires_matrix_vxc = .FALSE.
931 7366 : qs_env%has_unit_metric = .FALSE.
932 7366 : qs_env%calc_image_preconditioner = .TRUE.
933 7366 : qs_env%do_transport = .FALSE.
934 7366 : qs_env%given_embed_pot = .FALSE.
935 7366 : IF (PRESENT(globenv)) THEN
936 7360 : qs_env%target_time = globenv%cp2k_target_time
937 7360 : qs_env%start_time = globenv%cp2k_start_time
938 : qs_env%single_point_run = (globenv%run_type_id == energy_run .OR. &
939 7360 : globenv%run_type_id == energy_force_run)
940 : ELSE
941 6 : qs_env%target_time = 0.0_dp
942 6 : qs_env%start_time = 0.0_dp
943 : END IF
944 :
945 7366 : qs_env%sim_time = 0._dp
946 7366 : qs_env%sim_step = 0
947 :
948 7366 : qs_env%total_zeff_corr = 0.0_dp
949 7366 : qs_env%surface_dipole_moment = 0.0_dp
950 7366 : qs_env%surface_dipole_switch_off = .FALSE.
951 :
952 : ! Zero all variables containing results
953 7366 : NULLIFY (qs_env%mo_derivs)
954 7366 : NULLIFY (qs_env%mo_loc_history)
955 :
956 7366 : IF (.NOT. ASSOCIATED(qs_env%molecular_scf_guess_env)) ALLOCATE (qs_env%molecular_scf_guess_env)
957 :
958 7366 : END SUBROUTINE init_qs_env
959 :
960 : ! **************************************************************************************************
961 : !> \brief Set the QUICKSTEP environment.
962 : !> \param qs_env ...
963 : !> \param super_cell ...
964 : !> \param mos ...
965 : !> \param qmmm ...
966 : !> \param qmmm_periodic ...
967 : !> \param ewald_env ...
968 : !> \param ewald_pw ...
969 : !> \param mpools ...
970 : !> \param rho_external ...
971 : !> \param external_vxc ...
972 : !> \param mask ...
973 : !> \param scf_control ...
974 : !> \param rel_control ...
975 : !> \param qs_charges ...
976 : !> \param ks_env ...
977 : !> \param ks_qmmm_env ...
978 : !> \param wf_history ...
979 : !> \param scf_env ...
980 : !> \param active_space ...
981 : !> \param input ...
982 : !> \param oce ...
983 : !> \param rho_atom_set ...
984 : !> \param rho0_atom_set ...
985 : !> \param rho0_mpole ...
986 : !> \param run_rtp ...
987 : !> \param rtp ...
988 : !> \param rhoz_set ...
989 : !> \param rhoz_tot ...
990 : !> \param ecoul_1c ...
991 : !> \param has_unit_metric ...
992 : !> \param requires_mo_derivs ...
993 : !> \param mo_derivs ...
994 : !> \param mo_loc_history ...
995 : !> \param efield ...
996 : !> \param linres_control ...
997 : !> \param xas_env ...
998 : !> \param cp_ddapc_env ...
999 : !> \param cp_ddapc_ewald ...
1000 : !> \param outer_scf_history ...
1001 : !> \param outer_scf_ihistory ...
1002 : !> \param x_data ...
1003 : !> \param et_coupling ...
1004 : !> \param dftb_potential ...
1005 : !> \param se_taper ...
1006 : !> \param se_store_int_env ...
1007 : !> \param se_nddo_mpole ...
1008 : !> \param se_nonbond_env ...
1009 : !> \param admm_env ...
1010 : !> \param ls_scf_env ...
1011 : !> \param do_transport ...
1012 : !> \param transport_env ...
1013 : !> \param lri_env ...
1014 : !> \param lri_density ...
1015 : !> \param exstate_env ...
1016 : !> \param ec_env ...
1017 : !> \param dispersion_env ...
1018 : !> \param harris_env ...
1019 : !> \param gcp_env ...
1020 : !> \param mp2_env ...
1021 : !> \param bs_env ...
1022 : !> \param kg_env ...
1023 : !> \param force ...
1024 : !> \param kpoints ...
1025 : !> \param WannierCentres ...
1026 : !> \param almo_scf_env ...
1027 : !> \param gradient_history ...
1028 : !> \param variable_history ...
1029 : !> \param embed_pot ...
1030 : !> \param spin_embed_pot ...
1031 : !> \param polar_env ...
1032 : !> \param mos_last_converged ... [SGh]
1033 : !> \param eeq ...
1034 : !> \param rhs ...
1035 : !> \date 23.01.2002
1036 : !> \author MK
1037 : !> \version 1.0
1038 : ! **************************************************************************************************
1039 152464 : SUBROUTINE set_qs_env(qs_env, super_cell, &
1040 : mos, qmmm, qmmm_periodic, &
1041 : ewald_env, ewald_pw, mpools, &
1042 : rho_external, external_vxc, mask, &
1043 : scf_control, rel_control, qs_charges, ks_env, &
1044 : ks_qmmm_env, wf_history, scf_env, active_space, &
1045 : input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, &
1046 : rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, &
1047 : mo_loc_history, efield, &
1048 : linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, &
1049 : outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, &
1050 : se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, &
1051 : do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, &
1052 : harris_env, gcp_env, mp2_env, bs_env, kg_env, force, &
1053 : kpoints, WannierCentres, almo_scf_env, gradient_history, variable_history, embed_pot, &
1054 : spin_embed_pot, polar_env, mos_last_converged, eeq, rhs)
1055 :
1056 : TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
1057 : TYPE(cell_type), OPTIONAL, POINTER :: super_cell
1058 : TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos
1059 : LOGICAL, OPTIONAL :: qmmm, qmmm_periodic
1060 : TYPE(ewald_environment_type), OPTIONAL, POINTER :: ewald_env
1061 : TYPE(ewald_pw_type), OPTIONAL, POINTER :: ewald_pw
1062 : TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
1063 : TYPE(qs_rho_type), OPTIONAL, POINTER :: rho_external
1064 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: external_vxc, mask
1065 : TYPE(scf_control_type), OPTIONAL, POINTER :: scf_control
1066 : TYPE(rel_control_type), OPTIONAL, POINTER :: rel_control
1067 : TYPE(qs_charges_type), OPTIONAL, POINTER :: qs_charges
1068 : TYPE(qs_ks_env_type), OPTIONAL, POINTER :: ks_env
1069 : TYPE(qs_ks_qmmm_env_type), OPTIONAL, POINTER :: ks_qmmm_env
1070 : TYPE(qs_wf_history_type), OPTIONAL, POINTER :: wf_history
1071 : TYPE(qs_scf_env_type), OPTIONAL, POINTER :: scf_env
1072 : TYPE(active_space_type), OPTIONAL, POINTER :: active_space
1073 : TYPE(section_vals_type), OPTIONAL, POINTER :: input
1074 : TYPE(oce_matrix_type), OPTIONAL, POINTER :: oce
1075 : TYPE(rho_atom_type), DIMENSION(:), OPTIONAL, &
1076 : POINTER :: rho_atom_set
1077 : TYPE(rho0_atom_type), DIMENSION(:), OPTIONAL, &
1078 : POINTER :: rho0_atom_set
1079 : TYPE(rho0_mpole_type), OPTIONAL, POINTER :: rho0_mpole
1080 : LOGICAL, OPTIONAL :: run_rtp
1081 : TYPE(rt_prop_type), OPTIONAL, POINTER :: rtp
1082 : TYPE(rhoz_type), DIMENSION(:), OPTIONAL, POINTER :: rhoz_set
1083 : REAL(dp), OPTIONAL :: rhoz_tot
1084 : TYPE(ecoul_1center_type), DIMENSION(:), OPTIONAL, &
1085 : POINTER :: ecoul_1c
1086 : LOGICAL, OPTIONAL :: has_unit_metric, requires_mo_derivs
1087 : TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
1088 : POINTER :: mo_derivs
1089 : TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: mo_loc_history
1090 : TYPE(efield_berry_type), OPTIONAL, POINTER :: efield
1091 : TYPE(linres_control_type), OPTIONAL, POINTER :: linres_control
1092 : TYPE(xas_environment_type), OPTIONAL, POINTER :: xas_env
1093 : TYPE(cp_ddapc_type), OPTIONAL, POINTER :: cp_ddapc_env
1094 : TYPE(cp_ddapc_ewald_type), OPTIONAL, POINTER :: cp_ddapc_ewald
1095 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: outer_scf_history
1096 : INTEGER, INTENT(IN), OPTIONAL :: outer_scf_ihistory
1097 : TYPE(hfx_type), DIMENSION(:, :), OPTIONAL, POINTER :: x_data
1098 : TYPE(et_coupling_type), OPTIONAL, POINTER :: et_coupling
1099 : TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), &
1100 : OPTIONAL, POINTER :: dftb_potential
1101 : TYPE(se_taper_type), OPTIONAL, POINTER :: se_taper
1102 : TYPE(semi_empirical_si_type), OPTIONAL, POINTER :: se_store_int_env
1103 : TYPE(nddo_mpole_type), OPTIONAL, POINTER :: se_nddo_mpole
1104 : TYPE(fist_nonbond_env_type), OPTIONAL, POINTER :: se_nonbond_env
1105 : TYPE(admm_type), OPTIONAL, POINTER :: admm_env
1106 : TYPE(ls_scf_env_type), OPTIONAL, POINTER :: ls_scf_env
1107 : LOGICAL, OPTIONAL :: do_transport
1108 : TYPE(transport_env_type), OPTIONAL, POINTER :: transport_env
1109 : TYPE(lri_environment_type), OPTIONAL, POINTER :: lri_env
1110 : TYPE(lri_density_type), OPTIONAL, POINTER :: lri_density
1111 : TYPE(excited_energy_type), OPTIONAL, POINTER :: exstate_env
1112 : TYPE(energy_correction_type), OPTIONAL, POINTER :: ec_env
1113 : TYPE(qs_dispersion_type), OPTIONAL, POINTER :: dispersion_env
1114 : TYPE(harris_type), OPTIONAL, POINTER :: harris_env
1115 : TYPE(qs_gcp_type), OPTIONAL, POINTER :: gcp_env
1116 : TYPE(mp2_type), OPTIONAL, POINTER :: mp2_env
1117 : TYPE(post_scf_bandstructure_type), OPTIONAL, &
1118 : POINTER :: bs_env
1119 : TYPE(kg_environment_type), OPTIONAL, POINTER :: kg_env
1120 : TYPE(qs_force_type), DIMENSION(:), OPTIONAL, &
1121 : POINTER :: force
1122 : TYPE(kpoint_type), OPTIONAL, POINTER :: kpoints
1123 : TYPE(wannier_centres_type), DIMENSION(:), &
1124 : OPTIONAL, POINTER :: WannierCentres
1125 : TYPE(almo_scf_env_type), OPTIONAL, POINTER :: almo_scf_env
1126 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: gradient_history, variable_history
1127 : TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: embed_pot, spin_embed_pot
1128 : TYPE(polar_env_type), OPTIONAL, POINTER :: polar_env
1129 : TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_last_converged
1130 : REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: eeq, rhs
1131 :
1132 : TYPE(qs_subsys_type), POINTER :: subsys
1133 :
1134 152464 : IF (PRESENT(mp2_env)) qs_env%mp2_env => mp2_env
1135 152464 : IF (PRESENT(bs_env)) qs_env%bs_env => bs_env
1136 152464 : IF (PRESENT(kg_env)) qs_env%kg_env => kg_env
1137 152464 : IF (PRESENT(super_cell)) THEN
1138 46 : CALL cell_retain(super_cell)
1139 46 : CALL cell_release(qs_env%super_cell)
1140 46 : qs_env%super_cell => super_cell
1141 : END IF
1142 : !
1143 152464 : IF (PRESENT(qmmm)) qs_env%qmmm = qmmm
1144 152464 : IF (PRESENT(qmmm_periodic)) qs_env%qmmm_periodic = qmmm_periodic
1145 152464 : IF (PRESENT(mos)) qs_env%mos => mos
1146 152464 : IF (PRESENT(mos_last_converged)) qs_env%mos_last_converged => mos_last_converged
1147 152464 : IF (PRESENT(ls_scf_env)) qs_env%ls_scf_env => ls_scf_env
1148 152464 : IF (PRESENT(almo_scf_env)) qs_env%almo_scf_env => almo_scf_env
1149 152464 : IF (PRESENT(do_transport)) qs_env%do_transport = do_transport
1150 152464 : IF (PRESENT(transport_env)) qs_env%transport_env => transport_env
1151 : ! if intels checking (-C) complains here, you have rediscovered a bug in the intel
1152 : ! compiler (present in at least 10.0.025). A testcase has been submitted to intel.
1153 152464 : IF (PRESENT(oce)) qs_env%oce => oce
1154 152464 : IF (PRESENT(outer_scf_history)) qs_env%outer_scf_history => outer_scf_history
1155 152464 : IF (PRESENT(gradient_history)) qs_env%gradient_history => gradient_history
1156 152464 : IF (PRESENT(variable_history)) qs_env%variable_history => variable_history
1157 152464 : IF (PRESENT(outer_scf_ihistory)) qs_env%outer_scf_ihistory = outer_scf_ihistory
1158 152464 : IF (PRESENT(requires_mo_derivs)) qs_env%requires_mo_derivs = requires_mo_derivs
1159 152464 : IF (PRESENT(has_unit_metric)) qs_env%has_unit_metric = has_unit_metric
1160 152464 : IF (PRESENT(mo_derivs)) qs_env%mo_derivs => mo_derivs
1161 152464 : IF (PRESENT(mo_loc_history)) qs_env%mo_loc_history => mo_loc_history
1162 152464 : IF (PRESENT(run_rtp)) qs_env%run_rtp = run_rtp
1163 152464 : IF (PRESENT(rtp)) qs_env%rtp => rtp
1164 152464 : IF (PRESENT(efield)) qs_env%efield => efield
1165 152464 : IF (PRESENT(active_space)) qs_env%active_space => active_space
1166 :
1167 152464 : IF (PRESENT(ewald_env)) THEN ! accept also null pointers?
1168 324 : IF (ASSOCIATED(qs_env%ewald_env)) THEN
1169 0 : IF (.NOT. ASSOCIATED(qs_env%ewald_env, ewald_env)) THEN
1170 0 : CALL ewald_env_release(qs_env%ewald_env)
1171 0 : DEALLOCATE (qs_env%ewald_env)
1172 : END IF
1173 : END IF
1174 324 : qs_env%ewald_env => ewald_env
1175 : END IF
1176 152464 : IF (PRESENT(ewald_pw)) THEN ! accept also null pointers?
1177 324 : IF (ASSOCIATED(qs_env%ewald_pw)) THEN
1178 0 : IF (.NOT. ASSOCIATED(ewald_pw, qs_env%ewald_pw)) THEN
1179 0 : CALL ewald_pw_release(qs_env%ewald_pw)
1180 0 : DEALLOCATE (qs_env%ewald_pw)
1181 : END IF
1182 : END IF
1183 324 : qs_env%ewald_pw => ewald_pw
1184 : END IF
1185 152464 : IF (PRESENT(scf_control)) THEN ! accept also null pointers?
1186 7366 : IF (ASSOCIATED(qs_env%scf_control)) THEN
1187 0 : IF (.NOT. ASSOCIATED(qs_env%scf_control, scf_control)) THEN
1188 0 : CALL scf_c_release(qs_env%scf_control)
1189 0 : DEALLOCATE (qs_env%scf_control)
1190 : END IF
1191 : END IF
1192 7366 : qs_env%scf_control => scf_control
1193 : END IF
1194 152464 : IF (PRESENT(rel_control)) THEN ! accept also null pointers?
1195 7366 : IF (ASSOCIATED(qs_env%rel_control)) THEN
1196 0 : IF (.NOT. ASSOCIATED(qs_env%rel_control, rel_control)) THEN
1197 0 : CALL rel_c_release(qs_env%rel_control)
1198 0 : DEALLOCATE (qs_env%rel_control)
1199 : END IF
1200 : END IF
1201 7366 : qs_env%rel_control => rel_control
1202 : END IF
1203 152464 : IF (PRESENT(linres_control)) THEN ! accept also null pointers?
1204 1634 : IF (ASSOCIATED(qs_env%linres_control)) THEN
1205 614 : IF (.NOT. ASSOCIATED(qs_env%linres_control, linres_control)) THEN
1206 614 : CALL linres_control_release(qs_env%linres_control)
1207 614 : DEALLOCATE (qs_env%linres_control)
1208 : END IF
1209 : END IF
1210 1634 : qs_env%linres_control => linres_control
1211 : END IF
1212 : ! ZMP associating variables
1213 152464 : IF (PRESENT(rho_external)) THEN
1214 0 : IF (ASSOCIATED(qs_env%rho_external)) THEN
1215 0 : IF (.NOT. ASSOCIATED(qs_env%rho_external, rho_external)) THEN
1216 0 : CALL qs_rho_release(qs_env%rho_external)
1217 0 : DEALLOCATE (qs_env%rho_external)
1218 : END IF
1219 : END IF
1220 0 : qs_env%rho_external => rho_external
1221 : END IF
1222 152464 : IF (PRESENT(external_vxc)) qs_env%external_vxc => external_vxc
1223 152464 : IF (PRESENT(mask)) qs_env%mask => mask
1224 : ! Embedding potential
1225 152464 : IF (PRESENT(embed_pot)) qs_env%embed_pot => embed_pot
1226 152464 : IF (PRESENT(spin_embed_pot)) qs_env%spin_embed_pot => spin_embed_pot
1227 :
1228 : ! Polarisability tensor
1229 152464 : IF (PRESENT(polar_env)) qs_env%polar_env => polar_env
1230 :
1231 152464 : IF (PRESENT(qs_charges)) THEN
1232 7366 : IF (ASSOCIATED(qs_env%qs_charges)) THEN
1233 0 : IF (.NOT. ASSOCIATED(qs_env%qs_charges, qs_charges)) THEN
1234 0 : CALL qs_charges_release(qs_env%qs_charges)
1235 0 : DEALLOCATE (qs_env%qs_charges)
1236 : END IF
1237 : END IF
1238 7366 : qs_env%qs_charges => qs_charges
1239 : END IF
1240 152464 : IF (PRESENT(ks_qmmm_env)) THEN
1241 378 : IF (ASSOCIATED(qs_env%ks_qmmm_env)) THEN
1242 0 : IF (.NOT. ASSOCIATED(qs_env%ks_qmmm_env, ks_qmmm_env)) THEN
1243 0 : CALL qs_ks_qmmm_release(qs_env%ks_qmmm_env)
1244 0 : DEALLOCATE (qs_env%ks_qmmm_env)
1245 : END IF
1246 : END IF
1247 378 : qs_env%ks_qmmm_env => ks_qmmm_env
1248 : END IF
1249 152464 : IF (PRESENT(ks_env)) THEN ! accept also null pointers?
1250 7366 : IF (ASSOCIATED(qs_env%ks_env)) THEN
1251 0 : IF (.NOT. ASSOCIATED(qs_env%ks_env, ks_env)) THEN
1252 0 : CALL qs_ks_release(qs_env%ks_env)
1253 0 : DEALLOCATE (qs_env%ks_env)
1254 : END IF
1255 : END IF
1256 7366 : qs_env%ks_env => ks_env
1257 : END IF
1258 152464 : IF (PRESENT(wf_history)) THEN ! accept also null pointers ?
1259 7738 : CALL wfi_retain(wf_history)
1260 7738 : CALL wfi_release(qs_env%wf_history)
1261 7738 : qs_env%wf_history => wf_history
1262 : END IF
1263 152464 : IF (PRESENT(scf_env)) THEN ! accept also null pointers ?
1264 6327 : IF (ASSOCIATED(qs_env%scf_env)) THEN
1265 50 : IF (.NOT. ASSOCIATED(qs_env%scf_env, scf_env)) THEN
1266 50 : CALL scf_env_release(qs_env%scf_env)
1267 50 : DEALLOCATE (qs_env%scf_env)
1268 : END IF
1269 : END IF
1270 6327 : qs_env%scf_env => scf_env
1271 : END IF
1272 152464 : IF (PRESENT(xas_env)) THEN ! accept also null pointers?
1273 42 : IF (ASSOCIATED(qs_env%xas_env)) THEN
1274 0 : IF (.NOT. ASSOCIATED(qs_env%xas_env, xas_env)) THEN
1275 0 : CALL xas_env_release(qs_env%xas_env)
1276 0 : DEALLOCATE (qs_env%xas_env)
1277 : END IF
1278 : END IF
1279 42 : qs_env%xas_env => xas_env
1280 : END IF
1281 152464 : IF (PRESENT(mpools)) THEN
1282 0 : CALL mpools_retain(mpools)
1283 0 : CALL mpools_release(qs_env%mpools)
1284 0 : qs_env%mpools => mpools
1285 : END IF
1286 152464 : IF (PRESENT(rho_atom_set)) THEN
1287 922 : CALL set_local_rho(qs_env%local_rho_set, rho_atom_set=rho_atom_set)
1288 : END IF
1289 152464 : IF (PRESENT(rho0_atom_set)) THEN
1290 0 : CALL set_local_rho(qs_env%local_rho_set, rho0_atom_set=rho0_atom_set)
1291 : END IF
1292 152464 : IF (PRESENT(rho0_mpole)) THEN
1293 0 : CALL set_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_mpole)
1294 : END IF
1295 152464 : IF (PRESENT(rhoz_set)) THEN
1296 0 : CALL set_local_rho(qs_env%local_rho_set, rhoz_set=rhoz_set)
1297 : END IF
1298 152464 : IF (PRESENT(rhoz_tot)) qs_env%local_rho_set%rhoz_tot = rhoz_tot
1299 152464 : IF (PRESENT(ecoul_1c)) THEN
1300 0 : CALL set_hartree_local(qs_env%hartree_local, ecoul_1c=ecoul_1c)
1301 : END IF
1302 152464 : IF (PRESENT(input)) THEN
1303 7366 : CALL section_vals_retain(input)
1304 7366 : CALL section_vals_release(qs_env%input)
1305 7366 : qs_env%input => input
1306 : END IF
1307 152464 : IF (PRESENT(cp_ddapc_env)) THEN
1308 0 : IF (ASSOCIATED(qs_env%cp_ddapc_env)) THEN
1309 0 : IF (.NOT. ASSOCIATED(qs_env%cp_ddapc_env, cp_ddapc_env)) THEN
1310 0 : CALL cp_ddapc_release(qs_env%cp_ddapc_env)
1311 0 : DEALLOCATE (qs_env%cp_ddapc_env)
1312 : END IF
1313 : END IF
1314 0 : qs_env%cp_ddapc_env => cp_ddapc_env
1315 : END IF
1316 152464 : IF (PRESENT(cp_ddapc_ewald)) THEN
1317 0 : qs_env%cp_ddapc_ewald => cp_ddapc_ewald
1318 : END IF
1319 152464 : IF (PRESENT(x_data)) qs_env%x_data => x_data
1320 152464 : IF (PRESENT(et_coupling)) qs_env%et_coupling => et_coupling
1321 152464 : IF (PRESENT(dftb_potential)) qs_env%dftb_potential => dftb_potential
1322 152464 : IF (PRESENT(se_taper)) THEN
1323 998 : CALL se_taper_release(qs_env%se_taper)
1324 998 : qs_env%se_taper => se_taper
1325 : END IF
1326 152464 : IF (PRESENT(se_store_int_env)) THEN
1327 998 : CALL semi_empirical_si_release(qs_env%se_store_int_env)
1328 998 : qs_env%se_store_int_env => se_store_int_env
1329 : END IF
1330 152464 : IF (PRESENT(se_nddo_mpole)) THEN
1331 32 : CALL nddo_mpole_release(qs_env%se_nddo_mpole)
1332 32 : qs_env%se_nddo_mpole => se_nddo_mpole
1333 : END IF
1334 152464 : IF (PRESENT(se_nonbond_env)) THEN
1335 32 : IF (ASSOCIATED(qs_env%se_nonbond_env)) THEN
1336 0 : IF (.NOT. ASSOCIATED(qs_env%se_nonbond_env, se_nonbond_env)) THEN
1337 0 : CALL fist_nonbond_env_release(qs_env%se_nonbond_env)
1338 0 : DEALLOCATE (qs_env%se_nonbond_env)
1339 : END IF
1340 : END IF
1341 32 : qs_env%se_nonbond_env => se_nonbond_env
1342 : END IF
1343 152464 : IF (PRESENT(admm_env)) qs_env%admm_env => admm_env
1344 152464 : IF (PRESENT(lri_env)) qs_env%lri_env => lri_env
1345 152464 : IF (PRESENT(lri_density)) qs_env%lri_density => lri_density
1346 152464 : IF (PRESENT(harris_env)) qs_env%harris_env => harris_env
1347 152464 : IF (PRESENT(ec_env)) qs_env%ec_env => ec_env
1348 152464 : IF (PRESENT(exstate_env)) qs_env%exstate_env => exstate_env
1349 152464 : IF (PRESENT(dispersion_env)) qs_env%dispersion_env => dispersion_env
1350 152464 : IF (PRESENT(gcp_env)) qs_env%gcp_env => gcp_env
1351 152464 : IF (PRESENT(WannierCentres)) qs_env%WannierCentres => WannierCentres
1352 152464 : IF (PRESENT(kpoints)) CALL set_ks_env(qs_env%ks_env, kpoints=kpoints)
1353 :
1354 : ! EEQ charges
1355 152464 : IF (PRESENT(eeq)) qs_env%eeq => eeq
1356 :
1357 : ! Resp charges
1358 152464 : IF (PRESENT(rhs)) qs_env%rhs => rhs
1359 :
1360 152464 : IF (PRESENT(force)) THEN
1361 2248 : CALL get_qs_env(qs_env, subsys=subsys)
1362 2248 : CALL qs_subsys_set(subsys, force=force)
1363 : END IF
1364 :
1365 152464 : END SUBROUTINE set_qs_env
1366 :
1367 : ! **************************************************************************************************
1368 : !> \brief allocates and intitializes a qs_env
1369 : !> \param qs_env the object to create
1370 : !> \param globenv ...
1371 : !> \par History
1372 : !> 12.2002 created [fawzi]
1373 : !> \author Fawzi Mohamed
1374 : ! **************************************************************************************************
1375 7366 : SUBROUTINE qs_env_create(qs_env, globenv)
1376 : TYPE(qs_environment_type), INTENT(OUT) :: qs_env
1377 : TYPE(global_environment_type), OPTIONAL, POINTER :: globenv
1378 :
1379 7366 : CALL init_qs_env(qs_env, globenv=globenv)
1380 7366 : END SUBROUTINE qs_env_create
1381 :
1382 : ! **************************************************************************************************
1383 : !> \brief releases the given qs_env (see doc/ReferenceCounting.html)
1384 : !> \param qs_env the object to release
1385 : !> \par History
1386 : !> 12.2002 created [fawzi]
1387 : !> 06.2018 polar_env added (MK)
1388 : !> \author Fawzi Mohamed
1389 : ! **************************************************************************************************
1390 7366 : SUBROUTINE qs_env_release(qs_env)
1391 : TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
1392 :
1393 : INTEGER :: i
1394 :
1395 7366 : CALL cell_release(qs_env%super_cell)
1396 7366 : IF (ASSOCIATED(qs_env%mos)) THEN
1397 15655 : DO i = 1, SIZE(qs_env%mos)
1398 15655 : CALL deallocate_mo_set(qs_env%mos(i))
1399 : END DO
1400 7028 : DEALLOCATE (qs_env%mos)
1401 : END IF
1402 7366 : IF (ASSOCIATED(qs_env%mos_last_converged)) THEN
1403 4 : DO i = 1, SIZE(qs_env%mos_last_converged)
1404 4 : CALL deallocate_mo_set(qs_env%mos_last_converged(i))
1405 : END DO
1406 2 : DEALLOCATE (qs_env%mos_last_converged)
1407 : END IF
1408 :
1409 7366 : IF (ASSOCIATED(qs_env%mo_derivs)) THEN
1410 4495 : DO I = 1, SIZE(qs_env%mo_derivs)
1411 4495 : CALL dbcsr_release_p(qs_env%mo_derivs(I)%matrix)
1412 : END DO
1413 1953 : DEALLOCATE (qs_env%mo_derivs)
1414 : END IF
1415 :
1416 7366 : CALL cp_fm_release(qs_env%mo_loc_history)
1417 :
1418 7366 : IF (ASSOCIATED(qs_env%rtp)) THEN
1419 198 : CALL rt_prop_release(qs_env%rtp)
1420 198 : DEALLOCATE (qs_env%rtp)
1421 : END IF
1422 7366 : IF (ASSOCIATED(qs_env%outer_scf_history)) THEN
1423 1293 : DEALLOCATE (qs_env%outer_scf_history)
1424 1293 : qs_env%outer_scf_ihistory = 0
1425 : END IF
1426 7366 : IF (ASSOCIATED(qs_env%gradient_history)) &
1427 1293 : DEALLOCATE (qs_env%gradient_history)
1428 7366 : IF (ASSOCIATED(qs_env%variable_history)) &
1429 1293 : DEALLOCATE (qs_env%variable_history)
1430 7366 : IF (ASSOCIATED(qs_env%oce)) CALL deallocate_oce_set(qs_env%oce)
1431 7366 : IF (ASSOCIATED(qs_env%local_rho_set)) THEN
1432 7357 : CALL local_rho_set_release(qs_env%local_rho_set)
1433 : END IF
1434 7366 : IF (ASSOCIATED(qs_env%hartree_local)) THEN
1435 7357 : CALL hartree_local_release(qs_env%hartree_local)
1436 : END IF
1437 7366 : IF (ASSOCIATED(qs_env%scf_control)) THEN
1438 7357 : CALL scf_c_release(qs_env%scf_control)
1439 7357 : DEALLOCATE (qs_env%scf_control)
1440 : END IF
1441 7366 : IF (ASSOCIATED(qs_env%rel_control)) THEN
1442 7357 : CALL rel_c_release(qs_env%rel_control)
1443 7357 : DEALLOCATE (qs_env%rel_control)
1444 : END IF
1445 :
1446 7366 : IF (ASSOCIATED(qs_env%linres_control)) THEN
1447 1020 : CALL linres_control_release(qs_env%linres_control)
1448 1020 : DEALLOCATE (qs_env%linres_control)
1449 : END IF
1450 :
1451 7366 : IF (ASSOCIATED(qs_env%almo_scf_env)) THEN
1452 66 : CALL almo_scf_env_release(qs_env%almo_scf_env)
1453 : END IF
1454 :
1455 7366 : IF (ASSOCIATED(qs_env%ls_scf_env)) THEN
1456 336 : CALL ls_scf_release(qs_env%ls_scf_env)
1457 : END IF
1458 7366 : IF (ASSOCIATED(qs_env%molecular_scf_guess_env)) THEN
1459 7357 : CALL molecular_scf_guess_env_destroy(qs_env%molecular_scf_guess_env)
1460 7357 : DEALLOCATE (qs_env%molecular_scf_guess_env)
1461 : END IF
1462 :
1463 7366 : IF (ASSOCIATED(qs_env%transport_env)) THEN
1464 0 : CALL transport_env_release(qs_env%transport_env)
1465 : END IF
1466 :
1467 : !Only if do_xas_calculation
1468 7366 : IF (ASSOCIATED(qs_env%xas_env)) THEN
1469 0 : CALL xas_env_release(qs_env%xas_env)
1470 0 : DEALLOCATE (qs_env%xas_env)
1471 : END IF
1472 7366 : IF (ASSOCIATED(qs_env%ewald_env)) THEN
1473 324 : CALL ewald_env_release(qs_env%ewald_env)
1474 324 : DEALLOCATE (qs_env%ewald_env)
1475 : END IF
1476 7366 : IF (ASSOCIATED(qs_env%ewald_pw)) THEN
1477 324 : CALL ewald_pw_release(qs_env%ewald_pw)
1478 324 : DEALLOCATE (qs_env%ewald_pw)
1479 : END IF
1480 7366 : IF (ASSOCIATED(qs_env%image_matrix)) THEN
1481 10 : DEALLOCATE (qs_env%image_matrix)
1482 : END IF
1483 7366 : IF (ASSOCIATED(qs_env%ipiv)) THEN
1484 8 : DEALLOCATE (qs_env%ipiv)
1485 : END IF
1486 7366 : IF (ASSOCIATED(qs_env%image_coeff)) THEN
1487 10 : DEALLOCATE (qs_env%image_coeff)
1488 : END IF
1489 : ! ZMP
1490 7366 : IF (ASSOCIATED(qs_env%rho_external)) THEN
1491 0 : CALL qs_rho_release(qs_env%rho_external)
1492 0 : DEALLOCATE (qs_env%rho_external)
1493 : END IF
1494 7366 : IF (ASSOCIATED(qs_env%external_vxc)) THEN
1495 0 : CALL qs_env%external_vxc%release()
1496 0 : DEALLOCATE (qs_env%external_vxc)
1497 : END IF
1498 7366 : IF (ASSOCIATED(qs_env%mask)) THEN
1499 0 : CALL qs_env%mask%release()
1500 0 : DEALLOCATE (qs_env%mask)
1501 : END IF
1502 7366 : IF (ASSOCIATED(qs_env%active_space)) THEN
1503 106 : CALL release_active_space_type(qs_env%active_space)
1504 : END IF
1505 : ! Embedding potentials if provided as input
1506 7366 : IF (qs_env%given_embed_pot) THEN
1507 2 : CALL qs_env%embed_pot%release()
1508 2 : DEALLOCATE (qs_env%embed_pot)
1509 2 : IF (ASSOCIATED(qs_env%spin_embed_pot)) THEN
1510 2 : CALL qs_env%spin_embed_pot%release()
1511 2 : DEALLOCATE (qs_env%spin_embed_pot)
1512 : END IF
1513 : END IF
1514 :
1515 : ! Polarisability tensor
1516 7366 : CALL polar_env_release(qs_env%polar_env)
1517 :
1518 7366 : IF (ASSOCIATED(qs_env%qs_charges)) THEN
1519 7357 : CALL qs_charges_release(qs_env%qs_charges)
1520 7357 : DEALLOCATE (qs_env%qs_charges)
1521 : END IF
1522 7366 : IF (ASSOCIATED(qs_env%ks_env)) THEN
1523 7366 : CALL qs_ks_release(qs_env%ks_env)
1524 7366 : DEALLOCATE (qs_env%ks_env)
1525 : END IF
1526 7366 : IF (ASSOCIATED(qs_env%ks_qmmm_env)) THEN
1527 378 : CALL qs_ks_qmmm_release(qs_env%ks_qmmm_env)
1528 378 : DEALLOCATE (qs_env%ks_qmmm_env)
1529 : END IF
1530 7366 : CALL wfi_release(qs_env%wf_history)
1531 7366 : IF (ASSOCIATED(qs_env%scf_env)) THEN
1532 6277 : CALL scf_env_release(qs_env%scf_env)
1533 6277 : DEALLOCATE (qs_env%scf_env)
1534 : END IF
1535 7366 : CALL mpools_release(qs_env%mpools)
1536 7366 : CALL section_vals_release(qs_env%input)
1537 7366 : IF (ASSOCIATED(qs_env%cp_ddapc_env)) THEN
1538 118 : CALL cp_ddapc_release(qs_env%cp_ddapc_env)
1539 118 : DEALLOCATE (qs_env%cp_ddapc_env)
1540 : END IF
1541 7366 : CALL cp_ddapc_ewald_release(qs_env%cp_ddapc_ewald)
1542 7366 : CALL efield_berry_release(qs_env%efield)
1543 7366 : IF (ASSOCIATED(qs_env%x_data)) THEN
1544 1182 : CALL hfx_release(qs_env%x_data)
1545 : END IF
1546 7366 : IF (ASSOCIATED(qs_env%et_coupling)) THEN
1547 10 : CALL et_coupling_release(qs_env%et_coupling)
1548 : END IF
1549 7366 : IF (ASSOCIATED(qs_env%dftb_potential)) THEN
1550 222 : CALL qs_dftb_pairpot_release(qs_env%dftb_potential)
1551 : END IF
1552 7366 : IF (ASSOCIATED(qs_env%se_taper)) THEN
1553 998 : CALL se_taper_release(qs_env%se_taper)
1554 : END IF
1555 7366 : IF (ASSOCIATED(qs_env%se_store_int_env)) THEN
1556 998 : CALL semi_empirical_si_release(qs_env%se_store_int_env)
1557 : END IF
1558 7366 : IF (ASSOCIATED(qs_env%se_nddo_mpole)) THEN
1559 32 : CALL nddo_mpole_release(qs_env%se_nddo_mpole)
1560 : END IF
1561 7366 : IF (ASSOCIATED(qs_env%se_nonbond_env)) THEN
1562 32 : CALL fist_nonbond_env_release(qs_env%se_nonbond_env)
1563 32 : DEALLOCATE (qs_env%se_nonbond_env)
1564 : END IF
1565 7366 : IF (ASSOCIATED(qs_env%admm_env)) THEN
1566 442 : CALL admm_env_release(qs_env%admm_env)
1567 : END IF
1568 7366 : IF (ASSOCIATED(qs_env%lri_env)) THEN
1569 46 : CALL lri_env_release(qs_env%lri_env)
1570 46 : DEALLOCATE (qs_env%lri_env)
1571 : END IF
1572 7366 : IF (ASSOCIATED(qs_env%lri_density)) THEN
1573 46 : CALL lri_density_release(qs_env%lri_density)
1574 46 : DEALLOCATE (qs_env%lri_density)
1575 : END IF
1576 7366 : IF (ASSOCIATED(qs_env%harris_env)) THEN
1577 7357 : CALL harris_env_release(qs_env%harris_env)
1578 : END IF
1579 7366 : IF (ASSOCIATED(qs_env%ec_env)) THEN
1580 7357 : CALL ec_env_release(qs_env%ec_env)
1581 : END IF
1582 7366 : IF (ASSOCIATED(qs_env%exstate_env)) THEN
1583 7357 : CALL exstate_release(qs_env%exstate_env)
1584 : END IF
1585 7366 : IF (ASSOCIATED(qs_env%mp2_env)) THEN
1586 476 : CALL mp2_env_release(qs_env%mp2_env)
1587 6188 : DEALLOCATE (qs_env%mp2_env)
1588 : NULLIFY (qs_env%mp2_env)
1589 : END IF
1590 7366 : IF (ASSOCIATED(qs_env%bs_env)) THEN
1591 34 : CALL bs_env_release(qs_env%bs_env)
1592 : END IF
1593 7366 : IF (ASSOCIATED(qs_env%kg_env)) THEN
1594 66 : CALL kg_env_release(qs_env%kg_env)
1595 : END IF
1596 :
1597 : ! dispersion
1598 7366 : CALL qs_dispersion_release(qs_env%dispersion_env)
1599 : ! gCP
1600 7366 : IF (ASSOCIATED(qs_env%gcp_env)) THEN
1601 5197 : CALL qs_gcp_release(qs_env%gcp_env)
1602 : END IF
1603 :
1604 7366 : IF (ASSOCIATED(qs_env%WannierCentres)) THEN
1605 12 : DO i = 1, SIZE(qs_env%WannierCentres)
1606 6 : DEALLOCATE (qs_env%WannierCentres(i)%WannierHamDiag)
1607 12 : DEALLOCATE (qs_env%WannierCentres(i)%centres)
1608 : END DO
1609 6 : DEALLOCATE (qs_env%WannierCentres)
1610 : END IF
1611 : ! EEQ charges
1612 7366 : IF (ASSOCIATED(qs_env%eeq)) DEALLOCATE (qs_env%eeq)
1613 : ! Resp charges
1614 7366 : IF (ASSOCIATED(qs_env%rhs)) DEALLOCATE (qs_env%rhs)
1615 :
1616 7366 : END SUBROUTINE qs_env_release
1617 :
1618 : ! **************************************************************************************************
1619 : !> \brief releases part of the given qs_env in order to save memory
1620 : !> \param qs_env the object to release
1621 : !> \par History
1622 : !> 04.2022 created [JGH]
1623 : ! **************************************************************************************************
1624 9 : SUBROUTINE qs_env_part_release(qs_env)
1625 : TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
1626 :
1627 : INTEGER :: i
1628 :
1629 9 : IF (ASSOCIATED(qs_env%mos_last_converged)) THEN
1630 0 : DO i = 1, SIZE(qs_env%mos_last_converged)
1631 0 : CALL deallocate_mo_set(qs_env%mos_last_converged(i))
1632 : END DO
1633 0 : DEALLOCATE (qs_env%mos_last_converged)
1634 : END IF
1635 :
1636 9 : IF (ASSOCIATED(qs_env%mo_derivs)) THEN
1637 0 : DO I = 1, SIZE(qs_env%mo_derivs)
1638 0 : CALL dbcsr_release_p(qs_env%mo_derivs(I)%matrix)
1639 : END DO
1640 0 : DEALLOCATE (qs_env%mo_derivs)
1641 : END IF
1642 :
1643 9 : CALL cp_fm_release(qs_env%mo_loc_history)
1644 :
1645 9 : IF (ASSOCIATED(qs_env%rtp)) THEN
1646 0 : CALL rt_prop_release(qs_env%rtp)
1647 0 : DEALLOCATE (qs_env%rtp)
1648 : END IF
1649 9 : IF (ASSOCIATED(qs_env%outer_scf_history)) THEN
1650 0 : DEALLOCATE (qs_env%outer_scf_history)
1651 0 : qs_env%outer_scf_ihistory = 0
1652 : END IF
1653 9 : IF (ASSOCIATED(qs_env%gradient_history)) &
1654 0 : DEALLOCATE (qs_env%gradient_history)
1655 9 : IF (ASSOCIATED(qs_env%variable_history)) &
1656 0 : DEALLOCATE (qs_env%variable_history)
1657 9 : IF (ASSOCIATED(qs_env%oce)) CALL deallocate_oce_set(qs_env%oce)
1658 9 : IF (ASSOCIATED(qs_env%local_rho_set)) THEN
1659 9 : CALL local_rho_set_release(qs_env%local_rho_set)
1660 : END IF
1661 9 : IF (ASSOCIATED(qs_env%hartree_local)) THEN
1662 9 : CALL hartree_local_release(qs_env%hartree_local)
1663 : END IF
1664 9 : IF (ASSOCIATED(qs_env%scf_control)) THEN
1665 9 : CALL scf_c_release(qs_env%scf_control)
1666 9 : DEALLOCATE (qs_env%scf_control)
1667 : END IF
1668 9 : IF (ASSOCIATED(qs_env%rel_control)) THEN
1669 9 : CALL rel_c_release(qs_env%rel_control)
1670 9 : DEALLOCATE (qs_env%rel_control)
1671 : END IF
1672 :
1673 9 : IF (ASSOCIATED(qs_env%linres_control)) THEN
1674 0 : CALL linres_control_release(qs_env%linres_control)
1675 0 : DEALLOCATE (qs_env%linres_control)
1676 : END IF
1677 :
1678 9 : IF (ASSOCIATED(qs_env%almo_scf_env)) THEN
1679 0 : CALL almo_scf_env_release(qs_env%almo_scf_env)
1680 : END IF
1681 :
1682 9 : IF (ASSOCIATED(qs_env%ls_scf_env)) THEN
1683 0 : CALL ls_scf_release(qs_env%ls_scf_env)
1684 : END IF
1685 9 : IF (ASSOCIATED(qs_env%molecular_scf_guess_env)) THEN
1686 9 : CALL molecular_scf_guess_env_destroy(qs_env%molecular_scf_guess_env)
1687 9 : DEALLOCATE (qs_env%molecular_scf_guess_env)
1688 : END IF
1689 :
1690 9 : IF (ASSOCIATED(qs_env%transport_env)) THEN
1691 0 : CALL transport_env_release(qs_env%transport_env)
1692 : END IF
1693 :
1694 : !Only if do_xas_calculation
1695 9 : IF (ASSOCIATED(qs_env%xas_env)) THEN
1696 0 : CALL xas_env_release(qs_env%xas_env)
1697 0 : DEALLOCATE (qs_env%xas_env)
1698 : END IF
1699 9 : IF (ASSOCIATED(qs_env%ewald_env)) THEN
1700 0 : CALL ewald_env_release(qs_env%ewald_env)
1701 0 : DEALLOCATE (qs_env%ewald_env)
1702 : END IF
1703 9 : IF (ASSOCIATED(qs_env%ewald_pw)) THEN
1704 0 : CALL ewald_pw_release(qs_env%ewald_pw)
1705 0 : DEALLOCATE (qs_env%ewald_pw)
1706 : END IF
1707 9 : IF (ASSOCIATED(qs_env%image_matrix)) THEN
1708 0 : DEALLOCATE (qs_env%image_matrix)
1709 : END IF
1710 9 : IF (ASSOCIATED(qs_env%ipiv)) THEN
1711 0 : DEALLOCATE (qs_env%ipiv)
1712 : END IF
1713 9 : IF (ASSOCIATED(qs_env%image_coeff)) THEN
1714 0 : DEALLOCATE (qs_env%image_coeff)
1715 : END IF
1716 : ! ZMP
1717 9 : IF (ASSOCIATED(qs_env%rho_external)) THEN
1718 0 : CALL qs_rho_release(qs_env%rho_external)
1719 0 : DEALLOCATE (qs_env%rho_external)
1720 : END IF
1721 9 : IF (ASSOCIATED(qs_env%external_vxc)) THEN
1722 0 : CALL qs_env%external_vxc%release()
1723 0 : DEALLOCATE (qs_env%external_vxc)
1724 : END IF
1725 9 : IF (ASSOCIATED(qs_env%mask)) THEN
1726 0 : CALL qs_env%mask%release()
1727 0 : DEALLOCATE (qs_env%mask)
1728 : END IF
1729 9 : IF (ASSOCIATED(qs_env%active_space)) THEN
1730 0 : CALL release_active_space_type(qs_env%active_space)
1731 : END IF
1732 : ! Embedding potentials if provided as input
1733 9 : IF (qs_env%given_embed_pot) THEN
1734 0 : CALL qs_env%embed_pot%release()
1735 0 : DEALLOCATE (qs_env%embed_pot)
1736 0 : IF (ASSOCIATED(qs_env%spin_embed_pot)) THEN
1737 0 : CALL qs_env%spin_embed_pot%release()
1738 0 : DEALLOCATE (qs_env%spin_embed_pot)
1739 : END IF
1740 : END IF
1741 :
1742 : ! Polarisability tensor
1743 9 : CALL polar_env_release(qs_env%polar_env)
1744 :
1745 9 : IF (ASSOCIATED(qs_env%qs_charges)) THEN
1746 9 : CALL qs_charges_release(qs_env%qs_charges)
1747 9 : DEALLOCATE (qs_env%qs_charges)
1748 : END IF
1749 9 : CALL qs_ks_part_release(qs_env%ks_env)
1750 9 : IF (ASSOCIATED(qs_env%ks_qmmm_env)) THEN
1751 0 : CALL qs_ks_qmmm_release(qs_env%ks_qmmm_env)
1752 0 : DEALLOCATE (qs_env%ks_qmmm_env)
1753 : END IF
1754 9 : CALL wfi_release(qs_env%wf_history)
1755 9 : IF (ASSOCIATED(qs_env%scf_env)) THEN
1756 0 : CALL scf_env_release(qs_env%scf_env)
1757 0 : DEALLOCATE (qs_env%scf_env)
1758 : END IF
1759 9 : IF (ASSOCIATED(qs_env%cp_ddapc_env)) THEN
1760 0 : CALL cp_ddapc_release(qs_env%cp_ddapc_env)
1761 0 : DEALLOCATE (qs_env%cp_ddapc_env)
1762 : END IF
1763 9 : CALL cp_ddapc_ewald_release(qs_env%cp_ddapc_ewald)
1764 9 : CALL efield_berry_release(qs_env%efield)
1765 9 : IF (ASSOCIATED(qs_env%x_data)) THEN
1766 0 : CALL hfx_release(qs_env%x_data)
1767 : END IF
1768 9 : IF (ASSOCIATED(qs_env%et_coupling)) THEN
1769 0 : CALL et_coupling_release(qs_env%et_coupling)
1770 : END IF
1771 9 : IF (ASSOCIATED(qs_env%dftb_potential)) THEN
1772 0 : CALL qs_dftb_pairpot_release(qs_env%dftb_potential)
1773 : END IF
1774 9 : IF (ASSOCIATED(qs_env%se_taper)) THEN
1775 0 : CALL se_taper_release(qs_env%se_taper)
1776 : END IF
1777 9 : IF (ASSOCIATED(qs_env%se_store_int_env)) THEN
1778 0 : CALL semi_empirical_si_release(qs_env%se_store_int_env)
1779 : END IF
1780 9 : IF (ASSOCIATED(qs_env%se_nddo_mpole)) THEN
1781 0 : CALL nddo_mpole_release(qs_env%se_nddo_mpole)
1782 : END IF
1783 9 : IF (ASSOCIATED(qs_env%se_nonbond_env)) THEN
1784 0 : CALL fist_nonbond_env_release(qs_env%se_nonbond_env)
1785 0 : DEALLOCATE (qs_env%se_nonbond_env)
1786 : END IF
1787 9 : IF (ASSOCIATED(qs_env%admm_env)) THEN
1788 0 : CALL admm_env_release(qs_env%admm_env)
1789 : END IF
1790 9 : IF (ASSOCIATED(qs_env%lri_env)) THEN
1791 0 : CALL lri_env_release(qs_env%lri_env)
1792 0 : DEALLOCATE (qs_env%lri_env)
1793 : END IF
1794 9 : IF (ASSOCIATED(qs_env%lri_density)) THEN
1795 0 : CALL lri_density_release(qs_env%lri_density)
1796 0 : DEALLOCATE (qs_env%lri_density)
1797 : END IF
1798 9 : IF (ASSOCIATED(qs_env%harris_env)) THEN
1799 9 : CALL harris_env_release(qs_env%harris_env)
1800 : END IF
1801 9 : IF (ASSOCIATED(qs_env%ec_env)) THEN
1802 9 : CALL ec_env_release(qs_env%ec_env)
1803 : END IF
1804 9 : IF (ASSOCIATED(qs_env%exstate_env)) THEN
1805 9 : CALL exstate_release(qs_env%exstate_env)
1806 : END IF
1807 9 : IF (ASSOCIATED(qs_env%mp2_env)) THEN
1808 0 : CALL mp2_env_release(qs_env%mp2_env)
1809 0 : DEALLOCATE (qs_env%mp2_env)
1810 : NULLIFY (qs_env%mp2_env)
1811 : END IF
1812 9 : IF (ASSOCIATED(qs_env%kg_env)) THEN
1813 0 : CALL kg_env_release(qs_env%kg_env)
1814 : END IF
1815 :
1816 : ! dispersion
1817 9 : CALL qs_dispersion_release(qs_env%dispersion_env)
1818 : ! gCP
1819 9 : IF (ASSOCIATED(qs_env%gcp_env)) THEN
1820 9 : CALL qs_gcp_release(qs_env%gcp_env)
1821 : END IF
1822 :
1823 9 : IF (ASSOCIATED(qs_env%WannierCentres)) THEN
1824 0 : DO i = 1, SIZE(qs_env%WannierCentres)
1825 0 : DEALLOCATE (qs_env%WannierCentres(i)%WannierHamDiag)
1826 0 : DEALLOCATE (qs_env%WannierCentres(i)%centres)
1827 : END DO
1828 0 : DEALLOCATE (qs_env%WannierCentres)
1829 : END IF
1830 : ! EEQ charges
1831 9 : IF (ASSOCIATED(qs_env%eeq)) DEALLOCATE (qs_env%eeq)
1832 : ! Resp charges
1833 9 : IF (ASSOCIATED(qs_env%rhs)) DEALLOCATE (qs_env%rhs)
1834 :
1835 9 : END SUBROUTINE qs_env_part_release
1836 :
1837 0 : END MODULE qs_environment_types
|