1C
2C     rt_tddft_params_clean.F
3C
4C     Deallocates all universal GAs, parameters, etc.
5C
6      subroutine rt_tddft_clean (params)
7      implicit none
8
9#include "errquit.fh"
10#include "mafdecls.fh"
11#include "stdio.fh"
12#include "global.fh"
13#include "cdft.fh"
14#include "geom.fh"
15#include "rt_tddft.fh"
16#include "bas.fh"
17
18
19C     == Inputs ==
20      type(rt_params_t), intent(in) :: params
21
22
23C     == Parameters ==
24      character(*), parameter :: pname = "rt_tddft_clean: "
25
26
27C     == Variables ==
28      logical ok
29      integer ik, ig
30
31
32
33C
34C     Clean up dipole and quadrupole integrals.
35C
36      ok = .true.
37
38      ok = ok .and. ga_destroy(params%g_dip%x)
39      ok = ok .and. ga_destroy(params%g_dip%y)
40      ok = ok .and. ga_destroy(params%g_dip%z)
41
42      ok = ok .and. ga_destroy (params%g_quad%xx)
43      ok = ok .and. ga_destroy (params%g_quad%xy)
44      ok = ok .and. ga_destroy (params%g_quad%xz)
45      ok = ok .and. ga_destroy (params%g_quad%yy)
46      ok = ok .and. ga_destroy (params%g_quad%yz)
47      ok = ok .and. ga_destroy (params%g_quad%zz)
48
49      if (.not.ok)
50     $     call errquit(pname//"g_dip, g_quad destroy failed", 0,GA_ERR)
51
52
53C
54C     Clean up 1e integrals
55C
56      if (.not. ga_destroy (params%g_fock_ao_core))
57     $     call errquit (pname//"destroy failed", 0, GA_ERR)
58
59
60C
61C     Clean up 2e and CD fitting integrals.
62C
63      call fock_2e_tidy (params%rtdb)
64
65      if (cdfit) then
66         if (.not. ma_pop_stack (params%l_3cwhat)) then
67            call ma_summarize_allocated_blocks()
68             call errquit (pname//"failed to pop 3cwhat",
69     C           params%l_3cwhat, MA_ERR)
70          endif
71
72         if (.not. ma_pop_stack (params%l_3ceri))
73     $        call errquit (pname//"failed to pop 3ceri", 0, MA_ERR)
74      endif
75
76
77C
78C     Clean up geometry masks.
79C
80      do ig = 1, params%ngeoms
81         if (.not. ga_destroy (params%geom(ig)%g_mask))
82     $        call errquit (pname//"failed to destroy mask",0,GA_ERR)
83      enddo
84
85
86C
87C     Clean up CAP.
88C
89      if (params%cap_active) then
90         if (.not. ga_destroy (params%g_zcap))
91     $        call errquit (pname//"failed to destroy zcap",0,GA_ERR)
92      endif
93
94
95C
96C     Clean up canonical orthogonalization transforms.
97C
98      call canorg_clean (params)
99
100CXXX  [KAL]: CLEAN UP ZORA HERE
101
102
103CXXX  [KAL]: Needed if using ECP?  FIX THIS (need clean slate for dplot)!
104C      call int_ecp_terminate ()
105
106      end subroutine rt_tddft_clean
107
108
109c $Id$
110