2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-04-15 04:14:09 +08:00
|
|
|
! Copyright (C) 2001,2003 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 .
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
2003-02-08 00:04:36 +08:00
|
|
|
subroutine restart_from_file
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
2003-11-04 18:53:05 +08:00
|
|
|
USE io_global, ONLY : stdout
|
2003-11-10 02:30:08 +08:00
|
|
|
USE io_files, ONLY : iunres
|
2004-01-23 23:08:03 +08:00
|
|
|
USE control_flags, ONLY: restart
|
2003-01-20 05:58:50 +08:00
|
|
|
implicit none
|
|
|
|
|
|
|
|
character :: where * 20 ! parameter indicating from where to restart
|
2003-02-08 00:04:36 +08:00
|
|
|
logical :: exst
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! check if restart file is present
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
iunres = 1
|
|
|
|
if (.not.restart) then
|
2003-11-04 18:53:05 +08:00
|
|
|
! WRITE( stdout, '(/5x,"RECOVER from restart file has been switched off on input")')
|
2003-02-08 00:04:36 +08:00
|
|
|
call seqopn (iunres, 'restart', 'unformatted', exst)
|
2003-11-04 18:53:05 +08:00
|
|
|
! if (exst) WRITE( stdout,'(/5x,"Existing restart file has been removed")')
|
2003-02-08 00:04:36 +08:00
|
|
|
close (unit = iunres, status = 'delete')
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
call seqopn (iunres, 'restart', 'unformatted', restart)
|
|
|
|
if (.not.restart) then
|
2003-11-04 18:53:05 +08:00
|
|
|
WRITE( stdout, '(/5x,"RECOVER from restart file failed: file not found")')
|
2003-02-08 00:04:36 +08:00
|
|
|
close (unit = iunres, status = 'delete')
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
!
|
2003-11-04 18:53:05 +08:00
|
|
|
WRITE( stdout, '(/5x,"read information from restart file")')
|
2003-02-08 00:04:36 +08:00
|
|
|
read (iunres, err = 10, end = 10) where
|
2003-11-04 18:53:05 +08:00
|
|
|
WRITE( stdout, '(5x,"Restarting in ",a)') where
|
2003-02-08 00:04:36 +08:00
|
|
|
if (where.ne.'ELECTRONS'.and.where.ne.'IONS') then
|
2003-11-04 18:53:05 +08:00
|
|
|
WRITE( stdout,*) where, '......?'
|
2003-02-21 22:57:00 +08:00
|
|
|
call errore ('readin', ' wrong recover file ', 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
!
|
|
|
|
! close the file for later use
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
close (unit = iunres, status = 'keep')
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-21 22:57:00 +08:00
|
|
|
10 call errore ('readin', 'problems in reading recover file', 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine restart_from_file
|