2004-11-26 18:12:26 +08:00
|
|
|
!
|
2005-08-24 21:17:28 +08:00
|
|
|
! Copyright (C) 2002-2005 Quantum-ESPRESSO group
|
2004-11-26 18:12:26 +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-01-20 05:58:50 +08:00
|
|
|
|
2004-11-24 18:56:23 +08:00
|
|
|
!-----------------------------------------------------------------------
|
2006-08-04 01:47:35 +08:00
|
|
|
|
2007-01-05 23:32:43 +08:00
|
|
|
SUBROUTINE writefile_cp &
|
2004-11-24 18:56:23 +08:00
|
|
|
& ( ndw,h,hold,nfi,c0,cm,taus,tausm,vels,velsm,acc, &
|
2005-10-18 08:32:50 +08:00
|
|
|
& lambda,lambdam,xnhe0,xnhem,vnhe,xnhp0,xnhpm,vnhp,nhpcl,nhpdim,ekincm,&
|
2004-11-24 18:56:23 +08:00
|
|
|
& xnhh0,xnhhm,vnhh,velh,ecut,ecutw,delt,pmass,ibrav,celldm, &
|
2005-08-26 17:28:33 +08:00
|
|
|
& fion, tps, mat_z, occ_f, rho )
|
2004-11-24 18:56:23 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! read from file and distribute data calculated in preceding iterations
|
|
|
|
!
|
2006-08-04 01:47:35 +08:00
|
|
|
USE kinds, ONLY: DP
|
2005-11-10 01:57:05 +08:00
|
|
|
USE ions_base, ONLY: nsp, na, cdmi, taui
|
2005-07-28 00:09:03 +08:00
|
|
|
USE cell_base, ONLY: s_to_r
|
|
|
|
USE cp_restart, ONLY: cp_writefile
|
2006-08-11 16:29:52 +08:00
|
|
|
USE cp_interfaces, ONLY: set_evtot, set_eitot
|
2005-07-28 00:09:03 +08:00
|
|
|
USE electrons_base, ONLY: nspin, nbnd, nbsp, iupdwn, nupdwn
|
2006-08-11 16:29:52 +08:00
|
|
|
USE electrons_module, ONLY: ei, ei_emp, n_emp, iupdwn_emp, nupdwn_emp
|
2006-08-12 20:27:56 +08:00
|
|
|
USE io_files, ONLY: outdir
|
2005-08-26 17:28:33 +08:00
|
|
|
USE ensemble_dft, ONLY: tens
|
2006-04-14 18:55:31 +08:00
|
|
|
USE mp, ONLY: mp_bcast
|
|
|
|
USE mp_global, ONLY: root_image, intra_image_comm
|
2006-08-11 16:29:52 +08:00
|
|
|
USE control_flags, ONLY: reduce_io
|
2004-11-24 18:56:23 +08:00
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
integer, INTENT(IN) :: ndw, nfi
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP), INTENT(IN) :: h(3,3), hold(3,3)
|
2006-08-04 01:47:35 +08:00
|
|
|
complex(DP), INTENT(IN) :: c0(:,:), cm(:,:)
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP), INTENT(IN) :: tausm(:,:), taus(:,:), fion(:,:)
|
|
|
|
REAL(DP), INTENT(IN) :: vels(:,:), velsm(:,:)
|
2006-01-30 00:43:06 +08:00
|
|
|
REAL(DP), INTENT(IN) :: acc(:), lambda(:,:,:), lambdam(:,:,:)
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP), INTENT(IN) :: xnhe0, xnhem, vnhe, ekincm
|
|
|
|
REAL(DP), INTENT(IN) :: xnhp0(:), xnhpm(:), vnhp(:)
|
2005-10-18 08:32:50 +08:00
|
|
|
integer, INTENT(in) :: nhpcl, nhpdim
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP), INTENT(IN) :: xnhh0(3,3),xnhhm(3,3),vnhh(3,3),velh(3,3)
|
|
|
|
REAL(DP), INTENT(in) :: ecut, ecutw, delt
|
|
|
|
REAL(DP), INTENT(in) :: pmass(:)
|
|
|
|
REAL(DP), INTENT(in) :: celldm(:)
|
|
|
|
REAL(DP), INTENT(in) :: tps
|
|
|
|
REAL(DP), INTENT(in) :: rho(:,:)
|
2004-11-24 18:56:23 +08:00
|
|
|
integer, INTENT(in) :: ibrav
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP), INTENT(in) :: occ_f(:)
|
|
|
|
REAL(DP), INTENT(in) :: mat_z(:,:,:)
|
2004-11-24 18:56:23 +08:00
|
|
|
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: ht(3,3), htm(3,3), htvel(3,3), gvel(3,3)
|
2006-08-11 16:29:52 +08:00
|
|
|
INTEGER :: nk = 1, ispin, i, ib
|
2006-06-01 18:51:33 +08:00
|
|
|
REAL(DP) :: xk(3,1) = 0.0d0, wk(1) = 2.0d0
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: htm1(3,3), omega
|
2006-08-11 16:29:52 +08:00
|
|
|
COMPLEX(DP), ALLOCATABLE :: ctot(:,:)
|
|
|
|
REAL(DP), ALLOCATABLE :: eitot(:,:)
|
|
|
|
INTEGER :: nupdwn_tot( 2 ), iupdwn_tot( 2 )
|
2004-11-24 18:56:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
if ( ndw < 1 ) then
|
2006-08-11 16:29:52 +08:00
|
|
|
!
|
|
|
|
! Do not write restart file if the unit number
|
|
|
|
! is negative, this is used mainly for benchmarks and tests
|
|
|
|
!
|
|
|
|
return
|
|
|
|
!
|
2004-11-24 18:56:23 +08:00
|
|
|
end if
|
|
|
|
|
|
|
|
ht = TRANSPOSE( h )
|
|
|
|
htm = TRANSPOSE( hold )
|
|
|
|
htvel = TRANSPOSE( velh )
|
2005-03-26 23:29:07 +08:00
|
|
|
gvel = 0.0d0
|
|
|
|
|
2006-08-11 16:29:52 +08:00
|
|
|
nupdwn_tot = nupdwn + nupdwn_emp
|
|
|
|
iupdwn_tot(1) = iupdwn(1)
|
|
|
|
iupdwn_tot(2) = nupdwn(1) + 1
|
|
|
|
!
|
|
|
|
ALLOCATE( eitot( nupdwn_tot(1), nspin ) )
|
|
|
|
!
|
|
|
|
CALL set_eitot( eitot )
|
|
|
|
!
|
|
|
|
IF( .NOT. reduce_io ) THEN
|
|
|
|
!
|
|
|
|
ALLOCATE( ctot( SIZE( c0, 1 ), nupdwn_tot(1) * nspin ) )
|
|
|
|
!
|
|
|
|
CALL set_evtot( c0, ctot, lambda, iupdwn_tot, nupdwn_tot )
|
|
|
|
!
|
|
|
|
END IF
|
2006-04-14 18:55:31 +08:00
|
|
|
!
|
|
|
|
! Sincronize lambdas, whose replicas could diverge on
|
|
|
|
! different processors
|
|
|
|
!
|
2005-08-26 17:28:33 +08:00
|
|
|
IF( tens ) THEN
|
2006-08-11 16:29:52 +08:00
|
|
|
!
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_writefile( ndw, outdir, .TRUE., nfi, tps, acc, nk, xk, wk, &
|
2006-08-11 16:29:52 +08:00
|
|
|
ht, htm, htvel, gvel, xnhh0, xnhhm, vnhh, taui, cdmi , taus, &
|
2006-08-04 01:47:35 +08:00
|
|
|
vels, tausm, velsm, fion, vnhp, xnhp0, xnhpm, nhpcl,nhpdim, occ_f , &
|
2006-08-11 16:29:52 +08:00
|
|
|
occ_f , lambda, lambdam, xnhe0, xnhem, vnhe, ekincm, ei, &
|
|
|
|
rho, c0, cm, ctot, iupdwn, nupdwn, iupdwn, nupdwn, mat_z = mat_z )
|
|
|
|
!
|
2005-08-26 17:28:33 +08:00
|
|
|
ELSE
|
2006-08-11 16:29:52 +08:00
|
|
|
!
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_writefile( ndw, outdir, .TRUE., nfi, tps, acc, nk, xk, wk, &
|
2006-08-11 16:29:52 +08:00
|
|
|
ht, htm, htvel, gvel, xnhh0, xnhhm, vnhh, taui, cdmi , taus, &
|
|
|
|
vels, tausm, velsm, fion, vnhp, xnhp0, xnhpm, nhpcl,nhpdim, occ_f , &
|
|
|
|
occ_f , lambda, lambdam, xnhe0, xnhem, vnhe, ekincm, eitot, &
|
|
|
|
rho, c0, cm, ctot, iupdwn, nupdwn, iupdwn_tot, nupdwn_tot )
|
|
|
|
!
|
2005-08-26 17:28:33 +08:00
|
|
|
END IF
|
2004-11-24 18:56:23 +08:00
|
|
|
|
2006-08-11 16:29:52 +08:00
|
|
|
DEALLOCATE( eitot )
|
|
|
|
!
|
|
|
|
IF( .NOT. reduce_io ) DEALLOCATE( ctot )
|
|
|
|
|
2004-11-24 18:56:23 +08:00
|
|
|
return
|
2005-05-18 17:10:54 +08:00
|
|
|
end subroutine writefile_cp
|
2004-11-24 18:56:23 +08:00
|
|
|
|
|
|
|
!-----------------------------------------------------------------------
|
2004-11-26 18:12:26 +08:00
|
|
|
subroutine readfile_cp &
|
2004-11-24 18:56:23 +08:00
|
|
|
& ( flag, ndr,h,hold,nfi,c0,cm,taus,tausm,vels,velsm,acc, &
|
2005-10-18 08:32:50 +08:00
|
|
|
& lambda,lambdam,xnhe0,xnhem,vnhe,xnhp0,xnhpm,vnhp,nhpcl,nhpdim,ekincm,&
|
2004-11-24 18:56:23 +08:00
|
|
|
& xnhh0,xnhhm,vnhh,velh,ecut,ecutw,delt,pmass,ibrav,celldm,&
|
2004-12-21 23:48:19 +08:00
|
|
|
& fion, tps, mat_z, occ_f )
|
2004-11-24 18:56:23 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! read from file and distribute data calculated in preceding iterations
|
|
|
|
!
|
2006-08-04 01:47:35 +08:00
|
|
|
USE kinds, ONLY : DP
|
2006-08-12 20:27:56 +08:00
|
|
|
USE io_files, ONLY : outdir
|
2006-06-01 18:51:33 +08:00
|
|
|
USE electrons_base, ONLY : nbnd, nbsp, nspin, nupdwn, iupdwn, keep_occ
|
2005-10-20 23:22:12 +08:00
|
|
|
USE gvecw, ONLY : ngw, ngwt
|
2005-11-10 01:57:05 +08:00
|
|
|
USE ions_base, ONLY : nsp, na, cdmi, taui
|
2005-10-20 23:22:12 +08:00
|
|
|
USE cp_restart, ONLY : cp_readfile, cp_read_cell, cp_read_wfc
|
|
|
|
USE ensemble_dft, ONLY : tens
|
|
|
|
USE autopilot, ONLY : event_step, event_index, max_event_step
|
2006-10-10 01:07:23 +08:00
|
|
|
USE cp_autopilot, ONLY : employ_rules
|
2004-11-24 18:56:23 +08:00
|
|
|
!
|
|
|
|
implicit none
|
2006-12-03 01:58:50 +08:00
|
|
|
INTEGER, INTENT(in) :: flag
|
|
|
|
integer :: ndr, nfi
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: h(3,3), hold(3,3)
|
2006-08-04 01:47:35 +08:00
|
|
|
complex(DP) :: c0(:,:), cm(:,:)
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: tausm(:,:),taus(:,:), fion(:,:)
|
|
|
|
REAL(DP) :: vels(:,:), velsm(:,:)
|
2006-01-30 00:43:06 +08:00
|
|
|
REAL(DP) :: acc(:),lambda(:,:,:), lambdam(:,:,:)
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: xnhe0,xnhem,vnhe
|
|
|
|
REAL(DP) :: xnhp0(:), xnhpm(:), vnhp(:)
|
2005-10-18 08:32:50 +08:00
|
|
|
integer, INTENT(inout) :: nhpcl,nhpdim
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: ekincm
|
|
|
|
REAL(DP) :: xnhh0(3,3),xnhhm(3,3),vnhh(3,3),velh(3,3)
|
|
|
|
REAL(DP), INTENT(in) :: ecut, ecutw, delt
|
|
|
|
REAL(DP), INTENT(in) :: pmass(:)
|
|
|
|
REAL(DP), INTENT(in) :: celldm(6)
|
2004-11-24 18:56:23 +08:00
|
|
|
integer, INTENT(in) :: ibrav
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP), INTENT(OUT) :: tps
|
|
|
|
REAL(DP), INTENT(INOUT) :: mat_z(:,:,:), occ_f(:)
|
2004-11-24 18:56:23 +08:00
|
|
|
!
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: ht(3,3), htm(3,3), htvel(3,3), gvel(3,3)
|
2005-03-02 18:03:55 +08:00
|
|
|
integer :: nk = 1, ispin, i, ib
|
2006-06-01 18:51:33 +08:00
|
|
|
REAL(DP) :: xk(3,1) = 0.0d0, wk(1) = 2.0d0
|
2006-08-04 01:47:35 +08:00
|
|
|
REAL(DP), ALLOCATABLE :: occ_ ( : )
|
2005-10-20 23:22:12 +08:00
|
|
|
REAL(DP) :: htm1(3,3), b1(3) , b2(3), b3(3), omega
|
|
|
|
|
|
|
|
LOGICAL::lopen
|
2004-11-24 18:56:23 +08:00
|
|
|
|
|
|
|
IF( flag == -1 ) THEN
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_read_cell( ndr, outdir, .TRUE., ht, htm, htvel, gvel, xnhh0, xnhhm, vnhh )
|
2004-11-24 18:56:23 +08:00
|
|
|
h = TRANSPOSE( ht )
|
|
|
|
hold = TRANSPOSE( htm )
|
|
|
|
velh = TRANSPOSE( htvel )
|
|
|
|
RETURN
|
|
|
|
ELSE IF ( flag == 0 ) THEN
|
|
|
|
DO ispin = 1, nspin
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_read_wfc( ndr, outdir, 1, 1, ispin, nspin, c2 = cm(:,:), tag = 'm' )
|
2004-11-24 18:56:23 +08:00
|
|
|
END DO
|
|
|
|
RETURN
|
|
|
|
END IF
|
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
ALLOCATE( occ_ ( SIZE( occ_f ) ) )
|
2004-11-24 18:56:23 +08:00
|
|
|
|
2005-08-26 17:28:33 +08:00
|
|
|
IF( tens ) THEN
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_readfile( ndr, outdir, .TRUE., nfi, tps, acc, nk, xk, wk, &
|
2005-11-10 01:57:05 +08:00
|
|
|
ht, htm, htvel, gvel, xnhh0, xnhhm, vnhh, taui, cdmi, taus, &
|
2005-10-18 08:32:50 +08:00
|
|
|
vels, tausm, velsm, fion, vnhp, xnhp0, xnhpm, nhpcl,nhpdim,occ_ , &
|
2005-08-26 17:28:33 +08:00
|
|
|
occ_ , lambda, lambdam, b1, b2, b3, &
|
2006-07-17 17:15:34 +08:00
|
|
|
xnhe0, xnhem, vnhe, ekincm, c0, cm, mat_z = mat_z )
|
2005-08-26 17:28:33 +08:00
|
|
|
ELSE
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_readfile( ndr, outdir, .TRUE., nfi, tps, acc, nk, xk, wk, &
|
2005-11-10 01:57:05 +08:00
|
|
|
ht, htm, htvel, gvel, xnhh0, xnhhm, vnhh, taui, cdmi, taus, &
|
2005-10-18 08:32:50 +08:00
|
|
|
vels, tausm, velsm, fion, vnhp, xnhp0, xnhpm, nhpcl,nhpdim,occ_ , &
|
2005-08-26 17:28:33 +08:00
|
|
|
occ_ , lambda, lambdam, b1, b2, b3, &
|
2006-07-17 17:15:34 +08:00
|
|
|
xnhe0, xnhem, vnhe, ekincm, c0, cm )
|
2005-08-26 17:28:33 +08:00
|
|
|
END IF
|
2004-11-24 18:56:23 +08:00
|
|
|
|
2005-08-24 22:23:09 +08:00
|
|
|
! AutoPilot (Dynamic Rules) Implementation
|
|
|
|
event_index = 1
|
|
|
|
|
|
|
|
do while (event_step(event_index) <= nfi)
|
|
|
|
! Assuming that the remaining dynamic parm values are set correctly by reading
|
|
|
|
! the the restart file.
|
|
|
|
! if this is not true, employ rules as events are updated right here as:
|
|
|
|
call employ_rules()
|
|
|
|
event_index = event_index + 1
|
|
|
|
if( event_index > max_event_step ) then
|
2007-01-05 23:32:43 +08:00
|
|
|
CALL errore( ' readfile ' , ' maximum events exceeded for dynamic rules ' , 1 )
|
|
|
|
end if
|
2005-08-24 22:23:09 +08:00
|
|
|
enddo
|
|
|
|
|
2006-06-01 18:51:33 +08:00
|
|
|
IF( .NOT. keep_occ ) THEN
|
2006-08-04 01:47:35 +08:00
|
|
|
occ_f( : ) = occ_ ( : )
|
2006-06-01 18:51:33 +08:00
|
|
|
END IF
|
|
|
|
|
2004-11-24 18:56:23 +08:00
|
|
|
DEALLOCATE( occ_ )
|
|
|
|
|
|
|
|
h = TRANSPOSE( ht )
|
|
|
|
hold = TRANSPOSE( htm )
|
|
|
|
velh = TRANSPOSE( htvel )
|
|
|
|
|
|
|
|
return
|
2005-05-18 17:10:54 +08:00
|
|
|
end subroutine readfile_cp
|
2004-11-24 18:56:23 +08:00
|
|
|
|
|
|
|
|
2004-11-26 18:12:26 +08:00
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
|
2004-11-27 03:22:35 +08:00
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
SUBROUTINE writefile_fpmd &
|
|
|
|
( nfi, trutime, c0, cm, occ, atoms_0, atoms_m, acc, taui, cdmi, ht_m, &
|
2006-08-11 16:29:52 +08:00
|
|
|
ht_0, rho, vpot, lambda )
|
2004-11-26 18:12:26 +08:00
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
USE kinds, ONLY: DP
|
2006-10-07 01:21:32 +08:00
|
|
|
USE cell_base, ONLY: boxdimensions, r_to_s
|
2006-08-04 01:47:35 +08:00
|
|
|
USE control_flags, ONLY: ndw, gamma_only
|
2006-08-11 16:29:52 +08:00
|
|
|
USE control_flags, ONLY: twfcollect, force_pairing, reduce_io
|
2004-11-26 18:12:26 +08:00
|
|
|
USE atoms_type_module, ONLY: atoms_type
|
2006-08-04 01:47:35 +08:00
|
|
|
USE io_global, ONLY: ionode, ionode_id
|
|
|
|
USE io_global, ONLY: stdout
|
|
|
|
USE electrons_nose, ONLY: xnhe0, xnhem, vnhe
|
2006-08-11 16:29:52 +08:00
|
|
|
USE electrons_base, ONLY: nbsp, nspin, nudx, iupdwn, nupdwn
|
2006-08-04 01:47:35 +08:00
|
|
|
USE cell_nose, ONLY: xnhh0, xnhhm, vnhh
|
|
|
|
USE ions_nose, ONLY: vnhp, xnhp0, xnhpm, nhpcl, nhpdim
|
|
|
|
USE cp_restart, ONLY: cp_writefile
|
2006-08-11 16:29:52 +08:00
|
|
|
USE electrons_module, ONLY: ei, ei_emp, iupdwn_emp, nupdwn_emp, n_emp
|
2006-08-12 20:27:56 +08:00
|
|
|
USE io_files, ONLY: outdir
|
2006-08-04 01:47:35 +08:00
|
|
|
USE grid_dimensions, ONLY: nr1, nr2, nr3, nr1x, nr2x, nr3x
|
2006-08-11 16:29:52 +08:00
|
|
|
USE cp_interfaces, ONLY: set_evtot, set_eitot
|
2005-04-28 23:27:41 +08:00
|
|
|
|
2004-11-26 18:12:26 +08:00
|
|
|
IMPLICIT NONE
|
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
INTEGER, INTENT(IN) :: nfi
|
|
|
|
COMPLEX(DP), INTENT(IN) :: c0(:,:), cm(:,:)
|
|
|
|
REAL(DP), INTENT(IN) :: occ(:)
|
|
|
|
TYPE (boxdimensions), INTENT(IN) :: ht_m, ht_0
|
|
|
|
TYPE (atoms_type), INTENT(IN) :: atoms_0, atoms_m
|
|
|
|
REAL(DP), INTENT(IN) :: rho(:,:)
|
|
|
|
REAL(DP), INTENT(INOUT) :: vpot(:,:)
|
|
|
|
REAL(DP), INTENT(IN) :: taui(:,:)
|
|
|
|
REAL(DP), INTENT(IN) :: acc(:), cdmi(:)
|
|
|
|
REAL(DP), INTENT(IN) :: trutime
|
2006-08-11 16:29:52 +08:00
|
|
|
REAL(DP), INTENT(IN) :: lambda(:,:,:)
|
2005-08-28 22:09:42 +08:00
|
|
|
|
|
|
|
REAL(DP) :: ekincm
|
2006-08-11 16:29:52 +08:00
|
|
|
INTEGER :: i, j, k, ir
|
|
|
|
COMPLEX(DP), ALLOCATABLE :: ctot(:,:)
|
|
|
|
REAL(DP), ALLOCATABLE :: eitot(:,:)
|
|
|
|
INTEGER :: nupdwn_tot( 2 ), iupdwn_tot( 2 )
|
2006-06-01 18:51:33 +08:00
|
|
|
|
|
|
|
INTEGER :: nkpt = 1
|
|
|
|
REAL(DP) :: xk(3,1) = 0.0d0, wk(1) = 2.0d0
|
2005-03-02 18:03:55 +08:00
|
|
|
|
2004-11-27 03:22:35 +08:00
|
|
|
IF( ndw < 1 ) RETURN
|
|
|
|
!
|
|
|
|
! this is used for benchmarking and debug
|
|
|
|
! if ndw < 1 Do not save wave functions and other system
|
|
|
|
! properties on the writefile subroutine
|
2004-11-26 18:12:26 +08:00
|
|
|
|
2005-03-02 18:03:55 +08:00
|
|
|
ekincm = 0.0d0
|
2005-08-26 17:28:33 +08:00
|
|
|
!
|
2006-08-11 16:29:52 +08:00
|
|
|
nupdwn_tot = nupdwn + nupdwn_emp
|
|
|
|
iupdwn_tot(1) = iupdwn(1)
|
|
|
|
iupdwn_tot(2) = nupdwn(1) + 1
|
|
|
|
!
|
|
|
|
ALLOCATE( eitot( nupdwn_tot(1), nspin ) )
|
|
|
|
!
|
|
|
|
CALL set_eitot( eitot )
|
|
|
|
|
|
|
|
IF( .NOT. reduce_io ) THEN
|
|
|
|
!
|
|
|
|
ALLOCATE( ctot( SIZE( c0, 1 ), nupdwn_tot(1) * nspin ) )
|
|
|
|
!
|
|
|
|
CALL set_evtot( c0, ctot, lambda, iupdwn_tot, nupdwn_tot )
|
|
|
|
!
|
|
|
|
END IF
|
2005-08-26 17:28:33 +08:00
|
|
|
!
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_writefile( ndw, outdir, .TRUE., nfi, trutime, acc, nkpt, xk, wk, &
|
2006-08-11 16:29:52 +08:00
|
|
|
ht_0%a, ht_m%a, ht_0%hvel, ht_0%gvel, xnhh0, xnhhm, vnhh, taui, cdmi, &
|
|
|
|
atoms_0%taus, atoms_0%vels, atoms_m%taus, atoms_m%vels, atoms_0%for, &
|
|
|
|
vnhp, xnhp0, xnhpm, nhpcl, nhpdim, occ, occ, lambda, lambda, &
|
|
|
|
xnhe0, xnhem, vnhe, ekincm, eitot, rho, c0, cm, ctot, iupdwn, nupdwn, &
|
|
|
|
iupdwn_tot, nupdwn_tot )
|
|
|
|
|
|
|
|
DEALLOCATE( eitot )
|
2004-11-26 18:12:26 +08:00
|
|
|
|
2006-08-11 16:29:52 +08:00
|
|
|
IF( .NOT. reduce_io ) DEALLOCATE( ctot )
|
2004-11-26 18:12:26 +08:00
|
|
|
|
|
|
|
RETURN
|
|
|
|
END SUBROUTINE writefile_fpmd
|
|
|
|
|
|
|
|
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
|
|
|
|
SUBROUTINE readfile_fpmd &
|
|
|
|
( nfi, trutime, c0, cm, occ, atoms_0, atoms_m, acc, taui, cdmi, ht_m, &
|
2006-08-11 16:29:52 +08:00
|
|
|
ht_0, rho, vpot, lambda )
|
2004-11-26 18:12:26 +08:00
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
USE kinds, ONLY: DP
|
|
|
|
use electrons_base, ONLY: nbsp, nspin, nudx
|
2006-10-07 01:21:32 +08:00
|
|
|
USE cell_base, ONLY: boxdimensions, cell_init, r_to_s, s_to_r
|
2006-08-04 01:47:35 +08:00
|
|
|
use parameters, ONLY: npkx, nsx
|
|
|
|
USE mp_global, ONLY: intra_image_comm
|
|
|
|
USE mp_wave, ONLY: mergewf
|
|
|
|
USE control_flags, ONLY: ndr, tbeg, gamma_only
|
2004-11-26 18:12:26 +08:00
|
|
|
USE atoms_type_module, ONLY: atoms_type
|
2006-08-04 01:47:35 +08:00
|
|
|
USE io_global, ONLY: ionode
|
|
|
|
USE io_global, ONLY: stdout
|
|
|
|
USE gvecw, ONLY: ecutwfc => ecutw
|
|
|
|
USE gvecp, ONLY: ecutrho => ecutp
|
|
|
|
USE ions_base, ONLY: nat, nsp, na
|
|
|
|
USE control_flags, ONLY: twfcollect, force_pairing
|
|
|
|
USE grid_dimensions, ONLY: nr1, nr2, nr3
|
|
|
|
USE electrons_nose, ONLY: xnhe0, xnhem, vnhe
|
|
|
|
USE cell_nose, ONLY: xnhh0, xnhhm, vnhh
|
|
|
|
USE ions_nose, ONLY: vnhp, xnhp0, xnhpm, nhpcl, nhpdim
|
|
|
|
USE cp_restart, ONLY: cp_readfile
|
2006-08-12 20:27:56 +08:00
|
|
|
USE io_files, ONLY: outdir
|
2004-11-26 18:12:26 +08:00
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
INTEGER, INTENT(OUT) :: nfi
|
|
|
|
COMPLEX(DP), INTENT(INOUT) :: c0(:,:), cm(:,:)
|
|
|
|
REAL(DP), INTENT(INOUT) :: occ(:)
|
2005-03-26 23:29:07 +08:00
|
|
|
TYPE (boxdimensions), INTENT(INOUT) :: ht_m, ht_0
|
2006-08-04 01:47:35 +08:00
|
|
|
TYPE (atoms_type), INTENT(INOUT) :: atoms_0, atoms_m
|
|
|
|
REAL(DP), INTENT(INOUT) :: rho(:,:)
|
|
|
|
REAL(DP), INTENT(INOUT) :: vpot(:,:)
|
|
|
|
REAL(DP), INTENT(OUT) :: taui(:,:)
|
|
|
|
REAL(DP), INTENT(OUT) :: acc(:), cdmi(:)
|
|
|
|
REAL(DP), INTENT(OUT) :: trutime
|
2006-08-11 16:29:52 +08:00
|
|
|
REAL(DP), INTENT(OUT) :: lambda(:,:,:)
|
2005-08-28 22:09:42 +08:00
|
|
|
|
|
|
|
REAL(DP) :: ekincm
|
|
|
|
REAL(DP) :: hp0_ (3,3)
|
|
|
|
REAL(DP) :: hm1_ (3,3)
|
|
|
|
REAL(DP) :: gvel_ (3,3)
|
|
|
|
REAL(DP) :: hvel_ (3,3)
|
|
|
|
REAL(DP) :: b1(3), b2(3), b3(3)
|
2004-12-21 23:48:19 +08:00
|
|
|
LOGICAL :: tens = .FALSE.
|
2004-11-26 18:12:26 +08:00
|
|
|
|
2006-06-01 18:51:33 +08:00
|
|
|
INTEGER :: nkpt = 1
|
|
|
|
REAL(DP) :: xk(3,1) = 0.0d0, wk(1) = 2.0d0
|
|
|
|
|
2006-08-12 20:27:56 +08:00
|
|
|
CALL cp_readfile( ndr, outdir, .TRUE., nfi, trutime, acc, nkpt, xk, wk, &
|
2005-03-26 23:29:07 +08:00
|
|
|
hp0_ , hm1_ , hvel_ , gvel_ , xnhh0, xnhhm, vnhh, taui, cdmi, &
|
2004-11-26 18:12:26 +08:00
|
|
|
atoms_0%taus, atoms_0%vels, atoms_m%taus, atoms_m%vels, atoms_0%for, vnhp, &
|
2006-08-11 16:29:52 +08:00
|
|
|
xnhp0, xnhpm, nhpcl, nhpdim, occ, occ, lambda, lambda, b1, b2, &
|
2006-07-17 17:15:34 +08:00
|
|
|
b3, xnhe0, xnhem, vnhe, ekincm, c0, cm )
|
2004-11-26 18:12:26 +08:00
|
|
|
|
2005-03-07 22:13:00 +08:00
|
|
|
IF( .NOT. tbeg ) THEN
|
|
|
|
CALL cell_init( ht_0, hp0_ )
|
|
|
|
CALL cell_init( ht_m, hm1_ )
|
|
|
|
ht_0%hvel = hvel_ ! set cell velocity
|
2005-03-26 23:29:07 +08:00
|
|
|
ht_0%gvel = gvel_ ! set cell velocity
|
2005-03-07 22:13:00 +08:00
|
|
|
END IF
|
|
|
|
|
2004-11-26 18:12:26 +08:00
|
|
|
RETURN
|
|
|
|
END SUBROUTINE readfile_fpmd
|
2006-08-11 16:29:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------!
|
|
|
|
SUBROUTINE set_eitot_x( eitot )
|
|
|
|
!------------------------------------------------------------------------------!
|
|
|
|
USE kinds, ONLY: DP
|
|
|
|
USE electrons_base, ONLY: nupdwn, nspin
|
|
|
|
USE electrons_module, ONLY: nupdwn_emp, ei, ei_emp, n_emp
|
|
|
|
!
|
|
|
|
IMPLICIT NONE
|
|
|
|
!
|
|
|
|
REAL(DP), INTENT(OUT) :: eitot(:,:)
|
|
|
|
!
|
|
|
|
INTEGER :: n
|
|
|
|
!
|
|
|
|
eitot = 0.0d0
|
|
|
|
!
|
|
|
|
eitot( 1:nupdwn(1), 1 ) = ei( 1:nupdwn(1), 1 )
|
|
|
|
IF( nspin == 2 ) eitot( 1:nupdwn(2), 2 ) = ei( 1:nupdwn(2), 2 )
|
|
|
|
!
|
|
|
|
IF( n_emp > 0 ) THEN
|
|
|
|
!
|
|
|
|
n = nupdwn(1)
|
|
|
|
eitot( n+1 : n+nupdwn_emp(1), 1 ) = ei_emp( 1 : nupdwn_emp(1), 1 )
|
|
|
|
IF( nspin == 2 ) THEN
|
|
|
|
n = nupdwn(2)
|
|
|
|
eitot( n+1 : n+nupdwn_emp(2), 2 ) = ei_emp( 1 : nupdwn_emp(2), 2 )
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
END SUBROUTINE set_eitot_x
|
|
|
|
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------!
|
|
|
|
SUBROUTINE set_evtot_x( c0, ctot, lambda, iupdwn_tot, nupdwn_tot )
|
|
|
|
!------------------------------------------------------------------------------!
|
2007-01-05 23:32:43 +08:00
|
|
|
USE kinds, ONLY: DP
|
|
|
|
USE electrons_base, ONLY: nupdwn, nspin, iupdwn, nudx
|
|
|
|
USE electrons_module, ONLY: nupdwn_emp, ei, ei_emp, n_emp, iupdwn_emp
|
|
|
|
USE cp_interfaces, ONLY: readempty, crot
|
|
|
|
USE cp_main_variables, ONLY: collect_lambda, descla
|
2006-08-11 16:29:52 +08:00
|
|
|
!
|
|
|
|
IMPLICIT NONE
|
|
|
|
!
|
|
|
|
COMPLEX(DP), INTENT(IN) :: c0(:,:)
|
|
|
|
COMPLEX(DP), INTENT(OUT) :: ctot(:,:)
|
|
|
|
REAL(DP), INTENT(IN) :: lambda(:,:,:)
|
|
|
|
INTEGER, INTENT(IN) :: iupdwn_tot(2), nupdwn_tot(2)
|
|
|
|
!
|
|
|
|
COMPLEX(DP), ALLOCATABLE :: cemp(:,:)
|
|
|
|
REAL(DP), ALLOCATABLE :: eitmp(:)
|
2007-01-05 23:32:43 +08:00
|
|
|
REAL(DP), ALLOCATABLE :: lambda_repl(:,:)
|
2006-08-11 16:29:52 +08:00
|
|
|
LOGICAL :: t_emp
|
|
|
|
!
|
|
|
|
ALLOCATE( eitmp( nudx ) )
|
2007-01-05 23:32:43 +08:00
|
|
|
ALLOCATE( lambda_repl( nudx, nudx ) )
|
2006-08-11 16:29:52 +08:00
|
|
|
!
|
|
|
|
ctot = 0.0d0
|
|
|
|
!
|
2007-01-05 23:32:43 +08:00
|
|
|
CALL collect_lambda( lambda_repl, lambda(:,:,1), descla(:,1) )
|
|
|
|
!
|
|
|
|
CALL crot( ctot, c0, SIZE( c0, 1 ), nupdwn(1), iupdwn_tot(1), iupdwn(1), lambda_repl, nudx, eitmp )
|
2006-08-11 16:29:52 +08:00
|
|
|
!
|
|
|
|
IF( nspin == 2 ) THEN
|
2007-01-05 23:32:43 +08:00
|
|
|
CALL collect_lambda( lambda_repl, lambda(:,:,2), descla(:,2) )
|
|
|
|
CALL crot( ctot, c0, SIZE( c0, 1 ), nupdwn(2), iupdwn_tot(2), iupdwn(2), lambda_repl, nudx, eitmp )
|
2006-08-11 16:29:52 +08:00
|
|
|
END IF
|
|
|
|
!
|
2007-01-05 23:32:43 +08:00
|
|
|
DEALLOCATE( lambda_repl )
|
|
|
|
!
|
2006-08-11 16:29:52 +08:00
|
|
|
t_emp = .FALSE.
|
|
|
|
!
|
|
|
|
IF( n_emp > 0 ) THEN
|
|
|
|
!
|
|
|
|
ALLOCATE( cemp( SIZE( c0, 1 ), n_emp * nspin ) )
|
|
|
|
cemp = 0.0d0
|
|
|
|
t_emp = readempty( cemp, n_emp * nspin )
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
IF( t_emp ) THEN
|
|
|
|
ctot( :, nupdwn( 1 )+1 : nupdwn_tot(1) ) = cemp( :, 1:nupdwn_emp( 1 ) )
|
|
|
|
IF( nspin == 2 ) THEN
|
|
|
|
ctot( :, iupdwn_tot(2) + nupdwn(2) : iupdwn_tot(2) + nupdwn_tot(1) - 1 ) = &
|
|
|
|
cemp( :, iupdwn_emp(2) : iupdwn_emp(2) + nupdwn_emp(2) - 1 )
|
|
|
|
END IF
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
IF( n_emp > 0 ) DEALLOCATE( cemp )
|
|
|
|
!
|
|
|
|
DEALLOCATE( eitmp )
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
|
|
|
|
END SUBROUTINE set_evtot_x
|