2 !------------------------------------------------------------------------------
8 !------------------------------------------------------------------------------
11 !-----------------------------------------------------------------------------
13 !-----------------------------------------------------------------------------
15 subroutine work_partition(lprint,ncon_work)
17 subroutine work_partition(islice,lprint)
19 ! Split the conformations between processors
21 ! include "DIMENSIONS"
22 ! include "DIMENSIONS.ZSCOPT"
23 ! include "DIMENSIONS.FREE"
25 ! include "COMMON.IOUNITS"
26 ! include "COMMON.MPI"
27 ! include "COMMON.PROT"
28 integer :: islice,ncon_work
29 integer :: n,chunk,i,j,ii,remainder
31 integer :: key,ierror,errcode
34 ! Divide conformations between processors; the first and
35 ! the last conformation to handle by ith processor is stored in
36 ! indstart(i) and indend(i), respectively.
39 if (.not. allocated(indstart)) allocate(indstart(0:nprocs))
40 if (.not. allocated(indend)) allocate(indend(0:nprocs))
41 if (.not. allocated(idispl)) allocate(idispl(0:nprocs))
42 if (.not. allocated(scount)) allocate(scount(0:nprocs))
43 ! First try to assign equal number of conformations to each processor.
47 write (iout,*) "n=",n," nprocs=",nprocs
56 write(iout,*)"chunk",chunk,scount(0)
58 ! print *,"i",0," indstart",indstart(0)," scount",&
61 indstart(i)=chunk+indstart(i-1)
63 ! print *,"i",i," indstart",indstart(i)," scount",
67 ! Determine how many conformations remained yet unassigned.
69 remainder=N-(indstart(nprocs1-1) &
71 ! print *,"remainder",remainder
73 ! Assign the remainder conformations to consecutive processors, starting
74 ! from the lowest rank; this continues until the list is exhausted.
76 if (remainder .gt. 0) then
78 scount(i-1) = scount(i-1) + 1
79 indstart(i) = indstart(i) + i
81 do i=remainder+1,nprocs1-1
82 indstart(i) = indstart(i) + remainder
90 indend(i)=indstart(i)+scount(i)-1
91 idispl(i)=indstart(i)-1
96 N=N+indend(i)-indstart(i)+1
99 ! print *,"N",n," NTOT",ntot(islice)
101 if (N.ne.ncon_work) then
102 write (iout,*) "!!! Checksum error on processor",me,&
105 if (N.ne.ntot(islice)) then
106 write (iout,*) "!!! Checksum error on processor",me,&
110 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
114 write (iout,*) "Partition of work between processors"
116 write (iout,'(a,i5,a,i7,a,i7,a,i7)') &
117 "Processor",i," indstart",indstart(i),&
118 " indend",indend(i)," count",scount(i)
122 end subroutine work_partition
124 !----------------------------------------------------------------------------
126 !-----------------------------------------------------------------------------
127 !-----------------------------------------------------------------------------