2 subroutine work_partition(lprint,ncon_work)
3 c Split the conformations between processors
8 include "COMMON.IOUNITS"
9 include "COMMON.CLUSTER"
11 integer n,chunk,i,j,ii,remainder
12 integer kolor,key,ierror,errcode,ncon_work
15 C Divide conformations between processors; the first and
16 C the last conformation to handle by ith processor is stored in
17 C indstart(i) and indend(i), respectively.
19 C First try to assign equal number of conformations to each processor.
22 write (iout,*) "n=",n," nprocs=",nprocs
26 c print *,"i",0," indstart",indstart(0)," scount",
29 indstart(i)=chunk+indstart(i-1)
31 c print *,"i",i," indstart",indstart(i)," scount",
35 C Determine how many conformations remained yet unassigned.
37 remainder=N-(indstart(nprocs-1)
38 & +scount(nprocs-1)-1)
39 c print *,"remainder",remainder
41 C Assign the remainder conformations to consecutive processors, starting
42 C from the lowest rank; this continues until the list is exhausted.
44 if (remainder .gt. 0) then
46 scount(i-1) = scount(i-1) + 1
47 indstart(i) = indstart(i) + i
49 do i=remainder+1,nprocs-1
50 indstart(i) = indstart(i) + remainder
58 indend(i)=indstart(i)+scount(i)-1
59 idispl(i)=indstart(i)-1
64 N=N+indend(i)-indstart(i)+1
67 c print *,"N",n," NCON_WORK",ncon_work
68 if (N.ne.ncon_work) then
69 write (iout,*) "!!! Checksum error on processor",me,
76 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
80 write (iout,*) "Partition of work between processors"
82 write (iout,'(a,i5,a,i7,a,i7,a,i7)')
83 & "Processor",i," indstart",indstart(i),
84 & " indend",indend(i)," count",scount(i)