From d6e206a64fb22d814d0b131ab93fc598fe985f2b Mon Sep 17 00:00:00 2001 From: Paolo Giannozzi Date: Fri, 20 Oct 2023 14:25:25 +0200 Subject: [PATCH] Misc changes and cleanup of I/O - Honor the disk_io='none' und 'nowf' options also when a run is interrupted - 'nowf' does what it promises but saves the charge density - previous 'nowf' replaced by new 'minimal' option - punch.f90 says more of what is written there - documentation aligned to new behavior --- Doc/release-notes | 3 +- PW/Doc/INPUT_PW.def | 9 ++++- PW/src/beef.f90 | 2 - PW/src/close_files.f90 | 44 +++++++++------------ PW/src/electrons.f90 | 10 ++--- PW/src/input.f90 | 6 ++- PW/src/punch.f90 | 87 ++++++++++++++++++++++++++---------------- PW/src/run_pwscf.f90 | 3 +- 8 files changed, 91 insertions(+), 73 deletions(-) diff --git a/Doc/release-notes b/Doc/release-notes index 8807b8c59..848ceed59 100644 --- a/Doc/release-notes +++ b/Doc/release-notes @@ -2,7 +2,8 @@ New in development version: * Experimental support for pseudopotentials in PSML format Incompatible changes in development version: - * None known + * Small changes in options "iprint" and "disk_io" of PWscf + * More pseudopotential-related code restructured and moved to upflib/ Fixed in development version: * Incorrect PP_SEMILOCAL field written for old-style pseudopotentials. diff --git a/PW/Doc/INPUT_PW.def b/PW/Doc/INPUT_PW.def index 1f681853d..1ecaa2fc5 100644 --- a/PW/Doc/INPUT_PW.def +++ b/PW/Doc/INPUT_PW.def @@ -361,8 +361,13 @@ input_description -distribution {Quantum ESPRESSO} -package PWscf -program pw.x } opt -val 'nowf' { - save to disk only the xml data file, - never save wavefunctions and charge density + save to disk only the xml data file and the charge density + at convergence, never save wavefunctions. Restarting from + an interrupted calculation is not possible with this option. + } + + opt -val 'minimal' { + save to disk only the xml data file at convergence } opt -val 'none' { diff --git a/PW/src/beef.f90 b/PW/src/beef.f90 index e60b3b5c0..1d8b8520e 100644 --- a/PW/src/beef.f90 +++ b/PW/src/beef.f90 @@ -35,7 +35,6 @@ SUBROUTINE beef_energies( ) USE io_global, ONLY : stdout, ionode USE xc_lib, ONLY : xclib_dft_is - USE control_flags, ONLY : io_level USE ener, ONLY : vtxc, etxc USE scf, ONLY : rho, rho_core, rhog_core, v ! @@ -106,7 +105,6 @@ SUBROUTINE beef_print( ) !------------------------------------------------------------------------- USE io_global, ONLY : stdout, ionode - USE control_flags, ONLY : io_level implicit none integer :: i diff --git a/PW/src/close_files.f90 b/PW/src/close_files.f90 index d24f75e45..8f39c5c3a 100644 --- a/PW/src/close_files.f90 +++ b/PW/src/close_files.f90 @@ -31,15 +31,22 @@ SUBROUTINE close_files( lflag ) ! LOGICAL, INTENT(IN) :: lflag ! + CHARACTER(LEN=6) :: close_option LOGICAL :: opnd ! + ! ... delete buffers + ! ... 1) at convergence, unless high disk I/O is required + ! ... 2) always, if minimal disk I/O is required + ! + IF ( (lflag .AND. io_level == 0) .OR. (io_level < 0) ) THEN + close_option = 'DELETE' + ELSE + close_option = 'KEEP' + END IF + ! ! ... close buffer/file containing wavefunctions ! - IF ( lflag .AND. (io_level <= 0) ) THEN - CALL close_buffer ( iunwfc, 'DELETE' ) - ELSE - CALL close_buffer ( iunwfc, 'KEEP' ) - END IF + CALL close_buffer ( iunwfc, close_option ) ! ! ... close files associated with the EXX calculation ! @@ -50,35 +57,19 @@ SUBROUTINE close_files( lflag ) ! ... iunhub as above, only for wfcs * S having an associated Hubbard U ! IF ( lda_plus_u .AND. (Hubbard_projectors /= 'pseudo') ) THEN - IF ( io_level < 0 ) THEN - CALL close_buffer( iunhub, 'DELETE' ) - ELSE - CALL close_buffer( iunhub, 'KEEP' ) - END IF + CALL close_buffer( iunhub, close_option ) END IF ! IF ( use_wannier .OR. one_atom_occupations ) THEN - IF ( io_level < 0 ) THEN - CALL close_buffer( iunsat,'DELETE' ) - ELSE - CALL close_buffer( iunsat,'KEEP' ) - END IF + CALL close_buffer( iunsat, close_option ) END IF ! ! ... close unit for electric field if needed ! IF ( lelfield ) THEN - ! - IF ( io_level < 0 ) THEN - CALL close_buffer( iunefield, 'DELETE' ) - CALL close_buffer( iunefieldm,'DELETE' ) - CALL close_buffer( iunefieldp,'DELETE' ) - ELSE - CALL close_buffer( iunefield, 'KEEP' ) - CALL close_buffer( iunefieldm,'KEEP' ) - CALL close_buffer( iunefieldp,'KEEP' ) - ENDIF - ! + CALL close_buffer( iunefield, close_option ) + CALL close_buffer( iunefieldm, close_option ) + CALL close_buffer( iunefieldp, close_option ) END IF #if defined (__OSCDFT) IF (use_oscdft) CALL oscdft_close_files(oscdft_ctx) @@ -86,7 +77,6 @@ SUBROUTINE close_files( lflag ) ! CALL mp_barrier( intra_image_comm ) ! - ! RETURN ! END SUBROUTINE close_files diff --git a/PW/src/electrons.f90 b/PW/src/electrons.f90 index 2910156c3..1c924d9cd 100644 --- a/PW/src/electrons.f90 +++ b/PW/src/electrons.f90 @@ -1187,14 +1187,14 @@ SUBROUTINE electrons_scf ( printout, exxen ) ! 10 FLUSH( stdout ) ! - ! ... exiting: write (unless disabled) the charge density to file - ! ... (also write ldaU ns coefficients and PAW becsum) + ! ... exiting: unless disabled by user (disk_io='minimal' or 'none'), + ! ... write charge density (also ldaU ns coefficients and PAW becsum) ! - IF ( io_level > -1 ) CALL write_scf( rho, nspin ) + IF ( io_level > -2 ) CALL write_scf( rho, nspin ) ! - ! ... delete mixing info if converged, keep it if not + ! ... keep mixing info if no converged achieved, delete it otherwise ! - IF ( conv_elec ) THEN + IF ( conv_elec .or. io_level < 0 ) THEN CALL close_mix_file( iunmix, 'delete' ) ELSE CALL close_mix_file( iunmix, 'keep' ) diff --git a/PW/src/input.f90 b/PW/src/input.f90 index d9f98c069..7e3d3d1f3 100644 --- a/PW/src/input.f90 +++ b/PW/src/input.f90 @@ -1063,10 +1063,14 @@ SUBROUTINE control_iosys() ! io_level = -1 ! - CASE ( 'none' ) + CASE ( 'minimal' ) ! io_level = -2 ! + CASE ( 'none' ) + ! + io_level = -3 + ! CASE DEFAULT ! ! In the scf case, it is usually convenient to write to RAM; diff --git a/PW/src/punch.f90 b/PW/src/punch.f90 index 36bf80f48..6e98141ef 100644 --- a/PW/src/punch.f90 +++ b/PW/src/punch.f90 @@ -1,5 +1,5 @@ ! -! Copyright (C) 2001-2016 Quantum ESPRESSO group +! Copyright (C) 2001-2023 Quantum ESPRESSO Foundation ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, @@ -11,20 +11,21 @@ SUBROUTINE punch( what ) !! This routine is called at the end of the run to save on a file !! the information needed for further processing (phonon etc.). ! - !! * what = 'all' : write xml data file and, if io_level > -1, charge - !! density and wavefunctions. For final data. - !! * what = 'config' : write xml data file and charge density; also, - !! for nks=1, wavefunctions in plain binary format - !! (see why in comments below). For intermediate - !! or incomplete results + !! * what = 'all' : write xml data file and, for normal or high I/O options, + !! tha charge density and wavefunctions. + !! Used for writing final data. + !! * what = 'config' : write xml data file and, for low I/O options, + !! the charge density; also, for nks=1, wavefunctions + !! in plain binary format (see comments below for reason) + !! Used for writing intermediate or incomplete results. !! * what = 'config-only' : write xml data file only + !! Used for saving restart information. !! * what = 'config-init' : write xml data file only excluding final results - !! (for dry run, can be called at early stages). + !! Used for dry run, at the start of calculation. ! USE io_global, ONLY : stdout, ionode - USE io_files, ONLY : iunpun, iunwfc, nwordwfc, diropn, & - tmp_dir, prefix, restart_dir, xmlfile, & - create_directory + USE io_files, ONLY : iunwfc, nwordwfc, diropn, tmp_dir, prefix, & + restart_dir, xmlfile, create_directory USE control_flags, ONLY : io_level, lscf, lxdm USE klist, ONLY : nks USE io_files, ONLY : psfile, pseudo_dir, molfile @@ -47,7 +48,7 @@ SUBROUTINE punch( what ) IMPLICIT NONE ! CHARACTER(LEN=*), INTENT(IN) :: what - !! see main comment + !! what is what? see main comment ! ! ... local variables ! @@ -56,11 +57,14 @@ SUBROUTINE punch( what ) INTEGER :: cp_status, nt, isolV ! ! - WRITE( stdout, '(/,5X,"Writing ",A," to output data dir ",A)' ) & - TRIM ( what ), TRIM ( restart_dir ( ) ) - iunpun = 4 - ! - ! ...New-style I/O with xml schema and (optionally) hdf5 binaries + IF ( io_level < -2 ) THEN + !! disk_io='none': no I/O at all, do not write anything + CALL infomsg('punch',"Nothing written, as per user request (disk_io='none')") + RETURN + ELSE + WRITE( stdout, '(/,5X,"Writing ",A," to output data dir ",A," :")' ) & + TRIM ( what ), TRIM ( restart_dir ( ) ) + END IF ! ! ... create the main restart directory (if needed) ! @@ -71,27 +75,38 @@ SUBROUTINE punch( what ) wf_collect = ( TRIM(what) == 'all' ) only_init = ( TRIM(what) == 'config-init' ) CALL pw_write_schema( only_init, wf_collect ) + WRITE( stdout, '(5X,"XML data file")', ADVANCE ='NO' ) ! - IF ( TRIM(what) == 'all' .AND. io_level < 0 ) RETURN + ! ... nothing left to do for 'minimal' I/O option: return ! - ! ... charge density - also writes rho%ns if lda+U and rho%bec if PAW - ! ... do not overwrite the scf charge density with a non-scf one - ! ... (except in the 'force theorem' calculation of MAE where the - ! ... charge density differs from the one read from disk) + IF ( io_level < -1 ) RETURN ! IF (TRIM(what) == 'all' .OR. TRIM(what) == 'config' ) THEN - IF ( lscf .OR. lforcet ) CALL write_scf( rho, nspin ) - ENDIF - ! - ! ... correlation functions of 3D-RISM. - ! ... do not overwrite them, in case of non-scf - ! - IF ( lrism3d ) THEN - IF (TRIM(what) == 'all' .OR. TRIM(what) == 'config' ) THEN - IF ( lscf ) CALL rism3d_write_to_restart() + ! + ! ... charge density - also writes rho%ns if lda+U and rho%bec if PAW + ! ... do not overwrite the scf charge density with a non-scf one + ! ... (except in the 'force theorem' calculation of MAE where the + ! ... charge density differs from the one read from disk) + ! + IF ( lscf .OR. lforcet ) THEN + CALL write_scf( rho, nspin ) + WRITE( stdout, '(", charge density")', ADVANCE ='NO' ) END IF + ! + ! ... correlation functions of 3D-RISM. + ! ... do not overwrite them, in case of non-scf + ! + IF ( lrism3d .AND. lscf ) THEN + CALL rism3d_write_to_restart() + WRITE( stdout, '(", RISM restart")', ADVANCE ='NO' ) + END IF + ! END IF ! + ! ... nothing left to do for 'nowf' I/O option: return + ! + IF ( io_level < 0 ) RETURN + ! IF (TRIM(what) == 'all') THEN ! ! ... copy xml file one level up (FIXME: why?), @@ -110,6 +125,7 @@ SUBROUTINE punch( what ) IF ( TRIM(cp_source) /= TRIM(cp_dest) ) & cp_status = f_copy(cp_source, cp_dest) ENDDO + WRITE( stdout, '(", pseudopotentials")', ADVANCE ='NO' ) ! IF ( lrism3d ) THEN ! @@ -119,19 +135,22 @@ SUBROUTINE punch( what ) IF ( TRIM(cp_source) /= TRIM(cp_dest) ) & cp_status = f_copy(cp_source, cp_dest) ENDDO + WRITE( stdout, '(", RISM molfiles")', ADVANCE ='NO' ) ! ENDIF ! ! write XDM dispersion data (coefficients and vdw radii) to xdm.dat IF (lxdm) THEN CALL write_xdmdat() + WRITE( stdout, '(", XDM data")', ADVANCE ='NO' ) ENDIF ENDIF ! ! ... wavefunctions in "collected" format - also G- and k+G-vectors ! CALL write_collected_wfc( ) - + WRITE( stdout, '(", collected wavefunctions")', ADVANCE ='NO' ) + ! ! ... if allocated, deallocate variables containing info on ionic steps ! CALL qexsd_reset_steps() @@ -141,14 +160,16 @@ SUBROUTINE punch( what ) ! ... here we are stopping an incomplete calculations - wavefunctions are ! ... stored in buffers and saved when buffers are closed. For 1 k-point ! ... however there is no buffer: wavefunctions must be saved to file here + ! ... (if disk_io='low' no file is open, must be opened and closed here) ! IF (io_level < 1) CALL diropn( iunwfc, 'wfc', 2*nwordwfc, exst ) CALL using_evc(0) CALL davcio ( evc, 2*nwordwfc, iunwfc, nks, 1 ) IF (io_level < 1) CLOSE ( UNIT=iunwfc, STATUS='keep' ) - CALL infomsg('punch','wavefunctions written to file') + WRITE( stdout, '(" distributed wavefunctions")', ADVANCE ='NO' ) ! ENDIF + WRITE( stdout, *) ! ! ... FIXME: for electron-phonon calculations - data should be read from xml file! ! diff --git a/PW/src/run_pwscf.f90 b/PW/src/run_pwscf.f90 index 09192c408..5f643d8ef 100644 --- a/PW/src/run_pwscf.f90 +++ b/PW/src/run_pwscf.f90 @@ -45,7 +45,6 @@ SUBROUTINE run_pwscf( exit_status ) USE control_flags, ONLY : conv_elec, gamma_only, ethr, lscf, treinit_gvecs USE control_flags, ONLY : conv_ions, istep, nstep, restart, lmd, lbfgs,& lensemb, lforce=>tprnfor, tstress - USE control_flags, ONLY : io_level USE cellmd, ONLY : lmovecell USE command_line_options, ONLY : command_line USE force_mod, ONLY : sigma, force @@ -352,7 +351,7 @@ SUBROUTINE run_pwscf( exit_status ) ! CALL qexsd_set_status( exit_status ) IF ( lensemb ) CALL beef_energies( ) - IF ( io_level > -2 ) CALL punch( 'all' ) + CALL punch( 'all' ) ! CALL qmmm_shutdown() !