5
5
! or http://www.gnu.org/copyleft/gpl.txt .
6
6
! See Docs/Contributors.txt for a list of contributors.
8
module m_compute_max_diff
9
use precision, only: dp
10
real(dp) :: dDmax_current
11
public :: compute_max_diff
12
public :: dDmax_current
14
subroutine compute_max_diff(Xin,Xout,MaxDiff)
16
use sparse_matrices, only: numh, listhptr
17
use m_spin, only: nspin
18
use atomlist, only: no_l
20
use m_mpi_utils, only: globalize_max
23
real(dp), intent(in) :: Xin(:,:), Xout(:,:)
24
real(dp), intent(out) :: MaxDiff
26
integer :: is, i, ind, in
35
ind = listhptr(i) + in
36
MaxDiff = max(MaxDiff, abs(Xout(ind,is) - Xin(ind,is)))
42
! Ensure that MaxDiff is the same on all nodes
43
call globalize_max(MaxDiff,buffer1)
47
dDmax_current = MaxDiff
49
end subroutine compute_max_diff
50
end module m_compute_max_diff
8
module m_compute_max_diff
9
use precision, only: dp
11
!> Temporary for storing the old maximum change
12
real(dp), public, save :: dDmax_current
14
interface compute_max_diff
15
module procedure compute_max_diff_1d
16
module procedure compute_max_diff_2d
17
end interface compute_max_diff
18
public :: compute_max_diff
22
subroutine compute_max_diff_2d(X1,X2, max_diff)
25
use m_mpi_utils, only: globalize_max
28
real(dp), intent(in) :: X1(:,:), X2(:,:)
29
real(dp), intent(out) :: max_diff
39
if ( size(X2, 1) /= n1 ) then
40
call die('compute_max_diff: Sizes of the arrays are not &
43
if ( size(X2, 2) /= n2 ) then
44
call die('compute_max_diff: Sizes of the arrays are not &
49
!$OMP parallel do default(shared), private(i2,i1), &
50
!$OMP& reduction(max:max_diff), collapse(2)
53
max_diff = max(max_diff, abs(X1(i1,i2) - X2(i1,i2)) )
59
! Ensure that max_diff is the same on all nodes
60
call globalize_max(max_diff, buffer1)
64
dDmax_current = max_diff
66
end subroutine compute_max_diff_2d
68
subroutine compute_max_diff_1d(X1, X2, max_diff)
71
use m_mpi_utils, only: globalize_max
74
real(dp), intent(in) :: X1(:), X2(:)
75
real(dp), intent(out) :: max_diff
84
if ( size(X2, 1) /= n1 ) then
85
call die('compute_max_diff: Sizes of the arrays are not &
90
!$OMP parallel do default(shared), private(i1), reduction(max:max_diff)
92
max_diff = max(max_diff, abs(X1(i1) - X2(i1)) )
97
! Ensure that max_diff is the same on all nodes
98
call globalize_max(max_diff, buffer1)
102
dDmax_current = max_diff
104
end subroutine compute_max_diff_1d
106
end module m_compute_max_diff