LCOV - code coverage report
Current view: top level - src - qs_environment_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:a43c040) Lines: 81.6 % 657 536
Test Date: 2026-02-12 06:45:40 Functions: 85.7 % 7 6

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

Generated by: LCOV version 2.0-1