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
|
|
|
|
!
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-01-20 05:58:50 +08:00
|
|
|
use para
|
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
|
|
|
|
! one additional band if me <= resto
|
|
|
|
! counter on bands
|
|
|
|
! counter on processors
|
2003-02-08 00:04:36 +08:00
|
|
|
nb = ntodiv / nprocp
|
|
|
|
resto = ntodiv - nb * nprocp
|
|
|
|
index = 0
|
|
|
|
do ip = 1, nprocp
|
|
|
|
if (ip.le.resto) then
|
|
|
|
if (me.eq.ip) then
|
|
|
|
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
|
|
|
|
if (me.eq.ip) then
|
|
|
|
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
|
|
|
|
|