2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
! Copyright (C) 2001-2004 PWSCF group
|
2003-01-20 05:58:50 +08:00
|
|
|
! 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,
|
|
|
|
! or http://www.gnu.org/copyleft/gpl.txt .
|
|
|
|
!
|
2005-06-28 23:50:30 +08:00
|
|
|
!----------------------------------------------------------------------------
|
2004-09-27 17:11:56 +08:00
|
|
|
SUBROUTINE punch()
|
2005-06-28 23:50:30 +08:00
|
|
|
!----------------------------------------------------------------------------
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-10-07 02:16:17 +08:00
|
|
|
! ... This routine is called at the end of the run to save to a file
|
|
|
|
! ... the information needed for further processing (phonon etc.)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
USE io_global, ONLY : stdout
|
|
|
|
USE klist, ONLY : nks, nkstot
|
2005-06-28 23:50:30 +08:00
|
|
|
USE lsda_mod, ONLY : nspin
|
|
|
|
USE scf, ONLY : rho
|
2004-09-27 17:11:56 +08:00
|
|
|
USE control_flags, ONLY : reduce_io, lscf
|
|
|
|
USE wvfct, ONLY : et, wg, nbnd
|
2004-06-14 23:22:24 +08:00
|
|
|
USE wavefunctions_module, ONLY : evc, evc_nc
|
2004-09-27 17:11:56 +08:00
|
|
|
USE io_files, ONLY : prefix, iunpun, iunwfc, nwordwfc
|
|
|
|
USE noncollin_module, ONLY : noncolin
|
|
|
|
USE restart_module, ONLY : writefile_new
|
|
|
|
USE mp_global, ONLY : kunit
|
2005-06-28 23:50:30 +08:00
|
|
|
USE pw_restart, ONLY : pw_writefile
|
2004-09-27 17:11:56 +08:00
|
|
|
!
|
|
|
|
IMPLICIT NONE
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
INTEGER :: ik, i, ibnd, kunittmp
|
|
|
|
LOGICAL :: exst
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
!
|
2005-12-07 12:22:30 +08:00
|
|
|
WRITE( UNIT = stdout, FMT = '(/,5X,"Writing output data file ",A)' ) &
|
2005-10-07 02:16:17 +08:00
|
|
|
TRIM( prefix ) // '.save'
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
kunittmp = 1
|
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
! ... if the wavefunction has not been written on file, do it now
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
IF ( noncolin ) THEN
|
|
|
|
!
|
|
|
|
IF ( nks == 1 .AND. reduce_io ) &
|
|
|
|
CALL davcio(evc_nc, nwordwfc, iunwfc, 1, +1 )
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
IF ( nks == 1 .AND. reduce_io ) &
|
|
|
|
CALL davcio( evc, nwordwfc, iunwfc, 1, +1 )
|
|
|
|
!
|
|
|
|
ENDIF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-06-28 23:50:30 +08:00
|
|
|
! ... The following instruction is used when more k-points are needed
|
|
|
|
! ... for finite-q phonon calculations (on fine q-grid) then those needed
|
|
|
|
! ... for self-consistency. In such a case, a self-consistent calculation
|
|
|
|
! ... with few k-points is followed by a non-self-consistent one with added
|
|
|
|
! ... k-points, whose weight is set to zero.
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
IF ( .NOT. lscf ) CALL sum_band()
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-06-28 23:50:30 +08:00
|
|
|
! ... Write: general variables (including dimensions of the arrays),
|
|
|
|
! ... atomic positions, forces, k-points, eigenvalues
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
#if defined (__PARA)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
! ... xk, wk, isk, et, wg are distributed across pools
|
|
|
|
! ... the first node has a complete copy of xk, wk, isk,
|
|
|
|
! ... while eigenvalues et and weights wg must be
|
2005-06-28 23:50:30 +08:00
|
|
|
! ... explicitely collected to the first node
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
CALL poolrecover( et, nbnd, nkstot, nks )
|
|
|
|
CALL poolrecover( wg, nbnd, nkstot, nks )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
! ... In parallel execution, only the first node writes this file
|
2003-02-03 17:03:53 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
kunittmp = kunit
|
|
|
|
!
|
2005-06-28 23:50:30 +08:00
|
|
|
#endif
|
|
|
|
!
|
|
|
|
! ... Write the charge density on a separate file
|
|
|
|
!
|
2005-10-07 02:16:17 +08:00
|
|
|
CALL io_pot( + 1, 'rho', rho, nspin )
|
2005-06-28 23:50:30 +08:00
|
|
|
!
|
2005-12-13 22:45:35 +08:00
|
|
|
iunpun = 4
|
2005-06-28 23:50:30 +08:00
|
|
|
!
|
2005-12-13 22:45:35 +08:00
|
|
|
#if defined (__NEWPUNCH)
|
2005-06-28 23:50:30 +08:00
|
|
|
!
|
2005-08-26 17:28:33 +08:00
|
|
|
CALL pw_writefile( 'all' )
|
2005-06-28 23:50:30 +08:00
|
|
|
!
|
2005-12-13 22:45:35 +08:00
|
|
|
#else
|
2005-06-28 23:50:30 +08:00
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
CALL writefile_new( 'all', iunpun, et, wg, kunittmp )
|
|
|
|
!
|
2005-12-13 22:45:35 +08:00
|
|
|
#endif
|
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END SUBROUTINE punch
|