4
public :: siesta_forces
8
subroutine siesta_forces(istep)
10
use m_setup_hamiltonian
12
use m_scfconvergence_test
16
use parallel, only: IOnode
22
integer, intent(in) :: istep
25
logical :: first, last
26
real(dp) :: dDmax ! Max. change in density matrix elements
28
!------------------------------------------------------------------------- BEGIN
30
! Initialization tasks for a given geometry
31
call state_init( istep )
33
! The current structure of the loop tries to reproduce the
34
! historical Siesta usage. It should be made more clear.
42
! The SCF loop is executed at least once,
43
! except if nscf <= 0.
49
call timer( 'IterSCF', 1 )
51
call setup_hamiltonian( first, last, iscf )
53
call compute_dm( iscf )
55
call mixer( iscf, dDmax )
57
call scfconvergence_test( first, iscf, last, dDmax )
59
call timer( 'IterSCF', 2 )
60
if (istep.eq.inicoor .and. first) call timer( 'IterSCF', 3 )
65
! The last scheduled iteration is used to compute forces
66
! and stresses, hence the exit if iscf==nscf.
67
! The ">" clause catches the nscf==1 case. For this,
69
if (iscf >= nscf) then
75
! End of standard SCF loop.
76
! Do one more pass to compute forces and stresses
79
call post_scf_work( first, last, iscf )
81
STOP 'Bad logic in SCF loop'
84
call state_analysis( istep )
86
!--------------------------------------------------------------------------- END
87
END subroutine siesta_forces
88
END module m_siesta_forces