! ! Copyright (C) 2007-2009 Jesse Noffsinger, Brad Malone, Feliciano Giustino ! ! 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 . ! ! Adapted from the subroutine poolscatter in PW/para - Quantum-ESPRESSO group ! !-------------------------------------------------------------------- subroutine poolgather (nsize, nkstot, nks, f_in, f_out) !-------------------------------------------------------------------- ! ! reduce the kpoints and the electronic eigenvalues ! across the pools ! !-------------------------------------------------------------------- USE kinds, only : DP #ifdef __PARA USE mp_global, ONLY : nproc, my_pool_id, nproc_pool, & inter_pool_comm, me_pool, root_pool, mpime,kunit,npool, my_pool_id USE mp, ONLY : mp_barrier, mp_bcast,mp_sum #endif implicit none ! INTEGER :: nsize, nkstot, nks ! first dimension of vectors f_in and f_out ! number of k-points per pool ! total number of k-points REAL (KIND=DP) :: f_in(nsize,nks), f_out(nsize,nkstot) ! input ( only for k-points of mypool ) ! output ( contains values for all k-point ) INTEGER :: rest, nbase ! the rest of the integer division nkstot / npo ! the position in the original list ! ! #ifdef __PARA ! rest = nkstot / kunit - ( nkstot / kunit / npool ) * npool ! nbase = nks * my_pool_id ! IF ( ( my_pool_id + 1 ) > rest ) nbase = nbase + rest * kunit ! f_out = 0.d0 f_out(:,(nbase+1):(nbase+nks)) = f_in(:,1:nks) ! ! ... reduce across the pools ! CALL mp_sum(f_out,inter_pool_comm) ! #else f_out(:,:) = f_in(:,:) ! #endif ! end subroutine poolgather