Commit 39f2fb6b authored by ccavazzoni's avatar ccavazzoni

- use helper function in place of an explicit reference to type member

- bug fix, wrong task groups increment


git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@13785 c92efa57-630b-4861-b058-cf58834340f0
parent d428cd85
......@@ -145,13 +145,17 @@ SUBROUTINE cft_wave_tg (ik, evc_g, evc_r, isw, v_size, ibnd, nbnd_occ)
USE mp_bands, ONLY : me_bgrp
USE fft_interfaces, ONLY: fwfft, invfft
USE noncollin_module, ONLY : noncolin, npol
USE fft_helper_subroutines
IMPLICIT NONE
INTEGER, INTENT(in) :: ik, v_size, isw, ibnd, nbnd_occ
COMPLEX(DP), INTENT(inout) :: evc_g(npwx*npol,nbnd_occ), evc_r(v_size,npol)
INTEGER :: ig, ikk, ikq, ioff, idx, npw, npwq
INTEGER :: ig, ikk, ikq, ioff, idx, npw, npwq, ntgrp, right_inc
ntgrp = fftx_ntgrp( dffts )
CALL tg_get_recip_inc( dffts, right_inc )
IF (isw == 1) then
ikk = ikks(ik) ! points to k+G indices
......@@ -159,7 +163,7 @@ SUBROUTINE cft_wave_tg (ik, evc_g, evc_r, isw, v_size, ibnd, nbnd_occ)
evc_r = (0.0_dp, 0.0_dp)
!
ioff = 0
DO idx = 1, dffts%nproc2
DO idx = 1, ntgrp
!
IF( idx + ibnd - 1 <= nbnd_occ ) THEN
DO ig = 1, npw
......@@ -172,7 +176,7 @@ SUBROUTINE cft_wave_tg (ik, evc_g, evc_r, isw, v_size, ibnd, nbnd_occ)
ENDIF
ENDIF
!
ioff = ioff + dffts%nnr
ioff = ioff + right_inc
!
ENDDO
......@@ -186,7 +190,7 @@ SUBROUTINE cft_wave_tg (ik, evc_g, evc_r, isw, v_size, ibnd, nbnd_occ)
IF (noncolin) CALL fwfft ('tgWave', evc_r(:,2), dffts)
!
ioff = 0
DO idx = 1, dffts%nproc2
DO idx = 1, ntgrp
!
IF( idx + ibnd - 1 <= nbnd_occ ) THEN
!
......@@ -204,7 +208,7 @@ SUBROUTINE cft_wave_tg (ik, evc_g, evc_r, isw, v_size, ibnd, nbnd_occ)
!
ENDIF
!
ioff = ioff + dffts%nnr
ioff = ioff + right_inc
!
ENDDO
ELSE
......
......@@ -27,6 +27,7 @@ subroutine incdrhoscf (drhoscf, weight, ik, dbecsum, dpsi)
USE control_lr, ONLY : nbnd_occ
USE mp_bands, ONLY : me_bgrp, inter_bgrp_comm, ntask_groups
USE mp, ONLY : mp_sum
USE fft_helper_subroutines
IMPLICIT NONE
!
......@@ -52,6 +53,7 @@ subroutine incdrhoscf (drhoscf, weight, ik, dbecsum, dpsi)
INTEGER :: npw, npwq, ikk, ikq
INTEGER :: ibnd, ir, ir3, ig, incr, v_siz, idx, ioff, ioff_tg, nxyp
INTEGER :: right_inc, ntgrp
! counters
CALL start_clock ('incdrhoscf')
......@@ -74,7 +76,7 @@ subroutine incdrhoscf (drhoscf, weight, ik, dbecsum, dpsi)
ALLOCATE( tg_dpsi( v_siz ) )
ALLOCATE( tg_drho( v_siz ) )
!
incr = dffts%nproc2
incr = fftx_ntgrp(dffts)
!
ENDIF
!
......@@ -90,8 +92,10 @@ subroutine incdrhoscf (drhoscf, weight, ik, dbecsum, dpsi)
tg_dpsi=(0.0_DP, 0.0_DP)
!
ioff = 0
CALL tg_get_recip_inc( dffts, right_inc )
ntgrp = fftx_ntgrp( dffts )
!
DO idx = 1, dffts%nproc2
DO idx = 1, ntgrp
!
! ... dtgs%nogrp ffts at the same time. We prepare both
! evc (at k) and dpsi (at k+q)
......@@ -107,7 +111,7 @@ subroutine incdrhoscf (drhoscf, weight, ik, dbecsum, dpsi)
!
END IF
!
ioff = ioff + dffts%nnr
ioff = ioff + right_inc
!
END DO
CALL invfft ('tgWave', tg_psi, dffts)
......@@ -120,16 +124,7 @@ subroutine incdrhoscf (drhoscf, weight, ik, dbecsum, dpsi)
! reduce the group charge (equivalent to sum over bands of
! orbital group)
!
CALL mp_sum( tg_drho, gid = dffts%comm2 )
!
! copy the charge back to the proper processor location
!
nxyp = dffts%nr1x * dffts%my_nr2p
DO ir3 = 1, dffts%my_nr3p
ioff = dffts%nr1x * dffts%my_nr2p * (ir3-1)
ioff_tg = dffts%nr1x * dffts%nr2x * (ir3-1) + dffts%nr1x * dffts%my_i0r2p
drhoscf(ioff+1:ioff+nxyp) = drhoscf(ioff+1:ioff+nxyp) + tg_drho(ioff_tg+1:ioff_tg+nxyp)
END DO
CALL tg_reduce_rho( drhoscf, tg_drho, dffts )
!
ELSE
!
......
......@@ -30,6 +30,7 @@ subroutine incdrhoscf_nc (drhoscf, weight, ik, dbecsum, dpsi)
USE control_lr, ONLY : nbnd_occ
USE mp_bands, ONLY : me_bgrp, inter_bgrp_comm, ntask_groups
USE mp, ONLY : mp_sum
USE fft_helper_subroutines
IMPLICIT NONE
!
......@@ -56,6 +57,7 @@ subroutine incdrhoscf_nc (drhoscf, weight, ik, dbecsum, dpsi)
!
INTEGER :: npw, npwq, ikk, ikq
INTEGER :: ibnd, jbnd, ir, ir3, ig, incr, v_siz, idx, ioff, ioff_tg, nxyp
INTEGER :: ntgrp, right_inc
! counters
!
CALL start_clock ('incdrhoscf')
......@@ -78,7 +80,7 @@ subroutine incdrhoscf_nc (drhoscf, weight, ik, dbecsum, dpsi)
ALLOCATE( tg_dpsi( v_siz, npol ) )
ALLOCATE( tg_drho( v_siz, nspin_mag ) )
!
incr = dffts%nproc2
incr = fftx_ntgrp(dffts)
!
ENDIF
!
......@@ -94,8 +96,10 @@ subroutine incdrhoscf_nc (drhoscf, weight, ik, dbecsum, dpsi)
tg_dpsi=(0.0_DP, 0.0_DP)
!
ioff = 0
CALL tg_get_recip_inc( dffts, right_inc )
ntgrp = fftx_ntgrp( dffts )
!
DO idx = 1, dffts%nproc2
DO idx = 1, ntgrp
!
! ... dtgs%nogrp ffts at the same time. We prepare both
! evc (at k) and dpsi (at k+q)
......@@ -113,7 +117,7 @@ subroutine incdrhoscf_nc (drhoscf, weight, ik, dbecsum, dpsi)
!
END IF
!
ioff = ioff + dffts%nnr
ioff = ioff + right_inc
!
END DO
CALL invfft ('tgWave', tg_psi(:,1), dffts)
......@@ -139,17 +143,7 @@ subroutine incdrhoscf_nc (drhoscf, weight, ik, dbecsum, dpsi)
! reduce the group charge (equivalent to sum over the bands of the
! orbital group)
!
CALL mp_sum( tg_drho, gid = dffts%comm2 )
!
! copy the charge back to the proper processor location
!
nxyp = dffts%nr1x * dffts%my_nr2p
DO ir3 = 1, dffts%my_nr3p
ioff = dffts%nr1x * dffts%my_nr2p * (ir3-1)
ioff_tg = dffts%nr1x * dffts%nr2x * (ir3-1) + dffts%nr1x * dffts%my_i0r2p
drhoscf(ioff+1:ioff+nxyp,1:nspin_mag) = drhoscf(ioff+1:ioff+nxyp,1:nspin_mag) &
+ tg_drho(ioff_tg+1:ioff_tg+nxyp,1:nspin_mag)
END DO
CALL tg_reduce_rho( drhoscf, tg_drho, dffts )
!
ELSE
!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment