2004-05-05 20:22:19 +08:00
|
|
|
!
|
2009-11-12 03:10:53 +08:00
|
|
|
! Copyright (C) 2002-2009 Quantum ESPRESSO group
|
2004-05-05 20:22:19 +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 .
|
|
|
|
!
|
2006-12-12 19:02:09 +08:00
|
|
|
!
|
2005-08-24 21:17:28 +08:00
|
|
|
!----------------------------------------------------------------------------
|
2004-05-05 20:22:19 +08:00
|
|
|
SUBROUTINE compute_scf( N_in, N_fin, stat )
|
2005-08-24 21:17:28 +08:00
|
|
|
!----------------------------------------------------------------------------
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2004-08-18 23:53:01 +08:00
|
|
|
! ... this subroutine is the main scf-driver for all "path" calculations
|
|
|
|
! ... ( called by Modules/path_base.f90/born_oppenheimer() subroutine )
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
|
|
|
USE kinds, ONLY : DP
|
2005-07-18 09:16:41 +08:00
|
|
|
USE ions_base, ONLY : nat, sort_tau, tau_srt, ind_srt, ityp, nsp
|
2009-11-22 16:26:59 +08:00
|
|
|
USE control_flags, ONLY : conv_elec, ndr, nbeg, taurdr, &
|
2006-02-28 04:06:23 +08:00
|
|
|
trane, ampre, nomore, tfor, isave
|
|
|
|
USE cp_main_variables, ONLY : nfi
|
2009-11-12 03:10:53 +08:00
|
|
|
USE io_files, ONLY : iunpath, iunexit, tmp_dir, prefix
|
2005-07-18 09:16:41 +08:00
|
|
|
USE io_global, ONLY : stdout, ionode
|
2004-08-18 23:53:01 +08:00
|
|
|
USE path_formats, ONLY : scf_fmt
|
|
|
|
USE path_variables, ONLY : pos, pes, grad_pes, num_of_images, &
|
2007-01-20 10:26:49 +08:00
|
|
|
dim1, pending_image, frozen
|
2004-05-05 20:22:19 +08:00
|
|
|
USE check_stop, ONLY : check_stop_now
|
2005-09-11 08:50:13 +08:00
|
|
|
USE xml_io_base, ONLY : check_restartfile
|
2005-07-18 09:16:41 +08:00
|
|
|
USE input, ONLY : modules_setup
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
|
|
|
IMPLICIT NONE
|
|
|
|
!
|
|
|
|
INTEGER, INTENT(IN) :: N_in, N_fin
|
|
|
|
LOGICAL, INTENT(OUT) :: stat
|
2004-08-18 23:53:01 +08:00
|
|
|
!
|
2005-09-11 08:50:13 +08:00
|
|
|
INTEGER :: image
|
|
|
|
REAL(DP) :: tcpu
|
2009-11-12 03:10:53 +08:00
|
|
|
CHARACTER(LEN=256) :: tmp_dir_saved
|
2006-12-12 19:02:09 +08:00
|
|
|
LOGICAL :: opnd
|
2005-09-11 08:50:13 +08:00
|
|
|
REAL(DP), ALLOCATABLE :: tau(:,:)
|
|
|
|
REAL(DP), ALLOCATABLE :: fion(:,:)
|
|
|
|
REAL(DP) :: etot
|
2006-02-28 04:06:23 +08:00
|
|
|
!
|
|
|
|
CHARACTER(LEN=6), EXTERNAL :: int_to_char
|
|
|
|
REAL(DP), EXTERNAL :: get_clock
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
|
|
|
!
|
|
|
|
stat = .TRUE.
|
2005-07-18 09:16:41 +08:00
|
|
|
tcpu = 0.D0
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2005-07-18 09:16:41 +08:00
|
|
|
ALLOCATE( tau( 3, nat ), fion( 3, nat ) )
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2009-11-12 03:10:53 +08:00
|
|
|
tmp_dir_saved = tmp_dir
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
|
|
|
DO image = N_in, N_fin
|
|
|
|
!
|
2004-08-18 23:53:01 +08:00
|
|
|
IF ( frozen(image) ) CYCLE
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2006-09-13 02:28:57 +08:00
|
|
|
pending_image = image
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2006-02-28 04:06:23 +08:00
|
|
|
IF ( check_stop_now() ) THEN
|
|
|
|
!
|
|
|
|
stat = .FALSE.
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END IF
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2009-11-12 03:10:53 +08:00
|
|
|
tmp_dir = TRIM ( tmp_dir_saved ) // "/" // TRIM( prefix ) // "_" // &
|
|
|
|
TRIM( int_to_char( image ) ) // "/"
|
2005-07-18 09:16:41 +08:00
|
|
|
!
|
2006-04-03 05:29:28 +08:00
|
|
|
tcpu = get_clock( 'CP' )
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2004-08-18 23:53:01 +08:00
|
|
|
WRITE( UNIT = iunpath, FMT = scf_fmt ) tcpu, image
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
|
|
|
! ... unit stdout is connected to the appropriate file
|
|
|
|
!
|
2005-07-18 09:16:41 +08:00
|
|
|
IF ( ionode ) THEN
|
|
|
|
!
|
2004-05-05 20:22:19 +08:00
|
|
|
INQUIRE( UNIT = stdout, OPENED = opnd )
|
|
|
|
IF ( opnd ) CLOSE( UNIT = stdout )
|
2009-11-12 03:10:53 +08:00
|
|
|
OPEN( UNIT = stdout, FILE = TRIM( tmp_dir ) // 'CP.out', &
|
2005-07-18 09:16:41 +08:00
|
|
|
STATUS = 'UNKNOWN', POSITION = 'APPEND' )
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2005-07-18 09:16:41 +08:00
|
|
|
END IF
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2006-02-28 04:06:23 +08:00
|
|
|
CALL deallocate_modules_var()
|
|
|
|
!
|
|
|
|
CALL modules_setup()
|
|
|
|
!
|
|
|
|
tau = RESHAPE( pos(:,image), SHAPE( tau ) )
|
|
|
|
!
|
|
|
|
CALL sort_tau( tau_srt, ind_srt, tau, ityp, nat, nsp )
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2005-07-28 00:09:03 +08:00
|
|
|
taurdr = .TRUE.
|
2006-02-28 04:06:23 +08:00
|
|
|
nfi = 0
|
|
|
|
tfor = .FALSE.
|
2005-07-28 00:09:03 +08:00
|
|
|
!
|
2009-11-12 03:10:53 +08:00
|
|
|
IF ( check_restartfile( tmp_dir, ndr ) ) THEN
|
2005-08-24 21:17:28 +08:00
|
|
|
!
|
2006-02-28 04:06:23 +08:00
|
|
|
WRITE( stdout, '(/,2X,"restarting from file",/)' )
|
2005-08-24 21:17:28 +08:00
|
|
|
!
|
2005-09-11 08:50:13 +08:00
|
|
|
nbeg = 0
|
2006-05-08 19:16:41 +08:00
|
|
|
nomore = 2000
|
2006-07-27 21:03:52 +08:00
|
|
|
trane = .FALSE.
|
|
|
|
ampre = 0.0D0
|
2005-08-24 21:17:28 +08:00
|
|
|
!
|
2004-05-05 20:22:19 +08:00
|
|
|
ELSE
|
2005-08-24 21:17:28 +08:00
|
|
|
!
|
|
|
|
WRITE( stdout, '(/,2X,"restarting from scratch",/)' )
|
|
|
|
!
|
|
|
|
nbeg = -1
|
2006-05-08 19:16:41 +08:00
|
|
|
nomore = 5000
|
2005-08-24 21:17:28 +08:00
|
|
|
trane = .TRUE.
|
|
|
|
ampre = 0.02D0
|
|
|
|
!
|
2004-05-05 20:22:19 +08:00
|
|
|
END IF
|
|
|
|
!
|
2006-02-28 04:06:23 +08:00
|
|
|
isave = nomore
|
2005-07-28 00:09:03 +08:00
|
|
|
!
|
2009-11-22 01:29:41 +08:00
|
|
|
! ... perform an electronic minimisation using CP
|
2005-07-28 00:09:03 +08:00
|
|
|
!
|
- FPMD: pseudopotential variable wsg, wnl, fnl substituted with
dion, beta, bec everyware.
- subroutines formfn, compute_beta, nlsm1, nlsm2, ecc ... now are common
between FPMD and CPV, a lot of clean ups!
- Changes in stdout: relevant physical quantities ( positions velocities an cell )
are now printed with the seme format of the corresponding input card,
like in PW, as was suggested by SdG.
- exemple23 updated to reflect the new input namelist "wannier"
- Subroutine init_run now is used in FPMD too.
- WARNING in the stress computed with CP, for a pseudo with core-corrections,
a contribution is missing! Not yet fixed, I need to talk with PG for the
box staff.
- WARNING the examples reference are not updated, I'm on the IBM sp, and
I prefer to update them from a linux machine.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2110 c92efa57-630b-4861-b058-cf58834340f0
2005-08-22 22:14:13 +08:00
|
|
|
CALL init_run()
|
|
|
|
!
|
2009-11-22 01:29:41 +08:00
|
|
|
CALL cprmain( tau, fion, etot )
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2005-07-18 09:16:41 +08:00
|
|
|
IF ( ionode ) THEN
|
|
|
|
!
|
2004-05-05 20:22:19 +08:00
|
|
|
INQUIRE( UNIT = stdout, OPENED = opnd )
|
|
|
|
IF ( opnd ) CLOSE( UNIT = stdout )
|
2005-07-18 09:16:41 +08:00
|
|
|
!
|
2004-05-05 20:22:19 +08:00
|
|
|
END IF
|
|
|
|
!
|
|
|
|
IF ( .NOT. conv_elec ) THEN
|
|
|
|
!
|
2004-08-18 23:53:01 +08:00
|
|
|
WRITE( iunpath, '(/,5X,"WARNING : scf convergence NOT achieved",/)' )
|
2007-01-20 10:26:49 +08:00
|
|
|
!
|
2004-05-05 20:22:19 +08:00
|
|
|
stat = .FALSE.
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
! ... gradients already in ( hartree / bohr )
|
|
|
|
!
|
2007-01-20 10:26:49 +08:00
|
|
|
grad_pes(:,image) = - RESHAPE( fion, (/ dim1 /) )
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2005-07-18 09:16:41 +08:00
|
|
|
! ... energy already in hartree
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2005-07-18 09:16:41 +08:00
|
|
|
pes(image) = etot
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
2009-11-12 03:10:53 +08:00
|
|
|
tmp_dir = tmp_dir_saved
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
2006-09-13 02:28:57 +08:00
|
|
|
pending_image = 0
|
2004-05-05 20:22:19 +08:00
|
|
|
!
|
|
|
|
DEALLOCATE( tau, fion )
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END SUBROUTINE compute_scf
|