2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2001 PWSCF group
|
|
|
|
! 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-02-08 00:04:36 +08:00
|
|
|
subroutine divide (ntodiv, startn, lastn)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! Divide the bands among processors in the phonon code
|
|
|
|
!
|
2004-09-27 17:11:56 +08:00
|
|
|
USE mp_global, ONLY : me_pool, nproc_pool
|
|
|
|
!
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2004-09-27 17:11:56 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: ntodiv, startn, lastn
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the number to divide
|
2003-04-23 00:03:45 +08:00
|
|
|
! output: the first band of this processor
|
2003-01-20 05:58:50 +08:00
|
|
|
! output: the last band of this processor
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: nb, resto, index, ip
|
2003-01-20 05:58:50 +08:00
|
|
|
! number of bands per processor
|
2004-09-27 17:11:56 +08:00
|
|
|
! one additional band if me_pool+1 <= resto
|
2003-01-20 05:58:50 +08:00
|
|
|
! counter on bands
|
|
|
|
! counter on processors
|
2004-09-27 17:11:56 +08:00
|
|
|
nb = ntodiv / nproc_pool
|
|
|
|
resto = ntodiv - nb * nproc_pool
|
2003-02-08 00:04:36 +08:00
|
|
|
index = 0
|
2004-09-27 17:11:56 +08:00
|
|
|
do ip = 1, nproc_pool
|
2003-02-08 00:04:36 +08:00
|
|
|
if (ip.le.resto) then
|
2004-09-27 17:11:56 +08:00
|
|
|
if (me_pool+1.eq.ip) then
|
2003-02-08 00:04:36 +08:00
|
|
|
startn = index + 1
|
|
|
|
lastn = startn + nb
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
index = index + nb + 1
|
|
|
|
else
|
2004-09-27 17:11:56 +08:00
|
|
|
if (me_pool+1.eq.ip) then
|
2003-02-08 00:04:36 +08:00
|
|
|
startn = index + 1
|
|
|
|
lastn = startn + nb - 1
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
index = index + nb
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
#else
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: ntodiv, startn, lastn
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the number to divide among proce
|
|
|
|
! output: the first band of this processo
|
|
|
|
! output: the last band of this processor
|
2003-02-08 00:04:36 +08:00
|
|
|
startn = 1
|
|
|
|
lastn = ntodiv
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
end subroutine divide
|
|
|
|
|