From d98bda5b1175ef06b0095250b28f9e1c55f3cd05 Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Thu, 27 May 2021 12:33:08 -0500 Subject: [PATCH] save determinants directory when save_wavefunction_general_complex is called added option to turn this on or off determinants/backup_determinants_dir (default True) tars the determinants directory and moves the tar to ezfio/save/determinants/determinants.nstate.ndet.tar gzip doesn't save any significant space (the large parts are already gzipped) saves one backup per nstate,ndet pair --- scripts/save_current_dets.sh | 41 ++++++++++++++++++++++++ src/determinants/EZFIO.cfg | 5 +++ src/determinants/determinants_cplx.irp.f | 3 ++ 3 files changed, 49 insertions(+) create mode 100755 scripts/save_current_dets.sh diff --git a/scripts/save_current_dets.sh b/scripts/save_current_dets.sh new file mode 100755 index 00000000..252a57e2 --- /dev/null +++ b/scripts/save_current_dets.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# This script is used by the determinants module, and should not be used by users. +# It copies the EZFIO/determinants directory to EZFIO/save/determinants/determinants.n_det + + +if [[ -z ${QP_ROOT} ]] ; then + print "The QP_ROOT environment variable is not set." + print "Please reload the quantum_package.rc file." + exit -1 +fi + +EZFIO="$1" + +if [[ -z "${EZFIO}" ]] ; then + echo "Error in $0" + exit 1 +fi + +NDET=$(head -1 "${EZFIO}/determinants/n_det" | xargs printf "%09d") #xargs trims the result +NSTATE=$(head -1 "${EZFIO}/determinants/n_states" | xargs) #xargs trims the result +DESTINATION="save/determinants/determinants.${NSTATE}.${NDET}.tar" + +cd "${EZFIO}" + +BACKUP="${DESTINATION}.old" +if [[ -f "${BACKUP}" ]] ; then + rm -f "${BACKUP}" +fi + +if [[ -f "${DESTINATION}" ]] ; then + mv "${DESTINATION}" "${BACKUP}" +fi +if [[ ! -d save/determinants ]] ; then + mkdir -p save/determinants +fi + +tar cf ${DESTINATION} determinants +#tar cf dets_tmp.tar determinants +#mv --backup=t dets_tmp.tar ${DESTINATION} + + diff --git a/src/determinants/EZFIO.cfg b/src/determinants/EZFIO.cfg index b03ab374..5d633758 100644 --- a/src/determinants/EZFIO.cfg +++ b/src/determinants/EZFIO.cfg @@ -148,3 +148,8 @@ doc: If |true|, discard any Slater determinants with an interaction smaller than interface: ezfio,provider,ocaml default: False +[backup_determinants_dir] +type: logical +doc: If |true|, make a copy of the existing determinants directory before saving a new wavefunction. +interface: ezfio,provider,ocaml +default: True diff --git a/src/determinants/determinants_cplx.irp.f b/src/determinants/determinants_cplx.irp.f index 76e4d9fc..b0fbbb15 100644 --- a/src/determinants/determinants_cplx.irp.f +++ b/src/determinants/determinants_cplx.irp.f @@ -205,6 +205,9 @@ subroutine save_wavefunction_general_complex(ndet,nstates,psidet,dim_psicoef,psi integer :: i,j,k, ndet_qp_edit if (mpi_master) then + if (backup_determinants_dir) then + call system('$QP_ROOT/scripts/save_current_dets.sh '//trim(ezfio_filename)) + endif ndet_qp_edit = min(ndet,N_det_qp_edit) call ezfio_set_determinants_N_int(N_int)