From a24adaabbc7247805a5270add48eefd91386d64c Mon Sep 17 00:00:00 2001 From: Oscar Baseggio Date: Mon, 26 Apr 2021 16:07:04 +0200 Subject: [PATCH] Reduce disk usage and clean buffer for Sternheimer algorithm --- TDDFPT/src/lr_init_nfo.f90 | 10 ++++------ TDDFPT/src/lr_sternheimer.f90 | 2 +- TDDFPT/src/lr_variables.f90 | 1 - TDDFPT/src/stop_lr.f90 | 8 +++++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/TDDFPT/src/lr_init_nfo.f90 b/TDDFPT/src/lr_init_nfo.f90 index 8f8bb9868..d3bb9bafd 100644 --- a/TDDFPT/src/lr_init_nfo.f90 +++ b/TDDFPT/src/lr_init_nfo.f90 @@ -21,7 +21,7 @@ SUBROUTINE lr_init_nfo() USE klist, ONLY : nks,xk,ngk,igk_k USE wvfct, ONLY : nbnd USE lr_variables, ONLY : lr_verbosity, eels, size_evc, calculator, & - & lrdrho, nwordd0psi, iund0psi, iudwf, iu1dwf,& + & iund0psi, iudwf, iu1dwf,& & iundvpsi USE io_global, ONLY : stdout USE constants, ONLY : tpi, eps8 @@ -99,11 +99,9 @@ SUBROUTINE lr_init_nfo() size_evc = nbnd * npwx * npol * nksq nwordwfc = nbnd * npwx * npol IF (trim(calculator)=='sternheimer') THEN - lrdrho = 2 * dfftp%nr1x * dfftp%nr2x * dfftp%nr3x * nspin_mag - nwordd0psi = nbnd * npwx * npol * nksq - CALL open_buffer ( iundvpsi, 'dvpsi.', nwordd0psi, io_level, exst_mem, exst) - CALL open_buffer ( iudwf, 'dwf', nwordd0psi, io_level, exst_mem, exst) - CALL open_buffer ( iu1dwf, 'mwf', nwordd0psi, io_level, exst_mem, exst) + CALL open_buffer ( iundvpsi, 'dvpsi.', nwordwfc, io_level, exst_mem, exst) + CALL open_buffer ( iudwf, 'dwf', nwordwfc, io_level, exst_mem, exst) + CALL open_buffer ( iu1dwf, 'mwf', nwordwfc, io_level, exst_mem, exst) ! ENDIF ! diff --git a/TDDFPT/src/lr_sternheimer.f90 b/TDDFPT/src/lr_sternheimer.f90 index 759a5680e..61df30e21 100644 --- a/TDDFPT/src/lr_sternheimer.f90 +++ b/TDDFPT/src/lr_sternheimer.f90 @@ -69,7 +69,7 @@ SUBROUTINE one_sternheimer_step(iu, flag) USE mp, ONLY : mp_sum USE fft_helper_subroutines, ONLY : fftx_ntgrp USE lr_variables, ONLY : fru, fiu, iundvpsi, iudwf, & - lrdrho, iudrho, n_ipol, lr_verbosity, & + iudrho, n_ipol, lr_verbosity, & chirr, chirz, chizr, chizz, epsm1, & current_w, lr1dwf, iu1dwf, itermax!, & !intq, intq_nc diff --git a/TDDFPT/src/lr_variables.f90 b/TDDFPT/src/lr_variables.f90 index bcd803c30..26f68b60b 100644 --- a/TDDFPT/src/lr_variables.f90 +++ b/TDDFPT/src/lr_variables.f90 @@ -60,7 +60,6 @@ MODULE lr_variables INTEGER :: iudwf = 24 INTEGER :: iudrho = 23 INTEGER :: iu1dwf = 25 - INTEGER :: lrdrho REAL(kind=dp) :: increment INTEGER :: units REAL(kind=dp) :: end diff --git a/TDDFPT/src/stop_lr.f90 b/TDDFPT/src/stop_lr.f90 index 863de4047..7fe4c619a 100644 --- a/TDDFPT/src/stop_lr.f90 +++ b/TDDFPT/src/stop_lr.f90 @@ -16,7 +16,8 @@ SUBROUTINE stop_lr( full_run ) USE lr_variables, ONLY : n_ipol, LR_polarization, beta_store, & & gamma_store, zeta_store, norm0, code1,code2, & & lr_verbosity, itermax, bgz_suffix, & - eels, q1, q2, q3 + & eels, q1, q2, q3, calculator, iundvpsi, iudwf,& + & iu1dwf USE io_global, ONLY : ionode, stdout USE io_files, ONLY : tmp_dir, prefix, iunwfc USE environment, ONLY : environment_end @@ -144,6 +145,11 @@ SUBROUTINE stop_lr( full_run ) ! EELS: Close the file where it read the wavefunctions at k and k+q. ! IF (eels) CALL close_buffer(iunwfc, 'keep') + IF ( trim(calculator)=='sternheimer' ) THEN + CALL close_buffer ( iundvpsi,'delete' ) + CALL close_buffer ( iudwf,'delete' ) + CALL close_buffer ( iu1dwf,'delete' ) + ENDIF ! STOP !