2
C rt_tddft_cs_restart.F
4
C Routines for dumping and reading in restart point info.
6
subroutine rt_tddft_cs_restart_save (params, it, tt, g_zdens_ao)
10
#include "mafdecls.fh"
16
#include "matutils.fh"
17
#include "rt_tddft.fh"
20
type(rt_params_t), intent(in) :: params
21
integer, intent(in) :: it
22
double precision, intent(in) :: tt
23
integer, intent(in) :: g_zdens_ao
27
character(*), parameter :: pname = "rt_tddft_cs_restart_save: "
32
integer g_densre_ao, g_densim_ao
33
character(255) fname_re, fname_im
35
double precision checksum
36
double precision elapsed
39
if (params%prof) call prof_start (elapsed)
41
if (params%ipol .ne. 1)
42
$ call errquit (pname//"only valid for ipol = 1",0,0)
46
C First, store current time in rtdb. Note we put both it and tt
47
C which is redundant, but we check that tt = tmin + (it-1)*dt when
50
if (.not.rtdb_put(params%rtdb,'rt_tddft:rest_it', mt_int, 1, it))
51
$ call errquit(pname//'Write failed rest_it to rtdb',
54
if (.not.rtdb_put(params%rtdb,'rt_tddft:rest_tt', mt_dbl, 1, tt))
55
$ call errquit(pname//'Write failed rest_tt to rtdb',
60
C Also store some other params (so we can check when we restart).
62
CXXX [KAL]: ns_ao, ns_mo
66
C Compute and store checksum for complex dens mat.
68
checksum = zmat_checksum (g_zdens_ao)
70
if (.not.rtdb_put(params%rtdb,'rt_tddft:rest_checksum',
71
$ mt_dbl, 1, checksum))
72
$ call errquit(pname//'Write failed rest_checksum to rtdb',
77
C Dump dens mat in AO basis to file. Note we do real and imag parts
80
n = params%ns_ao !alias for clarity
83
ok = ok.and.ga_create(mt_dbl, n, n, "Re[P]", 0, 0, g_densre_ao)
84
ok = ok.and.ga_create(mt_dbl, n, n, "Im[P]", 0, 0, g_densim_ao)
86
if (.not.ok) call errquit(pname//"GA allocation failed", 0,GA_ERR)
88
call convert_z2d (g_zdens_ao, g_densre_ao, g_densim_ao)
90
call util_file_name ("densmat_ao_re", .false., .false., fname_re)
91
call util_file_name ("densmat_ao_im", .false., .false., fname_im)
93
if (.not. dmat_io_dump (g_densre_ao, fname_re))
94
$ call errquit (pname//"failed to dump densao_re",0,0)
96
if (.not. dmat_io_dump (g_densim_ao, fname_im))
97
$ call errquit (pname//"failed to dump densao_im",0,0)
104
ok = ok .and. ga_destroy(g_densre_ao)
105
ok = ok .and. ga_destroy(g_densim_ao)
106
if (.not.ok) call errquit(pname//"failed to destroy GAs", 0,0)
108
if (params%prof) call prof_end (elapsed, "Saving restart point")
112
C====================================================================
114
C Load info from previous restart point.
116
subroutine rt_tddft_cs_restart_load (params, it, tt, g_zdens_ao)
119
#include "errquit.fh"
120
#include "mafdecls.fh"
126
#include "matutils.fh"
127
#include "rt_tddft.fh"
130
type(rt_params_t), intent(in) :: params
131
integer, intent(in) :: g_zdens_ao !the GA value will be updated
135
character(*), parameter :: pname = "rt_tddft_cs_restart_load: "
144
double precision checksum, rest_checksum
146
integer g_densre_ao, g_densim_ao
147
character(255) fname_re, fname_im
149
double precision tdiff
150
double precision elapsed
153
call rt_tddft_cs_confirm (params)
155
if (params%prof) call prof_start (elapsed)
159
C Read in previous time values.
161
if (.not.rtdb_get (params%rtdb,"rt_tddft:rest_it",mt_int, 1, it))
162
$ call errquit (pname//"failed to read rest_it from rtdb",0,0)
164
if (.not.rtdb_get (params%rtdb,"rt_tddft:rest_tt",mt_dbl, 1, tt))
165
$ call errquit (pname//"failed to read rest_tt from rtdb",0,0)
167
tdiff = tt - (params%tmin + (it-1)*params%dt)
168
if ( abs(tdiff) > 1d-4 ) then
169
call errquit (pname//"inconsistent rest_it, rest_tt",0,0)
173
if (.not.rtdb_get (params%rtdb,"rt_tddft:rest_checksum",
174
$ mt_dbl, 1, rest_checksum)) call errquit (pname//
175
$ "failed to read rest_checksum from rtdb",0,0)
179
C Read in complex dens mat in AO basis.
181
call util_file_name ("densmat_ao_re", .false., .false., fname_re)
182
call util_file_name ("densmat_ao_im", .false., .false., fname_im)
184
n = params%ns_ao !alias for clarity
187
ok = ok.and.ga_create(mt_dbl, n, n, "Re[P]", 0, 0, g_densre_ao)
188
ok = ok.and.ga_create(mt_dbl, n, n, "Im[P]", 0, 0, g_densim_ao)
190
if (.not. dmat_io_read (g_densre_ao, fname_re))
191
$ call errquit (pname//"failed to read densao_re",0,0)
193
if (.not. dmat_io_read (g_densim_ao, fname_im))
194
$ call errquit (pname//"failed to read densao_im",0,0)
198
C Load real and im parts into complex GA and check that checksum is
201
call convert_d2z (1d0, g_densre_ao, 1d0, g_densim_ao, g_zdens_ao)
203
checksum = zmat_checksum (g_zdens_ao)
205
if ( abs(checksum - rest_checksum) > params%tol_zero) !warning: hardcoded tol_zero
206
$ call errquit (pname//
207
$ "bad checksum while importing dens mat",0,0)
210
ok = ok .and. ga_destroy(g_densre_ao)
211
ok = ok .and. ga_destroy(g_densim_ao)
212
if (.not.ok) call errquit(pname//"failed to destroy GAs", 0,0)
215
if (params%prof) call prof_end (elapsed, "Loading restart point")